From 56f2d46820fa391bb9a3ed8750d899275e2e7d7d Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 3 Jun 2021 13:56:22 -0500 Subject: [PATCH] graph-store + validators: stop using +grab:noun and switch to using a static conversion to %graph-indexed-post --- pkg/arvo/app/graph-store.hoon | 23 ++++--- pkg/arvo/mar/graph/indexed-post.hoon | 14 ++++ pkg/arvo/mar/graph/validator/chat.hoon | 14 ++-- pkg/arvo/mar/graph/validator/dm.hoon | 14 ++-- pkg/arvo/mar/graph/validator/link.hoon | 45 ++++++------- pkg/arvo/mar/graph/validator/post.hoon | 14 ++-- pkg/arvo/mar/graph/validator/publish.hoon | 78 +++++++++++------------ 7 files changed, 113 insertions(+), 89 deletions(-) create mode 100644 pkg/arvo/mar/graph/indexed-post.hoon diff --git a/pkg/arvo/app/graph-store.hoon b/pkg/arvo/app/graph-store.hoon index a063dbc747..cf9e84ea47 100644 --- a/pkg/arvo/app/graph-store.hoon +++ b/pkg/arvo/app/graph-store.hoon @@ -19,7 +19,7 @@ +$ debug-input [%validate-graph =resource:store] :: +$ cache - $: validators=(map mark dais:clay) + $: validators=(map mark $-(indexed-post:store indexed-post:store)) == :: :: TODO: come back to this and potentially use ford runes or otherwise @@ -627,22 +627,27 @@ |= [=graph:store mark=(unit mark:store)] ^- [? _state] ?~ mark [%.y state] - =/ has-dais (~(has by validators) u.mark) - =/ =dais:clay - ?: has-dais + =/ has-validator (~(has by validators) u.mark) + =/ validate=$-(indexed-post:store indexed-post:store) + ?: has-validator (~(got by validators) u.mark) - .^ =dais:clay - %cb - /(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/[u.mark] + .^ $-(indexed-post:store indexed-post:store) + %cf + (scot %p our.bowl) + q.byk.bowl + (scot %da now.bowl) + u.mark + %graph-indexed-post + ~ == - :_ state(validators (~(put by validators) u.mark dais)) + :_ state(validators (~(put by validators) u.mark validate)) |- ^- ? ?~ graph %.y %+ roll (tap:orm graph) |= [[=atom =node:store] out=?] ^- ? ?& ?| ?=(%| -.post.node) - ?=(^ (vale:dais [atom p.post.node])) + ?=(^ (validate [atom p.post.node])) == :: ?- -.children.node diff --git a/pkg/arvo/mar/graph/indexed-post.hoon b/pkg/arvo/mar/graph/indexed-post.hoon new file mode 100644 index 0000000000..1013a61aae --- /dev/null +++ b/pkg/arvo/mar/graph/indexed-post.hoon @@ -0,0 +1,14 @@ +/- *post +|_ i=indexed-post +++ grow + |% + ++ noun i + -- +:: +++ grab + |% + ++ noun indexed-post + -- +:: +++ grad %noun +-- diff --git a/pkg/arvo/mar/graph/validator/chat.hoon b/pkg/arvo/mar/graph/validator/chat.hoon index f1a0a16843..63a6a8d3a7 100644 --- a/pkg/arvo/mar/graph/validator/chat.hoon +++ b/pkg/arvo/mar/graph/validator/chat.hoon @@ -4,6 +4,11 @@ |% ++ noun i :: + ++ graph-indexed-post + ^- indexed-post + ?> ?=([@ ~] index.p.i) + i + :: ++ graph-permissions-add |= vip=vip-metadata:met ^- permissions:graph @@ -30,13 +35,10 @@ =- [- post(index -)] [atom ~] -- -++ grab +:: +++ grab |% - ++ noun - |: p=`*`%*(. *indexed-post index.p [0 ~]) - =/ ip ;;(indexed-post p) - ?> ?=([@ ~] index.p.ip) - ip + ++ noun indexed-post -- :: ++ grad %noun diff --git a/pkg/arvo/mar/graph/validator/dm.hoon b/pkg/arvo/mar/graph/validator/dm.hoon index 67eae9cbff..85fe37e9db 100644 --- a/pkg/arvo/mar/graph/validator/dm.hoon +++ b/pkg/arvo/mar/graph/validator/dm.hoon @@ -3,6 +3,13 @@ ++ grow |% ++ noun i + :: + ++ graph-indexed-post + ^- indexed-post + ?> ?=(?([@ ~] [@ @ ~]) index.p.i) + ?> (lth i.index.p.i (bex 128)) + i + :: ++ notification-kind ^- (unit notif-kind:hark) ?+ index.p.i ~ @@ -12,12 +19,7 @@ -- ++ grab |% - ++ noun - |: p=`*`%*(. *indexed-post index.p [0 0 ~]) - =/ ip ;;(indexed-post p) - ?> ?=(?([@ ~] [@ @ ~]) index.p.ip) - ?> (lth i.index.p.ip (bex 128)) - ip + ++ noun indexed-post -- :: ++ grad %noun diff --git a/pkg/arvo/mar/graph/validator/link.hoon b/pkg/arvo/mar/graph/validator/link.hoon index 3f0164c363..a59086f1b7 100644 --- a/pkg/arvo/mar/graph/validator/link.hoon +++ b/pkg/arvo/mar/graph/validator/link.hoon @@ -4,6 +4,28 @@ |% ++ noun i :: + ++ graph-indexed-post + ^- indexed-post + ?+ index.p.i ~|(index+index.p.i !!) + :: top-level link post; title and url + :: + [@ ~] + ?> ?=([[%text @] $%([%url @] [%reference *]) ~] contents.p.i) + i + :: + :: comment on link post; container structure + :: + [@ @ ~] + ?> ?=(~ contents.p.i) + i + :: + :: comment on link post; comment text + :: + [@ @ @ ~] + ?> ?=(^ contents.p.i) + i + == + :: ++ graph-permissions-add |= vip=vip-metadata:met ^- permissions:graph @@ -48,28 +70,7 @@ -- ++ grab |% - ++ noun - |: p=`*`%*(. *indexed-post index.p [0 0 ~]) - =/ ip ;;(indexed-post p) - ?+ index.p.ip ~|(index+index.p.ip !!) - :: top-level link post; title and url - :: - [@ ~] - ?> ?=([[%text @] $%([%url @] [%reference *]) ~] contents.p.ip) - ip - :: - :: comment on link post; container structure - :: - [@ @ ~] - ?> ?=(~ contents.p.ip) - ip - :: - :: comment on link post; comment text - :: - [@ @ @ ~] - ?> ?=(^ contents.p.ip) - ip - == + ++ noun indexed-post -- ++ grad %noun -- diff --git a/pkg/arvo/mar/graph/validator/post.hoon b/pkg/arvo/mar/graph/validator/post.hoon index 15c9a3f010..9de65dc375 100644 --- a/pkg/arvo/mar/graph/validator/post.hoon +++ b/pkg/arvo/mar/graph/validator/post.hoon @@ -3,6 +3,12 @@ ++ grow |% ++ noun i + :: + ++ graph-indexed-post + ^- indexed-post + ?> ?=(^ contents.p.i) + i + :: ++ graph-permissions-add |= vip=vip-metadata:met ^- permissions:graph @@ -40,13 +46,7 @@ -- ++ grab |% - :: +noun: validate post - :: - ++ noun - |: p=`*`%*(. *indexed-post contents.p [%text '']~) - =/ ip ;;(indexed-post p) - ?> ?=(^ contents.p.ip) - ip + ++ noun indexed-post -- :: ++ grad %noun diff --git a/pkg/arvo/mar/graph/validator/publish.hoon b/pkg/arvo/mar/graph/validator/publish.hoon index d19812b3e1..e5cfd19117 100644 --- a/pkg/arvo/mar/graph/validator/publish.hoon +++ b/pkg/arvo/mar/graph/validator/publish.hoon @@ -3,6 +3,44 @@ ++ grow |% ++ noun i + :: + ++ graph-indexed-post + ^- indexed-post + ?+ index.p.i !! + :: top level post must have no content + [@ ~] + ?> ?=(~ contents.p.i) + i + :: container for revisions + :: + [@ %1 ~] + ?> ?=(~ contents.p.i) + i + :: specific revision + :: first content is the title + :: revisions are numbered by the revision count + :: starting at one + [@ %1 @ ~] + ?> ?=([* * *] contents.p.i) + ?> ?=(%text -.i.contents.p.i) + i + :: container for comments + :: + [@ %2 ~] + ?> ?=(~ contents.p.i) + i + :: container for comment revisions + :: + [@ %2 @ ~] + ?> ?=(~ contents.p.i) + i + :: specific comment revision + :: + [@ %2 @ @ ~] + ?> ?=(^ contents.p.i) + i + == + :: ++ graph-permissions-add |= vip=vip-metadata:met ^- permissions:graph @@ -55,45 +93,7 @@ -- ++ grab |% - :: +noun: validate publish note - :: - ++ noun - |: p=`*`%*(. *indexed-post index.p [0 ~]) - =/ ip ;;(indexed-post p) - ?+ index.p.ip !! - :: top level post must have no content - [@ ~] - ?> ?=(~ contents.p.ip) - ip - :: container for revisions - :: - [@ %1 ~] - ?> ?=(~ contents.p.ip) - ip - :: specific revision - :: first content is the title - :: revisions are numbered by the revision count - :: starting at one - [@ %1 @ ~] - ?> ?=([* * *] contents.p.ip) - ?> ?=(%text -.i.contents.p.ip) - ip - :: container for comments - :: - [@ %2 ~] - ?> ?=(~ contents.p.ip) - ip - :: container for comment revisions - :: - [@ %2 @ ~] - ?> ?=(~ contents.p.ip) - ip - :: specific comment revision - :: - [@ %2 @ @ ~] - ?> ?=(^ contents.p.ip) - ip - == + ++ noun indexed-post -- :: ++ grad %noun