keri-ts 0.11.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/esm/keri/npm/src/_dnt.polyfills.js +36 -0
- package/esm/keri/npm/src/acdc/observing.js +8 -34
- package/esm/keri/npm/src/acdc/regbasing.js +9 -20
- package/esm/keri/npm/src/acdc/regengine.js +17 -96
- package/esm/keri/npm/src/acdc/registering.js +9 -12
- package/esm/keri/npm/src/acdc/registraring.js +82 -46
- package/esm/keri/npm/src/acdc/scheming.js +12 -69
- package/esm/keri/npm/src/app/abortable.js +41 -4
- package/esm/keri/npm/src/app/agent-runtime.js +75 -169
- package/esm/keri/npm/src/app/authenticating.js +4 -24
- package/esm/keri/npm/src/app/byte-source.js +8 -16
- package/esm/keri/npm/src/app/cesr-egress.js +129 -143
- package/esm/keri/npm/src/app/cesr-http.js +10 -25
- package/esm/keri/npm/src/app/challenging.js +13 -8
- package/esm/keri/npm/src/app/cli/annotate.js +3 -8
- package/esm/keri/npm/src/app/cli/benchmark.js +3 -5
- package/esm/keri/npm/src/app/cli/challenge.js +16 -14
- package/esm/keri/npm/src/app/cli/common/context.js +1 -4
- package/esm/keri/npm/src/app/cli/common/existing.js +0 -18
- package/esm/keri/npm/src/app/cli/db-dump.js +3 -17
- package/esm/keri/npm/src/app/cli/delegate.js +37 -57
- package/esm/keri/npm/src/app/cli/did.js +12 -21
- package/esm/keri/npm/src/app/cli/ends.js +3 -5
- package/esm/keri/npm/src/app/cli/exchange.js +0 -2
- package/esm/keri/npm/src/app/cli/incept.js +5 -7
- package/esm/keri/npm/src/app/cli/init.js +3 -9
- package/esm/keri/npm/src/app/cli/ipex.js +129 -63
- package/esm/keri/npm/src/app/cli/loc.js +7 -10
- package/esm/keri/npm/src/app/cli/multisig.js +140 -54
- package/esm/keri/npm/src/app/cli/oobi.js +3 -5
- package/esm/keri/npm/src/app/cli/query.js +28 -29
- package/esm/keri/npm/src/app/cli/rotate.js +3 -5
- package/esm/keri/npm/src/app/cli/vc.js +2 -3
- package/esm/keri/npm/src/app/cli/verifier.js +5 -9
- package/esm/keri/npm/src/app/credential-workflows.js +22 -44
- package/esm/keri/npm/src/app/cue-runtime.js +23 -89
- package/esm/keri/npm/src/app/delegating.js +26 -18
- package/esm/keri/npm/src/app/endpoint-roleing.js +30 -26
- package/esm/keri/npm/src/app/essr.js +10 -75
- package/esm/keri/npm/src/app/exchanging.js +82 -300
- package/esm/keri/npm/src/app/forwarding.js +124 -534
- package/esm/keri/npm/src/app/grouping.js +192 -108
- package/esm/keri/npm/src/app/habbing.js +37 -87
- package/esm/keri/npm/src/app/httping.js +44 -12
- package/esm/keri/npm/src/app/ipex-credentialing.js +38 -35
- package/esm/keri/npm/src/app/ipex-graph.js +147 -37
- package/esm/keri/npm/src/app/ipex-grouping.js +31 -72
- package/esm/keri/npm/src/app/ipex-node-authentication.js +108 -0
- package/esm/keri/npm/src/app/ipex-v2.js +28 -132
- package/esm/keri/npm/src/app/ipexing.js +2 -10
- package/esm/keri/npm/src/app/mailbox-director.js +30 -128
- package/esm/keri/npm/src/app/mailbox-sse.js +10 -27
- package/esm/keri/npm/src/app/mailboxing.js +12 -16
- package/esm/keri/npm/src/app/multisig-workflows.js +142 -222
- package/esm/keri/npm/src/app/notifying.js +15 -36
- package/esm/keri/npm/src/app/oobi-replies.js +55 -138
- package/esm/keri/npm/src/app/oobiery.js +63 -205
- package/esm/keri/npm/src/app/parsering.js +48 -46
- package/esm/keri/npm/src/app/query-replies.js +36 -117
- package/esm/keri/npm/src/app/querying.js +246 -511
- package/esm/keri/npm/src/app/reactor.js +175 -298
- package/esm/keri/npm/src/app/reply-streams.js +12 -131
- package/esm/keri/npm/src/app/respondant.js +256 -71
- package/esm/keri/npm/src/app/runtime-services.js +0 -3
- package/esm/keri/npm/src/app/signaling.js +29 -240
- package/esm/keri/npm/src/app/socket-source.js +2 -3
- package/esm/keri/npm/src/app/stored-replies.js +13 -45
- package/esm/keri/npm/src/app/tcp-conversation.js +85 -0
- package/esm/keri/npm/src/app/tcp-egress.js +154 -237
- package/esm/keri/npm/src/app/verifier-agent.js +25 -43
- package/esm/keri/npm/src/app/verifying.js +10 -40
- package/esm/keri/npm/src/app/version.js +2 -2
- package/esm/keri/npm/src/app/witnessing.js +231 -273
- package/esm/keri/npm/src/core/deck.js +5 -44
- package/esm/keri/npm/src/core/dispatch.js +10 -2
- package/esm/keri/npm/src/core/errors.js +5 -10
- package/esm/keri/npm/src/core/eventing.js +153 -366
- package/esm/keri/npm/src/core/kever-decisions.js +5 -10
- package/esm/keri/npm/src/core/kever.js +80 -163
- package/esm/keri/npm/src/core/kram-pruning.js +2 -12
- package/esm/keri/npm/src/core/kram-staging.js +56 -118
- package/esm/keri/npm/src/core/kram-time.js +6 -13
- package/esm/keri/npm/src/core/kraming.js +28 -49
- package/esm/keri/npm/src/core/protocol-eventing.js +5 -0
- package/esm/keri/npm/src/core/protocol-exchanging.js +21 -0
- package/esm/keri/npm/src/core/protocol-vdr-eventing.js +10 -11
- package/esm/keri/npm/src/core/records.js +0 -19
- package/esm/keri/npm/src/core/routing.js +138 -185
- package/esm/keri/npm/src/db/basing.js +162 -196
- package/esm/keri/npm/src/db/core/keys.js +2 -2
- package/esm/keri/npm/src/db/core/lmdber.js +20 -85
- package/esm/keri/npm/src/db/core/path-manager.js +2 -4
- package/esm/keri/npm/src/db/escrowing.js +12 -154
- package/esm/keri/npm/src/db/exchange-nests.js +21 -116
- package/esm/keri/npm/src/db/index.js +0 -2
- package/esm/keri/npm/src/db/keeping.js +1 -3
- package/esm/keri/npm/src/db/kel-replay.js +2 -21
- package/esm/keri/npm/src/db/kram-factors.js +16 -49
- package/esm/keri/npm/src/db/mailboxing.js +2 -5
- package/esm/keri/npm/src/db/payload-archive.js +1 -1
- package/esm/keri/npm/src/db/payload-store.js +4 -14
- package/esm/keri/npm/src/db/reger.js +12 -42
- package/esm/keri/npm/src/db/subing.js +0 -8
- package/esm/keri/npm/src/db/tel-replay.js +4 -36
- package/esm/keri/npm/src/db/witness-replay.js +6 -12
- package/esm/keri/npm/src/did/keri/resolving.js +4 -18
- package/esm/keri/npm/src/did/webs/artifacts.js +13 -13
- package/esm/keri/npm/src/did/webs/designated-aliases.js +16 -44
- package/esm/keri/npm/src/did/webs/documenting.js +8 -8
- package/esm/keri/npm/src/did/webs/resolving.js +9 -27
- package/esm/keri/npm/src/runtime/index.js +70 -71
- package/esm/keri/npm/src/vdr/credential-tsn.js +126 -114
- package/esm/keri/npm/src/vdr/credentialing.js +0 -27
- package/esm/keri/npm/src/vdr/eventing.js +50 -56
- package/esm/keri/npm/src/vdr/registry-tsn.js +110 -111
- package/esm/keri/npm/src/vdr/tsn-query.js +15 -10
- package/package.json +4 -20
- package/types/_dnt.polyfills.d.ts +49 -0
- package/types/_dnt.polyfills.d.ts.map +1 -1
- package/types/acdc/observing.d.ts +1 -8
- package/types/acdc/observing.d.ts.map +1 -1
- package/types/acdc/regbasing.d.ts +5 -8
- package/types/acdc/regbasing.d.ts.map +1 -1
- package/types/acdc/regengine.d.ts +6 -25
- package/types/acdc/regengine.d.ts.map +1 -1
- package/types/acdc/registering.d.ts +6 -6
- package/types/acdc/registering.d.ts.map +1 -1
- package/types/acdc/registraring.d.ts +21 -21
- package/types/acdc/registraring.d.ts.map +1 -1
- package/types/acdc/scheming.d.ts +3 -2
- package/types/acdc/scheming.d.ts.map +1 -1
- package/types/app/abortable.d.ts +2 -0
- package/types/app/abortable.d.ts.map +1 -1
- package/types/app/agent-runtime.d.ts +27 -90
- package/types/app/agent-runtime.d.ts.map +1 -1
- package/types/app/authenticating.d.ts.map +1 -1
- package/types/app/byte-source.d.ts +4 -4
- package/types/app/byte-source.d.ts.map +1 -1
- package/types/app/cesr-egress.d.ts +18 -21
- package/types/app/cesr-egress.d.ts.map +1 -1
- package/types/app/cesr-http.d.ts +6 -7
- package/types/app/cesr-http.d.ts.map +1 -1
- package/types/app/challenging.d.ts +6 -0
- package/types/app/challenging.d.ts.map +1 -1
- package/types/app/cli/annotate.d.ts.map +1 -1
- package/types/app/cli/benchmark.d.ts.map +1 -1
- package/types/app/cli/challenge.d.ts.map +1 -1
- package/types/app/cli/common/context.d.ts +0 -4
- package/types/app/cli/common/context.d.ts.map +1 -1
- package/types/app/cli/common/existing.d.ts +0 -4
- package/types/app/cli/common/existing.d.ts.map +1 -1
- package/types/app/cli/db-dump.d.ts +0 -2
- package/types/app/cli/db-dump.d.ts.map +1 -1
- package/types/app/cli/delegate.d.ts +0 -22
- package/types/app/cli/delegate.d.ts.map +1 -1
- package/types/app/cli/did.d.ts.map +1 -1
- package/types/app/cli/ends.d.ts.map +1 -1
- package/types/app/cli/exchange.d.ts.map +1 -1
- package/types/app/cli/init.d.ts.map +1 -1
- package/types/app/cli/ipex.d.ts +1 -1
- package/types/app/cli/ipex.d.ts.map +1 -1
- package/types/app/cli/loc.d.ts.map +1 -1
- package/types/app/cli/multisig.d.ts.map +1 -1
- package/types/app/cli/oobi.d.ts +1 -1
- package/types/app/cli/oobi.d.ts.map +1 -1
- package/types/app/cli/query.d.ts.map +1 -1
- package/types/app/cli/rotate.d.ts.map +1 -1
- package/types/app/cli/vc.d.ts.map +1 -1
- package/types/app/cli/verifier.d.ts.map +1 -1
- package/types/app/credential-workflows.d.ts +4 -9
- package/types/app/credential-workflows.d.ts.map +1 -1
- package/types/app/cue-runtime.d.ts +3 -37
- package/types/app/cue-runtime.d.ts.map +1 -1
- package/types/app/delegating.d.ts +13 -8
- package/types/app/delegating.d.ts.map +1 -1
- package/types/app/endpoint-roleing.d.ts +7 -5
- package/types/app/endpoint-roleing.d.ts.map +1 -1
- package/types/app/essr.d.ts +5 -19
- package/types/app/essr.d.ts.map +1 -1
- package/types/app/exchanging.d.ts +17 -29
- package/types/app/exchanging.d.ts.map +1 -1
- package/types/app/forwarding.d.ts +32 -91
- package/types/app/forwarding.d.ts.map +1 -1
- package/types/app/grouping.d.ts +52 -8
- package/types/app/grouping.d.ts.map +1 -1
- package/types/app/habbing.d.ts +16 -25
- package/types/app/habbing.d.ts.map +1 -1
- package/types/app/httping.d.ts +7 -0
- package/types/app/httping.d.ts.map +1 -1
- package/types/app/ipex-credentialing.d.ts +9 -4
- package/types/app/ipex-credentialing.d.ts.map +1 -1
- package/types/app/ipex-graph.d.ts +21 -2
- package/types/app/ipex-graph.d.ts.map +1 -1
- package/types/app/ipex-grouping.d.ts +6 -14
- package/types/app/ipex-grouping.d.ts.map +1 -1
- package/types/app/ipex-node-authentication.d.ts +27 -0
- package/types/app/ipex-node-authentication.d.ts.map +1 -0
- package/types/app/ipex-v2.d.ts +2 -7
- package/types/app/ipex-v2.d.ts.map +1 -1
- package/types/app/ipexing.d.ts +2 -4
- package/types/app/ipexing.d.ts.map +1 -1
- package/types/app/mailbox-director.d.ts +12 -31
- package/types/app/mailbox-director.d.ts.map +1 -1
- package/types/app/mailbox-sse.d.ts +4 -10
- package/types/app/mailbox-sse.d.ts.map +1 -1
- package/types/app/mailboxing.d.ts +3 -6
- package/types/app/mailboxing.d.ts.map +1 -1
- package/types/app/multisig-workflows.d.ts +9 -21
- package/types/app/multisig-workflows.d.ts.map +1 -1
- package/types/app/notifying.d.ts +1 -1
- package/types/app/notifying.d.ts.map +1 -1
- package/types/app/oobi-replies.d.ts +2 -12
- package/types/app/oobi-replies.d.ts.map +1 -1
- package/types/app/oobiery.d.ts +0 -2
- package/types/app/oobiery.d.ts.map +1 -1
- package/types/app/parsering.d.ts +20 -27
- package/types/app/parsering.d.ts.map +1 -1
- package/types/app/query-replies.d.ts +16 -21
- package/types/app/query-replies.d.ts.map +1 -1
- package/types/app/querying.d.ts +59 -132
- package/types/app/querying.d.ts.map +1 -1
- package/types/app/reactor.d.ts +44 -77
- package/types/app/reactor.d.ts.map +1 -1
- package/types/app/reply-streams.d.ts +4 -35
- package/types/app/reply-streams.d.ts.map +1 -1
- package/types/app/respondant.d.ts +39 -24
- package/types/app/respondant.d.ts.map +1 -1
- package/types/app/runtime-services.d.ts +0 -3
- package/types/app/runtime-services.d.ts.map +1 -1
- package/types/app/signaling.d.ts +6 -34
- package/types/app/signaling.d.ts.map +1 -1
- package/types/app/socket-source.d.ts +2 -3
- package/types/app/socket-source.d.ts.map +1 -1
- package/types/app/stored-replies.d.ts +3 -10
- package/types/app/stored-replies.d.ts.map +1 -1
- package/types/app/tcp-conversation.d.ts +27 -0
- package/types/app/tcp-conversation.d.ts.map +1 -0
- package/types/app/tcp-egress.d.ts +27 -65
- package/types/app/tcp-egress.d.ts.map +1 -1
- package/types/app/verifier-agent.d.ts +5 -4
- package/types/app/verifier-agent.d.ts.map +1 -1
- package/types/app/verifying.d.ts +2 -3
- package/types/app/verifying.d.ts.map +1 -1
- package/types/app/version.d.ts +2 -2
- package/types/app/version.d.ts.map +1 -1
- package/types/app/witnessing.d.ts +34 -38
- package/types/app/witnessing.d.ts.map +1 -1
- package/types/core/cues.d.ts +68 -36
- package/types/core/cues.d.ts.map +1 -1
- package/types/core/deck.d.ts +2 -12
- package/types/core/deck.d.ts.map +1 -1
- package/types/core/dispatch.d.ts +7 -3
- package/types/core/dispatch.d.ts.map +1 -1
- package/types/core/errors.d.ts +4 -4
- package/types/core/errors.d.ts.map +1 -1
- package/types/core/eventing.d.ts +15 -38
- package/types/core/eventing.d.ts.map +1 -1
- package/types/core/kever-decisions.d.ts +16 -15
- package/types/core/kever-decisions.d.ts.map +1 -1
- package/types/core/kever.d.ts +11 -45
- package/types/core/kever.d.ts.map +1 -1
- package/types/core/kram-pruning.d.ts +2 -2
- package/types/core/kram-pruning.d.ts.map +1 -1
- package/types/core/kram-staging.d.ts +9 -15
- package/types/core/kram-staging.d.ts.map +1 -1
- package/types/core/kram-time.d.ts +3 -9
- package/types/core/kram-time.d.ts.map +1 -1
- package/types/core/kraming.d.ts +18 -22
- package/types/core/kraming.d.ts.map +1 -1
- package/types/core/protocol-eventing.d.ts +5 -0
- package/types/core/protocol-eventing.d.ts.map +1 -1
- package/types/core/protocol-exchanging.d.ts +8 -0
- package/types/core/protocol-exchanging.d.ts.map +1 -1
- package/types/core/protocol-vdr-eventing.d.ts +7 -5
- package/types/core/protocol-vdr-eventing.d.ts.map +1 -1
- package/types/core/records.d.ts +14 -49
- package/types/core/records.d.ts.map +1 -1
- package/types/core/routing.d.ts +52 -42
- package/types/core/routing.d.ts.map +1 -1
- package/types/db/basing.d.ts +46 -39
- package/types/db/basing.d.ts.map +1 -1
- package/types/db/core/keys.d.ts.map +1 -1
- package/types/db/core/lmdber.d.ts +3 -10
- package/types/db/core/lmdber.d.ts.map +1 -1
- package/types/db/core/path-manager.d.ts.map +1 -1
- package/types/db/escrowing.d.ts +9 -48
- package/types/db/escrowing.d.ts.map +1 -1
- package/types/db/exchange-nests.d.ts +5 -29
- package/types/db/exchange-nests.d.ts.map +1 -1
- package/types/db/exchange-records.d.ts +2 -4
- package/types/db/exchange-records.d.ts.map +1 -1
- package/types/db/index.d.ts +0 -2
- package/types/db/index.d.ts.map +1 -1
- package/types/db/keeping.d.ts.map +1 -1
- package/types/db/kel-replay.d.ts +1 -4
- package/types/db/kel-replay.d.ts.map +1 -1
- package/types/db/koming.d.ts +1 -1
- package/types/db/koming.d.ts.map +1 -1
- package/types/db/kram-factors.d.ts +1 -3
- package/types/db/kram-factors.d.ts.map +1 -1
- package/types/db/mailboxing.d.ts +1 -2
- package/types/db/mailboxing.d.ts.map +1 -1
- package/types/db/payload-store.d.ts +2 -2
- package/types/db/payload-store.d.ts.map +1 -1
- package/types/db/reger.d.ts +4 -7
- package/types/db/reger.d.ts.map +1 -1
- package/types/db/subing.d.ts +1 -5
- package/types/db/subing.d.ts.map +1 -1
- package/types/db/tel-replay.d.ts +2 -7
- package/types/db/tel-replay.d.ts.map +1 -1
- package/types/db/witness-replay.d.ts +1 -2
- package/types/db/witness-replay.d.ts.map +1 -1
- package/types/did/keri/resolving.d.ts +5 -10
- package/types/did/keri/resolving.d.ts.map +1 -1
- package/types/did/webs/artifacts.d.ts.map +1 -1
- package/types/did/webs/designated-aliases.d.ts +5 -3
- package/types/did/webs/designated-aliases.d.ts.map +1 -1
- package/types/did/webs/documenting.d.ts +6 -5
- package/types/did/webs/documenting.d.ts.map +1 -1
- package/types/did/webs/resolving.d.ts +6 -0
- package/types/did/webs/resolving.d.ts.map +1 -1
- package/types/runtime/index.d.ts +70 -72
- package/types/runtime/index.d.ts.map +1 -1
- package/types/vdr/credential-tsn.d.ts +6 -1
- package/types/vdr/credential-tsn.d.ts.map +1 -1
- package/types/vdr/credentialing.d.ts +0 -10
- package/types/vdr/credentialing.d.ts.map +1 -1
- package/types/vdr/eventing.d.ts +7 -6
- package/types/vdr/eventing.d.ts.map +1 -1
- package/types/vdr/registry-tsn.d.ts +9 -4
- package/types/vdr/registry-tsn.d.ts.map +1 -1
- package/types/vdr/tsn-query.d.ts +8 -3
- package/types/vdr/tsn-query.d.ts.map +1 -1
- package/esm/keri/npm/src/app/cesr-output.js +0 -12
- package/esm/keri/npm/src/app/cue-delivery.js +0 -171
- package/esm/keri/npm/src/app/cue-preparation.js +0 -124
- package/esm/keri/npm/src/app/cue-route.js +0 -64
- package/esm/keri/npm/src/app/direct-reply-delivery.js +0 -282
- package/esm/keri/npm/src/app/ipex-building.js +0 -164
- package/esm/keri/npm/src/app/runtime-deliveries.js +0 -510
- package/esm/keri/npm/src/core/cue-admission.js +0 -419
- package/esm/keri/npm/src/core/kram-handoff.js +0 -148
- package/esm/keri/npm/src/db/kram-snapshots.js +0 -216
- package/esm/keri/npm/src/db/mailbox-inbox.js +0 -206
- package/esm/keri/npm/src/db/outboxing.js +0 -371
- package/types/app/cesr-output.d.ts +0 -5
- package/types/app/cesr-output.d.ts.map +0 -1
- package/types/app/cue-delivery.d.ts +0 -30
- package/types/app/cue-delivery.d.ts.map +0 -1
- package/types/app/cue-preparation.d.ts +0 -25
- package/types/app/cue-preparation.d.ts.map +0 -1
- package/types/app/cue-route.d.ts +0 -19
- package/types/app/cue-route.d.ts.map +0 -1
- package/types/app/direct-reply-delivery.d.ts +0 -38
- package/types/app/direct-reply-delivery.d.ts.map +0 -1
- package/types/app/ipex-building.d.ts +0 -30
- package/types/app/ipex-building.d.ts.map +0 -1
- package/types/app/runtime-deliveries.d.ts +0 -67
- package/types/app/runtime-deliveries.d.ts.map +0 -1
- package/types/core/cue-admission.d.ts +0 -74
- package/types/core/cue-admission.d.ts.map +0 -1
- package/types/core/kram-handoff.d.ts +0 -45
- package/types/core/kram-handoff.d.ts.map +0 -1
- package/types/db/kram-snapshots.d.ts +0 -23
- package/types/db/kram-snapshots.d.ts.map +0 -1
- package/types/db/mailbox-inbox.d.ts +0 -72
- package/types/db/mailbox-inbox.d.ts.map +0 -1
- package/types/db/outboxing.d.ts +0 -182
- package/types/db/outboxing.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
import { Diger, dumps, ParserError
|
|
1
|
+
/** Local v2 ACDC schema validation against the inspected 71438328 profile; no network resolution. */
|
|
2
|
+
import { Diger, dumps, ParserError } from "cesr-ts";
|
|
3
3
|
import Ajv2020 from "ajv/dist/2020.js";
|
|
4
4
|
import { ValidationError } from "../core/errors.js";
|
|
5
5
|
import { Schemer } from "../core/scheming.js";
|
|
@@ -39,57 +39,6 @@ const singles = [
|
|
|
39
39
|
];
|
|
40
40
|
const maps = ["$defs", "properties", "patternProperties", "dependentSchemas"];
|
|
41
41
|
const arrays = ["prefixItems", "allOf", "anyOf", "oneOf"];
|
|
42
|
-
/** Admission counts values/depth as well as bytes before cloning or compiling; native row allocation remains separate. */
|
|
43
|
-
class Credit {
|
|
44
|
-
constructor() {
|
|
45
|
-
Object.defineProperty(this, "bytes", {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
configurable: true,
|
|
48
|
-
writable: true,
|
|
49
|
-
value: 8 * 1024 ** 2
|
|
50
|
-
});
|
|
51
|
-
Object.defineProperty(this, "values", {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
configurable: true,
|
|
54
|
-
writable: true,
|
|
55
|
-
value: 4096
|
|
56
|
-
});
|
|
57
|
-
Object.defineProperty(this, "refs", {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
configurable: true,
|
|
60
|
-
writable: true,
|
|
61
|
-
value: 4096
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
take(schema) {
|
|
65
|
-
const work = [[schema, 0]];
|
|
66
|
-
let characters = this.bytes;
|
|
67
|
-
while (work.length) {
|
|
68
|
-
const [value, depth] = work.pop();
|
|
69
|
-
if (--this.values < 0 || depth > 64)
|
|
70
|
-
throw new ResourceLimitError("ACDC schema value/depth credit exhausted");
|
|
71
|
-
if (typeof value === "string")
|
|
72
|
-
characters -= value.length;
|
|
73
|
-
if (characters < 0)
|
|
74
|
-
throw new ResourceLimitError("ACDC schema byte credit exhausted");
|
|
75
|
-
if (value && typeof value === "object") {
|
|
76
|
-
for (const key in value) {
|
|
77
|
-
if (!Object.hasOwn(value, key))
|
|
78
|
-
continue;
|
|
79
|
-
characters -= key.length;
|
|
80
|
-
if (characters < 0)
|
|
81
|
-
throw new ResourceLimitError("ACDC schema byte credit exhausted");
|
|
82
|
-
if (work.length >= this.values)
|
|
83
|
-
throw new ResourceLimitError("ACDC schema value credit exhausted");
|
|
84
|
-
work.push([value[key], depth + 1]);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
this.bytes -= dumps(schema, "JSON").length;
|
|
89
|
-
if (this.bytes < 0)
|
|
90
|
-
throw new ResourceLimitError("ACDC schema byte credit exhausted");
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
42
|
/** Plain maps and booleans are the only JSON Schema resource/fragment targets. */
|
|
94
43
|
function object(value) {
|
|
95
44
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -102,7 +51,7 @@ function digest(value) {
|
|
|
102
51
|
return diger;
|
|
103
52
|
}
|
|
104
53
|
catch (error) {
|
|
105
|
-
if (!(error instanceof ParserError)
|
|
54
|
+
if (!(error instanceof ParserError))
|
|
106
55
|
throw error;
|
|
107
56
|
}
|
|
108
57
|
throw new InvalidSchema("Schema reference must contain a complete SAID");
|
|
@@ -213,9 +162,7 @@ function fragment(resource, value) {
|
|
|
213
162
|
}
|
|
214
163
|
/** Local static schema closure plus a synchronous Draft 2020-12 validator; legacy Schemer behavior is unchanged. */
|
|
215
164
|
export function validateSchema(acdc, db, override) {
|
|
216
|
-
|
|
217
|
-
throw new ResourceLimitError("ACDC schema input exceeds finite body limit");
|
|
218
|
-
const credit = new Credit(), resources = new Map(), roots = [];
|
|
165
|
+
const resources = new Map(), roots = [];
|
|
219
166
|
const scopes = new Map(), refs = [];
|
|
220
167
|
const work = [];
|
|
221
168
|
let missing = null;
|
|
@@ -234,18 +181,14 @@ export function validateSchema(acdc, db, override) {
|
|
|
234
181
|
}
|
|
235
182
|
return add(cached.sed, true, said);
|
|
236
183
|
}
|
|
237
|
-
/**
|
|
184
|
+
/** Verify each original resource before cloning it for compilation. */
|
|
238
185
|
function add(schema, root, expected) {
|
|
239
|
-
if (root)
|
|
240
|
-
credit.take(schema);
|
|
241
186
|
const said = identity(schema, root);
|
|
242
187
|
if (expected && said !== expected)
|
|
243
188
|
throw new InvalidSchema("Cached schema does not match its lookup SAID");
|
|
244
189
|
const existing = resources.get(said);
|
|
245
190
|
if (existing)
|
|
246
191
|
return existing;
|
|
247
|
-
if (resources.size >= 128)
|
|
248
|
-
throw new ResourceLimitError("ACDC schema resource credit exhausted");
|
|
249
192
|
const resource = { said, schema, anchors: new Map() };
|
|
250
193
|
resources.set(said, resource);
|
|
251
194
|
if (root)
|
|
@@ -259,7 +202,7 @@ export function validateSchema(acdc, db, override) {
|
|
|
259
202
|
if (!root) {
|
|
260
203
|
return missing
|
|
261
204
|
? { kind: "missing", said: missing }
|
|
262
|
-
: { kind: "invalid", reason: "Invalid ACDC schema field" };
|
|
205
|
+
: { kind: "invalid", subject: "schema", reason: "Invalid ACDC schema field" };
|
|
263
206
|
}
|
|
264
207
|
for (;;) {
|
|
265
208
|
while (work.length) {
|
|
@@ -278,8 +221,6 @@ export function validateSchema(acdc, db, override) {
|
|
|
278
221
|
if (typeof node.$anchor === "string")
|
|
279
222
|
owner.anchors.set(node.$anchor, node);
|
|
280
223
|
if ("$ref" in node) {
|
|
281
|
-
if (--credit.refs < 0)
|
|
282
|
-
throw new ResourceLimitError("ACDC schema reference credit exhausted");
|
|
283
224
|
refs.push({ node, resource: owner, value: node.$ref });
|
|
284
225
|
}
|
|
285
226
|
for (const child of children(node))
|
|
@@ -344,20 +285,22 @@ export function validateSchema(acdc, db, override) {
|
|
|
344
285
|
}
|
|
345
286
|
catch (error) {
|
|
346
287
|
if (error instanceof SyntaxError && error.message.includes("regular expression")) {
|
|
347
|
-
return { kind: "invalid", reason: error.message };
|
|
288
|
+
return { kind: "invalid", subject: "schema", reason: error.message };
|
|
348
289
|
}
|
|
349
290
|
if (error instanceof Error && /^reference "urn:said:[^"]+" resolves to more than one schema$/.test(error.message)) {
|
|
350
|
-
return { kind: "invalid", reason: error.message };
|
|
291
|
+
return { kind: "invalid", subject: "schema", reason: error.message };
|
|
351
292
|
}
|
|
352
293
|
throw error;
|
|
353
294
|
}
|
|
354
295
|
if (!validate)
|
|
355
296
|
throw new Error("Admitted schema was not registered");
|
|
356
|
-
return validate(acdc.sad)
|
|
297
|
+
return validate(acdc.sad)
|
|
298
|
+
? { kind: "valid" }
|
|
299
|
+
: { kind: "invalid", subject: "credential", reason: validator.errorsText(validate.errors) };
|
|
357
300
|
}
|
|
358
301
|
catch (error) {
|
|
359
302
|
if (error instanceof InvalidSchema)
|
|
360
|
-
return { kind: "invalid", reason: error.message };
|
|
303
|
+
return { kind: "invalid", subject: "schema", reason: error.message };
|
|
361
304
|
throw error;
|
|
362
305
|
}
|
|
363
306
|
}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
import { call, useScope } from "effection";
|
|
1
|
+
import { call, ensure, useScope } from "effection";
|
|
2
|
+
/** Remove only this operation's cancellation from joined I/O failures. */
|
|
3
|
+
function remainingFailures(error, cancellation) {
|
|
4
|
+
if (error === cancellation)
|
|
5
|
+
return [];
|
|
6
|
+
if (!(error instanceof AggregateError))
|
|
7
|
+
return [error];
|
|
8
|
+
const remaining = error.errors.flatMap((child) => remainingFailures(child, cancellation));
|
|
9
|
+
return remaining.length === error.errors.length && remaining.every((child, index) => child === error.errors[index])
|
|
10
|
+
? [error]
|
|
11
|
+
: remaining;
|
|
12
|
+
}
|
|
13
|
+
/** Preserve foreign cleanup failures, removing only this owner's exact abort reason. */
|
|
14
|
+
export function rethrowCleanupFailure(error, signal) {
|
|
15
|
+
const failures = remainingFailures(error, signal.reason);
|
|
16
|
+
if (failures.length === 1)
|
|
17
|
+
throw failures[0];
|
|
18
|
+
if (failures.length)
|
|
19
|
+
throw new AggregateError(failures, "I/O cleanup failed during cancellation");
|
|
20
|
+
}
|
|
2
21
|
/**
|
|
3
22
|
* Own one cancellable Promise leaf inside an Effection operation.
|
|
4
23
|
* The leaf must observe its signal; teardown aborts it and joins its cleanup before returning.
|
|
@@ -12,16 +31,34 @@ export function abortable(start, upstream) {
|
|
|
12
31
|
const controller = new AbortController();
|
|
13
32
|
const signal = upstream ? AbortSignal.any([controller.signal, upstream]) : controller.signal;
|
|
14
33
|
let pending;
|
|
34
|
+
let reported = false;
|
|
35
|
+
// Register joining before work children, so they halt before their pending Promise is joined.
|
|
36
|
+
yield* ensure(function* () {
|
|
37
|
+
if (pending) {
|
|
38
|
+
yield* call(async () => {
|
|
39
|
+
try {
|
|
40
|
+
await pending;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (reported)
|
|
44
|
+
return;
|
|
45
|
+
rethrowCleanupFailure(error, signal);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
15
50
|
try {
|
|
16
51
|
signal.throwIfAborted();
|
|
17
52
|
pending = start(signal, yield* useScope());
|
|
18
53
|
return yield* call(() => pending);
|
|
19
54
|
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
reported = true;
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
20
59
|
finally {
|
|
60
|
+
// Abort before child teardown; joining is the registered resource's responsibility.
|
|
21
61
|
controller.abort();
|
|
22
|
-
// Cancellation stops waiting at the yield, but the leaf still owns I/O until its Promise settles.
|
|
23
|
-
if (pending)
|
|
24
|
-
yield* call(() => pending.then(() => { }, () => { }));
|
|
25
62
|
}
|
|
26
63
|
});
|
|
27
64
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { call, resource, spawn } from "effection";
|
|
1
|
+
import { call, resource, spawn, suspend } from "effection";
|
|
2
2
|
import { createRegery as createAcdcRegery } from "../acdc/registraring.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Deck } from "../core/deck.js";
|
|
4
4
|
import { DatabaseNotOpenError } from "../core/errors.js";
|
|
5
5
|
import { CREDENTIAL_MAILBOX_TOPIC, DELEGATE_MAILBOX_TOPIC, RECEIPT_MAILBOX_TOPIC, REPLAY_MAILBOX_TOPIC, REPLY_MAILBOX_TOPIC, } from "../core/mailbox-topics.js";
|
|
6
6
|
import { Mailboxer } from "../db/mailboxing.js";
|
|
7
7
|
import { Noter } from "../db/noting.js";
|
|
8
|
-
import { createReger
|
|
8
|
+
import { createReger } from "../db/reger.js";
|
|
9
9
|
import { Regery as VdrRegery } from "../vdr/credentialing.js";
|
|
10
|
-
import { Tevery } from "../vdr/eventing.js";
|
|
11
10
|
import { Authenticator } from "./authenticating.js";
|
|
12
11
|
import { loadChallengeHandlers } from "./challenging.js";
|
|
13
|
-
import { cueDo
|
|
12
|
+
import { cueDo } from "./cue-runtime.js";
|
|
14
13
|
import { Anchorer, loadDelegationHandlers } from "./delegating.js";
|
|
15
14
|
import { ForwardHandler, MailboxPoller, mailboxTopicForRoute, Poster, } from "./forwarding.js";
|
|
16
15
|
import { loadMultisigHandlers } from "./grouping.js";
|
|
@@ -23,42 +22,31 @@ import { QueryCoordinator } from "./querying.js";
|
|
|
23
22
|
import { Reactor } from "./reactor.js";
|
|
24
23
|
import { ReplyStreams } from "./reply-streams.js";
|
|
25
24
|
import { Respondant } from "./respondant.js";
|
|
26
|
-
import { RuntimeDeliveries } from "./runtime-deliveries.js";
|
|
27
25
|
import { resolveRuntimeServices } from "./runtime-services.js";
|
|
28
26
|
import { runtimeTurn } from "./runtime-turn.js";
|
|
29
27
|
import { Signaler } from "./signaling.js";
|
|
30
|
-
import { Verifier } from "./verifying.js";
|
|
31
28
|
/**
|
|
32
29
|
* Create the shared runtime composition root used by CLI commands and
|
|
33
30
|
* `tufa agent`.
|
|
34
31
|
*
|
|
35
32
|
* Construction rule:
|
|
36
|
-
* -
|
|
37
|
-
*
|
|
38
|
-
* - hosting style changes where the runtime is run, not what it is
|
|
33
|
+
* - hosts choose concrete optional stores and borrow supplied dependencies
|
|
34
|
+
* - the composition owns only stores it constructs
|
|
39
35
|
*/
|
|
40
36
|
export function* createAgentRuntime(hby, options = {}) {
|
|
41
|
-
const resources = hby.db.resources;
|
|
42
|
-
if ((options.resources && options.resources !== resources)
|
|
43
|
-
|| (options.services?.resources && options.services.resources !== resources)) {
|
|
44
|
-
throw new RangeError("AgentRuntime requires the Habery Baser resource policy; supply it when opening Habery");
|
|
45
|
-
}
|
|
46
37
|
const injectedSignaler = options.signaler ?? options.notifier?.signaler;
|
|
47
|
-
if ((
|
|
48
|
-
|| (options.notifier && options.notifier.hby !== hby)
|
|
38
|
+
if ((options.notifier && options.notifier.hby !== hby)
|
|
49
39
|
|| (options.signaler && options.notifier && options.signaler !== options.notifier.signaler)) {
|
|
50
|
-
throw new RangeError("AgentRuntime notification services require its exact Habery and
|
|
40
|
+
throw new RangeError("AgentRuntime notification services require its exact Habery and Signaler");
|
|
51
41
|
}
|
|
52
|
-
const
|
|
53
|
-
const services = resolveRuntimeServices({ ...options.services, resources });
|
|
54
|
-
const enableMailboxStore = options.enableMailboxStore ?? mode === "indirect";
|
|
42
|
+
const services = resolveRuntimeServices(options.services);
|
|
55
43
|
const mailboxer = options.mailboxer
|
|
56
|
-
?? (enableMailboxStore ? (yield* openRuntimeMailboxer(hby)) : null);
|
|
44
|
+
?? (options.enableMailboxStore ? (yield* openRuntimeMailboxer(hby)) : null);
|
|
57
45
|
const ownsMailboxer = options.mailboxer === undefined && mailboxer !== null;
|
|
58
46
|
const ownsSignaler = injectedSignaler === undefined && hby.signator !== null;
|
|
59
47
|
const signaler = injectedSignaler ?? (ownsSignaler
|
|
60
48
|
? (yield* resource(function* (provide) {
|
|
61
|
-
const owned = new Signaler(
|
|
49
|
+
const owned = new Signaler();
|
|
62
50
|
try {
|
|
63
51
|
yield* provide(owned);
|
|
64
52
|
}
|
|
@@ -75,23 +63,14 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
75
63
|
&& noter !== null;
|
|
76
64
|
const notifier = options.notifier
|
|
77
65
|
?? (noter && signaler ? new Notifier(hby, { noter, signaler }) : null);
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
const reger = vdr.reger instanceof Reger ? vdr.reger : null;
|
|
85
|
-
const acdc = { ...(options.acdc ?? {}) };
|
|
86
|
-
let ownsAcdcRegery = false;
|
|
87
|
-
if (acdc.rgy == null && !hby.readonly) {
|
|
88
|
-
acdc.rgy = yield* openAcdcRegeryForHabery(hby);
|
|
89
|
-
ownsAcdcRegery = true;
|
|
90
|
-
}
|
|
91
|
-
const acdcRegery = acdc.rgy;
|
|
66
|
+
const reger = options.reger ?? (!hby.readonly ? (yield* openRegerForHabery(hby)) : null);
|
|
67
|
+
const ownsReger = options.reger === undefined && reger !== null;
|
|
68
|
+
const acdc = options.acdc ?? (!hby.readonly ? (yield* openAcdcRegeryForHabery(hby)) : null);
|
|
69
|
+
const ownsAcdcRegery = options.acdc === undefined && acdc !== null;
|
|
70
|
+
const acdcRegery = acdc;
|
|
92
71
|
// Acquire after stores, before processors/consumers: reverse teardown joins consumers, clears cues, closes stores.
|
|
93
72
|
const cues = yield* resource(function* (provide) {
|
|
94
|
-
const owned = new
|
|
73
|
+
const owned = new Deck();
|
|
95
74
|
try {
|
|
96
75
|
yield* provide(owned);
|
|
97
76
|
}
|
|
@@ -99,23 +78,11 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
99
78
|
owned.clear();
|
|
100
79
|
}
|
|
101
80
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
if (reger && !vdr.vry) {
|
|
106
|
-
vdr.vry = new Verifier(hby, { reger, cues });
|
|
107
|
-
}
|
|
108
|
-
if (reger && vdr.tvy instanceof Tevery && vdr.vry instanceof Verifier && !vdr.rgy) {
|
|
109
|
-
vdr.rgy = new VdrRegery(hby, {
|
|
110
|
-
reger,
|
|
111
|
-
tvy: vdr.tvy,
|
|
112
|
-
vry: vdr.vry,
|
|
113
|
-
cues,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
81
|
+
const protocolCues = new Deck();
|
|
82
|
+
const vdr = reger ? new VdrRegery(hby, { reger, cues: protocolCues }) : null;
|
|
116
83
|
// Reverse scope teardown joins borrowed output evidence before its backing stores close.
|
|
117
84
|
const replyStreams = yield* resource(function* (provide) {
|
|
118
|
-
const streams = new ReplyStreams(
|
|
85
|
+
const streams = new ReplyStreams();
|
|
119
86
|
try {
|
|
120
87
|
yield* provide(streams);
|
|
121
88
|
}
|
|
@@ -123,20 +90,12 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
123
90
|
streams.close();
|
|
124
91
|
}
|
|
125
92
|
});
|
|
126
|
-
const deliveries = yield* resource(function* (provide) {
|
|
127
|
-
const deliveries = new RuntimeDeliveries(resources);
|
|
128
|
-
try {
|
|
129
|
-
yield* provide(deliveries);
|
|
130
|
-
}
|
|
131
|
-
finally {
|
|
132
|
-
yield* deliveries.close();
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
93
|
const reactor = new Reactor(hby, {
|
|
136
94
|
cues,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
95
|
+
protocolCues,
|
|
96
|
+
tevery: vdr?.tvy,
|
|
97
|
+
verifier: vdr?.vry,
|
|
98
|
+
registry: acdc ?? undefined,
|
|
140
99
|
messagePolicy: options.messagePolicy,
|
|
141
100
|
kram: options.kram,
|
|
142
101
|
now: () => services.clock.now(),
|
|
@@ -155,13 +114,11 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
155
114
|
loadMultisigHandlers(hby, reactor.exchanger, { notifier });
|
|
156
115
|
loadIpexHandlers(hby, reactor.exchanger, {
|
|
157
116
|
notifier,
|
|
158
|
-
registry: acdc
|
|
117
|
+
registry: acdc?.store ?? null,
|
|
159
118
|
});
|
|
160
119
|
const mailboxDirector = yield* resource(function* (provide) {
|
|
161
120
|
const director = new MailboxDirector(hby, {
|
|
162
121
|
...(mailboxer ? { mailboxer } : {}),
|
|
163
|
-
resources,
|
|
164
|
-
streamLimits: options.mailboxStreamLimits,
|
|
165
122
|
});
|
|
166
123
|
try {
|
|
167
124
|
yield* provide(director);
|
|
@@ -171,7 +128,15 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
171
128
|
}
|
|
172
129
|
});
|
|
173
130
|
const poster = new Poster(hby, { mailboxer, services });
|
|
174
|
-
const respondant =
|
|
131
|
+
const respondant = yield* resource(function* (provide) {
|
|
132
|
+
const respondant = new Respondant(hby, { poster, reactor, replyStreams });
|
|
133
|
+
try {
|
|
134
|
+
yield* provide(respondant);
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
yield* respondant.close();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
175
140
|
if (mailboxer) {
|
|
176
141
|
reactor.exchanger.addHandler(new ForwardHandler(mailboxDirector));
|
|
177
142
|
}
|
|
@@ -187,7 +152,6 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
187
152
|
const mailboxPoller = new MailboxPoller(hby, mailboxDirector, {
|
|
188
153
|
services,
|
|
189
154
|
pollTransport: options.mailboxPollTransport,
|
|
190
|
-
mailboxAdmission: options.mailboxAdmission,
|
|
191
155
|
});
|
|
192
156
|
for (const topic of [
|
|
193
157
|
DELEGATE_MAILBOX_TOPIC,
|
|
@@ -199,7 +163,7 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
199
163
|
mailboxDirector.registerTopic(topic);
|
|
200
164
|
}
|
|
201
165
|
const querying = yield* resource(function* (provide) {
|
|
202
|
-
const coordinator = new QueryCoordinator(hby);
|
|
166
|
+
const coordinator = new QueryCoordinator(hby, { reactor, services });
|
|
203
167
|
try {
|
|
204
168
|
yield* provide(coordinator);
|
|
205
169
|
}
|
|
@@ -207,14 +171,12 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
207
171
|
yield* coordinator.close();
|
|
208
172
|
}
|
|
209
173
|
});
|
|
210
|
-
const delegating = new Anchorer(hby, { poster, querying, services });
|
|
174
|
+
const delegating = new Anchorer(hby, { poster, querying, services, reactor });
|
|
211
175
|
const oobiery = new Oobiery(hby, reactor, { cues, services });
|
|
212
176
|
oobiery.registerReplyRoutes(reactor.router);
|
|
213
177
|
const authenticator = new Authenticator(hby, { services });
|
|
214
178
|
return {
|
|
215
179
|
hby,
|
|
216
|
-
resources,
|
|
217
|
-
mode,
|
|
218
180
|
mailboxer,
|
|
219
181
|
noter,
|
|
220
182
|
notifier,
|
|
@@ -230,7 +192,6 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
230
192
|
delegating,
|
|
231
193
|
querying,
|
|
232
194
|
replyStreams,
|
|
233
|
-
deliveries,
|
|
234
195
|
vdr,
|
|
235
196
|
acdc,
|
|
236
197
|
services,
|
|
@@ -246,7 +207,7 @@ export function* createAgentRuntime(hby, options = {}) {
|
|
|
246
207
|
signaler?.close();
|
|
247
208
|
},
|
|
248
209
|
function* () {
|
|
249
|
-
yield*
|
|
210
|
+
yield* respondant.close();
|
|
250
211
|
},
|
|
251
212
|
function* () {
|
|
252
213
|
yield* call(() => Promise.resolve(replyStreams.close()));
|
|
@@ -406,59 +367,6 @@ export function* settleMailboxPollBatch(runtime, batch) {
|
|
|
406
367
|
}
|
|
407
368
|
yield* runtime.reactor.processEscrowsOnce();
|
|
408
369
|
}
|
|
409
|
-
/**
|
|
410
|
-
* Drain one bounded mailbox polling turn and settle each returned batch.
|
|
411
|
-
*
|
|
412
|
-
* This keeps mailbox polling ownership inside the shared runtime surface so
|
|
413
|
-
* commands do not need to know how mailbox ingress is parsed and escrowed.
|
|
414
|
-
*/
|
|
415
|
-
export function* processMailboxTurn(runtime, options = {}) {
|
|
416
|
-
runtime.mailboxPoller.configure({ hab: options.hab });
|
|
417
|
-
const batches = yield* runtime.mailboxPoller.processOnce({
|
|
418
|
-
budgetMs: options.budgetMs,
|
|
419
|
-
});
|
|
420
|
-
for (const batch of batches) {
|
|
421
|
-
yield* settleMailboxPollBatch(runtime, batch);
|
|
422
|
-
}
|
|
423
|
-
return batches;
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Drain one bounded runtime turn by delegating to component-owned flows.
|
|
427
|
-
*
|
|
428
|
-
* Turn order:
|
|
429
|
-
* 1. `Reactor.processOnce()` drains queued ingress
|
|
430
|
-
* 2. `Oobiery.processOnce()` resolves at most one durable OOBI record
|
|
431
|
-
* 3. `Authenticator.processOnce()` advances one well-known auth step
|
|
432
|
-
* 4. `processCuesOnce()` emits cues from fresh ingress/OOBI work into
|
|
433
|
-
* `QueryCoordinator`
|
|
434
|
-
* 5. `QueryCoordinator.processPending()` resolves any newly correspondence-ready
|
|
435
|
-
* query work
|
|
436
|
-
* 6. `Reactor.processEscrowsOnce()` runs KEL and reply escrow passes
|
|
437
|
-
* 7. `processCuesOnce()` emits cues created during escrow progress
|
|
438
|
-
* 8. `QueryCoordinator.processPending()` resolves any follow-on query work
|
|
439
|
-
*
|
|
440
|
-
* This helper remains because command-local CLI flows and focused tests need a
|
|
441
|
-
* single deterministic step without having to spawn the long-lived doers.
|
|
442
|
-
*/
|
|
443
|
-
export function* processRuntimeTurn(runtime, options = {}) {
|
|
444
|
-
runtime.querying.configure({ hab: options.hab, sink: options.sink });
|
|
445
|
-
yield* runtime.reactor.processOnce();
|
|
446
|
-
yield* runtime.oobiery.processOnce();
|
|
447
|
-
yield* runtime.authenticator.processOnce();
|
|
448
|
-
yield* runtime.poster.processPending(runtime);
|
|
449
|
-
yield* runtime.delegating.processAllOnce(runtime);
|
|
450
|
-
runtime.signaler?.processOnce();
|
|
451
|
-
if (options.pollMailbox ?? true) {
|
|
452
|
-
yield* processMailboxTurn(runtime, { hab: options.hab });
|
|
453
|
-
}
|
|
454
|
-
yield* processCuesOnce(runtime, { ...options, sink: runtime.querying });
|
|
455
|
-
yield* runtime.querying.processPending(runtime);
|
|
456
|
-
yield* runtime.reactor.processEscrowsOnce();
|
|
457
|
-
yield* runtime.delegating.processAllOnce(runtime);
|
|
458
|
-
yield* processCuesOnce(runtime, { ...options, sink: runtime.querying });
|
|
459
|
-
yield* runtime.querying.processPending(runtime);
|
|
460
|
-
yield* runtime.deliveries.process(runtime);
|
|
461
|
-
}
|
|
462
370
|
/**
|
|
463
371
|
* Return the current pending-work summary for bounded command-local hosts.
|
|
464
372
|
*
|
|
@@ -476,12 +384,11 @@ export function runtimePendingState(runtime) {
|
|
|
476
384
|
multiPending: runtime.hby.db.moobi.cnt() > 0,
|
|
477
385
|
authQueued: runtime.hby.db.woobi.cnt() > 0,
|
|
478
386
|
authInFlight: runtime.hby.db.mfa.cnt() > 0,
|
|
479
|
-
outboxPending: runtime.poster.hasPendingWork(),
|
|
480
387
|
delegationPending: runtime.hby.db.dpwe.cnt() > 0
|
|
481
388
|
|| runtime.hby.db.dune.cnt() > 0
|
|
482
389
|
|| runtime.hby.db.dpub.cnt() > 0,
|
|
483
390
|
queriesPending: runtime.querying.hasPendingWork(),
|
|
484
|
-
deliveriesPending: runtime.
|
|
391
|
+
deliveriesPending: runtime.querying.hasPendingDelivery || runtime.respondant.hasPending,
|
|
485
392
|
};
|
|
486
393
|
}
|
|
487
394
|
/** Return true when any command-local runtime work remains in flight. */
|
|
@@ -489,7 +396,7 @@ export function runtimeHasPendingWork(runtime) {
|
|
|
489
396
|
const state = runtimePendingState(runtime);
|
|
490
397
|
return state.ingress || state.cues || state.replyEscrow
|
|
491
398
|
|| state.oobiQueued || state.oobiInFlight || state.multiPending
|
|
492
|
-
|| state.authQueued || state.authInFlight
|
|
399
|
+
|| state.authQueued || state.authInFlight
|
|
493
400
|
|| state.delegationPending
|
|
494
401
|
|| state.queriesPending
|
|
495
402
|
|| state.deliveriesPending;
|
|
@@ -526,32 +433,35 @@ export function runtimeOobiTerminalState(runtime, url) {
|
|
|
526
433
|
return { status: "pending", via: "none", record: null };
|
|
527
434
|
}
|
|
528
435
|
/**
|
|
529
|
-
* Return true once
|
|
530
|
-
*
|
|
436
|
+
* Return true once OOBI acceptance and its ingress/query dependencies settle.
|
|
437
|
+
* Background receipt delivery is not remote acknowledgement of OOBI acceptance;
|
|
438
|
+
* static OOBI servers may refuse unsolicited posts. Runtime close still joins I/O.
|
|
531
439
|
*/
|
|
532
440
|
export function runtimeOobiConverged(runtime, url) {
|
|
441
|
+
const pending = runtimePendingState(runtime);
|
|
533
442
|
return runtimeOobiTerminalState(runtime, url).status !== "pending"
|
|
534
|
-
&& !
|
|
443
|
+
&& !pending.ingress && !pending.cues && !pending.replyEscrow
|
|
444
|
+
&& !pending.oobiQueued && !pending.oobiInFlight && !pending.multiPending
|
|
445
|
+
&& !pending.authQueued && !pending.authInFlight && !pending.delegationPending
|
|
446
|
+
&& !pending.queriesPending;
|
|
535
447
|
}
|
|
536
|
-
/**
|
|
537
|
-
*
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
if (done()) {
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
if (!runtimeHasPendingWork(runtime)) {
|
|
448
|
+
/** Run the same component workers as a host until command state completes or its deadline expires. */
|
|
449
|
+
export function* runAgentRuntimeUntil(runtime, done, options) {
|
|
450
|
+
if (done())
|
|
451
|
+
return;
|
|
452
|
+
const { timeoutMs, ...workerOptions } = options;
|
|
453
|
+
const deadline = Date.now() + timeoutMs;
|
|
454
|
+
const worker = yield* spawn(() => runAgentRuntime(runtime, workerOptions));
|
|
455
|
+
try {
|
|
456
|
+
while (!done()) {
|
|
457
|
+
if (Date.now() >= deadline)
|
|
458
|
+
throw new Error(`Runtime did not converge within ${timeoutMs}ms.`);
|
|
551
459
|
yield* runtimeTurn();
|
|
552
460
|
}
|
|
553
461
|
}
|
|
554
|
-
|
|
462
|
+
finally {
|
|
463
|
+
yield* worker.halt();
|
|
464
|
+
}
|
|
555
465
|
}
|
|
556
466
|
/**
|
|
557
467
|
* Yield cooperatively back to the host scheduler between runtime turns.
|
|
@@ -575,12 +485,12 @@ export { runtimeTurn } from "./runtime-turn.js";
|
|
|
575
485
|
* doers and stays alive until the surrounding Effection scope halts.
|
|
576
486
|
*/
|
|
577
487
|
export function* runAgentRuntime(runtime, options = {}) {
|
|
578
|
-
runtime.querying.configure({ hab: options.hab
|
|
579
|
-
runtime.mailboxPoller.configure({ hab: options.hab });
|
|
488
|
+
runtime.querying.configure({ hab: options.hab });
|
|
580
489
|
const tasks = [
|
|
581
490
|
yield* spawn(function* () {
|
|
582
491
|
while (true) {
|
|
583
|
-
yield* runtime.
|
|
492
|
+
yield* runtime.querying.deliverOnce();
|
|
493
|
+
yield* runtime.respondant.process();
|
|
584
494
|
yield* runtimeTurn();
|
|
585
495
|
}
|
|
586
496
|
}),
|
|
@@ -588,7 +498,7 @@ export function* runAgentRuntime(runtime, options = {}) {
|
|
|
588
498
|
yield* runtime.reactor.msgDo();
|
|
589
499
|
}),
|
|
590
500
|
yield* spawn(function* () {
|
|
591
|
-
yield* cueDo(runtime,
|
|
501
|
+
yield* cueDo(runtime, options);
|
|
592
502
|
}),
|
|
593
503
|
yield* spawn(function* () {
|
|
594
504
|
yield* runtime.reactor.escrowDo();
|
|
@@ -606,29 +516,25 @@ export function* runAgentRuntime(runtime, options = {}) {
|
|
|
606
516
|
}),
|
|
607
517
|
]
|
|
608
518
|
: []),
|
|
519
|
+
...(options.pollMailbox ?? true
|
|
520
|
+
? [
|
|
521
|
+
yield* spawn(function* () {
|
|
522
|
+
yield* runtime.mailboxPoller.pollDo((batch) => settleMailboxPollBatch(runtime, batch));
|
|
523
|
+
}),
|
|
524
|
+
]
|
|
525
|
+
: []),
|
|
609
526
|
yield* spawn(function* () {
|
|
610
527
|
while (true) {
|
|
611
|
-
yield* runtime.
|
|
612
|
-
yield* runtimeTurn();
|
|
613
|
-
}
|
|
614
|
-
}),
|
|
615
|
-
yield* spawn(function* () {
|
|
616
|
-
yield* runtime.mailboxPoller.pollDo((batch) => settleMailboxPollBatch(runtime, batch));
|
|
617
|
-
}),
|
|
618
|
-
yield* spawn(function* () {
|
|
619
|
-
while (true) {
|
|
620
|
-
yield* runtime.delegating.processAllOnce(runtime);
|
|
528
|
+
yield* runtime.delegating.processAllOnce();
|
|
621
529
|
yield* runtimeTurn();
|
|
622
530
|
}
|
|
623
531
|
}),
|
|
624
532
|
yield* spawn(function* () {
|
|
625
|
-
yield* runtime.querying.queryDo(
|
|
533
|
+
yield* runtime.querying.queryDo();
|
|
626
534
|
}),
|
|
627
535
|
];
|
|
628
536
|
try {
|
|
629
|
-
|
|
630
|
-
yield* runtimeTurn();
|
|
631
|
-
}
|
|
537
|
+
return yield* suspend();
|
|
632
538
|
}
|
|
633
539
|
finally {
|
|
634
540
|
for (const task of tasks.reverse()) {
|