2020-09-01 04:54:39 +03:00
|
|
|
:: graph-store [landscape]
|
|
|
|
::
|
2021-04-14 22:26:36 +03:00
|
|
|
/+ store=graph-store, sigs=signatures, res=resource, default-agent, dbug, verb
|
2020-12-05 07:32:17 +03:00
|
|
|
~% %graph-store-top ..part ~
|
2020-06-02 00:07:31 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
+$ versioned-state
|
2021-04-14 22:26:36 +03:00
|
|
|
$% [%0 network:zero:store]
|
|
|
|
[%1 network:zero:store]
|
|
|
|
[%2 network:zero:store]
|
|
|
|
[%3 network:one:store]
|
2021-04-30 15:16:48 +03:00
|
|
|
[%4 network:store]
|
|
|
|
state-5
|
2020-06-02 00:07:31 +03:00
|
|
|
==
|
2020-06-23 21:09:31 +03:00
|
|
|
::
|
2021-04-30 15:16:48 +03:00
|
|
|
+$ state-5 [%5 network:store]
|
2020-06-10 23:47:18 +03:00
|
|
|
++ orm orm:store
|
|
|
|
++ orm-log orm-log:store
|
2020-11-12 23:00:59 +03:00
|
|
|
+$ debug-input [%validate-graph =resource:store]
|
2021-05-10 20:09:47 +03:00
|
|
|
::
|
|
|
|
+$ cache
|
|
|
|
$: validators=(map mark dais:clay)
|
|
|
|
==
|
|
|
|
::
|
2021-05-11 02:23:42 +03:00
|
|
|
:: TODO: come back to this and potentially use ford runes or otherwise
|
|
|
|
:: send a %t to be notified of validator changes
|
2021-05-10 20:09:47 +03:00
|
|
|
+$ inflated-state
|
|
|
|
$: state-5
|
|
|
|
cache
|
|
|
|
==
|
2020-06-02 00:07:31 +03:00
|
|
|
--
|
|
|
|
::
|
2021-05-10 20:09:47 +03:00
|
|
|
=| inflated-state
|
2020-06-02 00:07:31 +03:00
|
|
|
=* state -
|
|
|
|
::
|
|
|
|
%- agent:dbug
|
2021-02-03 22:08:53 +03:00
|
|
|
%+ verb |
|
2020-06-02 00:07:31 +03:00
|
|
|
^- agent:gall
|
2020-06-23 19:16:12 +03:00
|
|
|
~% %graph-store-agent ..card ~
|
2020-06-02 00:07:31 +03:00
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
::
|
|
|
|
++ on-init [~ this]
|
2021-05-10 20:09:47 +03:00
|
|
|
++ on-save !>(-.state)
|
2020-06-02 00:07:31 +03:00
|
|
|
++ on-load
|
2020-10-29 06:11:18 +03:00
|
|
|
|= =old=vase
|
2020-06-02 00:07:31 +03:00
|
|
|
^- (quip card _this)
|
2020-10-29 06:11:18 +03:00
|
|
|
=+ !<(old=versioned-state old-vase)
|
|
|
|
=| cards=(list card)
|
2021-04-13 23:37:32 +03:00
|
|
|
|-
|
2020-10-29 06:11:18 +03:00
|
|
|
?- -.old
|
2021-04-13 23:37:32 +03:00
|
|
|
%0
|
|
|
|
=* zro zero-load:upgrade:store
|
2020-10-29 06:11:18 +03:00
|
|
|
%_ $
|
|
|
|
-.old %1
|
|
|
|
::
|
|
|
|
graphs.old
|
|
|
|
%- ~(run by graphs.old)
|
2021-03-18 04:50:14 +03:00
|
|
|
|= [=graph:zero:store q=(unit mark)]
|
|
|
|
^- [graph:zero:store (unit mark)]
|
2021-04-13 23:37:32 +03:00
|
|
|
:- (convert-unix-timestamped-graph:zro graph)
|
2020-10-29 06:11:18 +03:00
|
|
|
?^ q q
|
|
|
|
`%graph-validator-link
|
2020-10-29 07:07:47 +03:00
|
|
|
::
|
|
|
|
update-logs.old
|
|
|
|
%- ~(run by update-logs.old)
|
2021-03-18 04:50:14 +03:00
|
|
|
|=(a=* *update-log:zero:store)
|
2020-10-29 06:11:18 +03:00
|
|
|
==
|
|
|
|
::
|
2020-11-10 22:56:19 +03:00
|
|
|
%1
|
2021-04-13 23:37:32 +03:00
|
|
|
=* zro zero-load:upgrade:store
|
2020-11-10 22:56:19 +03:00
|
|
|
%_ $
|
2020-11-19 05:02:42 +03:00
|
|
|
-.old %2
|
2021-04-13 23:37:32 +03:00
|
|
|
graphs.old (~(run by graphs.old) change-revision-graph:zro)
|
2020-11-10 22:56:19 +03:00
|
|
|
::
|
|
|
|
update-logs.old
|
|
|
|
%- ~(run by update-logs.old)
|
2021-03-18 04:50:14 +03:00
|
|
|
|=(a=* *update-log:zero:store)
|
2020-11-10 22:56:19 +03:00
|
|
|
==
|
|
|
|
::
|
2021-04-13 23:37:32 +03:00
|
|
|
%2
|
|
|
|
=* upg upgrade:store
|
2021-03-18 10:02:39 +03:00
|
|
|
%_ $
|
|
|
|
-.old %3
|
2021-04-13 23:37:32 +03:00
|
|
|
update-logs.old (~(run by update-logs.old) update-log-to-one:upg)
|
|
|
|
graphs.old (~(run by graphs.old) marked-graph-to-one:upg)
|
|
|
|
archive.old (~(run by archive.old) marked-graph-to-one:upg)
|
2021-03-18 10:02:39 +03:00
|
|
|
==
|
2021-03-18 04:50:14 +03:00
|
|
|
::
|
2021-04-14 22:26:36 +03:00
|
|
|
%3
|
|
|
|
=* upg upgrade:store
|
|
|
|
%_ $
|
|
|
|
-.old %4
|
|
|
|
graphs.old (~(run by graphs.old) marked-graph-to-two:upg)
|
|
|
|
archive.old (~(run by archive.old) marked-graph-to-two:upg)
|
2021-04-19 23:53:07 +03:00
|
|
|
tag-queries.old *tag-queries:store
|
2021-04-26 21:28:13 +03:00
|
|
|
validators.old ~
|
2021-03-18 04:50:14 +03:00
|
|
|
::
|
2021-04-14 22:26:36 +03:00
|
|
|
update-logs.old
|
|
|
|
%- ~(run by update-logs.old)
|
|
|
|
|=(a=* *update-log:store)
|
|
|
|
==
|
|
|
|
::
|
2021-04-30 15:16:48 +03:00
|
|
|
%4
|
|
|
|
%_ $
|
2021-04-30 19:36:54 +03:00
|
|
|
-.old %5
|
2021-03-18 04:50:14 +03:00
|
|
|
::
|
2021-04-30 15:16:48 +03:00
|
|
|
update-logs.old
|
|
|
|
%- ~(gas by *update-logs:store)
|
|
|
|
%+ turn ~(tap by graphs.old)
|
|
|
|
|= [=resource:store =graph:store mar=(unit mark)]
|
|
|
|
:- resource
|
|
|
|
=/ log (~(got by update-logs.old) resource)
|
|
|
|
?. =(~ log) log
|
|
|
|
=/ =logged-update:store
|
|
|
|
[now.bowl %add-graph resource graph mar %.y]
|
|
|
|
(gas:orm-log ~ [now.bowl logged-update] ~)
|
|
|
|
==
|
|
|
|
::
|
2021-05-10 20:09:47 +03:00
|
|
|
%5 [cards this(-.state old, +.state *cache)]
|
2020-10-29 06:11:18 +03:00
|
|
|
==
|
2020-06-02 00:07:31 +03:00
|
|
|
::
|
2020-06-26 21:38:11 +03:00
|
|
|
++ on-watch
|
|
|
|
~/ %graph-store-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
=/ cards=(list card)
|
|
|
|
?+ path (on-watch:def path)
|
|
|
|
[%updates ~] ~
|
|
|
|
[%keys ~] (give [%keys ~(key by graphs)])
|
|
|
|
[%tags ~] (give [%tags ~(key by tag-queries)])
|
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ give
|
2021-03-18 04:50:14 +03:00
|
|
|
|= =action:store
|
2020-06-26 21:38:11 +03:00
|
|
|
^- (list card)
|
2021-04-14 22:26:36 +03:00
|
|
|
[%give %fact ~ [%graph-update-2 !>([now.bowl action])]]~
|
2020-06-26 21:38:11 +03:00
|
|
|
--
|
|
|
|
::
|
2020-06-02 00:07:31 +03:00
|
|
|
++ on-poke
|
2020-06-23 19:16:12 +03:00
|
|
|
~/ %graph-store-poke
|
2020-06-02 00:07:31 +03:00
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
=^ cards state
|
2021-03-18 04:50:14 +03:00
|
|
|
?+ mark (on-poke:def mark vase)
|
2021-04-14 22:26:36 +03:00
|
|
|
%graph-update-2 (graph-update !<(update:store vase))
|
2021-03-18 04:50:14 +03:00
|
|
|
%noun (debug !<(debug-input vase))
|
|
|
|
%import (poke-import q.vase)
|
2020-06-02 00:07:31 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2020-06-26 21:38:11 +03:00
|
|
|
++ graph-update
|
|
|
|
|= =update:store
|
2020-06-02 00:07:31 +03:00
|
|
|
^- (quip card _state)
|
2020-06-05 22:22:36 +03:00
|
|
|
|^
|
2020-10-28 22:37:26 +03:00
|
|
|
=? p.update =(p.update *time) now.bowl
|
2020-06-30 04:14:55 +03:00
|
|
|
?- -.q.update
|
2021-01-15 04:57:12 +03:00
|
|
|
%add-graph (add-graph p.update +.q.update)
|
2020-06-30 04:14:55 +03:00
|
|
|
%remove-graph (remove-graph +.q.update)
|
|
|
|
%add-nodes (add-nodes p.update +.q.update)
|
2021-04-14 22:26:36 +03:00
|
|
|
%remove-posts (remove-posts p.update +.q.update)
|
2020-06-30 04:14:55 +03:00
|
|
|
%add-signatures (add-signatures p.update +.q.update)
|
|
|
|
%remove-signatures (remove-signatures p.update +.q.update)
|
|
|
|
%add-tag (add-tag +.q.update)
|
|
|
|
%remove-tag (remove-tag +.q.update)
|
|
|
|
%archive-graph (archive-graph +.q.update)
|
|
|
|
%unarchive-graph (unarchive-graph +.q.update)
|
|
|
|
%run-updates (run-updates +.q.update)
|
2020-07-07 02:31:57 +03:00
|
|
|
%keys ~|('cannot send %keys as poke' !!)
|
|
|
|
%tags ~|('cannot send %tags as poke' !!)
|
|
|
|
%tag-queries ~|('cannot send %tag-queries as poke' !!)
|
2020-06-05 22:22:36 +03:00
|
|
|
==
|
|
|
|
::
|
2020-06-12 20:50:22 +03:00
|
|
|
++ add-graph
|
2021-01-15 04:57:12 +03:00
|
|
|
|= $: =time
|
|
|
|
=resource:store
|
2020-11-12 23:40:12 +03:00
|
|
|
=graph:store
|
|
|
|
mark=(unit mark:store)
|
|
|
|
overwrite=?
|
|
|
|
==
|
2020-06-12 20:50:22 +03:00
|
|
|
^- (quip card _state)
|
2020-11-12 23:40:12 +03:00
|
|
|
?> ?| overwrite
|
|
|
|
?& !(~(has by archive) resource)
|
|
|
|
!(~(has by graphs) resource)
|
|
|
|
== ==
|
2021-03-31 19:26:00 +03:00
|
|
|
~| "validation of graph {<resource>} failed using mark {<mark>}"
|
2021-05-10 20:09:47 +03:00
|
|
|
=^ is-valid state
|
|
|
|
(validate-graph graph mark)
|
|
|
|
?> is-valid
|
2021-01-15 04:57:12 +03:00
|
|
|
=/ =logged-update:store
|
2021-03-18 04:50:14 +03:00
|
|
|
[time %add-graph resource graph mark overwrite]
|
2021-01-15 04:57:12 +03:00
|
|
|
=/ =update-log:store
|
|
|
|
(gas:orm-log ~ [time logged-update] ~)
|
2020-07-07 02:31:57 +03:00
|
|
|
:_ %_ state
|
|
|
|
graphs (~(put by graphs) resource [graph mark])
|
2021-01-15 04:57:12 +03:00
|
|
|
update-logs (~(put by update-logs) resource update-log)
|
2020-12-11 04:38:12 +03:00
|
|
|
archive (~(del by archive) resource)
|
2020-07-07 02:31:57 +03:00
|
|
|
==
|
|
|
|
%- zing
|
2020-12-11 07:57:20 +03:00
|
|
|
:~ (give [/keys ~] %keys (~(put in ~(key by graphs)) resource))
|
2020-12-11 06:05:40 +03:00
|
|
|
(give [/updates ~] %add-graph resource *graph:store mark overwrite)
|
2020-06-12 20:50:22 +03:00
|
|
|
==
|
2020-06-05 22:22:36 +03:00
|
|
|
::
|
|
|
|
++ remove-graph
|
|
|
|
|= =resource:store
|
|
|
|
^- (quip card _state)
|
2020-06-30 04:14:55 +03:00
|
|
|
?< (~(has by archive) resource)
|
2020-06-05 22:22:36 +03:00
|
|
|
?> (~(has by graphs) resource)
|
2020-06-10 19:08:49 +03:00
|
|
|
:- (give [/updates /keys ~] [%remove-graph resource])
|
2020-06-09 21:48:05 +03:00
|
|
|
%_ state
|
2020-06-09 00:44:51 +03:00
|
|
|
graphs (~(del by graphs) resource)
|
2020-06-30 04:14:55 +03:00
|
|
|
update-logs (~(del by update-logs) resource)
|
2020-06-09 00:44:51 +03:00
|
|
|
==
|
2020-06-05 22:22:36 +03:00
|
|
|
::
|
|
|
|
++ add-nodes
|
2020-07-07 02:31:57 +03:00
|
|
|
|= $: =time
|
|
|
|
=resource:store
|
|
|
|
nodes=(map index:store node:store)
|
|
|
|
==
|
2020-06-05 22:22:36 +03:00
|
|
|
^- (quip card _state)
|
2020-06-12 20:27:43 +03:00
|
|
|
|^
|
2020-07-07 02:31:57 +03:00
|
|
|
=/ [=graph:store mark=(unit mark:store)]
|
|
|
|
(~(got by graphs) resource)
|
2020-12-13 03:06:44 +03:00
|
|
|
~| "cannot add duplicate nodes to {<resource>}"
|
|
|
|
?< (check-for-duplicates graph ~(key by nodes))
|
2021-05-10 20:09:47 +03:00
|
|
|
~| "validation of nodes failed using mark {<mark>}"
|
|
|
|
=^ is-valid state
|
|
|
|
(check-validity ~(tap by nodes) mark)
|
|
|
|
?> is-valid
|
2020-06-30 04:14:55 +03:00
|
|
|
=/ =update-log:store (~(got by update-logs) resource)
|
|
|
|
=. update-log
|
2021-03-18 04:50:14 +03:00
|
|
|
(put:orm-log update-log time [time [%add-nodes resource nodes]])
|
2020-06-12 20:27:43 +03:00
|
|
|
::
|
|
|
|
:- (give [/updates]~ [%add-nodes resource nodes])
|
|
|
|
%_ state
|
2020-06-30 04:14:55 +03:00
|
|
|
update-logs (~(put by update-logs) resource update-log)
|
2020-06-12 20:27:43 +03:00
|
|
|
graphs
|
|
|
|
%+ ~(put by graphs)
|
|
|
|
resource
|
2020-07-22 01:57:44 +03:00
|
|
|
:_ mark
|
|
|
|
(add-node-list resource graph mark (sort-nodes nodes))
|
2020-06-12 20:27:43 +03:00
|
|
|
==
|
2020-06-05 22:22:36 +03:00
|
|
|
::
|
2021-05-10 20:09:47 +03:00
|
|
|
++ check-validity
|
|
|
|
|= [lis=(list (pair index:store node:store)) mark=(unit ^mark)]
|
|
|
|
^- [? _state]
|
2020-12-12 02:05:54 +03:00
|
|
|
|-
|
2021-05-10 20:09:47 +03:00
|
|
|
?~ lis [& state]
|
|
|
|
=^ is-valid state
|
|
|
|
(validate-graph (gas:orm ~ [(rear p.i.lis) q.i.lis]~) mark)
|
|
|
|
?. is-valid
|
|
|
|
[| state]
|
|
|
|
$(lis t.lis)
|
2020-12-12 02:05:54 +03:00
|
|
|
::
|
|
|
|
++ check-for-duplicates
|
2020-12-12 03:10:10 +03:00
|
|
|
|= [=graph:store nodes=(set index:store)]
|
2020-12-12 02:05:54 +03:00
|
|
|
^- ?
|
2021-04-14 23:39:34 +03:00
|
|
|
|^
|
|
|
|
%+ lien ~(tap in nodes)
|
|
|
|
|= =index:store
|
|
|
|
(has-node graph index)
|
|
|
|
::
|
|
|
|
++ has-node
|
|
|
|
|= [=graph:store =index:store]
|
|
|
|
^- ?
|
|
|
|
=/ node=(unit node:store) ~
|
|
|
|
|-
|
|
|
|
?~ index
|
|
|
|
?=(^ node)
|
|
|
|
?~ t.index
|
|
|
|
?=(^ (get:orm graph i.index))
|
|
|
|
=. node (get:orm graph i.index)
|
|
|
|
?~ node %.n
|
|
|
|
?- -.children.u.node
|
|
|
|
%empty %.n
|
|
|
|
%graph $(graph p.children.u.node, index t.index)
|
|
|
|
==
|
|
|
|
--
|
2020-12-12 02:05:54 +03:00
|
|
|
::
|
2020-07-22 01:57:44 +03:00
|
|
|
++ sort-nodes
|
|
|
|
|= nodes=(map index:store node:store)
|
|
|
|
^- (list [index:store node:store])
|
|
|
|
%+ sort ~(tap by nodes)
|
2020-07-22 02:01:46 +03:00
|
|
|
|= [p=[=index:store *] q=[=index:store *]]
|
2020-07-22 01:57:44 +03:00
|
|
|
^- ?
|
2020-07-22 03:37:28 +03:00
|
|
|
(lth (lent index.p) (lent index.q))
|
2020-07-22 01:57:44 +03:00
|
|
|
::
|
2020-06-05 22:22:36 +03:00
|
|
|
++ add-node-list
|
|
|
|
|= $: =resource:store
|
|
|
|
=graph:store
|
2020-07-07 02:31:57 +03:00
|
|
|
mark=(unit mark:store)
|
2020-06-05 22:22:36 +03:00
|
|
|
node-list=(list [index:store node:store])
|
|
|
|
==
|
|
|
|
^- graph:store
|
|
|
|
?~ node-list graph
|
|
|
|
=* index -.i.node-list
|
|
|
|
=* node +.i.node-list
|
2021-05-15 00:36:27 +03:00
|
|
|
~| "cannot add deleted post"
|
|
|
|
?> ?=(%& -.post.node)
|
|
|
|
=* p p.post.node
|
|
|
|
~| "graph indexes must match"
|
|
|
|
?> =(index index.p)
|
2020-06-05 22:22:36 +03:00
|
|
|
%_ $
|
|
|
|
node-list t.node-list
|
2020-07-21 21:04:18 +03:00
|
|
|
graph (add-node-at-index graph index node mark)
|
2020-06-05 22:22:36 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ add-node-at-index
|
2020-07-21 21:04:18 +03:00
|
|
|
=| parent-hash=(unit hash:store)
|
2020-06-09 21:48:05 +03:00
|
|
|
|= $: =graph:store
|
|
|
|
=index:store
|
|
|
|
=node:store
|
2020-07-07 02:31:57 +03:00
|
|
|
mark=(unit mark:store)
|
2020-06-09 21:48:05 +03:00
|
|
|
==
|
2020-06-05 22:22:36 +03:00
|
|
|
^- graph:store
|
2020-07-21 21:04:18 +03:00
|
|
|
?< ?=(~ index)
|
2020-06-05 22:22:36 +03:00
|
|
|
=* atom i.index
|
2020-06-10 19:08:49 +03:00
|
|
|
%^ put:orm
|
|
|
|
graph
|
|
|
|
atom
|
2020-06-18 22:59:50 +03:00
|
|
|
:: add child
|
|
|
|
::
|
2020-06-09 00:44:51 +03:00
|
|
|
?~ t.index
|
2021-04-14 22:26:36 +03:00
|
|
|
~| "cannot add deleted post"
|
|
|
|
?> ?=(%& -.post.node)
|
|
|
|
=* p p.post.node
|
|
|
|
?~ hash.p node(signatures.p.post *signatures:store)
|
2020-06-09 21:48:05 +03:00
|
|
|
=/ =validated-portion:store
|
2020-07-21 21:04:18 +03:00
|
|
|
[parent-hash author.p time-sent.p contents.p]
|
2020-07-22 23:32:47 +03:00
|
|
|
=/ =hash:store `@ux`(sham validated-portion)
|
2020-06-18 22:59:50 +03:00
|
|
|
~| "hash of post does not match calculated hash"
|
|
|
|
?> =(hash u.hash.p)
|
2021-02-25 22:06:26 +03:00
|
|
|
~| "signatures do not match the calculated hash"
|
|
|
|
?> (are-signatures-valid:sigs our.bowl signatures.p hash now.bowl)
|
2020-06-18 22:59:50 +03:00
|
|
|
node
|
|
|
|
:: recurse children
|
|
|
|
::
|
2020-07-31 01:06:48 +03:00
|
|
|
=/ parent=node:store
|
|
|
|
~| "index does not exist to add a node to!"
|
|
|
|
(need (get:orm graph atom))
|
2020-06-10 19:08:49 +03:00
|
|
|
%_ parent
|
|
|
|
children
|
|
|
|
^- internal-graph:store
|
|
|
|
:- %graph
|
|
|
|
%_ $
|
2021-04-14 22:26:36 +03:00
|
|
|
index t.index
|
|
|
|
::
|
|
|
|
parent-hash
|
|
|
|
?- -.post.parent
|
|
|
|
%| `p.post.parent
|
|
|
|
%& hash.p.post.parent
|
|
|
|
==
|
|
|
|
::
|
2020-06-05 22:22:36 +03:00
|
|
|
graph
|
2020-06-10 19:08:49 +03:00
|
|
|
?: ?=(%graph -.children.parent)
|
|
|
|
p.children.parent
|
|
|
|
(gas:orm ~ ~)
|
2020-06-05 22:22:36 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
2021-04-14 22:26:36 +03:00
|
|
|
++ remove-posts
|
2020-06-30 04:14:55 +03:00
|
|
|
|= [=time =resource:store indices=(set index:store)]
|
2020-06-05 22:22:36 +03:00
|
|
|
^- (quip card _state)
|
2020-06-12 20:27:43 +03:00
|
|
|
|^
|
2020-07-07 02:31:57 +03:00
|
|
|
=/ [=graph:store mark=(unit mark:store)]
|
|
|
|
(~(got by graphs) resource)
|
|
|
|
=/ =update-log:store (~(got by update-logs) resource)
|
2020-06-30 04:14:55 +03:00
|
|
|
=. update-log
|
2021-04-14 23:33:15 +03:00
|
|
|
(put:orm-log update-log time [time [%remove-posts resource indices]])
|
|
|
|
:- (give [/updates]~ [%remove-posts resource indices])
|
2020-06-12 20:27:43 +03:00
|
|
|
%_ state
|
2021-04-14 23:33:15 +03:00
|
|
|
update-logs (~(put by update-logs) resource update-log)
|
|
|
|
::
|
2020-06-12 20:27:43 +03:00
|
|
|
graphs
|
|
|
|
%+ ~(put by graphs)
|
|
|
|
resource
|
2021-04-14 23:33:15 +03:00
|
|
|
:_ mark
|
2021-04-14 23:49:54 +03:00
|
|
|
%^ remove-indices
|
|
|
|
resource
|
|
|
|
graph
|
|
|
|
(sort ~(tap in indices) by-lent)
|
2020-06-12 20:27:43 +03:00
|
|
|
==
|
2020-06-05 23:31:55 +03:00
|
|
|
::
|
2021-01-11 04:50:11 +03:00
|
|
|
++ by-lent
|
|
|
|
|* [a=(list) b=(list)]
|
|
|
|
^- ?
|
|
|
|
(gth (lent a) (lent b))
|
|
|
|
::
|
2020-06-05 23:31:55 +03:00
|
|
|
++ remove-indices
|
|
|
|
|= [=resource:store =graph:store indices=(list index:store)]
|
2021-04-14 23:33:15 +03:00
|
|
|
^- graph:store
|
|
|
|
?~ indices graph
|
2020-06-05 23:31:55 +03:00
|
|
|
%_ $
|
2021-04-14 23:33:15 +03:00
|
|
|
indices t.indices
|
|
|
|
graph (remove-index graph i.indices)
|
2020-06-05 23:31:55 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ remove-index
|
2021-04-14 23:33:15 +03:00
|
|
|
=| parent-hash=(unit hash:store)
|
2020-06-05 23:31:55 +03:00
|
|
|
|= [=graph:store =index:store]
|
2021-04-14 23:33:15 +03:00
|
|
|
^- graph:store
|
|
|
|
?~ index graph
|
2020-06-05 23:31:55 +03:00
|
|
|
=* atom i.index
|
2021-04-14 23:33:15 +03:00
|
|
|
%^ put:orm
|
|
|
|
graph
|
|
|
|
atom
|
2020-06-05 23:31:55 +03:00
|
|
|
:: last index in list
|
|
|
|
::
|
|
|
|
?~ t.index
|
2021-04-14 23:33:15 +03:00
|
|
|
=/ =node:store
|
|
|
|
~| "cannot remove index that does not exist {<index>}"
|
|
|
|
(need (get:orm graph atom))
|
2021-04-17 00:54:30 +03:00
|
|
|
%_ node
|
2021-04-14 23:33:15 +03:00
|
|
|
post
|
2021-04-17 00:54:30 +03:00
|
|
|
~| "cannot remove post that has already been removed"
|
|
|
|
?> ?=(%& -.post.node)
|
|
|
|
=* p p.post.node
|
2021-04-14 23:33:15 +03:00
|
|
|
^- maybe-post:store
|
|
|
|
:- %|
|
|
|
|
?~ hash.p
|
|
|
|
=/ =validated-portion:store
|
|
|
|
[parent-hash author.p time-sent.p contents.p]
|
|
|
|
`@ux`(sham validated-portion)
|
|
|
|
u.hash.p
|
|
|
|
==
|
|
|
|
:: recurse children
|
|
|
|
::
|
|
|
|
=/ parent=node:store
|
2020-07-31 01:06:48 +03:00
|
|
|
~| "parent index does not exist to remove a node from!"
|
|
|
|
(need (get:orm graph atom))
|
2020-06-10 19:08:49 +03:00
|
|
|
~| "child index does not exist to remove a node from!"
|
2021-04-14 23:33:15 +03:00
|
|
|
?> ?=(%graph -.children.parent)
|
|
|
|
%_ parent
|
|
|
|
p.children
|
|
|
|
%_ $
|
|
|
|
index t.index
|
|
|
|
graph p.children.parent
|
|
|
|
::
|
|
|
|
parent-hash
|
|
|
|
?- -.post.parent
|
|
|
|
%| `p.post.parent
|
|
|
|
%& hash.p.post.parent
|
|
|
|
==
|
|
|
|
==
|
|
|
|
==
|
2020-06-05 23:31:55 +03:00
|
|
|
--
|
2020-06-05 22:22:36 +03:00
|
|
|
::
|
|
|
|
++ add-signatures
|
2020-06-30 04:14:55 +03:00
|
|
|
|= [=time =uid:store =signatures:store]
|
2020-06-05 22:22:36 +03:00
|
|
|
^- (quip card _state)
|
2020-06-12 20:27:43 +03:00
|
|
|
|^
|
|
|
|
=* resource resource.uid
|
2020-07-07 02:31:57 +03:00
|
|
|
=/ [=graph:store mark=(unit mark:store)]
|
|
|
|
(~(got by graphs) resource)
|
2020-06-30 04:14:55 +03:00
|
|
|
=/ =update-log:store (~(got by update-logs) resource)
|
|
|
|
=. update-log
|
2021-03-18 04:50:14 +03:00
|
|
|
(put:orm-log update-log time [time [%add-signatures uid signatures]])
|
2020-06-12 20:27:43 +03:00
|
|
|
::
|
|
|
|
:- (give [/updates]~ [%add-signatures uid signatures])
|
|
|
|
%_ state
|
2020-06-30 04:14:55 +03:00
|
|
|
update-logs (~(put by update-logs) resource update-log)
|
2020-06-12 20:27:43 +03:00
|
|
|
graphs
|
2020-07-07 02:31:57 +03:00
|
|
|
%+ ~(put by graphs) resource
|
|
|
|
[(add-at-index graph index.uid signatures) mark]
|
2020-06-12 20:27:43 +03:00
|
|
|
==
|
2020-06-09 00:44:51 +03:00
|
|
|
::
|
|
|
|
++ add-at-index
|
|
|
|
|= [=graph:store =index:store =signatures:store]
|
|
|
|
^- graph:store
|
|
|
|
?~ index graph
|
|
|
|
=* atom i.index
|
2020-07-31 01:06:48 +03:00
|
|
|
=/ =node:store
|
2020-09-01 04:54:39 +03:00
|
|
|
~| "node does not exist to add signatures to!"
|
2020-07-31 01:06:48 +03:00
|
|
|
(need (get:orm graph atom))
|
2020-06-09 00:44:51 +03:00
|
|
|
:: last index in list
|
|
|
|
::
|
2020-06-10 19:08:49 +03:00
|
|
|
%^ put:orm
|
|
|
|
graph
|
|
|
|
atom
|
2020-06-09 00:44:51 +03:00
|
|
|
?~ t.index
|
2021-04-14 22:26:36 +03:00
|
|
|
~| "cannot add signatures to a deleted post"
|
|
|
|
?> ?=(%& -.post.node)
|
2020-06-10 19:08:49 +03:00
|
|
|
~| "cannot add signatures to a node missing a hash"
|
2021-04-14 22:26:36 +03:00
|
|
|
?> ?=(^ hash.p.post.node)
|
2020-06-10 19:08:49 +03:00
|
|
|
~| "signatures did not match public keys!"
|
2021-04-14 22:26:36 +03:00
|
|
|
?> (are-signatures-valid:sigs our.bowl signatures u.hash.p.post.node now.bowl)
|
|
|
|
node(signatures.p.post (~(uni in signatures) signatures.p.post.node))
|
2020-06-10 19:08:49 +03:00
|
|
|
~| "child graph does not exist to add signatures to!"
|
|
|
|
?> ?=(%graph -.children.node)
|
|
|
|
node(p.children $(graph p.children.node, index t.index))
|
2020-06-09 00:44:51 +03:00
|
|
|
--
|
2020-06-05 22:22:36 +03:00
|
|
|
::
|
|
|
|
++ remove-signatures
|
2020-06-30 04:14:55 +03:00
|
|
|
|= [=time =uid:store =signatures:store]
|
2020-06-05 22:22:36 +03:00
|
|
|
^- (quip card _state)
|
2020-06-12 20:27:43 +03:00
|
|
|
|^
|
|
|
|
=* resource resource.uid
|
2020-07-07 02:31:57 +03:00
|
|
|
=/ [=graph:store mark=(unit mark:store)]
|
|
|
|
(~(got by graphs) resource)
|
2020-06-30 04:14:55 +03:00
|
|
|
=/ =update-log:store (~(got by update-logs) resource)
|
|
|
|
=. update-log
|
|
|
|
%^ put:orm-log update-log
|
|
|
|
time
|
2021-03-18 04:50:14 +03:00
|
|
|
[time [%remove-signatures uid signatures]]
|
2020-06-12 20:27:43 +03:00
|
|
|
::
|
|
|
|
:- (give [/updates]~ [%remove-signatures uid signatures])
|
|
|
|
%_ state
|
2020-06-30 04:14:55 +03:00
|
|
|
update-logs (~(put by update-logs) resource update-log)
|
2020-06-12 20:27:43 +03:00
|
|
|
graphs
|
|
|
|
%+ ~(put by graphs) resource
|
2020-07-07 02:31:57 +03:00
|
|
|
[(remove-at-index graph index.uid signatures) mark]
|
2020-06-12 20:27:43 +03:00
|
|
|
==
|
2020-06-10 19:08:49 +03:00
|
|
|
::
|
|
|
|
++ remove-at-index
|
|
|
|
|= [=graph:store =index:store =signatures:store]
|
|
|
|
^- graph:store
|
|
|
|
?~ index graph
|
|
|
|
=* atom i.index
|
2020-07-31 01:06:48 +03:00
|
|
|
=/ =node:store
|
2020-09-01 04:54:39 +03:00
|
|
|
~| "node does not exist to add signatures to!"
|
2020-07-31 01:06:48 +03:00
|
|
|
(need (get:orm graph atom))
|
2020-06-10 19:08:49 +03:00
|
|
|
:: last index in list
|
|
|
|
::
|
|
|
|
%^ put:orm
|
|
|
|
graph
|
|
|
|
atom
|
|
|
|
?~ t.index
|
2021-04-14 22:26:36 +03:00
|
|
|
~| "cannot add signatures to a deleted post"
|
|
|
|
?> ?=(%& -.post.node)
|
|
|
|
node(signatures.p.post (~(dif in signatures) signatures.p.post.node))
|
2020-06-10 19:08:49 +03:00
|
|
|
~| "child graph does not exist to add signatures to!"
|
|
|
|
?> ?=(%graph -.children.node)
|
|
|
|
node(p.children $(graph p.children.node, index t.index))
|
|
|
|
--
|
2020-06-05 22:22:36 +03:00
|
|
|
::
|
|
|
|
++ add-tag
|
2021-04-19 23:53:07 +03:00
|
|
|
|= [=term =uid:store]
|
2020-06-05 22:22:36 +03:00
|
|
|
^- (quip card _state)
|
2021-04-19 23:53:07 +03:00
|
|
|
?> (~(has by graphs) resource.uid)
|
|
|
|
:- (give [/updates /tags ~] [%add-tag term uid])
|
2020-06-09 00:44:51 +03:00
|
|
|
%_ state
|
2021-04-19 23:53:07 +03:00
|
|
|
tag-queries (~(put ju tag-queries) term uid)
|
2020-06-09 00:44:51 +03:00
|
|
|
==
|
2020-06-05 22:22:36 +03:00
|
|
|
::
|
|
|
|
++ remove-tag
|
2021-04-19 23:53:07 +03:00
|
|
|
|= [=term =uid:store]
|
2020-06-05 22:22:36 +03:00
|
|
|
^- (quip card _state)
|
2021-04-19 23:53:07 +03:00
|
|
|
:- (give [/updates /tags ~] [%remove-tag term uid])
|
2020-06-09 00:44:51 +03:00
|
|
|
%_ state
|
2021-04-19 23:53:07 +03:00
|
|
|
tag-queries (~(del ju tag-queries) term uid)
|
2020-06-09 00:44:51 +03:00
|
|
|
==
|
2020-06-05 22:22:36 +03:00
|
|
|
::
|
2020-06-23 20:53:50 +03:00
|
|
|
++ archive-graph
|
|
|
|
|= =resource:store
|
|
|
|
^- (quip card _state)
|
|
|
|
?< (~(has by archive) resource)
|
|
|
|
?> (~(has by graphs) resource)
|
2020-06-26 21:38:11 +03:00
|
|
|
:- (give [/updates /keys /tags ~] [%archive-graph resource])
|
2020-06-23 20:53:50 +03:00
|
|
|
%_ state
|
|
|
|
archive (~(put by archive) resource (~(got by graphs) resource))
|
|
|
|
graphs (~(del by graphs) resource)
|
2020-06-30 04:14:55 +03:00
|
|
|
update-logs (~(del by update-logs) resource)
|
2020-06-23 20:53:50 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ unarchive-graph
|
|
|
|
|= =resource:store
|
|
|
|
^- (quip card _state)
|
|
|
|
?> (~(has by archive) resource)
|
|
|
|
?< (~(has by graphs) resource)
|
|
|
|
:- (give [/updates /keys ~] [%unarchive-graph resource])
|
|
|
|
%_ state
|
|
|
|
archive (~(del by archive) resource)
|
|
|
|
graphs (~(put by graphs) resource (~(got by archive) resource))
|
2020-06-30 04:14:55 +03:00
|
|
|
update-logs (~(put by update-logs) resource (gas:orm-log ~ ~))
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ run-updates
|
|
|
|
|= [=resource:store =update-log:store]
|
|
|
|
^- (quip card _state)
|
|
|
|
?< (~(has by archive) resource)
|
|
|
|
?> (~(has by graphs) resource)
|
2020-11-10 08:43:35 +03:00
|
|
|
=/ updates=(list [=time upd=logged-update:store])
|
2021-01-05 01:23:12 +03:00
|
|
|
:: updates are time-ordered with most recent first
|
|
|
|
:: process with earliest first
|
|
|
|
(bap:orm-log update-log)
|
2020-11-10 08:43:35 +03:00
|
|
|
=| cards=(list card)
|
|
|
|
|- ^- (quip card _state)
|
|
|
|
?~ updates
|
|
|
|
[cards state]
|
|
|
|
=* update upd.i.updates
|
|
|
|
=^ crds state
|
2021-03-11 07:00:50 +03:00
|
|
|
%- graph-update
|
2020-11-10 08:43:35 +03:00
|
|
|
^- update:store
|
|
|
|
?- -.q.update
|
2021-01-15 04:57:12 +03:00
|
|
|
%add-graph update(resource.q resource)
|
2020-11-10 08:43:35 +03:00
|
|
|
%add-nodes update(resource.q resource)
|
2021-04-14 22:26:36 +03:00
|
|
|
%remove-posts update(resource.q resource)
|
2020-11-10 08:43:35 +03:00
|
|
|
%add-signatures update(resource.uid.q resource)
|
|
|
|
%remove-signatures update(resource.uid.q resource)
|
|
|
|
==
|
|
|
|
$(cards (weld cards crds), updates t.updates)
|
2020-06-23 20:53:50 +03:00
|
|
|
::
|
2020-06-05 22:22:36 +03:00
|
|
|
++ give
|
2021-03-18 04:50:14 +03:00
|
|
|
|= [paths=(list path) update=action:store]
|
2020-06-05 22:22:36 +03:00
|
|
|
^- (list card)
|
2021-04-14 23:49:54 +03:00
|
|
|
[%give %fact paths [%graph-update-2 !>([now.bowl update])]]~
|
2020-06-05 22:22:36 +03:00
|
|
|
--
|
2020-11-12 23:00:59 +03:00
|
|
|
::
|
|
|
|
++ debug
|
|
|
|
|= =debug-input
|
|
|
|
^- (quip card _state)
|
|
|
|
=/ [=graph:store mark=(unit mark:store)]
|
|
|
|
(~(got by graphs) resource.debug-input)
|
2021-05-10 20:09:47 +03:00
|
|
|
=^ is-valid state
|
|
|
|
(validate-graph graph mark)
|
|
|
|
?> is-valid
|
2020-11-12 23:00:59 +03:00
|
|
|
[~ state]
|
|
|
|
::
|
|
|
|
++ validate-graph
|
|
|
|
|= [=graph:store mark=(unit mark:store)]
|
2021-05-10 20:09:47 +03:00
|
|
|
^- [? _state]
|
|
|
|
?~ mark [%.y state]
|
|
|
|
=/ has-dais (~(has by validators) u.mark)
|
2020-11-12 23:00:59 +03:00
|
|
|
=/ =dais:clay
|
2021-05-10 20:09:47 +03:00
|
|
|
?: has-dais
|
|
|
|
(~(got by validators) u.mark)
|
2020-11-12 23:00:59 +03:00
|
|
|
.^ =dais:clay
|
|
|
|
%cb
|
|
|
|
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/[u.mark]
|
|
|
|
==
|
2021-05-10 20:09:47 +03:00
|
|
|
:_ state(validators (~(put by validators) u.mark dais))
|
2021-03-31 20:28:43 +03:00
|
|
|
|- ^- ?
|
|
|
|
?~ graph %.y
|
2020-11-12 23:00:59 +03:00
|
|
|
%+ roll (tap:orm graph)
|
|
|
|
|= [[=atom =node:store] out=?]
|
2021-03-31 20:13:42 +03:00
|
|
|
^- ?
|
2021-04-22 22:17:01 +03:00
|
|
|
?& ?| ?=(%| -.post.node)
|
|
|
|
?=(^ (vale:dais [atom p.post.node]))
|
|
|
|
==
|
|
|
|
::
|
2020-11-12 23:00:59 +03:00
|
|
|
?- -.children.node
|
2021-03-31 19:26:00 +03:00
|
|
|
%empty %.y
|
|
|
|
%graph ^$(graph p.children.node)
|
2021-03-31 20:13:42 +03:00
|
|
|
== ==
|
2020-12-01 00:08:15 +03:00
|
|
|
::
|
|
|
|
++ poke-import
|
|
|
|
|= arc=*
|
|
|
|
^- (quip card _state)
|
2021-05-10 20:09:47 +03:00
|
|
|
=^ cards -.state
|
|
|
|
(import:store arc our.bowl)
|
|
|
|
[cards state]
|
2020-06-02 00:07:31 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-peek
|
2020-06-23 19:16:12 +03:00
|
|
|
~/ %graph-store-peek
|
2020-06-02 00:07:31 +03:00
|
|
|
|= =path
|
|
|
|
^- (unit (unit cage))
|
2020-06-26 21:38:11 +03:00
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
2020-06-02 00:07:31 +03:00
|
|
|
?+ path (on-peek:def path)
|
2020-10-21 08:59:39 +03:00
|
|
|
[%x %graph-mark @ @ ~]
|
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
|
|
|
=/ result=(unit marked-graph:store)
|
|
|
|
(~(get by graphs) [ship term])
|
|
|
|
?~ result [~ ~]
|
|
|
|
``noun+!>(q.u.result)
|
|
|
|
::
|
2020-08-28 01:31:36 +03:00
|
|
|
[%x %keys ~]
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2021-03-18 04:50:14 +03:00
|
|
|
!>(`update:store`[now.bowl [%keys ~(key by graphs)]])
|
2020-08-28 01:31:36 +03:00
|
|
|
::
|
|
|
|
[%x %tags ~]
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2021-03-18 04:50:14 +03:00
|
|
|
!>(`update:store`[now.bowl [%tags ~(key by tag-queries)]])
|
2020-08-28 01:31:36 +03:00
|
|
|
::
|
|
|
|
[%x %tag-queries ~]
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2021-03-18 04:50:14 +03:00
|
|
|
!>(`update:store`[now.bowl [%tag-queries tag-queries]])
|
2020-08-28 01:31:36 +03:00
|
|
|
::
|
2020-06-12 21:02:52 +03:00
|
|
|
[%x %graph @ @ ~]
|
|
|
|
=/ =ship (slav %p i.t.t.path)
|
2020-06-12 23:29:14 +03:00
|
|
|
=/ =term i.t.t.t.path
|
2020-07-07 03:02:15 +03:00
|
|
|
=/ result=(unit marked-graph:store)
|
|
|
|
(~(get by graphs) [ship term])
|
2020-07-28 22:30:59 +03:00
|
|
|
?~ result [~ ~]
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2020-08-28 01:31:36 +03:00
|
|
|
!> ^- update:store
|
2021-03-18 04:50:14 +03:00
|
|
|
:- now.bowl
|
2020-11-12 23:40:12 +03:00
|
|
|
[%add-graph [ship term] `graph:store`p.u.result q.u.result %.y]
|
2020-09-18 22:50:54 +03:00
|
|
|
::
|
|
|
|
:: note: near-duplicate of /x/graph
|
|
|
|
::
|
|
|
|
[%x %archive @ @ ~]
|
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
|
|
|
=/ result=(unit marked-graph:store)
|
|
|
|
(~(get by archive) [ship term])
|
2020-09-18 23:50:34 +03:00
|
|
|
?~ result
|
|
|
|
~& no-archived-graph+[ship term]
|
|
|
|
[~ ~]
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2020-09-18 22:50:54 +03:00
|
|
|
!> ^- update:store
|
2021-03-18 04:50:14 +03:00
|
|
|
:- now.bowl
|
2020-11-12 23:40:12 +03:00
|
|
|
[%add-graph [ship term] `graph:store`p.u.result q.u.result %.y]
|
2020-12-01 00:08:15 +03:00
|
|
|
::
|
|
|
|
[%x %export ~]
|
|
|
|
``noun+!>(state)
|
2020-06-18 22:59:50 +03:00
|
|
|
::
|
2020-06-26 21:38:11 +03:00
|
|
|
[%x %graph-subset @ @ @ @ ~]
|
2020-07-07 03:02:15 +03:00
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
2020-07-22 23:32:47 +03:00
|
|
|
=/ start=(unit atom) (rush i.t.t.t.t.path dem:ag)
|
|
|
|
=/ end=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
2020-07-07 03:02:15 +03:00
|
|
|
=/ graph=(unit marked-graph:store)
|
|
|
|
(~(get by graphs) [ship term])
|
2020-07-28 22:30:59 +03:00
|
|
|
?~ graph [~ ~]
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2020-08-28 01:31:36 +03:00
|
|
|
!> ^- update:store
|
2021-03-18 04:50:14 +03:00
|
|
|
:- now.bowl
|
2020-08-28 01:31:36 +03:00
|
|
|
:+ %add-nodes
|
|
|
|
[ship term]
|
|
|
|
%- ~(gas by *(map index:store node:store))
|
2021-04-29 00:12:46 +03:00
|
|
|
%+ turn (tap:orm `graph:store`(lot:orm p.u.graph start end))
|
2020-08-28 01:31:36 +03:00
|
|
|
|= [=atom =node:store]
|
|
|
|
^- [index:store node:store]
|
|
|
|
[~[atom] node]
|
2021-01-11 02:51:36 +03:00
|
|
|
::
|
|
|
|
[%x %node-exists @ @ @ *]
|
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
|
|
|
=/ =index:store
|
|
|
|
(turn t.t.t.t.path (cury slav %ud))
|
|
|
|
=/ node=(unit node:store)
|
|
|
|
(get-node ship term index)
|
|
|
|
``noun+!>(?=(^ node))
|
2020-06-18 22:59:50 +03:00
|
|
|
::
|
|
|
|
[%x %node @ @ @ *]
|
2020-07-07 03:02:15 +03:00
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
|
|
|
=/ =index:store
|
2020-10-05 08:27:26 +03:00
|
|
|
(turn t.t.t.t.path (cury slav %ud))
|
2020-06-26 21:38:11 +03:00
|
|
|
=/ node=(unit node:store) (get-node ship term index)
|
2020-07-28 22:30:59 +03:00
|
|
|
?~ node [~ ~]
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2020-08-28 01:31:36 +03:00
|
|
|
!> ^- update:store
|
2021-03-18 04:50:14 +03:00
|
|
|
:- now.bowl
|
2020-08-28 01:31:36 +03:00
|
|
|
:+ %add-nodes
|
|
|
|
[ship term]
|
|
|
|
(~(gas by *(map index:store node:store)) [index u.node] ~)
|
2020-11-24 08:39:53 +03:00
|
|
|
::
|
|
|
|
[%x %node-siblings ?(%older %younger) @ @ @ *]
|
|
|
|
=/ older ?=(%older i.t.t.path)
|
|
|
|
=/ =ship (slav %p i.t.t.t.path)
|
|
|
|
=/ =term i.t.t.t.t.path
|
2020-12-11 05:21:47 +03:00
|
|
|
=/ count (slav %ud i.t.t.t.t.t.path)
|
2020-11-24 08:39:53 +03:00
|
|
|
=/ =index:store
|
|
|
|
(turn t.t.t.t.t.t.path (cury slav %ud))
|
|
|
|
=/ parent=index:store
|
|
|
|
(scag (dec (lent index)) index)
|
|
|
|
=/ graph
|
|
|
|
(get-node-children ship term parent)
|
|
|
|
?~ graph [~ ~]
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2020-11-24 08:39:53 +03:00
|
|
|
!> ^- update:store
|
2021-03-18 04:50:14 +03:00
|
|
|
:- now.bowl
|
2020-11-24 08:39:53 +03:00
|
|
|
:+ %add-nodes
|
|
|
|
[ship term]
|
|
|
|
%- ~(gas by *(map index:store node:store))
|
2020-12-11 06:05:40 +03:00
|
|
|
:: TODO time complexity not desirable
|
|
|
|
:: replace with custom ordered map functions
|
|
|
|
%+ turn
|
|
|
|
=- ?.(older (slag (safe-sub (lent -) count) -) (scag count -))
|
2020-11-24 08:39:53 +03:00
|
|
|
%- tap:orm
|
2021-04-29 00:12:46 +03:00
|
|
|
%+ lot:orm u.graph
|
2020-11-24 08:39:53 +03:00
|
|
|
=/ idx
|
|
|
|
(snag (dec (lent index)) index)
|
|
|
|
?:(older [`idx ~] [~ `idx])
|
|
|
|
|= [=atom =node:store]
|
|
|
|
^- [index:store node:store]
|
|
|
|
[(snoc parent atom) node]
|
|
|
|
::
|
|
|
|
[%x ?(%newest %oldest) @ @ @ *]
|
|
|
|
=/ newest ?=(%newest i.t.path)
|
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
|
|
|
=/ count=@ud
|
|
|
|
(slav %ud i.t.t.t.t.path)
|
|
|
|
=/ =index:store
|
|
|
|
(turn t.t.t.t.t.path (cury slav %ud))
|
|
|
|
=/ children
|
|
|
|
(get-node-children ship term index)
|
|
|
|
?~ children [~ ~]
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2020-11-24 08:39:53 +03:00
|
|
|
!> ^- update:store
|
2021-03-18 04:50:14 +03:00
|
|
|
:- now.bowl
|
2020-11-24 08:39:53 +03:00
|
|
|
:+ %add-nodes
|
|
|
|
[ship term]
|
|
|
|
%- ~(gas by *(map index:store node:store))
|
|
|
|
%+ turn
|
|
|
|
%+ scag count
|
|
|
|
%- ?:(newest same flop)
|
|
|
|
(tap:orm u.children)
|
|
|
|
|= [=atom =node:store]
|
|
|
|
^- [index:store node:store]
|
|
|
|
[(snoc index atom) node]
|
2020-06-26 21:38:11 +03:00
|
|
|
::
|
|
|
|
[%x %node-children-subset @ @ @ @ @ *]
|
2020-07-07 03:02:15 +03:00
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
2020-07-22 23:32:47 +03:00
|
|
|
=/ start=(unit atom) (rush i.t.t.t.t.path dem:ag)
|
|
|
|
=/ end=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
2020-07-07 03:02:15 +03:00
|
|
|
=/ =index:store
|
|
|
|
(turn t.t.t.t.t.t.path |=(=cord (slav %ud cord)))
|
2020-06-26 21:38:11 +03:00
|
|
|
=/ node=(unit node:store) (get-node ship term index)
|
2020-07-28 22:30:59 +03:00
|
|
|
?~ node [~ ~]
|
2020-06-26 21:38:11 +03:00
|
|
|
?- -.children.u.node
|
2020-07-28 22:30:59 +03:00
|
|
|
%empty [~ ~]
|
2020-08-28 01:31:36 +03:00
|
|
|
%graph
|
2021-04-14 23:49:54 +03:00
|
|
|
:- ~ :- ~ :- %graph-update-2
|
2020-08-28 01:31:36 +03:00
|
|
|
!> ^- update:store
|
2021-03-18 04:50:14 +03:00
|
|
|
:- now.bowl
|
2020-08-28 01:31:36 +03:00
|
|
|
:+ %add-nodes
|
|
|
|
[ship term]
|
|
|
|
%- ~(gas by *(map index:store node:store))
|
2021-04-29 00:12:46 +03:00
|
|
|
%+ turn (tap:orm `graph:store`(lot:orm p.children.u.node end start))
|
2020-08-28 01:31:36 +03:00
|
|
|
|= [=atom =node:store]
|
|
|
|
^- [index:store node:store]
|
|
|
|
[(snoc index atom) node]
|
2020-06-26 21:38:11 +03:00
|
|
|
==
|
2021-05-04 02:25:52 +03:00
|
|
|
::
|
2021-05-14 04:27:24 +03:00
|
|
|
[%x %deep-nodes-older-than @ @ @ @ ~]
|
2021-05-04 02:25:52 +03:00
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
|
|
|
=/ count=(unit atom) (rush i.t.t.t.t.path dem:ag)
|
2021-05-06 00:49:55 +03:00
|
|
|
=/ start=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
2021-05-04 02:25:52 +03:00
|
|
|
?: ?=(~ count)
|
|
|
|
[~ ~]
|
|
|
|
=/ result=(unit marked-graph:store)
|
|
|
|
(~(get by graphs) [ship term])
|
|
|
|
?~ result
|
|
|
|
[~ ~]
|
|
|
|
:- ~ :- ~ :- %graph-update-2
|
|
|
|
!> ^- update:store
|
2021-05-11 21:01:22 +03:00
|
|
|
:- now.bowl
|
2021-05-04 02:25:52 +03:00
|
|
|
:+ %add-nodes
|
|
|
|
[ship term]
|
2021-05-06 01:25:13 +03:00
|
|
|
=* a u.count
|
|
|
|
=/ b=(list (pair atom node:store))
|
|
|
|
(tab:orm p.u.result start u.count)
|
|
|
|
=| c=index:store
|
|
|
|
=| d=(map index:store node:store)
|
|
|
|
=| e=@ud
|
|
|
|
=- d
|
|
|
|
|- ^- [e=@ud d=(map index:store node:store)]
|
|
|
|
?: ?|(?=(~ b) =(e a))
|
|
|
|
[e d]
|
|
|
|
=* atom p.i.b
|
|
|
|
=* node q.i.b
|
2021-05-11 22:27:08 +03:00
|
|
|
=. c (snoc c atom)
|
2021-05-04 02:25:52 +03:00
|
|
|
?- -.children.node
|
2021-05-11 22:27:08 +03:00
|
|
|
%empty
|
2021-05-18 23:02:17 +03:00
|
|
|
$(b t.b, e +(e), d (~(put by d) c node), c (snip c))
|
2021-05-04 02:25:52 +03:00
|
|
|
::
|
|
|
|
%graph
|
2021-05-11 22:27:08 +03:00
|
|
|
=/ f $(b (tab:orm p.children.node ~ (sub a e)))
|
2021-05-06 01:25:13 +03:00
|
|
|
?: =(e.f a) f
|
|
|
|
%_ $
|
2021-05-11 22:27:08 +03:00
|
|
|
b t.b
|
2021-05-06 01:25:13 +03:00
|
|
|
e +(e.f)
|
|
|
|
d (~(put by d.f) c node(children [%empty ~]))
|
2021-05-19 02:01:04 +03:00
|
|
|
c (snip c)
|
2021-05-06 01:25:13 +03:00
|
|
|
==
|
2021-05-04 02:25:52 +03:00
|
|
|
==
|
2021-05-14 04:27:24 +03:00
|
|
|
::
|
2021-05-18 23:42:29 +03:00
|
|
|
[%x %firstborn @ @ @ *]
|
|
|
|
|^
|
2021-05-14 04:27:24 +03:00
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
2021-05-18 23:42:29 +03:00
|
|
|
=/ =index:store
|
|
|
|
(turn t.t.t.t.path (cury slav %ud))
|
|
|
|
?> ?=(^ index)
|
2021-05-14 04:27:24 +03:00
|
|
|
=/ result=(unit marked-graph:store)
|
|
|
|
(~(get by graphs) [ship term])
|
|
|
|
?~ result
|
|
|
|
[~ ~]
|
2021-05-18 23:42:29 +03:00
|
|
|
%- (bond |.(`(unit (unit cage))`[~ ~]))
|
|
|
|
%+ biff
|
|
|
|
(collect-parents p.u.result index ship term)
|
|
|
|
(corl some collect-firstborn)
|
|
|
|
::
|
|
|
|
++ collect-parents
|
|
|
|
|= [=graph:store =index:store =ship =term]
|
|
|
|
^- (unit [node:store index:store (map index:store node:store) ^ship ^term])
|
|
|
|
=| =(map index:store node:store)
|
|
|
|
=| =node:store
|
|
|
|
=| ind=index:store
|
|
|
|
=/ len (lent index)
|
|
|
|
|-
|
|
|
|
?: (gte (lent ind) len)
|
|
|
|
`[node ind map ship term]
|
|
|
|
?> ?=(^ index)
|
|
|
|
=* atom i.index
|
|
|
|
?. (has:orm graph atom)
|
|
|
|
~
|
|
|
|
=: node (got:orm graph atom)
|
|
|
|
ind (snoc ind atom)
|
|
|
|
==
|
|
|
|
?: ?=(%empty -.children.node)
|
2021-05-19 00:56:03 +03:00
|
|
|
?. (gte (lent ind) len)
|
|
|
|
~
|
|
|
|
:- ~
|
|
|
|
:* node ind
|
|
|
|
(~(put by map) ind node)
|
|
|
|
ship term
|
|
|
|
==
|
2021-05-18 23:42:29 +03:00
|
|
|
%_ $
|
|
|
|
index t.index
|
|
|
|
graph p.children.node
|
2021-05-19 00:56:03 +03:00
|
|
|
map (~(put by map) ind node(children empty+~))
|
2021-05-18 23:42:29 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ collect-firstborn
|
|
|
|
|= [=node:store =index:store map=(map index:store node:store) =ship =term]
|
|
|
|
^- (unit (unit cage))
|
|
|
|
?: ?=(%empty -.children.node)
|
|
|
|
:- ~ :- ~ :- %graph-update-2
|
|
|
|
!> ^- update:store
|
|
|
|
[now.bowl [%add-nodes [ship term] map]]
|
|
|
|
=/ item=[k=atom v=node:store]
|
|
|
|
(need (ram:orm p.children.node))
|
|
|
|
=. index (snoc index k.item)
|
|
|
|
$(map (~(put by map) index v.item(children empty+~)), node v.item)
|
|
|
|
--
|
2020-08-19 22:22:20 +03:00
|
|
|
::
|
|
|
|
[%x %update-log-subset @ @ @ @ ~]
|
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
|
|
|
=/ start=(unit time) (slaw %da i.t.t.t.t.path)
|
|
|
|
=/ end=(unit time) (slaw %da i.t.t.t.t.t.path)
|
|
|
|
=/ update-log=(unit update-log:store) (~(get by update-logs) [ship term])
|
|
|
|
?~ update-log [~ ~]
|
2020-11-17 11:00:29 +03:00
|
|
|
:: orm-log is ordered backwards, so swap start and end
|
2021-04-29 00:12:46 +03:00
|
|
|
``noun+!>((lot:orm-log u.update-log end start))
|
2020-06-27 00:36:57 +03:00
|
|
|
::
|
2020-06-30 04:14:55 +03:00
|
|
|
[%x %update-log @ @ ~]
|
2020-06-27 00:36:57 +03:00
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
2020-06-30 04:14:55 +03:00
|
|
|
=/ update-log=(unit update-log:store) (~(get by update-logs) [ship term])
|
2020-07-28 22:30:59 +03:00
|
|
|
?~ update-log [~ ~]
|
2020-06-30 04:14:55 +03:00
|
|
|
``noun+!>(u.update-log)
|
2020-06-27 00:36:57 +03:00
|
|
|
::
|
2020-06-30 04:14:55 +03:00
|
|
|
[%x %peek-update-log @ @ ~]
|
2020-06-27 00:36:57 +03:00
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ =term i.t.t.t.path
|
2020-11-25 07:40:49 +03:00
|
|
|
=/ m-update-log=(unit update-log:store) (~(get by update-logs) [ship term])
|
|
|
|
:- ~ :- ~ :- %noun
|
|
|
|
!> ^- (unit time)
|
|
|
|
%+ biff m-update-log
|
|
|
|
|= =update-log:store
|
|
|
|
=/ result=(unit [=time =update:store])
|
2021-04-29 00:12:46 +03:00
|
|
|
(pry:orm-log:store update-log)
|
2020-11-25 07:40:49 +03:00
|
|
|
(bind result |=([=time update:store] time))
|
2020-06-26 21:38:11 +03:00
|
|
|
==
|
2020-12-11 06:05:40 +03:00
|
|
|
::
|
|
|
|
++ safe-sub
|
|
|
|
|= [a=@ b=@]
|
|
|
|
^- @
|
|
|
|
?: (gte b a)
|
|
|
|
0
|
|
|
|
(sub a b)
|
|
|
|
::
|
2020-11-24 08:39:53 +03:00
|
|
|
++ get-node-children
|
|
|
|
|= [=ship =term =index:store]
|
|
|
|
^- (unit graph:store)
|
|
|
|
?: ?=(~ index)
|
|
|
|
=/ graph
|
|
|
|
(~(get by graphs) [ship term])
|
|
|
|
?~ graph ~
|
|
|
|
`p.u.graph
|
|
|
|
=/ node
|
|
|
|
(get-node ship term index)
|
|
|
|
?~ node ~
|
|
|
|
?: ?=(%empty -.children.u.node)
|
|
|
|
~
|
|
|
|
`p.children.u.node
|
2020-06-26 21:38:11 +03:00
|
|
|
::
|
|
|
|
++ get-node
|
|
|
|
|= [=ship =term =index:store]
|
|
|
|
^- (unit node:store)
|
2020-07-07 03:02:15 +03:00
|
|
|
=/ parent-graph=(unit marked-graph:store)
|
|
|
|
(~(get by graphs) [ship term])
|
2020-06-20 22:56:00 +03:00
|
|
|
?~ parent-graph ~
|
|
|
|
=/ node=(unit node:store) ~
|
2020-07-07 03:02:15 +03:00
|
|
|
=/ =graph:store p.u.parent-graph
|
2020-06-18 22:59:50 +03:00
|
|
|
|-
|
|
|
|
?~ index
|
2020-06-26 21:38:11 +03:00
|
|
|
node
|
2020-06-18 22:59:50 +03:00
|
|
|
?~ t.index
|
2020-06-26 21:38:11 +03:00
|
|
|
(get:orm graph i.index)
|
2020-06-20 22:56:00 +03:00
|
|
|
=. node (get:orm graph i.index)
|
2020-06-18 22:59:50 +03:00
|
|
|
?~ node ~
|
|
|
|
?- -.children.u.node
|
|
|
|
%empty ~
|
2020-06-20 22:56:00 +03:00
|
|
|
%graph $(graph p.children.u.node, index t.index)
|
2020-06-18 22:59:50 +03:00
|
|
|
==
|
2020-06-26 21:38:11 +03:00
|
|
|
--
|
2020-06-02 00:07:31 +03:00
|
|
|
::
|
2020-07-07 02:31:57 +03:00
|
|
|
++ on-arvo
|
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
2020-10-29 07:07:47 +03:00
|
|
|
?+ wire (on-arvo:def wire sign-arvo)
|
|
|
|
::
|
|
|
|
:: old wire, do nothing
|
2021-04-07 01:21:09 +03:00
|
|
|
[%graph *] [~ this]
|
|
|
|
[%validator @ ~] [~ this]
|
2020-12-01 00:08:15 +03:00
|
|
|
::
|
|
|
|
[%try-rejoin @ *]
|
|
|
|
=/ rid=resource:store (de-path:res t.t.wire)
|
|
|
|
=/ nack-count (slav %ud i.t.wire)
|
2020-12-08 03:22:26 +03:00
|
|
|
?> ?=([%behn %wake *] sign-arvo)
|
2020-12-01 00:08:15 +03:00
|
|
|
~? ?=(^ error.sign-arvo)
|
|
|
|
"behn errored in backoff timers, continuing anyway"
|
|
|
|
=/ new=^wire [%try-rejoin (scot %ud +(nack-count)) t.t.wire]
|
|
|
|
:_ this
|
|
|
|
[%pass new %agent [entity.rid %graph-push-hook] %watch resource+t.t.wire]~
|
2020-07-07 02:31:57 +03:00
|
|
|
==
|
|
|
|
::
|
2020-12-01 00:08:15 +03:00
|
|
|
++ on-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card _this)
|
|
|
|
?. ?=([%try-rejoin @ *] wire)
|
|
|
|
(on-agent:def wire sign)
|
|
|
|
?. ?=(%watch-ack -.sign)
|
|
|
|
[~ this]
|
|
|
|
=/ rid=resource:store (de-path:res t.t.wire)
|
|
|
|
?~ p.sign
|
|
|
|
=/ =cage [%pull-hook-action !>([%add entity.rid rid])]
|
|
|
|
:_ this
|
2020-12-02 04:52:24 +03:00
|
|
|
:~ [%pass / %agent [our.bowl %graph-pull-hook] %poke cage]
|
|
|
|
[%pass wire %agent [entity.rid %graph-push-hook] %leave ~]
|
|
|
|
==
|
2020-12-01 00:08:15 +03:00
|
|
|
=/ nack-count=@ud (slav %ud i.t.wire)
|
|
|
|
=/ wakeup=@da
|
|
|
|
(add now.bowl (mul ~s1 (bex (min 19 nack-count))))
|
|
|
|
:_ this
|
|
|
|
[%pass wire %arvo %b %wait wakeup]~
|
|
|
|
::
|
2020-06-02 00:07:31 +03:00
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|