neo: start networking rewrite

This commit is contained in:
Liam Fitzgerald 2024-05-17 16:19:24 -04:00
parent 538b34dc7d
commit 5b8d72d094
6 changed files with 130 additions and 27 deletions

View File

@ -1,6 +1,7 @@
/- neo
/+ lib=neo-two
/+ default-agent
/+ dbug
|%
+$ card $+(card card:agent:gall)
+$ state-0
@ -22,6 +23,7 @@
=* state -
=<
!:
%- agent:dbug
^- agent:gall
|_ =bowl:gall
+* this .
@ -135,8 +137,10 @@
^+ run
?+ mark ~|(bad-poke-mark/mark !!)
%neo-move =;(f (f !<(_+<.f vase)) on-move)
%neo-dirt-card =;(f (f !<(_+<.f vase)) on-dirt-card)
%neo-sync =;(f (f !<(_+<.f vase)) on-sync)
::
%neo-raw-poke (on-move (poke:harden !<(raw-poke:neo vase)))
%neo-dirt-card (on-dirt-card !<(=card:dirt:neo vase))
==
++ on-move
|= =move:neo
@ -152,6 +156,22 @@
(~(call plow:lib loam) card)
=. farm (~(take till:lib farm) gifts)
run
++ on-sync
|= =sync:neo
^+ run
?- r.sync
%start abet:(start:rare [p q]:sync)
%stop abet:(stop:rare [p q]:sync)
==
++ on-sync-start
|= [src=pith:neo =hunt:neo]
^+ run
!!
++ on-sync-stop
|= [src=pith:neo =hunt:neo]
^+ run
!!
::
++ on-watch
|= =(pole knot)
^+ run
@ -161,7 +181,7 @@
=/ paxs=(list road:neo) (de:drive:neo pith)
?> ?=([^ ^ ~] paxs)
?+ i.paxs !!
[car=@ [%ud since=@] ~] !! :: XX: TODO:
[car=@ [%ud since=@] ~] abet:(serve:rare ;;(care:neo car.i.paxs) i.t.paxs)
==
++ on-agent
|= [=wire =sign:agent:gall]
@ -169,7 +189,7 @@
=/ =road:neo (pave:neo wire)
?+ road +:(on-agent:def wire sign)
[%deal rest=*] (on-deal-sign rest.road sign)
[%sync rest=*] (on-sync-sign rest.road sign)
[%sync rest=*] abet:(on-sign:rare rest.road sign)
==
++ on-deal-sign
|= [=road:neo =sign:agent:gall]
@ -178,11 +198,7 @@
:: run
!! :: XX: deliver nack
::
++ on-sync-sign
|= [=road:neo =sign:agent:gall]
^+ run
!!
++ on-arvo
|= [=wire syn=sign-arvo]
^+ run
@ -234,11 +250,29 @@
|= [=pith:neo =mall:neo]
%- pout
(welp #/sync (en:drive:neo #/[(care mart.mall)]/[ud/0] pith ~))
++ peer
|= [=pith:neo =mall:neo]
=/ =name:neo (de-pith:name:neo pith)
=/ =wire sync/(pout pith)
(do-watch-her wire ship.name (peer-path pith mall))
++ stop
|= [src=pith:neo =hunt:neo]
^+ rare
!!
++ start
|= [src=pith:neo =hunt:neo]
^+ rare
=/ ton (~(dip of:neo town) pith.hunt)
?^ fil.ton
=. mart.u.fil.ton (~(put in mart.u.fil.ton) [care.hunt src])
=. town (~(rep of:neo town) pith.hunt ton)
rare
=> .(fil.ton `(unit mall:neo)`fil.ton)
:: XX: search upwards for
=| =mall:neo
=. mart.mall (~(put in mart.mall) [care.hunt src])
=. del.mall `*deli:neo
=/ =wire sync/(pout pith.hunt)
=/ =name:neo (de-pith:name:neo pith.hunt)
=. run (emit (do-watch-her wire ship.name (peer-path pith.hunt mall)))
=. fil.ton `mall
=. town (~(rep of:neo town) pith.hunt ton)
rare
++ resign
|= =pith:neo
^- (unit pith:neo)
@ -284,6 +318,31 @@
~& last-standing-ending-sub/pith
(leave pith)
!!
++ on-sign
|= [=pith:neo =sign:agent:gall]
^+ rare
=/ ton (~(dip of:neo town) pith)
?+ -.sign ~|(bad-sign/-.sign !!)
%watch-ack
%. rare
?~ p.sign
same
(slog u.p.sign)
::
%fact
%- (slog leaf/"got fact" (sell q.cage.sign) ~)
rare
::
%kick
~& 'todo: kick handling'
rare
==
++ serve
|= =hunt:neo
^+ rare
=| =epic:neo
!!
--
++ rent
|_ =city:neo

View File

@ -0,0 +1,8 @@
/- neo
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[=pith:neo =pail:neo ~]
auto=_|
==
:- %neo-dirt-card
[pith %grow pail *oath:neo]

View File

@ -0,0 +1,11 @@
/- neo
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[=hunt:neo ~]
src=_`pith:neo`#/~zod/sync/test
==
?> ?=(^ src)
=. src src(i p/p.bec)
:- %neo-sync
[src hunt %start]

View File

@ -127,7 +127,12 @@
:: layer 2
|%
++ till
|_ =farm:neo
|_ [=soil:neo =farm:neo =plot:neo]
++ area +<
++ reap
|= =pith:neo
++ self
|= [=pith:neo case=@ud]
=/ parent=land:neo
@ -139,6 +144,7 @@
::
++ eternal
|= [=pith:neo case=@ud]
^+ +<
=. farm (heir pith)
=. farm (chain pith)
(self pith case)
@ -150,6 +156,11 @@
=? fil.farm ?=(^ fil.farm)
`(bump u.fil.farm %z)
farm(kid (~(put by kid.farm) i.pith $(farm kid, pith t.pith)))
++ slip
|= [=pith:neo =ever:neo]
^- (list pith:neo)
!!
::
++ heir
|= =pith:neo
@ -174,18 +185,20 @@
farm
$(farm (eternal [p q]:i.gis), gis t.gis)
::
++ scry
++ look
|= [=loam:dirt:neo =care:neo =case:neo =pith:neo]
^- (unit (unit myth:neo))
^- (unit (unit (axal saga:neo)))
=+ pom=(~(scry plow loam) case pith)
?: ?=($?(~ [~ ~]) pom)
pom
?~ q.u.u.pom
[~ ~]
?~ val=(~(get of:neo farm) pith)
~
?~ ver=(ram:on:land:neo u.val)
~
=/ =ever:neo (nail val.u.ver case)
``[q.u.u.pom ever q.p.u.u.pom]
!! :: ``[q.u.u.pom ever q.p.u.u.pom]
--
--

View File

@ -29,6 +29,7 @@
%b :: node and immediate children (%y)
%c :: node and all descendants
==
+$ hunt [=care =pith] ::
:: $over: range of time for case bookkeeping
::
::
@ -46,9 +47,19 @@
:: .zed is incremened when the shrub of any of its descendants change
::
+$ ever
$: exe=@ud
why=@ud
$:
zed=@ud
zed-mut=@ud
why=@ud
why-mut=@ud
exe=@ud
::
shrub-life=@ud
shrub-rift=@ud
ship-life=@ud
ship-rift=@ud
::
block=@ux
==
:: $once: Partial version
::
@ -295,13 +306,14 @@
+$ land ((mop case over) lte)
++ on ((^on case over) lte)
--
++ farm
=< farm
|%
+$ farm (axal land)
--
+$ plot
$: by-kids=(jug [=pith why=@ud] pith:neo)
by-desc=(jug [=pith zed=@ud] pith:neo)
==
++ farm (axal land)
--
|%
+$ sync (trel pith hunt ?(%start %stop))
:: $curt: Single constraint
+$ curt
$~ [%pro %$]
@ -801,7 +813,6 @@
::
:: $hunt: perspective and shrub
::
+$ hunt [=care =pith] ::
+$ tour hunt
:: $block: call-stack state for blocking semantics
::
@ -1662,6 +1673,7 @@
::
+$ dish (pair pith mode)
+$ yarn (pair aeon mode)
+$ idea (unit (unit (axal saga)))
:: $lore: diff over namespace
+$ lore
(axal yarn)
@ -1998,7 +2010,7 @@
+$ kids (map pish port)
:: $plot: virtual namespace binding
::
+$ plot
+$ o-plot
$_ ^&
|%
:: $state: the state of this value in the urbit namespace

View File

@ -1,6 +1,6 @@
/- neo
/+ *test-agent
/= neo-agent /app/neo-two
/= neo-agent /app/neo
|%
++ scry-handler
|= =(pole knot)