graph-store: internally cache all scried daises
++ orm orm:store
++ orm-log orm-log:store
+$ debug-input [%validate-graph =resource:store]
+::
++$ cache
+ $: validators=(map mark dais:clay)
+ ==
+::
++$ inflated-state
+ $: state-5
+ cache
+ ==
--
::
-=| state-5
+=| inflated-state
=* state -
::
%- agent:dbug
def ~(. (default-agent this %|) bowl)
::
++ on-init [~ this]
-++ on-save !>(state)
+++ on-save !>(-.state)
++ on-load
|= =old=vase
^- (quip card _this)
(gas:orm-log ~ [now.bowl logged-update] ~)
==
::
- %5 [cards this(state old)]
+ %5 [cards this(-.state old, +.state *cache)]
==
::
++ on-watch
!(~(has by graphs) resource)
== ==
~| "validation of graph {<resource>} failed using mark {<mark>}"
- ?> (validate-graph graph mark)
+ =^ is-valid state
+ (validate-graph graph mark)
+ ?> is-valid
=/ =logged-update:store
[time %add-graph resource graph mark overwrite]
=/ =update-log:store
(~(got by graphs) resource)
~| "cannot add duplicate nodes to {<resource>}"
?< (check-for-duplicates graph ~(key by nodes))
+ ~| "validation of nodes failed using mark {<mark>}"
+ =^ is-valid state
+ (check-validity ~(tap by nodes) mark)
+ ?> is-valid
=/ =update-log:store (~(got by update-logs) resource)
=. update-log
(put:orm-log update-log time [time [%add-nodes resource nodes]])
(add-node-list resource graph mark (sort-nodes nodes))
==
::
+ ++ check-validity
+ |= [lis=(list (pair index:store node:store)) mark=(unit ^mark)]
+ ^- [? _state]
+ |-
+ ?~ lis [& state]
+ =^ is-valid state
+ (validate-graph (gas:orm ~ [(rear p.i.lis) q.i.lis]~) mark)
+ ?. is-valid
+ [| state]
+ $(lis t.lis)
+ ::
++ check-for-duplicates
|= [=graph:store nodes=(set index:store)]
^- ?
==
^- graph:store
?< ?=(~ index)
- ~| "validation of node failed using mark {<mark>}"
- ?> (validate-graph (gas:orm ~ [i.index node]~) mark)
=* atom i.index
%^ put:orm
graph
^- (quip card _state)
=/ [=graph:store mark=(unit mark:store)]
(~(got by graphs) resource.debug-input)
- ?> (validate-graph graph mark)
+ =^ is-valid state
+ (validate-graph graph mark)
+ ?> is-valid
[~ state]
::
++ validate-graph
|= [=graph:store mark=(unit mark:store)]
- ^- ?
- ?~ mark %.y
+ ^- [? _state]
+ ?~ mark [%.y state]
+ =/ has-dais (~(has by validators) u.mark)
=/ =dais:clay
+ ?: has-dais
+ (~(got by validators) u.mark)
.^ =dais:clay
%cb
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/[u.mark]
==
+ :_ state(validators (~(put by validators) u.mark dais))
|- ^- ?
?~ graph %.y
%+ roll (tap:orm graph)
++ poke-import
|= arc=*
^- (quip card _state)
+ =^ cards -.state
(import:store arc our.bowl)
+ [cards state]
--
::
++ on-peek
