2020-09-01 04:54:39 +03:00
|
|
|
:: metadata-hook [landscape]:
|
|
|
|
::
|
|
|
|
:: allow syncing foreign metadata
|
2020-02-15 03:31:52 +03:00
|
|
|
::
|
2020-02-22 03:13:22 +03:00
|
|
|
:: watch paths:
|
|
|
|
:: /group/%group-path all updates related to this group
|
|
|
|
::
|
2020-02-19 04:35:00 +03:00
|
|
|
/- *metadata-store, *metadata-hook
|
2020-05-25 08:52:54 +03:00
|
|
|
/+ default-agent, dbug, verb, grpl=group
|
2020-04-03 00:49:46 +03:00
|
|
|
~% %metadata-hook-top ..is ~
|
2020-02-15 03:31:52 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
2020-02-21 01:55:46 +03:00
|
|
|
+$ versioned-state
|
2020-02-15 03:31:52 +03:00
|
|
|
$% state-zero
|
2020-07-23 08:02:54 +03:00
|
|
|
state-one
|
2020-02-15 03:31:52 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state-zero
|
|
|
|
$: %0
|
2020-02-19 04:35:00 +03:00
|
|
|
synced=(map group-path ship)
|
2020-02-15 03:31:52 +03:00
|
|
|
==
|
2020-07-23 08:02:54 +03:00
|
|
|
+$ state-one
|
|
|
|
$: %1
|
|
|
|
synced=(map group-path ship)
|
|
|
|
==
|
2020-02-15 03:31:52 +03:00
|
|
|
--
|
2020-07-23 08:02:54 +03:00
|
|
|
=| state-one
|
2020-02-15 03:31:52 +03:00
|
|
|
=* state -
|
2020-03-27 03:30:30 +03:00
|
|
|
%- agent:dbug
|
2020-05-25 08:52:54 +03:00
|
|
|
%+ verb |
|
2020-02-15 03:31:52 +03:00
|
|
|
^- agent:gall
|
|
|
|
=<
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
2020-02-20 04:56:36 +03:00
|
|
|
hc ~(. +> bowl)
|
2020-02-15 03:31:52 +03:00
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
::
|
2020-02-19 04:35:00 +03:00
|
|
|
++ on-init
|
2020-02-20 04:56:36 +03:00
|
|
|
[[%pass /updates %agent [our.bowl %metadata-store] %watch /updates]~ this]
|
2020-02-15 03:31:52 +03:00
|
|
|
::
|
2020-02-19 04:35:00 +03:00
|
|
|
++ on-save !>(state)
|
2020-09-01 04:54:39 +03:00
|
|
|
++ on-load
|
2020-07-23 08:02:54 +03:00
|
|
|
|= =vase
|
|
|
|
=/ old
|
|
|
|
!<(versioned-state vase)
|
|
|
|
?: ?=(%1 -.old)
|
|
|
|
`this(state old)
|
|
|
|
:: groups OTA did not migrate metadata syncs
|
|
|
|
:: we clear our syncs, and wait for metadata-store
|
|
|
|
:: to poke us with the syncs
|
|
|
|
`this
|
|
|
|
::
|
2020-02-15 03:31:52 +03:00
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
2020-02-19 04:35:00 +03:00
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%metadata-hook-action
|
|
|
|
=^ cards state
|
|
|
|
(poke-hook-action:hc !<(metadata-hook-action vase))
|
|
|
|
[cards this]
|
2020-03-03 03:50:20 +03:00
|
|
|
::
|
|
|
|
%metadata-action
|
|
|
|
[(poke-action:hc !<(metadata-action vase)) this]
|
2020-05-19 23:53:55 +03:00
|
|
|
==
|
2020-02-15 03:31:52 +03:00
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
2020-02-19 04:35:00 +03:00
|
|
|
?+ path (on-watch:def path)
|
2020-02-20 04:56:36 +03:00
|
|
|
[%group *] [(watch-group:hc t.path) this]
|
2020-02-19 04:35:00 +03:00
|
|
|
==
|
2020-02-15 03:31:52 +03:00
|
|
|
::
|
|
|
|
++ on-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card _this)
|
|
|
|
?+ -.sign (on-agent:def wire sign)
|
2020-02-20 04:56:36 +03:00
|
|
|
%kick =^(cards state (kick:hc wire) [cards this])
|
|
|
|
%watch-ack =^(cards state (watch-ack:hc wire p.sign) [cards this])
|
2020-02-15 03:31:52 +03:00
|
|
|
%fact
|
|
|
|
?+ p.cage.sign (on-agent:def wire sign)
|
|
|
|
%metadata-update
|
|
|
|
=^ cards state
|
2020-02-19 04:35:00 +03:00
|
|
|
(fact-metadata-update:hc wire !<(metadata-update q.cage.sign))
|
2020-02-15 03:31:52 +03:00
|
|
|
[cards this]
|
|
|
|
==
|
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
2020-02-20 04:56:36 +03:00
|
|
|
|_ =bowl:gall
|
2020-05-25 08:52:54 +03:00
|
|
|
+* grp ~(. grpl bowl)
|
2020-02-19 04:35:00 +03:00
|
|
|
++ poke-hook-action
|
|
|
|
|= act=metadata-hook-action
|
|
|
|
^- (quip card _state)
|
|
|
|
|^
|
|
|
|
?- -.act
|
|
|
|
%add-owned
|
2020-02-20 04:56:36 +03:00
|
|
|
?> (team:title our.bowl src.bowl)
|
2020-02-19 04:35:00 +03:00
|
|
|
:- ~
|
|
|
|
?: (~(has by synced) path.act) state
|
2020-02-20 04:56:36 +03:00
|
|
|
state(synced (~(put by synced) path.act our.bowl))
|
2020-02-19 04:35:00 +03:00
|
|
|
::
|
|
|
|
%add-synced
|
2020-02-20 04:56:36 +03:00
|
|
|
?> (team:title our.bowl src.bowl)
|
2020-02-19 04:35:00 +03:00
|
|
|
=/ =path [%group path.act]
|
|
|
|
?: (~(has by synced) path.act) [~ state]
|
|
|
|
:_ state(synced (~(put by synced) path.act ship.act))
|
|
|
|
[%pass path %agent [ship.act %metadata-hook] %watch path]~
|
|
|
|
::
|
|
|
|
%remove
|
|
|
|
=/ ship (~(get by synced) path.act)
|
|
|
|
?~ ship [~ state]
|
2020-02-22 03:13:22 +03:00
|
|
|
?: &(!=(u.ship src.bowl) ?!((team:title our.bowl src.bowl)))
|
2020-02-19 04:35:00 +03:00
|
|
|
[~ state]
|
|
|
|
:_ state(synced (~(del by synced) path.act))
|
|
|
|
%- zing
|
2020-02-20 04:56:36 +03:00
|
|
|
:~ (unsubscribe [%group path.act] u.ship)
|
2020-02-19 04:35:00 +03:00
|
|
|
[%give %kick ~[[%group path.act]] ~]~
|
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ unsubscribe
|
2020-02-20 04:56:36 +03:00
|
|
|
|= [=path =ship]
|
2020-02-19 04:35:00 +03:00
|
|
|
^- (list card)
|
2020-02-20 04:56:36 +03:00
|
|
|
?: =(ship our.bowl)
|
|
|
|
[%pass path %agent [our.bowl %metadata-store] %leave ~]~
|
|
|
|
[%pass path %agent [ship %metadata-hook] %leave ~]~
|
2020-02-19 04:35:00 +03:00
|
|
|
--
|
|
|
|
::
|
2020-03-03 03:50:20 +03:00
|
|
|
++ poke-action
|
|
|
|
|= act=metadata-action
|
|
|
|
^- (list card)
|
|
|
|
|^
|
|
|
|
?: (team:title our.bowl src.bowl)
|
|
|
|
?- -.act
|
|
|
|
%add (send group-path.act)
|
|
|
|
%remove (send group-path.act)
|
|
|
|
==
|
2020-07-02 05:17:28 +03:00
|
|
|
?> (is-member:grp src.bowl group-path.act)
|
2020-03-03 03:50:20 +03:00
|
|
|
?- -.act
|
|
|
|
%add (metadata-poke our.bowl %metadata-store)
|
|
|
|
%remove (metadata-poke our.bowl %metadata-store)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ send
|
|
|
|
|= =group-path
|
|
|
|
^- (list card)
|
|
|
|
=/ =ship
|
|
|
|
%+ slav %p
|
|
|
|
(snag 1 group-path)
|
|
|
|
=/ app ?:(=(ship our.bowl) %metadata-store %metadata-hook)
|
|
|
|
(metadata-poke ship app)
|
|
|
|
::
|
|
|
|
++ metadata-poke
|
|
|
|
|= [=ship app=@tas]
|
|
|
|
^- (list card)
|
|
|
|
[%pass / %agent [ship app] %poke %metadata-action !>(act)]~
|
|
|
|
::
|
|
|
|
++ is-managed
|
|
|
|
|= =path
|
|
|
|
^- ?
|
|
|
|
?> ?=(^ path)
|
|
|
|
!=(i.path '~')
|
|
|
|
--
|
|
|
|
::
|
2020-02-19 04:35:00 +03:00
|
|
|
++ watch-group
|
|
|
|
|= =path
|
|
|
|
^- (list card)
|
2020-02-21 01:55:46 +03:00
|
|
|
|^
|
2020-02-22 03:13:22 +03:00
|
|
|
?> =(our.bowl (~(got by synced) path))
|
2020-07-02 05:17:28 +03:00
|
|
|
?> (is-member:grp src.bowl path)
|
2020-02-21 01:55:46 +03:00
|
|
|
%+ turn ~(tap by (metadata-scry path))
|
2020-06-08 10:53:16 +03:00
|
|
|
|= [[=group-path =md-resource] =metadata]
|
2020-02-21 01:55:46 +03:00
|
|
|
^- card
|
2020-06-08 10:53:16 +03:00
|
|
|
[%give %fact ~ %metadata-update !>([%add group-path md-resource metadata])]
|
2020-02-21 01:55:46 +03:00
|
|
|
::
|
|
|
|
++ metadata-scry
|
|
|
|
|= pax=^path
|
|
|
|
^- associations
|
2020-05-19 23:53:55 +03:00
|
|
|
=. pax
|
|
|
|
;: weld
|
|
|
|
/(scot %p our.bowl)/metadata-store/(scot %da now.bowl)/group
|
|
|
|
pax
|
|
|
|
/noun
|
|
|
|
==
|
2020-02-28 01:54:03 +03:00
|
|
|
.^(associations %gx pax)
|
2020-02-21 01:55:46 +03:00
|
|
|
--
|
2020-02-19 04:35:00 +03:00
|
|
|
::
|
|
|
|
++ fact-metadata-update
|
|
|
|
|= [wir=wire fact=metadata-update]
|
|
|
|
^- (quip card _state)
|
|
|
|
|^
|
2020-02-20 04:56:36 +03:00
|
|
|
[?:((team:title our.bowl src.bowl) handle-local handle-foreign) state]
|
2020-02-19 04:35:00 +03:00
|
|
|
::
|
|
|
|
++ handle-local
|
|
|
|
?+ -.fact ~
|
|
|
|
%add
|
2020-02-20 04:56:36 +03:00
|
|
|
?. (~(has by synced) group-path.fact) ~
|
|
|
|
(give group-path.fact fact)
|
2020-02-19 04:35:00 +03:00
|
|
|
::
|
|
|
|
%update-metadata
|
2020-02-20 04:56:36 +03:00
|
|
|
?. (~(has by synced) group-path.fact) ~
|
|
|
|
(give group-path.fact fact)
|
2020-02-19 04:35:00 +03:00
|
|
|
::
|
|
|
|
%remove
|
2020-02-20 04:56:36 +03:00
|
|
|
?. (~(has by synced) group-path.fact) ~
|
|
|
|
(give group-path.fact fact)
|
2020-02-19 04:35:00 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-foreign
|
|
|
|
?+ -.fact ~
|
|
|
|
%add
|
2020-02-20 04:56:36 +03:00
|
|
|
?. =(src.bowl (~(got by synced) group-path.fact)) ~
|
|
|
|
(poke fact)
|
2020-02-19 04:35:00 +03:00
|
|
|
::
|
|
|
|
%update-metadata
|
2020-02-20 04:56:36 +03:00
|
|
|
?. =(src.bowl (~(got by synced) group-path.fact)) ~
|
|
|
|
(poke [%add +.fact])
|
2020-02-19 04:35:00 +03:00
|
|
|
::
|
|
|
|
%remove
|
2020-02-20 04:56:36 +03:00
|
|
|
?. =(src.bowl (~(got by synced) group-path.fact)) ~
|
|
|
|
(poke fact)
|
2020-02-19 04:35:00 +03:00
|
|
|
==
|
2020-02-20 04:56:36 +03:00
|
|
|
::
|
|
|
|
++ give
|
|
|
|
|= [=path upd=metadata-update]
|
|
|
|
^- (list card)
|
|
|
|
[%give %fact ~[[%group path]] %metadata-update !>(upd)]~
|
|
|
|
::
|
|
|
|
++ poke
|
|
|
|
|= act=metadata-action
|
|
|
|
^- (list card)
|
|
|
|
[%pass / %agent [our.bowl %metadata-store] %poke %metadata-action !>(act)]~
|
2020-02-19 04:35:00 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ kick
|
|
|
|
|= wir=wire
|
|
|
|
^- (quip card _state)
|
2020-02-21 01:55:46 +03:00
|
|
|
:_ state
|
|
|
|
?+ wir !!
|
|
|
|
[%updates ~]
|
|
|
|
[%pass /updates %agent [our.bowl %metadata-store] %watch /updates]~
|
|
|
|
::
|
|
|
|
[%group @ *]
|
|
|
|
?. (~(has by synced) t.wir) ~
|
|
|
|
=/ =ship (~(got by synced) t.wir)
|
|
|
|
?: =(ship our.bowl)
|
|
|
|
[%pass wir %agent [our.bowl %metadata-store] %watch wir]~
|
|
|
|
[%pass wir %agent [ship %metadata-hook] %watch wir]~
|
|
|
|
==
|
2020-02-19 04:35:00 +03:00
|
|
|
::
|
2020-02-15 03:31:52 +03:00
|
|
|
++ watch-ack
|
|
|
|
|= [wir=wire saw=(unit tang)]
|
|
|
|
^- (quip card _state)
|
|
|
|
?> ?=(^ wir)
|
2020-02-21 01:55:46 +03:00
|
|
|
[~ ?~(saw state state(synced (~(del by synced) t.wir)))]
|
2020-03-03 03:50:20 +03:00
|
|
|
::
|
2020-02-15 03:31:52 +03:00
|
|
|
--
|