Merge branch 'next/kelvin/413' into x/json-bgon

This commit is contained in:
fang 2023-04-11 21:54:43 +02:00
commit 4b68139c40
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
19 changed files with 542 additions and 230 deletions

View File

@ -9,7 +9,7 @@ on:
- '.github/workflows/develop.yml'
- '.github/workflows/release.yml'
- '.github/workflows/master.yml'
- '.github/workflows/vere.yml'
- '.github/workflows/shared.yml'
- 'pkg/arvo/**'
- 'pkg/docker-image/**'
- 'pkg/ent/**'
@ -24,7 +24,7 @@ on:
jobs:
call-vere:
uses: ./.github/workflows/vere.yml
uses: ./.github/workflows/shared.yml
with:
pace: 'edge'
upload: >-

View File

@ -7,7 +7,7 @@ on:
- '.github/workflows/develop.yml'
- '.github/workflows/release.yml'
- '.github/workflows/master.yml'
- '.github/workflows/vere.yml'
- '.github/workflows/shared.yml'
- 'pkg/arvo/**'
- 'pkg/docker-image/**'
- 'pkg/ent/**'
@ -22,11 +22,12 @@ on:
jobs:
call-vere:
uses: ./.github/workflows/vere.yml
uses: ./.github/workflows/shared.yml
with:
pace: 'edge'
upload: >-
${{
(github.ref_name == 'next/vere' && github.ref_type == 'branch')
}}
next: ${{ github.base_ref }}
secrets: inherit

View File

@ -9,7 +9,7 @@ on:
- '.github/workflows/develop.yml'
- '.github/workflows/release.yml'
- '.github/workflows/master.yml'
- '.github/workflows/vere.yml'
- '.github/workflows/shared.yml'
- 'pkg/arvo/**'
- 'pkg/docker-image/**'
- 'pkg/ent/**'
@ -24,7 +24,7 @@ on:
jobs:
call-vere:
uses: ./.github/workflows/vere.yml
uses: ./.github/workflows/shared.yml
with:
pace: 'live'
upload: >-

31
.github/workflows/next.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Push to next/kelvin/*
on:
push:
branches:
- 'next/kelvin/*'
paths:
- '.github/workflows/feature.yml'
- '.github/workflows/develop.yml'
- '.github/workflows/release.yml'
- '.github/workflows/master.yml'
- '.github/workflows/shared.yml'
- 'pkg/arvo/**'
- 'pkg/docker-image/**'
- 'pkg/ent/**'
- 'pkg/ge-additions/**'
- 'pkg/libaes_siv/**'
- 'pkg/urbit/**'
- 'pkg/urcrypt/**'
- 'tests/**'
- 'bin/**'
- 'nix/**'
- 'default.nix'
jobs:
call-vere:
uses: ./.github/workflows/shared.yml
with:
upload: true
next: ${{ github.ref_name }}
secrets: inherit

View File

@ -9,7 +9,7 @@ on:
- '.github/workflows/develop.yml'
- '.github/workflows/release.yml'
- '.github/workflows/master.yml'
- '.github/workflows/vere.yml'
- '.github/workflows/shared.yml'
- 'pkg/arvo/**'
- 'pkg/docker-image/**'
- 'pkg/ent/**'
@ -24,7 +24,7 @@ on:
jobs:
call-vere:
uses: ./.github/workflows/vere.yml
uses: ./.github/workflows/shared.yml
with:
pace: 'soon'
upload: >-

View File

@ -14,6 +14,11 @@ on:
type: string
default: 'edge'
required: false
next:
description: 'next kelvin version branch name'
type: string
default: null
required: false
secrets:
CACHIX_AUTH_TOKEN:
required: false
@ -73,9 +78,18 @@ jobs:
name: run urbit-tests
run: |
cp -RL tests pkg/arvo/tests
vere=$(curl https://bootstrap.urbit.org/vere/${{ inputs.pace }}/last)
if [[ "${{ inputs.next }}" == "next/kelvin/"* ]]; then
next=$(echo ${{ inputs.next }} | sed 's/[^0-9]//g')
base="https://bootstrap.urbit.org/vere/next/kelvin/${next}"
elif [[ "${{ github.head_ref }}" == "next/kelvin"* ]]; then
next=$(echo ${{ github.head_ref }} | sed 's/[^0-9]//g')
base="https://bootstrap.urbit.org/vere/next/kelvin/${next}"
else
base="https://bootstrap.urbit.org/vere/${{ inputs.pace }}"
fi
vere=$(curl ${base}/last)
url="$(echo ${base}/v${vere}/vere-v${vere}-linux-x86_64)"
echo $vere
url="$(echo https://bootstrap.urbit.org/vere/${{ inputs.pace }}/v${vere}/vere-v${vere}-linux-x86_64)"
echo $url
# put in .jam so it doesn't crash when it gets -A'd in
curl -Lo pkg/arvo/vere.jam "$url"

View File

@ -485,11 +485,10 @@
=/ =desk +.val
=. userspace-ova.pil
:: take all files from a userspace desk
=/ all-dirs=(list path) ~[/]
:_ ~
%- unix-event:pill-lib
%+ %*(. file-ovum:pill-lib directories all-dirs)
desk /(scot %p our.hid)/[desk]/(scot %da now.hid)
%- file-ovum:pill-lib
[desk /(scot %p our.hid)/[desk]/(scot %da now.hid) ~]
=^ ms state (poke-pill pil)
(emit-cards ms)
::

View File

@ -25,6 +25,7 @@
==
::
prime=_|
exc=(list spur)
==
:- %pill
^- pill:pill
@ -45,4 +46,4 @@
|= =desk
[desk /(scot %p p.bec)/[desk]/(scot %da now)]
::
(brass:pill sys dez prime)
(brass:pill sys dez prime exc)

View File

@ -5,6 +5,6 @@
::::
::
:- %say
|= [^ ships=(list ship) ~]
|= [^ [form=?(%allow %deny) ships=(list ship)] ~]
:- %helm-ames-snub
ships
[form ships]

View File

@ -29,6 +29,7 @@
::
dub=_|
prime=_|
exc=(list spur)
==
:- %pill
^- pill:pill
@ -46,4 +47,4 @@
|= =desk
[desk /(scot %p p.bec)/[desk]/(scot %da now)]
::
(solid:pill sys dez dub now prime)
(solid:pill sys dez dub now prime exc)

View File

@ -202,8 +202,8 @@
abet:(emit %pass /helm/prod %arvo %a %prod ships)
::
++ poke-ames-snub
|= ships=(list ship)
abet:(emit %pass /helm/snub %arvo %a %snub ships)
|= snub=[form=?(%allow %deny) ships=(list ship)]
abet:(emit %pass /helm/snub %arvo %a %snub snub)
::
++ poke-atom
|= ato=@

View File

@ -583,15 +583,13 @@
..abet
=/ kel i.wic
%- emil
=/ cards
=/ desks=(list [=desk =zest])
%+ murn ~(tap by rock)
|= [=desk =zest wic=(set weft)]
?: |(=(%base desk) !?=(%live zest) (~(has in wic) kel))
~
`u=[%pass /kiln/bump/[desk] %arvo %c %zest desk %held]
?~ cards
[%pass /kiln/bump/wick %arvo %c %wick ~]~
cards
`u=[desk %held]
[%pass /kiln/bump/zeal %arvo %c %zeal desks]~
::
++ poke-cancel
|= a=@tas

View File

@ -361,7 +361,7 @@
:: %init: vane boot
:: %prod: re-send a packet per flow, to all peers if .ships is ~
:: %sift: limit verbosity to .ships
:: %snub: set packet blacklist to .ships
:: %snub: set packet blocklist to .ships
:: %spew: set verbosity toggles
:: %cong: adjust congestion control parameters
:: %stir: recover from timer desync
@ -380,7 +380,7 @@
$>(%init vane-task)
[%prod ships=(list ship)]
[%sift ships=(list ship)]
[%snub ships=(list ship)]
[%snub form=?(%allow %deny) ships=(list ship)]
[%spew veb=(list verb)]
[%cong msg=@ud mem=@ud]
[%stir arg=@t]
@ -522,7 +522,6 @@
:: heeds: listeners for %clog notifications
:: closing: bones closed on the sender side
:: corked: bones closed on both sender and receiver
:: krocs: bones that need to be sent again to the publisher
::
+$ peer-state
$: $: =symmetric-key
@ -540,7 +539,6 @@
heeds=(set duct)
closing=(set bone)
corked=(set bone)
krocs=(set bone)
==
:: $qos: quality of service; how is our connection to a peer doing?
::
@ -801,6 +799,7 @@
[%warp wer=ship rif=riff] :: internal file req
[%werp who=ship wer=ship rif=riff-any] :: external file req
[%wick ~] :: try upgrade
[%zeal lit=(list [=desk =zest])] :: batch zest
[%zest des=desk liv=zest] :: live
$>(%plea vane-task) :: ames request
== ::
@ -1355,6 +1354,11 @@
:: ::::
++ eyre ^?
|%
+$ cache-entry
$: auth=?
$= body
$% [%payload =simple-payload:http]
== ==
+$ gift
$% :: set-config: configures the external http server
::
@ -1374,6 +1378,9 @@
:: not allowed.
::
[%bound accepted=? =binding]
:: notification that a cache entry has changed
::
[%grow =path]
==
::
+$ task
@ -1426,6 +1433,12 @@
:: start responding negatively to cors requests from origin
::
[%reject-origin =origin]
:: %spew: set verbosity toggle
::
[%spew veb=@]
:: remember (or update) a cache mapping
::
[%set-response url=@t entry=(unit cache-entry)]
==
:: +origin: request origin as specified in an Origin header
::

View File

@ -612,20 +612,18 @@
:: snub: blocklist for incoming packets
:: cong: parameters for marking a flow as clogged
::
:: Note: .corks is only still present for unreleased migration reasons
::
::
+$ ames-state
$: peers=(map ship ship-state) :: TODO: remove krocs from peer-state
$: peers=(map ship ship-state)
=unix=duct
=life
crypto-core=acru:ames
=bug
corks=(set wire) :: TODO: remove next state update
snub=(set ship)
snub=[form=?(%allow %deny) ships=(set ship)]
cong=[msg=@ud mem=@ud]
==
+$ ames-state-4 ames-state-5
::
+$ azimuth-state [=symmetric-key =life =rift =public-key sponsor=ship]
+$ ames-state-4 ames-state-5
+$ ames-state-5
$: peers=(map ship ship-state-5)
=unix=duct
@ -641,11 +639,7 @@
==
::
+$ peer-state-5
$: $: =symmetric-key
=life
=public-key
sponsor=ship
==
$: azimuth-state
route=(unit [direct=? =lane])
=qos
=ossuary
@ -655,6 +649,11 @@
heeds=(set duct)
==
::
+$ bug-9
$: veb=_[`?`%.n `?`%.n `?`%.n `?`%.n `?`%.n `?`%.n `?`%.n]
ships=(set ship)
==
::
+$ ames-state-6
$: peers=(map ship ship-state-6)
=unix=duct
@ -669,12 +668,7 @@
==
::
+$ peer-state-6
$: $: =symmetric-key
=life
=rift
=public-key
sponsor=ship
==
$: azimuth-state
route=(unit [direct=? =lane])
=qos
=ossuary
@ -685,7 +679,7 @@
==
::
+$ ames-state-7
$: peers=(map ship ship-state)
$: peers=(map ship ship-state-7)
=unix=duct
=life
crypto-core=acru:ames
@ -693,7 +687,7 @@
==
::
+$ ames-state-8
$: peers=(map ship ship-state)
$: peers=(map ship ship-state-7)
=unix=duct
=life
crypto-core=acru:ames
@ -701,18 +695,8 @@
corks=(set wire)
==
::
+$ bug-9
$: veb=_[`?`%.n `?`%.n `?`%.n `?`%.n `?`%.n `?`%.n `?`%.n]
ships=(set ship)
==
::
+$ bug-10
$: veb=_[`?`%.n `?`%.n `?`%.n `?`%.n `?`%.n `?`%.n `?`%.n `?`%.n]
ships=(set ship)
==
::
+$ ames-state-9
$: peers=(map ship ship-state)
$: peers=(map ship ship-state-7)
=unix=duct
=life
crypto-core=acru:ames
@ -722,15 +706,54 @@
==
::
+$ ames-state-10
$: peers=(map ship ship-state)
$: peers=(map ship ship-state-7)
=unix=duct
=life
crypto-core=acru:ames
bug=bug-10
=bug
corks=(set wire)
snub=(set ship)
==
::
+$ ship-state-7
$% [%alien alien-agenda]
[%known peer-state-7]
==
::
+$ peer-state-7
$: azimuth-state
route=(unit [direct=? =lane])
=qos
=ossuary
snd=(map bone message-pump-state)
rcv=(map bone message-sink-state)
nax=(set [=bone =message-num])
heeds=(set duct)
closing=(set bone)
corked=(set bone)
krocs=(set bone)
==
::
+$ ames-state-11
$: peers=(map ship ship-state-7)
=unix=duct
=life
crypto-core=acru:ames
=bug
corks=(set wire)
snub=(set ship)
cong=[msg=@ud mem=@ud]
==
::
+$ queued-event-11
$% [%call =duct wrapped-task=(hobo task-11)]
[%take =wire =duct =sign]
==
::
+$ task-11
$% [%snub ships=(list ship)]
$<(%snub task)
==
:: $bug: debug printing configuration
::
:: veb: verbosity toggles
@ -857,7 +880,8 @@
[%8 ames-state-8]
[%9 ames-state-9]
[%10 ames-state-10]
[%11 ^ames-state]
[%11 ames-state-11]
[%12 ^ames-state]
==
::
|= [now=@da eny=@ rof=roof]
@ -980,7 +1004,7 @@
:: lifecycle arms; mostly pass-throughs to the contained adult ames
::
++ scry scry:adult-core
++ stay [%11 %larva queued-events ames-state.adult-gate]
++ stay [%12 %larva queued-events ames-state.adult-gate]
++ load
|= $= old
$% $: %4
@ -1033,6 +1057,13 @@
[%adult state=ames-state-10]
== ==
$: %11
$% $: %larva
events=(qeu queued-event-11)
state=ames-state-11
==
[%adult state=ames-state-11]
== ==
$: %12
$% $: %larva
events=(qeu queued-event)
state=_ames-state.adult-gate
@ -1107,14 +1138,34 @@
=. queued-events events.old
larval-gate
::
[%11 %adult *] (load:adult-core %11 state.old)
[%11 %adult *]
=. cached-state `[%11 state.old]
~> %slog.0^leaf/"ames: larva reload"
larval-gate
::
[%11 %larva *]
~> %slog.1^leaf/"ames: larva: load"
=. queued-events events.old
=. adult-gate (load:adult-core %11 state.old)
=. queued-events
:: "+rep:in on a +qeu looks strange, but works fine."
::
%- ~(rep in events.old)
|= [e=queued-event-11 q=(qeu queued-event)]
%- ~(put to q) ^- queued-event
?. ?=(%call -.e) e
=/ task=task-11 ((harden task-11) wrapped-task.e)
%= e
wrapped-task ?.(?=(%snub -.task) task [%snub %deny ships.task])
==
larval-gate
::
::
[%12 %adult *] (load:adult-core %12 state.old)
::
[%12 %larva *]
~> %slog.1^leaf/"ames: larva: load"
=. queued-events events.old
=. adult-gate (load:adult-core %12 state.old)
larval-gate
::
==
:: +molt: re-evolve to adult-ames
::
@ -1137,7 +1188,9 @@
10+(state-9-to-10:load:adult-core +.u.cached-state)
=? u.cached-state ?=(%10 -.u.cached-state)
11+(state-10-to-11:load:adult-core +.u.cached-state)
?> ?=(%11 -.u.cached-state)
=? u.cached-state ?=(%11 -.u.cached-state)
12+(state-11-to-12:load:adult-core +.u.cached-state)
?> ?=(%12 -.u.cached-state)
=. ames-state.adult-gate +.u.cached-state
[moz larval-core(cached-state ~)]
--
@ -1269,9 +1322,9 @@
:: +on-snub: handle request to change ship blacklist
::
++ on-snub
|= ships=(list ship)
|= [form=?(%allow %deny) ships=(list ship)]
^+ event-core
=. snub.ames-state (sy ships)
=. snub.ames-state [form (sy ships)]
event-core
:: +on-spew: handle request to set verbosity toggles on debug output
::
@ -1413,11 +1466,12 @@
~/ %on-hear-packet
|= [=lane =packet dud=(unit goof)]
^+ event-core
%- (ev-trace odd.veb sndr.packet |.("received packet"))
%- (ev-trace rcv.veb sndr.packet |.("received packet"))
::
?: =(our sndr.packet)
event-core
?: (~(has in snub.ames-state) sndr.packet)
?: .= =(%deny form.snub.ames-state)
(~(has in ships.snub.ames-state) sndr.packet)
%- (ev-trace rcv.veb sndr.packet |.("snubbed"))
event-core
::
@ -3386,6 +3440,15 @@
++ closing (~(has in closing.peer-state) bone)
++ corked (~(has in corked.peer-state) bone)
++ pump-core |=(=^bone (mu bone *message-pump-state))
++ received
|= =^bone
:: odd bone: %plea request message
:: even bone, 0 second bit: %boon response message
:: even bone, 1 second bit: nack-trace %boon message
::
?: =(1 (end 0 bone)) %plea
?: =(0 (end 0 (rsh 0 bone))) %boon
%nack
::
+| %entry-points
:: +call: handle a $message-sink-task
@ -3393,18 +3456,24 @@
++ call
|= task=message-sink-task
^+ sink
:: if we get a plea request and have corked this flow, always ack
::
?: corked
=? peer-core &(?=(%hear -.task) =(1 (end 0 bone)))
%- (mi-trace odd.veb |.("hear plea on a corked bone={<bone>}"))
%+ send-shut-packet bone
[message-num.shut-packet.task %| %| ok=& lag=*@dr]
sink
?- -.task
%drop sink(nax.state (~(del in nax.state) message-num.task))
%done (done ok.task)
%hear (hear [lane shut-packet ok]:task)
::
%hear
?. ?| corked
?& %*(corked sink bone (mix 0b10 bone))
=(%nack (received bone))
== ==
(hear [lane shut-packet ok]:task)
:: if we %hear a task on a corked bone, always ack
::
=. peer-core
%+ send-shut-packet bone
[message-num.shut-packet.task %| %| ok=& lag=*@dr]
%. sink
%+ mi-trace odd.veb
|.("hear {<(received bone)>} on corked bone={<bone>}")
==
::
+| %tasks
@ -3574,18 +3643,12 @@
+| %implementation
:: +handle-sink: dispatch message
::
:: odd bone: %plea request message
:: even bone, 0 second bit: %boon response message
:: even bone, 1 second bit: nack-trace %boon message
::
++ handle-sink
|= [=message-num message=* ok=?]
|^ ^+ sink
?: =(1 (end 0 bone)) sink-plea
?: =(0 (end 0 (rsh 0 bone))) sink-boon
sink-nack
:: XX FIXME: impure +abet pattern
++ sink-plea
^+ sink
|^ ?-((received bone) %plea ha-plea, %boon ha-boon, %nack ha-nack)
::
++ ha-plea
^+ sink
?: |(closing corked) sink
%- %+ mi-trace msg.veb
@ -3619,7 +3682,7 @@
=. closing.peer-state (~(put in closing.peer-state) bone)
(pe-emit duct %pass wire %a %plea her [%a /close ~])
::
:: +sink-boon: handle response message, acking unconditionally
:: +ha-boon: handle response message, acking unconditionally
::
:: .bone must be mapped in .ossuary.peer-state, or we crash.
:: This means a malformed message will kill a flow. We
@ -3633,7 +3696,7 @@
:: TODO: This handles a previous crash in the client vane, but
:: not in %ames itself.
::
++ sink-boon
++ ha-boon
^+ sink
?: |(closing corked) sink
%- %+ mi-trace msg.veb |.
@ -3654,7 +3717,7 @@
::
(call %done ok=%.y)
::
++ sink-nack
++ ha-nack
^+ sink
:: if we get a naxplanation for a %cork, the publisher hasn't
:: received the OTA. The /recork timer will retry eventually.
@ -3712,7 +3775,7 @@
%jilt (on-jilt:event-core ship.task)
%prod (on-prod:event-core ships.task)
%sift (on-sift:event-core ships.task)
%snub (on-snub:event-core ships.task)
%snub (on-snub:event-core [form ships]:task)
%spew (on-spew:event-core veb.task)
%cong (on-cong:event-core [msg mem]:task)
%stir (on-stir:event-core arg.task)
@ -3750,15 +3813,15 @@
[moves ames-gate]
:: +stay: extract state before reload
::
++ stay [%11 %adult ames-state]
++ stay [%12 %adult ames-state]
:: +load: load in old state after reload
::
++ load
=< |= $= old-state
$% [%11 ^ames-state]
$% [%12 ^ames-state]
==
^+ ames-gate
?> ?=(%11 -.old-state)
?> ?=(%12 -.old-state)
ames-gate(ames-state +.old-state)
:: all state transitions are called from larval ames
::
@ -3809,11 +3872,11 @@
:_ +.ames-state
%- ~(run by peers.ames-state)
|= ship-state=ship-state-6
^- ^ship-state
^- ship-state-7
?. ?=(%known -.ship-state)
ship-state
:- %known
^- peer-state
^- peer-state-7
:- +<.ship-state
[route qos ossuary snd rcv nax heeds ~ ~ ~]:ship-state
::
@ -3846,13 +3909,26 @@
::
++ state-10-to-11
|= ames-state=ames-state-10
^- ^^ames-state
^- ames-state-11
=, ames-state
:* peers unix-duct life crypto-core bug corks snub
:: 5 messages and 100Kb of data outstanding
::
[msg=5 mem=100.000]
==
::
++ state-11-to-12
|= ames-state=ames-state-11
^- ^^ames-state
:_ [unix-duct life crypto-core bug [%deny snub] cong]:ames-state
%- ~(run by peers.ames-state)
|= ship-state=ship-state-7
^- ^ship-state
?. ?=(%known -.ship-state)
ship-state
%= ship-state
+> [route qos ossuary snd rcv nax heeds closing corked]:+>.ship-state
==
--
:: +scry: dereference namespace
::
@ -3890,6 +3966,7 @@
:: /ax/peers/[ship]/forward-lane (list lane)
:: /ax/bones/[ship] [snd=(set bone) rcv=(set bone)]
:: /ax/snd-bones/[ship]/[bone] vase
:: /ax/snubbed (?(%allow %deny) (list ship))
::
?. ?=(%x ren) ~
?+ tyl ~
@ -3969,5 +4046,8 @@
=/ res
u.mps
``noun+!>(!>(res))
::
[%snubbed ~]
``noun+!>([form.snub.ames-state ~(tap in ships.snub.ames-state)])
==
--

View File

@ -4970,9 +4970,22 @@
::
%wick
=^ mos ruf
=/ den ((de now rof hen ruf) our %base)
abet:wick:den :: [wick]
abet:wick:((de now rof hen ruf) our %base) :: [wick]
[mos ..^$]
::
%zeal
=^ m1 ruf
=| mos=(list move)
|- ^+ [mos ruf]
?~ lit.req
[mos ruf]
=/ den ((de now rof hen ruf) our desk.i.lit.req)
=^ mos-new ruf abet:(set-zest:den zest.i.lit.req)
$(mos (weld mos mos-new), lit.req t.lit.req)
=^ m2 ruf
abet:wick:((de now rof hen ruf) our %base)
=^ m3 ruf abet:goad:(lu now rof hen ruf)
[:(weld m1 m2 m3) ..^$]
::
%zest
=^ m1 ruf

View File

@ -70,7 +70,7 @@
++ axle
$: :: date: date at which http-server's state was updated to this data structure
::
date=%~2023.3.15
date=%~2023.4.11
:: server-state: state of inbound requests
::
=server-state
@ -88,6 +88,9 @@
:: the :binding into a (map (unit @t) (trie knot =action)).
::
bindings=(list [=binding =duct =action])
:: cache: mapping from url to versioned entry
::
cache=(map url=@t [aeon=@ud val=(unit cache-entry)])
:: cors-registry: state used and managed by the +cors core
::
=cors-registry
@ -112,6 +115,9 @@
:: outgoing-duct: to unix
::
outgoing-duct=duct
:: verb: verbosity
::
verb=@
==
:: channel-request: an action requested on a channel
::
@ -620,7 +626,8 @@
[act [& secure address request] ~ 0]
::
=. connections.state
(~(put by connections.state) duct connection)
%. (~(put by connections.state) duct connection)
(trace 2 |.("{<duct>} creating local"))
::
:_ state
(subscribe-to-app app.act inbound-request.connection)
@ -649,6 +656,7 @@
=/ connection=outstanding-connection
[action [authenticated secure address request] ~ 0]
=. connections.state
:: XX pretty sure this is superfluous - done in +handle-response
(~(put by connections.state) duct connection)
:: redirect to https if insecure, redirects enabled
:: and secure port live
@ -707,6 +715,11 @@
=- (fall - '*')
(get-header:http 'access-control-request-headers' headers)
==
:: handle requests to the cache
::
=/ entry (~(get by cache.state) url.request)
?: &(?=(^ entry) ?=(%'GET' method.request))
(handle-cache-req authenticated request val.u.entry)
::
?- -.action
%gen
@ -806,6 +819,32 @@
%^ 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
|= [authenticated=? =request:http entry=(unit cache-entry)]
|^ ^- (quip move server-state)
?~ entry
(error-response 404 "cache entry for that binding was deleted")
?: &(auth.u.entry !authenticated)
(error-response 403 ~)
=* body body.u.entry
?- -.body
%payload
%- handle-response
:* %start
response-header.simple-payload.body
data.simple-payload.body
complete=%.y
==
==
::
++ 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-scry: respond with scry result, 404 or 500
::
++ handle-scry
@ -900,6 +939,7 @@
%app
:_ state
:_ ~
%- (trace 1 |.("leaving subscription to {<app.action.u.connection>}"))
:* duct %pass /watch-response/[eyre-id]
%g %deal [our our] app.action.u.connection
%leave ~
@ -1070,6 +1110,7 @@
=^ moz state
(handle-response response)
[[give-session-tokens (weld moves moz)] state]
%- (trace 1 |.("{(trip i.channels)} discarding channel due to logout"))
=^ moz state
(discard-channel:by-channel i.channels |)
$(moves (weld moves moz), channels t.channels)
@ -1181,8 +1222,7 @@
:: POST methods are used solely for deleting channels
(on-put-request channel-id request)
::
~& %session-not-a-put
[~ state]
((trace 0 |.("session not a put")) `state)
:: +on-cancel-request: cancels an ongoing subscription
::
:: One of our long lived sessions just got closed. We put the associated
@ -1192,15 +1232,15 @@
^- [(list move) server-state]
:: lookup the session id by duct
::
?~ maybe-channel-id=(~(get by duct-to-key.channel-state.state) duct)
~> %slog.[0 leaf+"eyre: no channel to cancel {<duct>}"]
[~ state]
%- (trace 1 |.("{<duct>} moving channel to waiting state"))
::
~> %slog.[0 leaf+"eyre: canceling {<duct>}"]
?~ maybe-channel-id=(~(get by duct-to-key.channel-state.state) duct)
((trace 0 |.("{<duct>} no channel to move")) `state)
::
=/ maybe-session
(~(get by session.channel-state.state) u.maybe-channel-id)
?~ maybe-session [~ state]
?~ maybe-session
((trace 1 |.("{<maybe-session>} session doesn't exist")) `state)
::
=/ heartbeat-cancel=(list move)
?~ heartbeat.u.maybe-session ~
@ -1518,6 +1558,7 @@
^- move
:^ duct %pass
(subscription-wire channel-id request-id ship app)
%- (trace 1 |.("subscribing to {<app>} on {<path>}"))
:* %g %deal [our ship] app
`task:agent:gall`[%watch path]
==
@ -1544,8 +1585,9 @@
:: the client sent us a weird request referring to a subscription
:: which isn't active.
::
~& [%missing-subscription-in-unsubscribe channel-id subscription-id]
$(requests t.requests)
%. $(requests t.requests)
=* msg=tape "{(trip channel-id)} {<subscription-id>}"
(trace 0 |.("missing subscription in unsubscribe {msg}"))
::
=. gall-moves
:_ gall-moves
@ -1553,6 +1595,7 @@
=, u.maybe-subscription
:^ duc %pass
(subscription-wire channel-id subscription-id.i.requests ship app)
%- (trace 1 |.("leaving subscription to {<app>}"))
:* %g %deal [our ship] app
`task:agent:gall`[%leave ~]
==
@ -1568,6 +1611,7 @@
$(requests t.requests)
::
%delete
%- (trace 1 |.("{<channel-id>} discarding due to %delete PUT"))
=^ moves state
(discard-channel channel-id |)
=. gall-moves
@ -1594,10 +1638,8 @@
(emit-event channel-id request-id sign)
=/ =ship (slav %p i.extra)
=* app=term i.t.extra
=/ =tape
%+ weld "eyre: removing watch for "
"non-existent channel {(trip channel-id)} on {(trip app)}"
%- (slog leaf+tape ~)
=* msg=tape "{(trip channel-id)} {(trip app)}"
%- (trace 0 |.("removing watch for non-existent channel {msg}"))
:_ state
:_ ~
^- move
@ -1683,11 +1725,15 @@
?& (gte num clog-threshold)
(lth (add last-ack.u.channel clog-timeout) now)
==
~? clogged [%e %clogged channel-id request-id]
:: if we're clogged, or we ran into an event we can't serialize,
:: kill this gall subscription.
::
=* kicking |(clogged ?=(~ said))
=* msg=tape "on {(trip channel-id)} for {(trip request-id)}"
=/ kicking=?
?: clogged
((trace 0 |.("clogged {msg}")) &)
?. ?=(~ said) |
((trace 0 |.("can't serialize event, kicking {msg}")) &)
=? moves kicking
:_ moves
::NOTE this shouldn't crash because we
@ -1695,6 +1741,7 @@
:: - only clog on %facts, which have a subscription associated,
:: - and already checked whether we still have that subscription.
=+ (~(got by subscriptions.u.channel) request-id)
%- (trace 1 |.("leaving subscription to {<app>}"))
:^ duct %pass
(subscription-wire channel-id request-id ship app)
[%g %deal [our ship] app %leave ~]
@ -1744,11 +1791,11 @@
^- (unit desk)
=/ sub (~(get by subscriptions.channel) request-id)
?~ sub
((slog leaf+"eyre: no subscription for request-id {<request-id>}" ~) ~)
((trace 0 |.("no subscription for request-id {(trip request-id)}")) ~)
=/ des=(unit (unit cage))
(rof ~ %gd [our app.u.sub da+now] ~)
?. ?=([~ ~ *] des)
((slog leaf+"eyre: no desk for app {(trip app.u.sub)}" ~) ~)
((trace 0 |.("no desk for app {<app.u.sub>}")) ~)
`!<(=desk q.u.u.des)
:: +channel-event-to-sign: attempt to recover a sign from a channel-event
::
@ -1765,11 +1812,11 @@
=/ val=(unit (unit cage))
(rof ~ %cb [our u.des da+now] /[have])
?. ?=([~ ~ *] val)
((slog leaf+"eyre: no mark {(trip have)}" ~) ~)
((trace 0 |.("no mark {(trip have)}")) ~)
=+ !<(=dais:clay q.u.u.val)
=/ res (mule |.((vale:dais noun.event)))
?: ?=(%| -.res)
((slog leaf+"eyre: stale fact of mark {(trip have)}" ~) ~)
((trace 0 |.("stale fact of mark {(trip have)}")) ~)
`[%fact have p.res]
:: +sign-to-tape: render sign from request-id in specified mode
::
@ -1799,15 +1846,14 @@
?~ des [~ ~]
::
=* have=mark p.cage.sign
=* desc=tape "from {(trip have)} to json"
=/ convert=(unit vase)
=/ cag=(unit (unit cage))
(rof ~ %cf [our u.des da+now] /[have]/json)
?. ?=([~ ~ *] cag) ~
`q.u.u.cag
?~ convert
((slog leaf+"eyre: no convert {desc}" ~) [~ ~])
~| "conversion failed {desc}"
((trace 0 |.("no convert from {(trip have)} to json")) [~ ~])
~| "conversion failed from {(trip have)} to json"
[`[u.des have] `[%fact %json (slym u.convert q.q.cage.sign)]]
?~ jsyn ~
%- some
@ -1921,6 +1967,7 @@
%+ turn ~(tap by subscriptions.session)
|= [request-id=@ud ship=@p app=term =path duc=^duct]
^- move
%- (trace 1 |.("{<channel-id>} leaving subscription to {<app>}"))
:^ duc %pass
(subscription-wire channel-id request-id ship app)
[%g %deal [our ship] app %leave ~]
@ -1936,6 +1983,7 @@
?. ?=(%app -.action.connection)
~
:_ ~
%- (trace 1 |.("leaving subscription to {<app.action.connection>}"))
:* duct %pass /watch-response/[eyre-id]
%g %deal [our our] app.action.connection
%leave ~
@ -1963,8 +2011,7 @@
:: verify that this is a valid response on the duct
::
?~ connection-state=(~(get by connections.state) duct)
~& [%invalid-outstanding-connection duct]
[~ state]
((trace 0 |.("{<duct>} invalid outstanding connection")) `state)
::
|^ ^- [(list move) server-state]
::
@ -1972,8 +2019,7 @@
::
%start
?^ response-header.u.connection-state
~& [%http-multiple-start duct]
error-connection
((trace 0 |.("{<duct>} error multiple start")) error-connection)
:: if request was authenticated, extend the session & cookie's life
::
=^ response-header sessions.authentication-state.state
@ -1987,8 +2033,7 @@
?~ session-id=(session-id-from-request request.inbound)
:: cookies are the only auth method, so this is unexpected
::
~& [%e %authenticated-without-cookie]
no-op
((trace 0 |.("error authenticated without cookie")) no-op)
?. (~(has by sessions) u.session-id)
:: if the session has expired since the request was opened,
:: tough luck, we don't create/revive sessions here
@ -2020,6 +2065,7 @@
::
=. response-header.http-event response-header
=. connections.state
%- (trace 2 |.("{<duct>} start"))
%+ ~(put by connections.state) duct
%_ connection
response-header `response-header
@ -2033,10 +2079,11 @@
::
%continue
?~ response-header.u.connection-state
~& [%http-continue-without-start duct]
error-connection
%. error-connection
(trace 0 |.("{<duct>} error continue without start"))
::
=. connections.state
%- (trace 2 |.("{<duct>} continuing "))
%+ ~(jab by connections.state) duct
|= connection=outstanding-connection
=+ size=?~(data.http-event 0 p.u.data.http-event)
@ -2050,7 +2097,7 @@
%cancel
:: todo: log this differently from an ise.
::
error-connection
((trace 1 |.("cancel http event")) error-connection)
==
::
++ pass-response
@ -2063,7 +2110,8 @@
:: remove all outstanding state for this connection
::
=. connections.state
(~(del by connections.state) duct)
%. (~(del by connections.state) duct)
(trace 2 |.("{<duct>} completed"))
state
::
++ error-connection
@ -2081,11 +2129,22 @@
?. ?=(%app -.action.u.connection-state)
~
:_ ~
%- %+ trace 1
|.("leaving subscription to {<app.action.u.connection-state>}")
:* duct %pass /watch-response/[eyre-id]
%g %deal [our our] app.action.u.connection-state
%leave ~
==
--
:: +set-response: remember (or update) a cache mapping
::
++ set-response
|= [url=@t entry=(unit cache-entry)]
^- [(list move) server-state]
=/ aeon ?^(prev=(~(get by cache.state) url) +(aeon.u.prev) 1)
=. cache.state (~(put by cache.state) url [aeon entry])
:_ state
[outgoing-duct.state %give %grow /cache/(scot %ud aeon)/(scot %t url)]~
:: +add-binding: conditionally add a pairing between binding and action
::
:: Adds =binding =action if there is no conflicting bindings.
@ -2192,6 +2251,11 @@
:- outgoing-duct.state
=* ses sessions.authentication-state.state
[%give %sessions (~(run in ~(key by ses)) (cury scot %uv))]
::
++ trace
|= [pri=@ print=(trap tape)]
?: (lth verb.state pri) same
(slog leaf+"eyre: {(print)}" ~)
--
::
++ forwarded-params
@ -2369,6 +2433,12 @@
:: save duct for future %give to unix
::
=. outgoing-duct.server-state.ax duct
:: send all cache mappings to runtime
::
=/ cache-moves=(list move)
%+ turn ~(tap by cache.server-state.ax)
|= [url=@t cache-val=[aeon=@ud val=(unit cache-entry)]]
[duct %give %grow /cache/(scot %u aeon.cache-val)/(scot %t url)]
::
:_ http-server-gate
:* :: hand back default configuration for now
@ -2379,7 +2449,7 @@
=< give-session-tokens
(per-server-event [eny duct now rof] server-state.ax)
::
closed-connections
(zing ~[closed-connections cache-moves])
==
::
?: ?=(%code-changed -.task)
@ -2494,6 +2564,14 @@
(~(del in approved) origin.task)
(~(put in rejected) origin.task)
[~ http-server-gate]
::
%spew
=. verb.server-state.ax veb.task
`http-server-gate
::
%set-response
=^ moves server-state.ax (set-response:server +.task)
[moves http-server-gate]
==
::
++ take
@ -2605,10 +2683,11 @@
?> ?=([%behn %wake *] sign)
?^ error.sign
[[duct %slip %d %flog %crud %wake u.error.sign]~ http-server-gate]
=/ discard-channel
discard-channel:by-channel:(per-server-event event-args)
=* id i.t.t.wire
%- %+ trace:(per-server-event event-args) 1
|.("{(trip id)} cancelling channel due to timeout")
=^ moves server-state.ax
(discard-channel i.t.t.wire &)
(discard-channel:by-channel:(per-server-event event-args) id &)
[moves http-server-gate]
::
%heartbeat
@ -2683,77 +2762,144 @@
:: +load: migrate old state to new state (called on vane reload)
::
++ load
|^ |= old=$%(axle axle-any)
^+ ..^^$
::
=> |%
+$ axle-any
$% [%~2020.10.18 =server-state-0]
[%~2022.7.26 =server-state-0]
[%~2023.2.17 =server-state-1]
[%~2023.3.16 server-state-2]
[%~2023.4.11 server-state]
==
::
+$ server-state-0
$: bindings=(list [=binding =duct =action])
=cors-registry
connections=(map duct outstanding-connection)
=authentication-state
channel-state=channel-state-2
domains=(set turf)
=http-config
ports=[insecure=@ud secure=(unit @ud)]
outgoing-duct=duct
==
::
+$ server-state-1
$: bindings=(list [=binding =duct =action])
=cors-registry
connections=(map duct outstanding-connection)
=authentication-state
channel-state=channel-state-2
domains=(set turf)
=http-config
ports=[insecure=@ud secure=(unit @ud)]
outgoing-duct=duct
verb=@
==
::
+$ server-state-2
$: bindings=(list [=binding =duct =action])
cache=(map url=@t [aeon=@ud val=(unit cache-entry)])
=cors-registry
connections=(map duct outstanding-connection)
=authentication-state
channel-state=channel-state-2
domains=(set turf)
=http-config
ports=[insecure=@ud secure=(unit @ud)]
outgoing-duct=duct
verb=@
==
+$ channel-state-2
$: session=(map @t channel-2)
duct-to-key=(map duct @t)
==
+$ channel-2
$: state=(each timer duct)
next-id=@ud
last-ack=@da
events=(qeu [id=@ud request-id=@ud =channel-event])
unacked=(map @ud @ud)
subscriptions=(map @ud [ship=@p app=term =path duc=duct])
heartbeat=(unit timer)
==
--
|= old=axle-any
^+ ..^$
?- -.old
%~2020.10.18
=, server-state-0.old
%= $
date.old %~2022.7.26
::
bindings.server-state.old
%+ insert-binding
[[~ /~/name] outgoing-duct.server-state.old [%name ~]]
bindings.server-state.old
==
::
%~2022.7.26
:: enable https redirects if certificate configured
::
=. redirect.http-config.server-state.old
?& ?=(^ secure.ports.server-state.old)
?=(^ secure.http-config.server-state.old)
==
$(old (axle-0-to-1))
::
%~2023.3.15
..^^$(ax old)
==
::
+$ axle-any
$% axle
axle-0
==
::
++ axle-0-to-1
|= ax=axle-0
^- axle
:- %~2023.3.15
^- server-state
%= server-state.ax
session.channel-state
(~(run by session.channel-state.server-state.ax) (lead %json))
==
::
+$ axle-0
$: date=?(%~2022.7.26 %~2020.10.18)
$= server-state
$: bindings=(list [=binding =duct =action])
=cors-registry
connections=(map duct outstanding-connection)
=authentication-state
channel-state=channel-state-0
domains=(set turf)
=http-config
ports=[insecure=@ud secure=(unit @ud)]
outgoing-duct=duct
old
:* %~2023.3.16
(insert-binding [[~ /~/name] outgoing-duct [%name ~]] bindings)
*(map url=@t [aeon=@ud val=(unit cache-entry)])
cors-registry
connections
authentication-state
channel-state
domains
http-config
ports
outgoing-duct
0
== ==
::
+$ channel-state-0
$: session=(map @t channel-0)
duct-to-key=(map duct @t)
%~2022.7.26
=, server-state-0.old
%= $
old
:* %~2023.3.16
bindings
*(map url=@t [aeon=@ud val=(unit cache-entry)])
cors-registry
connections
authentication-state
channel-state
domains
http-config
ports
outgoing-duct
0
== ==
::
%~2023.2.17
=, server-state-1.old
%= $
old
:* %~2023.3.16
bindings
*(map url=@t [aeon=@ud val=(unit cache-entry)])
cors-registry
connections
authentication-state
channel-state
domains
http-config
ports
outgoing-duct
verb
== ==
::
%~2023.3.16
%= $
old
:- %~2023.4.11
%= +.old
session.channel-state
(~(run by session.channel-state.old) (lead %json))
::
redirect.http-config
:: enable https redirects if certificate configured
::
?& ?=(^ secure.ports.old)
?=(^ secure.http-config.old)
==
==
==
::
+$ channel-0
$: state=(each timer duct)
next-id=@ud
last-ack=@da
events=(qeu [id=@ud request-id=@ud =channel-event])
unacked=(map @ud @ud)
subscriptions=(map @ud [ship=@p app=term =path duc=duct])
heartbeat=(unit timer)
==
--
%~2023.4.11
..^$(ax old)
==
:: +stay: produce current state
::
++ stay `axle`ax
@ -2813,6 +2959,14 @@
%- =< request-is-logged-in:authentication
(per-server-event [eny *duct now rof] server-state.ax)
%*(. *request:http header-list ['cookie' u.cookies]~)
::
[%cache @ @ ~]
?~ 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 [~ ~]
``noun+!>(u.val)
==
?. ?=(%$ ren)
[~ ~]

View File

@ -32,25 +32,23 @@
[/sys/hoon hoon/hoon]
[/sys/arvo hoon/arvo]
==
:: +dirs: filter for userspace directories to include
::
++ dirs
|= [bas=path exc=(list spur)]
^- (list spur)
?~ exc ~(tap in dir:.^(arch %cy bas))
%+ skim
~(tap in dir:.^(arch %cy bas))
|=(=spur =(~ (find ~[spur] exc)))
:: +file-ovum: userspace filesystem load
::
:: bas: full path to / directory
::
++ file-ovum
=/ directories=(list path)
:~ /app :: %gall applications
/gen :: :dojo generators
/lib :: libraries
/mar :: mark definitions
/sur :: structures
/sys :: system files
/ted :: :spider strands
/web :: %eyre web content
/desk :: desk manifest
==
|= [des=desk bas=path]
|= [des=desk bas=path exc=(list spur)]
^- unix-event
%. directories
%. (dirs bas exc)
|= :: sal: all spurs to load from
::
sal=(list spur)
@ -99,7 +97,7 @@
::
:: +file-ovum2: electric boogaloo
::
++ file-ovum2 |=(p=path `unix-event`[//arvo what/(user-files p)])
++ file-ovum2 |=(z=[path (list spur)] `unix-event`[//arvo what/(user-files z)])
::
++ prep-ovum
|= dez=(list path)
@ -114,8 +112,8 @@
:: +user-files: all userspace hoon files
::
++ user-files
|= bas=path
%. directories:file-ovum
|= [bas=path exc=(list spur)]
%. (dirs bas exc)
|= sal=(list spur)
^- (list (pair path (cask)))
::
@ -154,8 +152,9 @@
++ solid
:: sys: root path to boot system, `/~me/[desk]/now/sys`
:: dez: secondary desks and their root paths
:: exc: list of desk folders to exclude
::
|= [sys=path dez=(list [desk path]) dub=? now=@da prime=?]
|= [sys=path dez=(list [desk path]) dub=? now=@da prime=? exc=(list spur)]
^- pill
=/ bas=path (scag 3 sys)
=/ compiler-path (weld sys /hoon)
@ -201,7 +200,8 @@
:- (boot-ovum:pill compiler-src arvo-src)
%+ turn
(snoc (turn dez tail) bas)
file-ovum2:pill
|= =path
(file-ovum2 [path exc])
.*(0 arvo-formula)
|= [ovo=ovum ken=*]
[~ (slum ken [now ovo])]
@ -230,15 +230,18 @@
:+ boot-ova ~
=. dez (snoc dez [%base bas])
%+ weld
(turn dez file-ovum)
%+ turn dez
|= [dek=desk bas=path]
(file-ovum [dek bas exc])
?. prime ~
[(prep-ovum (turn dez tail))]~
::
++ brass
:: sys: root path to boot system, `/~me/[desk]/now/sys`
:: dez: secondary desks and their root paths
:: exc: list of desk folders to exclude
::
|= [sys=path dez=(list [desk path]) prime=?]
|= [sys=path dez=(list [desk path]) prime=? exc=(list spur)]
^- pill
=/ bas=path (scag 3 sys)
:: compiler-source: hoon source file producing compiler, `sys/hoon`
@ -274,12 +277,14 @@
::
:+ %pill %brass
:+ boot-ova
:~ (boot-ovum:pill compiler-source arvo-source)
(file-ovum2:pill bas)
:~ (boot-ovum compiler-source arvo-source)
(file-ovum2 [bas exc])
==
=. dez (snoc dez [%base bas])
%+ weld
(turn dez file-ovum)
%+ turn dez
|= [dek=desk bas=path]
(file-ovum [dek bas exc])
?. prime ~
[(prep-ovum (turn dez tail))]~
::
@ -355,7 +360,7 @@
::TODO will exclude non-:directories files, such as /changelog/txt
=- (murn - same)
^- (list (unit ovum))
:~ `(file-ovum as (en-beam beak /))
:~ `(file-ovum as (en-beam beak /) ~)
::
?. pri ~
`(prep-ovum (en-beam beak /) ~)

View File

@ -201,7 +201,8 @@
?^ dat=(get:wav wav.tide u.when.req)
:_ pub :_ ~
(send scry/wave/u.dat src.bowl [dude u.when path]:req)
?. (gth u.when.req key::(fall (ram:wav wav.tide) [key=+(u.when.req) **]))
?: %+ lte u.when.req
key::(fall (ram:wav wav.tide) (pry:rok rok.tide) [=key val]:wav)
:_ pub :_ ~
(send yore/~ src.bowl [dude u.when path]:req)
:- ~[(send nigh/~ src.bowl [dude u.when path]:req)]

View File

@ -1,2 +1,3 @@
[%zuse 416]
[%zuse 415]
[%zuse 414]