From 1c0777e0a776ee1074f1dfb27ae78cc5de2cbf41 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 27 Oct 2020 19:16:00 -0500 Subject: [PATCH 01/11] thread-watcher: first sketch --- pkg/arvo/app/spider.hoon | 4 +- pkg/arvo/app/thread-watch-hook.hoon | 122 ++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 pkg/arvo/app/thread-watch-hook.hoon diff --git a/pkg/arvo/app/spider.hoon b/pkg/arvo/app/spider.hoon index a328e0d476..8eb1c58cce 100644 --- a/pkg/arvo/app/spider.hoon +++ b/pkg/arvo/app/spider.hoon @@ -309,7 +309,9 @@ ++ on-watch-result |= =tid ^- (quip card ^state) - `state + ?: (~(has by tid.state) tid) + `state + ~|('watching a thread that does not exist' !!) :: ++ handle-sign |= [=tid =wire =sign-arvo] diff --git a/pkg/arvo/app/thread-watch-hook.hoon b/pkg/arvo/app/thread-watch-hook.hoon new file mode 100644 index 0000000000..d64b001eff --- /dev/null +++ b/pkg/arvo/app/thread-watch-hook.hoon @@ -0,0 +1,122 @@ +:: thread-watch-hook: +:: +:: watch an app at a particular path and forward all facts to a +:: particular thread +:: +/+ default-agent, dbug +:: +|% + ++$ card card:agent:gall ++$ versioned-state + $% state-0 + == ++$ observer [app=term =path input=mark thread=term] ++$ state-0 [%0 observers=(map time observer)] ++$ action + $% [%watch =observer] + [%ignore =observer] + == +:: +++ got-by-val + |= [a=(map time observer) b=observer] + ^- time + %- need + %+ roll ~(tap by a) + |= [[key=time val=observer] output=(unit time)] + ?:(=(val b) `key output) +-- +:: +%- agent:dbug +=| state-0 +=* state - +:: +^- agent:gall +|_ =bowl:gall ++* this . + def ~(. (default-agent this %|) bowl) +:: +++ on-init on-init:def +++ on-save !>([%0 ~]) +++ on-load + |= old-vase=vase + ^- (quip card _this) + `this(state !<(state-0 old-vase)) +:: +++ on-poke + |= [=mark =vase] + ^- (quip card _this) + ?> (team:title our.bowl src.bowl) + ?. ?=(%thread-watch-action mark) + (on-poke:def mark vase) + =/ =action !<(action vase) + =/ vals (silt ~(val by observers)) + ?- -.action + %watch + ?: ?|(=(app.action %spider) =(app.action %thread-watch-hook)) + ~|('we avoid infinite loops' !!) + ?: (~(has in vals) observer.action) + ~|('duplicate observer' !!) + :_ this(observers.state (~(put by observers) now.bowl observer.action)) + :_ ~ + :* %pass + /observer/(scot %da now.bowl) + %agent + [our.bowl app.action] + %watch + path.action + == + :: + %ignore + ?. (~(has in vals) observer.action) + ~|('cannot remove nonexistent observer' !!) + =/ key (got-by-val observers observer.action) + :_ this(observers.state (~(del by observers) key)) + :_ ~ + :* %pass + /observer/(scot %da key) + %agent + [our.bowl app.action] + %leave + ~ + == + == +:: +++ on-agent + |= [=wire =sign:agent:gall] + ^- (quip card _this) + ?+ -.sign (on-agent:def wire sign) + %kick + :: TODO: handle this by resubscribing... unless it's a + :: thread-result kick + [~ this] + :: + %poke-ack + :: if thread start fails, delete observer! + [~ this] + :: + %watch-ack + :: TODO: handle nack by deleting observer + [~ this] + :: + %fact + ?+ wire (on-agent wire sign) + [%thread-result @ ~] + :: TODO: process whether the thread succeeded or failed and + :: respond accordingly + :: spider: if we get a %thread-fail on a %thread-result fact... delete the + :: observer + [~ this] + :: + [%observer @ ~] + :: TODO: spin up a thread to process input + [~ this] + == + == +:: +++ on-watch on-watch:def +++ on-leave on-leave:def +++ on-peek on-peek:def +++ on-arvo on-arvo:def +++ on-fail on-fail:def +-- From ce43ea07658356d6a05b5102d387edbd4c120bb8 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 29 Oct 2020 15:02:09 -0500 Subject: [PATCH 02/11] thread-watch-hook: compiles properly --- pkg/arvo/app/spider.hoon | 4 +- pkg/arvo/app/thread-watch-hook.hoon | 114 +++++++++++++++++++++------- 2 files changed, 89 insertions(+), 29 deletions(-) diff --git a/pkg/arvo/app/spider.hoon b/pkg/arvo/app/spider.hoon index 8eb1c58cce..a328e0d476 100644 --- a/pkg/arvo/app/spider.hoon +++ b/pkg/arvo/app/spider.hoon @@ -309,9 +309,7 @@ ++ on-watch-result |= =tid ^- (quip card ^state) - ?: (~(has by tid.state) tid) - `state - ~|('watching a thread that does not exist' !!) + `state :: ++ handle-sign |= [=tid =wire =sign-arvo] diff --git a/pkg/arvo/app/thread-watch-hook.hoon b/pkg/arvo/app/thread-watch-hook.hoon index d64b001eff..e54c22c50e 100644 --- a/pkg/arvo/app/thread-watch-hook.hoon +++ b/pkg/arvo/app/thread-watch-hook.hoon @@ -6,7 +6,6 @@ /+ default-agent, dbug :: |% - +$ card card:agent:gall +$ versioned-state $% state-0 @@ -50,33 +49,34 @@ ?. ?=(%thread-watch-action mark) (on-poke:def mark vase) =/ =action !<(action vase) + =* observer observer.action =/ vals (silt ~(val by observers)) ?- -.action %watch - ?: ?|(=(app.action %spider) =(app.action %thread-watch-hook)) + ?: ?|(=(app.observer %spider) =(app.observer %thread-watch-hook)) ~|('we avoid infinite loops' !!) - ?: (~(has in vals) observer.action) + ?: (~(has in vals) observer) ~|('duplicate observer' !!) - :_ this(observers.state (~(put by observers) now.bowl observer.action)) + :_ this(observers (~(put by observers) now.bowl observer)) :_ ~ :* %pass /observer/(scot %da now.bowl) %agent - [our.bowl app.action] + [our.bowl app.observer] %watch - path.action + path.observer == :: %ignore - ?. (~(has in vals) observer.action) + ?. (~(has in vals) observer) ~|('cannot remove nonexistent observer' !!) - =/ key (got-by-val observers observer.action) - :_ this(observers.state (~(del by observers) key)) + =/ key (got-by-val observers observer) + :_ this(observers (~(del by observers) key)) :_ ~ :* %pass /observer/(scot %da key) %agent - [our.bowl app.action] + [our.bowl app.observer] %leave ~ == @@ -85,32 +85,94 @@ ++ on-agent |= [=wire =sign:agent:gall] ^- (quip card _this) - ?+ -.sign (on-agent:def wire sign) + ?- -.sign %kick - :: TODO: handle this by resubscribing... unless it's a - :: thread-result kick - [~ this] + ?+ wire (on-agent:def wire sign) + [%thread-result @ ~] [~ this] + [%observer @ ~] + =/ =time (slav %da i.t.wire) + =/ =observer (~(got by observers) time) + :_ this + :_ ~ + :* %pass + wire + %agent + [our.bowl app.observer] + %watch + path.observer + == + == :: %poke-ack - :: if thread start fails, delete observer! - [~ this] + ?. ?=([%thread-start @ @ ~] wire) + (on-agent:def wire sign) + ?~ p.sign [~ this] + =/ =time (slav %da i.t.wire) + =/ tid (slav %uv i.t.t.wire) + =/ =observer (~(got by observers) time) + :_ this(observers (~(del by observers) time)) + :~ :* %pass + [%observer i.t.wire ~] + %agent + [our.bowl app.observer] + %leave + ~ + == + :* %pass + wire + %agent + [our.bowl app.observer] + %leave + ~ + == + == :: %watch-ack - :: TODO: handle nack by deleting observer - [~ this] + ?~ p.sign [~ this] + ?+ wire (on-agent:def wire sign) + [%thread-result @ ~] [~ this] + [%observer @ ~] + =/ =time (slav %da i.t.wire) + [~ this(observers (~(del by observers) time))] + == :: %fact - ?+ wire (on-agent wire sign) + ?+ wire (on-agent:def wire sign) [%thread-result @ ~] - :: TODO: process whether the thread succeeded or failed and - :: respond accordingly - :: spider: if we get a %thread-fail on a %thread-result fact... delete the - :: observer - [~ this] + ?. =(p.cage.sign %thread-fail) + [~ this] + =/ =time (slav %da i.t.wire) + =/ =observer (~(got by observers) time) + :_ this(observers (~(del by observers) time)) + :_ ~ + :* %pass + [%observer i.t.wire ~] + %agent + [our.bowl app.observer] + %leave + ~ + == :: [%observer @ ~] - :: TODO: spin up a thread to process input - [~ this] + =/ =time (slav %da i.t.wire) + =/ =observer (~(got by observers) time) + =/ tid (scot %uv (sham eny.bowl)) + :_ this + :~ :* %pass + [%thread-start i.t.wire tid ~] + %agent + [our.bowl %spider] + %poke + %spider-start + !>([~ `tid thread.observer q.cage.sign]) + == + :* %pass + [%thread-result tid ~] + %agent + [our.bowl %spider] + %watch + [%thread-result tid ~] + == == == == :: From 353d328340afaaf9d6f63242aefb31f9be7f4805 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 2 Nov 2020 12:25:32 -0600 Subject: [PATCH 03/11] thread-watch-hook: moved to marks and slopped vases --- pkg/arvo/app/thread-watch-hook.hoon | 24 ++++++++++-------------- pkg/arvo/mar/thread-watch/action.hoon | 13 +++++++++++++ pkg/arvo/sur/thread-watch-hook.hoon | 7 +++++++ 3 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 pkg/arvo/mar/thread-watch/action.hoon create mode 100644 pkg/arvo/sur/thread-watch-hook.hoon diff --git a/pkg/arvo/app/thread-watch-hook.hoon b/pkg/arvo/app/thread-watch-hook.hoon index e54c22c50e..7a67987fb0 100644 --- a/pkg/arvo/app/thread-watch-hook.hoon +++ b/pkg/arvo/app/thread-watch-hook.hoon @@ -3,6 +3,7 @@ :: watch an app at a particular path and forward all facts to a :: particular thread :: +/- sur=thread-watch-hook /+ default-agent, dbug :: |% @@ -10,19 +11,14 @@ +$ versioned-state $% state-0 == -+$ observer [app=term =path input=mark thread=term] -+$ state-0 [%0 observers=(map time observer)] -+$ action - $% [%watch =observer] - [%ignore =observer] - == :: ++$ state-0 [%0 observers=(map time observer:sur)] ++ got-by-val - |= [a=(map time observer) b=observer] + |= [a=(map time observer:sur) b=observer:sur] ^- time %- need %+ roll ~(tap by a) - |= [[key=time val=observer] output=(unit time)] + |= [[key=time val=observer:sur] output=(unit time)] ?:(=(val b) `key output) -- :: @@ -48,7 +44,7 @@ ?> (team:title our.bowl src.bowl) ?. ?=(%thread-watch-action mark) (on-poke:def mark vase) - =/ =action !<(action vase) + =/ =action:sur !<(action:sur vase) =* observer observer.action =/ vals (silt ~(val by observers)) ?- -.action @@ -91,7 +87,7 @@ [%thread-result @ ~] [~ this] [%observer @ ~] =/ =time (slav %da i.t.wire) - =/ =observer (~(got by observers) time) + =/ =observer:sur (~(got by observers) time) :_ this :_ ~ :* %pass @@ -109,7 +105,7 @@ ?~ p.sign [~ this] =/ =time (slav %da i.t.wire) =/ tid (slav %uv i.t.t.wire) - =/ =observer (~(got by observers) time) + =/ =observer:sur (~(got by observers) time) :_ this(observers (~(del by observers) time)) :~ :* %pass [%observer i.t.wire ~] @@ -142,7 +138,7 @@ ?. =(p.cage.sign %thread-fail) [~ this] =/ =time (slav %da i.t.wire) - =/ =observer (~(got by observers) time) + =/ =observer:sur (~(got by observers) time) :_ this(observers (~(del by observers) time)) :_ ~ :* %pass @@ -155,7 +151,7 @@ :: [%observer @ ~] =/ =time (slav %da i.t.wire) - =/ =observer (~(got by observers) time) + =/ =observer:sur (~(got by observers) time) =/ tid (scot %uv (sham eny.bowl)) :_ this :~ :* %pass @@ -164,7 +160,7 @@ [our.bowl %spider] %poke %spider-start - !>([~ `tid thread.observer q.cage.sign]) + !>([~ `tid thread.observer (slop !>(cage.sign) !>(~))]) == :* %pass [%thread-result tid ~] diff --git a/pkg/arvo/mar/thread-watch/action.hoon b/pkg/arvo/mar/thread-watch/action.hoon new file mode 100644 index 0000000000..282acd96ce --- /dev/null +++ b/pkg/arvo/mar/thread-watch/action.hoon @@ -0,0 +1,13 @@ +/- sur=thread-watch-hook +|_ =action:sur +++ grad %noun +++ grow + |% + ++ noun action + -- +:: +++ grab + |% + ++ noun action:sur + -- +-- diff --git a/pkg/arvo/sur/thread-watch-hook.hoon b/pkg/arvo/sur/thread-watch-hook.hoon new file mode 100644 index 0000000000..a424c96229 --- /dev/null +++ b/pkg/arvo/sur/thread-watch-hook.hoon @@ -0,0 +1,7 @@ +|% ++$ observer [app=term =path thread=term] ++$ action + $% [%watch =observer] + [%ignore =observer] + == +-- From 1b8af7d78ca17c03d5a9e1f85c9346aa5cc48ba6 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 2 Nov 2020 13:17:24 -0600 Subject: [PATCH 04/11] hood: start %thread-watch-hook --- pkg/arvo/app/hood.hoon | 3 ++- pkg/arvo/lib/hood/drum.hoon | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/hood.hoon b/pkg/arvo/app/hood.hoon index 433ccb2e40..7ea33fe6b9 100644 --- a/pkg/arvo/app/hood.hoon +++ b/pkg/arvo/app/hood.hoon @@ -2,7 +2,7 @@ /+ drum=hood-drum, helm=hood-helm, kiln=hood-kiln |% +$ state - $: %10 + $: %11 drum=state:drum helm=state:helm kiln=state:kiln @@ -13,6 +13,7 @@ [%7 drum=state:drum helm=state:helm kiln=state:kiln] [%8 drum=state:drum helm=state:helm kiln=state:kiln] [%9 drum=state:drum helm=state:helm kiln=state:kiln] + [%10 drum=state:drum helm=state:helm kiln=state:kiln] == +$ any-state-tuple $: drum=any-state:drum diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index a41c917a7c..46c25fc6c2 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -107,6 +107,7 @@ %graph-store %graph-pull-hook %graph-push-hook + %thread-watch-hook == :: ++ deft-fish :: default connects @@ -209,7 +210,7 @@ == :: ++ on-load - |= [hood-version=?(%1 %2 %3 %4 %5 %6 %7 %8 %9 %10) old=any-state] + |= [hood-version=?(%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11) old=any-state] =< se-abet =< se-view =. sat old =. dev (~(gut by bin) ost *source) @@ -241,6 +242,8 @@ =? ..on-load (lte hood-version %10) => (se-born | %home %graph-push-hook) (se-born | %home %graph-pull-hook) + =? ..on-load (lte hood-version %11) + (se-born | %home %thread-watch-hook) ..on-load :: ++ reap-phat :: ack connect From 697d23f83aaf5ae45766741e16fc4255a540d218 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 2 Nov 2020 15:22:08 -0600 Subject: [PATCH 05/11] thread-watch-hook: made %invite-accepted-graph thread --- pkg/arvo/app/thread-watch-hook.hoon | 8 ++++--- pkg/arvo/ted/invite/accepted-graph.hoon | 30 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 pkg/arvo/ted/invite/accepted-graph.hoon diff --git a/pkg/arvo/app/thread-watch-hook.hoon b/pkg/arvo/app/thread-watch-hook.hoon index 7a67987fb0..ee014c8f58 100644 --- a/pkg/arvo/app/thread-watch-hook.hoon +++ b/pkg/arvo/app/thread-watch-hook.hoon @@ -1,7 +1,7 @@ :: thread-watch-hook: :: -:: watch an app at a particular path and forward all facts to a -:: particular thread +:: helper that observes an app at a particular path and forwards all facts +:: to a particular thread. kills the subscription if the thread crashes :: /- sur=thread-watch-hook /+ default-agent, dbug @@ -32,7 +32,7 @@ def ~(. (default-agent this %|) bowl) :: ++ on-init on-init:def -++ on-save !>([%0 ~]) +++ on-save !>(state) ++ on-load |= old-vase=vase ^- (quip card _this) @@ -81,6 +81,7 @@ ++ on-agent |= [=wire =sign:agent:gall] ^- (quip card _this) + ~& [wire sign] ?- -.sign %kick ?+ wire (on-agent:def wire sign) @@ -102,6 +103,7 @@ %poke-ack ?. ?=([%thread-start @ @ ~] wire) (on-agent:def wire sign) + ~& sign ?~ p.sign [~ this] =/ =time (slav %da i.t.wire) =/ tid (slav %uv i.t.t.wire) diff --git a/pkg/arvo/ted/invite/accepted-graph.hoon b/pkg/arvo/ted/invite/accepted-graph.hoon new file mode 100644 index 0000000000..2ad0af5fa2 --- /dev/null +++ b/pkg/arvo/ted/invite/accepted-graph.hoon @@ -0,0 +1,30 @@ +/- spider, inv=invite-store, graph-view +/+ strandio +:: +=* strand strand:spider +=* fail strand-fail:strand +=* poke-our poke-our:strandio +=* start-thread start-thread:strandio +:: +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=+ !<([=update:inv ~] arg) +~& update +?. ?=(%accepted -.update) + (pure:m !>(~)) +;< =bowl:spider bind:m get-bowl:strandio +=* invite invite.update +?: =(our.bowl entity.resource.invite) + :: do not crash because that will kill the invitatory subscription + (pure:m !>(~)) +~& 'send graph-join' +;< ~ bind:m + %+ poke-our %spider + =- spider-start+!>([`tid.bowl ~ %graph-join -]) + %+ slop + !> ^- action:graph-view + [%join resource.invite ship.invite] + !>(~) +(pure:m !>(~)) From 65291863a0fbbac8bfbe82eb6761a0a1ce05bd73 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 3 Nov 2020 12:40:47 -0600 Subject: [PATCH 06/11] thread-watch-hook: successfully sends facts to %invite-accepted-graph thread --- pkg/arvo/app/thread-watch-hook.hoon | 4 +++- pkg/arvo/ted/invite/accepted-graph.hoon | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/app/thread-watch-hook.hoon b/pkg/arvo/app/thread-watch-hook.hoon index ee014c8f58..3cb49b4603 100644 --- a/pkg/arvo/app/thread-watch-hook.hoon +++ b/pkg/arvo/app/thread-watch-hook.hoon @@ -141,6 +141,7 @@ [~ this] =/ =time (slav %da i.t.wire) =/ =observer:sur (~(got by observers) time) + ~& [time observer] :_ this(observers (~(del by observers) time)) :_ ~ :* %pass @@ -155,6 +156,7 @@ =/ =time (slav %da i.t.wire) =/ =observer:sur (~(got by observers) time) =/ tid (scot %uv (sham eny.bowl)) + ~& [time observer tid] :_ this :~ :* %pass [%thread-start i.t.wire tid ~] @@ -162,7 +164,7 @@ [our.bowl %spider] %poke %spider-start - !>([~ `tid thread.observer (slop !>(cage.sign) !>(~))]) + !>([~ `tid thread.observer (slop q.cage.sign !>(~))]) == :* %pass [%thread-result tid ~] diff --git a/pkg/arvo/ted/invite/accepted-graph.hoon b/pkg/arvo/ted/invite/accepted-graph.hoon index 2ad0af5fa2..a30aa4d5ea 100644 --- a/pkg/arvo/ted/invite/accepted-graph.hoon +++ b/pkg/arvo/ted/invite/accepted-graph.hoon @@ -4,14 +4,15 @@ =* strand strand:spider =* fail strand-fail:strand =* poke-our poke-our:strandio -=* start-thread start-thread:strandio +=* flog-text flog-text:strandio :: ^- thread:spider |= arg=vase =/ m (strand ,vase) ^- form:m =+ !<([=update:inv ~] arg) -~& update +;< ~ bind:m + (flog-text "{}") ?. ?=(%accepted -.update) (pure:m !>(~)) ;< =bowl:spider bind:m get-bowl:strandio From 06062757db5ca654d097377f35598025a651b808 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 4 Nov 2020 14:55:46 -0600 Subject: [PATCH 07/11] thread-watch-hook: add +on-init to watch graph invitatory, and remove ~& --- pkg/arvo/app/thread-watch-hook.hoon | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/app/thread-watch-hook.hoon b/pkg/arvo/app/thread-watch-hook.hoon index 3cb49b4603..27bc9777a7 100644 --- a/pkg/arvo/app/thread-watch-hook.hoon +++ b/pkg/arvo/app/thread-watch-hook.hoon @@ -31,7 +31,26 @@ +* this . def ~(. (default-agent this %|) bowl) :: -++ on-init on-init:def +++ on-init + |^ ^- (quip card _this) + :_ this + :~ (act /inv-acc-gra [%watch /invitatory/graph %invite-accepted-graph]) + == + :: + ++ act + |= [=wire =action:sur] + ^- card + :* %pass + wire + %agent + [our.bowl %thread-watch-hook] + %poke + %thread-watch-action + !> ^- action:sur + action + == + -- +:: ++ on-save !>(state) ++ on-load |= old-vase=vase @@ -81,7 +100,6 @@ ++ on-agent |= [=wire =sign:agent:gall] ^- (quip card _this) - ~& [wire sign] ?- -.sign %kick ?+ wire (on-agent:def wire sign) @@ -103,7 +121,6 @@ %poke-ack ?. ?=([%thread-start @ @ ~] wire) (on-agent:def wire sign) - ~& sign ?~ p.sign [~ this] =/ =time (slav %da i.t.wire) =/ tid (slav %uv i.t.t.wire) @@ -141,7 +158,6 @@ [~ this] =/ =time (slav %da i.t.wire) =/ =observer:sur (~(got by observers) time) - ~& [time observer] :_ this(observers (~(del by observers) time)) :_ ~ :* %pass @@ -156,7 +172,6 @@ =/ =time (slav %da i.t.wire) =/ =observer:sur (~(got by observers) time) =/ tid (scot %uv (sham eny.bowl)) - ~& [time observer tid] :_ this :~ :* %pass [%thread-start i.t.wire tid ~] From ed81e2304dca2d51957342c0b8da41e26a1cf344 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 4 Nov 2020 15:14:18 -0600 Subject: [PATCH 08/11] thread-watch-hook: compiles --- pkg/arvo/app/thread-watch-hook.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/thread-watch-hook.hoon b/pkg/arvo/app/thread-watch-hook.hoon index 27bc9777a7..c8f6c1e61d 100644 --- a/pkg/arvo/app/thread-watch-hook.hoon +++ b/pkg/arvo/app/thread-watch-hook.hoon @@ -34,8 +34,8 @@ ++ on-init |^ ^- (quip card _this) :_ this - :~ (act /inv-acc-gra [%watch /invitatory/graph %invite-accepted-graph]) - == + :_ ~ + (act /inv-gra [%watch %invite-store /invitatory/graph %invite-accepted-graph]) :: ++ act |= [=wire =action:sur] From 63a0bb00c01bcf1fd6fc28607c976f96bca74b06 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 4 Nov 2020 18:42:52 -0600 Subject: [PATCH 09/11] thread-watch-hook: edge cases tested and fixed --- pkg/arvo/app/thread-watch-hook.hoon | 53 ++++++++++++++++--------- pkg/arvo/ted/invite/accepted-graph.hoon | 3 -- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/pkg/arvo/app/thread-watch-hook.hoon b/pkg/arvo/app/thread-watch-hook.hoon index c8f6c1e61d..477fd475a4 100644 --- a/pkg/arvo/app/thread-watch-hook.hoon +++ b/pkg/arvo/app/thread-watch-hook.hoon @@ -123,8 +123,8 @@ (on-agent:def wire sign) ?~ p.sign [~ this] =/ =time (slav %da i.t.wire) - =/ tid (slav %uv i.t.t.wire) =/ =observer:sur (~(got by observers) time) + ~& added-invalid-observer+observer :_ this(observers (~(del by observers) time)) :~ :* %pass [%observer i.t.wire ~] @@ -148,6 +148,7 @@ [%thread-result @ ~] [~ this] [%observer @ ~] =/ =time (slav %da i.t.wire) + ~& watch-ack-deleting-observer+(~(got by observers) time) [~ this(observers (~(del by observers) time))] == :: @@ -155,18 +156,34 @@ ?+ wire (on-agent:def wire sign) [%thread-result @ ~] ?. =(p.cage.sign %thread-fail) - [~ this] + :_ this + :_ ~ + :* %pass + wire + %agent + [our.bowl %spider] + %leave + ~ + == =/ =time (slav %da i.t.wire) =/ =observer:sur (~(got by observers) time) + ~& observer-failed+observer :_ this(observers (~(del by observers) time)) - :_ ~ - :* %pass - [%observer i.t.wire ~] - %agent - [our.bowl app.observer] - %leave - ~ - == + :~ :* %pass + [%observer i.t.wire ~] + %agent + [our.bowl app.observer] + %leave + ~ + == + :* %pass + wire + %agent + [our.bowl %spider] + %leave + ~ + == + == :: [%observer @ ~] =/ =time (slav %da i.t.wire) @@ -174,20 +191,20 @@ =/ tid (scot %uv (sham eny.bowl)) :_ this :~ :* %pass + [%thread-result i.t.wire ~] + %agent + [our.bowl %spider] + %watch + [%thread-result tid ~] + == + :* %pass [%thread-start i.t.wire tid ~] %agent [our.bowl %spider] %poke %spider-start !>([~ `tid thread.observer (slop q.cage.sign !>(~))]) - == - :* %pass - [%thread-result tid ~] - %agent - [our.bowl %spider] - %watch - [%thread-result tid ~] - == == + == == == == :: diff --git a/pkg/arvo/ted/invite/accepted-graph.hoon b/pkg/arvo/ted/invite/accepted-graph.hoon index a30aa4d5ea..bb1227082d 100644 --- a/pkg/arvo/ted/invite/accepted-graph.hoon +++ b/pkg/arvo/ted/invite/accepted-graph.hoon @@ -11,8 +11,6 @@ =/ m (strand ,vase) ^- form:m =+ !<([=update:inv ~] arg) -;< ~ bind:m - (flog-text "{}") ?. ?=(%accepted -.update) (pure:m !>(~)) ;< =bowl:spider bind:m get-bowl:strandio @@ -20,7 +18,6 @@ ?: =(our.bowl entity.resource.invite) :: do not crash because that will kill the invitatory subscription (pure:m !>(~)) -~& 'send graph-join' ;< ~ bind:m %+ poke-our %spider =- spider-start+!>([`tid.bowl ~ %graph-join -]) From 4b7f0e802589154157bd2ad01914065686e0267a Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Fri, 6 Nov 2020 14:55:32 -0600 Subject: [PATCH 10/11] thread-watch: change name to observe-hook --- .../{thread-watch-hook.hoon => observe-hook.hoon} | 12 ++++++------ pkg/arvo/lib/hood/drum.hoon | 4 ++-- pkg/arvo/mar/{thread-watch => observe}/action.hoon | 2 +- .../{thread-watch-hook.hoon => observe-hook.hoon} | 0 4 files changed, 9 insertions(+), 9 deletions(-) rename pkg/arvo/app/{thread-watch-hook.hoon => observe-hook.hoon} (95%) rename pkg/arvo/mar/{thread-watch => observe}/action.hoon (81%) rename pkg/arvo/sur/{thread-watch-hook.hoon => observe-hook.hoon} (100%) diff --git a/pkg/arvo/app/thread-watch-hook.hoon b/pkg/arvo/app/observe-hook.hoon similarity index 95% rename from pkg/arvo/app/thread-watch-hook.hoon rename to pkg/arvo/app/observe-hook.hoon index 477fd475a4..7e3de5185a 100644 --- a/pkg/arvo/app/thread-watch-hook.hoon +++ b/pkg/arvo/app/observe-hook.hoon @@ -1,9 +1,9 @@ -:: thread-watch-hook: +:: observe-hook: :: :: helper that observes an app at a particular path and forwards all facts :: to a particular thread. kills the subscription if the thread crashes :: -/- sur=thread-watch-hook +/- sur=observe-hook /+ default-agent, dbug :: |% @@ -43,9 +43,9 @@ :* %pass wire %agent - [our.bowl %thread-watch-hook] + [our.bowl %observe-hook] %poke - %thread-watch-action + %observe-action !> ^- action:sur action == @@ -61,14 +61,14 @@ |= [=mark =vase] ^- (quip card _this) ?> (team:title our.bowl src.bowl) - ?. ?=(%thread-watch-action mark) + ?. ?=(%observe-action mark) (on-poke:def mark vase) =/ =action:sur !<(action:sur vase) =* observer observer.action =/ vals (silt ~(val by observers)) ?- -.action %watch - ?: ?|(=(app.observer %spider) =(app.observer %thread-watch-hook)) + ?: ?|(=(app.observer %spider) =(app.observer %observe-hook)) ~|('we avoid infinite loops' !!) ?: (~(has in vals) observer) ~|('duplicate observer' !!) diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index 46c25fc6c2..826d618fd4 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -107,7 +107,7 @@ %graph-store %graph-pull-hook %graph-push-hook - %thread-watch-hook + %observe-hook == :: ++ deft-fish :: default connects @@ -243,7 +243,7 @@ => (se-born | %home %graph-push-hook) (se-born | %home %graph-pull-hook) =? ..on-load (lte hood-version %11) - (se-born | %home %thread-watch-hook) + (se-born | %home %observe-hook) ..on-load :: ++ reap-phat :: ack connect diff --git a/pkg/arvo/mar/thread-watch/action.hoon b/pkg/arvo/mar/observe/action.hoon similarity index 81% rename from pkg/arvo/mar/thread-watch/action.hoon rename to pkg/arvo/mar/observe/action.hoon index 282acd96ce..466debd69d 100644 --- a/pkg/arvo/mar/thread-watch/action.hoon +++ b/pkg/arvo/mar/observe/action.hoon @@ -1,4 +1,4 @@ -/- sur=thread-watch-hook +/- sur=observe-hook |_ =action:sur ++ grad %noun ++ grow diff --git a/pkg/arvo/sur/thread-watch-hook.hoon b/pkg/arvo/sur/observe-hook.hoon similarity index 100% rename from pkg/arvo/sur/thread-watch-hook.hoon rename to pkg/arvo/sur/observe-hook.hoon From f714fa602eb062d9e7be20cc952ab7ffa6b1dccb Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Fri, 6 Nov 2020 15:29:15 -0600 Subject: [PATCH 11/11] observe-hook: switch from time to serial, and reorganize on-agent --- pkg/arvo/app/observe-hook.hoon | 178 +++++++++++++++++---------------- 1 file changed, 92 insertions(+), 86 deletions(-) diff --git a/pkg/arvo/app/observe-hook.hoon b/pkg/arvo/app/observe-hook.hoon index 7e3de5185a..174b90b13c 100644 --- a/pkg/arvo/app/observe-hook.hoon +++ b/pkg/arvo/app/observe-hook.hoon @@ -12,13 +12,14 @@ $% state-0 == :: -+$ state-0 [%0 observers=(map time observer:sur)] ++$ serial @uv ++$ state-0 [%0 observers=(map serial observer:sur)] ++ got-by-val - |= [a=(map time observer:sur) b=observer:sur] - ^- time + |= [a=(map serial observer:sur) b=observer:sur] + ^- serial %- need %+ roll ~(tap by a) - |= [[key=time val=observer:sur] output=(unit time)] + |= [[key=serial val=observer:sur] output=(unit serial)] ?:(=(val b) `key output) -- :: @@ -72,10 +73,10 @@ ~|('we avoid infinite loops' !!) ?: (~(has in vals) observer) ~|('duplicate observer' !!) - :_ this(observers (~(put by observers) now.bowl observer)) + :_ this(observers (~(put by observers) (sham eny.bowl) observer)) :_ ~ :* %pass - /observer/(scot %da now.bowl) + /observer/(scot %uv (sham eny.bowl)) %agent [our.bowl app.observer] %watch @@ -89,7 +90,7 @@ :_ this(observers (~(del by observers) key)) :_ ~ :* %pass - /observer/(scot %da key) + /observer/(scot %uv key) %agent [our.bowl app.observer] %leave @@ -100,13 +101,25 @@ ++ on-agent |= [=wire =sign:agent:gall] ^- (quip card _this) - ?- -.sign - %kick - ?+ wire (on-agent:def wire sign) - [%thread-result @ ~] [~ this] - [%observer @ ~] - =/ =time (slav %da i.t.wire) - =/ =observer:sur (~(got by observers) time) + |^ + ?+ wire (on-agent:def wire sign) + [%observer @ ~] on-observer + [%thread-result @ ~] on-thread-result + [%thread-start @ @ ~] on-thread-start + == + :: + ++ on-observer + ?> ?=([%observer @ ~] wire) + ?+ -.sign (on-agent:def wire sign) + %watch-ack + ?~ p.sign [~ this] + =/ =serial (slav %uv i.t.wire) + ~& watch-ack-deleting-observer+(~(got by observers) serial) + [~ this(observers (~(del by observers) serial))] + :: + %kick + =/ =serial (slav %uv i.t.wire) + =/ =observer:sur (~(got by observers) serial) :_ this :_ ~ :* %pass @@ -116,78 +129,10 @@ %watch path.observer == - == - :: - %poke-ack - ?. ?=([%thread-start @ @ ~] wire) - (on-agent:def wire sign) - ?~ p.sign [~ this] - =/ =time (slav %da i.t.wire) - =/ =observer:sur (~(got by observers) time) - ~& added-invalid-observer+observer - :_ this(observers (~(del by observers) time)) - :~ :* %pass - [%observer i.t.wire ~] - %agent - [our.bowl app.observer] - %leave - ~ - == - :* %pass - wire - %agent - [our.bowl app.observer] - %leave - ~ - == - == - :: - %watch-ack - ?~ p.sign [~ this] - ?+ wire (on-agent:def wire sign) - [%thread-result @ ~] [~ this] - [%observer @ ~] - =/ =time (slav %da i.t.wire) - ~& watch-ack-deleting-observer+(~(got by observers) time) - [~ this(observers (~(del by observers) time))] - == - :: - %fact - ?+ wire (on-agent:def wire sign) - [%thread-result @ ~] - ?. =(p.cage.sign %thread-fail) - :_ this - :_ ~ - :* %pass - wire - %agent - [our.bowl %spider] - %leave - ~ - == - =/ =time (slav %da i.t.wire) - =/ =observer:sur (~(got by observers) time) - ~& observer-failed+observer - :_ this(observers (~(del by observers) time)) - :~ :* %pass - [%observer i.t.wire ~] - %agent - [our.bowl app.observer] - %leave - ~ - == - :* %pass - wire - %agent - [our.bowl %spider] - %leave - ~ - == - == :: - [%observer @ ~] - =/ =time (slav %da i.t.wire) - =/ =observer:sur (~(got by observers) time) + %fact + =/ =serial (slav %uv i.t.wire) + =/ =observer:sur (~(got by observers) serial) =/ tid (scot %uv (sham eny.bowl)) :_ this :~ :* %pass @@ -206,7 +151,68 @@ !>([~ `tid thread.observer (slop q.cage.sign !>(~))]) == == == - == + :: + ++ on-thread-result + ?> ?=([%thread-result @ ~] wire) + ?+ -.sign (on-agent:def wire sign) + %kick [~ this] + %watch-ack [~ this] + :: + %fact + ?. =(p.cage.sign %thread-fail) + :_ this + :_ ~ + :* %pass + wire + %agent + [our.bowl %spider] + %leave + ~ + == + =/ =serial (slav %uv i.t.wire) + =/ =observer:sur (~(got by observers) serial) + ~& observer-failed+observer + :_ this(observers (~(del by observers) serial)) + :~ :* %pass + [%observer i.t.wire ~] + %agent + [our.bowl app.observer] + %leave + ~ + == + :* %pass + wire + %agent + [our.bowl %spider] + %leave + ~ + == + == + == + :: + ++ on-thread-start + ?> ?=([%thread-start @ @ ~] wire) + ?. ?=(%poke-ack -.sign) (on-agent:def wire sign) + ?~ p.sign [~ this] + =/ =serial (slav %uv i.t.wire) + =/ =observer:sur (~(got by observers) serial) + ~& added-invalid-observer+observer + :_ this(observers (~(del by observers) serial)) + :~ :* %pass + [%observer i.t.wire ~] + %agent + [our.bowl app.observer] + %leave + ~ + == + :* %pass + wire + %agent + [our.bowl app.observer] + %leave + ~ + == == + -- :: ++ on-watch on-watch:def ++ on-leave on-leave:def