Merge remote-tracking branch 'upstream/master' into dev-summit

This commit is contained in:
Liam Fitzgerald 2024-06-17 14:31:48 -04:00
commit e0009aada1
129 changed files with 5481 additions and 88998 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:feaae0eece54db3e92122263706c283674af581d14ffde8a29fb24e1873a35b1 oid sha256:c2ab6607450382e0ec80c7264dad2c72d69672eaf861eb1c24cde5a76921c6a3
size 6453015 size 9972490

View File

@ -3,7 +3,7 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
tools = { tools = {
flake = false; flake = false;
url = "github:urbit/tools"; url = "github:urbit/tools/d454e2482c3d4820d37db6d5625a6d40db975864";
}; };
}; };

View File

@ -28,17 +28,6 @@ let
-- --
''; '';
testThread = dojoCommand:
pkgs.writeTextFile {
name = "${dojoCommand}.hoon";
text = ''
${poke}
=/ m (strand ,vase)
;< [=ship =desk =case] bind:m get-beak
;< ok=? bind:m (poke [ship %dojo] %lens-command !>([%$ [%dojo '${dojoCommand}'] [%stdout ~]]))
(pure:m !>(ok))
'';
};
appThread = generator: app: appThread = generator: app:
pkgs.writeTextFile { pkgs.writeTextFile {
name = ":${app}|${generator}.hoon"; name = ":${app}|${generator}.hoon";
@ -87,11 +76,12 @@ in pkgs.stdenvNoCC.mkDerivation {
sleep 2 sleep 2
${click} -k -p -i ${testThread "-test %/tests ~"} ./pier ${click} -c ./pier "[0 %fyrd [%base %test %noun %noun 0]]"
${click} -k -p -i ${pokeApp "%agents" "noun" "test"} ./pier ${click} -k -p -i ${pokeApp "%agents" "noun" "test"} ./pier
${click} -k -p -i ${pokeApp "%generators" "noun" "test"} ./pier ${click} -k -p -i ${pokeApp "%generators" "noun" "test"} ./pier
${click} -k -p -i ${pokeApp "%marks" "noun" "test"} ./pier ${click} -k -p -i ${pokeApp "%marks" "noun" "test"} ./pier
${click} -k -p -i ${pokeApp "%threads" "noun" "test"} ./pier
${click} -k -p -i ${appThread "mass" "hood"} ./pier ${click} -k -p -i ${appThread "mass" "hood"} ./pier
sleep 2 sleep 2
@ -112,7 +102,7 @@ in pkgs.stdenvNoCC.mkDerivation {
''; '';
checkPhase = '' checkPhase = ''
if egrep "((FAILED|CRASHED|Failed)|warn:)" $out >/dev/null; then if egrep "((FAILED|CRASHED|Failed|\[0 %avow 0 %noun 1\])|warn:)" $out >/dev/null; then
exit 1 exit 1
fi fi
''; '';

View File

@ -85,7 +85,7 @@
=^ cards state =^ cards state
?+ mark ~|([%aqua-bad-mark mark] !!) ?+ mark ~|([%aqua-bad-mark mark] !!)
%aqua-events (poke-aqua-events:ac !<((list aqua-event) vase)) %aqua-events (poke-aqua-events:ac !<((list aqua-event) vase))
%pill (poke-pill:ac !<(pill vase)) %pill (poke-pill:ac !<(pill vase))
%noun (poke-noun:ac !<(* vase)) %noun (poke-noun:ac !<(* vase))
%azimuth-action (poke-azimuth-action:ac !<(azimuth-action vase)) %azimuth-action (poke-azimuth-action:ac !<(azimuth-action vase))
== ==
@ -663,34 +663,55 @@
(pe ~bud) :: XX why ~bud? need an example (pe ~bud) :: XX why ~bud? need an example
:: ::
%read %read
?~ pier=(~(get by ships.piers) from.ae) ?~ pier=(~(get by ships.piers) ship.from.ae)
(pe from.ae) (pe ship.from.ae)
=/ cash (~(get by namespace.u.pier) path.ae) =/ cash (~(get by namespace.u.pier) path.ae)
|- |-
?^ cash ?^ cash
?: (gth num.ae (lent u.cash)) ?: (gth num.ae (lent u.cash))
(pe from.ae) (pe ship.from.ae)
::TODO depends on /ted/aqua/ames behavior in a weird indirect way ::TODO depends on /ted/aqua/ames behavior in a weird indirect way
=/ for=@p `@`(tail for.ae) ::NOTE moons & comets not supported =/ for=@p `@`(tail lane.for.ae) ::NOTE moons & comets not supported
=; task=task-arvo %- push-events:(pe for)
^$(ae [%event for /a/aqua/fine-response task], thus this) %- flop =< events
:+ %hear `lane:ames`[%| `@`from.ae] %+ roll u.cash
|= [=yowl:ames i=@ud events=(list unix-event)]
:- +(i)
:_ events
:- /a/aqua/fine-response/[(scot %ud i)]
^- task-arvo
:+ %hear `lane:ames`[%| `@`ship.from.ae]
^- blob:ames ^- blob:ames
=/ =shot:ames %- etch-shot:ames
::NOTE dec is important! so dumb!! :* [sndr=ship.from.ae rcvr=for]
(sift-shot:ames `@`(snag (dec num.ae) u.cash)) req=| sam=|
::TODO runtime needs to update rcvr field also sndr-tick=life.from.ae
::NOTE rcvr life is allowed to be wrong rcvr-tick=life.for.ae
(etch-shot:ames shot(sndr from.ae, rcvr for)) origin=~
content=`@ux`yowl
==
::
=/ pacs=(unit (list yowl:ames)) =/ pacs=(unit (list yowl:ames))
=/ =path [%fine %hunk (scot %ud num.ae) '512' path.ae]
%+ biff %+ biff
(peek-once:(pe from.ae) %ax %$ [%fine %message path.ae]) (peek-once:(pe ship.from.ae) %ax %$ path)
(soft (list yowl:ames)) (soft (list yowl:ames))
?~ pacs (pe from.ae) ?~ pacs (pe ship.from.ae)
=. u.pacs
:: add request to each response packet payload
::
=+ pat=(spat path.ae)
=+ wid=(met 3 pat)
%- flop =< blobs
%+ roll u.pacs
|= [=yowl:ames num=_1 blobs=(list @ux)]
:- +(num)
:_ blobs
(can 3 4^num 2^wid wid^`@`pat (met 3 yowl)^yowl ~)
=. namespace.u.pier =. namespace.u.pier
(~(put by namespace.u.pier) path.ae u.pacs) (~(put by namespace.u.pier) path.ae u.pacs)
=. ships.piers =. ships.piers
(~(put by ships.piers) from.ae u.pier) (~(put by ships.piers) ship.from.ae u.pier)
$(cash pacs, thus this) $(cash pacs, thus this)
:: ::
%event %event

View File

@ -42,8 +42,8 @@
++ on-poke ++ on-poke
|= [=mark =vase] |= [=mark =vase]
^- (quip card _this) ^- (quip card _this)
?> =(our src):bowl
?: ?=(%noun mark) ?: ?=(%noun mark)
?> (team:title [our src]:bowl)
=/ code !<((unit @t) vase) =/ code !<((unit @t) vase)
=/ msg=tape =/ msg=tape
?~ code ?~ code
@ -55,6 +55,13 @@
""" """
%- (slog leaf+msg ~) %- (slog leaf+msg ~)
[~ this(passcode code)] [~ this(passcode code)]
?: ?=(%json mark)
=/ jon=json !<(json vase)
=, dejs:format
=/ cmd
((of clear-eyre-cache+(ot url+so ~) ~) jon)
?> ?=(%clear-eyre-cache -.cmd)
[[%pass /cmd %arvo %e %set-response +.cmd ~]~ this]
?. ?=(%handle-http-request mark) ?. ?=(%handle-http-request mark)
(on-poke:def mark vase) (on-poke:def mark vase)
=+ !<([eyre-id=@ta =inbound-request:eyre] vase) =+ !<([eyre-id=@ta =inbound-request:eyre] vase)
@ -315,6 +322,19 @@
:~ 'location'^s+(cat 3 (fall site '*') (spat path)) :~ 'location'^s+(cat 3 (fall site '*') (spat path))
'action'^(render-action:v-eyre action) 'action'^(render-action:v-eyre action)
== ==
::
:: /eyre/cache.json
::
[%eyre %cache ~]
%- some
:- %a
%+ turn (sort ~(tap by cache:v-eyre) aor)
|= [url=@t aeon=@ud val=(unit cache-entry:eyre)]
%- pairs
:~ 'url'^s+url
'aeon'^(numb aeon)
'val'^?~(val ~ (render-cache-entry:v-eyre u.val))
==
:: ::
:: /eyre/connections.json :: /eyre/connections.json
:: ::
@ -566,7 +586,6 @@
%- pairs %- pairs
:~ 'messages'^(numb (lent messages)) :~ 'messages'^(numb (lent messages))
'packets'^(numb ~(wyt in packets)) 'packets'^(numb ~(wyt in packets))
'heeds'^(set-array heeds from-duct)
'keens'^(set-array ~(key by keens) path) 'keens'^(set-array ~(key by keens) path)
== ==
:: ::
@ -630,7 +649,6 @@
:: }, ...], :: }, ...],
:: closing: [bone, ..., bone], :: closing: [bone, ..., bone],
:: corked: [bone, ..., bone], :: corked: [bone, ..., bone],
:: heeds: [['/paths', ...] ...]
:: scries: :: scries:
:: -> { =path :: -> { =path
:: keen-state: { :: keen-state: {
@ -757,8 +775,6 @@
'closing'^(set-array closing numb) 'closing'^(set-array closing numb)
:: ::
'corked'^(set-array corked numb) 'corked'^(set-array corked numb)
::
'heeds'^(set-array heeds from-duct)
:: ::
'scries'^(scries ~(tap by keens)) 'scries'^(scries ~(tap by keens))
== ==
@ -773,7 +789,7 @@
'next'^(numb next) 'next'^(numb next)
:: ::
:- 'unsent-messages' :: as byte sizes :- 'unsent-messages' :: as byte sizes
(set-array unsent-messages (cork (cury met 3) numb)) (set-array unsent-messages (cork jam (cork (cury met 3) numb)))
:: ::
'unsent-fragments'^(numb (lent unsent-fragments)) :: as lent 'unsent-fragments'^(numb (lent unsent-fragments)) :: as lent
:: ::
@ -1038,6 +1054,9 @@
++ bindings ++ bindings
(scry ,(list [=binding =duct =action]) %e %bindings ~) (scry ,(list [=binding =duct =action]) %e %bindings ~)
:: ::
++ cache
(scry ,(map url=@t [aeon=@ud (unit cache-entry)]) %e %cache ~)
::
++ connections ++ connections
(scry ,(map duct outstanding-connection) %e %connections ~) (scry ,(map duct outstanding-connection) %e %connections ~)
:: ::
@ -1065,6 +1084,27 @@
%gen :((cury cat 3) '+' (spat [desk path]:generator.action)) %gen :((cury cat 3) '+' (spat [desk path]:generator.action))
%app (cat 3 ':' app.action) %app (cat 3 ':' app.action)
== ==
::
++ render-cache-entry
|= cache-entry
^- json
%- pairs:enjs:format
:~ 'auth'^b+auth
'payload'^(render-simple-payload simple-payload.body)
==
::
++ render-simple-payload
|= simple-payload:http
^- json
=, enjs:format
%- pairs
:~ 'status'^(numb status-code.response-header)
'data'^?~(data ~ (numb p.u.data))
::
:+ 'headers' %a
%+ turn headers.response-header
|=([k=@t v=@t] (pairs 'key'^s+k 'value'^s+v ~))
==
-- --
:: ::
:: helpers :: helpers

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@ -1,20 +1,16 @@
<!doctype html> <!doctype html>
<html> <html lang="en">
<head>
<head> <meta charset="UTF-8" />
<title>Debug Dashboard</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" /> <title>Debug Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <style type="text/css" src="/src/index.css"></style>
<link rel="stylesheet" href="/~debug/css/index.css" /> <script type="module" crossorigin src="/~debug/index.js"></script>
<link rel="icon" type="image/png" href="/~launch/img/Favicon.png"> <link rel="stylesheet" crossorigin href="/~debug/index.css">
</head> </head>
<body>
<body class="w-100 h-100"> <div id="root"></div>
<div id="root" class="w-100 h-100"> <script src="/~debug/channel.js"></script>
</div> <script src="/~debug/js/session.js"></script>
<script src="/~debug/js/channel.js"></script> </body>
<script src="/~debug/js/session.js"></script>
<script src="/~debug/js/index.js"></script>
</body>
</html> </html>

125
pkg/arvo/app/debug/index.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
import{errors as c,isChunkObject as y}from"./util.js";import"./index.js";let n=globalThis.File,p=globalThis.Blob;const m=o=>{n=o},g=o=>{p=o},{INVALID:z,GONE:s,MISMATCH:w,MOD_ERR:E,SYNTAX:l,DISALLOWED:O}=c;class D{constructor(e,i){this.fileHandle=e,this.file=i?e.file:new n([],e.file.name,e.file),this.size=i?e.file.size:0,this.position=0}async write(e){if(!this.fileHandle.file)throw new DOMException(...s);let i=this.file;if(y(e)){if(e.type==="write"){if(typeof e.position=="number"&&e.position>=0&&(this.position=e.position,this.size<e.position&&(this.file=new n([this.file,new ArrayBuffer(e.position-this.size)],this.file.name,this.file))),!("data"in e))throw new DOMException(...l("write requires a data argument"));e=e.data}else if(e.type==="seek")if(Number.isInteger(e.position)&&e.position>=0){if(this.size<e.position)throw new DOMException(...z);this.position=e.position;return}else throw new DOMException(...l("seek requires a position argument"));else if(e.type==="truncate")if(Number.isInteger(e.size)&&e.size>=0){i=e.size<this.size?new n([i.slice(0,e.size)],i.name,i):new n([i,new Uint8Array(e.size-this.size)],i.name,i),this.size=i.size,this.position>i.size&&(this.position=i.size),this.file=i;return}else throw new DOMException(...l("truncate requires a size argument"))}e=new p([e]);let t=this.file;const a=t.slice(0,this.position),d=t.slice(this.position+e.size);let r=this.position-a.size;r<0&&(r=0),t=new n([a,new Uint8Array(r),e,d],t.name),this.size=t.size,this.position+=e.size,this.file=t}async close(){if(!this.fileHandle.file)throw new DOMException(...s);this.fileHandle.file=this.file,this.file=this.position=this.size=null,this.fileHandle.onclose&&this.fileHandle.onclose(this.fileHandle)}}class f{constructor(e="",i=new n([],e),t=!0){this.kind="file",this.deleted=!1,this.file=i,this.name=e,this.writable=t}async getFile(){if(this.deleted||this.file===null)throw new DOMException(...s);return this.file}async createWritable(e){if(!this.writable)throw new DOMException(...O);if(this.deleted)throw new DOMException(...s);return new D(this,!!(e!=null&&e.keepExistingData))}async isSameEntry(e){return this===e}destroy(){this.deleted=!0,this.file=null}}class h{constructor(e,i=!0){this.kind="directory",this.deleted=!1,this._entries={},this.name=e,this.writable=i}async*entries(){if(this.deleted)throw new DOMException(...s);yield*Object.entries(this._entries)}async isSameEntry(e){return this===e}async getDirectoryHandle(e,i={}){if(this.deleted)throw new DOMException(...s);const t=this._entries[e];if(t){if(t instanceof f)throw new DOMException(...w);return t}else{if(i.create)return this._entries[e]=new h(e);throw new DOMException(...s)}}async getFileHandle(e,i={}){const t=this._entries[e];if(t){if(t instanceof f)return t;throw new DOMException(...w)}else{if(i.create)return this._entries[e]=new f(e);throw new DOMException(...s)}}async removeEntry(e,i={}){const t=this._entries[e];if(!t)throw new DOMException(...s);t.destroy(i.recursive),delete this._entries[e]}destroy(e){for(let i of Object.values(this._entries)){if(!e)throw new DOMException(...E);i.destroy(e)}this._entries={},this.deleted=!0}}const M=new h(""),u=()=>M;export{f as FileHandle,h as FolderHandle,u as default,g as setBlobImpl,m as setFileImpl};

View File

@ -0,0 +1,7 @@
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = ["memory.js","index.js","index.css"]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
import{_ as l}from"./index.js";const E={INVALID:["seeking position failed.","InvalidStateError"],GONE:["A requested file or directory could not be found at the time an operation was processed.","NotFoundError"],MISMATCH:["The path supplied exists, but was not an entry of requested type.","TypeMismatchError"],MOD_ERR:["The object can not be modified in this way.","InvalidModificationError"],SYNTAX:e=>[`Failed to execute 'write' on 'UnderlyingSinkBase': Invalid params passed. ${e}`,"SyntaxError"],ABORT:["The operation was aborted","AbortError"],SECURITY:["It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.","SecurityError"],DISALLOWED:["The request is not allowed by the user agent or the platform in the current context.","NotAllowedError"]},y=e=>typeof e=="object"&&typeof e.type<"u";async function v(e){var o,r,a;const{FolderHandle:t,FileHandle:u}=await l(()=>import("./memory.js"),__vite__mapDeps([0,1,2])),{FileSystemDirectoryHandle:m}=await l(()=>import("./index.js").then(n=>n.a),__vite__mapDeps([1,2])),p=(r=(o=e[0].webkitRelativePath)===null||o===void 0?void 0:o.split("/",1)[0])!==null&&r!==void 0?r:"",_=new t(p,!1);for(let n=0;n<e.length;n++){const i=e[n],d=!((a=i.webkitRelativePath)===null||a===void 0)&&a.length?i.webkitRelativePath.split("/"):["",i.name];d.shift();const f=d.pop(),w=d.reduce((c,s)=>(c._entries[s]||(c._entries[s]=new t(s,!1)),c._entries[s]),_);w._entries[f]=new u(i.name,i,!1)}return new m(_)}async function b(e){const{FileHandle:o}=await l(()=>import("./memory.js"),__vite__mapDeps([0,1,2])),{FileSystemFileHandle:r}=await l(()=>import("./index.js").then(t=>t.F),__vite__mapDeps([1,2]));return Array.from(e).map(t=>new r(new o(t.name,t,!1)))}export{E as errors,y as isChunkObject,v as makeDirHandleFromFileList,b as makeFileHandlesFromFileList};

View File

@ -168,7 +168,7 @@
:: ::
;~ pfix tis ;~ pfix tis
;~ pose ;~ pose
(parse-variable (jest %dir) ;~(pfix ace :(stag 0 %ex parse-rood))) (parse-variable (cold %dir (jest 'dir ')) :(stag 0 %ex parse-rood))
(parse-variable sym ;~(pfix ace parse-source)) (parse-variable sym ;~(pfix ace parse-source))
== ==
== ==

View File

@ -5,7 +5,6 @@
:: keep relevant mark conversions in cache for performance :: keep relevant mark conversions in cache for performance
:: ::
/$ blit-to-json %blit %json /$ blit-to-json %blit %json
/$ json-to-blit %json %blit
/$ json-to-task %json %herm-task /$ json-to-task %json %herm-task
:: ::
=, jael =, jael

View File

@ -2,8 +2,8 @@
/+ drum=hood-drum, helm=hood-helm, kiln=hood-kiln /+ drum=hood-drum, helm=hood-helm, kiln=hood-kiln
|% |%
+$ state +$ state
$~ [%26 *state:drum *state:helm *state:kiln] $~ [%27 *state:drum *state:helm *state:kiln]
$>(%26 any-state) $>(%27 any-state)
:: ::
+$ any-state +$ any-state
$% [ver=?(%1 %2 %3 %4 %5 %6) lac=(map @tas fin-any-state)] $% [ver=?(%1 %2 %3 %4 %5 %6) lac=(map @tas fin-any-state)]
@ -27,6 +27,7 @@
[%24 drum=state-4:drum helm=state-2:helm kiln=state-10:kiln] [%24 drum=state-4:drum helm=state-2:helm kiln=state-10:kiln]
[%25 drum=state-5:drum helm=state-2:helm kiln=state-10:kiln] [%25 drum=state-5:drum helm=state-2:helm kiln=state-10:kiln]
[%26 drum=state-6:drum helm=state-2:helm kiln=state-10:kiln] [%26 drum=state-6:drum helm=state-2:helm kiln=state-10:kiln]
[%27 drum=state-6:drum helm=state-2:helm kiln=state-11:kiln]
== ==
+$ any-state-tuple +$ any-state-tuple
$: drum=any-state:drum $: drum=any-state:drum

View File

@ -20,257 +20,42 @@
:: ::
++ nat-timeout ~s25 ++ nat-timeout ~s25
:: ::
:: How often to check our IP when we know we're not behind a NAT.
::
++ ip-timeout ~m5
::
:: Chosen because it's run by Cloudflare, and others I tried were
:: inconsistently slow.
::
++ ip-reflector 'https://icanhazip.com'
::
+$ card card:agent:gall +$ card card:agent:gall
+$ ship-state ::
$% [%idle ~] +$ state-3
[%poking ~] $: %3
[%http until=@da] mode=?(%formal %informal)
[%waiting until=@da] pokes=@ud
== timer=(unit [=wire date=@da])
+$ state-1 galaxy=@p
$: %1
ships=(set ship)
nonce=@ud
$= plan
$~ [%nat ~]
$% [%nat ~]
[%pub ip=(unit @t)]
==
== ==
-- --
:: ::
%- agent:dbug %- agent:dbug
:: ::
=| state=state-1 =| state=state-3
=> |% => |%
:: Bind for the the writer monad on (quip effect state) ++ galaxy-for
:: |= [=ship =bowl:gall]
++ rind ^- @p
|* [effect=mold state=*] =/ next (sein:title our.bowl now.bowl ship)
|* state-type=mold ?: ?=(%czar (clan:title next))
|= $: m-b=(quip effect state-type) next
fun=$-(state-type (quip effect state-type)) $(ship next)
== ::
^- (quip effect state-type) ++ wait-card
=^ effects-1=(list effect) state m-b |= [=wire now=@da]
=^ effects-2=(list effect) state (fun state) ^- card
[(weld effects-1 effects-2) state] [%pass wire %arvo %b %wait (add nat-timeout now)]
:: ::
++ once ++ ping
|= =cord |= [=ship force=?]
=(cord (scot %uw nonce.state)) ^- (quip card _state)
:: ?: &(!force (gth pokes.state 0) =(ship galaxy.state))
:: Subsystem to keep track of which ships to ping across breaches [~ state]
:: and sponsorship changes :_ state(pokes +(pokes.state), galaxy ship)
:: [%pass /ping %agent [ship %ping] %poke %noun !>(~)]~
++ ships --
|%
++ rind (^rind card state)
++ kick
|= [our=@p now=@da]
^- (quip card _state)
:: ?: =(%czar (clan:title our))
:: `state
::
:: NB: !! This includes our own ship, and for moons, this is
:: what has caused Jael to fetch our own rift from our parent.
:: This role may be taken by Ames's subscription to
:: %public-keys, but this must be tested before changing the
:: behavior here.
::
=/ new-ships (~(gas in *(set ship)) (saxo:title our now our))
=/ removed (~(dif in ships.state) new-ships)
=/ added (~(dif in new-ships) ships.state)
;< new-state=_state rind
?~ removed `state
[[%pass /jael %arvo %j %nuke removed]~ state]
=. state new-state
::
;< new-state=_state rind
?~ added `state
[[%pass /jael %arvo %j %public-keys added]~ state]
=. state new-state
::
:: Kick even if ships weren't added or removed
::
(kick-pings our now new-ships)
::
:: Kick whenever we get a response. We really care about
:: breaches and sponsorship changes.
::
:: Delay until next event in case of breach, so that ames can
:: clear its state.
::
++ take-jael
|= now=@da
^- (quip card _state)
[[%pass /jael/delay %arvo %b %wait now]~ state]
::
++ take-delay kick
--
::
:: Starts pinging a new set of `ships`.
::
++ kick-pings
|= [our=@p now=@da ships=(set ship)]
^- (quip card _state)
=: nonce.state +(nonce.state)
ships.state ships
==
::
?: ?=(%nat -.plan.state)
(kick:nat our)
(kick:pub our now)
::
:: Subsystem for pinging our sponsors when we might be behind a NAT
::
:: Ping each ship every 25 seconds to keep the pinhole open.
:: This is expensive, but if you don't do it and you are behind a
:: NAT, you will stop receiving packets from other ships except
:: during the 30 seconds following each packet you send.
::
++ nat
?> ?=(%nat -.plan.state)
|%
++ rind (^rind card state)
++ kick
|= our=@p
^- (quip card _state)
=/ ships ~(tap in ships.state)
|- ^- (quip card _state)
?~ ships `state
?: =(our i.ships) $(ships t.ships)
;< new-state=_state rind (send-ping i.ships)
=. state new-state
$(ships t.ships)
::
++ send-ping
|= =ship
^- (quip card _state)
:_ state
=/ wire /nat/(scot %uw nonce.state)/ping/(scot %p ship)
[%pass wire %agent [ship %ping] %poke %noun !>(~)]~
::
++ take-ping
|= [now=@da =wire error=(unit tang)]
^- (quip card _state)
?. ?=([%nat @ %ping @ ~] wire) `state
?. (once i.t.wire) `state
=/ ship (slav %p i.t.t.t.wire)
%- (slog ?~(error ~ ['ping: got nack' >ship< u.error]))
:_ state
=/ wire /nat/(scot %uw nonce.state)/wait/(scot %p ship)
[%pass wire %arvo %b %wait (add nat-timeout now)]~
::
++ take-wait
|= =wire
^- (quip card _state)
?. ?=([%nat @ %wait @ ~] wire) `state
?. (once i.t.wire) `state
=/ ship (slav %p i.t.t.t.wire)
(send-ping ship)
--
::
:: Subsystem for pinging our sponsors when we know we're not behind a NAT
::
:: Check our IP address every minute, and only if it changes,
:: ping all our sponsors.
::
++ pub
?> ?=(%pub -.plan.state)
|%
++ rind (^rind card state)
++ kick
|= [our=@p now=@da]
^- (quip card _state)
;< new-state=_state rind (send-pings our)
=. state new-state
::
;< new-state=_state rind check-ip
=. state new-state
::
(set-timer now)
::
++ send-pings
|= our=@p
^- (quip card _state)
:_ state
%+ murn ~(tap in ships.state)
|= =ship
?: =(our ship)
~
=/ wire /pub/(scot %uw nonce.state)/ping/(scot %p ship)
`u=[%pass wire %agent [ship %ping] %poke %noun !>(~)]
::
++ take-pings
|= [=wire error=(unit tang)]
^- (quip card _state)
?. ?=([%pub @ %ping @ ~] wire) `state
?. (once i.t.wire) `state
=/ ship (slav %p i.t.t.t.wire)
%- (slog ?~(error ~ ['ping: got nack' >ship< u.error]))
`state
::
++ check-ip
^- (quip card _state)
:_ state
=/ wire /pub/(scot %uw nonce.state)/ip
=/ =request:http [%'GET' ip-reflector ~ ~]
[%pass wire %arvo %i %request request *outbound-config:iris]~
::
++ take-ip
|= [our=@p =wire resp=client-response:iris]
^- (quip card _state)
?. ?=([%pub @ %ip ~] wire) `state
?. (once i.t.wire) `state
::
?. ?=(%finished -.resp) `state :: will retry in a minute
?. ?=(%200 status-code.response-header.resp)
=* s status-code.response-header.resp
%- (slog leaf+"ping: ip check failed: {<s>}" ~)
`state
::
?~ full-file.resp
%- (slog 'ping: ip check body empty' ~)
`state
::
=* body q.data.u.full-file.resp
?~ body
%- (slog 'ping: ip check body empty' ~)
`state
::
=/ ip (end [3 (dec (met 3 body))] body)
?: =(ip.plan.state `ip) `state
::
=. ip.plan.state `ip
(send-pings our)
::
++ set-timer
|= now=@da
^- (quip card _state)
=/ =wire /pub/(scot %uw nonce.state)/wait
[[%pass wire %arvo %b %wait (add ip-timeout now)]~ state]
::
++ take-wait
|= [our=@p now=@da =wire]
^- (quip card _state)
?. ?=([%pub @ %wait ~] wire) `state
?. (once i.t.wire) `state
;< new-state=_state rind check-ip
=. state new-state
::
(set-timer now)
--
--
%+ verb | %+ verb |
^- agent:gall ^- agent:gall
|_ =bowl:gall |_ =bowl:gall
@ -281,28 +66,73 @@
:: ::
++ on-init ++ on-init
^- [(list card) _this] ^- [(list card) _this]
=. plan.state [%nat ~] =. mode.state %formal
=^ cards state (kick:ships our.bowl now.bowl) =. pokes.state 0
[cards this] =. galaxy.state (galaxy-for our.bowl bowl)
[~ this]
:: ::
++ on-save !>(state)
++ on-load ++ on-load
|= old-vase=vase |= old-vase=vase
|^ |^
=/ old !<(state-any old-vase) =/ old !<(state-any old-vase)
=? old ?=(%0 -.old) (state-0-to-1 old) =? old ?=(%0 -.old) (state-0-to-1 old)
?> ?=(%1 -.old) =? old ?=(%1 -.old) (state-1-to-2 old)
=? old ?=(%2 -.old) (state-2-to-3 old)
?> ?=(%3 -.old)
=. state old =. state old
=^ cards state (kick:ships our.bowl now.bowl) [~ this]
[cards this]
:: ::
+$ state-any $%(state-0 state-1) +$ ship-state
+$ state-0 [%0 ships=(map ship [=rift =ship-state])] $% [%idle ~]
[%poking ~]
[%http until=@da]
[%waiting until=@da]
==
+$ state-any $%(state-0 state-1 state-2 state-3)
+$ state-0 [%0 ships=(map ship [=rift =ship-state])]
+$ state-1
$: %1
ships=(set ship)
nonce=@ud
$= plan
$~ [%nat ~]
$% [%nat ~]
[%pub ip=(unit @t)]
== ==
+$ state-2
$: %2
ships=(set ship)
nonce=@ud
$= plan
$~ [%nat ~]
$% [%nat ~]
[%pub ip=(unit @t)]
[%off ~]
[%one ~]
==
==
:: ::
++ state-0-to-1 ++ state-0-to-1
|= old=state-0 |= old=state-0
^- state-1 ^- state-1
[%1 ~ 0 %nat ~] [%1 ~ 0 %nat ~]
::
++ state-1-to-2
|= old=state-1
^- state-2
old(- %2)
::
++ state-2-to-3
|= old=state-2
^- state-3
:* %3 %formal 0 ~
=/ galaxy=(list @p)
%+ skim ~(tap in ships.old)
|=(p=@p ?=(%czar (clan:title p)))
?: =(1 (lent galaxy))
-.galaxy
(head (flop (^saxo:title our.bowl)))
==
-- --
:: +on-poke: positively acknowledge pokes :: +on-poke: positively acknowledge pokes
:: ::
@ -311,20 +141,21 @@
?. =(our src):bowl :: don't crash, this is where pings are handled ?. =(our src):bowl :: don't crash, this is where pings are handled
`this `this
:: ::
?: ?=(%czar (clan:title our.bowl))
`this
::
=^ cards state =^ cards state
?: =(q.vase %kick) :: NB: ames calls this on %born ?: ?=([%kick ?] q.vase)
(kick:ships our.bowl now.bowl) =? mode.state =(+.q.vase %.y)
?: =(q.vase %nat) %formal
=. plan.state [%nat ~] (ping (galaxy-for our.bowl bowl) %.n)
(kick:ships our.bowl now.bowl) ::
?: =(q.vase %no-nat) ?: |(=(q.vase %once) =(q.vase %stop)) :: NB: ames calls this on %once
=. plan.state [%pub ~] =. mode.state %informal
(kick:ships our.bowl now.bowl) (ping (galaxy-for our.bowl bowl) %.y)
`state `state
[cards this] [cards this]
:: ::
++ on-watch on-watch:def
++ on-leave on-leave:def
++ on-peek ++ on-peek
|= =path |= =path
^- (unit (unit cage)) ^- (unit (unit cage))
@ -334,19 +165,18 @@
++ on-agent ++ on-agent
|= [=wire =sign:agent:gall] |= [=wire =sign:agent:gall]
^- [(list card) _this] ^- [(list card) _this]
=^ cards state ?. ?=([%ping *] wire)
?+ wire `state `this
[%nat *] ?. ?=(%poke-ack -.sign)
?. ?=(%nat -.plan.state) `state `this
?. ?=(%poke-ack -.sign) `state =. pokes.state (dec pokes.state)
(take-ping:nat now.bowl wire p.sign) ?. =(pokes.state 0)
:: `this
[%pub *] ?. |(?=(%formal mode.state) ?=(^ p.sign))
?. ?=(%pub -.plan.state) `state `this
?. ?=(%poke-ack -.sign) `state =/ wir /wait
(take-pings:pub wire p.sign) =. timer.state `[wir now.bowl]
== [[(wait-card wir now.bowl)]~ this]
[cards this]
:: +on-arvo: handle timer firing :: +on-arvo: handle timer firing
:: ::
++ on-arvo ++ on-arvo
@ -354,36 +184,22 @@
^- [(list card) _this] ^- [(list card) _this]
=^ cards state =^ cards state
?+ wire `state ?+ wire `state
[%jael %delay ~] [%wait *]
?: ?=(%czar (clan:title our.bowl))
`state
?. ?=(%formal mode.state) `state
?> ?=(%wake +<.sign-arvo) ?> ?=(%wake +<.sign-arvo)
?^ error.sign-arvo ?^ error.sign-arvo
%- (slog 'ping: strange jael wake fail!' u.error.sign-arvo) %- (slog 'ping: strange wake fail!' u.error.sign-arvo)
`state `state
(take-delay:ships our.bowl now.bowl) =. timer.state ~
(ping (galaxy-for our.bowl bowl) %.n)
:: ::
[%jael ~]
?> ?=(%public-keys +<.sign-arvo)
(take-jael:ships now.bowl)
::
[%nat *]
?. ?=(%nat -.plan.state) `state
?> ?=(%wake +<.sign-arvo)
?^ error.sign-arvo
%- (slog 'ping: strange nat wake fail!' u.error.sign-arvo)
`state
(take-wait:nat wire)
::
[%pub @ %ip *]
?. ?=(%pub -.plan.state) `state
?> ?=(%http-response +<.sign-arvo)
(take-ip:pub our.bowl wire client-response.sign-arvo)
::
[%pub @ %wait *]
?. ?=(%pub -.plan.state) `state
?> ?=(%wake +<.sign-arvo)
(take-wait:pub our.bowl now.bowl wire)
== ==
[cards this] [cards this]
:: ::
++ on-save !>(state)
++ on-fail on-fail:def ++ on-fail on-fail:def
++ on-watch on-watch:def
++ on-leave on-leave:def
-- --

View File

@ -14,7 +14,7 @@
$: starting=(map yarn [=trying =vase]) $: starting=(map yarn [=trying =vase])
running=(axal thread-form) running=(axal thread-form)
tid=(map tid yarn) tid=(map tid yarn)
serving=(map tid [(unit @ta) =mark =desk]) serving=(map tid [(unit [rid=@ta take=?(%json %noun)]) =mark =desk])
scrying=(jug tid [=wire =ship =path]) scrying=(jug tid [=wire =ship =path])
== ==
:: ::
@ -26,10 +26,20 @@
clean-slate-3 clean-slate-3
clean-slate-4 clean-slate-4
clean-slate-5 clean-slate-5
clean-slate-6
clean-slate clean-slate
== ==
:: ::
+$ clean-slate +$ clean-slate
$: %7
starting=(map yarn [=trying =vase])
running=(list yarn)
tid=(map tid yarn)
serving=(map tid [(unit [rid=@ta take=?(%json %noun)]) =mark =desk])
scrying=(jug tid [wire ship path])
==
::
+$ clean-slate-6
$: %6 $: %6
starting=(map yarn [=trying =vase]) starting=(map yarn [=trying =vase])
running=(list yarn) running=(list yarn)
@ -121,7 +131,8 @@
=. any (old-to-4 any) =. any (old-to-4 any)
=. any (old-to-5 any) =. any (old-to-5 any)
=. any (old-to-6 any) =. any (old-to-6 any)
?> ?=(%6 -.any) =. any (old-to-7 any)
?> ?=(%7 -.any)
:: ::
=. tid.state tid.any =. tid.state tid.any
=/ yarns=(list yarn) =/ yarns=(list yarn)
@ -148,8 +159,8 @@
++ old-to-2 ++ old-to-2
|= old=clean-slate-any |= old=clean-slate-any
^- (quip card clean-slate-any) ^- (quip card clean-slate-any)
?> ?=(?(%1 %2 %3 %4 %5 %6) -.old) ?> ?=(?(%1 %2 %3 %4 %5 %6 %7) -.old)
?: ?=(?(%2 %3 %4 %5 %6) -.old) ?: ?=(?(%2 %3 %4 %5 %6 %7) -.old)
`old `old
:- ~[bind-eyre:sc] :- ~[bind-eyre:sc]
:* %2 :* %2
@ -162,8 +173,8 @@
++ old-to-3 ++ old-to-3
|= old=clean-slate-any |= old=clean-slate-any
^- clean-slate-any ^- clean-slate-any
?> ?=(?(%2 %3 %4 %5 %6) -.old) ?> ?=(?(%2 %3 %4 %5 %6 %7) -.old)
?: ?=(?(%3 %4 %5 %6) -.old) ?: ?=(?(%3 %4 %5 %6 %7) -.old)
old old
:* %3 :* %3
starting.old starting.old
@ -175,8 +186,8 @@
++ old-to-4 ++ old-to-4
|= old=clean-slate-any |= old=clean-slate-any
^- clean-slate-any ^- clean-slate-any
?> ?=(?(%3 %4 %5 %6) -.old) ?> ?=(?(%3 %4 %5 %6 %7) -.old)
?: ?=(?(%4 %5 %6) -.old) ?: ?=(?(%4 %5 %6 %7) -.old)
old old
:* %4 :* %4
starting.old starting.old
@ -188,15 +199,15 @@
++ old-to-5 ++ old-to-5
|= old=clean-slate-any |= old=clean-slate-any
^- clean-slate-any ^- clean-slate-any
?> ?=(?(%4 %5 %6) -.old) ?> ?=(?(%4 %5 %6 %7) -.old)
?: ?=(?(%5 %6) -.old) old ?: ?=(?(%5 %6 %7) -.old) old
[%5 +.old(serving [serving.old ~])] [%5 +.old(serving [serving.old ~])]
:: ::
++ old-to-6 ++ old-to-6
|= old=clean-slate-any |= old=clean-slate-any
^- clean-slate ^- clean-slate-any
?> ?=(?(%5 %6) -.old) ?> ?=(?(%5 %6 %7) -.old)
?: ?=(%6 -.old) old ?: ?=(?(%6 %7) -.old) old
:- %6 :- %6
%= +.old %= +.old
scrying scrying
@ -208,6 +219,16 @@
:: ::
[/keen ship path]~ [/keen ship path]~
== ==
::
++ old-to-7
|= old=clean-slate-any
^- clean-slate-any
?> ?=(?(%6 %7) -.old)
?: ?=(%7 -.old) old
=- old(- %7, serving -)
%- ~(run by serving.old)
|= [request=(unit @ta) =mark =desk]
[(bind request (late %json)) mark desk]
-- --
:: ::
++ on-poke ++ on-poke
@ -309,15 +330,36 @@
=* input-mark i.t.t.site.url =* input-mark i.t.t.site.url
=* thread i.t.t.t.site.url =* thread i.t.t.t.site.url
=* output-mark i.t.t.t.t.site.url =* output-mark i.t.t.t.t.site.url
=/ =tid (new-thread-id thread)
=. serving.state
(~(put by serving.state) tid [`eyre-id output-mark desk])
:: TODO: speed this up somehow. we spend about 15ms in this arm alone :: TODO: speed this up somehow. we spend about 15ms in this arm alone
:: ::
=/ tube (convert-tube %json input-mark desk bowl)
?> ?=(^ body.request.inbound-request) ?> ?=(^ body.request.inbound-request)
=/ body=json (need (de:json:html q.u.body.request.inbound-request)) =/ test=$-(@t ?(%json %noun))
=/ input=vase (slop !>(~) (tube !>(body))) |= head=@t
=; type=(unit @t)
?:(=(`'application/x-urb-jam' type) %noun %json)
%+ bind
(get-header:http head header-list.request.inbound-request)
:(cork trip cass crip)
=/ give (test 'content-type')
=/ take (test 'accept')
::
=/ =tid (new-thread-id thread)
=. serving.state
(~(put by serving.state) tid [`[eyre-id take] output-mark desk])
::
=/ input=vase
%+ slop !>(~)
?- give
%json
=/ tube (convert-tube %json input-mark desk bowl)
=/ body=json (need (de:json:html q.u.body.request.inbound-request))
(tube !>(body))
::
%noun
=/ tube (convert-tube %noun input-mark desk bowl)
=/ body=noun (cue q.u.body.request.inbound-request)
(tube !>(body))
==
=/ boc bec =/ boc bec
=/ =start-args:spider [~ `tid boc(q desk, r da+now.bowl) thread input] =/ =start-args:spider [~ `tid boc(q desk, r da+now.bowl) thread input]
(handle-start-thread start-args) (handle-start-thread start-args)
@ -490,8 +532,9 @@
^- [(list card) _state] ^- [(list card) _state]
%+ roll cards.r %+ roll cards.r
|= [=card cards=(list card) s=_state] |= [=card cards=(list card) s=_state]
:_ =? scrying.s ?=([%pass ^ %arvo %a %keen @ *] card) :_ =? scrying.s ?=([%pass ^ %arvo %a %keen ?(~ ^) @ *] card)
(~(put ju scrying.s) tid [&2 &6 |6]:card) :: &2=wire &7=ship 7|=path
(~(put ju scrying.s) tid [&2 &7 |7]:card)
s s
:_ cards :_ cards
^- ^card ^- ^card
@ -549,18 +592,25 @@
=- (fall - `state) =- (fall - `state)
%+ bind %+ bind
(~(get by serving.state) tid) (~(get by serving.state) tid)
|= [eyre-id=(unit @ta) output=mark =desk] |= [request=(unit [rid=@ta take=?(%json %noun)]) output=mark =desk]
:_ state(serving (~(del by serving.state) tid)) :_ state(serving (~(del by serving.state) tid))
?~ eyre-id ?~ request
~ ~
%+ give-simple-payload:app:server u.eyre-id %+ give-simple-payload:app:server rid.u.request
^- simple-payload:http ^- simple-payload:http
?. ?=(http-error:spider term) ?. ?=(http-error:spider term)
%- (slog tang) %- (slog tang)
=/ tube (convert-tube %tang %json desk bowl) ?- take.u.request
:- [500 [['content-type' 'application/json'] ~]] %json
=- `(as-octs:mimes:html (en:json:html -)) =/ tube (convert-tube %tang %json desk bowl)
o/(malt `(list [key=@t json])`[term+s/term tang+!<(json (tube !>(tang))) ~]) :- [500 [['content-type' 'application/json'] ~]]
=- `(as-octs:mimes:html (en:json:html -))
o/(malt `(list [key=@t json])`[term+s/term tang+!<(json (tube !>(tang))) ~])
::
%noun
:- [500 [['content-type' 'application/x-urb-jam'] ~]]
`(as-octs:mimes:html (jam [term tang]))
==
:_ ~ :_ ~ :_ ~ :_ ~
?- term ?- term
%bad-request 400 %bad-request 400
@ -587,13 +637,22 @@
=- (fall - `state) =- (fall - `state)
%+ bind %+ bind
(~(get by serving.state) tid) (~(get by serving.state) tid)
|= [eyre-id=(unit @ta) output=mark =desk] |= [request=(unit [rid=@ta take=?(%json %noun)]) output=mark =desk]
?~ eyre-id ?~ request
`state `state
=/ tube (convert-tube output %json desk bowl) ?- take.u.request
:_ state(serving (~(del by serving.state) tid)) %json
%+ give-simple-payload:app:server u.eyre-id =/ tube (convert-tube output %json desk bowl)
(json-response:gen:server !<(json (tube vase))) :_ state(serving (~(del by serving.state) tid))
%+ give-simple-payload:app:server rid.u.request
(json-response:gen:server !<(json (tube vase)))
::
%noun
:_ state(serving (~(del by serving.state) tid))
%+ give-simple-payload:app:server rid.u.request
:- [200 ['content-type' 'application/x-urb-jam']~]
`(as-octs:mimes:html (jam q.vase))
==
:: ::
++ thread-done ++ thread-done
|= [=yarn =vase silent=?] |= [=yarn =vase silent=?]
@ -680,7 +739,7 @@
:: ::
++ clean-state ++ clean-state
!> ^- clean-slate !> ^- clean-slate
6+state(running (turn ~(tap of running.state) head)) 7+state(running (turn ~(tap of running.state) head))
:: ::
++ convert-tube ++ convert-tube
|= [from=mark to=mark =desk =bowl:gall] |= [from=mark to=mark =desk =bowl:gall]

View File

@ -2,7 +2,8 @@
!: !:
|% |%
+$ card card:agent:gall +$ card card:agent:gall
+$ test ?(%agents %marks %generators) +$ command $@(=test [=desk =test])
+$ test ?(%agents %marks %generators %threads)
+$ state +$ state
$: app=(set path) $: app=(set path)
app-ok=? app-ok=?
@ -10,9 +11,10 @@
mar-ok=? mar-ok=?
gen=(set path) gen=(set path)
gen-ok=? gen-ok=?
ted=(set path)
ted-ok=?
== ==
-- --
=, format
^- agent:gall ^- agent:gall
=| =state =| =state
|_ =bowl:gall |_ =bowl:gall
@ -26,12 +28,16 @@
|= [=mark =vase] |= [=mark =vase]
^- [(list card) _this] ^- [(list card) _this]
?> (team:title [our src]:bowl) ?> (team:title [our src]:bowl)
=+ !<(cmd=command vase)
=? cmd ?=(@ cmd)
[q.byk.bowl test.cmd]
?> ?=(^ cmd)
|^ |^
=+ !<(=test vase) ?- test.cmd
?- test %marks test-marks
%marks test-marks %agents test-agents
%agents test-agents
%generators test-generators %generators test-generators
%threads test-threads
== ==
:: ::
++ test-marks ++ test-marks
@ -51,7 +57,7 @@
|=(c=@tD `@tD`?:(=('/' c) '-' c)) |=(c=@tD `@tD`?:(=('/' c) '-' c))
=/ sing=card =/ sing=card
:+ %pass /build/mar/[mak] :+ %pass /build/mar/[mak]
[%arvo %c %warp our.bowl q.byk.bowl ~ %sing %b da+now.bowl /[mak]] [%arvo %c %warp our.bowl desk.cmd ~ %sing %b da+now.bowl /[mak]]
%_ $ %_ $
paz t.paz paz t.paz
fex [sing fex] fex [sing fex]
@ -73,7 +79,7 @@
$(daz t.daz) $(daz t.daz)
=/ sing=card =/ sing=card
:+ %pass /build/app/[i.daz] :+ %pass /build/app/[i.daz]
[%arvo %c %warp our.bowl q.byk.bowl ~ %sing %a da+now.bowl dap-pax] [%arvo %c %warp our.bowl desk.cmd ~ %sing %a da+now.bowl dap-pax]
%_ $ %_ $
daz t.daz daz t.daz
fex [sing fex] fex [sing fex]
@ -93,14 +99,33 @@
$(paz t.paz) $(paz t.paz)
=/ sing=card =/ sing=card
:+ %pass build+i.paz :+ %pass build+i.paz
[%arvo %c %warp our.bowl q.byk.bowl ~ %sing %a da+now.bowl i.paz] [%arvo %c %warp our.bowl desk.cmd ~ %sing %a da+now.bowl i.paz]
%_ $ %_ $
paz t.paz paz t.paz
fex [sing fex] fex [sing fex]
gen.state (~(put in gen.state) i.paz) gen.state (~(put in gen.state) i.paz)
== ==
:: ::
++ now-beak %_(byk.bowl r [%da now.bowl]) ++ test-threads
=| fex=(list card)
^+ [fex this]
?> =(~ ted.state)
=. ted-ok.state %.y
=+ .^(paz=(list path) ct+(en-beam now-beak /ted))
|- ^+ [fex this]
?~ paz [(flop fex) this]
=/ xap=path (flop i.paz)
?. ?=([%hoon *] xap)
$(paz t.paz)
=/ sing=card
:+ %pass build+i.paz
[%arvo %c %warp our.bowl desk.cmd ~ %sing %a da+now.bowl i.paz]
%_ $
paz t.paz
fex [sing fex]
ted.state (~(put in ted.state) i.paz)
==
++ now-beak [our.bowl desk.cmd da+now.bowl]
-- --
++ on-watch on-watch:def ++ on-watch on-watch:def
++ on-leave on-leave:def ++ on-leave on-leave:def
@ -150,6 +175,15 @@
~? =(~ gen.state) ~? =(~ gen.state)
?:(gen-ok.state %all-generators-built %some-generators-failed) ?:(gen-ok.state %all-generators-built %some-generators-failed)
[~ this] [~ this]
::
[%ted *]
=/ ok ?=(^ p.sign-arvo)
%- (report path ok)
=? ted-ok.state !ok %.n
=. ted.state (~(del in ted.state) path)
~? =(~ ted.state)
?:(ted-ok.state %all-threads-built %some-threads-failed)
[~ this]
== ==
++ on-fail on-fail:def ++ on-fail on-fail:def
-- --

View File

@ -0,0 +1,161 @@
:: verb-logger: serializes verb-plus events to unix-side json
::
:: watches specified agents for "verb plus" events, buffers those, and
:: periodically (+write-interval) flushes them out to unix, under the
:: .urb/put/verb-logger/[agent] directory of the pier.
::
/+ verb, dbug, verb-json
::
|%
+$ state-0
$: %0
events=(jar dude:gall event-plus:verb)
==
::
+$ card card:agent:gall
::
++ write-interval ~h1
::
++ write-events
|= [our=ship =dude:gall events=(list event-plus:verb)]
^- (list card)
?: =(~ events) ~ ::NOTE tmi
=/ first=event-plus:verb
(rear events)
=/ pax=path
/verb-logger/[dude]/(crip (a-co:co (unm:chrono:userlib now.first)))/json
=/ vex=@
(en:json:html (events:enjs our dude events))
[%pass /write/[dude] %agent [our %hood] %poke %drum-put !>([pax vex])]~
::
++ ingest-event
|= $: our=ship
events=(jar dude:gall event-plus:verb)
[=dude:gall event=event-plus:verb]
==
^- (quip card _events)
?~ ves=(~(get ja events) dude)
:- ~
(~(put by events) dude [event ~])
?: .= (sub now.i.ves (mod now.i.ves write-interval))
(sub now.event (mod now.event write-interval))
:- ~
(~(put by events) dude [event ves])
:- (write-events our dude ves)
(~(put by events) dude [event ~])
::
++ enjs
=, enjs:format
|%
++ events
|= [our=@p =dude:gall events=(list event-plus:verb)] :: latest-first
=/ first=event-plus:verb (rear events)
%- pairs
:~ 'ship'^s+(scot %p our)
'dude'^s+dude
'from'^(time now.first)
::
:- 'events'
:- %a
%+ roll events ::NOTE we +roll to +turn & +flop simultaneously
|= [event=event-plus:verb out=(list json)]
[(event:enjs:verb-json event) out]
==
--
--
::
=| state-0
=* state -
::
%+ verb |
%- agent:dbug
|_ =bowl:gall
+* this .
::
++ on-init
^- (quip card _this)
[~ this]
::
++ on-save
!>(state)
::
++ on-load
|= ole=vase
^- (quip card _this)
[~ this(state !<(state-0 ole))]
::
++ on-poke
|= [=mark =vase]
^- (quip card _this)
?> =(%noun mark)
?+ q.vase !!
[%watch =dude:gall]
=* dude dude.q.vase
:_ this
[%pass /log/[dude] %agent [our.bowl dude] %watch /verb/events-plus]~
::
[%leave =dude:gall]
=* dude dude.q.vase
:- :- [%pass /log/[dude] %agent [our.bowl dude] %leave ~]
(write-events our.bowl dude (~(get ja events) dude))
this(events (~(del by events) dude))
::
[%flush =dude:gall]
|-
=* dude dude.q.vase
?. =(%$ dude)
:- (write-events our.bowl dude (~(get ja events) dude))
this(events (~(del by events) dude))
=| cards=(list card)
=/ dudes=(list dude:gall) ~(tap in ~(key by events))
|- ^- (quip card _this)
?~ dudes [cards this]
=^ caz this ^$(dude.q.vase i.dudes)
=. cards (weld cards caz)
$(dudes t.dudes)
==
::
++ on-agent
|= [=wire =sign:agent:gall]
^- (quip card _this)
~| wire
?+ wire !!
[%write @ ~]
=* dude i.t.wire
?> ?=(%poke-ack -.sign)
?~ p.sign [~ this]
%. [~ this]
%- %*(. slog pri 3)
[(cat 3 'verb-logger: lost export for %' dude) u.p.sign]
::
[%log @ ~]
=* dude i.t.wire
?- -.sign
%poke-ack !!
%kick =- [[-]~ this]
[%pass /log/[dude] %agent [our.bowl dude] %watch /verb/events-plus]
%watch-ack ?~ p.sign [~ this]
%. [~ this]
%- %*(. slog pri 2)
[(cat 3 'verb-logger: failed verb watch for %' dude) u.p.sign]
%fact ?> =(%verb-event-plus p.cage.sign)
=^ caz events
%- ingest-event
[our.bowl events dude !<(event-plus:verb q.cage.sign)]
[caz this]
==
==
::
++ on-fail
|= [=term =tang]
^- (quip card _this)
%. [~ this]
%- %*(. slog pri 3)
:_ tang
(cat 3 'verb-logger: dropping the ball: ' term)
::
++ on-watch |=(* !!)
++ on-leave |=(* !!)
++ on-arvo |=(* !!)
++ on-peek |=(* ~)
--

View File

@ -0,0 +1,16 @@
:: make a unix commit event
::
:: call as > .event/jam +commit-event /path/to/file
:: to be used with ./urbit-binary -I event.jam pier
::
:: XX expand with arbitrary user-defined events?
:: XX only supports files in which +noun:grab in the mark file returns a @t
:: (e.g. hoon files)
::
:- %say
|= [[now=@da eny=@uvJ bec=beak] [=path ~] ~]
:- %noun
?~ beam=(de-beam path)
~|(%path-not-beam !!)
=+ .^(file=@t %cx path)
[/c/sync %info desk=q.u.beam & [s.u.beam %ins %mime !>([/ (as-octs:mimes:html file)])]~]

View File

@ -0,0 +1,6 @@
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[syd=desk her=ship sud=desk approve=? ~]
~
==
kiln-approve-merge+[[syd her sud] approve]

View File

@ -2,16 +2,36 @@
:: ::
:::: /hoon/cp/hood/gen :::: /hoon/cp/hood/gen
:: ::
:: XX clay discards the type, so %noun is used
:: copy by lobe should be used, if implemented
::
/? 310 /? 310
:- %say :- %say
=, space:userlib =, space:userlib
|= [^ [input=path output=path ~] ~] |= [^ [input=path output=path ~] r=_|]
:- %kiln-info :- %kiln-info
?. =(-:(flop input) -:(flop output)) ^- [mez=tape tor=(unit toro:clay)]
["Can't move to a different mark" ~] ?. r
=+ dir=.^(arch %cy input) ?. =(-:(flop input) -:(flop output))
?~ fil.dir ["Can't move to a different mark" ~]
~& "No such file:" ?~ =<(fil .^(arch %cy input))
[<input> ~] ~& "No such file:"
:- "copied" [<input> ~]
`(foal output -:(flop input) [%atom %t ~] .^(* %cx input)) :: XX type :- "copied"
`(foal output -:(flop input) [%noun .^(* %cx input)])
?~ in-beam=(de-beam input) ["bad input path" ~]
?~ =<(dir .^(arch %cy input)) ["input path isn't a directory" ~]
?~ out-beam=(de-beam output) ["bad output path" ~]
=/ in-beak=beak [p q r]:u.in-beam
=/ out-beak=beak [p q r]:u.out-beam
=/ =soba:clay
%+ murn .^((list path) %ct input)
|= pax=path
?: =(1 (sub (lent pax) (lent s.u.in-beam))) ~
=/ =cage
:- -:(flop pax)
[%noun .^(* %cx (en-beam in-beak pax))]
=/ =spur (weld s.u.out-beam (slag (lent s.u.in-beam) pax))
`[spur (feel (en-beam out-beak spur) cage)]
?~ soba ["nothing to copy" ~]
["copied" `[q.out-beak [%& soba]]]

View File

@ -0,0 +1,6 @@
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[auto=? ~]
~
==
kiln-global-automerge+auto

View File

@ -0,0 +1,6 @@
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[old=dock new=dock ~]
~
==
kiln-jump-opt+[old new &]

View File

@ -0,0 +1,16 @@
/+ *generators
:- %ask
|= $: [now=@da eny=@uvJ bec=beak]
[syd=desk her=ship sud=desk ~]
hard=_|
==
?: hard (produce %kiln-jump-propose syd her sud)
=/ msg
leaf+"Are you sure you want to tell subscribers to get ".
"updates for {<syd>} from {<her>}/{(trip sud)}?"
%+ print msg
%+ prompt [%& %prompt "(y/N) "]
|= in=tape
?. |(=("y" in) =("Y" in) =("yes" in))
no-product
(produce %kiln-jump-propose syd her sud)

View File

@ -0,0 +1,6 @@
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[old=dock new=dock ~]
~
==
kiln-jump-opt+[old new |]

View File

@ -24,6 +24,14 @@
?^ arg ?^ arg
mon.arg mon.arg
(add our (lsh 5 (end 5 (shaz eny)))) (add our (lsh 5 (end 5 (shaz eny))))
=/ ryf=(unit rift)
.^((unit rift) %j /(scot %p p.bec)/ryft/(scot %da now)/(scot %p mon))
?^ ryf
%. ~
%- slog
:~ leaf+"can't create {(scow %p mon)}, it already exists."
'use |moon-breach and/or |moon-cycle-keys instead.'
==
=/ seg=ship (sein:title our now mon) =/ seg=ship (sein:title our now mon)
?. =(our seg) ?. =(our seg)
%- %- slog :_ ~ %- %- slog :_ ~

View File

@ -0,0 +1,6 @@
:- %say
|= $: [now=@da eny=@uvJ bec=beak]
[syd=desk her=ship sud=desk auto=(unit ?) ~]
~
==
kiln-sync-automerge+[[syd her sud] auto]

16
pkg/arvo/gen/jumps.hoon Normal file
View File

@ -0,0 +1,16 @@
/- h=hood
:- %say
|= [[now=@da eny=@uvJ bec=beak] ~ ~]
:- %tang
^- tang
=+ .^ hop=jump:h
%gx
(scot %p p.bec)
%hood
(scot %da now)
/kiln/jumps/noun
==
?> ?=(%all -.hop)
%+ turn ~(tap by all.hop)
|= [old=dock new=dock]
leaf+"{<p.old>}/{(trip q.old)} -> {<p.new>}/{(trip q.new)}"

16
pkg/arvo/gen/updates.hoon Normal file
View File

@ -0,0 +1,16 @@
/- h=hood
:- %say
|= [[now=@da eny=@uvJ bec=beak] ~ ~]
:- %tang
^- tang
=+ .^ upd=sync-update:h
%gx
(scot %p p.bec)
%hood
(scot %da now)
/kiln/pending/noun
==
?> ?=(%pending -.upd)
%+ turn ~(tap in pending.upd)
|= [sync-record:h rev=@ud]
leaf+"{<syd>} <- {<her>}/{(trip sud)}/{<rev>}"

View File

@ -2,6 +2,6 @@
:- %say :- %say
|= [[now=@da eny=@uvJ bec=beak] [syd=desk ~] verb=_&] |= [[now=@da eny=@uvJ bec=beak] [syd=desk ~] verb=_&]
:* %tang :* %tang
leaf+"Notice: +vat is deprecated. use +vats which now takes one or more desks as arguments. e.g. '+vats %base %garden'" leaf+"Notice: +vat is deprecated. use +vats which now takes one or more desks as arguments. e.g. '+vats %base %landscape'"
(report-vat (report-prep p.bec now) p.bec now syd verb) (report-vat (report-prep p.bec now) p.bec now syd verb)
== ==

View File

@ -17,12 +17,4 @@
[filt=@tas verb=_|] [filt=@tas verb=_|]
== ==
:- %tang ^- tang :- %tang ^- tang
?. &(=(~ deks) =(%$ filt)) (report-vats p.bec now deks filt verb)
(report-vats p.bec now deks filt verb)
%- zing
%+ turn
%+ sort
=/ sed .^((set desk) %cd /(scot %p p.bec)//(scot %da now))
(sort ~(tap in sed) |=([a=@ b=@] !(aor a b)))
|=([a=desk b=desk] ?|(=(a %kids) =(b %base)))
|=(syd=desk (report-vat (report-prep p.bec now) p.bec now syd verb))

View File

@ -1070,8 +1070,9 @@
++ wrd :: next or current word ++ wrd :: next or current word
|= a=(list @) |= a=(list @)
=| i=@ud =| i=@ud
?~ a i
|- ^- @ud |- ^- @ud
?: |(?=(~ a) (alnm i.a)) i ?: |(?=(~ t.a) (alnm i.a)) i
$(i +(i), a t.a) $(i +(i), a t.a)
-- --
-- --

View File

@ -5,7 +5,8 @@
=, format =, format
=* dude dude:gall =* dude dude:gall
|% |%
+$ state state-10 +$ state state-11
+$ state-11 [%11 pith-11]
+$ state-10 [%10 pith-10] +$ state-10 [%10 pith-10]
+$ state-9 [%9 pith-9] +$ state-9 [%9 pith-9]
+$ state-8 [%8 pith-9] +$ state-8 [%8 pith-9]
@ -19,7 +20,8 @@
+$ state-0 [%0 pith-0] +$ state-0 [%0 pith-0]
+$ any-state +$ any-state
$~ *state $~ *state
$% state-10 $% state-11
state-10
state-9 state-9
state-8 state-8
state-7 state-7
@ -32,10 +34,32 @@
state-0 state-0
== ==
:: ::
+$ pith-11
$: rem=(map desk per-desk)
nyz=@ud
zyn=(map sync-record sync-state)
:: requests from publishers to switch sync source
hop=(map dock dock)
:: toggle global update auto-merge
mer=?
::
commit-timer=[way=wire nex=@da tim=@dr mon=term]
:: map desk to the currently ongoing fuse request
:: and the latest version numbers for beaks to
fus=(map desk per-fuse)
:: used for fuses - every time we get a fuse we
:: bump this. used when calculating hashes to
:: ensure they're unique even when the same
:: request is made multiple times.
hxs=(map desk @ud)
==
::
+$ sync-state-10 [nun=@ta kid=(unit desk) let=@ud]
::
+$ pith-10 +$ pith-10
$: rem=(map desk per-desk) $: rem=(map desk per-desk)
nyz=@ud nyz=@ud
zyn=(map kiln-sync sync-state) zyn=(map sync-record sync-state-10)
commit-timer=[way=wire nex=@da tim=@dr mon=term] commit-timer=[way=wire nex=@da tim=@dr mon=term]
:: map desk to the currently ongoing fuse request :: map desk to the currently ongoing fuse request
:: and the latest version numbers for beaks to :: and the latest version numbers for beaks to
@ -50,7 +74,7 @@
+$ pith-9 +$ pith-9
$: wef=(unit weft) $: wef=(unit weft)
rem=(map desk per-desk) rem=(map desk per-desk)
syn=(map kiln-sync let=@ud) syn=(map sync-record let=@ud)
ark=(map desk arak-9) ark=(map desk arak-9)
commit-timer=[way=wire nex=@da tim=@dr mon=term] commit-timer=[way=wire nex=@da tim=@dr mon=term]
:: map desk to the currently ongoing fuse request :: map desk to the currently ongoing fuse request
@ -78,7 +102,7 @@
+$ pith-7 +$ pith-7
$: wef=(unit weft) $: wef=(unit weft)
rem=(map desk per-desk) rem=(map desk per-desk)
syn=(map kiln-sync let=@ud) syn=(map sync-record let=@ud)
ark=(map desk arak-7) ark=(map desk arak-7)
commit-timer=[way=wire nex=@da tim=@dr mon=term] commit-timer=[way=wire nex=@da tim=@dr mon=term]
:: map desk to the currently ongoing fuse request :: map desk to the currently ongoing fuse request
@ -121,7 +145,7 @@
+$ pith-6 +$ pith-6
$: wef=(unit weft) $: wef=(unit weft)
rem=(map desk per-desk) :: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) :: syn=(map sync-record let=@ud) ::
ark=(map desk arak-6) :: ark=(map desk arak-6) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] :: commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
:: map desk to the currently ongoing fuse request :: map desk to the currently ongoing fuse request
@ -139,7 +163,7 @@
:: ::
+$ pith-5 +$ pith-5
$: rem=(map desk per-desk) :: $: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) :: syn=(map sync-record let=@ud) ::
ark=(map desk arak-6) :: ark=(map desk arak-6) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] :: commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
:: map desk to the currently ongoing fuse request :: map desk to the currently ongoing fuse request
@ -154,7 +178,7 @@
:: ::
+$ pith-4 :: +$ pith-4 ::
$: rem=(map desk per-desk) :: $: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) :: syn=(map sync-record let=@ud) ::
ark=(map desk arak-4) :: ark=(map desk arak-4) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] :: commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
:: map desk to the currently ongoing fuse request :: map desk to the currently ongoing fuse request
@ -175,7 +199,7 @@
== ==
+$ pith-3 :: +$ pith-3 ::
$: rem=(map desk per-desk) :: $: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) :: syn=(map sync-record let=@ud) ::
ark=(map desk arak-3) :: ark=(map desk arak-3) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] :: commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
:: map desk to the currently ongoing fuse request :: map desk to the currently ongoing fuse request
@ -201,7 +225,7 @@
:: ::
+$ pith-2 :: +$ pith-2 ::
$: rem=(map desk per-desk) :: $: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) :: syn=(map sync-record let=@ud) ::
ota=(unit [=ship =desk =aeon]) :: ota=(unit [=ship =desk =aeon]) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] :: commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
fus=(map desk per-fuse) fus=(map desk per-fuse)
@ -209,13 +233,13 @@
== :: == ::
+$ pith-1 :: +$ pith-1 ::
$: rem=(map desk per-desk) :: $: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) :: syn=(map sync-record let=@ud) ::
ota=(unit [=ship =desk =aeon]) :: ota=(unit [=ship =desk =aeon]) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] :: commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
== :: == ::
+$ pith-0 :: +$ pith-0 ::
$: rem=(map desk per-desk) :: $: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) :: syn=(map sync-record let=@ud) ::
autoload-on=? :: autoload-on=? ::
cur-hoon=@uvI :: cur-hoon=@uvI ::
cur-arvo=@uvI :: cur-arvo=@uvI ::
@ -245,16 +269,6 @@
pot=term :: pot=term ::
== ==
+$ kiln-unmount $@(term [knot path]) :: +$ kiln-unmount $@(term [knot path]) ::
+$ kiln-sync ::
$: syd=desk :: local desk
her=ship :: foreign ship
sud=desk :: foreign desk
==
+$ kiln-unsync ::
$: syd=desk :: local desk
her=ship :: foreign ship
sud=desk :: foreign desk
==
+$ kiln-merge :: +$ kiln-merge ::
$@ ~ $@ ~
$: syd=desk :: $: syd=desk ::
@ -285,7 +299,6 @@
+$ kiln-fuse-list (unit desk) +$ kiln-fuse-list (unit desk)
-- --
|= [bowl:gall state] |= [bowl:gall state]
?> =(src our)
=| moz=(list card:agent:gall) =| moz=(list card:agent:gall)
|% |%
++ kiln . ++ kiln .
@ -440,7 +453,7 @@
=^ cards-9=(list card:agent:gall) old =^ cards-9=(list card:agent:gall) old
?. ?=(%9 -.old) ?. ?=(%9 -.old)
`old `old
=/ syn=(set kiln-sync) =/ syn=(set sync-record)
%- ~(gas in ~(key by syn.old)) %- ~(gas in ~(key by syn.old))
%+ murn ~(tap by ark.old) %+ murn ~(tap by ark.old)
|= [=desk =arak-9] |= [=desk =arak-9]
@ -468,8 +481,8 @@
[%pass /kiln/load-zest %arvo %c %zest desk zest] [%pass /kiln/load-zest %arvo %c %zest desk zest]
:: ::
%+ turn ~(tap in syn) %+ turn ~(tap in syn)
|= k=kiln-sync |= r=sync-record
[%pass /kiln/load-sync %agent [our %hood] %poke %kiln-sync !>(k)] [%pass /kiln/load-sync %agent [our %hood] %poke %kiln-sync !>(r)]
:: ::
=/ ks ~(tap in syn) =/ ks ~(tap in syn)
|- ^- (list card:agent:gall) |- ^- (list card:agent:gall)
@ -483,7 +496,17 @@
$(ks t.ks) $(ks t.ks)
== ==
:: ::
?> ?=(%10 -.old) =? old ?=(%10 -.old)
%= old
- %11
|4 [hop=~ mer=& |4.old]
zyn %- ~(run by zyn.old)
|= sync-state-10
^- sync-state
[nun kid let ~ ~ |]
==
::
?> ?=(%11 -.old)
=. state old =. state old
abet:(emil cards-9) abet:(emil cards-9)
:: ::
@ -499,18 +522,31 @@
=/ ver (mergebase-hashes our %base now (~(got by sources) %base)) =/ ver (mergebase-hashes our %base now (~(got by sources) %base))
``noun+!>(?~(ver 0v0 i.ver)) ``noun+!>(?~(ver 0v0 i.ver))
:: ::
[%x %kiln %syncs ~] ``noun+!>(zyn) [%x %kiln %jumps ~] ``kiln-jump+!>([%all hop])
[%x %kiln %sources ~] ``noun+!>(sources) [%x %kiln %syncs ~] ``noun+!>(zyn)
[%x %kiln %sources ~] ``noun+!>(sources)
[%x %kiln %automerge ~] ``loob+!>(mer)
[%x %kiln %pikes ~] [%x %kiln %pikes ~]
=+ .^(=rock:tire %cx /(scot %p our)//(scot %da now)/tire) =+ .^(=rock:tire %cx /(scot %p our)//(scot %da now)/tire)
:^ ~ ~ %kiln-pikes :^ ~ ~ %kiln-pikes
!> ^- pikes !> ^- pikes
%- ~(rut by rock) %- ~(urn by rock)
|= [=desk =zest wic=(set weft)] |= [=desk =zest wic=(set weft)]
^- pike ^- pike
=+ .^(hash=@uv %cz /(scot %p our)/[desk]/(scot %da now)) =+ .^(hash=@uv %cz /(scot %p our)/[desk]/(scot %da now))
=/ sync (~(get by sources) desk) =/ sync (~(get by sources) desk)
[sync hash zest wic] [sync hash zest wic]
::
[%x %kiln %pending ~]
:^ ~ ~ %kiln-sync-update
!> ^- sync-update
:- %pending
%- ~(gas by *(set [sync-record @ud]))
^- (list [sync-record @ud])
%+ murn ~(tap by zyn)
|= [sync-record sync-state]
?~ hav ~
(some [syd her sud] u.hav)
== ==
:: ::
:: +get-germ: select merge strategy into local desk :: +get-germ: select merge strategy into local desk
@ -528,12 +564,15 @@
:: ::
++ poke ++ poke
|= [=mark =vase] |= [=mark =vase]
?> |(=(src our) =(%kiln-jump-ask mark))
?+ mark ~|([%poke-kiln-bad-mark mark] !!) ?+ mark ~|([%poke-kiln-bad-mark mark] !!)
%kiln-approve-merge =;(f (f !<(_+<.f vase)) poke-approve-merge)
%kiln-autocommit =;(f (f !<(_+<.f vase)) poke-autocommit) %kiln-autocommit =;(f (f !<(_+<.f vase)) poke-autocommit)
%kiln-bump =;(f (f !<(_+<.f vase)) poke-bump) %kiln-bump =;(f (f !<(_+<.f vase)) poke-bump)
%kiln-cancel =;(f (f !<(_+<.f vase)) poke-cancel) %kiln-cancel =;(f (f !<(_+<.f vase)) poke-cancel)
%kiln-cancel-autocommit =;(f (f !<(_+<.f vase)) poke-cancel-autocommit) %kiln-cancel-autocommit =;(f (f !<(_+<.f vase)) poke-cancel-autocommit)
%kiln-commit =;(f (f !<(_+<.f vase)) poke-commit) %kiln-commit =;(f (f !<(_+<.f vase)) poke-commit)
%kiln-sync-automerge =;(f (f !<(_+<.f vase)) poke-sync-automerge)
%kiln-fuse =;(f (f !<(_+<.f vase)) poke-fuse) %kiln-fuse =;(f (f !<(_+<.f vase)) poke-fuse)
%kiln-fuse-list =;(f (f !<(_+<.f vase)) poke-fuse-list) %kiln-fuse-list =;(f (f !<(_+<.f vase)) poke-fuse-list)
%kiln-gall-sear =;(f (f !<(_+<.f vase)) poke-gall-sear) %kiln-gall-sear =;(f (f !<(_+<.f vase)) poke-gall-sear)
@ -543,12 +582,16 @@
%kiln-label =;(f (f !<(_+<.f vase)) poke-label) %kiln-label =;(f (f !<(_+<.f vase)) poke-label)
%kiln-merge =;(f (f !<(_+<.f vase)) poke-merge) %kiln-merge =;(f (f !<(_+<.f vase)) poke-merge)
%kiln-mount =;(f (f !<(_+<.f vase)) poke-mount) %kiln-mount =;(f (f !<(_+<.f vase)) poke-mount)
%kiln-jump-ask =;(f (f !<(_+<.f vase)) poke-jump-ask)
%kiln-jump-opt =;(f (f !<(_+<.f vase)) poke-jump-opt)
%kiln-jump-propose =;(f (f !<(_+<.f vase)) poke-jump-propose)
%kiln-nuke =;(f (f !<(_+<.f vase)) poke-nuke) %kiln-nuke =;(f (f !<(_+<.f vase)) poke-nuke)
%kiln-pause =;(f (f !<(_+<.f vase)) poke-pause) %kiln-pause =;(f (f !<(_+<.f vase)) poke-pause)
%kiln-permission =;(f (f !<(_+<.f vase)) poke-permission) %kiln-permission =;(f (f !<(_+<.f vase)) poke-permission)
%kiln-revive =;(f (f !<(_+<.f vase)) poke-revive) %kiln-revive =;(f (f !<(_+<.f vase)) poke-revive)
%kiln-rein =;(f (f !<(_+<.f vase)) poke-rein) %kiln-rein =;(f (f !<(_+<.f vase)) poke-rein)
%kiln-rm =;(f (f !<(_+<.f vase)) poke-rm) %kiln-rm =;(f (f !<(_+<.f vase)) poke-rm)
%kiln-global-automerge =;(f (f !<(_+<.f vase)) poke-global-automerge)
%kiln-schedule =;(f (f !<(_+<.f vase)) poke-schedule) %kiln-schedule =;(f (f !<(_+<.f vase)) poke-schedule)
%kiln-suspend =;(f (f !<(_+<.f vase)) poke-suspend) %kiln-suspend =;(f (f !<(_+<.f vase)) poke-suspend)
%kiln-suspend-many =;(f (f !<(_+<.f vase)) poke-suspend-many) %kiln-suspend-many =;(f (f !<(_+<.f vase)) poke-suspend-many)
@ -559,6 +602,19 @@
%kiln-unsync =;(f (f !<(_+<.f vase)) poke-unsync) %kiln-unsync =;(f (f !<(_+<.f vase)) poke-unsync)
== ==
:: ::
++ poke-approve-merge
|= [sync-record approve=?]
?~ got=(~(get by zyn) syd her sud)
=+ msg="kiln: no syncs from {(scow %p her)}/{(trip sud)} to {<syd>}"
((slog leaf+msg ~) abet)
?~ hav.u.got
=+ msg="kiln: no updates from {(scow %p her)}/{(trip sud)} for {<syd>}"
((slog leaf+msg ~) abet)
=< abet
?. approve
abet:drop:(sync syd her sud)
abet:(merg /main syd):(sync syd her sud)
::
++ poke-autocommit ++ poke-autocommit
|= [mon=kiln-commit auto=?] |= [mon=kiln-commit auto=?]
=< abet =< abet
@ -679,6 +735,23 @@
|= =ship |= =ship
abet:(emit %pass /kiln %arvo %g %sear ship) abet:(emit %pass /kiln %arvo %g %sear ship)
:: ::
++ poke-global-automerge
|= auto=?
=. mer auto
?. mer abet
=/ zyns=(list [sync-record sync-state]) ~(tap by zyn)
=< abet
|-
?~ zyns ..abet
?. ?& ?=(^ hav.i.zyns)
!?=([~ %.n] nit.i.zyns)
==
$(zyns t.zyns)
%= $
zyns t.zyns
..abet abet:(merg /main syd):(sync -.i.zyns)
==
::
++ poke-info ++ poke-info
|= [mez=tape tor=(unit toro)] |= [mez=tape tor=(unit toro)]
?~ tor ?~ tor
@ -692,17 +765,20 @@
?~ got=(~(get by rock) loc) ?~ got=(~(get by rock) loc)
%dead %dead
zest.u.got zest.u.got
=. zyn =. ..abet
?~ got=(~(get by sources) loc) ?~ got=(~(get by sources) loc)
zyn ..abet
(~(del by zyn) loc u.got) ?: =([her rem] u.got)
..abet
=. ..abet abet:drop:(sync loc u.got)
..abet(zyn (~(del by zyn) loc u.got))
=? ..abet ?=(%dead zest) =? ..abet ?=(%dead zest)
(emit %pass /kiln/install %arvo %c %zest loc ?:(=(our her) %live %held)) (emit %pass /kiln/install %arvo %c %zest loc ?:(=(our her) %live %held))
?: (~(has by zyn) loc her rem) ?: (~(has by zyn) loc her rem)
abet:(spam (render "already syncing" loc her rem ~) ~) abet:(spam (render "already syncing" loc her rem ~) ~)
?: =([our loc] [her rem]) ?: =([our loc] [her rem])
abet abet
=/ sun (sync loc her rem) =/ sun okay:(sync loc her rem)
~> %slog.(fmt "beginning install into {here:sun}") ~> %slog.(fmt "beginning install into {here:sun}")
=< abet:abet:init =< abet:abet:init
?: =(%base loc) ?: =(%base loc)
@ -710,7 +786,7 @@
sun sun
:: ::
++ poke-kids ++ poke-kids
|= [hos=kiln-sync nex=(unit desk)] |= [hos=sync-record nex=(unit desk)]
abet:abet:(apex:(sync hos) nex) abet:abet:(apex:(sync hos) nex)
:: ::
++ poke-label ++ poke-label
@ -731,6 +807,84 @@
abet:(spam leaf+- ~) abet:(spam leaf+- ~)
abet:(emit %pass /mount %arvo %c [%mont pot u.bem]) abet:(emit %pass /mount %arvo %c [%mont pot u.bem])
:: ::
++ poke-jump-propose
|= [syd=desk her=ship sud=desk]
?: =([our syd] [her sud])
abet
=/ let=@ud ud:.^(cass:clay %cw /(scot %p our)/[syd]/(scot %da now))
=/ subs=(set [@p rave:clay])
.^((set [@p rave:clay]) %cx /(scot %p our)//(scot %da now)/cult/[syd])
=/ ships=(set @p)
%+ roll ~(tap in subs)
|= [[=ship =rave:clay] ships=(set @p)]
?: =(our ship) ships
?. ?=([%sing %w [%ud @] ~] rave) ships
?. =(+(let) p.case.mood.rave) ships
(~(put in ships) ship)
=< abet
%- emil
%+ turn ~(tap in ships)
|= =ship
:* %pass /kiln/jump-propose %agent [ship %hood]
%poke %kiln-jump-ask !>([[our syd] [her sud]])
==
::
++ poke-jump-ask
|= [old=dock new=dock]
?> |(=(src p.old) =(src our))
?: =(old new)
?~ had=(~(get by hop) old)
abet
=. hop (~(del by hop) old)
abet:(emit %give %fact ~[/jumps] %kiln-jump !>([%nay old u.had]))
?~ (skim ~(tap by sources) |=(sync-record =(old [her sud])))
~> %slog.(fmt "no syncs from {(scow %p p.old)}/{(trip q.old)}")
abet
=. hop (~(put by hop) old new)
abet:(emit %give %fact ~[/jumps] %kiln-jump !>([%add old new]))
::
++ poke-jump-opt
|= [old=dock new=dock yea=?]
?~ got=(~(get by hop) old)
~> %slog.(fmt "no jump request for {(scow %p p.old)}/{(trip q.old)}")
abet
?. =(new u.got)
=/ txt-old "{(scow %p p.old)}/{(trip q.old)}"
=/ txt-new "{(scow %p p.new)}/{(trip q.new)}"
~> %slog.(fmt "no jump request from {txt-old} to {txt-new}")
abet
?. yea
=/ txt-old "{(scow %p p.old)}/{(trip q.old)}"
=/ txt-new "{(scow %p p.new)}/{(trip q.new)}"
~> %slog.(fmt "denied jump from {txt-old} to {txt-new}")
=. hop (~(del by hop) old)
abet:(emit %give %fact ~[/jumps] %kiln-jump !>([%nay old new]))
=/ old-sources=(list sync-record)
(skim ~(tap by sources) |=(sync-record =(old [her sud])))
=/ new-sources=(list sync-record)
(turn old-sources |=(sync-record [syd new]))
=. ..abet
(emit %give %fact ~[/jumps] %kiln-jump !>([%yea old new]))
=. ..abet
|-
?~ old-sources
..abet
=. ..abet abet:drop:(sync i.old-sources)
=. zyn (~(del by zyn) i.old-sources)
$(old-sources t.old-sources, ..abet ..abet)
=. hop (~(del by hop) old)
=< abet
|- ^+ ..abet
?~ new-sources ..abet
%= $
new-sources t.new-sources
..abet =/ sun (sync i.new-sources)
=< abet:init
?: =(%base syd.i.new-sources)
(apex:sun `%kids)
sun
==
::
++ poke-nuke ++ poke-nuke
|= [=term desk=?] |= [=term desk=?]
=< abet =< abet
@ -801,11 +955,28 @@
|=(=desk [%pass /kiln/suspend %arvo %c %zest desk %dead]) |=(=desk [%pass /kiln/suspend %arvo %c %zest desk %dead])
:: ::
++ poke-sync ++ poke-sync
|= hos=kiln-sync |= sync-record
?: (~(has by zyn) hos) ?: (~(has by zyn) sud her syd)
abet:(spam (render "already syncing" [sud her syd ~]:hos) ~) abet:(spam (render "already syncing" [sud her syd ~]) ~)
~> %slog.(fmt "beginning sync into {<syd.hos>} from {<her.hos>}/{<sud.hos>}") =. ..abet
abet:abet:init:(sync hos) ?~ got=(~(get by sources) syd)
..abet
=. ..abet abet:drop:(sync syd u.got)
..abet(zyn (~(del by zyn) syd u.got))
~> %slog.(fmt "beginning sync into {<syd>} from {<her>}/{<sud>}")
abet:abet:init:(sync syd her sud)
::
++ poke-sync-automerge
|= [sync-record auto=(unit ?)]
?~ got=(~(get by zyn) syd her sud)
=+ msg="kiln: no syncs from {(scow %p her)}/{(trip sud)} to {<syd>}"
((slog leaf+msg ~) abet)
=. zyn (~(put by zyn) [syd her sud] u.got(nit auto))
?~ hav.u.got
abet
?. |(?=([~ %.y] auto) &(mer ?=(~ auto)))
abet
abet:abet:(merg /main syd):(sync [syd her sud])
:: ::
++ poke-syncs :: print sync config ++ poke-syncs :: print sync config
|= ~ |= ~
@ -813,7 +984,7 @@
?: =(0 ~(wyt by zyn)) ?: =(0 ~(wyt by zyn))
[%leaf "no syncs configured"]~ [%leaf "no syncs configured"]~
%+ turn ~(tap by zyn) %+ turn ~(tap by zyn)
|= [kiln-sync sync-state] |= [sync-record sync-state]
(render "sync configured" sud her syd kid) (render "sync configured" sud her syd kid)
:: ::
++ poke-uninstall ++ poke-uninstall
@ -841,9 +1012,10 @@
:: Don't need to cancel anything because new syncs will get a new nonce :: Don't need to cancel anything because new syncs will get a new nonce
:: ::
++ poke-unsync ++ poke-unsync
|= hus=kiln-unsync |= hus=sync-record
?~ got=(~(get by zyn) hus) ?~ got=(~(get by zyn) hus)
abet:(spam (render "not syncing" [sud her syd ~]:hus) ~) abet:(spam (render "not syncing" [sud her syd ~]:hus) ~)
=. ..abet abet:drop:(sync hus)
=. zyn (~(del by zyn) hus) =. zyn (~(del by zyn) hus)
abet:(spam (render "cancelling sync" sud.hus her.hus syd.hus kid.u.got) ~) abet:(spam (render "cancelling sync" sud.hus her.hus syd.hus kid.u.got) ~)
:: +peer: handle %watch :: +peer: handle %watch
@ -851,10 +1023,26 @@
++ peer ++ peer
|= =path |= =path
?> (team:title our src) ?> (team:title our src)
?: =(0 1) abet :: avoid mint-vain
?+ path ~|(kiln-path/path !!) ?+ path ~|(kiln-path/path !!)
[%vats ~] [%vats ~]
(mean leaf+"kiln: old subscription to /kiln/vats failed" ~) (mean leaf+"kiln: old subscription to /kiln/vats failed" ~)
::
[%jumps ~]
abet:(emit %give %fact ~ %kiln-jump !>([%all hop]))
::
[%updates ~]
=< abet
%- emit
:^ %give %fact ~
:- %kiln-sync-update
!> ^- sync-update
:- %pending
%- ~(gas by *(set [sync-record @ud]))
^- (list [sync-record @ud])
%+ murn ~(tap by zyn)
|= [sync-record sync-state]
?~ hav ~
(some [syd her sud] u.hav)
== ==
:: ::
++ take-agent ++ take-agent
@ -864,6 +1052,8 @@
~? ?=(^ p.sign) [%kiln-poke-nack u.p.sign] ~? ?=(^ p.sign) [%kiln-poke-nack u.p.sign]
abet abet
~|([%kiln-bad-take-agent wire -.sign] !!) ~|([%kiln-bad-take-agent wire -.sign] !!)
::
[%change-publisher ~] abet
:: ::
[%fancy *] [%fancy *]
?> ?=(%poke-ack -.sign) ?> ?=(%poke-ack -.sign)
@ -1078,15 +1268,30 @@
abet:abet:(take:(sync syd her sud) t.t.t.wire sign-arvo) abet:abet:(take:(sync syd her sud) t.t.t.wire sign-arvo)
:: ::
++ sync ++ sync
|= kiln-sync |= sync-record
=/ got (~(get by zyn) syd her sud) =/ got (~(get by zyn) syd her sud)
=+ `sync-state`(fall got [(scot %uv nyz) ~ *@ud]) =+ `sync-state`(fall got [(scot %uv nyz) ~ *@ud ~ ~ |])
=? nyz ?=(~ got) +(nyz) =? nyz ?=(~ got) +(nyz)
|% |%
++ abet ..sync(zyn (~(put by zyn) [syd her sud] nun kid let)) ++ abet ..sync(zyn (~(put by zyn) [syd her sud] nun kid let nit hav yea))
++ apex |=(nex=(unit desk) ..abet(kid nex)) ++ apex |=(nex=(unit desk) ..abet(kid nex))
++ emit |=(card:agent:gall ..abet(kiln (^emit +<))) ++ emit |=(card:agent:gall ..abet(kiln (^emit +<)))
++ emil |=((list card:agent:gall) ..abet(kiln (^emil +<))) ++ emil |=((list card:agent:gall) ..abet(kiln (^emil +<)))
++ okay ..abet(yea &)
++ gain
=. hav `(dec let)
=/ upd=sync-update [%new [syd her sud] (dec let)]
(emit %give %fact ~[/update] %kiln-sync-update !>(upd))
++ drop
=? ..abet ?=(^ hav)
=/ upd=sync-update [%drop [syd her sud] u.hav]
(emit %give %fact ~[/updates] %kiln-sync-update !>(upd))
..abet(hav ~, yea |)
++ tada
=? ..abet ?=(^ hav)
=/ upd=sync-update [%done [syd her sud] u.hav]
(emit %give %fact ~[/updates] %kiln-sync-update !>(upd))
..abet(hav ~, yea |)
++ here "{<syd>} from {<her>}/{<sud>}" ++ here "{<syd>} from {<her>}/{<sud>}"
++ ware ++ ware
|= =wire |= =wire
@ -1101,7 +1306,6 @@
%merg desk her sud %merg desk her sud
ud+(dec let) (get-germ desk) ud+(dec let) (get-germ desk)
== ==
::
:: (re)Start a sync from scratch by finding what version the source :: (re)Start a sync from scratch by finding what version the source
:: desk is at :: desk is at
:: ::
@ -1129,8 +1333,8 @@
?> ?=(^ riot) ?> ?=(^ riot)
:: The syncs may have changed, so get the latest :: The syncs may have changed, so get the latest
:: ::
;< zyx=(map kiln-sync sync-state) bind:m ;< zyx=(map sync-record sync-state) bind:m
(scry:strandio (map kiln-sync sync-state) /gx/hood/kiln/syncs/noun) (scry:strandio (map sync-record sync-state) /gx/hood/kiln/syncs/noun)
?. (~(has by zyx) syd her sud) ?. (~(has by zyx) syd her sud)
(pure:m !>(%done)) (pure:m !>(%done))
~> %slog.(fmt "downloading update for {here}") ~> %slog.(fmt "downloading update for {here}")
@ -1175,6 +1379,7 @@
?: ?=(%| -.p.sign-arvo) ?: ?=(%| -.p.sign-arvo)
:: ~> %slog.(fmt "download failed into {here}; retrying sync") :: ~> %slog.(fmt "download failed into {here}; retrying sync")
:: %- (slog p.p.sign-arvo) :: %- (slog p.p.sign-arvo)
=. ..abet drop
init init
:: ::
~> %slog.(fmt "finished downloading update for {here}") ~> %slog.(fmt "finished downloading update for {here}")
@ -1182,7 +1387,7 @@
:: If nothing changed, just ensure %kids is up-to-date and advance :: If nothing changed, just ensure %kids is up-to-date and advance
:: ::
?. (get-remote-diff our syd now [her sud (dec let)]) ?. (get-remote-diff our syd now [her sud (dec let)])
=< next =< next:drop
?~ kid ?~ kid
~> %slog.(fmt "remote is identical to {here}, skipping") ~> %slog.(fmt "remote is identical to {here}, skipping")
..abet ..abet
@ -1191,15 +1396,22 @@
..abet ..abet
~> %slog.(fmt "remote is identical to {here}, merging into {<u.kid>}") ~> %slog.(fmt "remote is identical to {here}, merging into {<u.kid>}")
(merg /kids u.kid) (merg /kids u.kid)
:: wait for approval if can't automerge & signal available update
::
?. |(=(our her) yea =([~ &] nit) &(=(~ nit) mer))
=. ..abet gain
next
:: Else start merging, but also immediately start listening to :: Else start merging, but also immediately start listening to
:: the next revision. Now, all errors should no-op -- we're :: the next revision. Now, all errors should no-op -- we're
:: already waiting for the next revision. :: already waiting for the next revision.
:: ::
=. yea |
=. ..abet (merg /main syd) =. ..abet (merg /main syd)
next next
:: ::
%main %main
?> ?=(%mere +<.sign-arvo) ?> ?=(%mere +<.sign-arvo)
=< tada
?: ?=(%| -.p.sign-arvo) ?: ?=(%| -.p.sign-arvo)
=+ "kiln: merge into {here} failed, waiting for next revision" =+ "kiln: merge into {here} failed, waiting for next revision"
%- (slog leaf/- p.p.sign-arvo) %- (slog leaf/- p.p.sign-arvo)

View File

@ -213,7 +213,7 @@
=< q =< q
%- need %- need %- need %- need
%- scry:(ames-gate now eny roof) %- scry:(ames-gate now eny roof)
[~ / %x [[our %$ da+now] /peers/(scot %p her)]] [[~ ~] / %x [[our %$ da+now] /peers/(scot %p her)]]
:: ::
++ gall-scry-nonce ++ gall-scry-nonce
|= $: =gall-gate |= $: =gall-gate
@ -227,7 +227,7 @@
=< q =< q
%- need %- need %- need %- need
%- scry:(gall-gate now eny roof) %- scry:(gall-gate now eny roof)
[~ / %n [[our dude da+now] [%$ (scot %p ship.sub) [term wire]:sub]]] [[~ ~] / %n [[our dude da+now] [%$ (scot %p ship.sub) [term wire]:sub]]]
:: ::
++ load-agent ++ load-agent
|= [=ship =gall-gate =dude:gall =agent:gall] |= [=ship =gall-gate =dude:gall =agent:gall]

1
pkg/arvo/lib/verb Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/verb

View File

@ -0,0 +1 @@
../../../base-dev/mar/kiln/approve-merge.hoon

View File

@ -0,0 +1 @@
../../../base-dev/mar/kiln/jump-ask.hoon

View File

@ -0,0 +1 @@
../../../base-dev/mar/kiln/jump-opt.hoon

1
pkg/arvo/mar/kiln/jump.hoon Symbolic link
View File

@ -0,0 +1 @@
../../../base-dev/mar/kiln/jump.hoon

View File

@ -0,0 +1 @@
../../../base-dev/mar/kiln/sync-update.hoon

1
pkg/arvo/mar/verb Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/verb

View File

@ -1 +1 @@
[%zuse 412] [%zuse 411]

View File

@ -352,7 +352,9 @@
?~ dat=(rof lyc pov u.mon) ~ ?~ dat=(rof lyc pov u.mon) ~
?~ u.dat [~ ~] ?~ u.dat [~ ~]
=* vax q.u.u.dat =* vax q.u.u.dat
?. ?& ?=(^ ref) ?. => [ref=ref vax=p=p.vax hoon-version=hoon-version wa=wa worm=worm]
~> %memo./arvo/look :: with memoization
?& ?=(^ ref)
=(hoon-version -.ref) =(hoon-version -.ref)
-:(~(nets wa *worm) +.ref p.vax) -:(~(nets wa *worm) +.ref p.vax)
== ==

View File

@ -2,11 +2,11 @@
:::: /sys/hoon :: :::: /sys/hoon ::
:: :: :: ::
=< ride =< ride
=> %139 => => %138 =>
:: :: :: ::
:::: 0: version stub :: :::: 0: version stub ::
:: :: :: ::
~% %k.139 ~ ~ :: ~% %k.138 ~ ~ ::
|% |%
++ hoon-version + ++ hoon-version +
-- => -- =>
@ -217,6 +217,7 @@
:: computes the axis of {b} within axis {a}. :: computes the axis of {b} within axis {a}.
|= [a=@ b=@] |= [a=@ b=@]
?< =(0 a) ?< =(0 a)
?< =(0 b)
:: a composed axis :: a composed axis
^- @ ^- @
?- b ?- b
@ -1394,23 +1395,19 @@
:: ::
++ bif :: splits a by b ++ bif :: splits a by b
~/ %bif ~/ %bif
|* [b=* c=*] |* b=*
^+ [l=a r=a] |- ^+ [l=a r=a]
=< +
|- ^+ a
?~ a ?~ a
[[b c] ~ ~] [~ ~]
?: =(b p.n.a) ?: =(b p.n.a)
?: =(c q.n.a) +.a
a
a(n [b c])
?: (gor b p.n.a) ?: (gor b p.n.a)
=+ d=$(a l.a) =+ d=$(a l.a)
?> ?=(^ d) ?> ?=(^ d)
d(r a(l r.d)) [l.d a(l r.d)]
=+ d=$(a r.a) =+ d=$(a r.a)
?> ?=(^ d) ?> ?=(^ d)
d(l a(r l.d)) [a(r l.d) r.d]
:: ::
++ del :: delete at key b ++ del :: delete at key b
~/ %del ~/ %del
@ -1435,7 +1432,7 @@
|- ^+ a |- ^+ a
?~ b ?~ b
a a
=+ c=(bif p.n.b q.n.b) =+ c=(bif p.n.b)
?> ?=(^ c) ?> ?=(^ c)
=+ d=$(a l.c, b l.b) =+ d=$(a l.c, b l.b)
=+ e=$(a r.c, b r.b) =+ e=$(a r.c, b r.b)
@ -1592,12 +1589,6 @@
?~ a a ?~ a a
[n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)] [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
:: ::
++ rut :: apply gate to nodes
|* b=gate
|-
?~ a a
[n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)]
::
++ tap :: listify pairs ++ tap :: listify pairs
=< $ =< $
~/ %tap ~/ %tap
@ -1687,6 +1678,19 @@
|* [b=* c=*] |* [b=* c=*]
=+ d=(get b) =+ d=(get b)
(~(put by a) b [c d]) (~(put by a) b [c d])
::
++ zip :: listify jar
=< $
~/ %zip
=+ b=`(list _?>(?=([[* ^] *] a) [p=p q=i.q]:n.a))`~
|. ^+ b
?~ a b
%= $
a r.a
b |- ^+ b
?~ q.n.a ^$(a l.a)
[[p i.q]:n.a $(q.n.a t.q.n.a)]
==
-- --
++ ju :: jug engine ++ ju :: jug engine
=| a=(tree (pair * (tree))) :: (jug) =| a=(tree (pair * (tree))) :: (jug)
@ -1791,6 +1795,12 @@
[b ~ ~] [b ~ ~]
bal(l.a $(a l.a)) bal(l.a $(a l.a))
:: ::
++ run :: apply gate to values
|* b=gate
|-
?~ a a
[n=(b n.a) l=$(a l.a) r=$(a r.a)]
::
++ tap :: adds list to end ++ tap :: adds list to end
=+ b=`(list _?>(?=(^ a) n.a))`~ =+ b=`(list _?>(?=(^ a) n.a))`~
|- ^+ b |- ^+ b
@ -1877,17 +1887,17 @@
++ corl :: compose backwards ++ corl :: compose backwards
|* [a=$-(* *) b=$-(* *)] |* [a=$-(* *) b=$-(* *)]
=< +:|.((a (b))) :: type check =< +:|.((a (b))) :: type check
|* c=_+<.b |* c=_,.+<.b
(a (b c)) (a (b c))
:: ::
++ cury :: curry left ++ cury :: curry left
|* [a=$-(^ *) b=*] |* [a=$-(^ *) b=*]
|* c=_+<+.a |* c=_,.+<+.a
(a b c) (a b c)
:: ::
++ curr :: curry right ++ curr :: curry right
|* [a=$-(^ *) c=*] |* [a=$-(^ *) c=*]
|* b=_+<+.a |* b=_,.+<-.a
(a b c) (a b c)
:: ::
++ fore |*(a=$-(* *) |*(b=$-(* *) (pair a b))) :: pair before ++ fore |*(a=$-(* *) |*(b=$-(* *) (pair a b))) :: pair before
@ -2043,6 +2053,7 @@
+$ tang (list tank) :: bottom-first error +$ tang (list tank) :: bottom-first error
:: :: :: ::
+$ iota :: typed path segment +$ iota :: typed path segment
$+ iota
$~ [%n ~] $~ [%n ~]
$@ @tas $@ @tas
$% [%ub @ub] [%uc @uc] [%ud @ud] [%ui @ui] $% [%ub @ub] [%uc @uc] [%ud @ud] [%ui @ui]
@ -2067,6 +2078,7 @@
:: flat-mid, open, close :: flat-mid, open, close
:: ::
+$ tank +$ tank
$+ tank
$~ leaf/~ $~ leaf/~
$@ cord $@ cord
$% [%leaf p=tape] $% [%leaf p=tape]
@ -3252,7 +3264,8 @@
++ shas :: salted hash ++ shas :: salted hash
~/ %shas ~/ %shas
|= [sal=@ ruz=@] |= [sal=@ ruz=@]
(shax (mix sal (shax ruz))) =/ len (max 32 (met 3 sal))
(shay len (mix sal (shax ruz)))
:: ::
++ shax :: sha-256 ++ shax :: sha-256
~/ %shax ~/ %shax
@ -6381,6 +6394,7 @@
== ==
-- :: -- ::
+$ hoon :: hoon AST +$ hoon :: hoon AST
$+ hoon
$~ [%zpzp ~] :: $~ [%zpzp ~] ::
$^ [p=hoon q=hoon] :: $^ [p=hoon q=hoon] ::
$% :: $% ::
@ -6534,7 +6548,8 @@
[%know p=stud] :: global standard [%know p=stud] :: global standard
[%made p=term q=(unit (list wing))] :: structure [%made p=term q=(unit (list wing))] :: structure
== :: == ::
+$ type $~ %noun :: +$ type $+ type
$~ %noun ::
$@ $? %noun :: any nouns $@ $? %noun :: any nouns
%void :: no noun %void :: no noun
== :: == ::
@ -7144,7 +7159,10 @@
:: 5a: compiler utilities :: 5a: compiler utilities
+| %compiler-utilities +| %compiler-utilities
:: ::
++ bool `type`(fork [%atom %f `0] [%atom %f `1] ~) :: make loobean ++ bool :: make loobean
^- type
(fork [%atom %f `%.y] [%atom %f `%.n] ~)
::
++ cell :: make %cell type ++ cell :: make %cell type
~/ %cell ~/ %cell
|= [hed=type tal=type] |= [hed=type tal=type]
@ -7216,11 +7234,10 @@
~/ %cond ~/ %cond
|= [pex=nock yom=nock woq=nock] |= [pex=nock yom=nock woq=nock]
^- nock ^- nock
?- pex ?: =([%1 &] pex) yom
[%1 %0] yom ?: =([%1 |] pex) woq
[%1 %1] woq ?: =([%0 0] pex) pex
* [%6 pex yom woq] [%6 pex yom woq]
==
:: ::
++ cons :: make formula cell ++ cons :: make formula cell
~/ %cons ~/ %cons
@ -7253,10 +7270,10 @@
=(0 p.wux) =(0 p.wux)
&(!=(0 p.wux) (lte p.wux p.yoz)) &(!=(0 p.wux) (lte p.wux p.yoz))
== ==
|- ?| =(%$ p.yoz) |- ?| =(%$ q.yoz)
=(%$ p.wux) =(%$ q.wux)
?& =((end 3 p.yoz) (end 3 p.wux)) ?& =((end 3 q.yoz) (end 3 q.wux))
$(p.yoz (rsh 3 p.yoz), p.wux (rsh 3 p.wux)) $(q.yoz (rsh 3 q.yoz), q.wux (rsh 3 q.wux))
== ==
== ==
== ==
@ -7265,43 +7282,44 @@
~/ %flan ~/ %flan
|= [bos=nock nif=nock] |= [bos=nock nif=nock]
^- nock ^- nock
?: =(bos nif) bos ?: ?| =(bos nif)
?: =([%0 0] bos) nif =([%1 |] bos)
?: =([%0 0] nif) bos =([%1 &] nif)
?- bos =([%0 0] bos)
[%1 %1] bos ==
[%1 %0] nif bos
* ?: ?| =([%1 &] bos)
?- nif =([%1 |] nif)
[%1 %1] nif =([%0 0] nif)
[%1 %0] bos ==
* [%6 bos nif [%1 1]] nif
== [%6 bos nif [%1 |]]
==
:: ::
++ flip :: loobean negation ++ flip :: loobean negation
~/ %flip ~/ %flip
|= dyr=nock |= dyr=nock
^- nock
?: =([%1 &] dyr) [%1 |]
?: =([%1 |] dyr) [%1 &]
?: =([%0 0] dyr) dyr ?: =([%0 0] dyr) dyr
[%6 dyr [%1 1] [%1 0]] [%6 dyr [%1 |] %1 &]
:: ::
++ flor :: loobean | ++ flor :: loobean |
~/ %flor ~/ %flor
|= [bos=nock nif=nock] |= [bos=nock nif=nock]
^- nock ^- nock
?: =(bos nif) bos ?: ?| =(bos nif)
?: =([%0 0] bos) nif =([%1 &] bos)
?: =([%0 0] nif) bos =([%1 |] nif)
?- bos =([%0 0] bos)
[%1 %1] nif ==
[%1 %0] bos bos
* ?: ?| =([%1 |] bos)
?- nif =([%1 &] nif)
[%1 %1] bos =([%0 0] nif)
[%1 %0] nif ==
* [%6 bos [%1 0] nif] nif
== [%6 bos [%1 &] nif]
==
:: ::
++ hike ++ hike
~/ %hike ~/ %hike
@ -8302,9 +8320,6 @@
:: ::
[%limb @] [%limb @]
`p.gen `p.gen
::
:: [%rock *]
:: [%spec %leaf q.gen q.gen]
:: ::
[%note [%help *] *] [%note [%help *] *]
(bind $(gen q.gen) |=(=skin [%help p.p.gen skin])) (bind $(gen q.gen) |=(=skin [%help p.p.gen skin]))
@ -8779,7 +8794,7 @@
++ fish ++ fish
|= =axis |= =axis
^- nock ^- nock
?@ skin [%1 &] ?@ skin $(skin spec+[[%like [skin]~ ~] [%base %noun]])
?- -.skin ?- -.skin
:: ::
%base %base
@ -8809,8 +8824,8 @@
[%1 &] [%1 &]
[%3 %0 axis] [%3 %0 axis]
%+ flan %+ flan
$(ref (peek(sut ref) %free 2), skin skin.skin) $(ref (peek(sut ref) %free 2), axis (peg axis 2), skin skin.skin)
$(ref (peek(sut ref) %free 3), skin ^skin.skin) $(ref (peek(sut ref) %free 3), axis (peg axis 3), skin ^skin.skin)
:: ::
%leaf %leaf
?: (~(nest ut [%atom %$ `atom.skin]) | ref) ?: (~(nest ut [%atom %$ `atom.skin]) | ref)
@ -8820,16 +8835,21 @@
%dbug $(skin skin.skin) %dbug $(skin skin.skin)
%help $(skin skin.skin) %help $(skin skin.skin)
%name $(skin skin.skin) %name $(skin skin.skin)
%over $(skin skin.skin) %over ::NOTE might need to guard with +feel, crashing is too strict
%spec $(skin skin.skin) =+ ~| %oops-guess-you-needed-feel-after-all
%wash [%1 1] fid=(fend %read wing.skin)
$(sut p.fid, axis (peg axis q.fid), skin skin.skin)
%spec =/ hit (~(play ut sut) ~(example ax spec.skin))
?> (~(nest ut hit) & ref)
$(skin skin.skin)
%wash [%1 &]
== ==
:: ::
:: +gain: make a $type by restricting .ref to .skin :: +gain: make a $type by restricting .ref to .skin
:: ::
++ gain ++ gain
|- ^- type |- ^- type
?@ skin [%face skin ref] ?@ skin $(skin spec+[[%like [skin]~ ~] [%base %noun]])
?- -.skin ?- -.skin
:: ::
%base %base
@ -8852,7 +8872,7 @@
q.ref q.ref
[%cell *] %void [%cell *] %void
[%core *] %void [%core *] %void
[%face *] (face p.ref $(ref q.ref)) [%face *] $(ref q.ref)
[%fork *] (fork (turn ~(tap in p.ref) |=(=type ^$(ref type)))) [%fork *] (fork (turn ~(tap in p.ref) |=(=type ^$(ref type))))
[%hint *] (hint p.ref $(ref q.ref)) [%hint *] (hint p.ref $(ref q.ref))
[%hold *] ?: (~(has in gil) ref) %void [%hold *] ?: (~(has in gil) ref) %void
@ -8865,7 +8885,9 @@
|- ^- type |- ^- type
?- ref ?- ref
%void %void %void %void
%noun [%cell %noun %noun] %noun =+ ^$(skin skin.skin)
?: =(%void -) %void
(cell - ^$(skin ^skin.skin))
[%atom *] %void [%atom *] %void
[%cell *] =+ ^$(skin skin.skin, ref p.ref) [%cell *] =+ ^$(skin skin.skin, ref p.ref)
?: =(%void -) %void ?: =(%void -) %void
@ -8875,7 +8897,7 @@
?. =(%noun ^skin.skin) ?. =(%noun ^skin.skin)
(cell - ^$(skin ^skin.skin, ref %noun)) (cell - ^$(skin ^skin.skin, ref %noun))
[%core - q.ref] [%core - q.ref]
[%face *] (face p.ref $(ref q.ref)) [%face *] $(ref q.ref)
[%fork *] (fork (turn ~(tap in p.ref) |=(=type ^$(ref type)))) [%fork *] (fork (turn ~(tap in p.ref) |=(=type ^$(ref type))))
[%hint *] (hint p.ref $(ref q.ref)) [%hint *] (hint p.ref $(ref q.ref))
[%hold *] ?: (~(has in gil) ref) %void [%hold *] ?: (~(has in gil) ref) %void
@ -8897,7 +8919,7 @@
`atom.skin `atom.skin
[%cell *] %void [%cell *] %void
[%core *] %void [%core *] %void
[%face *] (face p.ref $(ref q.ref)) [%face *] $(ref q.ref)
[%fork *] (fork (turn ~(tap in p.ref) |=(=type ^$(ref type)))) [%fork *] (fork (turn ~(tap in p.ref) |=(=type ^$(ref type))))
[%hint *] (hint p.ref $(ref q.ref)) [%hint *] (hint p.ref $(ref q.ref))
[%hold *] ?: (~(has in gil) ref) %void [%hold *] ?: (~(has in gil) ref) %void
@ -8908,10 +8930,9 @@
%help (hint [sut %help help.skin] $(skin skin.skin)) %help (hint [sut %help help.skin] $(skin skin.skin))
%name (face term.skin $(skin skin.skin)) %name (face term.skin $(skin skin.skin))
%over $(skin skin.skin, sut (~(play ut sut) %wing wing.skin)) %over $(skin skin.skin, sut (~(play ut sut) %wing wing.skin))
%spec =/ yon $(skin skin.skin) %spec =/ hit (~(play ut sut) ~(example ax spec.skin))
=/ hit (~(play ut sut) ~(example ax spec.skin)) ?> (~(nest ut hit) & $(skin skin.skin))
?> (~(nest ut hit) & yon) (~(fuse ut ref) hit)
hit
%wash =- $(ref (~(play ut ref) -)) %wash =- $(ref (~(play ut ref) -))
:- %wing :- %wing
|- ^- wing |- ^- wing
@ -8923,13 +8944,13 @@
:: ::
++ lose ++ lose
|- ^- type |- ^- type
?@ skin [%face skin ref] ?@ skin $(skin spec+[[%like [skin]~ ~] [%base %noun]])
?- -.skin ?- -.skin
:: ::
%base %base
?- base.skin ?- base.skin
%cell $(skin [%cell [%base %noun] [%base %noun]]) %cell $(skin [%cell [%base %noun] [%base %noun]])
%flag $(skin [%base %atom %f]) %flag $(ref $(skin [%leaf %f &]), skin [%leaf %f |])
%null $(skin [%leaf %n ~]) %null $(skin [%leaf %n ~])
%void ref %void ref
%noun %void %noun %void
@ -8955,17 +8976,19 @@
|- ^- type |- ^- type
?- ref ?- ref
%void %void %void %void
%noun [%atom %$ ~] %noun ?. =([%cell [%base %noun] [%base %noun]] skin)
ref
[%atom %$ ~]
[%atom *] ref [%atom *] ref
[%cell *] =+ ^$(skin skin.skin, ref p.ref) [%cell *] =/ lef ^$(skin skin.skin, ref p.ref)
?: =(%void -) %void =/ rig ^$(skin ^skin.skin, ref q.ref)
(cell - ^$(skin ^skin.skin, ref q.ref)) (fork (cell lef rig) (cell lef q.ref) (cell p.ref rig) ~)
[%core *] =+ ^$(skin skin.skin, ref p.ref) [%core *] =+ ^$(skin skin.skin, ref p.ref)
?: =(%void -) %void ?: =(%void -) %void
?. =(%noun ^skin.skin) ?. =(%noun ^skin.skin)
(cell - ^$(skin ^skin.skin, ref %noun)) (cell - ^$(skin ^skin.skin, ref %noun))
[%core - q.ref] [%core - q.ref]
[%face *] (face p.ref $(ref q.ref)) [%face *] $(ref q.ref)
[%fork *] (fork (turn ~(tap in p.ref) |=(=type ^$(ref type)))) [%fork *] (fork (turn ~(tap in p.ref) |=(=type ^$(ref type))))
[%hint *] (hint p.ref $(ref q.ref)) [%hint *] (hint p.ref $(ref q.ref))
[%hold *] ?: (~(has in gil) ref) %void [%hold *] ?: (~(has in gil) ref) %void
@ -8993,8 +9016,11 @@
%dbug $(skin skin.skin) %dbug $(skin skin.skin)
%help $(skin skin.skin) %help $(skin skin.skin)
%name $(skin skin.skin) %name $(skin skin.skin)
%over $(skin skin.skin) %over ::TODO if we guard in +fish (+feel), we have to guard again here
%spec $(skin skin.skin) $(skin skin.skin, sut (~(play ut sut) %wing wing.skin))
%spec =/ hit (~(play ut sut) ~(example ax spec.skin))
?> (~(nest ut hit) & $(skin skin.skin))
(~(crop ut ref) hit)
%wash ref %wash ref
== ==
-- --
@ -9238,21 +9264,21 @@
:: ::
++ mint ++ mint
|= gol=type |= gol=type
=- ?>(?|(!vet (nest(sut gol) & p.-)) -)
^- (pair type nock) ^- (pair type nock)
=+ lug=(find %read hyp) =+ lug=(find %read hyp)
?: ?=(%| -.lug) ~>(%mean.'hoon' ?>(?=(~ rig) p.lug)) ?: ?=(%| -.lug) ~>(%mean.'hoon' ?>(?=(~ rig) p.lug))
=- ?>(?|(!vet (nest(sut gol) & p.-)) -)
(ergo p.lug rig) (ergo p.lug rig)
:: ::
++ mull ++ mull
|= [gol=type dox=type] |= [gol=type dox=type]
^- [type type] =- ?>(?|(!vet (nest(sut gol) & p.-)) -)
^- (pair type type)
=+ lug=[p=(find %read hyp) q=(find(sut dox) %read hyp)] =+ lug=[p=(find %read hyp) q=(find(sut dox) %read hyp)]
?: ?=(%| -.p.lug) ?: ?=(%| -.p.lug)
?> &(?=(%| -.q.lug) ?=(~ rig)) ?> &(?=(%| -.q.lug) ?=(~ rig))
[p.p.p.lug p.p.q.lug] [p.p.p.lug p.p.q.lug]
?> ?=(%& -.q.lug) ?> ?=(%& -.q.lug)
=- ?>(?|(!vet (nest(sut gol) & p.-)) -)
(endo [p.p.lug p.q.lug] dox rig) (endo [p.p.lug p.q.lug] dox rig)
-- --
:: ::
@ -9472,6 +9498,14 @@
== == == ==
(fond way hyp) (fond way hyp)
:: ::
++ fend
|= [way=vial hyp=wing]
^- (pair type axis)
=+ fid=(find way hyp)
~> %mean.'fend-fragment'
?> &(?=(%& -.fid) ?=(%& -.q.p.fid))
[p.q.p.fid (tend p.p.fid)]
::
++ fund ++ fund
~/ %fund ~/ %fund
|= [way=vial gen=hoon] |= [way=vial gen=hoon]
@ -9690,14 +9724,13 @@
?: ?=([%wtts *] gen) ?: ?=([%wtts *] gen)
(cool how q.gen (play ~(example ax p.gen))) (cool how q.gen (play ~(example ax p.gen)))
?: ?=([%wthx *] gen) ?: ?=([%wthx *] gen)
=+ (play %wing q.gen) =+ fid=(find %both q.gen)
~> %slog.[0 [%leaf "chipping"]] ?- -.fid
?: how %| sut
=- ~> %slog.[0 (dunk(sut +<) 'chip: gain: ref')] %& =< q
~> %slog.[0 (dunk(sut -) 'chip: gain: gain')] %+ take p.p.fid
- |=(a=type ?:(how ~(gain ar a p.gen) ~(lose ar a p.gen)))
~(gain ar - p.gen) ==
~(lose ar - p.gen)
?: ?&(how ?=([%wtpm *] gen)) ?: ?&(how ?=([%wtpm *] gen))
|-(?~(p.gen sut $(p.gen t.p.gen, sut ^$(gen i.p.gen)))) |-(?~(p.gen sut $(p.gen t.p.gen, sut ^$(gen i.p.gen))))
?: ?&(!how ?=([%wtbr *] gen)) ?: ?&(!how ?=([%wtbr *] gen))
@ -9971,22 +10004,27 @@
:: ::
[%wtcl *] [%wtcl *]
=+ nor=$(gen p.gen, gol bool) =+ nor=$(gen p.gen, gol bool)
=+ fex=(gain p.gen) =+ [fex=(gain p.gen) wux=(lose p.gen)]
=+ wux=(lose p.gen) ::
=+ ^= duy :: if either branch is impossible, eliminate it
?: =(%void fex) :: (placing the conditional in a dynamic hint to preserve crashes)
?:(=(%void wux) [%0 0] [%1 1]) ::
?:(=(%void wux) [%1 0] q.nor) =+ ^= [ned duy]
?- -
[%void %void] |+[%0 0]
[%void *] &+[%1 |]
[* %void] &+[%1 &]
* |+q.nor
==
=+ hiq=$(sut fex, gen q.gen) =+ hiq=$(sut fex, gen q.gen)
=+ ran=$(sut wux, gen r.gen) =+ ran=$(sut wux, gen r.gen)
[(fork p.hiq p.ran ~) (cond duy q.hiq q.ran)] =+ fol=(cond duy q.hiq q.ran)
[(fork p.hiq p.ran ~) ?.(ned fol [%11 [%toss q.nor] fol])]
:: ::
[%wthx *] [%wthx *]
:- (nice bool) :- (nice bool)
=+ fid=(find %read [[%& 1] q.gen]) =+ fid=(fend %read [[%& 1] q.gen])
~> %mean.'mint-fragment' (~(fish ar `type`p.fid `skin`p.gen) q.fid)
?> &(?=(%& -.fid) ?=(%& -.q.p.fid))
(~(fish ar `type`p.q.p.fid `skin`p.gen) (tend p.p.fid))
:: ::
[%fits *] [%fits *]
:- (nice bool) :- (nice bool)
@ -10173,12 +10211,8 @@
:: ::
[%wthx *] [%wthx *]
~> %mean.'mull-bonk-x' ~> %mean.'mull-bonk-x'
=+ :- =+ (find %read [[%& 1] q.gen]) =+ :- new=[type=p axis=q]:(fend %read [[%& 1] q.gen])
?> &(?=(%& -.-) ?=(%& -.q.p.-)) old=[type=p axis=q]:(fend(sut dox) %read [[%& 1] q.gen])
new=[type=p.q.p.- axis=(tend p.p.-)]
=+ (find(sut dox) %read [%& 1] q.gen)
?> &(?=(%& -.-) ?=(%& -.q.p.-))
old=[type=p.q.p.- axis=(tend p.p.-)]
?> =(axis.old axis.new) ?> =(axis.old axis.new)
?> (nest(sut type.old) & type.new) ?> (nest(sut type.old) & type.new)
(beth bool) (beth bool)
@ -13107,6 +13141,12 @@
|= [%cnhp a=hoon b=spec] |= [%cnhp a=hoon b=spec]
[%make a b ~] [%make a b ~]
(rune hep %cnhp exqd) (rune hep %cnhp exqd)
::
:- '.'
%+ cook
|= [%cndt a=spec b=hoon]
[%make b a ~]
(rune dot %cndt exqc)
:: ::
:- ':' :- ':'
%+ cook %+ cook

View File

@ -765,13 +765,12 @@
:: ::
:: %hear: packet from unix :: %hear: packet from unix
:: %dear: lane from unix :: %dear: lane from unix
:: %heed: track peer's responsiveness; gives %clog if slow
:: %jilt: stop tracking peer's responsiveness
:: %cork: request to delete message flow :: %cork: request to delete message flow
:: %tame: request to delete route for ship :: %tame: request to delete route for ship
:: %kroc: request to delete specific message flows, from their bones :: %kroc: request to delete specific message flows, from their bones
:: %plea: request to send message :: %plea: request to send message
:: %deep: deferred calls to %ames, from itself :: %deep: deferred calls to %ames, from itself
:: %stun: STUN response (or failure), from unix
:: ::
:: Remote Scry Tasks :: Remote Scry Tasks
:: ::
@ -796,17 +795,18 @@
$+ ames-task $+ ames-task
$% [%hear =lane =blob] $% [%hear =lane =blob]
[%dear =ship =lane] [%dear =ship =lane]
[%heed =ship]
[%jilt =ship]
[%cork =ship] [%cork =ship]
[%tame =ship] [%tame =ship]
[%kroc bones=(list [ship bone])] [%kroc bones=(list [ship bone])]
$>(%plea vane-task) $>(%plea vane-task)
[%deep =deep] [%deep =deep]
[%stun =stun]
:: ::
[%keen spar] [%keen sec=(unit [idx=@ key=@]) spar]
[%chum spar]
[%yawn spar] [%yawn spar]
[%wham spar] [%wham spar]
[%plug =path]
:: ::
$>(%born vane-task) $>(%born vane-task)
$>(%init vane-task) $>(%init vane-task)
@ -824,10 +824,12 @@
:: Messaging Gifts :: Messaging Gifts
:: ::
:: %boon: response message from remote ship :: %boon: response message from remote ship
:: %noon: boon with duct for clog tracking
:: %clog: notify vane that %boon's to peer are backing up locally :: %clog: notify vane that %boon's to peer are backing up locally
:: %done: notify vane that peer (n)acked our message :: %done: notify vane that peer (n)acked our message
:: %lost: notify vane that we crashed on %boon :: %lost: notify vane that we crashed on %boon
:: %send: packet to unix :: %send: packet to unix
:: %nail: lanes to unix
:: ::
:: Remote Scry Gifts :: Remote Scry Gifts
:: ::
@ -836,17 +838,22 @@
:: System and Lifecycle Gifts :: System and Lifecycle Gifts
:: ::
:: %turf: domain report, relayed from jael :: %turf: domain report, relayed from jael
:: %saxo: our sponsor list report
:: ::
+$ gift +$ gift
$% [%boon payload=*] $% [%boon payload=*]
[%clog =ship] [%noon id=* payload=*]
[%done error=(unit error)] [%done error=(unit error)]
[%lost ~] [%lost ~]
[%send =lane =blob] [%send =lane =blob]
[%nail =ship lanes=(list lane)]
:: ::
[%stub num=@ud key=@]
[%near spar dat=(unit (unit page))]
[%tune spar roar=(unit roar)] [%tune spar roar=(unit roar)]
:: ::
[%turf turfs=(list turf)] [%turf turfs=(list turf)]
[%saxo sponsors=(list ship)]
== ==
:: ::
:::: :: (1a2) :::: :: (1a2)
@ -884,7 +891,7 @@
+$ address @uxaddress +$ address @uxaddress
:: $verb: verbosity flag for ames :: $verb: verbosity flag for ames
:: ::
+$ verb ?(%snd %rcv %odd %msg %ges %for %rot %kay %fin) +$ verb ?(%snd %rcv %odd %msg %ges %for %rot %kay %fin %sun)
:: $blob: raw atom to or from unix, representing a packet :: $blob: raw atom to or from unix, representing a packet
:: ::
+$ blob @uxblob +$ blob @uxblob
@ -904,6 +911,12 @@
:: payload: semantic message contents :: payload: semantic message contents
:: ::
+$ plea [vane=@tas =path payload=*] +$ plea [vane=@tas =path payload=*]
::
+$ message
$% [%plea plea]
[%boon payload=*]
[%naxplanation =message-num =error]
==
:: $spar: pair of $ship and $path :: $spar: pair of $ship and $path
:: ::
:: Instead of fully qualifying a scry path, ames infers rift and :: Instead of fully qualifying a scry path, ames infers rift and
@ -913,12 +926,21 @@
:: $deep: deferred %ames call, from self, to keep +abet cores pure :: $deep: deferred %ames call, from self, to keep +abet cores pure
:: ::
+$ deep +$ deep
$% [%nack =ship =nack=bone =message-blob] $% [%nack =ship =nack=bone =message]
[%sink =ship =target=bone naxplanation=[=message-num =error]] [%sink =ship =target=bone naxplanation=[=message-num =error]]
[%drop =ship =nack=bone =message-num] [%drop =ship =nack=bone =message-num]
[%cork =ship =bone] [%cork =ship =bone]
[%kill =ship =bone] [%kill =ship =bone]
== ==
:: $stun: STUN notifications, from unix
::
:: .lane is the latest cached lane in vere, from the point of view of .ship
::
+$ stun
$% [%stop =ship =lane] :: succesful STUN response, stop %ping app
[%fail =ship =lane] :: failure to STUN, re-enable %ping app
[%once =ship =lane] :: new lane discovered, notify ping %app
==
:: +| %atomics :: +| %atomics
:: ::
+$ bone @udbone +$ bone @udbone
@ -932,10 +954,12 @@
:: $hoot: request packet payload :: $hoot: request packet payload
:: $yowl: serialized response packet payload :: $yowl: serialized response packet payload
:: $hunk: a slice of $yowl fragments :: $hunk: a slice of $yowl fragments
:: $lock: keys for remote scry
:: ::
+$ hoot @uxhoot +$ hoot @uxhoot
+$ yowl @uxyowl +$ yowl @uxyowl
+$ hunk [lop=@ len=@] +$ hunk [lop=@ len=@]
+$ lock [idx=@ key=@]
:: ::
:: +| %kinetics :: +| %kinetics
:: $dyad: pair of sender and receiver ships :: $dyad: pair of sender and receiver ships
@ -985,15 +1009,15 @@
:: ::
:: messages: pleas local vanes have asked us to send :: messages: pleas local vanes have asked us to send
:: packets: packets we've tried to send :: packets: packets we've tried to send
:: heeds: local tracking requests; passed through into $peer-state
:: ::
+$ alien-agenda +$ alien-agenda
$+ alien-agenda $+ alien-agenda
$: messages=(list [=duct =plea]) $: messages=(list [=duct =plea])
packets=(set =blob) packets=(set =blob)
heeds=(set duct)
keens=(jug path duct) keens=(jug path duct)
chums=(jug path duct)
== ==
+$ chain ((mop ,@ ,[key=@ =path]) lte)
:: $peer-state: state for a peer with known life and keys :: $peer-state: state for a peer with known life and keys
:: ::
:: route: transport-layer destination for packets to peer :: route: transport-layer destination for packets to peer
@ -1011,7 +1035,6 @@
:: information completes the packet+nack-trace, we remove the :: information completes the packet+nack-trace, we remove the
:: entry and emit a nack to the local vane that asked us to send :: entry and emit a nack to the local vane that asked us to send
:: the message. :: the message.
:: heeds: listeners for %clog notifications
:: closing: bones closed on the sender side :: closing: bones closed on the sender side
:: corked: bones closed on both sender and receiver :: corked: bones closed on both sender and receiver
:: ::
@ -1029,10 +1052,10 @@
snd=(map bone message-pump-state) snd=(map bone message-pump-state)
rcv=(map bone message-sink-state) rcv=(map bone message-sink-state)
nax=(set [=bone =message-num]) nax=(set [=bone =message-num])
heeds=(set duct)
closing=(set bone) closing=(set bone)
corked=(set bone) corked=(set bone)
keens=(map path keen-state) keens=(map path keen-state)
=chain
== ==
+$ keen-state +$ keen-state
$+ keen-state $+ keen-state
@ -1157,7 +1180,7 @@
$+ message-pump-state $+ message-pump-state
$: current=_`message-num`1 $: current=_`message-num`1
next=_`message-num`1 next=_`message-num`1
unsent-messages=(qeu message-blob) unsent-messages=(qeu message)
unsent-fragments=(list static-fragment) unsent-fragments=(list static-fragment)
queued-message-acks=(map message-num ack) queued-message-acks=(map message-num ack)
=packet-pump-state =packet-pump-state
@ -2703,13 +2726,15 @@
|% |%
+$ gift :: outgoing result +$ gift :: outgoing result
$% [%boon payload=*] :: ames response $% [%boon payload=*] :: ames response
[%noon id=* payload=*]
[%done error=(unit error:ames)] :: ames message (n)ack [%done error=(unit error:ames)] :: ames message (n)ack
[%flub ~] :: not ready to handle plea [%flub ~] :: not ready to handle plea
[%unto p=unto] :: [%unto p=unto] ::
== :: == ::
+$ task :: incoming request +$ task :: incoming request
$~ [%vega ~] :: $~ [%vega ~] ::
$% [%deal p=sack q=term r=deal] :: full transmission $% [%clog id=*] :: clog notification
[%deal p=sack q=term r=deal] :: full transmission
[%sear =ship] :: clear pending queues [%sear =ship] :: clear pending queues
[%jolt =desk =dude] :: (re)start agent [%jolt =desk =dude] :: (re)start agent
[%idle =dude] :: suspend agent [%idle =dude] :: suspend agent
@ -2728,17 +2753,27 @@
+$ boat (map [=wire =ship =term] [acked=? =path]) :: outgoing subs +$ boat (map [=wire =ship =term] [acked=? =path]) :: outgoing subs
+$ boar (map [=wire =ship =term] nonce=@) :: and their nonces +$ boar (map [=wire =ship =term] nonce=@) :: and their nonces
:: ::
+$ path-state +$ fans ((mop @ud (pair @da (each page @uvI))) lte)
+$ plot
$: bob=(unit @ud) $: bob=(unit @ud)
fan=((mop @ud (pair @da (each page @uvI))) lte) fan=fans
== ==
+$ stats :: statistics +$ stats :: statistics
$: change=@ud :: processed move count $: change=@ud :: processed move count
eny=@uvJ :: entropy eny=@uvJ :: entropy
time=@da :: current event time time=@da :: current event time
== ==
+$ hutch [rev=@ud idx=@ud key=@]
::
+$ farm
$+ farm
$~ [%plot ~ ~]
$% [%coop p=hutch q=(map path plot)]
[%plot p=(unit plot) q=(map @ta farm)]
==
::
+$ egg :: migratory agent state +$ egg :: migratory agent state
$% [%nuke sky=(map spur @ud)] :: see /sys/gall $yoke $% [%nuke sky=(map spur @ud) cop=(map coop hutch)] :: see /sys/gall $yoke
$: %live $: %live
control-duct=duct control-duct=duct
run-nonce=@t run-nonce=@t
@ -2751,11 +2786,32 @@
old-state=[%| vase] old-state=[%| vase]
=beak =beak
marks=(map duct mark) marks=(map duct mark)
sky=(map spur path-state) sky=farm
ken=(jug spar:ames wire) ken=(jug spar:ames wire)
pen=(jug spar:ames wire)
gem=(jug coop [path page])
== == == ==
+$ egg-any $%([%15 egg]) +$ egg-any $%([%15 egg-15] [%16 egg])
+$ egg-15
$% [%nuke sky=(map spur @ud)]
$: %live
control-duct=duct
run-nonce=@t
sub-nonce=@
=stats
=bitt
=boat
=boar
code=~
old-state=[%| vase]
=beak
marks=(map duct mark)
sky=(map spur plot)
ken=(jug spar:ames wire)
== ==
::
+$ bowl :: standard app state +$ bowl :: standard app state
$+ gall-agent-bowl ::
$: $: our=ship :: host $: $: our=ship :: host
src=ship :: guest src=ship :: guest
dap=term :: agent dap=term :: agent
@ -2763,9 +2819,7 @@
== :: == ::
$: wex=boat :: outgoing subs $: wex=boat :: outgoing subs
sup=bitt :: incoming subs sup=bitt :: incoming subs
$= sky :: scry bindings sky=(map path fans) :: scry bindings
%+ map path ::
((mop @ud (pair @da (each page @uvI))) lte) ::
== :: == ::
$: act=@ud :: change number $: act=@ud :: change number
eny=@uvJ :: entropy eny=@uvJ :: entropy
@ -2793,6 +2847,7 @@
:: TODO: add more flags? :: TODO: add more flags?
:: ::
+$ verb ?(%odd) +$ verb ?(%odd)
+$ coop spur
:: ::
:: +agent: app core :: +agent: app core
:: ::
@ -2800,8 +2855,11 @@
=< form =< form
|% |%
+$ step (quip card form) +$ step (quip card form)
+$ card (wind note gift) +$ card
$+ gall-agent-card
(wind note gift)
+$ note +$ note
$+ gall-agent-note
$% [%agent [=ship name=term] =task] $% [%agent [=ship name=term] =task]
[%arvo note-arvo] [%arvo note-arvo]
[%pyre =tang] [%pyre =tang]
@ -2809,8 +2867,15 @@
[%grow =spur =page] [%grow =spur =page]
[%tomb =case =spur] [%tomb =case =spur]
[%cull =case =spur] [%cull =case =spur]
::
[%tend =coop =path =page]
[%germ =coop]
[%snip =coop]
::
[%keen secret=? spar:ames]
== ==
+$ task +$ task
$+ gall-agent-task
$% [%watch =path] $% [%watch =path]
[%watch-as =mark =path] [%watch-as =mark =path]
[%leave ~] [%leave ~]
@ -2818,12 +2883,14 @@
[%poke-as =mark =cage] [%poke-as =mark =cage]
== ==
+$ gift +$ gift
$+ gall-agent-gift
$% [%fact paths=(list path) =cage] $% [%fact paths=(list path) =cage]
[%kick paths=(list path) ship=(unit ship)] [%kick paths=(list path) ship=(unit ship)]
[%watch-ack p=(unit tang)] [%watch-ack p=(unit tang)]
[%poke-ack p=(unit tang)] [%poke-ack p=(unit tang)]
== ==
+$ sign +$ sign
$+ gall-agent-sign
$% [%poke-ack p=(unit tang)] $% [%poke-ack p=(unit tang)]
[%watch-ack p=(unit tang)] [%watch-ack p=(unit tang)]
[%fact =cage] [%fact =cage]
@ -3264,14 +3331,19 @@
|% |%
+$ card card:agent:gall +$ card card:agent:gall
+$ input +$ input
$+ input
$% [%poke =cage] $% [%poke =cage]
[%sign =wire =sign-arvo] [%sign =wire =sign-arvo]
[%agent =wire =sign:agent:gall] [%agent =wire =sign:agent:gall]
[%watch =path] [%watch =path]
== ==
+$ strand-input [=bowl in=(unit input)] +$ error (pair term $+(tang tang))
+$ strand-input
$+ strand-input
[=bowl in=(unit input)]
+$ tid @tatid +$ tid @tatid
+$ bowl +$ bowl
$+ strand-bowl
$: our=ship $: our=ship
src=ship src=ship
tid=tid tid=tid
@ -3299,27 +3371,29 @@
:: ::
++ strand-output-raw ++ strand-output-raw
|* a=mold |* a=mold
$+ strand-output-raw
$~ [~ %done *a] $~ [~ %done *a]
$: cards=(list card) $: cards=(list card)
$= next $= next
$% [%wait ~] $% [%wait ~]
[%skip ~] [%skip ~]
[%cont self=(strand-form-raw a)] [%cont self=(strand-form-raw a)]
[%fail err=(pair term tang)] [%fail err=error]
[%done value=a] [%done value=a]
== ==
== ==
:: ::
++ strand-form-raw ++ strand-form-raw
|* a=mold |* a=mold
$+ strand-form-raw
$-(strand-input (strand-output-raw a)) $-(strand-input (strand-output-raw a))
:: ::
:: Abort strand computation with error message :: Abort strand computation with error message
:: ::
++ strand-fail ++ strand-fail
|= err=(pair term tang) |= =error
|= strand-input |= strand-input
[~ %fail err] [~ %fail error]
:: ::
:: Asynchronous transcaction monad. :: Asynchronous transcaction monad.
:: ::
@ -3332,11 +3406,11 @@
++ strand ++ strand
|* a=mold |* a=mold
|% |%
++ output (strand-output-raw a) ++ output $+(output (strand-output-raw a))
:: ::
:: Type of an strand computation. :: Type of an strand computation.
:: ::
++ form (strand-form-raw a) ++ form $+(form (strand-form-raw a))
:: ::
:: Monadic pure. Identity computation for bind. :: Monadic pure. Identity computation for bind.
:: ::

File diff suppressed because it is too large Load Diff

View File

@ -243,11 +243,12 @@
=* lot=coin $/r.bem =* lot=coin $/r.bem
=* tyl s.bem =* tyl s.bem
:: ::
:: only respond for the local identity, %$ desk, current timestamp :: only respond for the local identity, %$ desk, current timestamp, root gang
:: ::
?. ?& =(&+our why) ?. ?& =(&+our why)
=([%$ %da now] lot) =([%$ %da now] lot)
=(%$ syd) =(%$ syd)
=([~ ~] lyc)
== ==
~ ~
:: /bx//whey (list mass) memory usage labels :: /bx//whey (list mass) memory usage labels

View File

@ -729,11 +729,7 @@
:: ::
%- (trace 1 |.("make cast {<a>} -> {<b>}")) %- (trace 1 |.("make cast {<a>} -> {<b>}"))
=^ old=vase nub (build-fit %mar a) =^ old=vase nub (build-fit %mar a)
?: =/ ram (mule |.((slap old !,(*hoon grow)))) ?: (has-arm %grow b old)
?: ?=(%| -.ram) %.n
=/ lab (mule |.((slob b p.p.ram)))
?: ?=(%| -.lab) %.n
p.lab
:: +grow core has .b arm; use that :: +grow core has .b arm; use that
:: ::
%+ gain-leak cast+a^b %+ gain-leak cast+a^b
@ -749,8 +745,9 @@
:: try direct +grab :: try direct +grab
:: ::
=^ new=vase nub (build-fit %mar b) =^ new=vase nub (build-fit %mar b)
=/ arm=? (has-arm %grab a new)
=/ rab (mule |.((slap new tsgl/[limb/a limb/%grab]))) =/ rab (mule |.((slap new tsgl/[limb/a limb/%grab])))
?: &(?=(%& -.rab) ?=(^ q.p.rab)) ?: &(arm ?=(%& -.rab) ?=(^ q.p.rab))
%+ gain-leak cast+a^b %+ gain-leak cast+a^b
|= nob=state |= nob=state
%- (trace 4 |.("{<a>} -> {<b>}: +{(trip a)}:grab:{(trip b)}")) %- (trace 4 |.("{<a>} -> {<b>}: +{(trip a)}:grab:{(trip b)}"))
@ -759,11 +756,11 @@
:: try +jump :: try +jump
:: ::
=/ jum (mule |.((slap old tsgl/[limb/b limb/%jump]))) =/ jum (mule |.((slap old tsgl/[limb/b limb/%jump])))
?: ?=(%& -.jum) ?: &((has-arm %jump a old) ?=(%& -.jum))
=/ via !<(mark p.jum) =/ via !<(mark p.jum)
%- (trace 4 |.("{<a>} -> {<b>}: via {<via>} per +jump:{(trip a)}")) %- (trace 4 |.("{<a>} -> {<b>}: via {<via>} per +jump:{(trip a)}"))
(compose-casts a via b) (compose-casts a via b)
?: ?=(%& -.rab) ?: &(arm ?=(%& -.rab))
=/ via !<(mark p.rab) =/ via !<(mark p.rab)
%- (trace 4 |.("{<a>} -> {<b>}: via {<via>} per +grab:{(trip b)}")) %- (trace 4 |.("{<a>} -> {<b>}: via {<via>} per +grab:{(trip b)}"))
(compose-casts a via b) (compose-casts a via b)
@ -787,6 +784,15 @@
%+ slap %+ slap
(with-faces uno+uno dos+dos ~) (with-faces uno+uno dos+dos ~)
!,(*hoon |=(_+<.uno (dos (uno +<)))) !,(*hoon |=(_+<.uno (dos (uno +<))))
::
++ has-arm
|= [arm=@tas =mark core=vase]
^- ?
=/ rib (mule |.((slap core [%wing ~[arm]])))
?: ?=(%| -.rib) %.n
=/ lab (mule |.((slob mark p.p.rib)))
?: ?=(%| -.lab) %.n
p.lab
:: +build-tube: produce a $tube mark conversion gate from .a to .b :: +build-tube: produce a $tube mark conversion gate from .a to .b
:: ::
++ build-tube ++ build-tube
@ -1518,7 +1524,7 @@
[%c care (scot case) desk path] [%c care (scot case) desk path]
:- [time path] :- [time path]
%- emil %- emil
:~ [hen %pass wire %a %keen ship path] :~ [hen %pass wire %a %keen ~ ship path]
[hen %pass wire %b %wait time] [hen %pass wire %b %wait time]
== ==
:: ::
@ -4642,10 +4648,12 @@
$(desks t.desks) $(desks t.desks)
=^ res den (aver:den ~ %x da+now /desk/bill) =^ res den (aver:den ~ %x da+now /desk/bill)
=. ruf +:abet:den =. ruf +:abet:den
?. ?=([~ ~ *] res) =/ bill
?. ?=([~ ~ *] res) *bill
~|([%building-bill i.desks] !<(bill q.u.u.res))
?~ rid=(override bill ren.dom.den)
%- (trace 2 |.("{<i.desks>} has no dudes"))
$(desks t.desks) $(desks t.desks)
=/ bill ~| [%building-bill i.desks] !<(bill q.u.u.res)
=/ rid (override bill ren.dom.den)
%- %+ trace 2 |. %- %+ trace 2 |.
"{<i.desks>} has bill {<bill>} and rein {<ren.dom.den>}, so {<rid>}" "{<i.desks>} has bill {<bill>} and rein {<ren.dom.den>}, so {<rid>}"
=^ sats ..abet $(desks t.desks) =^ sats ..abet $(desks t.desks)
@ -4668,22 +4676,9 @@
:: +override: apply rein to bill :: +override: apply rein to bill
:: ::
++ override ++ override
|= [duz=bill ren=(map dude:gall ?)] |= [duz=bill ren=(map dude:gall ?)] ^- bill
^- bill =/ out=bill (skip duz ~(has by ren))
=. duz (~(rep by ren) |=([[d=dude:gall r=?] =_out] ?.(r out [d out])))
%+ skip duz
|= =dude:gall
=(`| (~(get by ren) dude))
::
=/ dus (sy duz)
=. duz
%+ weld duz
%+ murn ~(tap by ren)
|= [=dude:gall on=?]
?: &(?=(%& on) !(~(has in dus) dude))
`u=dude
~
duz
:: +apply-precedence: resolve conflicts between $bill's :: +apply-precedence: resolve conflicts between $bill's
:: ::
:: policy is to crash if multiple desks are trying to run the same :: policy is to crash if multiple desks are trying to run the same
@ -5934,6 +5929,7 @@
:: ::
=/ for=(unit ship) ?~(lyc ~ ?~(u.lyc ~ `n.u.lyc)) =/ for=(unit ship) ?~(lyc ~ ?~(u.lyc ~ `n.u.lyc))
?: &(=(our his) ?=(?(%d %x) ren) =(%$ syd) =([%da now] u.luk)) ?: &(=(our his) ?=(?(%d %x) ren) =(%$ syd) =([%da now] u.luk))
?. =([~ ~] lyc) ~
?- ren ?- ren
%d (read-buc-d tyl) %d (read-buc-d tyl)
%x (read-buc-x tyl) %x (read-buc-x tyl)

View File

@ -146,7 +146,7 @@
++ sponsor ++ sponsor
^- ship ^- ship
=/ dat=(unit (unit cage)) =/ dat=(unit (unit cage))
(rof `[our ~ ~] /dill j/[[our sein/da/now] /(scot %p our)]) (rof [~ ~] /dill j/[[our sein/da/now] /(scot %p our)])
;;(ship q.q:(need (need dat))) ;;(ship q.q:(need (need dat)))
:: ::
++ init :: initialize ++ init :: initialize
@ -490,11 +490,12 @@
?. ?=(%& -.why) ~ ?. ?=(%& -.why) ~
=* his p.why =* his p.why
:: ::
:: only respond for the local identity, %$ desk, current timestamp :: only respond for the local identity, %$ desk, current timestamp, root gang
:: ::
?. ?& =(&+our why) ?. ?& =(&+our why)
=([%$ %da now] lot) =([%$ %da now] lot)
=(%$ syd) =(%$ syd)
=([~ ~] lyc)
== ==
~ ~
:: /%x//whey (list mass) memory usage labels :: /%x//whey (list mass) memory usage labels

View File

@ -798,14 +798,15 @@
=* headers header-list.request =* headers header-list.request
:: for requests from localhost, respect the "forwarded" header :: for requests from localhost, respect the "forwarded" header
:: ::
=/ [secure=? =^address] =/ [secure=? host=(unit @t) =^address]
=* same [secure address] =/ host=(unit @t) (get-header:http 'host' headers)
=* same [secure host address]
?. =([%ipv4 .127.0.0.1] address) same ?. =([%ipv4 .127.0.0.1] address) same
?~ forwards=(forwarded-params headers) same ?~ forwards=(forwarded-params headers) same
:- (fall (forwarded-secure u.forwards) secure) :+ (fall (forwarded-secure u.forwards) secure)
(clap (forwarded-host u.forwards) host head)
(fall (forwarded-for u.forwards) address) (fall (forwarded-for u.forwards) address)
:: ::
=/ host (get-header:http 'host' headers)
=/ [=action suburl=@t] =/ [=action suburl=@t]
(get-action-for-binding host url.request) (get-action-for-binding host url.request)
:: ::
@ -898,22 +899,32 @@
=- (fall - '*') =- (fall - '*')
(get-header:http 'access-control-request-headers' headers) (get-header:http 'access-control-request-headers' headers)
== ==
:: handle requests to the cache :: handle HTTP scries
:: ::
=/ entry (~(get by cache.state) url.request) :: TODO: ideally this would look more like:
?: &(?=(^ entry) ?=(%'GET' method.request)) ::
(handle-cache-req authenticated request val.u.entry) :: ?^ p=(parse-http-scry url.request)
:: (handle-http-scry authenticated p request)
::
?: =('/_~_/' (end [3 5] url.request))
(handle-http-scry authenticated request)
:: handle requests to the cache, if a non-empty entry exists
::
=/ cached=(unit [aeon=@ud val=(unit cache-entry)])
(~(get by cache.state) url.request)
?: &(?=([~ @ ^] cached) ?=(%'GET' method.request))
(handle-cache-req authenticated request u.val.u.cached)
:: ::
?- -.action ?- -.action
%gen %gen
=/ bek=beak [our desk.generator.action da+now] =/ bek=beak [our desk.generator.action da+now]
=/ sup=spur path.generator.action =/ sup=spur path.generator.action
=/ ski (rof ~ /eyre %ca bek sup) =/ ski (rof [~ ~] /eyre %ca bek sup)
=/ cag=cage (need (need ski)) =/ cag=cage (need (need ski))
?> =(%vase p.cag) ?> =(%vase p.cag)
=/ gat=vase !<(vase q.cag) =/ gat=vase !<(vase q.cag)
=/ res=toon =/ res=toon
%- mock :_ (look rof ~ /eyre) %- mock :_ (look rof [~ ~] /eyre)
:_ [%9 2 %0 1] |. :_ [%9 2 %0 1] |.
%+ slam %+ slam
%+ slam gat %+ slam gat
@ -1003,16 +1014,52 @@
=/ nom=@p =/ nom=@p
?+(-.identity who.identity %ours our) ?+(-.identity who.identity %ours our)
(as-octs:mimes:html (scot %p nom)) (as-octs:mimes:html (scot %p nom))
:: +handle-http-scry: respond with scry result
::
++ handle-http-scry
|= [authenticated=? =request:http]
|^ ^- (quip move server-state)
?. authenticated (error-response 403 ~)
?. =(%'GET' method.request)
(error-response 405 "may only GET scries")
=/ req (parse-request-line url.request)
=/ fqp (fully-qualified site.req)
=/ mym (scry-mime now rof ext.req site.req)
?: ?=(%| -.mym) (error-response 500 p.mym)
=* mime p.mym
%- handle-response
:* %start
:- status-code=200
^= headers
:~ ['content-type' (rsh 3 (spat p.mime))]
['content-length' (crip (format-ud-as-integer p.q.mime))]
['cache-control' ?:(fqp 'max-age=31536000' 'no-cache')]
==
data=[~ q.mime]
complete=%.y
==
::
++ fully-qualified
|= a=path
^- ?
?. ?=([%'_~_' @ @ @ *] a) %.n
=/ vez (vang | (en-beam [our %base da+now] ~))
?= [~ [^ ^ ^ *]] (rush (spat t.t.a) ;~(pfix fas gash:vez))
::
++ error-response
|= [status=@ud =tape]
^- (quip move server-state)
%^ return-static-data-on-duct status 'text/html'
(error-page status authenticated url.request tape)
--
:: +handle-cache-req: respond with cached value, 404 or 500 :: +handle-cache-req: respond with cached value, 404 or 500
:: ::
++ handle-cache-req ++ handle-cache-req
|= [authenticated=? =request:http entry=(unit cache-entry)] |= [authenticated=? =request:http entry=cache-entry]
|^ ^- (quip move server-state) |^ ^- (quip move server-state)
?~ entry ?: &(auth.entry !authenticated)
(error-response 404 "cache entry for that binding was deleted")
?: &(auth.u.entry !authenticated)
(error-response 403 ~) (error-response 403 ~)
=* body body.u.entry =* body body.entry
?- -.body ?- -.body
%payload %payload
%- handle-response %- handle-response
@ -1090,7 +1137,7 @@
++ do-scry ++ do-scry
|= [care=term =desk =path] |= [care=term =desk =path]
^- (unit (unit cage)) ^- (unit (unit cage))
(rof ~ /eyre care [our desk da+now] path) (rof [~ ~] /eyre care [our desk da+now] path)
:: ::
++ error-response ++ error-response
|= [status=@ud =tape] |= [status=@ud =tape]
@ -1105,7 +1152,7 @@
^- (quip move server-state) ^- (quip move server-state)
:: if the agent isn't running, we synchronously serve a 503 :: if the agent isn't running, we synchronously serve a 503
:: ::
?. !<(? q:(need (need (rof ~ /eyre %gu [our app da+now] /$)))) ?. !<(? q:(need (need (rof [~ ~] /eyre %gu [our app da+now] /$))))
%^ return-static-data-on-duct 503 'text/html' %^ return-static-data-on-duct 503 'text/html'
%: error-page %: error-page
503 503
@ -1259,11 +1306,23 @@
o(session-id session.fex) o(session-id session.fex)
:: store the hostname used for this login, later reuse it for eauth :: store the hostname used for this login, later reuse it for eauth
:: ::
=? endpoint.auth.state ?=(^ host) =? endpoint.auth.state
:: avoid overwriting public domains with localhost
::
?& ?=(^ host)
?| ?=(~ auth.endpoint.auth.state)
!=('localhost' (fall (rush u.host host-sans-port) ''))
== ==
%- (trace 2 |.("eauth: storing endpoint at {(trip u.host)}")) %- (trace 2 |.("eauth: storing endpoint at {(trip u.host)}"))
:+ user.endpoint.auth.state =/ new-auth=(unit @t)
`(cat 3 ?:(secure 'https://' 'http://') u.host) `(cat 3 ?:(secure 'https://' 'http://') u.host)
now =, endpoint.auth.state
:+ user new-auth
:: only update the timestamp if the derived endpoint visibly changed.
:: that is, it's not hidden behind a user-provided hardcoded url,
:: and the new value is different from the old.)
::
?:(|(?=(^ user) =(new-auth auth)) time now)
:: ::
=; out=[moves=(list move) server-state] =; out=[moves=(list move) server-state]
out(moves [give-session-tokens :(weld moz moves.fex moves.out)]) out(moves [give-session-tokens :(weld moz moves.fex moves.out)])
@ -1498,7 +1557,7 @@
++ code ++ code
^- @ta ^- @ta
=/ res=(unit (unit cage)) =/ res=(unit (unit cage))
(rof ~ /eyre %j [our %code da+now] /(scot %p our)) (rof [~ ~] /eyre %j [our %code da+now] /(scot %p our))
(rsh 3 (scot %p ;;(@ q.q:(need (need res))))) (rsh 3 (scot %p ;;(@ q.q:(need (need res)))))
:: +session-cookie-string: compose session cookie :: +session-cookie-string: compose session cookie
:: ::
@ -1709,7 +1768,7 @@
=/ =wire /eauth/keen/(scot %p ship)/(scot %uv nonce) =/ =wire /eauth/keen/(scot %p ship)/(scot %uv nonce)
=. time (sub time (mod time ~h1)) =. time (sub time (mod time ~h1))
=/ =spar:ames [ship /e/x/(scot %da time)//eauth/url] =/ =spar:ames [ship /e/x/(scot %da time)//eauth/url]
[duct %pass wire %a ?-(kind %keen keen+spar, %yawn yawn+spar)] [duct %pass wire %a ?-(kind %keen keen+[~ spar], %yawn yawn+spar)]
:: ::
++ send-boon ++ send-boon
|= boon=eauth-boon |= boon=eauth-boon
@ -2699,7 +2758,7 @@
?~ sub ?~ sub
((trace 0 |.("no subscription for request-id {(scow %ud request-id)}")) ~) ((trace 0 |.("no subscription for request-id {(scow %ud request-id)}")) ~)
=/ des=(unit (unit cage)) =/ des=(unit (unit cage))
(rof ~ /eyre %gd [our app.u.sub da+now] /$) (rof [~ ~] /eyre %gd [our app.u.sub da+now] /$)
?. ?=([~ ~ *] des) ?. ?=([~ ~ *] des)
((trace 0 |.("no desk for app {<app.u.sub>}")) ~) ((trace 0 |.("no desk for app {<app.u.sub>}")) ~)
`!<(=desk q.u.u.des) `!<(=desk q.u.u.des)
@ -2735,7 +2794,7 @@
=* have=mark mark.event =* have=mark mark.event
=/ convert=(unit vase) =/ convert=(unit vase)
=/ cag=(unit (unit cage)) =/ cag=(unit (unit cage))
(rof ~ /eyre %cf [our desk.event da+now] /[have]/json) (rof [~ ~] /eyre %cf [our desk.event da+now] /[have]/json)
?. ?=([~ ~ *] cag) ~ ?. ?=([~ ~ *] cag) ~
`q.u.u.cag `q.u.u.cag
?~ convert ?~ convert
@ -3039,6 +3098,7 @@
:: ::
?: ?| ?=([%'~' *] path.binding) :: eyre ?: ?| ?=([%'~' *] path.binding) :: eyre
?=([%'~_~' *] path.binding) :: runtime ?=([%'~_~' *] path.binding) :: runtime
?=([%'_~_' *] path.binding) :: scries
== ==
[| bindings.state] [| bindings.state]
[& (insert-binding [binding duct action] bindings.state)] [& (insert-binding [binding duct action] bindings.state)]
@ -3194,6 +3254,12 @@
%https `& %https `&
== ==
:: ::
++ forwarded-host
|= forwards=(list (map @t @t))
^- (unit @t)
?. ?=(^ forwards) ~
(~(get by i.forwards) 'host')
::
++ parse-request-line ++ parse-request-line
|= url=@t |= url=@t
^- [[ext=(unit @ta) site=(list @t)] args=(list [key=@t value=@t])] ^- [[ext=(unit @ta) site=(list @t)] args=(list [key=@t value=@t])]
@ -3239,6 +3305,69 @@
:: need to issue a %leave after we've forgotten the identity with :: need to issue a %leave after we've forgotten the identity with
:: which the subscription was opened. :: which the subscription was opened.
/(scot %p ship)/[app]/(scot %p from) /(scot %p ship)/[app]/(scot %p from)
::
++ scry-mime
|= [now=@da rof=roof ext=(unit @ta) pax=path]
|^ ^- (each mime tape)
:: parse
::
=/ u=(unit [view=term bem=beam])
?. ?=([@ @ @ @ *] pax) ~
?~ view=(slaw %tas i.t.pax) ~
?~ path=(expand-path t.t.pax) ~
?~ beam=(de-beam u.path) ~
`[u.view u.beam]
?~ u [%| "invalid scry path"]
:: perform scry
::
?~ res=(rof [~ ~] /eyre u.u) [%| "failed scry"]
?~ u.res [%| "no scry result"]
=* mark p.u.u.res
=* vase q.u.u.res
:: convert to mime via ext
::
=/ dysk (conversion-desk u.u)
?: ?=(%| -.dysk) [%| p.dysk]
=/ ext (fall ext %mime)
=/ mym (convert vase mark ext p.dysk)
?: ?=(%| -.mym) [%| p.mym]
=/ mym (convert p.mym ext %mime p.dysk)
?: ?=(%| -.mym) [%| p.mym]
[%& !<(mime p.mym)]
::
++ expand-path
|= a=path
^- (unit path)
=/ vez (vang | (en-beam [our %base da+now] ~))
(rush (spat a) (sear plex:vez (stag %clsg ;~(pfix fas poor:vez))))
::
++ conversion-desk
|= [view=term =beam]
^- (each desk tape)
?: =(%$ q.beam) [%& %base]
?+ (end 3 view) [%& %base]
%c
[%& q.beam]
%g
=/ res (rof [~ ~] /eyre %gd [our q.beam da+now] /$)
?. ?=([~ ~ *] res)
[%| "no desk for app {<q.beam>}"]
[%& !<(=desk q.u.u.res)]
==
::
++ convert
|= [=vase from=mark to=mark =desk]
^- (each ^vase tape)
?: =(from to) [%& vase]
=/ tub (rof [~ ~] /eyre %cc [our desk da+now] /[from]/[to])
?. ?=([~ ~ %tube *] tub)
[%| "no tube from {(trip from)} to {(trip to)}"]
=/ tube !<(tube:clay q.u.u.tub)
=/ res (mule |.((tube vase)))
?: ?=(%| -.res)
[%| "failed tube from {(trip from)} to {(trip to)}"]
[%& +.res]
--
-- --
:: end the =~ :: end the =~
:: ::
@ -3396,6 +3525,8 @@
$(moves [mov moves], siz t.siz) $(moves [mov moves], siz t.siz)
:: ::
?: ?=(%eauth-host -.task) ?: ?=(%eauth-host -.task)
?: =(user.endpoint.auth.server-state.ax host.task)
[~ http-server-gate]
=. user.endpoint.auth.server-state.ax host.task =. user.endpoint.auth.server-state.ax host.task
=. time.endpoint.auth.server-state.ax now =. time.endpoint.auth.server-state.ax now
[~ http-server-gate] [~ http-server-gate]
@ -4005,14 +4136,44 @@
[~ ~] [~ ~]
?. =(our who) ?. =(our who)
?. =([%da now] p.lot) ?. =([%da now] p.lot)
[~ ~] ~
~& [%r %scry-foreign-host who] ~& [%r %scry-foreign-host who]
~ ~
::
?: ?=([%eauth %url ~] tyl)
?. &(?=(%x ren) ?=(%$ syd)) ~
=* endpoint endpoint.auth.server-state.ax
?. ?=(%da -.p.lot) [~ ~]
:: we cannot answer for something prior to the last set time,
:: or something beyond the present moment.
::
?: ?| (lth q.p.lot time.endpoint)
(gth q.p.lot now)
==
~
:^ ~ ~ %noun
!> ^- (unit @t)
=< eauth-url:eauth:authentication
(per-server-event [eny *duct now rof] server-state.ax)
::
?: ?=([%cache @ @ ~] tyl)
?. &(?=(%x ren) ?=(%$ syd)) ~
=, server-state.ax
?~ aeon=(slaw %ud i.t.tyl) [~ ~]
?~ url=(slaw %t i.t.t.tyl) [~ ~]
?~ entry=(~(get by cache) u.url) ~
?. =(u.aeon aeon.u.entry) ~
?~ val=val.u.entry ~
?: &(auth.u.val !=([~ ~] lyc)) ~
``noun+!>(u.val)
:: private endpoints
?. ?=([~ ~] lyc) ~
?: &(?=(%x ren) ?=(%$ syd)) ?: &(?=(%x ren) ?=(%$ syd))
=, server-state.ax =, server-state.ax
?+ tyl [~ ~] ?+ tyl ~
[%$ %whey ~] =- ``mass+!>(`(list mass)`-) [%$ %whey ~] =- ``mass+!>(`(list mass)`-)
:~ bindings+&+bindings.server-state.ax :~ bindings+&+bindings.server-state.ax
cache+&+cache.server-state.ax
auth+&+auth.server-state.ax auth+&+auth.server-state.ax
connections+&+connections.server-state.ax connections+&+connections.server-state.ax
channels+&+channel-state.server-state.ax channels+&+channel-state.server-state.ax
@ -4032,21 +4193,6 @@
%approved ``noun+!>((~(has in approved.cors-registry) u.origin)) %approved ``noun+!>((~(has in approved.cors-registry) u.origin))
%rejected ``noun+!>((~(has in rejected.cors-registry) u.origin)) %rejected ``noun+!>((~(has in rejected.cors-registry) u.origin))
== ==
::
[%eauth %url ~]
=* endpoint endpoint.auth.server-state.ax
?. ?=(%da -.p.lot) [~ ~]
:: we cannot answer for something prior to the last set time,
:: or something beyond the present moment.
::
?: ?| (lth q.p.lot time.endpoint)
(gth q.p.lot now)
==
~
:^ ~ ~ %noun
!> ^- (unit @t)
=< eauth-url:eauth:authentication
(per-server-event [eny *duct now rof] server-state.ax)
:: ::
[%authenticated %cookie @ ~] [%authenticated %cookie @ ~]
?~ cookies=(slaw %t i.t.t.tyl) [~ ~] ?~ cookies=(slaw %t i.t.t.tyl) [~ ~]
@ -4056,22 +4202,19 @@
(per-server-event [eny *duct now rof] server-state.ax) (per-server-event [eny *duct now rof] server-state.ax)
%*(. *request:http header-list ['cookie' u.cookies]~) %*(. *request:http header-list ['cookie' u.cookies]~)
:: ::
[%cache @ @ ~] [%'_~_' *]
?~ aeon=(slaw %ud i.t.tyl) [~ ~] =/ mym (scry-mime now rof (deft:de-purl:html tyl))
?~ url=(slaw %t i.t.t.tyl) [~ ~] ?: ?=(%| -.mym) [~ ~]
?~ entry=(~(get by cache) u.url) [~ ~] ``noun+!>(p.mym)
?. =(u.aeon aeon.u.entry) [~ ~]
?~ val=val.u.entry [~ ~]
``noun+!>(u.val)
== ==
?. ?=(%$ ren) ?. ?=(%$ ren) ~
[~ ~] ?+ syd ~
?+ syd [~ ~]
%bindings ``noun+!>(bindings.server-state.ax) %bindings ``noun+!>(bindings.server-state.ax)
%cache ``noun+!>(cache.server-state.ax)
%connections ``noun+!>(connections.server-state.ax) %connections ``noun+!>(connections.server-state.ax)
%authentication-state ``noun+!>(auth.server-state.ax) %authentication-state ``noun+!>(auth.server-state.ax)
%channel-state ``noun+!>(channel-state.server-state.ax) %channel-state ``noun+!>(channel-state.server-state.ax)
:: ::
%host %host
%- (lift (lift |=(a=hart:eyre [%hart !>(a)]))) %- (lift (lift |=(a=hart:eyre [%hart !>(a)])))
^- (unit (unit hart:eyre)) ^- (unit (unit hart:eyre))

File diff suppressed because it is too large Load Diff

View File

@ -395,7 +395,7 @@
:: ::
?. ?=(%& -.why) ~ ?. ?=(%& -.why) ~
=* his p.why =* his p.why
?: &(?=(%x ren) =(tyl //whey)) ?: &(?=(%x ren) =(tyl //whey) =([~ ~] lyc))
=/ maz=(list mass) =/ maz=(list mass)
:~ nex+&+next-id.state.ax :~ nex+&+next-id.state.ax
outbound+&+outbound-duct.state.ax outbound+&+outbound-duct.state.ax

View File

@ -654,7 +654,10 @@
++ public-keys-give ++ public-keys-give
|= [yen=(set duct) =public-keys-result] |= [yen=(set duct) =public-keys-result]
|^ |^
=+ yez=(sort ~(tap in yen) sorter) =/ yaz %+ skid ~(tap in yen)
|= d=duct
&(?=([[%ames @ @ *] *] d) !=(%public-keys i.t.i.d))
=/ yez (weld p.yaz (sort q.yaz sorter))
|- ^+ this-su |- ^+ this-su
?~ yez this-su ?~ yez this-su
=* d i.yez =* d i.yez
@ -667,7 +670,9 @@
$(yez t.yez) $(yez t.yez)
:: ::
:: We want to notify Ames, then Clay, then Gall. This happens to :: We want to notify Ames, then Clay, then Gall. This happens to
:: be alphabetical, but this is mostly a coincidence. :: be alphabetical, but this is mostly a coincidence. We also have
:: to notify Gall the vane before we notify any Gall agents, so we
:: can kiss the coincidence goodbye.
:: ::
++ sorter ++ sorter
|= [a=duct b=duct] |= [a=duct b=duct]
@ -675,6 +680,8 @@
| |
?. ?=([[@ *] *] b) ?. ?=([[@ *] *] b)
& &
?: &(?=([[%gall *] *] a) ?=([[%gall *] *] b))
?=([%gall %sys *] i.a)
(lth (end 3 i.i.a) (end 3 i.i.b)) (lth (end 3 i.i.a) (end 3 i.i.b))
-- --
:: ::
@ -1065,7 +1072,7 @@
:: ::
:: XX review for security, stability, cases other than now :: XX review for security, stability, cases other than now
:: ::
?. =(lot [%$ %da now]) ~ ?. &(=(lot [%$ %da now]) =([~ ~] lyc)) ~
:: ::
?: &(?=(%x ren) =(tyl //whey)) ?: &(?=(%x ren) =(tyl //whey))
=/ maz=(list mass) =/ maz=(list mass)

View File

@ -72,7 +72,7 @@
++ get-dais ++ get-dais
|= [=beak =mark rof=roof] |= [=beak =mark rof=roof]
^- dais:clay ^- dais:clay
?~ ret=(rof ~ /khan %cb beak /[mark]) ?~ ret=(rof [~ ~] /khan %cb beak /[mark])
~|(mark-unknown+mark !!) ~|(mark-unknown+mark !!)
?~ u.ret ?~ u.ret
~|(mark-invalid+mark !!) ~|(mark-invalid+mark !!)
@ -82,7 +82,7 @@
++ get-tube ++ get-tube
|= [=beak =mark =out=mark rof=roof] |= [=beak =mark =out=mark rof=roof]
^- tube:clay ^- tube:clay
?~ ret=(rof ~ /khan %cc beak /[mark]/[out-mark]) ?~ ret=(rof [~ ~] /khan %cc beak /[mark]/[out-mark])
~|(tube-unknown+[mark out-mark] !!) ~|(tube-unknown+[mark out-mark] !!)
?~ u.ret ?~ u.ret
~|(tube-invalid+[mark out-mark] !!) ~|(tube-invalid+[mark out-mark] !!)

View File

@ -88,11 +88,12 @@
|= [lyc=gang pov=path car=term bem=beam] |= [lyc=gang pov=path car=term bem=beam]
^- (unit (unit cage)) ^- (unit (unit cage))
|^ |^
:: only respond for the local identity, current timestamp :: only respond for the local identity, current timestamp, root gang
:: ::
?. ?& =(our p.bem) ?. ?& =(our p.bem)
=(%$ q.bem) =(%$ q.bem)
=([%da now] r.bem) =([%da now] r.bem)
=([~ ~] lyc)
== ==
~ ~
?+ car ~ ?+ car ~

View File

@ -4,7 +4,7 @@
=> ..lull => ..lull
~% %zuse ..part ~ ~% %zuse ..part ~
|% |%
++ zuse %412 ++ zuse %411
:: :: :: :: :: ::
:::: :: :: (2) engines :::: :: :: (2) engines
:: :: :: :: :: ::
@ -5256,7 +5256,7 @@
|= [rof=roof pov=path our=ship now=@da who=ship] |= [rof=roof pov=path our=ship now=@da who=ship]
;; ship ;; ship
=< q.q %- need %- need =< q.q %- need %- need
(rof ~ pov %j `beam`[[our %sein %da now] /(scot %p who)]) (rof [~ ~] pov %j `beam`[[our %sein %da now] /(scot %p who)])
-- --
:: middle core: stateless queries for default numeric sponsorship :: middle core: stateless queries for default numeric sponsorship
:: ::

View File

@ -26,11 +26,13 @@
^- (list card:agent:gall) ^- (list card:agent:gall)
=/ rcvr=ship (lane-to-ship lan) =/ rcvr=ship (lane-to-ship lan)
=/ hear-lane (ship-to-lane sndr) =/ hear-lane (ship-to-lane sndr)
=/ [ames=? =packet] (decode-packet pac) =/ =shot (sift-shot pac)
?: &(!ames !resp==(& (cut 0 [2 1] pac))) ?: &(!sam.shot req.shot) :: is fine request
=/ [=peep =purr] (decode-request-info `@ux`(rsh 3^64 content.packet)) =/ [%0 =peep] (sift-wail `@ux`content.shot)
%+ emit-aqua-events our %+ emit-aqua-events our
[%read [rcvr path.peep] [hear-lane num.peep]]~ :_ ~
:- %read
[[[rcvr rcvr-tick.shot] path.peep] [hear-lane sndr-tick.shot] num.peep]
%+ emit-aqua-events our %+ emit-aqua-events our
[%event rcvr /a/newt/0v1n.2m9vh %hear hear-lane pac]~ [%event rcvr /a/newt/0v1n.2m9vh %hear hear-lane pac]~
:: +lane-to-ship: decode a ship from an aqua lane :: +lane-to-ship: decode a ship from an aqua lane

View File

@ -14,20 +14,24 @@
|= [who=@p way=wire %blit blits=(list blit:dill)] |= [who=@p way=wire %blit blits=(list blit:dill)]
^- (list card:agent:gall) ^- (list card:agent:gall)
=/ last-line =/ last-line
%+ roll blits |^ (roll blits ha-blit)
|= [b=blit:dill line=tape] ::
?- -.b ++ ha-blit
%put (tape p.b) |= [b=blit:dill line=tape]
%klr (tape (zing (turn p.b tail))) ?- -.b
%nel ~& "{<who>}: {line}" "" %put (tape p.b)
%hop line %klr (tape (zing (turn p.b tail)))
%bel line %mor `tape`(roll p.b ha-blit)
%clr "" %nel ~& "{<who>}: {line}" ""
%sag ~& [%save-jamfile-to p.b] line %hop line
%sav ~& [%save-file-to p.b] line %bel line
%url ~& [%activate-url p.b] line %clr ""
%wyp "" %sag ~& [%save-jamfile-to p.b] line
== %sav ~& [%save-file-to p.b] line
%url ~& [%activate-url p.b] line
%wyp ""
==
--
~? !=(~ last-line) last-line ~? !=(~ last-line) last-line
~ ~
-- --

View File

@ -0,0 +1,27 @@
/- spider
/+ strandio
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([~ =spar:ames] arg)
;< ~ bind:m
(keen-shut:strandio /keen spar)
;< [* dat=(unit (unit page))] bind:m
(take-near:strandio /keen)
?~ dat
~& mysterious/~
(pure:m !>(~))
?~ u.dat
~& non-existent/~
(pure:m !>(~))
::
;< =bowl:spider bind:m get-bowl:strandio
=+ .^ =dais:clay %cb
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/[p.u.u.dat]
==
=/ res (mule |.((vale.dais q.u.u.dat)))
?. ?=(%| -.res)
(pure:m p.res)
~|(%keen-mark-fail (mean leaf+"-keen: ames vale fail {<mark>}" p.res))

View File

@ -1,67 +0,0 @@
/- spider
/+ *ph-io
=>
|%
++ wait-for-agent-start
|= [=ship agent=term]
=/ m (strand:spider ,~)
^- form:m
=* loop $
;< [her=^ship =unix-effect] bind:m take-unix-effect
?: (is-dojo-output:util ship her unix-effect "activated app base/{(trip agent)}")
(pure:m ~)
loop
::
++ start-agent
|= [=ship agent=term]
=/ m (strand:spider ,~)
^- form:m
=* loop $
;< ~ bind:m (dojo ship "|start {<agent>}")
;< ~ bind:m (wait-for-agent-start ship agent)
(pure:m ~)
::
++ wait-for-goad
|= =ship
=/ m (strand:spider ,~)
^- form:m
=* loop $
;< [her=^ship =unix-effect] bind:m take-unix-effect
?: (is-dojo-output:util ship her unix-effect "p=%hood q=%bump")
(pure:m ~)
loop
::
++ start-group-agents
|= =ship
=/ m (strand:spider ,~)
^- form:m
;< ~ bind:m (start-agent ship %group-store)
(pure:m ~)
--
=, strand=strand:spider
^- thread:spider
|= args=vase
=/ m (strand ,vase)
;< ~ bind:m start-azimuth
;< ~ bind:m (spawn ~bud)
;< ~ bind:m (spawn ~marbud)
;< ~ bind:m (spawn ~zod)
;< ~ bind:m (spawn ~marzod)
;< ~ bind:m (init-ship ~bud |)
;< ~ bind:m (init-ship ~marbud |)
;< ~ bind:m (wait-for-goad ~marbud)
;< ~ bind:m (init-ship ~zod |)
;< ~ bind:m (init-ship ~marzod |)
;< ~ bind:m (wait-for-goad ~marzod)
;< ~ bind:m (start-group-agents ~marbud)
;< ~ bind:m (start-group-agents ~marzod)
;< ~ bind:m (dojo ~marbud ":group-store|create 'test-group'")
;< ~ bind:m (wait-for-output ~marbud ">=")
;< ~ bind:m (sleep ~s1)
;< ~ bind:m (breach-and-hear ~marzod ~marbud)
;< ~ bind:m (init-ship ~marzod |)
;< ~ bind:m (wait-for-goad ~marzod)
;< ~ bind:m (start-group-agents ~marzod)
;< ~ bind:m (sleep ~s3)
;< ~ bind:m end
(pure:m *vase)

View File

@ -7,7 +7,7 @@
;< ~ bind:m start-simple ;< ~ bind:m start-simple
;< ~ bind:m (init-ship ~bud &) ;< ~ bind:m (init-ship ~bud &)
;< ~ bind:m (init-ship ~dev &) ;< ~ bind:m (init-ship ~dev &)
;< ~ bind:m (dojo ~bud "-keen /cx/~dev/kids/1/desk/bill") ;< ~ bind:m (dojo ~bud "-keen ~dev /c/x/1/kids/sys/kelvin")
;< ~ bind:m (wait-for-output ~bud "[ ~") ;< ~ bind:m (wait-for-output ~bud "kal=[lal=%zuse num={(scow %ud zuse)}]")
;< ~ bind:m end ;< ~ bind:m end
(pure:m *vase) (pure:m *vase)

View File

@ -1,66 +0,0 @@
/- spider
/+ io=ph-io, *strandio
=>
=, io
|%
++ strand strand:spider
++ start-agents
|= =ship
=/ m (strand ,~)
;< ~ bind:m (dojo ship "|start %graph-store")
;< ~ bind:m (dojo ship "|start %graph-push-hook")
;< ~ bind:m (dojo ship "|start %graph-pull-hook")
;< ~ bind:m (dojo ship "|start %group-store")
;< ~ bind:m (dojo ship "|start %group-push-hook")
;< ~ bind:m (dojo ship "|start %group-pull-hook")
;< ~ bind:m (dojo ship "|start %metadata-store")
;< ~ bind:m (dojo ship "|start %metadata-hook")
;< ~ bind:m (sleep `@dr`300)
(pure:m ~)
::
++ make-link
|= [title=@t url=@t]
=/ m (strand ,~)
;< ~ bind:m (dojo ~bud ":graph-store|add-post [~bud %test] ~[[%text '{(trip title)}'] [%url '{(trip url)}']]")
(pure:m ~)
--
^- thread:spider
|= vase
=/ m (strand ,vase)
;< ~ bind:m start-azimuth
;< ~ bind:m (spawn ~bud)
;< ~ bind:m (spawn ~dev)
;< ~ bind:m (init-ship ~bud |)
;< ~ bind:m (init-ship ~dev |)
;< ~ bind:m (start-agents ~bud)
;< ~ bind:m (start-agents ~dev)
;< ~ bind:m (send-hi ~bud ~dev)
;< ~ bind:m (dojo ~bud "-graph-create [%create [~bud %test] 'test' '' `%graph-validator-link [%policy [%open ~ ~]] 'link']")
;< ~ bind:m (sleep ~s5)
;< ~ bind:m (dojo ~dev "-graph-join [%join [~bud %test] ~bud]")
;< ~ bind:m (sleep ~s5)
;< ~ bind:m (send-hi ~bud ~dev)
;< ~ bind:m (poke-our %aqua noun+!>([%pause-events ~[~dev]]))
;< ~ bind:m (make-link 'one' 'one')
;< ~ bind:m (make-link 'two' 'one')
;< ~ bind:m (make-link 'thre' 'one')
;< ~ bind:m (make-link 'four' 'one')
;< ~ bind:m (make-link 'five' 'one')
;< ~ bind:m (make-link 'six' 'one')
;< ~ bind:m (make-link 'seven' 'one')
;< ~ bind:m (sleep ~s40)
:: five unacked events is sufficent to cause a clog, and by extension a
:: %kick
;< ~ bind:m (poke-our %aqua noun+!>([%unpause-events ~[~dev]]))
;< ~ bind:m (sleep ~s10)
;< ~ bind:m (make-link 'eight' 'one')
;< ~ bind:m (make-link 'nine' 'one')
;< ~ bind:m (sleep ~s10)
;< ~ bind:m (dojo ~dev ":graph-pull-hook +dbug %bowl")
;< ~ bind:m (dojo ~dev ":graph-store +dbug")
;< ~ bind:m (dojo ~bud ":graph-push-hook +dbug %bowl")
;< ~ bind:m (dojo ~bud ":graph-store +dbug")
;< ~ bind:m end
(pure:m *vase)
::(pure:m *vase)

70
pkg/arvo/ted/ph/tend.hoon Normal file
View File

@ -0,0 +1,70 @@
/- spider
/+ *ph-io, strandio
/* tend-agent %hoon /tests/app/tend/hoon
=, strand=strand:spider
=< all
|%
++ tend
|= zuse=@ud
=/ m (strand ,~)
;< ~ bind:m (dojo ~bud ":tend [%tend /foo /baz %kelvin %zuse {(scow %ud zuse)}]")
;< ~ bind:m (sleep:strandio ~s2)
;< ~ bind:m (dojo ~bud ":tend +dbug %bowl")
(pure:m ~)
::
++ keen-wait-for-result
|= [cas=@ud zuse=@ud]
=/ m (strand ,~)
;< ~ bind:m (dojo ~dev ":tend [%keen ~bud {(scow %ud cas)} /tend//foo/baz]")
;< ~ bind:m (wait-for-output ~dev "kal=[lal=%zuse num={(scow %ud zuse)}]")
(pure:m ~)
::
++ setup
=/ m (strand ,~)
;< ~ bind:m start-simple
:: testing usual case
;< ~ bind:m (init-ship ~bud &)
;< ~ bind:m (init-ship ~dev &)
;< ~ bind:m (dojo ~bud "|mount %base")
;< ~ bind:m (dojo ~dev "|mount %base")
;< ~ bind:m (copy-file ~bud /app/tend/hoon tend-agent)
;< ~ bind:m (copy-file ~dev /app/tend/hoon tend-agent)
;< ~ bind:m (dojo ~bud "|start %tend")
;< ~ bind:m (dojo ~dev "|start %tend")
(pure:m ~)
::
++ all
^- thread:spider
|= vase
=/ m (strand ,vase)
;< ~ bind:m test-normal
;< ~ bind:m test-larval-ames
(pure:m *vase)
::
++ test-larval-ames
=/ m (strand ,~)
;< ~ bind:m setup
;< ~ bind:m (dojo ~bud ":tend [%germ /foo]")
;< ~ bind:m (sleep:strandio ~s2)
;< ~ bind:m (tend zuse)
;< ~ bind:m (keen-wait-for-result 0 zuse)
=/ zuse (dec zuse)
;< ~ bind:m (tend zuse)
;< ~ bind:m (keen-wait-for-result 1 zuse)
;< ~ bind:m end
(pure:m ~)
::
++ test-normal
=/ m (strand ,~)
;< ~ bind:m setup
;< ~ bind:m (send-hi ~bud ~dev) :: make sure both ames have metamorphosed
;< ~ bind:m (dojo ~bud ":tend [%germ /foo]")
;< ~ bind:m (sleep:strandio ~s2)
;< ~ bind:m (tend zuse)
;< ~ bind:m (keen-wait-for-result 0 zuse)
=/ zuse (dec zuse)
;< ~ bind:m (tend zuse)
;< ~ bind:m (keen-wait-for-result 1 zuse)
;< ~ bind:m end
(pure:m ~)
--

View File

@ -103,6 +103,8 @@
:: ::
?~ q.arg ?~ q.arg
~[/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/tests] ~[/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/tests]
?~ +.q.arg
~[/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/tests]
:: else cast path to ~[path] if needed :: else cast path to ~[path] if needed
:: ::
?@ +<.q.arg ?@ +<.q.arg

View File

@ -256,6 +256,14 @@
;< ~ bind:m (send-events (insert-files:util her desk [pax warped] ~)) ;< ~ bind:m (send-events (insert-files:util her desk [pax warped] ~))
(pure:m warped) (pure:m warped)
:: ::
++ copy-file
=/ m (strand ,~)
|= [her=ship pax=path file=@t]
^- form:m
;< ~ bind:m
(send-events (insert-files:util her %base [pax file] ~))
(sleep ~s1)
::
:: Check /sur/aquarium/hoon on the given has the given contents. :: Check /sur/aquarium/hoon on the given has the given contents.
:: ::
++ check-file-touched ++ check-file-touched

View File

@ -62,15 +62,26 @@
::TODO should be rename -dill-output ::TODO should be rename -dill-output
++ is-dojo-output ++ is-dojo-output
|= [who=ship her=ship uf=unix-effect what=tape] |= [who=ship her=ship uf=unix-effect what=tape]
|^
?& =(who her) ?& =(who her)
?=(%blit -.q.uf) ?=(%blit -.q.uf)
:: (lien p.q.uf handle-blit)
%+ lien p.q.uf
|= =blit:dill
?. ?=(%put -.blit)
|
!=(~ (find what p.blit))
== ==
::
++ handle-blit
|= =blit:dill
^- ?
?: ?=(%mor -.blit)
(lien p.blit handle-blit)
?+ -.blit |
%put !=(~ (find what p.blit))
::
%klr
%+ lien p.blit
|= [* q=(list @c)]
!=(~ (find what q))
==
--
:: ::
:: Test is successful if +is-dojo-output :: Test is successful if +is-dojo-output
:: ::

View File

@ -197,6 +197,20 @@
`[%done +>.sign-arvo.u.in.tin] `[%done +>.sign-arvo.u.in.tin]
== ==
:: ::
++ take-near
|= =wire
=/ m (strand ,[spar:ames (unit (unit page))])
^- form:m
|= tin=strand-input:strand
?+ in.tin `[%skip ~]
~ `[%wait ~]
::
[~ %sign * %ames %near ^ *]
?. =(wire wire.u.in.tin)
`[%skip ~]
`[%done +>.sign-arvo.u.in.tin]
==
::
++ take-poke-ack ++ take-poke-ack
|= =wire |= =wire
=/ m (strand ,~) =/ m (strand ,~)
@ -335,7 +349,13 @@
|= [=wire =spar:ames] |= [=wire =spar:ames]
=/ m (strand ,~) =/ m (strand ,~)
^- form:m ^- form:m
(send-raw-card %pass wire %arvo %a %keen spar) (send-raw-card %pass wire %arvo %a %keen ~ spar)
::
++ keen-shut
|= [=wire =spar:ames]
=/ m (strand ,~)
^- form:m
(send-raw-card %pass wire %keen & spar)
:: ::
++ sleep ++ sleep
|= for=@dr |= for=@dr

View File

@ -1,6 +1,6 @@
:: Print what your agent is doing. :: Print what your agent is doing.
:: ::
/- verb /- *verb
:: ::
|= [loud=? =agent:gall] |= [loud=? =agent:gall]
=| bowl-print=_| =| bowl-print=_|
@ -14,7 +14,10 @@
^- (quip card:agent:gall agent:gall) ^- (quip card:agent:gall agent:gall)
%- (print bowl |.("{<dap.bowl>}: on-init")) %- (print bowl |.("{<dap.bowl>}: on-init"))
=^ cards agent on-init:ag =^ cards agent on-init:ag
[[(emit-event %on-init ~) cards] this] :_ this
:_ :_ cards
(emit-event %on-init ~)
(emit-event-plus bowl [%on-init ~] cards)
:: ::
++ on-save ++ on-save
^- vase ^- vase
@ -26,7 +29,10 @@
^- (quip card:agent:gall agent:gall) ^- (quip card:agent:gall agent:gall)
%- (print bowl |.("{<dap.bowl>}: on-load")) %- (print bowl |.("{<dap.bowl>}: on-load"))
=^ cards agent (on-load:ag old-state) =^ cards agent (on-load:ag old-state)
[[(emit-event %on-load ~) cards] this] :_ this
:_ :_ cards
(emit-event %on-load ~)
(emit-event-plus bowl [%on-load ~] cards)
:: ::
++ on-poke ++ on-poke
|= [=mark =vase] |= [=mark =vase]
@ -38,17 +44,23 @@
%bowl `this(bowl-print !bowl-print) %bowl `this(bowl-print !bowl-print)
== ==
=^ cards agent (on-poke:ag mark vase) =^ cards agent (on-poke:ag mark vase)
[[(emit-event %on-poke mark) cards] this] :_ this
:_ :_ cards
(emit-event %on-poke mark)
(emit-event-plus bowl [%on-poke mark (mug q.vase)] cards)
:: ::
++ on-watch ++ on-watch
|= =path |= =path
^- (quip card:agent:gall agent:gall) ^- (quip card:agent:gall agent:gall)
%- (print bowl |.("{<dap.bowl>}: on-watch on path {<path>}")) %- (print bowl |.("{<dap.bowl>}: on-watch on path {<path>}"))
=^ cards agent =^ cards agent
?: ?=([%verb %events ~] path) ?: ?=([%verb ?(%events %events-plus) ~] path)
[~ agent] [~ agent]
(on-watch:ag path) (on-watch:ag path)
[[(emit-event %on-watch path) cards] this] :_ this
:_ :_ cards
(emit-event %on-watch path)
(emit-event-plus bowl [%on-watch path] cards)
:: ::
++ on-leave ++ on-leave
|= =path |= =path
@ -57,7 +69,10 @@
?: ?=([%verb %event ~] path) ?: ?=([%verb %event ~] path)
[~ this] [~ this]
=^ cards agent (on-leave:ag path) =^ cards agent (on-leave:ag path)
[[(emit-event %on-leave path) cards] this] :_ this
:_ :_ cards
(emit-event %on-leave path)
(emit-event-plus bowl [%on-leave path] cards)
:: ::
++ on-peek ++ on-peek
|= =path |= =path
@ -70,7 +85,17 @@
^- (quip card:agent:gall agent:gall) ^- (quip card:agent:gall agent:gall)
%- (print bowl |.("{<dap.bowl>}: on-agent on wire {<wire>}, {<-.sign>}")) %- (print bowl |.("{<dap.bowl>}: on-agent on wire {<wire>}, {<-.sign>}"))
=^ cards agent (on-agent:ag wire sign) =^ cards agent (on-agent:ag wire sign)
[[(emit-event %on-agent wire -.sign) cards] this] :_ this
:_ :_ cards
(emit-event %on-agent wire -.sign)
=; =^sign
(emit-event-plus bowl [%on-agent wire sign] cards)
?- -.sign
%poke-ack [%poke-ack ?=(~ p.sign)]
%watch-ack [%watch-ack ?=(~ p.sign)]
%kick [%kick ~]
%fact [%fact p.cage.sign (mug q.q.cage.sign)]
==
:: ::
++ on-arvo ++ on-arvo
|= [=wire =sign-arvo] |= [=wire =sign-arvo]
@ -78,14 +103,20 @@
%- %+ print bowl |. %- %+ print bowl |.
"{<dap.bowl>}: on-arvo on wire {<wire>}, {<[- +<]:sign-arvo>}" "{<dap.bowl>}: on-arvo on wire {<wire>}, {<[- +<]:sign-arvo>}"
=^ cards agent (on-arvo:ag wire sign-arvo) =^ cards agent (on-arvo:ag wire sign-arvo)
[[(emit-event %on-arvo wire [- +<]:sign-arvo) cards] this] :_ this
:_ :_ cards
(emit-event %on-arvo wire [- +<]:sign-arvo)
(emit-event-plus bowl [%on-arvo wire [- +<]:sign-arvo] cards)
:: ::
++ on-fail ++ on-fail
|= [=term =tang] |= [=term =tang]
^- (quip card:agent:gall agent:gall) ^- (quip card:agent:gall agent:gall)
%- (print bowl |.("{<dap.bowl>}: on-fail with term {<term>}")) %- (print bowl |.("{<dap.bowl>}: on-fail with term {<term>}"))
=^ cards agent (on-fail:ag term tang) =^ cards agent (on-fail:ag term tang)
[[(emit-event %on-fail term) cards] this] :_ this
:_ :_ cards
(emit-event %on-fail term)
(emit-event-plus bowl [%on-fail term] cards)
-- --
:: ::
++ print ++ print
@ -99,7 +130,53 @@
same same
:: ::
++ emit-event ++ emit-event
|= =event:verb |= =event
^- card:agent:gall ^- card:agent:gall
[%give %fact ~[/verb/events] %verb-event !>(event)] [%give %fact ~[/verb/events] %verb-event !>(event)]
::
++ emit-event-plus
|= [=bowl:gall =cause cards=(list card:agent:gall)]
^- card:agent:gall
=; event=event-plus
[%give %fact ~[/verb/events-plus] %verb-event-plus !>(event)]
=- [act.bowl now.bowl src.bowl sap.bowl cause -]
%+ turn cards
|= =card:agent:gall
^- effect
::TODO for %fact, %kick, could calculate how many ships affected
?- card
[%pass * %agent * ?(%poke %poke-as) *]
=, q.card
=/ =cage ?-(-.task.q.card %poke cage.task, %poke-as [mark.task q.cage.task])
[%poke p.card [ship name] p.cage `@`(mug q.q.cage)]
::
[%pass * %agent * ?(%watch %watch-as) *]
=, q.card
=/ =path ?-(-.task.q.card %watch path.task, %watch-as path.task)
[%watch p.card [ship name] path]
::
[%pass * %agent * %leave *]
=, q.card
[%leave p.card [ship name]]
::
[%give %fact *]
=, p.card
[%fact paths p.cage (mug q.q.cage)]
::
[%give %kick *]
[%kick paths.p.card]
::
[%give ?(%poke-ack %watch-ack) *]
~| %explicit-ack
!! :: shouldn't be given explicitly
::
[%pass * %arvo *]
[%arvo p.card -.q.card +<.q.card]
::
[%pass *]
[%arvo p.card %$ -.q.card]
::
[%slip *]
$(card [%pass //slip p.card])
==
-- --

View File

@ -0,0 +1,78 @@
:: verb-json: conversions for verb events
::
/- verb
::
|%
++ enjs
=, enjs:format
|%
++ event
|= event-plus:verb
%- pairs
:~ 'act'^(numb act)
'now'^(time now) :: ms timestamp, lossy-ness is fine here
'src'^s+(scot %p src)
'sap'^s+(spat sap)
'kind'^s+-.cause
'deets'^(^cause cause)
'effects'^a+(turn effects effect)
==
::
++ cause
|= =cause:verb
^- json
?- -.cause
%on-init b+&
%on-load b+&
%on-poke (pairs 'mark'^s+mark.cause 'mug'^(mug mug.cause) ~)
%on-watch (path path.cause)
%on-leave (path path.cause)
%on-agent %- pairs
:~ 'wire'^(path wire.cause)
'sign'^s+-.sign.cause
::
:- 'deets'
?- -.sign.cause
%poke-ack b+ack.sign.cause
%watch-ack b+ack.sign.cause
%kick ~
%fact %- pairs
:~ 'mark'^s+mark.sign.cause
'mug'^(mug mug.sign.cause)
==
==
==
%on-arvo %- pairs
:~ 'wire'^(path wire.cause)
'vane'^s+vane.cause
'sign'^s+sign.cause
==
%on-fail s+term.cause
==
::
++ effect
|= effect:verb
^- json
%- pairs
:- 'kind'^s++<-
:_ ~
:- 'deets'
%- pairs
^- (list [@t json])
?- +<-
%poke :~ 'wire'^(path wire)
'gill'^(^gill gill)
'mark'^s+mark
'mug'^(^mug mug)
==
%watch ~['wire'^(^path wire) 'gill'^(^gill gill) 'path'^(^path path)]
%leave ~['wire'^(path wire) 'gill'^(^gill gill)]
%fact ~['paths'^a+(turn paths path) 'mark'^s+mark 'mug'^(^mug mug)]
%kick ~['paths'^a+(turn paths path)]
%arvo ~['wire'^(path wire) 'vane'^s+vane 'task'^s+task]
==
::
++ gill |=(=gill:gall `json`s+(rap 3 (scot %p p.gill) '/' q.gill ~))
++ mug |=(mug=@ux `json`s+(crip ((x-co:co 8) mug)))
--
--

View File

@ -0,0 +1,22 @@
::
:::: /hoon/approve-merge/kiln/mar
::
/- h=hood
|_ req=[sync-record:h approve=?]
::
++ grow
|%
++ noun req
--
++ grab
|%
++ noun ,[sync-record:h approve=?]
++ json
=, dejs:format
%- ot
:~ [%sync (ot syd+so her+(se %p) sud+so ~)]
[%approve bo]
==
--
++ grad %noun
--

View File

@ -0,0 +1,16 @@
::
:::: /hoon/jump-ask/kiln/mar
::
/? 310
|_ req=[old=dock new=dock]
::
++ grow
|%
++ noun req
--
++ grab
|%
++ noun ,[dock dock]
--
++ grad %noun
--

View File

@ -0,0 +1,22 @@
::
:::: /hoon/jump-opt/kiln/mar
::
|_ req=[old=dock new=dock yea=?]
::
++ grow
|%
++ noun req
--
++ grab
|%
++ noun ,[dock dock ?]
++ json
=, dejs:format
%- ot
:~ [%old (ot ship+(se %p) desk+so ~)]
[%new (ot ship+(se %p) desk+so ~)]
[%yea bo]
==
--
++ grad %noun
--

View File

@ -0,0 +1,43 @@
::
:::: /hoon/jump/kiln/mar
::
/- h=hood
|_ jum=jump:h
::
++ grow
|%
++ noun jum
++ json
=, enjs:format
|^ ^- ^json
?- -.jum
%add
%+ frond 'add'
(pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~)
::
%yea
%+ frond 'yea'
(pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~)
::
%nay
%+ frond 'nay'
(pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~)
::
%all
%+ frond 'all'
:- %a
%+ turn ~(tap by all.jum)
|= [old=dock new=dock]
(pairs ['old' (en-dock old)] ['new' (en-dock new)] ~)
==
++ en-dock
|= =dock
(pairs ['ship' s+(scot %p p.dock)] ['desk' s+q.dock] ~)
--
--
++ grab
|%
++ noun jump:h
--
++ grad %noun
--

View File

@ -0,0 +1,50 @@
::
:::: /hoon/sync-update/kiln/mar
::
/- h=hood
|_ upd=sync-update:h
::
++ grow
|%
++ noun upd
++ json
=, enjs:format
|^ ^- ^json
?- -.upd
%new
%+ frond 'new'
(pairs ['for' (en-sync-record for.upd)] ['rev' (numb rev.upd)] ~)
::
%done
%+ frond 'done'
(pairs ['for' (en-sync-record for.upd)] ['rev' (numb rev.upd)] ~)
::
%drop
%+ frond 'drop'
(pairs ['for' (en-sync-record for.upd)] ['rev' (numb rev.upd)] ~)
::
%pending
%+ frond 'pending'
:- %a
%+ turn ~(tap by pending.upd)
|= [for=sync-record:h rev=@ud]
%- pairs
:~ ['for' (en-sync-record for)]
['rev' (numb rev)]
==
==
++ en-sync-record
|= sync-record:h
%- pairs
:~ ['syd' s+syd]
['her' s+(scot %p her)]
['sud' s+sud]
==
--
--
++ grab
|%
++ noun sync-update:h
--
++ grad %noun
--

View File

@ -0,0 +1,15 @@
/- verb
/+ verb-json
|_ =event-plus:verb
++ grad %noun
++ grab
|%
++ noun event-plus:verb
--
::
++ grow
|%
++ noun event-plus
++ json (event:enjs:verb-json event-plus)
--
--

View File

@ -41,7 +41,7 @@
[%pause-events who=ship] [%pause-events who=ship]
[%snap-ships lab=term hers=(list ship)] [%snap-ships lab=term hers=(list ship)]
[%restore-snap lab=term] [%restore-snap lab=term]
[%read [from=ship =path] [for=lane:ames num=@ud]] [%read [from=[=ship life=@ubC] =path] for=[=lane:ames life=@ubC] num=@ud]
[%event who=ship ue=unix-event] [%event who=ship ue=unix-event]
== ==
:: ::
@ -82,5 +82,10 @@
[%kill ~] [%kill ~]
[%init ~] [%init ~]
[%request id=@ud request=request:http] [%request id=@ud request=request:http]
[%turf p=(list turf)]
:: XX effects seen after running :aqua [%swap-files ~]
[%vega ~]
[%set-config =http-config:eyre]
[%sessions p=(set @t)]
== ==
-- --

View File

@ -10,12 +10,41 @@
== ==
:: ::
+$ pikes (map desk pike) +$ pikes (map desk pike)
:: :: $jump: changes to update source change requests
::
+$ jump
$% [%all all=(map dock dock)] :: pending requests
[%add old=dock new=dock] :: new request
[%yea old=dock new=dock] :: approved
[%nay old=dock new=dock] :: denied
==
:: $rung: reference to upstream commit :: $rung: reference to upstream commit
:: ::
+$ rung [=aeon =weft] +$ rung [=aeon =weft]
:: #sync-record: source and destination of a kiln sync
::
+$ sync-record ::
$: syd=desk :: local desk
her=ship :: foreign ship
sud=desk :: foreign desk
==
::
+$ sync-state ::
$: nun=@ta :: nonce
kid=(unit desk) :: has kids desk too?
let=@ud :: next revision
nit=(unit ?) :: automerge or default
hav=(unit @ud) :: update available
yea=? :: update approved
==
::
+$ sync-update
$% [%new for=sync-record rev=@ud]
[%done for=sync-record rev=@ud]
[%drop for=sync-record rev=@ud]
[%pending pending=(set [for=sync-record rev=@ud])]
==
:: ::
+$ sync-state [nun=@ta kid=(unit desk) let=@ud]
+$ sink (unit [her=@p sud=desk kid=(unit desk) let=@ud]) +$ sink (unit [her=@p sud=desk kid=(unit desk) let=@ud])
:: +truncate-hash: get last 5 digits of hash and convert to tape :: +truncate-hash: get last 5 digits of hash and convert to tape
:: ::
@ -30,7 +59,7 @@
=/ ego (scot %p our) =/ ego (scot %p our)
=/ wen (scot %da now) =/ wen (scot %da now)
:* .^(rock:tire %cx /[ego]//[wen]/tire) :* .^(rock:tire %cx /[ego]//[wen]/tire)
.^(=cone %cx /[ego]//[wen]/domes) .^(cone %cx /[ego]//[wen]/domes)
.^((map desk [ship desk]) %gx /[ego]/hood/[wen]/kiln/sources/noun) .^((map desk [ship desk]) %gx /[ego]/hood/[wen]/kiln/sources/noun)
.^ (map [desk ship desk] sync-state) %gx .^ (map [desk ship desk] sync-state) %gx
/[ego]/hood/[wen]/kiln/syncs/noun /[ego]/hood/[wen]/kiln/syncs/noun
@ -43,44 +72,73 @@
^- tang ^- tang
=/ ego (scot %p our) =/ ego (scot %p our)
=/ wen (scot %da now) =/ wen (scot %da now)
=/ prep (report-prep our now) =+ prep=[tyr cone sor zyn]=(report-prep our now)
?~ filt ?: =(%$ filt)
%- zing %- zing
%+ turn (flop desks) %+ turn
?^ desks
(flop desks)
%+ sort ~(tap in ~(key by tyr.prep))
|= [a=desk b=desk]
?: |(=(a %kids) =(b %base)) &
?: |(=(a %base) =(b %kids)) |
(aor b a)
|=(syd=@tas (report-vat prep our now syd verb)) |=(syd=@tas (report-vat prep our now syd verb))
=/ deks =/ deks=(list [=desk =zest wic=(set weft)])
?~ desks ?~ desks
%+ sort %+ sort ~(tap by tyr.prep)
(sort ~(tap by -.prep) |=([[a=@ *] b=@ *] !(aor a b))) |= [[a=desk *] [b=desk *]]
|=([[a=@ *] [b=@ *]] ?|(=(a %kids) =(b %base))) ?: |(=(a %kids) =(b %base)) &
%+ skip ~(tap by -.prep) ?: |(=(a %base) =(b %kids)) |
|=([syd=@tas *] =(~ (find ~[syd] desks))) (aor b a)
=. deks (skim deks |=([=desk *] ((sane %tas) desk))) %+ murn (flop desks)
|= des=desk
^- (unit [=desk =zest wic=(set weft)])
?~ got=(~(get by tyr.prep) des)
~
`[des u.got]
?: =(filt %blocking) ?: =(filt %blocking)
=/ base-wic =/ base-weft=(unit weft)
%+ sort ~(tap by wic:(~(got by -.prep) %base)) %- ~(rep in wic:(~(got by tyr.prep) %base))
|=([[* a=@ud] [* b=@ud]] (gth a b)) |= [=weft out=(unit weft)]
?~ base-wic ~[leaf+"%base already up-to-date"] ?~ out
`weft
?: (lth num.weft num.u.out)
out
`weft
?~ base-weft ~['%base already up-to-date']
=/ blockers=(list desk) =/ blockers=(list desk)
%+ turn %+ sort
%+ skip ~(tap in -.prep) ^- (list desk)
|= [* [zest=@tas wic=(set weft)]] %+ murn deks
?. =(zest %live) & |= [=desk =zest wic=(set weft)]
(~(has in wic) i.base-wic) ^- (unit ^desk)
|=([syd=desk *] syd) ?. =(%live zest)
?~ blockers ~[leaf+"No desks blocking upgrade, run |bump to apply"] ~
:- [%rose [" %" "To unblock upgrade run |suspend %" ""] blockers] ?: (~(has in wic) u.base-weft)
~
`desk
aor
?~ blockers ~['No desks blocking upgrade']
%- zing %- zing
%+ turn (flop blockers) ^- (list tang)
:- :~ %+ rap 3
:~ 'These desks are blocking upgrade to [%zuse '
(scot %ud num.u.base-weft)
']:'
== ==
%+ turn blockers
|=(syd=desk (report-vat prep our now syd verb)) |=(syd=desk (report-vat prep our now syd verb))
:: ::
%- zing %- zing
%+ turn %+ turn
?+ filt !! ?+ filt !!
::
%exists %exists
%+ skip deks %+ skip deks
|=([syd=desk *] =(ud:.^(cass %cw /[ego]/[syd]/[wen]) 0)) |= [syd=desk *]
?~ got=(~(get by cone.prep) our syd)
&
=(0 let.u.got)
:: ::
%running %running
%+ skim deks %+ skim deks
@ -91,103 +149,143 @@
|= [syd=@tas [zest=@tas *]] |= [syd=@tas [zest=@tas *]]
?| =(syd %kids) ?| =(syd %kids)
=(zest %live) =(zest %live)
=(ud:.^(cass %cw /[ego]/[syd]/[wen]) 0) ?~ got=(~(get by cone.prep) our syd)
&
=(0 let.u.got)
== ==
:: ::
%exists-not %exists-not
%+ skim deks %+ skim deks
|=([syd=desk *] =(ud:.^(cass %cw /[ego]/[syd]/[wen]) 0)) |= [syd=desk *]
?~ got=(~(get by cone.prep) our syd)
|
=(0 let.u.got)
== ==
|=([syd=desk *] (report-vat prep our now syd verb)) |=([syd=desk *] (report-vat prep our now syd verb))
:: +report-vat: report on a single desk installation :: +report-vat: report on a single desk installation
:: ::
++ report-vat ++ report-vat
|= $: $: tyr=rock:tire =cone sor=(map desk [ship desk]) |= $: $: tyr=rock:tire =cone sor=(map desk (pair ship desk))
zyn=(map [desk ship desk] sync-state) zyn=(map [desk ship desk] sync-state)
== ==
our=ship now=@da syd=desk verb=? our=ship now=@da syd=desk verb=?
== ==
^- tang |^ ^- tang
=- :: hack to force wrapped rendering
::
:: edg=6 empirically prevents dedent
::
%+ roll
(~(win re -) [0 6])
|=([a=tape b=(list @t)] [(crip a) b])
::
^- tank
=/ ego (scot %p our) =/ ego (scot %p our)
=/ wen (scot %da now) =/ wen (scot %da now)
?. ((sane %tas) syd) ?. ((sane %tas) syd)
leaf+"insane desk: {<syd>}" ~[(cat 3 'insane desk: %' syd)]
=+ .^(=cass %cw /[ego]/[syd]/[wen]) ?. (~(has by cone) our syd)
?: =(ud.cass 0) ~[(cat 3 'desk does not yet exist: %' syd)]
leaf+"desk does not yet exist: {<syd>}"
?: =(%kids syd)
=+ .^(hash=@uv %cz /[ego]/[syd]/[wen])
leaf+"%kids %cz hash: {<hash>}"
=/ kel-path
/[ego]/[syd]/[wen]/sys/kelvin
?. .^(? %cu kel-path)
leaf+"bad desk: {<syd>}"
=+ .^(=waft %cx kel-path)
:+ %rose ["" "{<syd>}" "::"]
^- tang
=/ hash .^(@uv %cz /[ego]/[syd]/[wen]) =/ hash .^(@uv %cz /[ego]/[syd]/[wen])
?: =(%kids syd)
~[(cat 3 '%kids %cz hash: ' (scot %uv hash))]
=/ kel-path /[ego]/[syd]/[wen]/sys/kelvin
?. .^(? %cu kel-path)
~[(cat 3 'bad desk: %' syd)]
=+ .^(=waft %cx kel-path)
^- tang
=/ =sink =/ =sink
?~ s=(~(get by sor) syd) ?~ s=(~(get by sor) syd)
~ ~
?~ z=(~(get by zyn) syd u.s) ?~ z=(~(get by zyn) syd u.s)
~ ~
`[-.u.s +.u.s +.u.z] `[p.u.s q.u.s [kid let]:u.z]
=/ meb=(list @uv) =/ meb=(list @uv)
?~ sink [hash]~ ?~ sink ~[hash]
(mergebase-hashes our syd now her.u.sink sud.u.sink) %+ turn
.^ (list tako) %cs
/[ego]/[syd]/[wen]/base/(scot %p her.u.sink)/[sud.u.sink]
==
|=(=tako .^(@uv %cs /[ego]/[syd]/[wen]/hash/(scot %uv tako)))
=/ dek (~(got by tyr) syd) =/ dek (~(got by tyr) syd)
=/ sat =/ sat
?- zest.dek ?- zest.dek
%live "running" %live 'running'
%dead "suspended" %dead 'suspended'
%held "suspended until next update" %held 'suspended until next update'
== ==
=/ kul=tape =/ kul=cord (print-wefts (waft-to-wefts waft))
%+ roll
%+ sort
~(tap in (waft-to-wefts:clay waft))
|= [a=weft b=weft]
?: =(lal.a lal.b)
(lte num.a num.b)
(lte lal.a lal.b)
|= [=weft =tape]
(welp " {<[lal num]:weft>}" tape)
?. verb ?. verb
:~ leaf/"/sys/kelvin: {kul}" :~ '::'
leaf/"%cz hash ends in: {(truncate-hash hash)}" (cat 3 ' pending updates: ' (print-wefts wic.dek))
leaf/"app status: {sat}" (cat 3 ' source ship: ' ?~(sink '~' (scot %p her.u.sink)))
leaf/"source ship: {?~(sink <~> <her.u.sink>)}" (cat 3 ' app status: ' sat)
leaf/"pending updates: {<`(list [@tas @ud])`~(tap in wic.dek)>}" (cat 3 ' %cz hash ends in: ' (print-shorthash hash))
(cat 3 ' /sys/kelvin: ' (print-wefts (waft-to-wefts waft)))
(cat 3 '%' syd)
== ==
:: ::
=/ [on=(list [@tas ?]) of=(list [@tas ?])] =/ [on=(list @tas) of=(list @tas)]
=/ =dome (~(got by cone) our syd) =/ [on=(list @tas) of=(list @tas)]
(skid ~(tap by ren.dome) |=([* ?] +<+)) %- ~(rep by ren:(~(got by cone) our syd))
:~ leaf/"/sys/kelvin: {kul}" |= [[=dude:gall is-on=?] on=(list @tas) of=(list @tas)]
leaf/"base hash: {?.(=(1 (lent meb)) <meb> <(head meb)>)}" ?: is-on
leaf/"%cz hash: {<hash>}" [[dude on] of]
:: [on [dude of]]
leaf/"app status: {sat}" [(sort on aor) (sort of aor)]
leaf/"force on: {<(sort (turn on head) aor)>}" :~ '::'
leaf/"force off: {<(sort (turn of head) aor)>}" (cat 3 ' pending updates: ' (print-wefts wic.dek))
:: %^ cat 3 ' kids desk: ' ?~ sink '~'
leaf/"publishing ship: {?~(sink <~> <(get-publisher our syd now)>)}" ?~ kid.u.sink '~'
leaf/"updates: {?~(sink "local" "remote")}" (cat 3 '%' u.kid.u.sink)
leaf/"source ship: {?~(sink <~> <her.u.sink>)}" (cat 3 ' source aeon: ' ?~(sink '~' (scot %ud let.u.sink)))
leaf/"source desk: {?~(sink <~> <sud.u.sink>)}" (cat 3 ' source desk: ' ?~(sink '~' (cat 3 '%' sud.u.sink)))
leaf/"source aeon: {?~(sink <~> <let.u.sink>)}" (cat 3 ' source ship: ' ?~(sink '~' (scot %p her.u.sink)))
leaf/"kids desk: {?~(sink <~> ?~(kid.u.sink <~> <u.kid.u.sink>))}" (cat 3 ' updates: ' ?~(sink 'local' 'remote'))
leaf/"pending updates: {<`(list [@tas @ud])`~(tap in wic.dek)>}" %^ cat 3 ' publishing ship: ' ?~ got=(get-publisher our syd now)
'~'
(scot %p u.got)
::
(cat 3 ' force off: ' (print-agents of))
(cat 3 ' force on: ' (print-agents on))
(cat 3 ' app status: ' sat)
::
(cat 3 ' %cz hash: ' (scot %uv hash))
(cat 3 ' base hash: ' (print-mergebases meb))
(cat 3 ' /sys/kelvin: ' (print-wefts (waft-to-wefts waft)))
(cat 3 '%' syd)
== ==
++ print-wefts
|= wefts=(set weft)
^- @t
?: =(~ wefts)
'~'
%+ roll (sort ~(tap in wefts) aor)
|= [=weft out=@t]
?: =('' out)
(rap 3 '[%' lal.weft ' ' (scot %ud num.weft) ']' ~)
(rap 3 out ' [%' lal.weft ' ' (scot %ud num.weft) ']' ~)
::
++ print-shorthash
|= hash=@uv
^- @t
(crip ((v-co:co 5) (end [0 25] hash)))
::
++ print-mergebases
|= hashes=(list @uv)
^- @t
?~ hashes
'~'
?~ t.hashes
(scot %uv i.hashes)
%+ roll `(list @uv)`hashes
|= [hash=@uv out=@t]
?: =('' out)
(print-shorthash hash)
(rap 3 out ' ' (print-shorthash hash) ~)
::
++ print-agents
|= agents=(list @tas)
^- @t
?~ agents
'~'
%+ roll `(list @tas)`agents
|= [agent=@tas out=@tas]
?: =('' out)
(cat 3 '%' agent)
(rap 3 out ' %' agent ~)
--
:: +report-kids: non-vat cz hash report for kids desk :: +report-kids: non-vat cz hash report for kids desk
:: ::
++ report-kids ++ report-kids
@ -197,9 +295,9 @@
=/ ego (scot %p our) =/ ego (scot %p our)
=/ wen (scot %da now) =/ wen (scot %da now)
?. (~(has in .^((set desk) %cd /[ego]//[wen])) syd) ?. (~(has in .^((set desk) %cd /[ego]//[wen])) syd)
leaf/"no %kids desk" 'no %kids desk'
=+ .^(hash=@uv %cz /[ego]/[syd]/[wen]) =+ .^(hash=@uv %cz /[ego]/[syd]/[wen])
leaf/"%kids %cz hash: {<hash>}" (cat 3 '%kids %cz hash: ' (scot %uv hash))
:: +read-bill-foreign: read /desk/bill from a foreign desk :: +read-bill-foreign: read /desk/bill from a foreign desk
:: ::
++ read-bill-foreign ++ read-bill-foreign
@ -259,8 +357,8 @@
=/ her (scot %p her) =/ her (scot %p her)
=/ ego (scot %p our) =/ ego (scot %p our)
=/ wen (scot %da now) =/ wen (scot %da now)
%+ turn .^((list tako) %cs ~[ego syd wen %base her sud]) %+ turn .^((list tako) %cs /[ego]/[syd]/[wen]/base/[her]/[sud])
|=(=tako .^(@uv %cs ~[ego syd wen %hash (scot %uv tako)])) |=(=tako .^(@uv %cs /[ego]/[syd]/[wen]/hash/(scot %uv tako)))
:: ::
++ enjs ++ enjs
=, enjs:format =, enjs:format

View File

@ -9,4 +9,40 @@
[%on-arvo =wire vane=term sign=term] [%on-arvo =wire vane=term sign=term]
[%on-fail =term] [%on-fail =term]
== ==
-- ::
+$ event-plus
$: act=@ud
now=@da
src=@p
sap=path
=cause
effects=(list effect)
==
::
+$ cause
$% [%on-init ~]
[%on-load ~]
[%on-poke =mark mug=@ux]
[%on-watch =path]
[%on-leave =path]
[%on-agent =wire =sign]
[%on-arvo =wire vane=term sign=term]
[%on-fail =term]
==
::
+$ sign
$% [%poke-ack ack=?]
[%watch-ack ack=?]
[%kick ~]
[%fact =mark mug=@ux]
==
::
+$ effect
$% [%poke =wire =gill:gall =mark mug=@ux]
[%watch =wire =gill:gall =path]
[%leave =wire =gill:gall]
[%fact paths=(list path) =mark mug=@ux]
[%kick paths=(list path)]
[%arvo =wire vane=term task=term]
==
--

View File

@ -1,183 +0,0 @@
var gulp = require('gulp');
var cssimport = require('gulp-cssimport');
var rollup = require('gulp-better-rollup');
var cssnano = require('cssnano');
var postcss = require('gulp-postcss');
var sucrase = require('@sucrase/gulp-plugin');
var minify = require('gulp-minify');
var rename = require('gulp-rename');
var del = require('del');
var resolve = require('rollup-plugin-node-resolve');
var commonjs = require('rollup-plugin-commonjs');
var rootImport = require('rollup-plugin-root-import');
var globals = require('rollup-plugin-node-globals');
/***
Main config options
***/
var urbitrc = require('../urbitrc');
/***
End main config options
***/
gulp.task('css-bundle', function() {
let plugins = [
cssnano()
];
return gulp
.src('src/index.css')
.pipe(cssimport())
.pipe(postcss(plugins))
.pipe(gulp.dest('../../arvo/app/debug/css'));
});
gulp.task('jsx-transform', function(cb) {
return gulp.src('src/**/*.js')
.pipe(sucrase({
transforms: ['jsx']
}))
.pipe(gulp.dest('dist'));
});
gulp.task('tile-jsx-transform', function(cb) {
return gulp.src('tile/**/*.js')
.pipe(sucrase({
transforms: ['jsx']
}))
.pipe(gulp.dest('dist'));
});
gulp.task('js-imports', function(cb) {
return gulp.src('dist/index.js')
.pipe(rollup({
plugins: [
commonjs({
namedExports: {
'node_modules/react/index.js': [ 'Component', 'createRef', 'createElement', 'useState', 'useRef', 'useEffect', 'Fragment' ],
'node_modules/react-is/index.js': [ 'isValidElementType' ],
}
}),
rootImport({
root: `${__dirname}/dist/js`,
useEntry: 'prepend',
extensions: '.js'
}),
globals(),
resolve()
]
}, 'umd'))
.on('error', function(e){
console.log(e);
cb();
})
.pipe(gulp.dest('../../arvo/app/debug/js/'))
.on('end', cb);
});
gulp.task('tile-js-imports', function(cb) {
return gulp.src('dist/tile.js')
.pipe(rollup({
plugins: [
commonjs({
namedExports: {
'node_modules/react/index.js': [ 'Component' ],
}
}),
rootImport({
root: `${__dirname}/dist/js`,
useEntry: 'prepend',
extensions: '.js'
}),
globals(),
resolve()
]
}, 'umd'))
.on('error', function(e){
console.log(e);
cb();
})
.pipe(gulp.dest('../../arvo/app/debug/js/'))
.on('end', cb);
});
gulp.task('js-minify', function () {
return gulp.src('../../arvo/app/debug/js/index.js')
.pipe(minify())
.pipe(gulp.dest('../../arvo/app/debug/js/'));
});
gulp.task('tile-js-minify', function () {
return gulp.src('../../arvo/app/debug/js/tile.js')
.pipe(minify())
.pipe(gulp.dest('../../arvo/app/debug/js/'));
});
gulp.task('rename-index-min', function() {
return gulp.src('../../arvo/app/debug/js/index-min.js')
.pipe(rename('index.js'))
.pipe(gulp.dest('../../arvo/app/debug/js/'))
});
gulp.task('rename-tile-min', function() {
return gulp.src('../../arvo/app/debug/js/tile-min.js')
.pipe(rename('tile.js'))
.pipe(gulp.dest('../../arvo/app/debug/js/'))});
gulp.task('clean-min', function() {
return del(['../../arvo/app/debug/js/index-min.js', '../../arvo/app/debug/js/tile-min.js'], {force: true})
});
gulp.task('urbit-copy', function () {
let ret = gulp.src('../../arvo/**/*');
urbitrc.URBIT_PIERS.forEach(function(pier) {
ret = ret.pipe(gulp.dest(pier));
});
return ret;
});
gulp.task('js-bundle-dev', gulp.series('jsx-transform', 'js-imports'));
gulp.task('tile-js-bundle-dev', gulp.series('tile-jsx-transform', 'tile-js-imports'));
gulp.task('js-bundle-prod', gulp.series('jsx-transform', 'js-imports', 'js-minify'))
gulp.task('tile-js-bundle-prod',
gulp.series('tile-jsx-transform', 'tile-js-imports', 'tile-js-minify'));
gulp.task('bundle-dev',
gulp.series(
gulp.parallel(
'css-bundle',
'js-bundle-dev',
'tile-js-bundle-dev'
),
'urbit-copy'
)
);
gulp.task('bundle-prod',
gulp.series(
gulp.parallel(
'css-bundle',
'js-bundle-prod',
'tile-js-bundle-prod',
),
'rename-index-min',
'rename-tile-min',
'clean-min',
'urbit-copy'
)
);
gulp.task('default', gulp.series('bundle-dev'));
gulp.task('watch', gulp.series('default', function() {
gulp.watch('tile/**/*.js', gulp.parallel('tile-js-bundle-dev'));
gulp.watch('src/**/*.js', gulp.parallel('js-bundle-dev'));
gulp.watch('src/**/*.css', gulp.parallel('css-bundle'));
gulp.watch('../../arvo/**/*', gulp.parallel('urbit-copy'));
}));

View File

@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Debug Dashboard</title>
<style type="text/css" src="/src/index.css"></style>
</head>
<body>
<div id="root"></div>
<script src="/~debug/channel.js"></script>
<script src="/~debug/js/session.js"></script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

Binary file not shown.

View File

@ -1,43 +1,32 @@
{ {
"name": "urbit-apps", "name": "debug-dashboard",
"version": "1.0.0", "private": true,
"description": "", "version": "2.0.0",
"main": "index.js", "type": "module",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "dev": "vite",
}, "build": "tsc && vite build",
"author": "", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"license": "ISC", "preview": "vite preview"
"devDependencies": {
"@sucrase/gulp-plugin": "^2.0.0",
"cssnano": "^4.1.10",
"gulp": "^4.0.0",
"gulp-better-rollup": "^4.0.1",
"gulp-cssimport": "^7.0.0",
"gulp-minify": "^3.1.0",
"gulp-postcss": "^8.0.0",
"gulp-rename": "^1.4.0",
"moment": "^2.24.0",
"rollup": "^1.6.0",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-root-import": "^0.2.3",
"sucrase": "^3.8.0"
}, },
"dependencies": { "dependencies": {
"@gitgraph/react": "^1.5.4", "@gitgraph/react": "^1.6.0",
"classnames": "^2.2.6", "file-system-access": "^1.0.4",
"del": "^5.1.0", "lodash": "^4.17.21",
"lodash": "^4.17.11", "react": "^18.2.0",
"mousetrap": "^1.6.3", "react-dom": "^18.2.0",
"react": "^16.5.2", "urbit-ob": "^5.0.1"
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.0",
"urbit-ob": "^5.0.0",
"urbit-sigil-js": "^1.3.2"
}, },
"resolutions": { "devDependencies": {
"natives": "1.1.3" "@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"typescript": "^5.2.2",
"vite": "^5.2.0"
} }
} }

View File

@ -0,0 +1,292 @@
class Channel {
constructor() {
this.init();
this.deleteOnUnload();
// a way to handle channel errors
//
//
this.onChannelError = (err) => {
console.error('event source error: ', err);
};
this.onChannelOpen = (e) => {
console.log('open', e);
};
}
init() {
this.debounceInterval = 500;
// unique identifier: current time and random number
//
this.uid =
new Date().getTime().toString() +
"-" +
Math.random().toString(16).slice(-6);
this.requestId = 1;
// the currently connected EventSource
//
this.eventSource = null;
// the id of the last EventSource event we received
//
this.lastEventId = 0;
// this last event id acknowledgment sent to the server
//
this.lastAcknowledgedEventId = 0;
// a registry of requestId to successFunc/failureFunc
//
// These functions are registered during a +poke and are executed
// in the onServerEvent()/onServerError() callbacks. Only one of
// the functions will be called, and the outstanding poke will be
// removed after calling the success or failure function.
//
this.outstandingPokes = new Map();
// a registry of requestId to subscription functions.
//
// These functions are registered during a +subscribe and are
// executed in the onServerEvent()/onServerError() callbacks. The
// event function will be called whenever a new piece of data on this
// subscription is available, which may be 0, 1, or many times. The
// disconnect function may be called exactly once.
//
this.outstandingSubscriptions = new Map();
this.outstandingJSON = [];
this.debounceTimer = null;
}
resetDebounceTimer() {
if (this.debounceTimer) {
clearTimeout(this.debounceTimer);
this.debounceTimer = null;
}
this.debounceTimer = setTimeout(() => {
this.sendJSONToChannel();
}, this.debounceInterval)
}
setOnChannelError(onError = (err) => {}) {
this.onChannelError = onError;
}
setOnChannelOpen(onOpen = (e) => {}) {
this.onChannelOpen = onOpen;
}
deleteOnUnload() {
window.addEventListener("beforeunload", (event) => {
this.delete();
});
}
clearQueue() {
clearTimeout(this.debounceTimer);
this.debounceTimer = null;
this.sendJSONToChannel();
}
// sends a poke to an app on an urbit ship
//
poke(ship, app, mark, json, successFunc, failureFunc) {
let id = this.nextId();
this.outstandingPokes.set(
id,
{
success: successFunc,
fail: failureFunc
}
);
const j = {
id,
action: "poke",
ship,
app,
mark,
json
};
this.sendJSONToChannel(j);
}
// subscribes to a path on an specific app and ship.
//
// Returns a subscription id, which is the same as the same internal id
// passed to your Urbit.
subscribe(
ship,
app,
path,
connectionErrFunc = () => {},
eventFunc = () => {},
quitFunc = () => {},
subAckFunc = () => {},
) {
let id = this.nextId();
this.outstandingSubscriptions.set(
id,
{
err: connectionErrFunc,
event: eventFunc,
quit: quitFunc,
subAck: subAckFunc
}
);
const json = {
id,
action: "subscribe",
ship,
app,
path
}
this.resetDebounceTimer();
this.outstandingJSON.push(json);
return id;
}
// quit the channel
//
delete() {
let id = this.nextId();
clearInterval(this.ackTimer);
navigator.sendBeacon(this.channelURL(), JSON.stringify([{
id,
action: "delete"
}]));
if (this.eventSource) {
this.eventSource.close();
}
}
// unsubscribe to a specific subscription
//
unsubscribe(subscription) {
let id = this.nextId();
this.sendJSONToChannel({
id,
action: "unsubscribe",
subscription
});
}
// sends a JSON command command to the server.
//
sendJSONToChannel(j) {
let req = new XMLHttpRequest();
req.open("PUT", this.channelURL());
req.setRequestHeader("Content-Type", "application/json");
if (this.lastEventId == this.lastAcknowledgedEventId) {
if (j) {
this.outstandingJSON.push(j);
}
if (this.outstandingJSON.length > 0) {
let x = JSON.stringify(this.outstandingJSON);
req.send(x);
}
} else {
// we add an acknowledgment to clear the server side queue
//
// The server side puts messages it sends us in a queue until we
// acknowledge that we received it.
//
let payload = [
...this.outstandingJSON,
{action: "ack", "event-id": this.lastEventId}
];
if (j) {
payload.push(j)
}
let x = JSON.stringify(payload);
req.send(x);
this.lastAcknowledgedEventId = this.lastEventId;
}
this.outstandingJSON = [];
this.connectIfDisconnected();
}
// connects to the EventSource if we are not currently connected
//
connectIfDisconnected() {
if (this.eventSource) {
return;
}
this.eventSource = new EventSource(this.channelURL(), {withCredentials:true});
this.eventSource.onmessage = e => {
this.lastEventId = parseInt(e.lastEventId, 10);
let obj = JSON.parse(e.data);
let pokeFuncs = this.outstandingPokes.get(obj.id);
let subFuncs = this.outstandingSubscriptions.get(obj.id);
if (obj.response == "poke" && !!pokeFuncs) {
let funcs = pokeFuncs;
if (obj.hasOwnProperty("ok")) {
funcs["success"]();
} else if (obj.hasOwnProperty("err")) {
funcs["fail"](obj.err);
} else {
console.error("Invalid poke response: ", obj);
}
this.outstandingPokes.delete(obj.id);
} else if (obj.response == "subscribe" ||
(obj.response == "poke" && !!subFuncs)) {
let funcs = subFuncs;
if (obj.hasOwnProperty("err")) {
funcs["err"](obj.err);
this.outstandingSubscriptions.delete(obj.id);
} else if (obj.hasOwnProperty("ok")) {
funcs["subAck"](obj);
}
} else if (obj.response == "diff") {
// ensure we ack before channel clogs
if((this.lastEventId - this.lastAcknowledgedEventId) > 30) {
this.clearQueue();
}
let funcs = subFuncs;
funcs["event"](obj.json);
} else if (obj.response == "quit") {
let funcs = subFuncs;
funcs["quit"](obj);
this.outstandingSubscriptions.delete(obj.id);
} else {
console.log("Unrecognized response: ", e);
}
}
this.eventSource.onopen = this.onChannelOpen;
this.eventSource.onerror = e => {
this.delete();
this.init();
this.onChannelError(e);
}
}
channelURL() {
return "/~/channel/" + this.uid;
}
nextId() {
return this.requestId++;
}
}
window.channel = Channel;

View File

@ -3,6 +3,7 @@ html, body {
width: 100%; width: 100%;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
overflow: hidden; overflow: hidden;
background-color: white;
} }
p, h1, h2, h3, h4, h5, h6, a, input, textarea, button { p, h1, h2, h3, h4, h5, h6, a, input, textarea, button {

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,73 @@
#viewport {
position: relative;
width: 100%;
padding-top: 1em;
border: 1px solid black;
font-family: monospace;
}
#controls input {
width: 100%;
}
.agent {
position: relative;
padding-left: 1em;
width: calc(100% - 1em);
border-top: 2px solid black;
margin-top: 2em;
}
.cause {
position: relative;
width: 100%;
height: 5em;
border-top: 1px solid grey;
}
.legend {
position: absolute;
left: -1em;
width: auto;
height: auto;
text-orientation: sideways;
writing-mode: vertical-rl;
text-wrap: nowrap;
}
.event {
position: absolute;
width: 1em;
height: 1em;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.2);
border: 1px dotted rgba(0,0,0,0);
}
.event.effects {
border-style: solid;
}
.details {
padding: 0.3em;
display: none;
position: absolute;
top: 0.75em;
left: 0.75em;
z-index: 2;
min-width: 20em;
display: none;
overflow: visible;
border: 1px solid black;
background-color: white;
}
.event.right .details {
left: initial;
right: 0.75em;
}
.event:hover .details, .event.focus .details {
display: block;
}
.event:hover, .event.focus {
box-shadow: 0 0 10px 0 #f30;
}
.event details {
padding-left: 1em;
}
.event details summary {
position: relative;
left: -1em;
}

View File

@ -1,4 +1,4 @@
@import "css/indigo-static.css"; @import "css/indigo-static.css";
@import "css/fonts.css"; @import "css/fonts.css";
@import "css/custom.css"; @import "css/custom.css";
@import "css/logs.css";

View File

@ -1,17 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Root } from '/components/root';
import { api } from '/api';
import { store } from '/store';
import { subscription } from "/subscription";
api.setAuthTokens({
ship: window.ship
});
window.urb = new window.channel();
subscription.start();
ReactDOM.render((
<Root />
), document.querySelectorAll("#root")[0]);

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import _ from 'lodash'; import _ from 'lodash';
import { store } from '/store'; import { store } from './store';
import moment from 'moment'; import moment from 'moment';
import { stringToTa } from './lib/util'; import { stringToTa } from './lib/util';
@ -72,6 +72,42 @@ class UrbitApi {
); );
} }
bindToVerbPlus(app) {
return this.bind('/verb/events-plus', 'PUT', this.authTokens.ship, app,
(result) => {
result.data.app = app;
store.handleEvent({ data: { local: { verbEventPlus: {
gill: `~${this.authTokens.ship}/${app}`,
log: result.data
} } } });
},
() => {
store.handleEvent({
data: {
local: {
verbStatus: {
app: app,
msg: 'failed to establish verb+ connection to ' + app
}
}
}
});
},
() => {
store.handleEvent({
data: {
local: {
verbStatus: {
app: app,
msg: 'verb+ connection to ' + app + ' was dropped'
}
}
}
});
}
);
}
getJson(path, localTransform, onFail) { getJson(path, localTransform, onFail) {
let source = '/~debug' + path + '.json'; let source = '/~debug' + path + '.json';
const query = window.location.href.split('?')[1]; const query = window.location.href.split('?')[1];
@ -201,6 +237,13 @@ class UrbitApi {
); );
} }
getCache() {
this.getJson('/eyre/cache',
this.wrapLocal('eyreCache'),
this.showStatus('error fetching eyre cache')
);
}
getConnections() { getConnections() {
this.getJson('/eyre/connections', this.getJson('/eyre/connections',
this.wrapLocal('eyreConnections'), this.wrapLocal('eyreConnections'),
@ -222,6 +265,11 @@ class UrbitApi {
); );
} }
clearCache(url) {
return this.action("dbug", "json", { 'clear-eyre-cache': { url: url } })
.then(this.getCache.bind(this));
}
// local // local
sidebarToggle() { sidebarToggle() {

View File

@ -3,17 +3,18 @@ import { BrowserRouter, Switch, Route, Link } from "react-router-dom";
import classnames from 'classnames'; import classnames from 'classnames';
import _ from 'lodash'; import _ from 'lodash';
import { api } from '/api'; import { api } from '../api';
import { subscription } from '/subscription'; import { subscription } from '../subscription';
import { store } from '/store'; import { store } from '../store';
import { Skeleton } from '/components/skeleton'; import { Skeleton } from '../components/skeleton';
import { MessageScreen } from '/components/message-screen'; import { MessageScreen } from '../components/message-screen';
import { Apps } from '/views/apps'; import { Apps } from '../views/apps';
import { Spider } from '/views/spider'; import { Logs } from '../views/logs';
import { Ames } from '/views/ames'; import { Spider } from '../views/spider';
import { Behn } from '/views/behn'; import { Ames } from '../views/ames';
import { Clay } from '/views/clay'; import { Behn } from '../views/behn';
import { Eyre } from '/views/eyre'; import { Clay } from '../views/clay';
import { Eyre } from '../views/eyre';
import { makeRoutePath } from '../lib/util'; import { makeRoutePath } from '../lib/util';
export class Root extends Component { export class Root extends Component {
@ -54,6 +55,16 @@ export class Root extends Component {
}} }}
/> />
<Route exact path={makeRoutePath('logs')}
render={(props) => {
return (
<Skeleton status={state.status} selected="logs">
<Logs logs={state.logs} {...props} />
</Skeleton>
);
}}
/>
<Route exact path={makeRoutePath('spider')} <Route exact path={makeRoutePath('spider')}
render={(props) => { render={(props) => {
return ( return (
@ -100,6 +111,7 @@ export class Root extends Component {
<Skeleton status={state.status} selected="eyre"> <Skeleton status={state.status} selected="eyre">
<Eyre <Eyre
bindings={state.bindings} bindings={state.bindings}
cache={state.cache}
connections={state.connections} connections={state.connections}
authentication={state.authentication} authentication={state.authentication}
channels={state.channels} channels={state.channels}

View File

@ -43,7 +43,10 @@ export class SearchableList extends Component {
return (<div style={{position: 'relative', border: '1px solid grey', padding: '4px'}}> return (<div style={{position: 'relative', border: '1px solid grey', padding: '4px'}}>
{props.children} {props.children}
<div>{searchBar} ({items.length})</div> <div>{searchBar} ({items.length})</div>
<div>{items.length === 0 ? 'none' : items}</div> <details open={(props.open === undefined) ? true : props.open}>
<summary>{items.length} items</summary>
<div>{items.length === 0 ? 'none' : items}</div>
</details>
</div>); </div>);
} }
} }

View File

@ -27,6 +27,7 @@ export class Skeleton extends Component {
let items = [ let items = [
'apps', 'apps',
'logs',
'spider', 'spider',
'ames', 'ames',
'behn', 'behn',

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { SearchableList } from '../components/searchable-list'; import { SearchableList } from './searchable-list';
import { renderDuct } from '../lib/util'; import { renderDuct } from '../lib/util';
export class Subscriptions extends Component { export class Subscriptions extends Component {
@ -65,4 +65,4 @@ export class Subscriptions extends Component {
} }
} }
export default Links; export default Subscriptions;

Some files were not shown because too many files have changed in this diff Show More