@astrosheep/keiyaku 4.6.30 → 4.6.31
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 +5 -5
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku/SKILL.md +12 -12
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +12 -12
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/plugins/opencode/package.json +1 -1
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +12 -12
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/plugins/pi/README.md +5 -5
- package/build/plugins/pi/akuma-tools.ts +17 -23
- package/build/skills/keiyaku/SKILL.md +12 -12
- package/build/skills/keiyaku-akuma/SKILL.md +16 -16
- package/build/skills/keiyaku-akuma/references/automation.md +14 -14
- package/build/skills/keiyaku-babysit/SKILL.md +10 -10
- package/build/skills/keiyaku-bind/SKILL.md +15 -15
- package/build/skills/keiyaku-debt/SKILL.md +16 -16
- package/build/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/src/akuma/akuma-call.d.ts +1 -1
- package/build/src/akuma/akuma-call.js +9 -9
- package/build/src/akuma/akuma-errors.d.ts +5 -5
- package/build/src/akuma/akuma-instance.d.ts +355 -12
- package/build/src/akuma/akuma-instance.js +20 -20
- package/build/src/akuma/akuma-observe.d.ts +11 -12
- package/build/src/akuma/akuma-observe.js +34 -26
- package/build/src/akuma/akuma-owner.d.ts +32 -11
- package/build/src/akuma/akuma-owner.js +35 -16
- package/build/src/akuma/akuma-probe.d.ts +3 -3
- package/build/src/akuma/akuma-probe.js +2 -2
- package/build/src/akuma/akuma-selection-execution.d.ts +985 -1
- package/build/src/akuma/akuma-selection-execution.js +42 -18
- package/build/src/akuma/akuma-stream.d.ts +2 -2
- package/build/src/akuma/akuma-stream.js +1 -1
- package/build/src/akuma/akuma-wait.d.ts +5 -5
- package/build/src/akuma/akuma-wait.js +52 -14
- package/build/src/akuma/akuma.d.ts +245 -271
- package/build/src/akuma/akuma.js +98 -46
- package/build/src/akuma/archetype.d.ts +19 -6
- package/build/src/akuma/archetype.js +25 -9
- package/build/src/akuma/body-launch.d.ts +2 -2
- package/build/src/akuma/body.js +4 -4
- package/build/src/akuma/call-initial-tell.d.ts +60 -44
- package/build/src/akuma/call-initial-tell.js +41 -2
- package/build/src/akuma/caller.d.ts +26 -17
- package/build/src/akuma/caller.js +22 -9
- package/build/src/akuma/coordinate.d.ts +9 -0
- package/build/src/akuma/coordinate.js +13 -0
- package/build/src/akuma/detached-body.js +2 -2
- package/build/src/akuma/dispatch-association.d.ts +4 -4
- package/build/src/akuma/dispatch-association.js +12 -3
- package/build/src/akuma/execution-instructions.js +2 -2
- package/build/src/akuma/heart/facts.d.ts +29 -7
- package/build/src/akuma/heart/facts.js +13 -0
- package/build/src/akuma/heart/index.d.ts +0 -3
- package/build/src/akuma/heart/index.js +3 -6
- package/build/src/akuma/heart/rows.js +2 -2
- package/build/src/akuma/heart/soul.js +5 -5
- package/build/src/akuma/identity.d.ts +17 -16
- package/build/src/akuma/identity.js +20 -19
- package/build/src/akuma/index.d.ts +1 -2
- package/build/src/akuma/lineage-cache.d.ts +4 -4
- package/build/src/akuma/lineage-cache.js +10 -10
- package/build/src/akuma/projection-read.d.ts +2 -5
- package/build/src/akuma/projection-read.js +34 -47
- package/build/src/akuma/projection.d.ts +659 -569
- package/build/src/akuma/projection.js +203 -94
- package/build/src/akuma/providers/acp/index.js +1 -1
- package/build/src/akuma/providers/execution-environment.d.ts +1 -3
- package/build/src/akuma/providers/execution-environment.js +0 -4
- package/build/src/akuma/publication.d.ts +2 -2
- package/build/src/akuma/publication.js +3 -3
- package/build/src/akuma/retention.js +2 -2
- package/build/src/akuma/selection-observation.d.ts +507 -43
- package/build/src/akuma/selection-observation.js +153 -1
- package/build/src/akuma/status-projection.d.ts +288 -0
- package/build/src/akuma/status-projection.js +154 -0
- package/build/src/akuma/turn-drive.js +0 -3
- package/build/src/alias/index.d.ts +9 -4
- package/build/src/alias/index.js +11 -9
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +9 -0
- package/build/src/cli/commands/akuma-grammar.d.ts +2 -2
- package/build/src/cli/commands/akuma-grammar.js +21 -21
- package/build/src/cli/commands/akuma.d.ts +1 -2
- package/build/src/cli/commands/akuma.js +115 -251
- package/build/src/cli/commands/contract-grammar.d.ts +4 -3
- package/build/src/cli/commands/contract-grammar.js +39 -22
- package/build/src/cli/commands/contract-help.d.ts +3 -1
- package/build/src/cli/commands/contract-help.js +4 -3
- package/build/src/cli/commands/contract.d.ts +6 -3
- package/build/src/cli/commands/contract.js +203 -434
- package/build/src/cli/commands/debt.d.ts +2 -3
- package/build/src/cli/commands/debt.js +101 -317
- package/build/src/cli/commands/report.js +11 -28
- package/build/src/cli/commands/whoami.d.ts +3 -43
- package/build/src/cli/commands/whoami.js +8 -121
- package/build/src/cli/coordinates.d.ts +4 -35
- package/build/src/cli/coordinates.js +13 -129
- package/build/src/cli/parse.d.ts +0 -6
- package/build/src/cli/parse.js +5 -48
- package/build/src/cli/render/akuma-activity.d.ts +31 -16
- package/build/src/cli/render/akuma-activity.js +157 -149
- package/build/src/cli/render/akuma-tool.d.ts +3 -6
- package/build/src/cli/render/akuma-tool.js +20 -14
- package/build/src/cli/render/akuma.d.ts +25 -26
- package/build/src/cli/render/akuma.js +100 -129
- package/build/src/cli/render/catalog.d.ts +4 -7
- package/build/src/cli/render/catalog.js +52 -99
- package/build/src/cli/render/contract-history.d.ts +3 -1
- package/build/src/cli/render/contract-history.js +140 -215
- package/build/src/cli/render/contract-observation.d.ts +43 -30
- package/build/src/cli/render/contract-observation.js +64 -31
- package/build/src/cli/render/contract-wait.js +6 -6
- package/build/src/cli/render/contract.d.ts +41 -6
- package/build/src/cli/render/contract.js +274 -370
- package/build/src/cli/render/debt.d.ts +9 -19
- package/build/src/cli/render/debt.js +120 -185
- package/build/src/cli/render/delivery-preview.d.ts +4 -3
- package/build/src/cli/render/delivery-preview.js +68 -96
- package/build/src/cli/render/kanshi-akuma.d.ts +4 -4
- package/build/src/cli/render/kanshi-akuma.js +70 -59
- package/build/src/cli/render/kanshi.d.ts +4 -4
- package/build/src/cli/render/kanshi.js +205 -221
- package/build/src/cli/render/marks.d.ts +11 -2
- package/build/src/cli/render/marks.js +13 -3
- package/build/src/cli/render/nuke.d.ts +3 -3
- package/build/src/cli/render/nuke.js +13 -16
- package/build/src/cli/render/receipt.d.ts +37 -43
- package/build/src/cli/render/receipt.js +313 -236
- package/build/src/cli/render/reconcile.d.ts +6 -4
- package/build/src/cli/render/reconcile.js +53 -137
- package/build/src/cli/render/refusal.d.ts +3 -2
- package/build/src/cli/render/refusal.js +73 -54
- package/build/src/cli/render/region.d.ts +11 -2
- package/build/src/cli/render/region.js +17 -23
- package/build/src/cli/render/settings.d.ts +0 -1
- package/build/src/cli/render/settings.js +8 -17
- package/build/src/cli/render/terminal.d.ts +2 -0
- package/build/src/cli/render/verbs.d.ts +4 -0
- package/build/src/cli/render/verbs.js +312 -0
- package/build/src/cli/render/whoami.d.ts +1 -1
- package/build/src/cli/render/whoami.js +24 -31
- package/build/src/cli/runtime.d.ts +3 -11
- package/build/src/cli/runtime.js +96 -79
- package/build/src/cli/scan.d.ts +1 -1
- package/build/src/cli/streams.js +1 -0
- package/build/src/contract-guidance.js +2 -2
- package/build/src/contract-worktree.d.ts +2 -15
- package/build/src/contract-worktree.js +19 -35
- package/build/src/core/facts/observation.d.ts +4 -5
- package/build/src/core/facts/observation.js +7 -9
- package/build/src/core/verbs/amend.d.ts +0 -1
- package/build/src/core/verbs/amend.js +3 -3
- package/build/src/core/verbs/bind.d.ts +0 -1
- package/build/src/core/verbs/bind.js +5 -5
- package/build/src/core/verbs/deliver.d.ts +3 -2
- package/build/src/core/verbs/deliver.js +2 -2
- package/build/src/core/verbs/placement.d.ts +0 -5
- package/build/src/core/verbs/placement.js +4 -6
- package/build/src/core/verbs/reintegrate.d.ts +0 -1
- package/build/src/core/verbs/reintegrate.js +2 -2
- package/build/src/debt/board.d.ts +132 -116
- package/build/src/debt/board.js +138 -94
- package/build/src/debt/catalog.d.ts +4 -4
- package/build/src/debt/catalog.js +2 -18
- package/build/src/debt/context.d.ts +15 -3
- package/build/src/debt/context.js +12 -1
- package/build/src/debt/created-observation.d.ts +5 -17
- package/build/src/debt/created-observation.js +14 -6
- package/build/src/debt/document.d.ts +20 -15
- package/build/src/debt/document.js +18 -1
- package/build/src/debt/index.d.ts +346 -23
- package/build/src/debt/index.js +68 -22
- package/build/src/debt/input.d.ts +2 -1
- package/build/src/debt/input.js +14 -0
- package/build/src/debt/lifecycle-operations.d.ts +2 -2
- package/build/src/debt/lifecycle-operations.js +14 -22
- package/build/src/debt/operation-types.d.ts +188 -66
- package/build/src/debt/operation-types.js +113 -1
- package/build/src/debt/operations.d.ts +11 -10
- package/build/src/debt/operations.js +46 -71
- package/build/src/debt/query.d.ts +14 -10
- package/build/src/debt/query.js +3 -12
- package/build/src/debt/store.d.ts +4 -2
- package/build/src/debt/store.js +8 -8
- package/build/src/debt/view.d.ts +0 -3
- package/build/src/debt/view.js +0 -4
- package/build/src/dispatch/index.d.ts +22 -5
- package/build/src/dispatch/index.js +46 -37
- package/build/src/git/admission.d.ts +2 -2
- package/build/src/git/admission.js +2 -1
- package/build/src/git/hooks.d.ts +14 -35
- package/build/src/git/hooks.js +45 -25
- package/build/src/git/integration.d.ts +6 -24
- package/build/src/git/integration.js +10 -16
- package/build/src/git/private-state-seat.d.ts +2 -2
- package/build/src/git/private-state-seat.js +2 -1
- package/build/src/git/reconcile.d.ts +17 -79
- package/build/src/git/reconcile.js +37 -52
- package/build/src/git/scratch.d.ts +3 -3
- package/build/src/git/scratch.js +4 -1
- package/build/src/git/target-placement.d.ts +23 -31
- package/build/src/git/target-placement.js +42 -27
- package/build/src/git/target.d.ts +2 -2
- package/build/src/git/target.js +2 -1
- package/build/src/git/tender.d.ts +7 -39
- package/build/src/git/tender.js +21 -54
- package/build/src/git/terminal-reconcile.js +15 -18
- package/build/src/git/terminal-seal.d.ts +2 -4
- package/build/src/git/terminal-seal.js +7 -33
- package/build/src/git/workspace.d.ts +65 -41
- package/build/src/git/workspace.js +45 -14
- package/build/src/identity/selector.d.ts +2 -0
- package/build/src/identity/selector.js +13 -3
- package/build/src/index.d.ts +48 -54
- package/build/src/index.js +31 -43
- package/build/src/kanshi/counts.d.ts +42 -8
- package/build/src/kanshi/counts.js +13 -2
- package/build/src/kanshi/index.d.ts +5 -5
- package/build/src/kanshi/index.js +4 -3
- package/build/src/kanshi/read.d.ts +489 -6
- package/build/src/kanshi/read.js +334 -483
- package/build/src/kanshi/report.d.ts +2504 -103
- package/build/src/kanshi/report.js +165 -1
- package/build/src/kanshi/select.d.ts +0 -8
- package/build/src/kanshi/select.js +20 -59
- package/build/src/library/address.d.ts +8 -8
- package/build/src/library/address.js +7 -7
- package/build/src/library/akuma-creation.d.ts +690 -84
- package/build/src/library/akuma-creation.js +202 -142
- package/build/src/library/akuma-retention.d.ts +2 -2
- package/build/src/library/akuma-retention.js +2 -2
- package/build/src/library/akumas.d.ts +10 -6
- package/build/src/library/akumas.js +24 -7
- package/build/src/library/bind.d.ts +28 -54
- package/build/src/library/bind.js +6 -4
- package/build/src/library/continuation.d.ts +197 -479
- package/build/src/library/continuation.js +40 -23
- package/build/src/library/contract-address.d.ts +6 -5
- package/build/src/library/contract-address.js +5 -7
- package/build/src/library/contract-composition.d.ts +18 -12
- package/build/src/library/contract-composition.js +55 -47
- package/build/src/library/contract-creation.d.ts +3 -2
- package/build/src/library/contract-creation.js +38 -32
- package/build/src/library/contract-execution.js +77 -38
- package/build/src/library/contract-outcomes.d.ts +1877 -27
- package/build/src/library/contract-outcomes.js +93 -10
- package/build/src/library/contract-settings.d.ts +2 -2
- package/build/src/library/contract-settings.js +18 -14
- package/build/src/library/contract-types.d.ts +238 -61
- package/build/src/library/contract-types.js +131 -1
- package/build/src/library/contract-wait.d.ts +38 -17
- package/build/src/library/contract-wait.js +40 -10
- package/build/src/library/delivery.d.ts +588 -36
- package/build/src/library/delivery.js +35 -27
- package/build/src/library/input.d.ts +1 -1
- package/build/src/library/input.js +1 -2
- package/build/src/library/invocation.d.ts +11 -7
- package/build/src/library/invocation.js +42 -51
- package/build/src/library/kei.d.ts +48 -0
- package/build/src/library/kei.js +256 -0
- package/build/src/library/keiyaku-attribution.d.ts +11 -0
- package/build/src/{cli/delivery-identity.js → library/keiyaku-attribution.js} +12 -1
- package/build/src/library/keiyaku-classify.d.ts +11 -0
- package/build/src/library/keiyaku-classify.js +146 -0
- package/build/src/library/keiyaku-coordinates.d.ts +31 -0
- package/build/src/library/keiyaku-coordinates.js +103 -0
- package/build/src/library/keiyaku-debt.d.ts +142 -0
- package/build/src/library/keiyaku-debt.js +188 -0
- package/build/src/library/keiyaku-identity.d.ts +58 -0
- package/build/src/library/keiyaku-identity.js +176 -0
- package/build/src/library/keiyaku-policy.d.ts +27 -0
- package/build/src/library/keiyaku-policy.js +44 -0
- package/build/src/library/keiyaku-status.d.ts +1487 -0
- package/build/src/library/keiyaku-status.js +92 -0
- package/build/src/library/keiyaku-verbs.d.ts +6774 -0
- package/build/src/library/keiyaku-verbs.js +458 -0
- package/build/src/library/keiyaku.d.ts +871 -38
- package/build/src/library/keiyaku.js +677 -127
- package/build/src/library/nuke.d.ts +22 -0
- package/build/src/library/nuke.js +4 -1
- package/build/src/library/outcome.d.ts +706 -692
- package/build/src/library/outcome.js +582 -167
- package/build/src/library/reconcile.d.ts +464 -116
- package/build/src/library/reconcile.js +174 -102
- package/build/src/library/refusal.d.ts +113 -577
- package/build/src/library/refusal.js +64 -51
- package/build/src/library/region.d.ts +5 -24
- package/build/src/library/region.js +6 -21
- package/build/src/library/selection.d.ts +181 -32
- package/build/src/library/selection.js +99 -64
- package/build/src/mcp/adapter.d.ts +11 -0
- package/build/src/mcp/adapter.js +106 -0
- package/build/src/mcp/help.d.ts +1 -0
- package/build/src/mcp/help.js +26 -0
- package/build/src/mcp/index.d.ts +2 -0
- package/build/src/mcp/index.js +37 -0
- package/build/src/plugin/public.d.ts +1 -1
- package/build/src/plugin/runtime.js +17 -14
- package/build/src/protocol/arc.d.ts +4 -1
- package/build/src/protocol/arc.js +7 -1
- package/build/src/protocol/attempt.d.ts +2 -3
- package/build/src/protocol/attempt.js +1 -10
- package/build/src/protocol/bind.d.ts +6 -7
- package/build/src/protocol/bind.js +9 -5
- package/build/src/protocol/completion.d.ts +448 -12
- package/build/src/protocol/completion.js +164 -26
- package/build/src/protocol/deliver.d.ts +26 -24
- package/build/src/protocol/deliver.js +24 -52
- package/build/src/protocol/delivery-preview.d.ts +97 -247
- package/build/src/protocol/delivery-preview.js +132 -128
- package/build/src/protocol/execution-observation.d.ts +146 -123
- package/build/src/protocol/execution-observation.js +9 -6
- package/build/src/protocol/intent.d.ts +9 -48
- package/build/src/protocol/intent.js +32 -46
- package/build/src/protocol/operations.d.ts +207 -505
- package/build/src/protocol/operations.js +81 -134
- package/build/src/protocol/placement.d.ts +0 -1
- package/build/src/protocol/placement.js +5 -2
- package/build/src/protocol/progress.d.ts +7 -97
- package/build/src/protocol/progress.js +7 -55
- package/build/src/protocol/read/observation.d.ts +13 -6
- package/build/src/protocol/read/observation.js +10 -9
- package/build/src/protocol/read/status.d.ts +464 -93
- package/build/src/protocol/read/status.js +372 -85
- package/build/src/protocol/reconcile.d.ts +2 -0
- package/build/src/protocol/reconcile.js +12 -11
- package/build/src/protocol/reintegrate.d.ts +0 -1
- package/build/src/protocol/reintegrate.js +4 -4
- package/build/src/protocol/result-leaves.d.ts +528 -0
- package/build/src/protocol/result-leaves.js +195 -0
- package/build/src/protocol/result-reasons.d.ts +129 -0
- package/build/src/protocol/result-reasons.js +87 -0
- package/build/src/protocol/review.d.ts +14 -11
- package/build/src/protocol/review.js +30 -14
- package/build/src/protocol/run.d.ts +4 -4
- package/build/src/protocol/run.js +4 -1
- package/build/src/protocol/verify.d.ts +359 -30
- package/build/src/protocol/verify.js +118 -28
- package/build/src/region.d.ts +26 -0
- package/build/src/region.js +28 -0
- package/build/src/runtime/proc/diagnostic.d.ts +11 -0
- package/build/src/runtime/proc/diagnostic.js +20 -0
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +126 -32
- package/build/src/settings.js +107 -34
- package/build/src/settlement/settle.d.ts +29 -12
- package/build/src/settlement/settle.js +22 -15
- package/build/src/verification/declaration.d.ts +1 -3
- package/build/src/verification/declaration.js +2 -5
- package/build/src/verification/execution.d.ts +7 -19
- package/build/src/verification/execution.js +37 -16
- package/build/src/verification/observation.d.ts +13 -13
- package/build/src/verification/observation.js +9 -7
- package/build/src/world.d.ts +8 -0
- package/build/src/world.js +7 -0
- package/package.json +6 -5
- package/plugins/paseo/plugin/server/keiyaku.ts +13 -46
- package/plugins/paseo/plugin/server/message.ts +8 -30
- package/plugins/paseo/plugin/server/mirror.ts +16 -20
- package/plugins/paseo/plugin/server/provider.ts +1 -1
- package/plugins/paseo/plugin/server/sdk.ts +14 -6
- package/plugins/pi/README.md +5 -5
- package/plugins/pi/akuma-tools.ts +17 -23
- package/skills/keiyaku/SKILL.md +12 -12
- package/skills/keiyaku-akuma/SKILL.md +16 -16
- package/skills/keiyaku-akuma/references/automation.md +14 -14
- package/skills/keiyaku-babysit/SKILL.md +10 -10
- package/skills/keiyaku-bind/SKILL.md +15 -15
- package/skills/keiyaku-debt/SKILL.md +16 -16
- package/skills/keiyaku-workflow/SKILL.md +21 -21
- package/build/src/cli/actor.d.ts +0 -10
- package/build/src/cli/actor.js +0 -24
- package/build/src/cli/akuma-caller.d.ts +0 -3
- package/build/src/cli/akuma-caller.js +0 -31
- package/build/src/cli/delivery-identity.d.ts +0 -3
- package/build/src/cli/render/effects.d.ts +0 -26
- package/build/src/cli/render/effects.js +0 -41
- package/build/src/cli/selectors.d.ts +0 -10
- package/build/src/cli/selectors.js +0 -42
- package/build/src/markdown/diff.d.ts +0 -1
- package/build/src/markdown/diff.js +0 -4
|
@@ -1,28 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { snapshotIdSchema, changeIdSchema } from "../git/identity.js";
|
|
3
|
+
import { compactPlacement, placedSchema, placementStopSchema, } from "../protocol/completion.js";
|
|
4
|
+
import { continuationReportSchema } from "./continuation.js";
|
|
5
|
+
export const deliverPlacementSchema = z.union([
|
|
6
|
+
placedSchema.unwrap().omit({ integration: true }).readonly(),
|
|
7
|
+
placementStopSchema,
|
|
8
|
+
]);
|
|
9
|
+
export const deliveredValueSchema = z
|
|
10
|
+
.strictObject({
|
|
11
|
+
candidate: snapshotIdSchema,
|
|
12
|
+
integration: snapshotIdSchema,
|
|
13
|
+
contentId: changeIdSchema,
|
|
14
|
+
admission: z.literal("reused").exactOptional(),
|
|
15
|
+
placement: deliverPlacementSchema.exactOptional(),
|
|
16
|
+
previousContentId: changeIdSchema.exactOptional(),
|
|
17
|
+
continuation: continuationReportSchema.exactOptional(),
|
|
18
|
+
})
|
|
19
|
+
.readonly();
|
|
20
|
+
export const deliverySchema = deliveredValueSchema.nullable();
|
|
21
|
+
export function compactDelivery(delivery) {
|
|
22
|
+
const observed = compactPlacement(delivery);
|
|
23
|
+
const placement = observed?.kind === "placed" ? (({ integration: _integration, ...rest }) => rest)(observed) : observed;
|
|
24
|
+
const continuation = delivery.continuation;
|
|
25
|
+
return {
|
|
26
|
+
candidate: delivery.tenderSnapshot,
|
|
27
|
+
integration: delivery.completion?.integration ?? delivery.integration.snapshot,
|
|
28
|
+
contentId: delivery.integration.changeId,
|
|
29
|
+
...(delivery.leading?.kind === "already-admitted" ? { admission: "reused" } : {}),
|
|
30
|
+
...(placement === undefined ? {} : { placement }),
|
|
31
|
+
...(delivery.previousContentId === undefined ? {} : { previousContentId: delivery.previousContentId }),
|
|
32
|
+
...(continuation === undefined || (continuation.claimed === undefined && continuation.stopped === undefined)
|
|
33
|
+
? {}
|
|
34
|
+
: { continuation }),
|
|
35
|
+
};
|
|
28
36
|
}
|
|
@@ -13,7 +13,7 @@ export declare function optionalBoolean(value: unknown, label: string): boolean
|
|
|
13
13
|
export declare function optionalSignal(value: unknown): AbortSignal | undefined;
|
|
14
14
|
export declare function normalizedList<T>(values: unknown, label: string, brand: (value: string) => T): readonly T[];
|
|
15
15
|
export declare function contractTerms(document: DecodedContractDocument, gates: readonly Gate[], after: readonly ContractId[]): ContractTerms;
|
|
16
|
-
export declare function documentDerivation(document: DecodedContractDocument, gates: readonly Gate[]
|
|
16
|
+
export declare function documentDerivation(document: DecodedContractDocument, gates: readonly Gate[]): DocumentDerivation;
|
|
17
17
|
/** Early CLI acquisition uses the same Library caller boundary, never document-owner capabilities. */
|
|
18
18
|
export declare function validateContractMarkdown(markdown: string): void;
|
|
19
19
|
export declare function validateArcMarkdown(markdown: string): void;
|
|
@@ -92,7 +92,7 @@ export function contractTerms(document, gates, after) {
|
|
|
92
92
|
after,
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
export function documentDerivation(document, gates
|
|
95
|
+
export function documentDerivation(document, gates) {
|
|
96
96
|
return {
|
|
97
97
|
document: document.document.key,
|
|
98
98
|
bytes: document.document.bytes,
|
|
@@ -100,7 +100,6 @@ export function documentDerivation(document, gates, contractId) {
|
|
|
100
100
|
verification: prepareVerificationDeclaration({
|
|
101
101
|
gates,
|
|
102
102
|
definition: verificationDefinition(document),
|
|
103
|
-
...(contractId === undefined ? {} : { contractId }),
|
|
104
103
|
}),
|
|
105
104
|
};
|
|
106
105
|
}
|
|
@@ -8,25 +8,28 @@ import type { ContractCheckpoint, ExecutionStop, ProgressResidue, ProtocolProgre
|
|
|
8
8
|
import type { SettlementReport } from "../settlement/settle.js";
|
|
9
9
|
import type { WorldRoot } from "../world.js";
|
|
10
10
|
import type { ContinuationReport } from "./continuation.js";
|
|
11
|
-
import type { InvocationEffect,
|
|
11
|
+
import type { InvocationEffect, ReconciliationLag, ResetCounts } from "./outcome.js";
|
|
12
|
+
type RecordedVerificationCheck = Parameters<ProtocolProgress["recordVerificationCheck"]>[2];
|
|
13
|
+
export type CandidateConclusion = Readonly<Record<string, unknown>> & Readonly<{
|
|
14
|
+
checks?: readonly RecordedVerificationCheck[];
|
|
15
|
+
}>;
|
|
12
16
|
export type InvocationSnapshot = Readonly<{
|
|
13
17
|
facts: readonly JournalEntry[];
|
|
14
18
|
checkpoints: ReadonlyMap<ContractId, ContractCheckpoint>;
|
|
15
19
|
heads: ReadonlyMap<ContractId, ContractHead>;
|
|
16
20
|
affected: readonly ContractId[];
|
|
17
21
|
effects: readonly InvocationEffect[];
|
|
18
|
-
conclusions: ReadonlyMap<ContractId,
|
|
22
|
+
conclusions: ReadonlyMap<ContractId, CandidateConclusion>;
|
|
19
23
|
reset?: Readonly<{
|
|
20
24
|
world: WorldRoot;
|
|
21
25
|
removed: ResetCounts;
|
|
26
|
+
attempted: readonly ("git" | "debt")[];
|
|
22
27
|
}>;
|
|
23
28
|
}>;
|
|
24
29
|
type ReconciliationRecord = Readonly<{
|
|
25
|
-
effects?:
|
|
30
|
+
effects?: ReconcileResult["effects"];
|
|
26
31
|
lag?: readonly ReconciliationLag[];
|
|
27
32
|
settlement?: SettlementReport;
|
|
28
|
-
retiredWorktree?: string;
|
|
29
|
-
retainedWorktree?: string;
|
|
30
33
|
}>;
|
|
31
34
|
/**
|
|
32
35
|
* The one invocation accumulator. It exists before any admission-capable await, satisfies the lower
|
|
@@ -46,6 +49,7 @@ export declare class InvocationAccumulator implements ProtocolProgress {
|
|
|
46
49
|
private resetState?;
|
|
47
50
|
constructor(observer?: ExecutionObserver | undefined);
|
|
48
51
|
beginReset(world: WorldRoot): void;
|
|
52
|
+
recordResetAttempt(owner: "git" | "debt"): void;
|
|
49
53
|
recordResetRemoved(counts: Partial<ResetCounts>): void;
|
|
50
54
|
observe(event: ExecutionObservation): void;
|
|
51
55
|
/** A confirmed publication is retained even if folding or later physical work throws. */
|
|
@@ -59,7 +63,7 @@ export declare class InvocationAccumulator implements ProtocolProgress {
|
|
|
59
63
|
requirement: string;
|
|
60
64
|
index: number;
|
|
61
65
|
}>): void;
|
|
62
|
-
recordVerificationCheck(contract: ContractId,
|
|
66
|
+
recordVerificationCheck(contract: ContractId, snapshot: Parameters<ProtocolProgress["recordVerificationCheck"]>[1], check: RecordedVerificationCheck): void;
|
|
63
67
|
/** Replace the current candidate's conclusions; accumulated resources are never erased. */
|
|
64
68
|
recordCandidate(contract: ContractId, evidence: CompletionEvidence): void;
|
|
65
69
|
/** The candidate's completion base, known before an optional observation can fail. */
|
|
@@ -82,7 +86,7 @@ export declare class InvocationAccumulator implements ProtocolProgress {
|
|
|
82
86
|
/** Replace the current candidate conclusions; accumulated resources are never erased. */
|
|
83
87
|
recordConclusions(contract: ContractId, patch: Readonly<Record<string, unknown>>): void;
|
|
84
88
|
extendConclusions(contract: ContractId, patch: Readonly<Record<string, unknown>>): void;
|
|
85
|
-
conclusions(contract: ContractId):
|
|
89
|
+
conclusions(contract: ContractId): CandidateConclusion | undefined;
|
|
86
90
|
snapshot(): InvocationSnapshot;
|
|
87
91
|
private recordSeatClose;
|
|
88
92
|
private recordLag;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { encodeEntry } from "../core/facts/codec.js";
|
|
3
3
|
import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
4
4
|
import { observeExecution, } from "../protocol/execution-observation.js";
|
|
5
|
-
import { reconcileLagScope } from "./
|
|
6
|
-
const CANDIDATE_CONCLUSION_KEYS = ["completion", "
|
|
5
|
+
import { compactEffect, reconcileLagScope } from "./outcome.js";
|
|
6
|
+
const CANDIDATE_CONCLUSION_KEYS = ["completion", "placement"];
|
|
7
7
|
function entryKey(fact) {
|
|
8
8
|
return `${fact.contract}\u0000${fact.entry}`;
|
|
9
9
|
}
|
|
@@ -27,7 +27,13 @@ export class InvocationAccumulator {
|
|
|
27
27
|
this.observer = observer;
|
|
28
28
|
}
|
|
29
29
|
beginReset(world) {
|
|
30
|
-
this.resetState = { world, removed: { refs: 0, worktrees: 0, debts: 0 } };
|
|
30
|
+
this.resetState = { world, removed: { refs: 0, worktrees: 0, debts: 0 }, attempted: [] };
|
|
31
|
+
}
|
|
32
|
+
recordResetAttempt(owner) {
|
|
33
|
+
if (this.resetState === undefined)
|
|
34
|
+
throw new Error("reset progress requires its World");
|
|
35
|
+
if (!this.resetState.attempted.includes(owner))
|
|
36
|
+
this.resetState.attempted.push(owner);
|
|
31
37
|
}
|
|
32
38
|
recordResetRemoved(counts) {
|
|
33
39
|
if (this.resetState === undefined)
|
|
@@ -94,33 +100,32 @@ export class InvocationAccumulator {
|
|
|
94
100
|
recordVerification(contract, snapshot, result, coordinate) {
|
|
95
101
|
if (result.cleanup !== undefined)
|
|
96
102
|
this.records.push({
|
|
97
|
-
kind: "
|
|
103
|
+
kind: "issue",
|
|
98
104
|
contract,
|
|
99
105
|
issue: {
|
|
100
106
|
kind: "verification-cleanup",
|
|
101
|
-
contractId: contract,
|
|
102
107
|
...(snapshot === undefined ? {} : { snapshot }),
|
|
103
108
|
...coordinate,
|
|
104
|
-
|
|
109
|
+
name: result.cleanup.name,
|
|
110
|
+
diagnostic: result.cleanup.diagnostic,
|
|
105
111
|
},
|
|
106
112
|
});
|
|
107
113
|
if (result.leak !== undefined)
|
|
108
114
|
this.records.push({
|
|
109
|
-
kind: "
|
|
115
|
+
kind: "issue",
|
|
110
116
|
contract,
|
|
111
117
|
issue: {
|
|
112
118
|
kind: "worktree-leak",
|
|
113
|
-
contractId: contract,
|
|
114
119
|
...(snapshot === undefined ? {} : { snapshot }),
|
|
115
120
|
...coordinate,
|
|
116
|
-
leak: result.leak,
|
|
121
|
+
...(result.leak.path === undefined ? {} : { path: result.leak.path }),
|
|
122
|
+
diagnostic: result.leak.diagnostic,
|
|
117
123
|
},
|
|
118
124
|
});
|
|
119
125
|
}
|
|
120
|
-
recordVerificationCheck(contract, check) {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
this.extendConclusions(contract, { snapshot: check.snapshot, checks: [...checks, check] });
|
|
126
|
+
recordVerificationCheck(contract, snapshot, check) {
|
|
127
|
+
const checks = this.candidateConclusions.get(contract)?.checks ?? [];
|
|
128
|
+
this.extendConclusions(contract, { snapshot, checks: [...checks, check] });
|
|
124
129
|
}
|
|
125
130
|
/** Replace the current candidate's conclusions; accumulated resources are never erased. */
|
|
126
131
|
recordCandidate(contract, evidence) {
|
|
@@ -144,19 +149,6 @@ export class InvocationAccumulator {
|
|
|
144
149
|
this.recordReconciliation(contract, physical);
|
|
145
150
|
}
|
|
146
151
|
recordPlacementPhysical(contract, physical) {
|
|
147
|
-
for (const lag of physical.lag) {
|
|
148
|
-
if (lag.kind !== "target-checkout-retained" || this.reportedResidue.has(lag))
|
|
149
|
-
continue;
|
|
150
|
-
this.reportedResidue.add(lag);
|
|
151
|
-
this.records.push({
|
|
152
|
-
kind: "checkout-retained",
|
|
153
|
-
contract,
|
|
154
|
-
path: lag.path,
|
|
155
|
-
target: lag.target,
|
|
156
|
-
diagnostic: lag.diagnostic,
|
|
157
|
-
});
|
|
158
|
-
this.affectedContracts.add(contract);
|
|
159
|
-
}
|
|
160
152
|
this.recordReconciliation(contract, physical);
|
|
161
153
|
}
|
|
162
154
|
/** Incremental continuation progress for the primary Contract. */
|
|
@@ -164,18 +156,16 @@ export class InvocationAccumulator {
|
|
|
164
156
|
this.extendConclusions(contract, { continuation: report });
|
|
165
157
|
}
|
|
166
158
|
recordStop(stop) {
|
|
167
|
-
if (this.records.some((record) => record.kind === "
|
|
159
|
+
if (this.records.some((record) => record.kind === "issue" &&
|
|
160
|
+
record.issue.kind === "execution-stopped" &&
|
|
168
161
|
record.contract === stop.contractId &&
|
|
169
|
-
record.
|
|
170
|
-
record.
|
|
171
|
-
record.diagnostic === stop.diagnostic))
|
|
162
|
+
record.issue.reason === stop.reason &&
|
|
163
|
+
record.issue.diagnostic === stop.diagnostic))
|
|
172
164
|
return;
|
|
173
165
|
this.records.push({
|
|
174
|
-
kind: "
|
|
166
|
+
kind: "issue",
|
|
175
167
|
contract: stop.contractId,
|
|
176
|
-
|
|
177
|
-
reason: stop.reason,
|
|
178
|
-
diagnostic: stop.diagnostic,
|
|
168
|
+
issue: { kind: "execution-stopped", reason: stop.reason, diagnostic: stop.diagnostic },
|
|
179
169
|
});
|
|
180
170
|
}
|
|
181
171
|
/** Physical reconciliation observations: effects, lags, settlement, and worktree topology. */
|
|
@@ -184,8 +174,10 @@ export class InvocationAccumulator {
|
|
|
184
174
|
if (this.reportedResidue.has(effect))
|
|
185
175
|
continue;
|
|
186
176
|
this.reportedResidue.add(effect);
|
|
187
|
-
this.records.push({ kind: "reconciliation-effect", contract, effect });
|
|
188
177
|
this.affectedContracts.add(contract);
|
|
178
|
+
const movement = compactEffect(effect);
|
|
179
|
+
if (movement !== undefined)
|
|
180
|
+
this.records.push({ kind: "movement", contract, effect: movement });
|
|
189
181
|
}
|
|
190
182
|
for (const lag of "lag" in record ? (record.lag ?? []) : []) {
|
|
191
183
|
if (this.reportedResidue.has(lag))
|
|
@@ -196,30 +188,29 @@ export class InvocationAccumulator {
|
|
|
196
188
|
const settlement = "settlement" in record ? record.settlement : undefined;
|
|
197
189
|
if (settlement !== undefined)
|
|
198
190
|
this.recordSettlement(contract, settlement);
|
|
199
|
-
const retired = "retiredWorktree" in record ? record.retiredWorktree : undefined;
|
|
200
|
-
if (retired !== undefined &&
|
|
201
|
-
!this.records.some((entry) => entry.kind === "worktree-retired" && entry.contract === contract && entry.name === retired))
|
|
202
|
-
this.records.push({ kind: "worktree-retired", contract, name: retired });
|
|
203
|
-
const retained = "retainedWorktree" in record ? record.retainedWorktree : undefined;
|
|
204
|
-
if (retained !== undefined &&
|
|
205
|
-
!this.records.some((entry) => entry.kind === "worktree-retained" && entry.contract === contract && entry.path === retained))
|
|
206
|
-
this.records.push({ kind: "worktree-retained", contract, path: retained });
|
|
207
191
|
}
|
|
208
192
|
recordSettlement(contract, report) {
|
|
209
193
|
for (const action of report.actions)
|
|
210
194
|
this.records.push({ kind: "settlement-action", contract, action });
|
|
211
195
|
for (const lag of report.lags)
|
|
212
|
-
this.records.push({
|
|
196
|
+
this.records.push({
|
|
197
|
+
kind: "issue",
|
|
198
|
+
contract,
|
|
199
|
+
issue: {
|
|
200
|
+
kind: "settlement-failed",
|
|
201
|
+
...(lag.debtId === undefined ? {} : { debtId: lag.debtId }),
|
|
202
|
+
diagnostic: `${lag.surface}: ${lag.diagnostic}`,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
213
205
|
for (const failure of report.seatClose ?? [])
|
|
214
206
|
this.recordSeatClose(contract, failure);
|
|
215
207
|
}
|
|
216
208
|
recordChannelRetirement(contract, error) {
|
|
217
209
|
this.records.push({
|
|
218
|
-
kind: "
|
|
210
|
+
kind: "issue",
|
|
219
211
|
contract,
|
|
220
212
|
issue: {
|
|
221
213
|
kind: "decode-channel-retirement",
|
|
222
|
-
contractId: contract,
|
|
223
214
|
diagnostic: error instanceof Error ? error.message : String(error),
|
|
224
215
|
},
|
|
225
216
|
});
|
|
@@ -252,6 +243,7 @@ export class InvocationAccumulator {
|
|
|
252
243
|
reset: Object.freeze({
|
|
253
244
|
world: this.resetState.world,
|
|
254
245
|
removed: Object.freeze({ ...this.resetState.removed }),
|
|
246
|
+
attempted: Object.freeze([...this.resetState.attempted]),
|
|
255
247
|
}),
|
|
256
248
|
}),
|
|
257
249
|
};
|
|
@@ -261,15 +253,14 @@ export class InvocationAccumulator {
|
|
|
261
253
|
return;
|
|
262
254
|
this.reportedResidue.add(failure);
|
|
263
255
|
this.records.push({
|
|
264
|
-
kind: "
|
|
256
|
+
kind: "issue",
|
|
265
257
|
contract,
|
|
266
|
-
issue: { kind: "private-state-seat-close",
|
|
258
|
+
issue: { kind: "private-state-seat-close", diagnostic: failure.diagnostic },
|
|
267
259
|
});
|
|
268
260
|
}
|
|
269
261
|
recordLag(contract, lag) {
|
|
270
|
-
|
|
271
|
-
this.records.push({ kind: "reconciliation-lag", contract, affects, lag });
|
|
272
|
-
if (affects !== "none")
|
|
262
|
+
if (reconcileLagScope(lag) !== "none")
|
|
273
263
|
this.affectedContracts.add(contract);
|
|
264
|
+
this.records.push({ kind: "issue", contract, issue: lag });
|
|
274
265
|
}
|
|
275
266
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** @architectureCompositionRoot */
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { ContractId, ContractState } from "../core/facts/types.js";
|
|
4
|
+
import { type RepositoryScope } from "../protocol/operations.js";
|
|
5
|
+
import type { AbandonOutcome, AmendOutcome, ArcOutcome, DeliveryPreviewInput, DeliveryPreviewOutcome, DeliverOutcome, MutationObservation, ReviewOutcome, VerifyOutcome } from "./contract-outcomes.js";
|
|
6
|
+
import type { LocalContractCompositionCapture } from "./contract-settings.js";
|
|
7
|
+
import type { AbandonInput, AmendInput, ArcInput, ContractHistory, ContractHistoryInput, DeliverInput, ReviewInput, VerifyInput } from "./contract-types.js";
|
|
8
|
+
import { type Delivery } from "./delivery.js";
|
|
9
|
+
import { type ContractWaitOptions, type ContractWaitResult } from "./contract-wait.js";
|
|
10
|
+
export declare const guidanceSchema: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{
|
|
11
|
+
kind: z.ZodLiteral<"present">;
|
|
12
|
+
guidance: z.ZodString;
|
|
13
|
+
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
14
|
+
kind: z.ZodLiteral<"missing">;
|
|
15
|
+
}, z.core.$strict>>]>;
|
|
16
|
+
export type Guidance = z.output<typeof guidanceSchema>;
|
|
17
|
+
declare const KEIYAKU_HANDLE: unique symbol;
|
|
18
|
+
type HandleSeat = Readonly<{
|
|
19
|
+
id: ContractId;
|
|
20
|
+
scope: RepositoryScope;
|
|
21
|
+
}>;
|
|
22
|
+
export declare class Kei {
|
|
23
|
+
private readonly id;
|
|
24
|
+
private readonly scope;
|
|
25
|
+
private readonly operations;
|
|
26
|
+
constructor(token: typeof KEIYAKU_HANDLE, id: ContractId, scope: RepositoryScope, composition: LocalContractCompositionCapture);
|
|
27
|
+
/** The handle's one durable identity; everything else is process-local custody. */
|
|
28
|
+
toJSON(): Readonly<{
|
|
29
|
+
contract: ContractId;
|
|
30
|
+
}>;
|
|
31
|
+
state(): Promise<ContractState | null>;
|
|
32
|
+
wait(input?: ContractWaitOptions): Promise<ContractWaitResult>;
|
|
33
|
+
history(input?: ContractHistoryInput): Promise<ContractHistory>;
|
|
34
|
+
guidance(): Promise<Guidance>;
|
|
35
|
+
delivery(): Promise<Delivery | null>;
|
|
36
|
+
amend(input: AmendInput): Promise<AmendOutcome>;
|
|
37
|
+
deliver(input?: DeliverInput, options?: MutationObservation): Promise<DeliverOutcome>;
|
|
38
|
+
verify(input?: VerifyInput, options?: MutationObservation): Promise<VerifyOutcome>;
|
|
39
|
+
review(input: ReviewInput, options?: MutationObservation): Promise<ReviewOutcome>;
|
|
40
|
+
abandon(input?: AbandonInput): Promise<AbandonOutcome>;
|
|
41
|
+
arc(input: ArcInput): Promise<ArcOutcome>;
|
|
42
|
+
previewDelivery(input?: DeliveryPreviewInput, options?: MutationObservation): Promise<DeliveryPreviewOutcome>;
|
|
43
|
+
}
|
|
44
|
+
/** Internal constructor capability; callers select a Contract through Keis.of. */
|
|
45
|
+
export declare function createKeiHandle(id: ContractId, scope: RepositoryScope, composition: LocalContractCompositionCapture): Kei;
|
|
46
|
+
/** Internal package composition capability; not exported from the package root. */
|
|
47
|
+
export declare function seatForKei(value: unknown): HandleSeat | null;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/** @architectureCompositionRoot */
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { renderContractGuidance } from "../contract-guidance.js";
|
|
4
|
+
import { parseToAST } from "../markdown/parse.js";
|
|
5
|
+
import { indexDocument, indexedHeadings, sectionContent } from "../markdown/query.js";
|
|
6
|
+
import { readDispatchesAt } from "../dispatch/index.js";
|
|
7
|
+
import { observeContractsForAdmissionInObservationAt } from "../git/observe.js";
|
|
8
|
+
import { withGitDecodeChannel, withGitReadObservation } from "../git/read-observation.js";
|
|
9
|
+
import { contractObservationOperation, deliveryOperation, stateOperation, } from "../protocol/operations.js";
|
|
10
|
+
import { errorCategory, readContractValue, validated } from "./outcome.js";
|
|
11
|
+
import { optionalBoolean, requireInput } from "./input.js";
|
|
12
|
+
import { ContractExecution } from "./contract-execution.js";
|
|
13
|
+
import { compactDelivery } from "./delivery.js";
|
|
14
|
+
import { validateContractWaitHandle, waitContractLocal, } from "./contract-wait.js";
|
|
15
|
+
export const guidanceSchema = z.union([
|
|
16
|
+
z.strictObject({ kind: z.literal("present"), guidance: z.string() }).readonly(),
|
|
17
|
+
z.strictObject({ kind: z.literal("missing") }).readonly(),
|
|
18
|
+
]);
|
|
19
|
+
const KEIYAKU_HANDLE = Symbol("Kei handle");
|
|
20
|
+
const KEIYAKU_SEATS = new WeakMap();
|
|
21
|
+
export class Kei {
|
|
22
|
+
id;
|
|
23
|
+
scope;
|
|
24
|
+
operations;
|
|
25
|
+
constructor(token, id, scope, composition) {
|
|
26
|
+
if (token !== KEIYAKU_HANDLE)
|
|
27
|
+
throw new TypeError("Kei handles are created by Keis.of");
|
|
28
|
+
this.id = id;
|
|
29
|
+
this.scope = scope;
|
|
30
|
+
this.operations = new ContractExecution({ id, scope, composition });
|
|
31
|
+
// Process-local custody never serializes: identity-only JSON projection.
|
|
32
|
+
Object.defineProperties(this, {
|
|
33
|
+
id: { value: id, enumerable: false },
|
|
34
|
+
scope: { value: scope, enumerable: false },
|
|
35
|
+
operations: { value: this.operations, enumerable: false },
|
|
36
|
+
composition: { value: composition, enumerable: false },
|
|
37
|
+
});
|
|
38
|
+
KEIYAKU_SEATS.set(this, { id, scope });
|
|
39
|
+
Object.freeze(this);
|
|
40
|
+
}
|
|
41
|
+
/** The handle's one durable identity; everything else is process-local custody. */
|
|
42
|
+
toJSON() {
|
|
43
|
+
return { contract: this.id };
|
|
44
|
+
}
|
|
45
|
+
async state() {
|
|
46
|
+
return await readContractValue(() => withGitDecodeChannel(this.scope, (channel) => stateOperation({ scope: this.scope, channel, contractId: this.id })));
|
|
47
|
+
}
|
|
48
|
+
async wait(input) {
|
|
49
|
+
return await waitContractLocal(validateContractWaitHandle(this.scope, this.id, input));
|
|
50
|
+
}
|
|
51
|
+
async history(input) {
|
|
52
|
+
const full = validated(() => {
|
|
53
|
+
const values = input === undefined ? {} : requireInput(input, "Contract history input", ["full"]);
|
|
54
|
+
return optionalBoolean(values.full, "full") === true;
|
|
55
|
+
});
|
|
56
|
+
return await readContractValue(() => withGitDecodeChannel(this.scope, (channel) => withGitReadObservation(this.scope, channel, async (observation) => {
|
|
57
|
+
const journals = await observeContractsForAdmissionInObservationAt(observation, [this.id]);
|
|
58
|
+
const record = journals.journals.get(this.id);
|
|
59
|
+
if (record === undefined)
|
|
60
|
+
throw new Error(`missing requested contract observation: ${this.id}`);
|
|
61
|
+
if (record.state === null)
|
|
62
|
+
return { kind: "contract-missing", contractId: this.id };
|
|
63
|
+
let terms;
|
|
64
|
+
const events = record.entries.map((entry) => {
|
|
65
|
+
const event = historyEvent(entry, terms, full);
|
|
66
|
+
if (entry.kind === "bind")
|
|
67
|
+
terms = entry.data.terms;
|
|
68
|
+
else if (entry.kind === "amend")
|
|
69
|
+
terms = entry.data;
|
|
70
|
+
return event;
|
|
71
|
+
});
|
|
72
|
+
let unavailable;
|
|
73
|
+
let dispatches;
|
|
74
|
+
try {
|
|
75
|
+
dispatches = await readDispatchesAt(observation);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const category = errorCategory(error);
|
|
79
|
+
if (category === "aborted" || this.scope.signal?.aborted === true)
|
|
80
|
+
throw error;
|
|
81
|
+
unavailable = {
|
|
82
|
+
kind: "unavailable",
|
|
83
|
+
category: category === "authority-corruption" ? category : "internal",
|
|
84
|
+
diagnostic: error instanceof Error ? error.message : String(error),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
events.push(...(dispatches ?? [])
|
|
88
|
+
.filter((dispatch) => dispatch.contractId === this.id)
|
|
89
|
+
.map((dispatch) => ({
|
|
90
|
+
kind: "dispatch",
|
|
91
|
+
at: dispatch.dispatchedAt,
|
|
92
|
+
akumaId: dispatch.akumaId,
|
|
93
|
+
})));
|
|
94
|
+
events.sort((left, right) => {
|
|
95
|
+
if (left.at !== right.at)
|
|
96
|
+
return left.at < right.at ? -1 : 1;
|
|
97
|
+
if ((left.kind === "dispatch") !== (right.kind === "dispatch"))
|
|
98
|
+
return left.kind === "dispatch" ? 1 : -1;
|
|
99
|
+
return 0;
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
kind: "contract",
|
|
103
|
+
contractId: this.id,
|
|
104
|
+
events,
|
|
105
|
+
...(unavailable === undefined ? {} : { dispatches: unavailable }),
|
|
106
|
+
};
|
|
107
|
+
})));
|
|
108
|
+
}
|
|
109
|
+
async guidance() {
|
|
110
|
+
return await readContractValue(() => withGitDecodeChannel(this.scope, async (channel) => {
|
|
111
|
+
const observed = await contractObservationOperation({ scope: this.scope, channel, contractId: this.id });
|
|
112
|
+
if (observed.kind === "missing")
|
|
113
|
+
return { kind: "missing" };
|
|
114
|
+
const state = await stateOperation({ scope: this.scope, channel, contractId: this.id });
|
|
115
|
+
return state === null ? { kind: "missing" } : { kind: "present", guidance: renderContractGuidance(state) };
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
async delivery() {
|
|
119
|
+
const delivery = await readContractValue(() => withGitDecodeChannel(this.scope, (channel) => deliveryOperation({ scope: this.scope, channel, contractId: this.id })));
|
|
120
|
+
return delivery === null ? null : compactDelivery(delivery);
|
|
121
|
+
}
|
|
122
|
+
async amend(input) {
|
|
123
|
+
return await this.operations.amend(input);
|
|
124
|
+
}
|
|
125
|
+
async deliver(input, options) {
|
|
126
|
+
return await this.operations.deliver(input, options);
|
|
127
|
+
}
|
|
128
|
+
async verify(input, options) {
|
|
129
|
+
return await this.operations.verify(input, options);
|
|
130
|
+
}
|
|
131
|
+
async review(input, options) {
|
|
132
|
+
return await this.operations.review(input, options);
|
|
133
|
+
}
|
|
134
|
+
async abandon(input) {
|
|
135
|
+
return await this.operations.abandon(input);
|
|
136
|
+
}
|
|
137
|
+
async arc(input) {
|
|
138
|
+
return await this.operations.arc(input);
|
|
139
|
+
}
|
|
140
|
+
async previewDelivery(input, options) {
|
|
141
|
+
return await this.operations.previewDelivery(input, options);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function changedHistoryTerms(before, after) {
|
|
145
|
+
const sections = (terms) => {
|
|
146
|
+
const document = parseToAST(terms.document.bytes);
|
|
147
|
+
return new Map(indexedHeadings(indexDocument(document), { level: 2 })
|
|
148
|
+
.filter((section) => section.type === "section")
|
|
149
|
+
.map((section) => [section.title, sectionContent(document, section)]));
|
|
150
|
+
};
|
|
151
|
+
const source = before === undefined ? new Map() : sections(before);
|
|
152
|
+
const amended = sections(after);
|
|
153
|
+
const changedSections = [...new Set([...source.keys(), ...amended.keys()])].filter((name) => source.get(name) !== amended.get(name));
|
|
154
|
+
const equal = (left, right) => left !== undefined && left.length === right.length && left.every((value, index) => value === right[index]);
|
|
155
|
+
return {
|
|
156
|
+
...(changedSections.length === 0 ? {} : { changedSections }),
|
|
157
|
+
...(equal(before?.gates, after.gates) ? {} : { gates: after.gates }),
|
|
158
|
+
...(equal(before?.after, after.after) ? {} : { after: after.after }),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function attestationHistory(entry) {
|
|
162
|
+
const { gate, requirement, subject, verdict, summary } = entry.data;
|
|
163
|
+
return {
|
|
164
|
+
kind: "attestation",
|
|
165
|
+
gate,
|
|
166
|
+
requirement,
|
|
167
|
+
verdict,
|
|
168
|
+
subject,
|
|
169
|
+
...(summary === undefined ? {} : { summary }),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function historyEvent(entry, terms, full) {
|
|
173
|
+
const common = { id: entry.entry, at: entry.at, ...(entry.actor === undefined ? {} : { actor: entry.actor }) };
|
|
174
|
+
switch (entry.kind) {
|
|
175
|
+
case "bind": {
|
|
176
|
+
const { coordinates, terms: bound } = entry.data;
|
|
177
|
+
const target = coordinates.target;
|
|
178
|
+
return {
|
|
179
|
+
...common,
|
|
180
|
+
kind: "bind",
|
|
181
|
+
start: coordinates.start,
|
|
182
|
+
...(target === undefined
|
|
183
|
+
? {}
|
|
184
|
+
: {
|
|
185
|
+
target: typeof target === "string" ? target : { kind: "contract", contractId: target.contractId },
|
|
186
|
+
}),
|
|
187
|
+
...(full
|
|
188
|
+
? {
|
|
189
|
+
document: bound.document.bytes,
|
|
190
|
+
gates: bound.gates,
|
|
191
|
+
after: bound.after,
|
|
192
|
+
...(typeof target === "object" ? { targetIncarnation: target.worktree } : {}),
|
|
193
|
+
}
|
|
194
|
+
: {
|
|
195
|
+
...(bound.gates.length === 0 ? {} : { gates: bound.gates }),
|
|
196
|
+
...(bound.after.length === 0 ? {} : { after: bound.after }),
|
|
197
|
+
}),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
case "amend":
|
|
201
|
+
return {
|
|
202
|
+
...common,
|
|
203
|
+
kind: "amend",
|
|
204
|
+
...changedHistoryTerms(terms, entry.data),
|
|
205
|
+
...(full ? { document: entry.data.document.bytes, gates: entry.data.gates, after: entry.data.after } : {}),
|
|
206
|
+
};
|
|
207
|
+
case "deliver": {
|
|
208
|
+
const { tenderSnapshot, integration, note } = entry.data;
|
|
209
|
+
return {
|
|
210
|
+
...common,
|
|
211
|
+
kind: "deliver",
|
|
212
|
+
candidate: tenderSnapshot,
|
|
213
|
+
integration: integration.snapshot,
|
|
214
|
+
contentId: integration.changeId,
|
|
215
|
+
predecessor: integration.predecessor,
|
|
216
|
+
...(note === undefined ? {} : { note }),
|
|
217
|
+
...(full ? { requireBranchesToBeUpToDate: entry.data.policy.requireBranchesToBeUpToDate } : {}),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
case "reintegrated":
|
|
221
|
+
return {
|
|
222
|
+
...common,
|
|
223
|
+
kind: "reintegrated",
|
|
224
|
+
predecessor: entry.data.predecessor,
|
|
225
|
+
integration: entry.data.snapshot,
|
|
226
|
+
};
|
|
227
|
+
case "attestation":
|
|
228
|
+
return { ...common, ...attestationHistory(entry) };
|
|
229
|
+
case "claimed":
|
|
230
|
+
return { ...common, kind: "claimed", deliveryId: entry.data.delivery };
|
|
231
|
+
case "arc":
|
|
232
|
+
return {
|
|
233
|
+
...common,
|
|
234
|
+
kind: "arc",
|
|
235
|
+
chapter: entry.data.seq,
|
|
236
|
+
title: entry.data.title,
|
|
237
|
+
...(entry.data.body.length === 0 && !full ? {} : { body: entry.data.body }),
|
|
238
|
+
};
|
|
239
|
+
case "abandoned":
|
|
240
|
+
return {
|
|
241
|
+
...common,
|
|
242
|
+
kind: "abandoned",
|
|
243
|
+
...(entry.data.note === undefined ? {} : { note: entry.data.note }),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/** Internal constructor capability; callers select a Contract through Keis.of. */
|
|
248
|
+
export function createKeiHandle(id, scope, composition) {
|
|
249
|
+
return new Kei(KEIYAKU_HANDLE, id, scope, composition);
|
|
250
|
+
}
|
|
251
|
+
/** Internal package composition capability; not exported from the package root. */
|
|
252
|
+
export function seatForKei(value) {
|
|
253
|
+
return value !== null && (typeof value === "object" || typeof value === "function")
|
|
254
|
+
? (KEIYAKU_SEATS.get(value) ?? null)
|
|
255
|
+
: null;
|
|
256
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Owner } from "@astrosheep/square";
|
|
2
|
+
import { type ActorId } from "../core/facts/types.js";
|
|
3
|
+
type ActorResolutionInput = Readonly<{
|
|
4
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
5
|
+
actor?: string;
|
|
6
|
+
}>;
|
|
7
|
+
/** Resolve optional caller testimony from explicit invocation input. */
|
|
8
|
+
export declare function resolveActor(input?: ActorResolutionInput): ActorId | undefined;
|
|
9
|
+
/** Select attribution at the submitting edge; no host or artifact lookup. */
|
|
10
|
+
export declare function deliveryOwner(environment: NodeJS.ProcessEnv): Owner | undefined;
|
|
11
|
+
export {};
|