@astrosheep/keiyaku 4.5.29 → 4.6.2
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/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +0 -13
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +47 -78
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/references/automation.md +54 -41
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +10 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +27 -9
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +68 -71
- package/build/src/akuma/akuma-call.d.ts +53 -0
- package/build/src/akuma/akuma-call.js +113 -0
- package/build/src/akuma/akuma-instance.d.ts +20 -18
- package/build/src/akuma/akuma-instance.js +65 -175
- package/build/src/akuma/akuma-observe.d.ts +3 -21
- package/build/src/akuma/akuma-observe.js +7 -24
- package/build/src/akuma/{akuma-handle.d.ts → akuma-owner.d.ts} +55 -27
- package/build/src/akuma/{akuma-handle.js → akuma-owner.js} +24 -23
- package/build/src/akuma/akuma-selection-execution.d.ts +51 -0
- package/build/src/akuma/akuma-selection-execution.js +134 -0
- package/build/src/akuma/{fleet-execution.d.ts → akuma-wait.d.ts} +24 -44
- package/build/src/akuma/akuma-wait.js +113 -0
- package/build/src/akuma/akuma.d.ts +35 -89
- package/build/src/akuma/akuma.js +148 -30
- package/build/src/akuma/archetype.d.ts +12 -0
- package/build/src/akuma/archetype.js +47 -19
- package/build/src/akuma/body.d.ts +76 -36
- package/build/src/akuma/body.js +84 -49
- package/build/src/akuma/call-initial-tell.d.ts +131 -22
- package/build/src/akuma/call-initial-tell.js +31 -1
- package/build/src/akuma/call-request.d.ts +237 -31
- package/build/src/akuma/call-request.js +67 -94
- package/build/src/akuma/coordinate.d.ts +15 -5
- package/build/src/akuma/coordinate.js +12 -22
- package/build/src/akuma/dispatch-association.d.ts +1 -1
- package/build/src/akuma/dispatch-association.js +1 -10
- package/build/src/akuma/heart/activity-schema.d.ts +325 -0
- package/build/src/akuma/heart/activity-schema.js +53 -0
- package/build/src/akuma/heart/facts.d.ts +1 -6
- package/build/src/akuma/heart/index.d.ts +3 -1
- package/build/src/akuma/heart/index.js +4 -1
- package/build/src/akuma/heart/rows.d.ts +49 -2
- package/build/src/akuma/heart/rows.js +16 -2
- package/build/src/akuma/heart/soul.d.ts +1 -0
- package/build/src/akuma/heart/soul.js +6 -4
- package/build/src/akuma/heart/tells.d.ts +1 -0
- package/build/src/akuma/heart/tells.js +18 -0
- package/build/src/akuma/identity.d.ts +10 -7
- package/build/src/akuma/identity.js +23 -0
- package/build/src/akuma/index.d.ts +10 -8
- package/build/src/akuma/index.js +2 -2
- package/build/src/akuma/nuke.d.ts +3 -0
- package/build/src/akuma/nuke.js +13 -7
- package/build/src/akuma/projection.d.ts +0 -5
- package/build/src/akuma/projection.js +22 -43
- package/build/src/akuma/provider-recipe.d.ts +58 -13
- package/build/src/akuma/provider-recipe.js +62 -80
- package/build/src/akuma/provider.d.ts +6 -76
- package/build/src/akuma/provider.js +11 -219
- package/build/src/akuma/providers/acp/config.d.ts +2 -0
- package/build/src/akuma/providers/acp/config.js +26 -1
- package/build/src/akuma/providers/acp/core.d.ts +7 -0
- package/build/src/akuma/providers/acp/core.js +49 -18
- package/build/src/akuma/providers/acp/index.js +14 -6
- package/build/src/akuma/providers/grok-build/index.js +44 -13
- package/build/src/akuma/providers/index.d.ts +3 -3
- package/build/src/akuma/providers/index.js +2 -13
- package/build/src/akuma/providers/opencode-sdk/event-stream.d.ts +28 -0
- package/build/src/akuma/providers/opencode-sdk/event-stream.js +92 -0
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +0 -1
- package/build/src/akuma/providers/opencode-sdk/index.js +200 -64
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +41 -1
- package/build/src/akuma/providers/opencode-sdk/session.js +69 -2
- package/build/src/akuma/providers/pi/events.js +5 -2
- package/build/src/akuma/providers/pi/index.d.ts +3 -4
- package/build/src/akuma/providers/pi/index.js +99 -45
- package/build/src/akuma/publication.d.ts +84 -3
- package/build/src/akuma/publication.js +145 -2
- package/build/src/akuma/read-pool.d.ts +2 -0
- package/build/src/akuma/read-pool.js +15 -0
- package/build/src/akuma/request-rendezvous.js +10 -0
- package/build/src/akuma/request-serve.js +7 -0
- package/build/src/akuma/request-wire.d.ts +14 -26
- package/build/src/akuma/request-wire.js +4 -0
- package/build/src/akuma/requests.d.ts +0 -2
- package/build/src/akuma/requests.js +0 -17
- package/build/src/akuma/{fleet-observation.d.ts → selection-observation.d.ts} +37 -36
- package/build/src/akuma/selection-observation.js +65 -0
- package/build/src/akuma/{fleet-owner-port.d.ts → selection-owner-port.d.ts} +3 -3
- package/build/src/akuma/{fleet-owner-port.js → selection-owner-port.js} +11 -17
- package/build/src/akuma/{fleet-request.d.ts → selection-request.d.ts} +42 -82
- package/build/src/akuma/{fleet-request.js → selection-request.js} +92 -136
- package/build/src/akuma/turn-drive.js +73 -14
- package/build/src/akuma-body.js +91 -56
- package/build/src/body/amend.d.ts +5 -0
- package/build/src/body/amend.js +26 -50
- package/build/src/body/arc.d.ts +4 -2
- package/build/src/body/arc.js +19 -26
- package/build/src/body/criteria.d.ts +6 -0
- package/build/src/body/criteria.js +37 -0
- package/build/src/body/decode.js +5 -42
- package/build/src/body/region.d.ts +5 -0
- package/build/src/body/region.js +45 -2
- package/build/src/body/render.js +2 -4
- package/build/src/cli/activity.d.ts +26 -0
- package/build/src/cli/activity.js +75 -0
- package/build/src/cli/actor.d.ts +3 -1
- package/build/src/cli/actor.js +15 -2
- package/build/src/cli/commands/akuma-grammar.d.ts +75 -0
- package/build/src/cli/commands/akuma-grammar.js +414 -0
- package/build/src/cli/commands/akuma.d.ts +5 -69
- package/build/src/cli/commands/akuma.js +352 -319
- package/build/src/cli/commands/amend.d.ts +4 -5
- package/build/src/cli/commands/amend.js +1 -2
- package/build/src/cli/commands/bind.d.ts +4 -5
- package/build/src/cli/commands/bind.js +7 -10
- package/build/src/cli/commands/contract-grammar.d.ts +112 -0
- package/build/src/cli/commands/contract-grammar.js +282 -0
- package/build/src/cli/commands/contract-help.d.ts +17 -22
- package/build/src/cli/commands/contract-help.js +37 -24
- package/build/src/cli/commands/contract.d.ts +18 -97
- package/build/src/cli/commands/contract.js +621 -233
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +2 -2
- package/build/src/cli/commands/task-grammar.d.ts +19 -0
- package/build/src/cli/commands/task-grammar.js +438 -0
- package/build/src/cli/commands/task-query.js +23 -104
- package/build/src/cli/commands/task.d.ts +5 -20
- package/build/src/cli/commands/task.js +414 -364
- package/build/src/cli/coordinates.d.ts +10 -0
- package/build/src/cli/coordinates.js +20 -0
- package/build/src/cli/draft.d.ts +7 -1
- package/build/src/cli/main.js +10 -1
- package/build/src/cli/parse.d.ts +8 -9
- package/build/src/cli/parse.js +62 -62
- package/build/src/cli/render/akuma-activity.d.ts +54 -36
- package/build/src/cli/render/akuma-activity.js +262 -242
- package/build/src/cli/render/akuma-tool.d.ts +8 -4
- package/build/src/cli/render/akuma-tool.js +6 -5
- package/build/src/cli/render/akuma.d.ts +36 -16
- package/build/src/cli/render/akuma.js +65 -132
- package/build/src/cli/render/audit.d.ts +6 -2
- package/build/src/cli/render/audit.js +59 -28
- package/build/src/cli/render/catalog.d.ts +11 -2
- package/build/src/cli/render/catalog.js +75 -95
- package/build/src/cli/render/contract-history.d.ts +3 -1
- package/build/src/cli/render/contract-history.js +215 -22
- package/build/src/cli/render/contract-observation.d.ts +10 -5
- package/build/src/cli/render/contract-observation.js +29 -46
- package/build/src/cli/render/contract.d.ts +10 -3
- package/build/src/cli/render/contract.js +252 -103
- package/build/src/cli/render/effects.d.ts +26 -0
- package/build/src/cli/render/effects.js +41 -0
- package/build/src/cli/render/execution-progress.d.ts +18 -6
- package/build/src/cli/render/execution-progress.js +34 -31
- package/build/src/cli/render/kanshi-akuma.d.ts +1 -2
- package/build/src/cli/render/kanshi-akuma.js +5 -26
- package/build/src/cli/render/kanshi.js +107 -128
- package/build/src/cli/render/marks.d.ts +13 -0
- package/build/src/cli/render/marks.js +74 -0
- package/build/src/cli/render/nuke.js +18 -7
- package/build/src/cli/render/receipt.d.ts +10 -4
- package/build/src/cli/render/receipt.js +124 -44
- package/build/src/cli/render/reconcile.d.ts +5 -0
- package/build/src/cli/render/reconcile.js +152 -0
- package/build/src/cli/render/refusal.d.ts +21 -4
- package/build/src/cli/render/refusal.js +60 -33
- package/build/src/cli/render/region.js +3 -2
- package/build/src/cli/render/settings.js +2 -12
- package/build/src/cli/render/task.d.ts +37 -6
- package/build/src/cli/render/task.js +161 -157
- package/build/src/cli/render/terminal.d.ts +20 -1
- package/build/src/cli/render/terminal.js +92 -18
- package/build/src/cli/runtime.d.ts +32 -8
- package/build/src/cli/runtime.js +157 -165
- package/build/src/cli/selectors.d.ts +5 -2
- package/build/src/cli/selectors.js +11 -3
- package/build/src/cli/streams.d.ts +11 -0
- package/build/src/cli/streams.js +32 -0
- package/build/src/cli/usage.d.ts +2 -0
- package/build/src/cli/usage.js +12 -8
- package/build/src/contract-guidance.js +3 -7
- package/build/src/contract-worktree.d.ts +20 -28
- package/build/src/contract-worktree.js +18 -70
- package/build/src/coordination/durable-file.d.ts +2 -2
- package/build/src/coordination/durable-file.js +0 -27
- package/build/src/core/facts/codec.d.ts +1 -2
- package/build/src/core/facts/codec.js +6 -7
- package/build/src/core/facts/gate.d.ts +0 -1
- package/build/src/core/facts/gate.js +0 -82
- package/build/src/core/facts/types.d.ts +1 -2
- package/build/src/core/verbs/abandon.d.ts +2 -6
- package/build/src/core/verbs/abandon.js +0 -16
- package/build/src/core/verbs/amend.d.ts +0 -1
- package/build/src/core/verbs/amend.js +0 -20
- package/build/src/core/verbs/arc.d.ts +7 -8
- package/build/src/core/verbs/arc.js +2 -19
- package/build/src/core/verbs/attestation.d.ts +2 -6
- package/build/src/core/verbs/attestation.js +0 -16
- package/build/src/core/verbs/bind.d.ts +0 -1
- package/build/src/core/verbs/bind.js +0 -16
- package/build/src/core/verbs/deliver.d.ts +0 -1
- package/build/src/core/verbs/deliver.js +0 -16
- package/build/src/core/verbs/placement.d.ts +2 -1
- package/build/src/core/verbs/placement.js +10 -59
- package/build/src/git/admission.d.ts +6 -4
- package/build/src/git/admission.js +4 -0
- package/build/src/git/hooks.d.ts +55 -30
- package/build/src/git/hooks.js +30 -3
- package/build/src/git/identity.d.ts +6 -0
- package/build/src/git/identity.js +47 -0
- package/build/src/git/integration.d.ts +31 -13
- package/build/src/git/integration.js +32 -1
- package/build/src/git/nuke.d.ts +10 -1
- package/build/src/git/nuke.js +31 -11
- package/build/src/git/observe.js +2 -15
- package/build/src/git/private-state-seat.d.ts +6 -7
- package/build/src/git/private-state-seat.js +8 -6
- package/build/src/git/read-observation.d.ts +6 -1
- package/build/src/git/read-observation.js +81 -46
- package/build/src/git/reconcile.d.ts +117 -40
- package/build/src/git/reconcile.js +169 -40
- package/build/src/git/scratch.d.ts +7 -4
- package/build/src/git/scratch.js +28 -6
- package/build/src/git/target-placement.d.ts +53 -38
- package/build/src/git/target-placement.js +69 -54
- package/build/src/git/tender.d.ts +37 -28
- package/build/src/git/tender.js +39 -0
- package/build/src/git/terminal-reconcile.js +21 -23
- package/build/src/git/terminal-seal.d.ts +8 -6
- package/build/src/git/terminal-seal.js +10 -0
- package/build/src/git/workspace.d.ts +29 -15
- package/build/src/git/workspace.js +28 -2
- package/build/src/identity/normalize.js +19 -6
- package/build/src/index.d.ts +78 -7
- package/build/src/index.js +52 -4
- package/build/src/kanshi/read.d.ts +3 -3
- package/build/src/kanshi/read.js +21 -21
- package/build/src/kanshi/report.d.ts +9 -8
- package/build/src/kanshi/roster.d.ts +2 -0
- package/build/src/kanshi/roster.js +2 -0
- package/build/src/kanshi/select.js +7 -3
- package/build/src/library/address.d.ts +3 -7
- package/build/src/library/address.js +7 -7
- package/build/src/library/akuma-creation.d.ts +21 -32
- package/build/src/library/akuma-creation.js +148 -165
- package/build/src/library/akumas.d.ts +20 -22
- package/build/src/library/akumas.js +43 -20
- package/build/src/library/bind.d.ts +107 -13
- package/build/src/library/bind.js +29 -23
- package/build/src/library/continuation.d.ts +556 -28
- package/build/src/library/continuation.js +29 -54
- package/build/src/library/contract-composition.d.ts +40 -0
- package/build/src/library/contract-composition.js +105 -0
- package/build/src/library/contract-creation.d.ts +7 -0
- package/build/src/library/contract-creation.js +192 -0
- package/build/src/library/contract-execution.d.ts +29 -40
- package/build/src/library/contract-execution.js +503 -128
- package/build/src/library/contract-operations.d.ts +275 -134
- package/build/src/library/contract-operations.js +83 -92
- package/build/src/library/contract-outcomes.d.ts +71 -0
- package/build/src/library/contract-outcomes.js +32 -0
- package/build/src/library/contract-settings.d.ts +25 -0
- package/build/src/library/contract-settings.js +135 -0
- package/build/src/library/contract-types.d.ts +17 -38
- package/build/src/library/delivery.d.ts +530 -10
- package/build/src/library/delivery.js +20 -45
- package/build/src/library/input.d.ts +3 -1
- package/build/src/library/input.js +11 -16
- package/build/src/library/invocation.d.ts +87 -0
- package/build/src/library/invocation.js +290 -0
- package/build/src/library/keiyaku.d.ts +45 -22
- package/build/src/library/keiyaku.js +134 -8
- package/build/src/library/nuke.d.ts +2 -11
- package/build/src/library/nuke.js +70 -57
- package/build/src/library/outcome.d.ts +13196 -0
- package/build/src/library/outcome.js +487 -0
- package/build/src/library/reconcile.d.ts +96 -24
- package/build/src/library/reconcile.js +102 -42
- package/build/src/library/refusal.d.ts +470 -42
- package/build/src/library/refusal.js +55 -143
- package/build/src/library/region.d.ts +15 -7
- package/build/src/library/region.js +23 -3
- package/build/src/library/repo.d.ts +2 -12
- package/build/src/library/repo.js +1 -22
- package/build/src/library/selection.d.ts +121 -0
- package/build/src/library/{fleet.js → selection.js} +169 -152
- package/build/src/plugin/public.d.ts +2 -0
- package/build/src/protocol/abandon.d.ts +2 -2
- package/build/src/protocol/abandon.js +1 -0
- package/build/src/protocol/amend.js +1 -0
- package/build/src/protocol/arc.d.ts +6 -4
- package/build/src/protocol/attempt.d.ts +4 -2
- package/build/src/protocol/attempt.js +10 -0
- package/build/src/protocol/audit.d.ts +255 -52
- package/build/src/protocol/audit.js +63 -5
- package/build/src/protocol/bind.d.ts +18 -17
- package/build/src/protocol/bind.js +9 -28
- package/build/src/protocol/completion.d.ts +256 -22
- package/build/src/protocol/completion.js +100 -12
- package/build/src/protocol/deliver.d.ts +34 -23
- package/build/src/protocol/deliver.js +39 -25
- package/build/src/protocol/execution-observation.d.ts +36 -37
- package/build/src/protocol/execution-observation.js +7 -9
- package/build/src/protocol/intent.d.ts +101 -30
- package/build/src/protocol/intent.js +74 -1
- package/build/src/protocol/operations.d.ts +570 -64
- package/build/src/protocol/operations.js +189 -9
- package/build/src/protocol/outcome.d.ts +2 -1
- package/build/src/protocol/placement.d.ts +2 -2
- package/build/src/protocol/placement.js +3 -1
- package/build/src/protocol/progress.d.ts +108 -65
- package/build/src/protocol/progress.js +82 -132
- package/build/src/protocol/read/status.d.ts +4 -3
- package/build/src/protocol/read/status.js +6 -5
- package/build/src/protocol/reconcile.d.ts +3 -3
- package/build/src/protocol/reconcile.js +4 -0
- package/build/src/protocol/reintegrate.d.ts +2 -2
- package/build/src/protocol/review.d.ts +30 -12
- package/build/src/protocol/review.js +15 -24
- package/build/src/protocol/run.d.ts +34 -5
- package/build/src/protocol/run.js +24 -12
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +0 -10
- package/build/src/settings.js +0 -76
- package/build/src/settlement/holder.d.ts +1 -1
- package/build/src/settlement/settle.d.ts +25 -16
- package/build/src/settlement/settle.js +80 -20
- package/build/src/task/board.d.ts +3 -1
- package/build/src/task/board.js +13 -17
- package/build/src/task/catalog.d.ts +0 -4
- package/build/src/task/catalog.js +0 -15
- package/build/src/task/compose-language.d.ts +19 -9
- package/build/src/task/compose-language.js +30 -20
- package/build/src/task/compose.d.ts +7 -37
- package/build/src/task/compose.js +20 -2
- package/build/src/task/created-observation.d.ts +0 -1
- package/build/src/task/created-observation.js +1 -4
- package/build/src/task/document.d.ts +12 -2
- package/build/src/task/document.js +4 -0
- package/build/src/task/identity.d.ts +4 -1
- package/build/src/task/identity.js +21 -17
- package/build/src/task/index.d.ts +36 -16
- package/build/src/task/index.js +103 -96
- package/build/src/task/lifecycle-operations.d.ts +1 -1
- package/build/src/task/mutation-result.d.ts +647 -586
- package/build/src/task/mutation-result.js +79 -46
- package/build/src/task/mutation.d.ts +298 -270
- package/build/src/task/mutation.js +93 -110
- package/build/src/task/operation-types.d.ts +6 -49
- package/build/src/task/operations.d.ts +2 -1
- package/build/src/task/operations.js +35 -12
- package/build/src/task/query.d.ts +9 -3
- package/build/src/task/query.js +42 -16
- package/build/src/task/store.d.ts +2 -1
- package/build/src/task/store.js +10 -14
- package/build/src/verification/declaration.d.ts +0 -1
- package/build/src/verification/declaration.js +1 -18
- package/build/src/verification/execution.d.ts +6 -2
- package/build/src/verification/observation.d.ts +1 -1
- package/package.json +2 -18
- package/build/src/akuma/akuma-product.d.ts +0 -58
- package/build/src/akuma/akuma-product.js +0 -276
- package/build/src/akuma/fleet-execution.js +0 -234
- package/build/src/akuma/fleet-observation.js +0 -97
- package/build/src/cli/accepted.d.ts +0 -24
- package/build/src/cli/accepted.js +0 -167
- package/build/src/cli/catalog.d.ts +0 -45
- package/build/src/cli/catalog.js +0 -1
- package/build/src/cli/commands/akuma-invoke.d.ts +0 -114
- package/build/src/cli/commands/akuma-invoke.js +0 -375
- package/build/src/cli/commands/contract-invoke.d.ts +0 -34
- package/build/src/cli/commands/contract-invoke.js +0 -259
- package/build/src/cli/commands/nuke.d.ts +0 -10
- package/build/src/cli/commands/nuke.js +0 -20
- package/build/src/cli/commands/status-set.d.ts +0 -4
- package/build/src/cli/commands/status-set.js +0 -52
- package/build/src/cli/commands/task-invoke.d.ts +0 -49
- package/build/src/cli/commands/task-invoke.js +0 -306
- package/build/src/cli/invoke.d.ts +0 -27
- package/build/src/cli/invoke.js +0 -521
- package/build/src/cli/render/board.d.ts +0 -3
- package/build/src/cli/render/board.js +0 -25
- package/build/src/cli/render/status-set.d.ts +0 -5
- package/build/src/cli/render/status-set.js +0 -19
- package/build/src/cli/render/text.d.ts +0 -3
- package/build/src/cli/render/text.js +0 -33
- package/build/src/cli/result.d.ts +0 -240
- package/build/src/cli/result.js +0 -1
- package/build/src/git/result-codec.d.ts +0 -29
- package/build/src/git/result-codec.js +0 -309
- package/build/src/kanshi/fleet.d.ts +0 -6
- package/build/src/kanshi/fleet.js +0 -27
- package/build/src/library/audit.d.ts +0 -29
- package/build/src/library/audit.js +0 -41
- package/build/src/library/composition.d.ts +0 -15
- package/build/src/library/composition.js +0 -28
- package/build/src/library/configuration.d.ts +0 -4
- package/build/src/library/configuration.js +0 -2
- package/build/src/library/contract-bind.d.ts +0 -31
- package/build/src/library/contract-bind.js +0 -140
- package/build/src/library/contract-forwarding.d.ts +0 -55
- package/build/src/library/contract-forwarding.js +0 -67
- package/build/src/library/contract-handle.d.ts +0 -50
- package/build/src/library/contract-handle.js +0 -385
- package/build/src/library/contract.d.ts +0 -46
- package/build/src/library/contract.js +0 -73
- package/build/src/library/execution-result.d.ts +0 -243
- package/build/src/library/execution-result.js +0 -101
- package/build/src/library/execution.d.ts +0 -8
- package/build/src/library/execution.js +0 -102
- package/build/src/library/fleet.d.ts +0 -83
- package/build/src/library/mutation.d.ts +0 -501
- package/build/src/library/mutation.js +0 -248
- package/build/src/library/result-codec.d.ts +0 -2
- package/build/src/library/result-codec.js +0 -12
- package/build/src/protocol/result-codec.d.ts +0 -23
- package/build/src/protocol/result-codec.js +0 -488
- package/build/src/settlement/result-codec.d.ts +0 -2
- package/build/src/settlement/result-codec.js +0 -56
- package/build/src/task/public.d.ts +0 -2
- package/build/src/task/public.js +0 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { decodeArcDocument } from "../body/arc.js";
|
|
2
|
+
import { decodeContractDocument } from "../body/decode.js";
|
|
3
|
+
import { validated } from "./outcome.js";
|
|
1
4
|
import { verificationDefinition } from "../body/decode.js";
|
|
2
|
-
import { actorId
|
|
5
|
+
import { actorId } from "../core/facts/types.js";
|
|
3
6
|
import { parseTaskId } from "../task/identity.js";
|
|
4
7
|
import { prepareVerificationDeclaration } from "../verification/declaration.js";
|
|
5
8
|
export function actorOption(actor) {
|
|
@@ -84,21 +87,6 @@ export function normalizedList(values, label, brand) {
|
|
|
84
87
|
}
|
|
85
88
|
});
|
|
86
89
|
}
|
|
87
|
-
export function normalizedGates(values) {
|
|
88
|
-
if (values === undefined)
|
|
89
|
-
return [];
|
|
90
|
-
if (!Array.isArray(values))
|
|
91
|
-
throw new TypeError("gates must be an array");
|
|
92
|
-
const normalized = values.map((value, index) => {
|
|
93
|
-
if (!gateWord(value)) {
|
|
94
|
-
throw new TypeError(`gates[${index}] must match ^[a-z][a-z0-9-]{0,63}$`);
|
|
95
|
-
}
|
|
96
|
-
return gate(value);
|
|
97
|
-
});
|
|
98
|
-
if (new Set(normalized).size !== normalized.length)
|
|
99
|
-
throw new TypeError("gates must not contain duplicates");
|
|
100
|
-
return normalized;
|
|
101
|
-
}
|
|
102
90
|
export function contractTerms(document, gates, after) {
|
|
103
91
|
return {
|
|
104
92
|
document: document.document,
|
|
@@ -119,3 +107,10 @@ export function documentDerivation(document, gates, contractId) {
|
|
|
119
107
|
}),
|
|
120
108
|
};
|
|
121
109
|
}
|
|
110
|
+
/** Early CLI acquisition uses the same Library caller boundary, never document-owner capabilities. */
|
|
111
|
+
export function validateContractMarkdown(markdown) {
|
|
112
|
+
validated(() => decodeContractDocument(requireMarkdown(markdown), { requireTimeout: true }));
|
|
113
|
+
}
|
|
114
|
+
export function validateArcMarkdown(markdown) {
|
|
115
|
+
validated(() => decodeArcDocument(requireMarkdown(markdown)));
|
|
116
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ContractHead, ContractId, JournalEntry } from "../core/facts/types.js";
|
|
2
|
+
import type { ReconcileResult } from "../git/reconcile.js";
|
|
3
|
+
import type { AuditReport } from "../protocol/audit.js";
|
|
4
|
+
import type { CandidateCompletion, CompletionEvidence } from "../protocol/completion.js";
|
|
5
|
+
import { type ExecutionObservation, type ExecutionObserver } from "../protocol/execution-observation.js";
|
|
6
|
+
import type { AcceptedProtocolStep } from "../protocol/outcome.js";
|
|
7
|
+
import type { ContractCheckpoint, ExecutionStop, ProgressResidue, ProtocolProgress, VerificationResidue } from "../protocol/progress.js";
|
|
8
|
+
import type { SettlementReport } from "../settlement/settle.js";
|
|
9
|
+
import type { WorldRoot } from "../world.js";
|
|
10
|
+
import type { ContinuationReport } from "./continuation.js";
|
|
11
|
+
import type { InvocationEffect, ReconciliationEffect, ReconciliationLag, ResetCounts } from "./outcome.js";
|
|
12
|
+
export type InvocationSnapshot = Readonly<{
|
|
13
|
+
facts: readonly JournalEntry[];
|
|
14
|
+
checkpoints: ReadonlyMap<ContractId, ContractCheckpoint>;
|
|
15
|
+
heads: ReadonlyMap<ContractId, ContractHead>;
|
|
16
|
+
affected: readonly ContractId[];
|
|
17
|
+
effects: readonly InvocationEffect[];
|
|
18
|
+
conclusions: ReadonlyMap<ContractId, Readonly<Record<string, unknown>>>;
|
|
19
|
+
reset?: Readonly<{
|
|
20
|
+
world: WorldRoot;
|
|
21
|
+
removed: ResetCounts;
|
|
22
|
+
}>;
|
|
23
|
+
}>;
|
|
24
|
+
type ReconciliationRecord = Readonly<{
|
|
25
|
+
effects?: readonly ReconciliationEffect[];
|
|
26
|
+
lag?: readonly ReconciliationLag[];
|
|
27
|
+
settlement?: SettlementReport;
|
|
28
|
+
retiredWorktree?: string;
|
|
29
|
+
retainedWorktree?: string;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* The one invocation accumulator. It exists before any admission-capable await, satisfies the lower
|
|
33
|
+
* Protocol progress sink, and holds every confirmed publication, candidate conclusion and physical
|
|
34
|
+
* observation until the single final projection.
|
|
35
|
+
*/
|
|
36
|
+
export declare class InvocationAccumulator implements ProtocolProgress {
|
|
37
|
+
private readonly observer?;
|
|
38
|
+
private readonly entries;
|
|
39
|
+
private readonly admittedFacts;
|
|
40
|
+
private readonly admittedHeads;
|
|
41
|
+
private readonly admittedCheckpoints;
|
|
42
|
+
private readonly affectedContracts;
|
|
43
|
+
private readonly records;
|
|
44
|
+
private readonly candidateConclusions;
|
|
45
|
+
private readonly reportedResidue;
|
|
46
|
+
private resetState?;
|
|
47
|
+
constructor(observer?: ExecutionObserver | undefined);
|
|
48
|
+
beginReset(world: WorldRoot): void;
|
|
49
|
+
recordResetRemoved(counts: Partial<ResetCounts>): void;
|
|
50
|
+
observe(event: ExecutionObservation): void;
|
|
51
|
+
/** A confirmed publication is retained even if folding or later physical work throws. */
|
|
52
|
+
recordPublication(contract: ContractId, head: ContractHead, facts: readonly JournalEntry[]): void;
|
|
53
|
+
recordAdmission(step: AcceptedProtocolStep): void;
|
|
54
|
+
hasFact(fact: JournalEntry): boolean;
|
|
55
|
+
head(contract: ContractId): ContractHead | undefined;
|
|
56
|
+
checkpoint(contract: ContractId): ContractCheckpoint | undefined;
|
|
57
|
+
recordResidue(contract: ContractId, residue: ProgressResidue): void;
|
|
58
|
+
recordVerification(contract: ContractId, snapshot: Parameters<ProtocolProgress["recordVerification"]>[1], result: VerificationResidue): void;
|
|
59
|
+
/** Replace the current candidate's conclusions; accumulated resources are never erased. */
|
|
60
|
+
recordCandidate(contract: ContractId, evidence: CompletionEvidence): void;
|
|
61
|
+
/** The candidate's completion base, known before an optional observation can fail. */
|
|
62
|
+
recordCompletion(contract: ContractId, completion: CandidateCompletion): void;
|
|
63
|
+
recordAudit(contract: ContractId, report: Partial<AuditReport>): void;
|
|
64
|
+
/** Physical residue a continuation's dependent reconciliation observed. */
|
|
65
|
+
recordPhysical(contract: ContractId, physical: ReconcileResult): void;
|
|
66
|
+
recordPlacementPhysical(contract: ContractId, physical: ReconcileResult): void;
|
|
67
|
+
/** Incremental continuation progress for the primary Contract. */
|
|
68
|
+
recordContinuation(contract: ContractId, report: ContinuationReport): void;
|
|
69
|
+
recordStop(stop: ExecutionStop): void;
|
|
70
|
+
/** Physical reconciliation observations: effects, lags, settlement, and worktree topology. */
|
|
71
|
+
recordReconciliation(contract: ContractId, record: ReconcileResult | ReconciliationRecord): void;
|
|
72
|
+
recordSettlement(contract: ContractId, report: SettlementReport): void;
|
|
73
|
+
recordChannelRetirement(contract: ContractId, error: unknown): void;
|
|
74
|
+
/** World reset observations share the carrier without pretending a Contract admission happened. */
|
|
75
|
+
recordReset(effect: Extract<InvocationEffect, {
|
|
76
|
+
kind: "reset-owner-stopped" | "reset-residue";
|
|
77
|
+
}>): void;
|
|
78
|
+
/** Replace the current candidate conclusions; accumulated resources are never erased. */
|
|
79
|
+
recordConclusions(contract: ContractId, patch: Readonly<Record<string, unknown>>): void;
|
|
80
|
+
extendConclusions(contract: ContractId, patch: Readonly<Record<string, unknown>>): void;
|
|
81
|
+
conclusions(contract: ContractId): Readonly<Record<string, unknown>> | undefined;
|
|
82
|
+
snapshot(): InvocationSnapshot;
|
|
83
|
+
private recordSeatClose;
|
|
84
|
+
private recordLag;
|
|
85
|
+
}
|
|
86
|
+
export declare function physicalOf(snapshot: InvocationSnapshot): ReconcileResult;
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/** @architectureCompositionRoot */
|
|
2
|
+
import { encodeEntry } from "../core/facts/codec.js";
|
|
3
|
+
import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
4
|
+
import { observeExecution, } from "../protocol/execution-observation.js";
|
|
5
|
+
import { reconcileLagScope } from "./reconcile.js";
|
|
6
|
+
const CANDIDATE_CONCLUSION_KEYS = [
|
|
7
|
+
"completion",
|
|
8
|
+
"verification",
|
|
9
|
+
"verificationReuse",
|
|
10
|
+
"verificationSubject",
|
|
11
|
+
"verificationSummary",
|
|
12
|
+
"placement",
|
|
13
|
+
];
|
|
14
|
+
function entryKey(fact) {
|
|
15
|
+
return `${fact.contract}\u0000${fact.entry}`;
|
|
16
|
+
}
|
|
17
|
+
/** The owner codec's canonical bytes: identity is (contract, entry), the payload is retained whole. */
|
|
18
|
+
function entryBytes(fact) {
|
|
19
|
+
return encodeEntry(fact);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The one invocation accumulator. It exists before any admission-capable await, satisfies the lower
|
|
23
|
+
* Protocol progress sink, and holds every confirmed publication, candidate conclusion and physical
|
|
24
|
+
* observation until the single final projection.
|
|
25
|
+
*/
|
|
26
|
+
export class InvocationAccumulator {
|
|
27
|
+
observer;
|
|
28
|
+
entries = new Map();
|
|
29
|
+
admittedFacts = [];
|
|
30
|
+
admittedHeads = new Map();
|
|
31
|
+
admittedCheckpoints = new Map();
|
|
32
|
+
affectedContracts = new Set();
|
|
33
|
+
records = [];
|
|
34
|
+
candidateConclusions = new Map();
|
|
35
|
+
reportedResidue = new WeakSet();
|
|
36
|
+
resetState;
|
|
37
|
+
constructor(observer) {
|
|
38
|
+
this.observer = observer;
|
|
39
|
+
}
|
|
40
|
+
beginReset(world) {
|
|
41
|
+
this.resetState = { world, removed: { refs: 0, worktrees: 0, tasks: 0 } };
|
|
42
|
+
}
|
|
43
|
+
recordResetRemoved(counts) {
|
|
44
|
+
if (this.resetState === undefined)
|
|
45
|
+
throw new Error("reset progress requires its World");
|
|
46
|
+
for (const key of ["refs", "worktrees", "tasks"])
|
|
47
|
+
this.resetState.removed[key] += counts[key] ?? 0;
|
|
48
|
+
}
|
|
49
|
+
observe(event) {
|
|
50
|
+
observeExecution(this.observer, event);
|
|
51
|
+
}
|
|
52
|
+
/** A confirmed publication is retained even if folding or later physical work throws. */
|
|
53
|
+
recordPublication(contract, head, facts) {
|
|
54
|
+
const incoming = new Map();
|
|
55
|
+
for (const fact of facts) {
|
|
56
|
+
const key = entryKey(fact);
|
|
57
|
+
const bytes = entryBytes(fact);
|
|
58
|
+
const previous = incoming.get(key)?.bytes ?? this.entries.get(key);
|
|
59
|
+
if (previous !== undefined && previous !== bytes)
|
|
60
|
+
throw new AuthorityCorruptionError("conflicting invocation receipt");
|
|
61
|
+
incoming.set(key, { fact, bytes });
|
|
62
|
+
}
|
|
63
|
+
let fresh = false;
|
|
64
|
+
for (const [key, { fact, bytes }] of incoming) {
|
|
65
|
+
if (this.entries.has(key))
|
|
66
|
+
continue;
|
|
67
|
+
this.entries.set(key, bytes);
|
|
68
|
+
this.admittedFacts.push(fact);
|
|
69
|
+
if (fact.kind === "deliver")
|
|
70
|
+
this.extendConclusions(fact.contract, {
|
|
71
|
+
...fact.data,
|
|
72
|
+
leading: { kind: "admitted-now", fact: fact.entry },
|
|
73
|
+
});
|
|
74
|
+
this.observe({ kind: "admitted", contractId: contract, fact });
|
|
75
|
+
this.affectedContracts.add(fact.contract);
|
|
76
|
+
fresh = true;
|
|
77
|
+
}
|
|
78
|
+
if (fresh || !this.admittedHeads.has(contract))
|
|
79
|
+
this.admittedHeads.set(contract, head);
|
|
80
|
+
}
|
|
81
|
+
recordAdmission(step) {
|
|
82
|
+
if (step.state.head === null)
|
|
83
|
+
throw new Error("admission requires a journal head");
|
|
84
|
+
this.recordPublication(step.state.id, step.state.head, step.facts);
|
|
85
|
+
if (this.admittedHeads.get(step.state.id) === step.state.head) {
|
|
86
|
+
this.admittedCheckpoints.set(step.state.id, { state: step.state, journal: step.journal });
|
|
87
|
+
}
|
|
88
|
+
this.recordResidue(step.state.id, step);
|
|
89
|
+
}
|
|
90
|
+
hasFact(fact) {
|
|
91
|
+
return this.entries.get(entryKey(fact)) === entryBytes(fact);
|
|
92
|
+
}
|
|
93
|
+
head(contract) {
|
|
94
|
+
return this.admittedHeads.get(contract);
|
|
95
|
+
}
|
|
96
|
+
checkpoint(contract) {
|
|
97
|
+
return this.admittedCheckpoints.get(contract);
|
|
98
|
+
}
|
|
99
|
+
recordResidue(contract, residue) {
|
|
100
|
+
if (residue.physical !== undefined)
|
|
101
|
+
this.recordReconciliation(contract, residue.physical);
|
|
102
|
+
for (const failure of residue.seatClose ?? [])
|
|
103
|
+
this.recordSeatClose(contract, failure);
|
|
104
|
+
}
|
|
105
|
+
recordVerification(contract, snapshot, result) {
|
|
106
|
+
if (result.cleanup !== undefined)
|
|
107
|
+
this.records.push({
|
|
108
|
+
kind: "cleanup",
|
|
109
|
+
contract,
|
|
110
|
+
issue: {
|
|
111
|
+
kind: "verification-cleanup",
|
|
112
|
+
contractId: contract,
|
|
113
|
+
...(snapshot === undefined ? {} : { snapshot }),
|
|
114
|
+
failure: result.cleanup,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
if (result.leak !== undefined)
|
|
118
|
+
this.records.push({
|
|
119
|
+
kind: "cleanup",
|
|
120
|
+
contract,
|
|
121
|
+
issue: {
|
|
122
|
+
kind: "worktree-leak",
|
|
123
|
+
contractId: contract,
|
|
124
|
+
...(snapshot === undefined ? {} : { snapshot }),
|
|
125
|
+
leak: result.leak,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/** Replace the current candidate's conclusions; accumulated resources are never erased. */
|
|
130
|
+
recordCandidate(contract, evidence) {
|
|
131
|
+
const next = { ...(this.candidateConclusions.get(contract) ?? {}) };
|
|
132
|
+
for (const key of CANDIDATE_CONCLUSION_KEYS)
|
|
133
|
+
delete next[key];
|
|
134
|
+
for (const [key, value] of Object.entries(evidence))
|
|
135
|
+
if (value !== undefined)
|
|
136
|
+
next[key] = value;
|
|
137
|
+
this.candidateConclusions.set(contract, next);
|
|
138
|
+
}
|
|
139
|
+
/** The candidate's completion base, known before an optional observation can fail. */
|
|
140
|
+
recordCompletion(contract, completion) {
|
|
141
|
+
this.extendConclusions(contract, { completion });
|
|
142
|
+
}
|
|
143
|
+
recordAudit(contract, report) {
|
|
144
|
+
this.extendConclusions(contract, report);
|
|
145
|
+
}
|
|
146
|
+
/** Physical residue a continuation's dependent reconciliation observed. */
|
|
147
|
+
recordPhysical(contract, physical) {
|
|
148
|
+
this.recordReconciliation(contract, physical);
|
|
149
|
+
}
|
|
150
|
+
recordPlacementPhysical(contract, physical) {
|
|
151
|
+
for (const lag of physical.lag) {
|
|
152
|
+
if (lag.kind !== "target-checkout-retained" || this.reportedResidue.has(lag))
|
|
153
|
+
continue;
|
|
154
|
+
this.reportedResidue.add(lag);
|
|
155
|
+
this.records.push({
|
|
156
|
+
kind: "checkout-retained",
|
|
157
|
+
contract,
|
|
158
|
+
path: lag.path,
|
|
159
|
+
target: lag.target,
|
|
160
|
+
diagnostic: lag.diagnostic,
|
|
161
|
+
});
|
|
162
|
+
this.affectedContracts.add(contract);
|
|
163
|
+
}
|
|
164
|
+
this.recordReconciliation(contract, physical);
|
|
165
|
+
}
|
|
166
|
+
/** Incremental continuation progress for the primary Contract. */
|
|
167
|
+
recordContinuation(contract, report) {
|
|
168
|
+
this.extendConclusions(contract, { continuation: report });
|
|
169
|
+
}
|
|
170
|
+
recordStop(stop) {
|
|
171
|
+
if (this.records.some((record) => record.kind === "execution-stopped" &&
|
|
172
|
+
record.contract === stop.contractId &&
|
|
173
|
+
record.stage === stop.stage &&
|
|
174
|
+
record.reason === stop.reason &&
|
|
175
|
+
record.diagnostic === stop.diagnostic))
|
|
176
|
+
return;
|
|
177
|
+
this.records.push({
|
|
178
|
+
kind: "execution-stopped",
|
|
179
|
+
contract: stop.contractId,
|
|
180
|
+
stage: stop.stage,
|
|
181
|
+
reason: stop.reason,
|
|
182
|
+
diagnostic: stop.diagnostic,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/** Physical reconciliation observations: effects, lags, settlement, and worktree topology. */
|
|
186
|
+
recordReconciliation(contract, record) {
|
|
187
|
+
for (const effect of "effects" in record ? (record.effects ?? []) : []) {
|
|
188
|
+
if (this.reportedResidue.has(effect))
|
|
189
|
+
continue;
|
|
190
|
+
this.reportedResidue.add(effect);
|
|
191
|
+
this.records.push({ kind: "reconciliation-effect", contract, effect });
|
|
192
|
+
this.affectedContracts.add(contract);
|
|
193
|
+
}
|
|
194
|
+
for (const lag of "lag" in record ? (record.lag ?? []) : []) {
|
|
195
|
+
if (this.reportedResidue.has(lag))
|
|
196
|
+
continue;
|
|
197
|
+
this.reportedResidue.add(lag);
|
|
198
|
+
this.recordLag(contract, lag);
|
|
199
|
+
}
|
|
200
|
+
const settlement = "settlement" in record ? record.settlement : undefined;
|
|
201
|
+
if (settlement !== undefined)
|
|
202
|
+
this.recordSettlement(contract, settlement);
|
|
203
|
+
const retired = "retiredWorktree" in record ? record.retiredWorktree : undefined;
|
|
204
|
+
if (retired !== undefined &&
|
|
205
|
+
!this.records.some((entry) => entry.kind === "worktree-retired" && entry.contract === contract && entry.name === retired))
|
|
206
|
+
this.records.push({ kind: "worktree-retired", contract, name: retired });
|
|
207
|
+
const retained = "retainedWorktree" in record ? record.retainedWorktree : undefined;
|
|
208
|
+
if (retained !== undefined &&
|
|
209
|
+
!this.records.some((entry) => entry.kind === "worktree-retained" && entry.contract === contract && entry.path === retained))
|
|
210
|
+
this.records.push({ kind: "worktree-retained", contract, path: retained });
|
|
211
|
+
}
|
|
212
|
+
recordSettlement(contract, report) {
|
|
213
|
+
for (const action of report.actions)
|
|
214
|
+
this.records.push({ kind: "settlement-action", contract, action });
|
|
215
|
+
for (const lag of report.lags)
|
|
216
|
+
this.records.push({ kind: "settlement-lag", contract, lag });
|
|
217
|
+
for (const failure of report.seatClose ?? [])
|
|
218
|
+
this.recordSeatClose(contract, failure);
|
|
219
|
+
}
|
|
220
|
+
recordChannelRetirement(contract, error) {
|
|
221
|
+
this.records.push({
|
|
222
|
+
kind: "cleanup",
|
|
223
|
+
contract,
|
|
224
|
+
issue: {
|
|
225
|
+
kind: "decode-channel-retirement",
|
|
226
|
+
contractId: contract,
|
|
227
|
+
diagnostic: error instanceof Error ? error.message : String(error),
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
/** World reset observations share the carrier without pretending a Contract admission happened. */
|
|
232
|
+
recordReset(effect) {
|
|
233
|
+
this.records.push(effect);
|
|
234
|
+
}
|
|
235
|
+
/** Replace the current candidate conclusions; accumulated resources are never erased. */
|
|
236
|
+
recordConclusions(contract, patch) {
|
|
237
|
+
this.candidateConclusions.set(contract, patch);
|
|
238
|
+
}
|
|
239
|
+
extendConclusions(contract, patch) {
|
|
240
|
+
this.candidateConclusions.set(contract, { ...(this.candidateConclusions.get(contract) ?? {}), ...patch });
|
|
241
|
+
}
|
|
242
|
+
conclusions(contract) {
|
|
243
|
+
return this.candidateConclusions.get(contract);
|
|
244
|
+
}
|
|
245
|
+
snapshot() {
|
|
246
|
+
return {
|
|
247
|
+
facts: Object.freeze([...this.admittedFacts]),
|
|
248
|
+
checkpoints: new Map(this.admittedCheckpoints),
|
|
249
|
+
heads: new Map(this.admittedHeads),
|
|
250
|
+
affected: Object.freeze([...this.affectedContracts]),
|
|
251
|
+
effects: Object.freeze([...this.records]),
|
|
252
|
+
conclusions: new Map(this.candidateConclusions),
|
|
253
|
+
...(this.resetState === undefined
|
|
254
|
+
? {}
|
|
255
|
+
: {
|
|
256
|
+
reset: Object.freeze({
|
|
257
|
+
world: this.resetState.world,
|
|
258
|
+
removed: Object.freeze({ ...this.resetState.removed }),
|
|
259
|
+
}),
|
|
260
|
+
}),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
recordSeatClose(contract, failure) {
|
|
264
|
+
if (this.reportedResidue.has(failure))
|
|
265
|
+
return;
|
|
266
|
+
this.reportedResidue.add(failure);
|
|
267
|
+
this.records.push({
|
|
268
|
+
kind: "cleanup",
|
|
269
|
+
contract,
|
|
270
|
+
issue: { kind: "private-state-seat-close", contractId: contract, failure },
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
recordLag(contract, lag) {
|
|
274
|
+
const affects = reconcileLagScope(lag);
|
|
275
|
+
this.records.push({ kind: "reconciliation-lag", contract, affects, lag });
|
|
276
|
+
if (affects !== "none")
|
|
277
|
+
this.affectedContracts.add(contract);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
export function physicalOf(snapshot) {
|
|
281
|
+
const effects = [];
|
|
282
|
+
const lag = [];
|
|
283
|
+
for (const record of snapshot.effects) {
|
|
284
|
+
if (record.kind === "reconciliation-effect" && record.effect.kind !== "contract-file")
|
|
285
|
+
effects.push(record.effect);
|
|
286
|
+
else if (record.kind === "reconciliation-lag" && record.lag.kind !== "contract-file-failed")
|
|
287
|
+
lag.push(record.lag);
|
|
288
|
+
}
|
|
289
|
+
return { effects, lag };
|
|
290
|
+
}
|
|
@@ -1,22 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
/** @architectureCompositionRoot */
|
|
2
|
+
import { type ExecutionContext } from "../akuma/requests.js";
|
|
3
|
+
import type { ContractId, ContractState } from "../core/facts/types.js";
|
|
4
|
+
import { type RepositoryScope } from "../protocol/operations.js";
|
|
5
|
+
import { type KeiyakuLibrary } from "./contract-composition.js";
|
|
6
|
+
import type { AbandonOutcome, AmendOutcome, ArcOutcome, AuditInput, AuditOutcome, DeliverOutcome, MutationObservation, ReviewOutcome } from "./contract-outcomes.js";
|
|
7
|
+
import type { LocalContractCompositionCapture } from "./contract-settings.js";
|
|
8
|
+
import type { AbandonInput, AmendInput, ArcInput, ContractHistory, DeliverInput, LocalContractComposition, ReviewInput } from "./contract-types.js";
|
|
9
|
+
import { type Delivery } from "./delivery.js";
|
|
10
|
+
declare const KEIYAKU_HANDLE: unique symbol;
|
|
11
|
+
type HandleSeat = Readonly<{
|
|
12
|
+
id: ContractId;
|
|
13
|
+
scope: RepositoryScope;
|
|
14
|
+
}>;
|
|
15
|
+
export declare class Keiyaku {
|
|
16
|
+
static with(input?: LocalContractComposition): KeiyakuLibrary;
|
|
17
|
+
private readonly id;
|
|
18
|
+
private readonly scope;
|
|
19
|
+
private readonly operations;
|
|
20
|
+
constructor(token: typeof KEIYAKU_HANDLE, id: ContractId, scope: RepositoryScope, execution: ExecutionContext | undefined, composition: LocalContractCompositionCapture);
|
|
21
|
+
/** The handle's one durable identity; everything else is process-local custody. */
|
|
22
|
+
toJSON(): Readonly<{
|
|
23
|
+
contract: ContractId;
|
|
24
|
+
}>;
|
|
25
|
+
state(): Promise<ContractState | null>;
|
|
26
|
+
history(): Promise<ContractHistory | null>;
|
|
27
|
+
guidance(): Promise<string | null>;
|
|
28
|
+
delivery(): Promise<Delivery | null>;
|
|
29
|
+
amend(input: AmendInput): Promise<AmendOutcome>;
|
|
30
|
+
deliver(input?: DeliverInput, options?: MutationObservation): Promise<DeliverOutcome>;
|
|
31
|
+
review(input: ReviewInput, options?: MutationObservation): Promise<ReviewOutcome>;
|
|
32
|
+
abandon(input?: AbandonInput): Promise<AbandonOutcome>;
|
|
33
|
+
arc(input: ArcInput): Promise<ArcOutcome>;
|
|
34
|
+
audit(input?: AuditInput, options?: MutationObservation): Promise<AuditOutcome>;
|
|
35
|
+
/**
|
|
36
|
+
* Reads answer with a value or `null` for legitimate absence. Corrupt authority stays exceptional
|
|
37
|
+
* and keeps its original native cause instead of being disguised as a raw native exception.
|
|
38
|
+
*/
|
|
39
|
+
private read;
|
|
40
|
+
}
|
|
41
|
+
/** Internal constructor capability; callers select a Contract through Keiyaku.with. */
|
|
42
|
+
export declare function createKeiyakuHandle(id: ContractId, scope: RepositoryScope, execution: ExecutionContext, composition: LocalContractCompositionCapture): Keiyaku;
|
|
43
|
+
/** Internal package composition capability; not exported from the package root. */
|
|
44
|
+
export declare function seatForKeiyaku(value: unknown): HandleSeat | null;
|
|
45
|
+
export {};
|
|
@@ -1,8 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/** @architectureCompositionRoot */
|
|
2
|
+
import { localExecutionContext } from "../akuma/requests.js";
|
|
3
|
+
import { renderContractGuidance } from "../contract-guidance.js";
|
|
4
|
+
import { readDispatchesAt } from "../dispatch/index.js";
|
|
5
|
+
import { mintSnapshotId } from "../git/identity.js";
|
|
6
|
+
import { observeContractsForAdmissionInObservationAt } from "../git/observe.js";
|
|
7
|
+
import { withGitDecodeChannel, withGitReadObservation } from "../git/read-observation.js";
|
|
8
|
+
import { contractObservationOperation, deliveryOperation, stateOperation, } from "../protocol/operations.js";
|
|
9
|
+
import { readManagedWorktreeAppointment } from "../workspace-place.js";
|
|
10
|
+
import { composeContractLibrary, readContractValue } from "./contract-composition.js";
|
|
11
|
+
import { ContractExecution } from "./contract-execution.js";
|
|
12
|
+
import { deliveryForContract } from "./delivery.js";
|
|
13
|
+
const KEIYAKU_HANDLE = Symbol("Keiyaku handle");
|
|
14
|
+
const KEIYAKU_SEATS = new WeakMap();
|
|
15
|
+
export class Keiyaku {
|
|
16
|
+
static with(input) {
|
|
17
|
+
return composeContractLibrary(localExecutionContext(), createKeiyakuHandle, input);
|
|
18
|
+
}
|
|
19
|
+
id;
|
|
20
|
+
scope;
|
|
21
|
+
operations;
|
|
22
|
+
constructor(token, id, scope, execution = localExecutionContext(), composition) {
|
|
23
|
+
if (token !== KEIYAKU_HANDLE)
|
|
24
|
+
throw new TypeError("Keiyaku handles are created by Keiyaku.with");
|
|
25
|
+
this.id = id;
|
|
26
|
+
this.scope = scope;
|
|
27
|
+
this.operations = new ContractExecution({ id, scope, execution, composition });
|
|
28
|
+
// Process-local custody never serializes: identity-only JSON projection.
|
|
29
|
+
Object.defineProperties(this, {
|
|
30
|
+
id: { value: id, enumerable: false },
|
|
31
|
+
scope: { value: scope, enumerable: false },
|
|
32
|
+
execution: { value: execution, enumerable: false },
|
|
33
|
+
operations: { value: this.operations, enumerable: false },
|
|
34
|
+
composition: { value: composition, enumerable: false },
|
|
35
|
+
});
|
|
36
|
+
KEIYAKU_SEATS.set(this, { id, scope });
|
|
37
|
+
Object.freeze(this);
|
|
38
|
+
}
|
|
39
|
+
/** The handle's one durable identity; everything else is process-local custody. */
|
|
40
|
+
toJSON() {
|
|
41
|
+
return { contract: this.id };
|
|
42
|
+
}
|
|
43
|
+
async state() {
|
|
44
|
+
return await this.read(() => withGitDecodeChannel(this.scope, (channel) => stateOperation({ scope: this.scope, channel, contractId: this.id })));
|
|
45
|
+
}
|
|
46
|
+
async history() {
|
|
47
|
+
return await this.read(() => withGitDecodeChannel(this.scope, (channel) => withGitReadObservation(this.scope, channel, async (observation) => {
|
|
48
|
+
const [journals, dispatches] = await Promise.all([
|
|
49
|
+
observeContractsForAdmissionInObservationAt(observation, [this.id]),
|
|
50
|
+
readDispatchesAt(observation),
|
|
51
|
+
]);
|
|
52
|
+
const record = journals.journals.get(this.id);
|
|
53
|
+
if (record === undefined)
|
|
54
|
+
throw new Error(`missing requested contract observation: ${this.id}`);
|
|
55
|
+
if (record.state === null)
|
|
56
|
+
return null;
|
|
57
|
+
const commit = observation.snapshot.commit;
|
|
58
|
+
if (commit === null)
|
|
59
|
+
throw new Error("contract history requires a keiyaku-state snapshot");
|
|
60
|
+
const recordedAt = (event) => event.source === "journal" ? event.fact.at : event.dispatch.dispatchedAt;
|
|
61
|
+
const events = [
|
|
62
|
+
...record.entries.map((fact) => ({ source: "journal", fact })),
|
|
63
|
+
...dispatches
|
|
64
|
+
.filter((dispatch) => dispatch.contractId === this.id)
|
|
65
|
+
.map((dispatch) => ({ source: "dispatch", dispatch })),
|
|
66
|
+
].sort((left, right) => {
|
|
67
|
+
const leftAt = recordedAt(left);
|
|
68
|
+
const rightAt = recordedAt(right);
|
|
69
|
+
if (leftAt !== rightAt)
|
|
70
|
+
return leftAt < rightAt ? -1 : 1;
|
|
71
|
+
if (left.source !== right.source)
|
|
72
|
+
return left.source === "journal" ? -1 : 1;
|
|
73
|
+
return 0;
|
|
74
|
+
});
|
|
75
|
+
const workspace = await readManagedWorktreeAppointment(this.scope, this.id);
|
|
76
|
+
return {
|
|
77
|
+
id: this.id,
|
|
78
|
+
state: mintSnapshotId(commit),
|
|
79
|
+
...(workspace.kind === "appointed"
|
|
80
|
+
? { workspace: { kind: "worktree", path: workspace.path } }
|
|
81
|
+
: {}),
|
|
82
|
+
events,
|
|
83
|
+
};
|
|
84
|
+
})));
|
|
85
|
+
}
|
|
86
|
+
async guidance() {
|
|
87
|
+
return await this.read(() => withGitDecodeChannel(this.scope, async (channel) => {
|
|
88
|
+
const observed = await contractObservationOperation({ scope: this.scope, channel, contractId: this.id });
|
|
89
|
+
if (observed.kind === "missing")
|
|
90
|
+
return null;
|
|
91
|
+
const state = await stateOperation({ scope: this.scope, channel, contractId: this.id });
|
|
92
|
+
return state === null ? null : renderContractGuidance(state);
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
async delivery() {
|
|
96
|
+
const delivery = await this.read(() => withGitDecodeChannel(this.scope, (channel) => deliveryOperation({ scope: this.scope, channel, contractId: this.id })));
|
|
97
|
+
return delivery === null ? null : deliveryForContract(this.scope, delivery);
|
|
98
|
+
}
|
|
99
|
+
async amend(input) {
|
|
100
|
+
return await this.operations.amend(input);
|
|
101
|
+
}
|
|
102
|
+
async deliver(input, options) {
|
|
103
|
+
return await this.operations.deliver(input, options);
|
|
104
|
+
}
|
|
105
|
+
async review(input, options) {
|
|
106
|
+
return await this.operations.review(input, options);
|
|
107
|
+
}
|
|
108
|
+
async abandon(input) {
|
|
109
|
+
return await this.operations.abandon(input);
|
|
110
|
+
}
|
|
111
|
+
async arc(input) {
|
|
112
|
+
return await this.operations.arc(input);
|
|
113
|
+
}
|
|
114
|
+
async audit(input, options) {
|
|
115
|
+
return await this.operations.audit(input, options);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Reads answer with a value or `null` for legitimate absence. Corrupt authority stays exceptional
|
|
119
|
+
* and keeps its original native cause instead of being disguised as a raw native exception.
|
|
120
|
+
*/
|
|
121
|
+
async read(operation) {
|
|
122
|
+
return await readContractValue(operation);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Internal constructor capability; callers select a Contract through Keiyaku.with. */
|
|
126
|
+
export function createKeiyakuHandle(id, scope, execution, composition) {
|
|
127
|
+
return new Keiyaku(KEIYAKU_HANDLE, id, scope, execution, composition);
|
|
128
|
+
}
|
|
129
|
+
/** Internal package composition capability; not exported from the package root. */
|
|
130
|
+
export function seatForKeiyaku(value) {
|
|
131
|
+
return value !== null && (typeof value === "object" || typeof value === "function")
|
|
132
|
+
? (KEIYAKU_SEATS.get(value) ?? null)
|
|
133
|
+
: null;
|
|
134
|
+
}
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { type PrivateStateSeatCloseLag } from "../git/private-state-seat.js";
|
|
2
1
|
import type { GitRepository } from "../git/process.js";
|
|
3
2
|
import { type WorldRoot } from "../world.js";
|
|
3
|
+
import { type ResetOutcome } from "./outcome.js";
|
|
4
4
|
export type NukeInput = Readonly<{
|
|
5
5
|
world: WorldRoot;
|
|
6
6
|
confirm?: string;
|
|
7
7
|
}>;
|
|
8
|
-
export type NukeResult =
|
|
9
|
-
kind: "success";
|
|
10
|
-
world: WorldRoot;
|
|
11
|
-
seatClose?: readonly PrivateStateSeatCloseLag[];
|
|
12
|
-
}> | Readonly<{
|
|
13
|
-
kind: "failed";
|
|
14
|
-
world: WorldRoot;
|
|
15
|
-
diagnostic: string;
|
|
16
|
-
seatClose?: readonly PrivateStateSeatCloseLag[];
|
|
17
|
-
}>;
|
|
8
|
+
export type NukeResult = ResetOutcome;
|
|
18
9
|
type NukeGitOptions = Readonly<Pick<GitRepository, "onPrivateStateSeatContention" | "onPrivateStateSeatClose">>;
|
|
19
10
|
export declare function nukeKeiyaku(input: NukeInput, gitOptions?: NukeGitOptions): Promise<NukeResult>;
|
|
20
11
|
export {};
|