apps: reorder maps, sets, and jugs

This commit is contained in:
Isaac Visintainer 2020-12-01 23:03:05 -08:00
parent a779ca4d7e
commit 1d6a460345
10 changed files with 246 additions and 24 deletions

View File

@ -8,7 +8,7 @@
view=chat-view,
*group
/+ default-agent, verb, dbug, store=chat-store, group-store, grpl=group,
resource
resource, *migrate
~% %chat-hook-top ..is ~
|%
+$ card card:agent:gall
@ -704,7 +704,12 @@
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-10 ;;(state-10 arc)
=/ sty=state-10
:* %10
(remake-map ;;((tree [path ship]) -.arc))
;;(? +<.arc)
(remake-map ;;((tree [path ?]) +>.arc))
==
:_ sty
%+ turn ~(tap by synced.sty)
|= [=path =ship]

View File

@ -2,7 +2,7 @@
::
:: data store that holds linear sequences of chat messages
::
/+ store=chat-store, default-agent, verb, dbug, group-store
/+ store=chat-store, default-agent, verb, dbug, group-store, *migrate
~% %chat-store-top ..is ~
|%
+$ card card:agent:gall
@ -242,7 +242,7 @@
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-3 ;;(state-3 arc)
=/ sty=state-3 [%3 (remake-map ;;((tree [path mailbox:store]) +.arc))]
[~ sty]
::
++ handle-create

View File

@ -8,7 +8,14 @@
*metadata-hook,
*metadata-store,
*group
/+ *contact-json, default-agent, dbug, group-store, verb, resource, grpl=group
/+ *contact-json,
default-agent,
dbug,
group-store,
verb,
resource,
grpl=group,
*migrate
~% %contact-hook-top ..is ~
|%
+$ card card:agent:gall
@ -286,7 +293,8 @@
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-three ;;(state-three arc)
=/ sty=state-three
[%3 (remake-map ;;((tree [path ship]) +<.arc)) ;;(? +>.arc)]
:_ sty
%+ turn ~(tap by synced.sty)
|= [=path =ship]

View File

@ -2,7 +2,7 @@
::
:: data store that holds group-based contact data
::
/+ *contact-json, default-agent, dbug
/+ *contact-json, default-agent, dbug, *migrate
|%
+$ card card:agent:gall
+$ versioned-state
@ -207,7 +207,10 @@
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-three ;;(state-three arc)
=/ sty=state-three
:- %3
%- remake-map-of-map
;;((tree [path (tree [ship contact])]) +.arc)
[~ sty]
::
++ handle-create

View File

@ -1,7 +1,8 @@
:: graph-store [landscape]
::
::
/+ store=graph-store, sigs=signatures, res=resource, default-agent, dbug
/+ store=graph-store, sigs=signatures, res=resource, default-agent, dbug,
*migrate
~% %graph-store-top ..is ~
|%
+$ card card:agent:gall
@ -617,7 +618,8 @@
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty ;;(state-2 arc)
|^
=/ sty=state-2 [%2 (remake-network ;;(tree-network +.arc))]
:_ sty
%+ turn ~(tap by graphs.sty)
|= [rid=resource:store =marked-graph:store]
@ -626,6 +628,130 @@
=/ =cage [%push-hook-action !>([%add rid])]
[%pass / %agent [our.bowl %graph-push-hook] %poke cage]
(try-rejoin rid 0)
::
+$ tree-network
$: graphs=tree-graphs
tag-queries=(tree [term (tree resource:store)])
update-logs=tree-update-logs
archive=tree-graphs
validators=(tree ^mark)
==
+$ tree-graphs (tree [resource:store tree-marked-graph])
+$ tree-marked-graph [p=tree-graph q=(unit ^mark)]
+$ tree-graph (tree [atom tree-node])
+$ tree-node [post=tree-post children=tree-internal-graph]
+$ tree-internal-graph
$~ [%empty ~]
$% [%graph p=tree-graph]
[%empty ~]
==
+$ tree-update-logs (tree [resource:store tree-update-log])
+$ tree-update-log (tree [time tree-logged-update])
+$ tree-logged-update
$: %0
p=time
$= q
$% [%add-nodes =resource:store nodes=(tree [index:store tree-node])]
[%remove-nodes =resource:store indices=(tree index:store)]
[%add-signatures =uid:store signatures=tree-signatures]
[%remove-signatures =uid:store signatures=tree-signatures]
==
==
+$ tree-signatures (tree signature:store)
+$ tree-post
$: author=ship
=index:store
time-sent=time
contents=(list content:store)
hash=(unit hash:store)
signatures=tree-signatures
==
::
++ remake-network
|= t=tree-network
^- network:store
:* (remake-graphs graphs.t)
(remake-jug tag-queries.t)
(remake-update-logs update-logs.t)
(remake-graphs archive.t)
(remake-set validators.t)
==
::
++ remake-graphs
|= t=tree-graphs
^- graphs:store
%- remake-map
(~(run by t) remake-marked-graph)
::
++ remake-marked-graph
|= t=tree-marked-graph
^- marked-graph:store
[(remake-graph p.t) q.t]
::
++ remake-graph
|= t=tree-graph
^- graph:store
%+ gas:orm *graph:store
%+ turn ~(tap by t)
|= [a=atom tn=tree-node]
^- [atom node:store]
[a (remake-node tn)]
::
++ remake-internal-graph
|= t=tree-internal-graph
^- internal-graph:store
?: ?=(%empty -.t)
[%empty ~]
[%graph (remake-graph p.t)]
::
++ remake-node
|= t=tree-node
^- node:store
:- (remake-post post.t)
(remake-internal-graph children.t)
::
++ remake-update-logs
|= t=tree-update-logs
^- update-logs:store
%- remake-map
(~(run by t) remake-update-log)
::
++ remake-update-log
|= t=tree-update-log
^- update-log:store
=/ ulm ((ordered-map time logged-update:store) gth)
%+ gas:ulm *update-log:store
%+ turn ~(tap by t)
|= [=time tlu=tree-logged-update]
^- [^time logged-update:store]
[time (remake-logged-update tlu)]
::
++ remake-logged-update
|= t=tree-logged-update
^- logged-update:store
:+ %0 p.t
?- -.q.t
%add-nodes
:- %add-nodes
:- resource.q.t
%- remake-map
(~(run by nodes.q.t) remake-node)
::
%remove-nodes
[%remove-nodes resource.q.t (remake-set indices.q.t)]
::
%add-signatures
[%add-signatures uid.q.t (remake-set signatures.q.t)]
::
%remove-signatures
[%remove-signatures uid.q.t (remake-set signatures.q.t)]
==
::
++ remake-post
|= t=tree-post
^- post:store
t(signatures (remake-set signatures.t))
--
::
++ try-rejoin
|= [rid=resource:store nack-count=@]

View File

@ -30,7 +30,7 @@
::
::
/- *group, permission-store, *contact-view
/+ store=group-store, default-agent, verb, dbug, resource
/+ store=group-store, default-agent, verb, dbug, resource, *migrate
|%
+$ card card:agent:gall
::
@ -285,23 +285,61 @@
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-one ;;(state-one arc)
|^
=/ sty=state-one
[%1 (remake-groups ;;((tree [resource tree-group]) +.arc))]
:_ sty
%+ roll ~(tap by groups.sty)
|= [[=resource =group] out=(list card)]
?: =(entity.resource our.bol)
|= [[rid=resource grp=group] out=(list card)]
?: =(entity.rid our.bol)
%+ weld out
%+ roll ~(tap in members.group)
%+ roll ~(tap in members.grp)
|= [recipient=@p out=(list card)]
?: =(recipient our.bol)
out
:_ out
%- poke-contact
:* %invite resource recipient
(crip "Rejoin disconnected group {<entity.resource>}/{<name.resource>}")
:* %invite rid recipient
(crip "Rejoin disconnected group {<entity.rid>}/{<name.rid>}")
==
:_ out
(try-rejoin resource 0)
(try-rejoin rid 0)
::
++ remake-groups
|= grps=(tree [resource tree-group])
^- ^groups
%- remake-map
(~(run by grps) remake-group)
::
++ remake-group
|= grp=tree-group
^- group
%= grp
members (remake-set members.grp)
tags (remake-jug tags.grp)
policy (remake-policy policy.grp)
==
::
+$ tree-group
$: members=(tree ship)
tags=(tree [tag (tree ship)])
policy=tree-policy
hidden=?
==
::
+$ tree-policy
$% [%invite pending=(tree ship)]
[%open ban-ranks=(tree rank:title) banned=(tree ship)]
==
::
++ remake-policy
|= pl=tree-policy
^- policy
?- -.pl
%invite [%invite (remake-set pending.pl)]
%open [%open (remake-set ban-ranks.pl) (remake-set banned.pl)]
==
--
::
++ try-rejoin
|= [rid=resource nack-count=@ud]

View File

@ -1,6 +1,6 @@
:: invite-store [landscape]
/- store=invite-store
/+ res=resource, default-agent, dbug
/+ res=resource, default-agent, dbug, *migrate
|%
+$ card card:agent:gall
+$ versioned-state
@ -109,7 +109,10 @@
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-1 ;;(state-1 arc)
=/ sty=state-1
:- %1
%- remake-map-of-map
;;((tree [term (tree [serial:store invite:store])]) +.arc)
[~ sty]
::
++ poke-invite-action

View File

@ -6,7 +6,7 @@
:: /group/%group-path all updates related to this group
::
/- *metadata-store, *metadata-hook
/+ default-agent, dbug, verb, grpl=group
/+ default-agent, dbug, verb, grpl=group, *migrate
~% %metadata-hook-top ..is ~
|%
+$ card card:agent:gall
@ -196,7 +196,8 @@
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-one ;;(state-one arc)
=/ sty=state-one
[%1 (remake-map ;;((tree [group-path ship]) +.arc))]
:_ sty
%+ murn ~(tap by synced.sty)
|= [=group-path =ship]

View File

@ -24,7 +24,7 @@
:: /group/%group-path associations for group
::
/- *metadata-store, *metadata-hook
/+ *metadata-json, default-agent, verb, dbug, resource
/+ *metadata-json, default-agent, verb, dbug, resource, *migrate
|%
+$ card card:agent:gall
+$ base-state-0
@ -378,8 +378,27 @@
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-6 ;;(state-6 arc)
|^
=/ sty=state-6
[%6 (remake-metadata ;;(tree-metadata +.arc))]
[~ sty]
::
+$ tree-metadata
$: associations=(tree [[group-path md-resource] metadata])
group-indices=(tree [group-path (tree md-resource)])
app-indices=(tree [app-name (tree [group-path app-path])])
resource-indices=(tree [md-resource (tree group-path)])
==
::
++ remake-metadata
|= tm=tree-metadata
^- base-state-1
:* (remake-map associations.tm)
(remake-jug group-indices.tm)
(remake-jug app-indices.tm)
(remake-jug resource-indices.tm)
==
--
::
++ handle-add
|= [=group-path =md-resource =metadata]

19
pkg/arvo/lib/migrate.hoon Normal file
View File

@ -0,0 +1,19 @@
|%
++ remake-set
|* s=(tree)
(sy ~(tap in s))
::
++ remake-map
|* m=(tree)
(my ~(tap by m))
::
++ remake-jug
|* j=(tree [* (tree)])
%- remake-map
(~(run by j) remake-set)
::
++ remake-map-of-map
|* mm=(tree [* (tree)])
%- remake-map
(~(run by mm) remake-map)
--