Merge branch 'm/dbug' (#2179)

* origin/m/dbug:
  dbug: support app state printing
  dbug: augment various apps with /lib/dbug
  dbug: add agent wrapper for debugging pokes

Signed-off-by: Jared Tobin <jared@tlon.io>
This commit is contained in:
Jared Tobin 2020-01-27 10:21:28 +04:00
commit 865a1cec90
No known key found for this signature in database
GPG Key ID: 0E4647D58F8A69E4
10 changed files with 178 additions and 10 deletions

View File

@ -12,7 +12,7 @@
/- *chat-store, *chat-view, *chat-hook,
*permission-store, *group-store, *invite-store,
sole-sur=sole
/+ sole-lib=sole, chat-eval, default-agent, verb,
/+ sole-lib=sole, chat-eval, default-agent, verb, dbug,
auto=language-server-complete
::
|%
@ -70,9 +70,11 @@
--
=| state
=* all-state -
::
%- agent:dbug
%+ verb |
^- agent:gall
=<
%+ verb |
^- agent:gall
|_ =bowl:gall
+* this .
talk-core +>

View File

@ -3,7 +3,7 @@
:: allow sending chat messages to foreign paths based on write perms
::
/- *permission-store, *chat-hook, *invite-store
/+ *chat-json, default-agent, verb
/+ *chat-json, default-agent, verb, dbug
|%
+$ card card:agent:gall
::
@ -31,6 +31,8 @@
--
=| state-zero
=* state -
::
%- agent:dbug
%+ verb |
^- agent:gall
=<

View File

@ -1,6 +1,6 @@
:: chat-store: data store that holds linear sequences of chat messages
::
/+ *chat-json, *chat-eval, default-agent
/+ *chat-json, *chat-eval, default-agent, verb, dbug
|%
+$ card card:agent:gall
+$ versioned-state
@ -21,6 +21,9 @@
::
=| state-zero
=* state -
::
%- agent:dbug
%+ verb |
^- agent:gall
=<
|_ =bowl:gall

View File

@ -6,7 +6,7 @@
*group-store,
*permission-group-hook,
*chat-hook
/+ *server, *chat-json, default-agent
/+ *server, *chat-json, default-agent, verb, dbug
/= index
/^ octs
/; as-octs:mimes:html
@ -51,6 +51,8 @@
[%permission-group-hook-action permission-group-hook-action]
==
--
%- agent:dbug
%+ verb |
^- agent:gall
=<
|_ bol=bowl:gall

View File

@ -1,7 +1,7 @@
:: group-hook: allow syncing group data from foreign paths to local paths
::
/- *group-store, *group-hook
/+ default-agent
/+ default-agent, verb, dbug
|%
+$ card card:agent:gall
::
@ -19,6 +19,9 @@
::
=| state-zero
=* state -
::
%- agent:dbug
%+ verb |
^- agent:gall
=<
|_ =bowl:gall

View File

@ -1,7 +1,7 @@
:: group-store: data store for groups of ships
::
/- *group-store
/+ default-agent
/+ default-agent, verb, dbug
|%
+$ card card:agent:gall
::
@ -22,6 +22,9 @@
::
=| state-zero
=* state -
::
%- agent:dbug
%+ verb |
^- agent:gall
=<
|_ =bowl:gall

View File

@ -5,7 +5,7 @@
:: configured for them as `access-control`.
::
/- *permission-hook
/+ *permission-json, default-agent
/+ *permission-json, default-agent, verb, dbug
::
|%
+$ state
@ -26,6 +26,8 @@
=| state-0
=* state -
::
%- agent:dbug
%+ verb |
^- agent:gall
=<
|_ =bowl:gall

View File

@ -1,7 +1,7 @@
:: permission-store: track black- and whitelists of ships
::
/- *permission-store
/+ default-agent
/+ default-agent, verb, dbug
::
|%
+$ card card:agent:gall
@ -17,6 +17,9 @@
--
=| state-zero
=* state -
::
%- agent:dbug
%+ verb |
^- agent:gall
=<
|_ =bowl:gall

32
pkg/arvo/gen/dbug.hoon Normal file
View File

@ -0,0 +1,32 @@
:: +dbug: tell /lib/dbug app to print some generic state
::
:: :app +dbug
:: the entire bowl
:: :app +dbug [direction] [specifics]
:: all in subs matching the parameters
:: direction: %incoming or %outgoing
:: specifics:
:: [%ship ~ship] subscriptions to/from this ship
:: [%path /path] subscriptions on path containing /path
:: [%wire /wire] subscriptions on wire containing /wire
:: [%term %name] subscriptions to app %name
::
/+ *dbug
::
:- %say
|= $: :: environment
::
*
:: inline arguments
::
args=?(~ [what=?(%bowl %state) ~] [=what =about ~])
:: named arguments
::
~
==
:- %dbug
?- args
~ [%bowl *about]
[@ ~] [what.args *about]
[@ * ~] [what about]:args
==

116
pkg/arvo/lib/dbug.hoon Normal file
View File

@ -0,0 +1,116 @@
:: dbug: agent wrapper for generic debugging tools
::
:: usage: %-(agent:dbug your-agent)
::
|%
+$ what
$? %bowl
%state
%incoming
%outgoing
==
::
+$ about
$% [%ship =ship]
[%path =path]
[%wire =wire]
[%term =term]
==
::
++ agent
|= =agent:gall
^- agent:gall
|_ =bowl:gall
+* this .
ag ~(. agent bowl)
::
++ on-poke
|= [=mark =vase]
^- (quip card:agent:gall agent:gall)
?. ?=(%dbug mark)
=^ cards agent (on-poke:ag mark vase)
[cards this]
=/ dbug
!<([=what =about] vase)
=; out=^vase
((slog (sell out) ~) [~ this])
?- what.dbug
%bowl !>(bowl)
%state on-save:ag
::
%incoming
!>
%+ murn ~(tap by sup.bowl)
|= sub=[=duct [=ship =path]]
^- (unit _sub)
=; relevant=?
?:(relevant `sub ~)
?- -.about.dbug
%ship =(ship.sub ship.about.dbug)
%path ?=(^ (find path.about.dbug path.sub))
%wire %+ lien duct.sub
|=(=wire ?=(^ (find wire.about.dbug wire)))
%term !!
==
::
%outgoing
!>
%+ murn ~(tap by wex.bowl)
|= sub=[[=wire =ship =term] [acked=? =path]]
^- (unit _sub)
=; relevant=?
?:(relevant `sub ~)
?- -.about.dbug
%ship =(ship.sub ship.about.dbug)
%path ?=(^ (find path.about.dbug path.sub))
%wire ?=(^ (find wire.about.dbug wire.sub))
%term =(term.sub term.about.dbug)
==
==
::
++ on-init
^- (quip card:agent:gall agent:gall)
=^ cards agent on-init:ag
[cards this]
::
++ on-save on-save:ag
::
++ on-load
|= old-state=vase
^- (quip card:agent:gall agent:gall)
=^ cards agent (on-load:ag old-state)
[cards this]
::
++ on-watch
|= =path
^- (quip card:agent:gall agent:gall)
=^ cards agent (on-watch:ag path)
[cards this]
::
++ on-leave
|= =path
^- (quip card:agent:gall agent:gall)
=^ cards agent (on-leave:ag path)
[cards this]
::
++ on-peek on-peek:ag
::
++ on-agent
|= [=wire =sign:agent:gall]
^- (quip card:agent:gall agent:gall)
=^ cards agent (on-agent:ag wire sign)
[cards this]
::
++ on-arvo
|= [=wire =sign-arvo]
^- (quip card:agent:gall agent:gall)
=^ cards agent (on-arvo:ag wire sign-arvo)
[cards this]
::
++ on-fail
|= [=term =tang]
^- (quip card:agent:gall agent:gall)
=^ cards agent (on-fail:ag term tang)
[cards this]
--
--