@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,11 +1,163 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { targetName } from "../core/facts/types.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { snapshotIdSchema, contractIdSchema } from "../git/identity.js";
|
|
4
|
+
import { requirementIdSchema, gateSchema } from "./result-leaves.js";
|
|
4
5
|
import { admitPlacement, observeTargetPlacement, observeIntegrationTargetMovement } from "./placement.js";
|
|
5
6
|
import { reintegrateOperation } from "./reintegrate.js";
|
|
6
7
|
import { contractCheckpoint, executionStop, isOperationalFailure, isOperationalStop, } from "./progress.js";
|
|
7
8
|
import { placementStop, timestamp } from "./operations.js";
|
|
9
|
+
import { activeReasonSchema, targetLifecycleReasonSchema, targetWorkspaceReasonSchema, checkoutCollisionSchema, integrationProblemSchema, retrySchema, compactRetry, compactReason, } from "./result-reasons.js";
|
|
8
10
|
const MAX_REINTEGRATION_CYCLES = 3;
|
|
11
|
+
const requirementCoordinate = { gate: gateSchema, requirement: requirementIdSchema };
|
|
12
|
+
export const requirementProblemSchema = z.union([
|
|
13
|
+
z.strictObject({ ...requirementCoordinate, state: z.literal("missing") }).readonly(),
|
|
14
|
+
z
|
|
15
|
+
.strictObject({ ...requirementCoordinate, state: z.literal("unsatisfied"), summary: z.string().exactOptional() })
|
|
16
|
+
.readonly(),
|
|
17
|
+
z
|
|
18
|
+
.strictObject({
|
|
19
|
+
...requirementCoordinate,
|
|
20
|
+
state: z.literal("stale"),
|
|
21
|
+
previousContentId: z.string().min(1).exactOptional(),
|
|
22
|
+
currentContentId: z.string().min(1).exactOptional(),
|
|
23
|
+
})
|
|
24
|
+
.readonly(),
|
|
25
|
+
]);
|
|
26
|
+
/** Select already-adjudicated unmet requirements; never recompute currentness. */
|
|
27
|
+
export function unmetGateProblems(reports) {
|
|
28
|
+
return reports
|
|
29
|
+
.filter((report) => !report.satisfied)
|
|
30
|
+
.flatMap((report) => report.requirements.flatMap(({ requirement, current }) => {
|
|
31
|
+
const coordinate = { gate: report.gate, requirement };
|
|
32
|
+
if (current.kind === "missing")
|
|
33
|
+
return [{ ...coordinate, state: "missing" }];
|
|
34
|
+
if (current.kind === "attested")
|
|
35
|
+
return current.verdict === "satisfied"
|
|
36
|
+
? []
|
|
37
|
+
: [
|
|
38
|
+
{
|
|
39
|
+
...coordinate,
|
|
40
|
+
state: "unsatisfied",
|
|
41
|
+
...(current.summary === undefined ? {} : { summary: current.summary }),
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
...coordinate,
|
|
47
|
+
state: "stale",
|
|
48
|
+
...(current.reason === undefined
|
|
49
|
+
? {}
|
|
50
|
+
: {
|
|
51
|
+
previousContentId: current.reason.previousChange,
|
|
52
|
+
currentContentId: current.reason.currentChange,
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
export const unmetPrerequisiteSchema = z
|
|
59
|
+
.strictObject({
|
|
60
|
+
contractId: contractIdSchema,
|
|
61
|
+
state: z.enum(["missing", "active", "abandoned"]),
|
|
62
|
+
})
|
|
63
|
+
.readonly();
|
|
64
|
+
export const placementReasonSchema = z.union([
|
|
65
|
+
activeReasonSchema,
|
|
66
|
+
targetLifecycleReasonSchema,
|
|
67
|
+
targetWorkspaceReasonSchema,
|
|
68
|
+
z.strictObject({ kind: z.enum(["delivery-missing", "target-missing"]) }).readonly(),
|
|
69
|
+
z
|
|
70
|
+
.strictObject({
|
|
71
|
+
kind: z.literal("prerequisites-unsatisfied"),
|
|
72
|
+
unmet: z.array(unmetPrerequisiteSchema).min(1).readonly(),
|
|
73
|
+
})
|
|
74
|
+
.readonly(),
|
|
75
|
+
z
|
|
76
|
+
.strictObject({ kind: z.literal("gates-unsatisfied"), unmet: z.array(requirementProblemSchema).min(1).readonly() })
|
|
77
|
+
.readonly(),
|
|
78
|
+
checkoutCollisionSchema,
|
|
79
|
+
...integrationProblemSchema.options,
|
|
80
|
+
]);
|
|
81
|
+
export const placementFailureSchema = z.union([
|
|
82
|
+
retrySchema,
|
|
83
|
+
z.strictObject({ kind: z.literal("failed"), diagnostic: z.string().min(1) }).readonly(),
|
|
84
|
+
z
|
|
85
|
+
.strictObject({
|
|
86
|
+
kind: z.literal("target-content-identical"),
|
|
87
|
+
target: z.string().min(1),
|
|
88
|
+
expected: snapshotIdSchema,
|
|
89
|
+
observed: snapshotIdSchema,
|
|
90
|
+
})
|
|
91
|
+
.readonly(),
|
|
92
|
+
z
|
|
93
|
+
.strictObject({
|
|
94
|
+
kind: z.literal("target-moved"),
|
|
95
|
+
target: z.string().min(1),
|
|
96
|
+
integration: snapshotIdSchema,
|
|
97
|
+
observed: snapshotIdSchema.nullable(),
|
|
98
|
+
})
|
|
99
|
+
.readonly(),
|
|
100
|
+
]);
|
|
101
|
+
export const placementStopLeaves = [
|
|
102
|
+
...placementReasonSchema.options,
|
|
103
|
+
...retrySchema.options,
|
|
104
|
+
placementFailureSchema.options[1],
|
|
105
|
+
placementFailureSchema.options[2],
|
|
106
|
+
placementFailureSchema.options[3],
|
|
107
|
+
];
|
|
108
|
+
export const placementStopSchema = z.union(placementStopLeaves);
|
|
109
|
+
export const compactScopeSchema = z
|
|
110
|
+
.strictObject({
|
|
111
|
+
filesChanged: z.number().int().positive().exactOptional(),
|
|
112
|
+
insertions: z.number().int().positive().exactOptional(),
|
|
113
|
+
deletions: z.number().int().positive().exactOptional(),
|
|
114
|
+
paths: z.array(z.string()).min(1).readonly().exactOptional(),
|
|
115
|
+
})
|
|
116
|
+
.readonly();
|
|
117
|
+
export const placedSchema = z
|
|
118
|
+
.strictObject({
|
|
119
|
+
kind: z.literal("placed"),
|
|
120
|
+
integration: snapshotIdSchema,
|
|
121
|
+
target: z.string().exactOptional(),
|
|
122
|
+
predecessor: snapshotIdSchema.exactOptional(),
|
|
123
|
+
})
|
|
124
|
+
.readonly();
|
|
125
|
+
export const placementSchema = z.union([placedSchema, placementStopSchema]);
|
|
126
|
+
export function compactScope(scope) {
|
|
127
|
+
return {
|
|
128
|
+
...(scope.filesChanged === 0 ? {} : { filesChanged: scope.filesChanged }),
|
|
129
|
+
...(scope.insertions === 0 ? {} : { insertions: scope.insertions }),
|
|
130
|
+
...(scope.deletions === 0 ? {} : { deletions: scope.deletions }),
|
|
131
|
+
...(scope.paths === undefined || scope.paths.length === 0 ? {} : { paths: scope.paths }),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export function compactPlacementStop(stop) {
|
|
135
|
+
if ("refusal" in stop) {
|
|
136
|
+
const reason = stop.refusal;
|
|
137
|
+
if (reason.kind === "gates-unsatisfied")
|
|
138
|
+
return { kind: reason.kind, unmet: unmetGateProblems(reason.unmet) };
|
|
139
|
+
if (reason.kind === "prerequisites-unsatisfied")
|
|
140
|
+
return { kind: reason.kind, unmet: reason.unmet };
|
|
141
|
+
if (reason.kind === "checkout-not-followable")
|
|
142
|
+
return reason;
|
|
143
|
+
return compactReason(reason);
|
|
144
|
+
}
|
|
145
|
+
if ("retry" in stop)
|
|
146
|
+
return compactRetry(stop.retry);
|
|
147
|
+
if (stop.failure === "target-placement-failed")
|
|
148
|
+
return { kind: "failed", diagnostic: stop.diagnostic };
|
|
149
|
+
if ("integratedAt" in stop)
|
|
150
|
+
return { kind: "target-moved", target: stop.target, integration: stop.integratedAt, observed: stop.observed };
|
|
151
|
+
if (!stop.observedTreeEqualsCandidate || stop.observed === null)
|
|
152
|
+
throw new Error("unexhausted returned target movement requires identical content");
|
|
153
|
+
return { kind: "target-content-identical", target: stop.target, expected: stop.expected, observed: stop.observed };
|
|
154
|
+
}
|
|
155
|
+
export function compactPlacement(evidence) {
|
|
156
|
+
if (evidence.completion !== undefined)
|
|
157
|
+
return { kind: "placed", ...evidence.completion };
|
|
158
|
+
return evidence.placement === undefined ? undefined : compactPlacementStop(evidence.placement);
|
|
159
|
+
}
|
|
160
|
+
export const candidateCompletionSchema = placedSchema.unwrap().omit({ kind: true }).readonly();
|
|
9
161
|
function reintegrationStop(result) {
|
|
10
162
|
if (result.kind === "placement-failed")
|
|
11
163
|
return { failure: "target-placement-failed", diagnostic: result.diagnostic };
|
|
@@ -42,25 +194,14 @@ async function completedResult(input, cursor) {
|
|
|
42
194
|
throw new Error("accepted placement requires its integration snapshot");
|
|
43
195
|
const target = state.coordinates.target;
|
|
44
196
|
const predecessor = state.currentIntegration?.predecessor;
|
|
45
|
-
// Movement and the completion base are known before this optional observation; a failed scope
|
|
46
|
-
// read must never erase an already-claimed candidate.
|
|
47
|
-
cursor.completion = {
|
|
48
|
-
integration,
|
|
49
|
-
...(predecessor === undefined || target === undefined ? {} : { predecessor, target: targetName(target) }),
|
|
50
|
-
};
|
|
51
|
-
input.progress.recordCompletion(state.id, cursor.completion);
|
|
52
|
-
cursor.evidence = { gates: gateReports(state).reports };
|
|
53
|
-
input.progress.recordCandidate(state.id, { ...cursor.evidence, completion: cursor.completion });
|
|
54
|
-
const scope = predecessor === undefined ? undefined : await readDeliveryScope(input.repository, predecessor, integration, false);
|
|
55
197
|
const completion = {
|
|
56
198
|
integration,
|
|
57
199
|
...(predecessor === undefined || target === undefined ? {} : { predecessor, target: targetName(target) }),
|
|
58
|
-
...(scope === undefined
|
|
59
|
-
? {}
|
|
60
|
-
: { scope: { filesChanged: scope.filesChanged, insertions: scope.insertions, deletions: scope.deletions } }),
|
|
61
200
|
};
|
|
62
201
|
cursor.completion = completion;
|
|
63
202
|
input.progress.recordCompletion(state.id, completion);
|
|
203
|
+
cursor.evidence = {};
|
|
204
|
+
input.progress.recordCandidate(state.id, { ...cursor.evidence, completion });
|
|
64
205
|
return {
|
|
65
206
|
kind: "completed",
|
|
66
207
|
checkpoint: cursor.checkpoint,
|
|
@@ -68,13 +209,10 @@ async function completedResult(input, cursor) {
|
|
|
68
209
|
};
|
|
69
210
|
}
|
|
70
211
|
function stoppedResult(cursor, stop) {
|
|
71
|
-
const evidence = "kind" in stop
|
|
72
|
-
? cursor.evidence
|
|
73
|
-
: { ...cursor.evidence, placement: stop };
|
|
212
|
+
const evidence = "kind" in stop ? cursor.evidence : { ...cursor.evidence, placement: stop };
|
|
74
213
|
return { kind: "stopped", checkpoint: cursor.checkpoint, evidence, stop };
|
|
75
214
|
}
|
|
76
215
|
async function placeCurrentCandidate(input, cursor) {
|
|
77
|
-
cursor.stage = "placement";
|
|
78
216
|
input.signal?.throwIfAborted();
|
|
79
217
|
input.progress.observe({
|
|
80
218
|
kind: "stage",
|
|
@@ -123,7 +261,7 @@ async function advanceCandidate(input, cursor) {
|
|
|
123
261
|
const target = cursor.checkpoint.state.coordinates.target;
|
|
124
262
|
for (let cycles = 0;; cycles += 1) {
|
|
125
263
|
input.signal?.throwIfAborted();
|
|
126
|
-
cursor.evidence = {
|
|
264
|
+
cursor.evidence = {};
|
|
127
265
|
input.progress.recordCandidate(cursor.checkpoint.state.id, cursor.evidence);
|
|
128
266
|
let placement = await observeIntegrationTargetMovement(input.repository, cursor.checkpoint.state);
|
|
129
267
|
if (placement === undefined) {
|
|
@@ -131,7 +269,7 @@ async function advanceCandidate(input, cursor) {
|
|
|
131
269
|
if (targetStop !== undefined)
|
|
132
270
|
return stoppedResult(cursor, targetStop);
|
|
133
271
|
placement = await placeCurrentCandidate(input, cursor);
|
|
134
|
-
cursor.evidence = {
|
|
272
|
+
cursor.evidence = {};
|
|
135
273
|
input.progress.recordCandidate(cursor.checkpoint.state.id, cursor.evidence);
|
|
136
274
|
}
|
|
137
275
|
if (placement.kind === "accepted")
|
|
@@ -145,15 +283,12 @@ async function advanceCandidate(input, cursor) {
|
|
|
145
283
|
if (cycles === MAX_REINTEGRATION_CYCLES) {
|
|
146
284
|
return stoppedResult(cursor, {
|
|
147
285
|
failure: "target-moved",
|
|
148
|
-
contractId: cursor.checkpoint.state.id,
|
|
149
286
|
target: targetName(target),
|
|
150
287
|
integratedAt: cursor.checkpoint.state.currentIntegration.snapshot,
|
|
151
288
|
observed: placement.observed,
|
|
152
|
-
attempts: cycles,
|
|
153
289
|
observedTreeEqualsCandidate: placement.observedTreeEqualsCandidate,
|
|
154
290
|
});
|
|
155
291
|
}
|
|
156
|
-
cursor.stage = "reintegration";
|
|
157
292
|
input.signal?.throwIfAborted();
|
|
158
293
|
const reintegrated = await reintegrateOperation({
|
|
159
294
|
channel: input.channel,
|
|
@@ -171,7 +306,10 @@ async function advanceCandidate(input, cursor) {
|
|
|
171
306
|
}
|
|
172
307
|
/** Advance one contract. The trigger owns the leading act; this node owns no other contract. */
|
|
173
308
|
export async function completeCandidate(input) {
|
|
174
|
-
const cursor = {
|
|
309
|
+
const cursor = {
|
|
310
|
+
checkpoint: input.checkpoint,
|
|
311
|
+
evidence: {},
|
|
312
|
+
};
|
|
175
313
|
try {
|
|
176
314
|
return await advanceCandidate(input, cursor);
|
|
177
315
|
}
|
|
@@ -179,7 +317,7 @@ export async function completeCandidate(input) {
|
|
|
179
317
|
if (!isOperationalStop(error, input.signal))
|
|
180
318
|
throw error;
|
|
181
319
|
const contractId = input.checkpoint.state.id;
|
|
182
|
-
const stop = executionStop(contractId,
|
|
320
|
+
const stop = executionStop(contractId, error, input.signal);
|
|
183
321
|
input.progress.recordStop(stop);
|
|
184
322
|
const admitted = input.progress.checkpoint(contractId);
|
|
185
323
|
if (admitted !== undefined)
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import type { ActorId, ContractId, ContractState, DeliverData, JournalEntry, SnapshotId } from "../core/facts/types.js";
|
|
2
|
+
import type { ActorId, ChangeId, ContractId, ContractState, DeliverData, EntryUlid, JournalEntry, SnapshotId } from "../core/facts/types.js";
|
|
4
3
|
import type { LeadingOutcome } from "./outcome.js";
|
|
5
4
|
import type { CompletionEvidence } from "./completion.js";
|
|
6
5
|
import { type ManagedWorktreeAppointment } from "../workspace-place.js";
|
|
7
|
-
import type { DeliveryPreparationRefusal, DocumentDerivation, MutationOperationInput } from "./operations.js";
|
|
6
|
+
import type { DeliveryPreparationRefusal, DocumentDerivation, MechanicalPreparationRefusal, MutationOperationInput } from "./operations.js";
|
|
8
7
|
type DeliveryIdentity = DeliverData;
|
|
9
8
|
/** Known prospective and delivered integrations, newest first, without giving Git producer vocabulary. */
|
|
10
9
|
export declare function deliveryIntegrationSnapshots(journal: readonly JournalEntry[]): readonly SnapshotId[];
|
|
11
|
-
export
|
|
12
|
-
kind:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}>;
|
|
16
|
-
fact: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").EntryUlid, string>>;
|
|
17
|
-
reusedIntegration: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>>;
|
|
18
|
-
}, z.core.$strict>;
|
|
19
|
-
type DeliverLeading = z.infer<typeof deliverLeadingSchema>;
|
|
10
|
+
export type DeliverLeading = Readonly<{
|
|
11
|
+
kind: "admitted-now" | "already-admitted";
|
|
12
|
+
fact: EntryUlid;
|
|
13
|
+
}>;
|
|
20
14
|
type DeliverValue = DeliveryIdentity & CompletionEvidence & Readonly<{
|
|
21
15
|
leading: DeliverLeading;
|
|
22
|
-
|
|
16
|
+
previousContentId?: ChangeId;
|
|
23
17
|
}>;
|
|
24
|
-
export declare const materializedConflictSchema: z.ZodObject<{
|
|
18
|
+
export declare const materializedConflictSchema: z.ZodReadonly<z.ZodObject<{
|
|
25
19
|
kind: z.ZodLiteral<"integration-conflict-materialized">;
|
|
26
20
|
targetHead: z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>;
|
|
27
21
|
conflictPaths: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
28
|
-
workspace: z.ZodObject<{
|
|
22
|
+
workspace: z.ZodReadonly<z.ZodObject<{
|
|
29
23
|
kind: z.ZodLiteral<"worktree">;
|
|
30
24
|
path: z.ZodString;
|
|
31
|
-
}, z.core.$strict
|
|
25
|
+
}, z.core.$strict>>;
|
|
32
26
|
handoffBase: z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>;
|
|
33
|
-
recovery: z.ZodObject<{
|
|
34
|
-
materialize: z.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, z.core.$strict
|
|
27
|
+
recovery: z.ZodReadonly<z.ZodObject<{
|
|
28
|
+
materialize: z.ZodReadonly<z.ZodObject<{
|
|
29
|
+
kind: z.ZodLiteral<"deliver">;
|
|
30
|
+
materializeConflict: z.ZodLiteral<true>;
|
|
31
|
+
includeDirty: z.ZodLiteral<true>;
|
|
32
|
+
}, z.core.$strict>>;
|
|
33
|
+
deliver: z.ZodReadonly<z.ZodObject<{
|
|
34
|
+
kind: z.ZodLiteral<"deliver">;
|
|
35
|
+
includeDirty: z.ZodLiteral<true>;
|
|
36
|
+
}, z.core.$strict>>;
|
|
37
|
+
}, z.core.$strict>>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
39
|
export type IntegrationConflictMaterialized = z.infer<typeof materializedConflictSchema>;
|
|
40
40
|
type DeliverOperationInput = MutationOperationInput & Readonly<{
|
|
41
41
|
deriveDocument: (state: ContractState) => DocumentDerivation;
|
|
@@ -46,7 +46,9 @@ type DeliverOperationInput = MutationOperationInput & Readonly<{
|
|
|
46
46
|
overwrite?: boolean;
|
|
47
47
|
signal?: AbortSignal;
|
|
48
48
|
}>;
|
|
49
|
-
type DeliverOperationRefusal = import("../core/verbs/deliver.js").DeliverRefusal
|
|
49
|
+
type DeliverOperationRefusal = Exclude<import("../core/verbs/deliver.js").DeliverRefusal, {
|
|
50
|
+
kind: "document-moved";
|
|
51
|
+
}> | DeliveryPreparationRefusal | import("./operations.js").DeliverConflictRefusal | import("../verification/declaration.js").VerificationDeclarationRefusal;
|
|
50
52
|
export declare function prepareDelivery(repository: import("../git/process.js").GitRepository, stage: Readonly<{
|
|
51
53
|
contractId: ContractId;
|
|
52
54
|
coordinates: ContractState["coordinates"];
|
|
@@ -66,7 +68,7 @@ export declare function prepareDelivery(repository: import("../git/process.js").
|
|
|
66
68
|
data: DeliverData;
|
|
67
69
|
} | {
|
|
68
70
|
kind: "refused";
|
|
69
|
-
refusal:
|
|
71
|
+
refusal: MechanicalPreparationRefusal;
|
|
70
72
|
}>;
|
|
71
73
|
export declare function admitDeliveryOperation(input: DeliverOperationInput): Promise<LeadingOutcome<DeliverValue, DeliverOperationRefusal> | IntegrationConflictMaterialized>;
|
|
72
74
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { entryUlidSchema } from "./attempt.js";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
import { snapshotIdSchema } from "./operations.js";
|
|
4
3
|
import { conflictRecoverySchema, worktreeWorkspaceSchema } from "../git/workspace.js";
|
|
@@ -7,9 +6,8 @@ import { captureTender, dirtyTenderRefusal, materializeTenderSnapshot, prepareDe
|
|
|
7
6
|
import { checkoutDetachedSnapshot, recordConflictHandoff, retireConflictHandoff, workspaceMergeStatePresent, worktreePath, conflictRecovery, } from "../git/workspace.js";
|
|
8
7
|
import { observeContractsForAdmissionAt } from "../git/observe.js";
|
|
9
8
|
import { externalPreparation, privateStateSeatAttempt, protocolSeatClose, runBoundedAttempts, sameWorktreeWitness, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
|
|
10
|
-
import { contractState,
|
|
9
|
+
import { contractState, targetContractRefusal } from "../core/facts/observation.js";
|
|
11
10
|
import { dependencyKeys } from "../core/subject.js";
|
|
12
|
-
import { targetName } from "../core/facts/types.js";
|
|
13
11
|
import { resolveContractTarget } from "../git/target.js";
|
|
14
12
|
import { acquireTargetPlacementFence } from "../git/target-placement.js";
|
|
15
13
|
import { decideDeliver } from "../core/verbs/deliver.js";
|
|
@@ -31,13 +29,6 @@ export function deliveryIntegrationSnapshots(journal) {
|
|
|
31
29
|
})
|
|
32
30
|
.reverse();
|
|
33
31
|
}
|
|
34
|
-
export const deliverLeadingSchema = z
|
|
35
|
-
.object({
|
|
36
|
-
kind: z.enum(["admitted-now", "already-admitted"]),
|
|
37
|
-
fact: entryUlidSchema,
|
|
38
|
-
reusedIntegration: snapshotIdSchema.optional(),
|
|
39
|
-
})
|
|
40
|
-
.strict();
|
|
41
32
|
export const materializedConflictSchema = z
|
|
42
33
|
.object({
|
|
43
34
|
kind: z.literal("integration-conflict-materialized"),
|
|
@@ -47,7 +38,8 @@ export const materializedConflictSchema = z
|
|
|
47
38
|
handoffBase: snapshotIdSchema,
|
|
48
39
|
recovery: conflictRecoverySchema,
|
|
49
40
|
})
|
|
50
|
-
.strict()
|
|
41
|
+
.strict()
|
|
42
|
+
.readonly();
|
|
51
43
|
const DELIVER_CONFLICT_RECOVERY = conflictRecovery;
|
|
52
44
|
async function captureAuthorizedDeliveryTender(repository, stage, includeDirty) {
|
|
53
45
|
const { contractId, coordinates } = stage;
|
|
@@ -66,7 +58,7 @@ async function captureAuthorizedDeliveryTender(repository, stage, includeDirty)
|
|
|
66
58
|
return tender;
|
|
67
59
|
if (((tender.data.dirty || tender.data.mergeHead !== undefined) && includeDirty !== true) ||
|
|
68
60
|
tender.data.changes.submodules.length > 0) {
|
|
69
|
-
return { kind: "refused", refusal:
|
|
61
|
+
return { kind: "refused", refusal: dirtyTenderRefusal(tender.data) };
|
|
70
62
|
}
|
|
71
63
|
return { kind: "prepared", data: tender.data };
|
|
72
64
|
}
|
|
@@ -87,10 +79,10 @@ async function prepareDeliveryWithWorktree(repository, stage, input, captured) {
|
|
|
87
79
|
});
|
|
88
80
|
const tenderSnapshot = await materializeTenderSnapshot(repository, tender.data, commit);
|
|
89
81
|
const requireBranchesToBeUpToDate = input.requireBranchesToBeUpToDate ?? false;
|
|
90
|
-
const integration = await planIntegration(repository, {
|
|
82
|
+
const integration = await planIntegration(repository, { coordinates }, { ...tender.data, head: tenderSnapshot }, requireBranchesToBeUpToDate);
|
|
91
83
|
if (integration.kind === "refused")
|
|
92
84
|
return integration;
|
|
93
|
-
const changeId = await worktreeChangeId(repository, {
|
|
85
|
+
const changeId = await worktreeChangeId(repository, { coordinates }, tender.data);
|
|
94
86
|
// A targetless dirty integration is the captured tender, whose sole parent is the worktree head.
|
|
95
87
|
const reusedIntegration = await reusableIntegrationSnapshot(repository, integration.data.tree, coordinates.target === undefined && tender.data.dirty ? tender.data.head : integration.data.predecessor, stage.recordedIntegrations ?? []);
|
|
96
88
|
const integrationSnapshot = reusedIntegration ??
|
|
@@ -99,7 +91,6 @@ async function prepareDeliveryWithWorktree(repository, stage, input, captured) {
|
|
|
99
91
|
: await materializeIntegrationSnapshot(repository, integration.data.tree, integration.data.predecessor, commit));
|
|
100
92
|
return {
|
|
101
93
|
kind: "prepared",
|
|
102
|
-
...(reusedIntegration === undefined ? {} : { reusedIntegration }),
|
|
103
94
|
data: {
|
|
104
95
|
...(input.message === undefined ? {} : { note: input.message }),
|
|
105
96
|
tenderSnapshot,
|
|
@@ -143,7 +134,7 @@ async function recaptureDeliveryWorktree(input, state) {
|
|
|
143
134
|
head: tender.data.head,
|
|
144
135
|
...(tender.data.mergeHead === undefined ? {} : { mergeHead: tender.data.mergeHead }),
|
|
145
136
|
dirty: tender.data.dirty,
|
|
146
|
-
changeId: await worktreeChangeId(input.scope, {
|
|
137
|
+
changeId: await worktreeChangeId(input.scope, { coordinates: state.coordinates }, tender.data),
|
|
147
138
|
};
|
|
148
139
|
}
|
|
149
140
|
async function mechanicalDeliveryPreparation(input, state, derivation, journal, captured) {
|
|
@@ -160,11 +151,10 @@ async function mechanicalDeliveryPreparation(input, state, derivation, journal,
|
|
|
160
151
|
document: derivation.document,
|
|
161
152
|
data: prepared.data,
|
|
162
153
|
worktree: prepared.worktree,
|
|
163
|
-
...(prepared.reusedIntegration === undefined ? {} : { reusedIntegration: prepared.reusedIntegration }),
|
|
164
154
|
};
|
|
165
155
|
}
|
|
166
156
|
function worktreeInput(repository, state, tender) {
|
|
167
|
-
return worktreeChangeId(repository, {
|
|
157
|
+
return worktreeChangeId(repository, { coordinates: state.coordinates }, tender).then((changeId) => ({
|
|
168
158
|
tree: tender.tree,
|
|
169
159
|
head: tender.head,
|
|
170
160
|
...(tender.mergeHead === undefined ? {} : { mergeHead: tender.mergeHead }),
|
|
@@ -198,7 +188,6 @@ async function prepareDeliveryArtifacts(input, observation, state) {
|
|
|
198
188
|
kind: "mechanical",
|
|
199
189
|
data: prepared.data,
|
|
200
190
|
worktree: prepared.worktree,
|
|
201
|
-
...(prepared.reusedIntegration === undefined ? {} : { reusedIntegration: prepared.reusedIntegration }),
|
|
202
191
|
}
|
|
203
192
|
: { kind: "refused", refusal: prepared.refusal };
|
|
204
193
|
}
|
|
@@ -250,7 +239,6 @@ async function assembleDeliveryAttempt(input, observation, external) {
|
|
|
250
239
|
state,
|
|
251
240
|
derivation,
|
|
252
241
|
preparation: { kind: "prepared", document: derivation.document, data: artifacts.data },
|
|
253
|
-
...(artifacts.reusedIntegration === undefined ? {} : { reusedIntegration: artifacts.reusedIntegration }),
|
|
254
242
|
};
|
|
255
243
|
}
|
|
256
244
|
/**
|
|
@@ -279,9 +267,6 @@ async function completeDeferredDelivery(input, state, derivation, journal) {
|
|
|
279
267
|
kind: "assembled",
|
|
280
268
|
state,
|
|
281
269
|
derivation,
|
|
282
|
-
...(prepared.kind !== "prepared" || prepared.reusedIntegration === undefined
|
|
283
|
-
? {}
|
|
284
|
-
: { reusedIntegration: prepared.reusedIntegration }),
|
|
285
270
|
preparation: prepared.kind === "prepared"
|
|
286
271
|
? { kind: "prepared", document: derivation.document, data: prepared.data }
|
|
287
272
|
: prepared,
|
|
@@ -298,9 +283,6 @@ function currentCandidateDeliveryDecision(input, observation, assembled) {
|
|
|
298
283
|
const state = assembled.state;
|
|
299
284
|
if (state === null || assembled.derivation === undefined || assembled.reuse !== true)
|
|
300
285
|
return undefined;
|
|
301
|
-
if (!documentIsCurrent(state, assembled.derivation.document)) {
|
|
302
|
-
return { kind: "refused", refusal: { kind: "document-moved", contractId: state.id } };
|
|
303
|
-
}
|
|
304
286
|
const record = observation.journals.get(input.contractId);
|
|
305
287
|
const delivery = record?.entries.findLast((entry) => entry.kind === "deliver");
|
|
306
288
|
if (record === undefined || delivery === undefined)
|
|
@@ -319,7 +301,7 @@ function currentCandidateDeliveryDecision(input, observation, assembled) {
|
|
|
319
301
|
}
|
|
320
302
|
async function validateDeliveryTarget(input, observation, assembled) {
|
|
321
303
|
const target = assembled.state?.coordinates.target;
|
|
322
|
-
const targetRefusal = targetContractRefusal(observation.decision,
|
|
304
|
+
const targetRefusal = targetContractRefusal(observation.decision, target);
|
|
323
305
|
if (targetRefusal !== undefined)
|
|
324
306
|
return { kind: "refused", refusal: targetRefusal };
|
|
325
307
|
if (target === undefined || typeof target === "string")
|
|
@@ -352,8 +334,11 @@ async function decideAndAdmitDelivery(input, attempt, seat, observation, assembl
|
|
|
352
334
|
attempt,
|
|
353
335
|
observation: observation.decision,
|
|
354
336
|
});
|
|
355
|
-
if (decision.kind === "refused")
|
|
356
|
-
return
|
|
337
|
+
if (decision.kind === "refused") {
|
|
338
|
+
return decision.refusal.kind === "document-moved"
|
|
339
|
+
? STALE_PRIVATE_STATE_PREPARATION
|
|
340
|
+
: { kind: "refused", refusal: decision.refusal };
|
|
341
|
+
}
|
|
357
342
|
if (preparation.kind !== "prepared")
|
|
358
343
|
throw new Error("offered delivery is missing its mechanical preparation");
|
|
359
344
|
const admission = await admitDecidedOffer({ ...input, seat, observation, attempt, offer: decision.offer });
|
|
@@ -362,8 +347,7 @@ async function decideAndAdmitDelivery(input, attempt, seat, observation, assembl
|
|
|
362
347
|
const deliverFact = admission.facts.find((fact) => fact.contract === input.contractId && fact.kind === "deliver");
|
|
363
348
|
if (deliverFact?.kind !== "deliver")
|
|
364
349
|
throw new Error("confirmed delivery requires its own receipt");
|
|
365
|
-
const
|
|
366
|
-
const currentChange = preparation.data.integration.changeId;
|
|
350
|
+
const previousContentId = assembled.state?.delivery?.data.integration.changeId;
|
|
367
351
|
return {
|
|
368
352
|
...admission,
|
|
369
353
|
value: {
|
|
@@ -371,20 +355,10 @@ async function decideAndAdmitDelivery(input, attempt, seat, observation, assembl
|
|
|
371
355
|
leading: {
|
|
372
356
|
kind: "admitted-now",
|
|
373
357
|
fact: deliverFact.entry,
|
|
374
|
-
...(assembled.reusedIntegration === undefined ? {} : { reusedIntegration: assembled.reusedIntegration }),
|
|
375
358
|
},
|
|
376
|
-
...(
|
|
359
|
+
...(previousContentId === undefined || previousContentId === preparation.data.integration.changeId
|
|
377
360
|
? {}
|
|
378
|
-
: {
|
|
379
|
-
contentChange: {
|
|
380
|
-
kind: "candidate-content-changed",
|
|
381
|
-
...(assembled.state?.coordinates.target === undefined
|
|
382
|
-
? {}
|
|
383
|
-
: { target: targetName(assembled.state.coordinates.target) }),
|
|
384
|
-
previousChange,
|
|
385
|
-
currentChange,
|
|
386
|
-
},
|
|
387
|
-
}),
|
|
361
|
+
: { previousContentId }),
|
|
388
362
|
},
|
|
389
363
|
};
|
|
390
364
|
}
|
|
@@ -410,21 +384,19 @@ function conflictDeliverRefusal(refusal) {
|
|
|
410
384
|
throw new Error("conflicted integration is missing conflict paths");
|
|
411
385
|
return {
|
|
412
386
|
kind: "integration-failed",
|
|
413
|
-
contractId: refusal.contractId,
|
|
414
387
|
reason: "conflict",
|
|
415
388
|
targetHead: refusal.targetHead,
|
|
416
389
|
conflictPaths: refusal.conflictPaths,
|
|
417
|
-
recovery: DELIVER_CONFLICT_RECOVERY,
|
|
418
390
|
};
|
|
419
391
|
}
|
|
420
392
|
async function appointedDeliverWorkspace(input) {
|
|
421
393
|
const observation = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
|
|
422
394
|
const state = contractState(observation.decision, input.contractId);
|
|
423
395
|
if (state === null)
|
|
424
|
-
return { kind: "refused", refusal: { kind: "worktree-missing"
|
|
396
|
+
return { kind: "refused", refusal: { kind: "worktree-missing" } };
|
|
425
397
|
const appointment = appointmentFor(await readPlaceRegister(input.scope), input.contractId);
|
|
426
398
|
if (appointment === undefined) {
|
|
427
|
-
return { kind: "refused", refusal: { kind: "worktree-missing"
|
|
399
|
+
return { kind: "refused", refusal: { kind: "worktree-missing" } };
|
|
428
400
|
}
|
|
429
401
|
return {
|
|
430
402
|
workspace: { kind: "worktree", path: worktreePath(input.scope, appointment.place) },
|
|
@@ -438,7 +410,7 @@ async function materializationMergeStateRefusal(input) {
|
|
|
438
410
|
return appointed.refusal;
|
|
439
411
|
const appointment = appointmentFor(await readPlaceRegister(input.scope), input.contractId);
|
|
440
412
|
if (appointment === undefined)
|
|
441
|
-
return { kind: "worktree-missing"
|
|
413
|
+
return { kind: "worktree-missing" };
|
|
442
414
|
const retirement = await retireConflictHandoff(input.scope, {
|
|
443
415
|
contractId: input.contractId,
|
|
444
416
|
place: appointment.place,
|
|
@@ -446,13 +418,13 @@ async function materializationMergeStateRefusal(input) {
|
|
|
446
418
|
consume: true,
|
|
447
419
|
});
|
|
448
420
|
if (retirement.kind === "retained")
|
|
449
|
-
return { kind: "merge-state-present",
|
|
421
|
+
return { kind: "merge-state-present", worktreePath: appointed.workspace.path };
|
|
450
422
|
return await mergeStatePresentRefusal(input, appointed.workspace);
|
|
451
423
|
}
|
|
452
424
|
async function mergeStatePresentRefusal(input, workspace) {
|
|
453
425
|
if (!(await workspaceMergeStatePresent(input.scope, workspace.path)))
|
|
454
426
|
return undefined;
|
|
455
|
-
return { kind: "merge-state-present",
|
|
427
|
+
return { kind: "merge-state-present", worktreePath: workspace.path };
|
|
456
428
|
}
|
|
457
429
|
async function materializeDeliverConflict(input, refusal) {
|
|
458
430
|
if (refusal.conflictPaths === undefined)
|
|
@@ -463,7 +435,7 @@ async function materializeDeliverConflict(input, refusal) {
|
|
|
463
435
|
const { workspace, coordinates } = appointed;
|
|
464
436
|
const appointment = appointmentFor(await readPlaceRegister(input.scope), input.contractId);
|
|
465
437
|
if (appointment === undefined)
|
|
466
|
-
return { kind: "refused", refusal: { kind: "worktree-missing"
|
|
438
|
+
return { kind: "refused", refusal: { kind: "worktree-missing" } };
|
|
467
439
|
const mergeState = await mergeStatePresentRefusal(input, workspace);
|
|
468
440
|
if (mergeState !== undefined)
|
|
469
441
|
return { kind: "refused", refusal: mergeState };
|
|
@@ -475,7 +447,7 @@ async function materializeDeliverConflict(input, refusal) {
|
|
|
475
447
|
if (tender.kind === "refused")
|
|
476
448
|
return tender;
|
|
477
449
|
if (tender.data.changes.submodules.length > 0 || (tender.data.dirty && input.includeDirty !== true)) {
|
|
478
|
-
return { kind: "refused", refusal:
|
|
450
|
+
return { kind: "refused", refusal: dirtyTenderRefusal(tender.data) };
|
|
479
451
|
}
|
|
480
452
|
let handoffHead = tender.data.head;
|
|
481
453
|
if (tender.data.dirty) {
|