@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,10 +1,175 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { contractIdSchema, snapshotIdSchema } from "../../git/identity.js";
|
|
3
|
+
import { gateSchema } from "../result-leaves.js";
|
|
1
4
|
import { observeActiveContractWorld, observeContractsForAdmissionInObservationAt, deliveryTargetObserver, withContractReadObservationAt, } from "../../git/observe.js";
|
|
2
5
|
import { decodeContractDocument } from "../../body/decode.js";
|
|
3
|
-
import { observeTargetLag, observeWorkspace,
|
|
6
|
+
import { observeTargetLag, observeWorkspace, worktreePath } from "../../git/workspace.js";
|
|
4
7
|
import { appointmentFor, readPlaceRegister } from "../../workspace-place.js";
|
|
5
8
|
import { gateReports } from "../../core/facts/gate.js";
|
|
6
9
|
import { verificationRequirement } from "../../verification/declaration.js";
|
|
7
10
|
import { projectBoundedList } from "../../bounded-list.js";
|
|
11
|
+
import { observeCurrentPhysicalIssue } from "./observation.js";
|
|
12
|
+
const phaseSchema = z.enum(["bound", "claimed", "abandoned"]);
|
|
13
|
+
const summaryGateSchema = z
|
|
14
|
+
.strictObject({
|
|
15
|
+
name: gateSchema,
|
|
16
|
+
verdict: z.enum(["missing", "stale", "satisfied", "unsatisfied"]),
|
|
17
|
+
})
|
|
18
|
+
.readonly();
|
|
19
|
+
export const contractSummaryAssociationSchema = z.union([
|
|
20
|
+
z.strictObject({ kind: z.literal("debt"), debtId: z.string().min(1) }).readonly(),
|
|
21
|
+
z
|
|
22
|
+
.strictObject({
|
|
23
|
+
kind: z.literal("akuma"),
|
|
24
|
+
akumaId: z.string().min(1),
|
|
25
|
+
aliases: z.array(z.string().min(1)).min(1).readonly().exactOptional(),
|
|
26
|
+
aliasesUnavailable: z.literal(true).exactOptional(),
|
|
27
|
+
})
|
|
28
|
+
.readonly(),
|
|
29
|
+
z
|
|
30
|
+
.strictObject({
|
|
31
|
+
kind: z.literal("unavailable"),
|
|
32
|
+
source: z.enum(["holder", "roster"]),
|
|
33
|
+
diagnostic: z.string(),
|
|
34
|
+
})
|
|
35
|
+
.readonly(),
|
|
36
|
+
]);
|
|
37
|
+
export const contractAttentionSchema = z.union([
|
|
38
|
+
z.strictObject({ kind: z.literal("workspace-unavailable"), path: z.string().min(1) }).readonly(),
|
|
39
|
+
z.strictObject({ kind: z.literal("workspace-unappointed") }).readonly(),
|
|
40
|
+
z.strictObject({ kind: z.literal("workspace-failed"), path: z.string().min(1), diagnostic: z.string() }).readonly(),
|
|
41
|
+
z
|
|
42
|
+
.strictObject({
|
|
43
|
+
kind: z.literal("merge-in-progress"),
|
|
44
|
+
path: z.string().min(1),
|
|
45
|
+
conflicts: z.number().int().positive().exactOptional(),
|
|
46
|
+
})
|
|
47
|
+
.readonly(),
|
|
48
|
+
z
|
|
49
|
+
.strictObject({
|
|
50
|
+
kind: z.literal("target-behind"),
|
|
51
|
+
behind: z.number().int().positive(),
|
|
52
|
+
subject: z.string().min(1).exactOptional(),
|
|
53
|
+
})
|
|
54
|
+
.readonly(),
|
|
55
|
+
z.strictObject({ kind: z.literal("target-unknown"), subject: z.string().min(1).exactOptional() }).readonly(),
|
|
56
|
+
]);
|
|
57
|
+
export const contractSummarySchema = z
|
|
58
|
+
.strictObject({
|
|
59
|
+
id: contractIdSchema,
|
|
60
|
+
title: z.string().min(1).exactOptional(),
|
|
61
|
+
phaseAt: z.string(),
|
|
62
|
+
delivered: z.literal(true).exactOptional(),
|
|
63
|
+
gates: z.array(summaryGateSchema).min(1).readonly().exactOptional(),
|
|
64
|
+
attention: z.array(contractAttentionSchema).min(1).readonly().exactOptional(),
|
|
65
|
+
})
|
|
66
|
+
.readonly();
|
|
67
|
+
export const contractCatalogueSchema = z
|
|
68
|
+
.strictObject({
|
|
69
|
+
observedAt: z.string(),
|
|
70
|
+
rows: z.array(contractSummarySchema).min(1).readonly().exactOptional(),
|
|
71
|
+
more: z.literal(true).exactOptional(),
|
|
72
|
+
})
|
|
73
|
+
.readonly();
|
|
74
|
+
const detailCurrentSchema = z.union([
|
|
75
|
+
z.strictObject({ kind: z.literal("missing") }).readonly(),
|
|
76
|
+
z.strictObject({ kind: z.literal("stale") }).readonly(),
|
|
77
|
+
z
|
|
78
|
+
.strictObject({
|
|
79
|
+
kind: z.literal("attested"),
|
|
80
|
+
verdict: z.enum(["satisfied", "unsatisfied"]),
|
|
81
|
+
summary: z.string().exactOptional(),
|
|
82
|
+
})
|
|
83
|
+
.readonly(),
|
|
84
|
+
]);
|
|
85
|
+
const rowRequirementSchema = z
|
|
86
|
+
.strictObject({
|
|
87
|
+
requirement: z.string().exactOptional(),
|
|
88
|
+
current: detailCurrentSchema,
|
|
89
|
+
index: z.number().int().positive().exactOptional(),
|
|
90
|
+
})
|
|
91
|
+
.readonly();
|
|
92
|
+
const rowGateSchema = z
|
|
93
|
+
.strictObject({
|
|
94
|
+
gate: z.string(),
|
|
95
|
+
requirements: z.array(rowRequirementSchema).readonly(),
|
|
96
|
+
})
|
|
97
|
+
.readonly();
|
|
98
|
+
const workspaceCountsSchema = z
|
|
99
|
+
.strictObject({
|
|
100
|
+
staged: z.number().int().positive().exactOptional(),
|
|
101
|
+
unstaged: z.number().int().positive().exactOptional(),
|
|
102
|
+
untracked: z.number().int().positive().exactOptional(),
|
|
103
|
+
submodules: z.number().int().positive().exactOptional(),
|
|
104
|
+
})
|
|
105
|
+
.readonly();
|
|
106
|
+
export const contractDetailWorkspaceSchema = z.union([
|
|
107
|
+
z
|
|
108
|
+
.strictObject({
|
|
109
|
+
kind: z.literal("present"),
|
|
110
|
+
path: z.string().min(1),
|
|
111
|
+
counts: workspaceCountsSchema.exactOptional(),
|
|
112
|
+
merge: z.array(z.string()).readonly().exactOptional(),
|
|
113
|
+
})
|
|
114
|
+
.readonly(),
|
|
115
|
+
z.strictObject({ kind: z.literal("unavailable"), path: z.string().min(1) }).readonly(),
|
|
116
|
+
z.strictObject({ kind: z.literal("unappointed") }).readonly(),
|
|
117
|
+
]);
|
|
118
|
+
export const contractDetailTargetLagSchema = z.union([
|
|
119
|
+
z
|
|
120
|
+
.strictObject({
|
|
121
|
+
kind: z.literal("counted"),
|
|
122
|
+
behind: z.number().int().positive().exactOptional(),
|
|
123
|
+
})
|
|
124
|
+
.readonly(),
|
|
125
|
+
z.strictObject({ kind: z.literal("unknown") }).readonly(),
|
|
126
|
+
]);
|
|
127
|
+
export const contractDetailTargetObservationSchema = z.union([
|
|
128
|
+
z.strictObject({ kind: z.literal("moved"), before: snapshotIdSchema, after: snapshotIdSchema }).readonly(),
|
|
129
|
+
z.strictObject({ kind: z.literal("unknown") }).readonly(),
|
|
130
|
+
]);
|
|
131
|
+
export const contractDetailSchema = z
|
|
132
|
+
.strictObject({
|
|
133
|
+
id: contractIdSchema,
|
|
134
|
+
title: z.string().min(1).exactOptional(),
|
|
135
|
+
phase: phaseSchema,
|
|
136
|
+
workspace: contractDetailWorkspaceSchema,
|
|
137
|
+
target: z.string().exactOptional(),
|
|
138
|
+
targetLag: contractDetailTargetLagSchema.exactOptional(),
|
|
139
|
+
delivery: z.strictObject({ candidate: snapshotIdSchema, integration: snapshotIdSchema }).readonly().exactOptional(),
|
|
140
|
+
targetObservation: contractDetailTargetObservationSchema.exactOptional(),
|
|
141
|
+
gates: z.array(rowGateSchema).min(1).readonly().exactOptional(),
|
|
142
|
+
after: z
|
|
143
|
+
.array(z.strictObject({ contractId: contractIdSchema, state: z.enum(["active", "abandoned", "missing"]) }).readonly())
|
|
144
|
+
.min(1)
|
|
145
|
+
.readonly()
|
|
146
|
+
.exactOptional(),
|
|
147
|
+
issue: z
|
|
148
|
+
.union([
|
|
149
|
+
z.strictObject({ kind: z.literal("target-checkout-retained") }).readonly(),
|
|
150
|
+
z.strictObject({ kind: z.literal("unavailable"), diagnostic: z.string() }).readonly(),
|
|
151
|
+
])
|
|
152
|
+
.exactOptional(),
|
|
153
|
+
abandonNote: z.string().exactOptional(),
|
|
154
|
+
})
|
|
155
|
+
.readonly();
|
|
156
|
+
const dependentSchema = z.strictObject({ contractId: contractIdSchema, phase: phaseSchema }).readonly();
|
|
157
|
+
export const contractBoardSchema = z
|
|
158
|
+
.strictObject({
|
|
159
|
+
rows: z
|
|
160
|
+
.array(contractDetailSchema
|
|
161
|
+
.unwrap()
|
|
162
|
+
.extend({
|
|
163
|
+
dependents: z.array(dependentSchema).min(1).readonly().exactOptional(),
|
|
164
|
+
})
|
|
165
|
+
.readonly())
|
|
166
|
+
.readonly(),
|
|
167
|
+
})
|
|
168
|
+
.readonly();
|
|
169
|
+
export const contractObservationSchema = z.union([
|
|
170
|
+
z.strictObject({ kind: z.literal("missing"), id: contractIdSchema }).readonly(),
|
|
171
|
+
z.strictObject({ kind: z.literal("present"), row: contractDetailSchema }).readonly(),
|
|
172
|
+
]);
|
|
8
173
|
function documentFor(state) {
|
|
9
174
|
try {
|
|
10
175
|
return decodeContractDocument(state.terms.document.bytes);
|
|
@@ -16,7 +181,8 @@ function documentFor(state) {
|
|
|
16
181
|
}
|
|
17
182
|
}
|
|
18
183
|
function titleFor(document) {
|
|
19
|
-
|
|
184
|
+
const title = document?.title;
|
|
185
|
+
return title === undefined || title.trim() === "" ? undefined : title;
|
|
20
186
|
}
|
|
21
187
|
function phaseFor(state) {
|
|
22
188
|
if (state.terminal?.kind === "claimed")
|
|
@@ -25,26 +191,94 @@ function phaseFor(state) {
|
|
|
25
191
|
return "abandoned";
|
|
26
192
|
return "bound";
|
|
27
193
|
}
|
|
28
|
-
|
|
194
|
+
function phaseAtFor(state, bindAt) {
|
|
29
195
|
return state.terminal?.at ?? state.delivery?.at ?? bindAt;
|
|
30
196
|
}
|
|
31
|
-
|
|
197
|
+
function lastJournalAtFor(entries) {
|
|
32
198
|
const last = entries.at(-1);
|
|
33
199
|
if (last === undefined)
|
|
34
200
|
throw new Error("present Contract journal is empty");
|
|
35
201
|
return last.at;
|
|
36
202
|
}
|
|
203
|
+
function summaryVerdict(current) {
|
|
204
|
+
if (current.kind === "missing")
|
|
205
|
+
return "missing";
|
|
206
|
+
if (current.kind === "stale")
|
|
207
|
+
return "stale";
|
|
208
|
+
return current.verdict;
|
|
209
|
+
}
|
|
210
|
+
function summaryFor({ state, bindAt }) {
|
|
211
|
+
const document = documentFor(state);
|
|
212
|
+
const title = titleFor(document);
|
|
213
|
+
const gates = gateReports(state).reports.map((report) => ({
|
|
214
|
+
name: report.gate,
|
|
215
|
+
verdict: summaryVerdict(report.current),
|
|
216
|
+
}));
|
|
217
|
+
return {
|
|
218
|
+
id: state.id,
|
|
219
|
+
...(title === undefined ? {} : { title }),
|
|
220
|
+
phaseAt: phaseAtFor(state, bindAt),
|
|
221
|
+
...(state.delivery === null ? {} : { delivered: true }),
|
|
222
|
+
...(gates.length === 0 ? {} : { gates }),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
37
225
|
function appointedWorkspace(repository, register, state) {
|
|
38
226
|
const appointed = appointmentFor(register, state.id);
|
|
39
227
|
return appointed === undefined
|
|
40
228
|
? undefined
|
|
41
229
|
: { contractId: state.id, place: appointed.place, workspace: worktreePath(repository, appointed.place) };
|
|
42
230
|
}
|
|
43
|
-
|
|
231
|
+
function detailCounts(counts) {
|
|
232
|
+
return {
|
|
233
|
+
...(counts.staged === 0 ? {} : { staged: counts.staged }),
|
|
234
|
+
...(counts.unstaged === 0 ? {} : { unstaged: counts.unstaged }),
|
|
235
|
+
...(counts.untracked === 0 ? {} : { untracked: counts.untracked }),
|
|
236
|
+
...(counts.submodules === 0 ? {} : { submodules: counts.submodules }),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function detailWorkspace(path, observed) {
|
|
240
|
+
switch (observed.kind) {
|
|
241
|
+
case "clean":
|
|
242
|
+
case "dirty": {
|
|
243
|
+
const counts = detailCounts(observed.counts);
|
|
244
|
+
return {
|
|
245
|
+
kind: "present",
|
|
246
|
+
path,
|
|
247
|
+
...(Object.keys(counts).length === 0 ? {} : { counts }),
|
|
248
|
+
...(observed.merge === null ? {} : { merge: observed.merge.unmergedPaths }),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
case "unavailable":
|
|
252
|
+
return { kind: "unavailable", path };
|
|
253
|
+
case "unappointed":
|
|
254
|
+
return { kind: "unappointed" };
|
|
255
|
+
case "failed":
|
|
256
|
+
throw new Error(observed.diagnostic);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function detailTargetLag(lag) {
|
|
260
|
+
if (lag.kind === "none")
|
|
261
|
+
return undefined;
|
|
262
|
+
return lag.kind === "counted"
|
|
263
|
+
? { kind: "counted", ...(lag.behind === 0 ? {} : { behind: lag.behind }) }
|
|
264
|
+
: { kind: "unknown" };
|
|
265
|
+
}
|
|
266
|
+
function detailTargetObservation(observed, state) {
|
|
267
|
+
if (observed === null)
|
|
268
|
+
return undefined;
|
|
269
|
+
if (observed.head === null)
|
|
270
|
+
return { kind: "unknown" };
|
|
271
|
+
const integration = state.currentIntegration;
|
|
272
|
+
const expected = state.terminal?.kind === "claimed" ? integration?.snapshot : integration?.predecessor;
|
|
273
|
+
return observed.drift && expected !== undefined
|
|
274
|
+
? { kind: "moved", before: expected, after: observed.head }
|
|
275
|
+
: undefined;
|
|
276
|
+
}
|
|
277
|
+
async function managedWorkspaceFacts(repository, state, appointed, targetObservation) {
|
|
44
278
|
if (appointed === undefined) {
|
|
45
279
|
return {
|
|
46
|
-
|
|
47
|
-
targetLag: state.coordinates.target === undefined ?
|
|
280
|
+
workspace: { kind: "unappointed" },
|
|
281
|
+
targetLag: state.coordinates.target === undefined ? undefined : { kind: "unknown" },
|
|
48
282
|
};
|
|
49
283
|
}
|
|
50
284
|
const path = appointed.workspace;
|
|
@@ -52,34 +286,49 @@ async function managedWorkspaceFacts(repository, state, appointed, targetObserva
|
|
|
52
286
|
observeWorkspace(repository, { kind: "worktree", path }, path),
|
|
53
287
|
observeTargetLag(repository, path, targetObservation?.head),
|
|
54
288
|
]);
|
|
55
|
-
|
|
56
|
-
(
|
|
57
|
-
|
|
58
|
-
? {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
289
|
+
return {
|
|
290
|
+
workspace: detailWorkspace(path, workspaceObservation),
|
|
291
|
+
targetLag: detailTargetLag(targetLag),
|
|
292
|
+
...(targetLag.kind === "none" || targetLag.subject === undefined ? {} : { lagSubject: targetLag.subject.path }),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function summaryAttention({ workspace, targetLag, lagSubject, }) {
|
|
296
|
+
const attention = [];
|
|
297
|
+
switch (workspace.kind) {
|
|
298
|
+
case "unavailable":
|
|
299
|
+
attention.push({ kind: "workspace-unavailable", path: workspace.path });
|
|
300
|
+
break;
|
|
301
|
+
case "unappointed":
|
|
302
|
+
attention.push({ kind: "workspace-unappointed" });
|
|
303
|
+
break;
|
|
304
|
+
case "present":
|
|
305
|
+
if (workspace.merge !== undefined) {
|
|
306
|
+
const conflicts = workspace.merge.length;
|
|
307
|
+
attention.push({ kind: "merge-in-progress", path: workspace.path, ...(conflicts === 0 ? {} : { conflicts }) });
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (targetLag?.kind === "unknown")
|
|
311
|
+
attention.push({ kind: "target-unknown", ...(lagSubject === undefined ? {} : { subject: lagSubject }) });
|
|
312
|
+
else if (targetLag?.behind !== undefined)
|
|
313
|
+
attention.push({
|
|
314
|
+
kind: "target-behind",
|
|
315
|
+
behind: targetLag.behind,
|
|
316
|
+
...(lagSubject === undefined ? {} : { subject: lagSubject }),
|
|
317
|
+
});
|
|
318
|
+
return attention;
|
|
68
319
|
}
|
|
69
320
|
function afterEndpoint(state) {
|
|
70
321
|
if (state === undefined || state === null)
|
|
71
|
-
return
|
|
322
|
+
return "missing";
|
|
72
323
|
if (state.terminal?.kind === "claimed")
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
return { kind: "abandoned" };
|
|
76
|
-
return { kind: "active", phase: phaseFor(state) };
|
|
324
|
+
return undefined;
|
|
325
|
+
return state.terminal?.kind === "abandoned" ? "abandoned" : "active";
|
|
77
326
|
}
|
|
78
327
|
function afterEdges(state, endpoints) {
|
|
79
|
-
return state.terms.after.
|
|
80
|
-
contractId
|
|
81
|
-
endpoint:
|
|
82
|
-
})
|
|
328
|
+
return state.terms.after.flatMap((contractId) => {
|
|
329
|
+
const endpoint = afterEndpoint(endpoints.get(contractId));
|
|
330
|
+
return endpoint === undefined ? [] : [{ contractId, state: endpoint }];
|
|
331
|
+
});
|
|
83
332
|
}
|
|
84
333
|
function reverseDependents(id, states) {
|
|
85
334
|
return states
|
|
@@ -88,8 +337,7 @@ function reverseDependents(id, states) {
|
|
|
88
337
|
.sort((left, right) => left.contractId.localeCompare(right.contractId));
|
|
89
338
|
}
|
|
90
339
|
async function rowFor(input) {
|
|
91
|
-
const { repository, state,
|
|
92
|
-
const gates = gateReports(state);
|
|
340
|
+
const { repository, state, targetObservation: rawTargetObservation, workspace, after, dependents } = input;
|
|
93
341
|
const document = documentFor(state);
|
|
94
342
|
const indexes = new Map();
|
|
95
343
|
document?.verification.forEach((declaration, index) => {
|
|
@@ -97,39 +345,60 @@ async function rowFor(input) {
|
|
|
97
345
|
if (!indexes.has(requirement))
|
|
98
346
|
indexes.set(requirement, index + 1);
|
|
99
347
|
});
|
|
100
|
-
const facts = await managedWorkspaceFacts(repository, state, workspace,
|
|
101
|
-
|
|
348
|
+
const facts = await managedWorkspaceFacts(repository, state, workspace, rawTargetObservation);
|
|
349
|
+
const gates = gateReports(state).reports.map((report) => ({
|
|
350
|
+
gate: report.gate,
|
|
351
|
+
requirements: report.requirements.map((requirement) => {
|
|
352
|
+
const index = report.gate === "verified" ? indexes.get(requirement.requirement) : undefined;
|
|
353
|
+
const current = requirement.current;
|
|
354
|
+
return {
|
|
355
|
+
...(index !== undefined
|
|
356
|
+
? { index }
|
|
357
|
+
: requirement.requirement === `gate:${report.gate}`
|
|
358
|
+
? {}
|
|
359
|
+
: { requirement: requirement.requirement }),
|
|
360
|
+
current: current.kind === "attested"
|
|
361
|
+
? {
|
|
362
|
+
kind: "attested",
|
|
363
|
+
verdict: current.verdict,
|
|
364
|
+
...(current.summary === undefined ? {} : { summary: current.summary }),
|
|
365
|
+
}
|
|
366
|
+
: { kind: current.kind },
|
|
367
|
+
};
|
|
368
|
+
}),
|
|
369
|
+
}));
|
|
370
|
+
const title = titleFor(document);
|
|
371
|
+
const targetObservation = detailTargetObservation(rawTargetObservation, state);
|
|
372
|
+
const row = {
|
|
102
373
|
id: state.id,
|
|
103
|
-
title:
|
|
374
|
+
...(title === undefined ? {} : { title }),
|
|
104
375
|
phase: phaseFor(state),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
376
|
+
workspace: facts.workspace,
|
|
377
|
+
...(state.coordinates.target === undefined
|
|
378
|
+
? {}
|
|
379
|
+
: {
|
|
380
|
+
target: typeof state.coordinates.target === "string"
|
|
381
|
+
? state.coordinates.target
|
|
382
|
+
: state.coordinates.target.contractId,
|
|
383
|
+
}),
|
|
384
|
+
...(facts.targetLag === undefined ? {} : { targetLag: facts.targetLag }),
|
|
385
|
+
...(state.delivery === null
|
|
386
|
+
? {}
|
|
387
|
+
: {
|
|
388
|
+
delivery: {
|
|
389
|
+
candidate: state.delivery.data.tenderSnapshot,
|
|
390
|
+
integration: (state.currentIntegration ?? state.delivery.data.integration).snapshot,
|
|
391
|
+
},
|
|
392
|
+
}),
|
|
393
|
+
...(targetObservation === undefined ? {} : { targetObservation }),
|
|
394
|
+
...(gates.length === 0 ? {} : { gates }),
|
|
395
|
+
...(after.length === 0 ? {} : { after }),
|
|
396
|
+
...(dependents.length === 0 ? {} : { dependents }),
|
|
116
397
|
...(state.terminal?.kind === "abandoned" && state.terminal.data.note !== undefined
|
|
117
398
|
? { abandonNote: state.terminal.data.note }
|
|
118
399
|
: {}),
|
|
119
|
-
targetObservation,
|
|
120
|
-
gates: {
|
|
121
|
-
reports: gates.reports.map((report) => ({
|
|
122
|
-
...report,
|
|
123
|
-
requirements: report.requirements.map((requirement) => {
|
|
124
|
-
const index = report.gate === "verified" ? indexes.get(requirement.requirement) : undefined;
|
|
125
|
-
return { ...requirement, ...(index === undefined ? {} : { index }) };
|
|
126
|
-
}),
|
|
127
|
-
})),
|
|
128
|
-
satisfied: gates.satisfied,
|
|
129
|
-
},
|
|
130
|
-
after,
|
|
131
|
-
dependents,
|
|
132
400
|
};
|
|
401
|
+
return input.physicalIssue ? await selectedDetailWithIssue(repository, state, row, rawTargetObservation) : row;
|
|
133
402
|
}
|
|
134
403
|
async function afterEndpointMap(observation, known, ids) {
|
|
135
404
|
const missing = ids.filter((id) => !known.has(id));
|
|
@@ -138,29 +407,26 @@ async function afterEndpointMap(observation, known, ids) {
|
|
|
138
407
|
const extra = await observeContractsForAdmissionInObservationAt(observation, missing);
|
|
139
408
|
return new Map([...known, ...[...extra.journals].map(([id, record]) => [id, record.state])]);
|
|
140
409
|
}
|
|
141
|
-
async function hydrateRows(observation, states, endpoints, dependentStates = []) {
|
|
410
|
+
async function hydrateRows(observation, states, endpoints, dependentStates = [], physicalIssue = false) {
|
|
142
411
|
const register = await readPlaceRegister(observation.repository);
|
|
143
412
|
const selected = states.map((value) => ({
|
|
144
413
|
...value,
|
|
145
414
|
workspace: appointedWorkspace(observation.repository, register, value.state),
|
|
146
415
|
}));
|
|
147
|
-
const handoffs = await readConflictHandoffs(observation.repository, observation.readBlobs, selected.flatMap(({ workspace }) => (workspace === undefined ? [] : [workspace])));
|
|
148
416
|
const observeTarget = deliveryTargetObserver(observation);
|
|
149
|
-
return await Promise.all(selected.map(async ({ state, bindAt,
|
|
417
|
+
return await Promise.all(selected.map(async ({ state, bindAt, workspace }) => await rowFor({
|
|
150
418
|
repository: observation.repository,
|
|
151
419
|
state,
|
|
152
420
|
bindAt,
|
|
153
|
-
lastJournalAt,
|
|
154
421
|
targetObservation: await observeTarget(state),
|
|
155
422
|
workspace,
|
|
156
|
-
handoff: handoffs.get(state.id),
|
|
157
423
|
after: afterEdges(state, endpoints),
|
|
158
424
|
dependents: reverseDependents(state.id, dependentStates),
|
|
425
|
+
physicalIssue,
|
|
159
426
|
})));
|
|
160
427
|
}
|
|
161
428
|
/** Build the complete board by default; a selected detail read retains complete dependency evidence. */
|
|
162
429
|
export async function readContractBoard(observation, include, detail = "board") {
|
|
163
|
-
const observedAt = new Date().toISOString();
|
|
164
430
|
const observed = await observeActiveContractWorld(observation);
|
|
165
431
|
const contracts = new Map(observed.contracts);
|
|
166
432
|
let endpoints = new Map(observed.eligibility);
|
|
@@ -178,12 +444,7 @@ export async function readContractBoard(observation, include, detail = "board")
|
|
|
178
444
|
const states = selectedContractStates(contracts);
|
|
179
445
|
const selected = detail === "selected" ? states.filter(({ state }) => state.id === include) : states;
|
|
180
446
|
const rows = await hydrateRows(observation, selected, endpoints, states);
|
|
181
|
-
return {
|
|
182
|
-
root: observation.repository.primaryWorktree,
|
|
183
|
-
state: observed.snapshot,
|
|
184
|
-
observedAt,
|
|
185
|
-
rows,
|
|
186
|
-
};
|
|
447
|
+
return { rows };
|
|
187
448
|
}
|
|
188
449
|
function compareRecentContracts(left, right) {
|
|
189
450
|
return (right.lastJournalAt.localeCompare(left.lastJournalAt) ||
|
|
@@ -200,21 +461,28 @@ function selectedContractStates(contracts) {
|
|
|
200
461
|
},
|
|
201
462
|
]);
|
|
202
463
|
}
|
|
203
|
-
/**
|
|
464
|
+
/**
|
|
465
|
+
* Observe a bounded recent active Contract catalogue, or its complete active set
|
|
466
|
+
* when no bound is selected, from one immutable Git observation.
|
|
467
|
+
*/
|
|
204
468
|
export async function readContractCatalogue(observation, limit) {
|
|
205
469
|
const observedAt = new Date().toISOString();
|
|
206
470
|
const observed = await observeActiveContractWorld(observation);
|
|
207
|
-
const active = selectedContractStates(observed.contracts)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
const
|
|
471
|
+
const active = selectedContractStates(observed.contracts)
|
|
472
|
+
.filter(({ state }) => state.terminal === null)
|
|
473
|
+
.sort(compareRecentContracts);
|
|
474
|
+
const selected = limit === undefined ? { rows: active, hasMore: false } : projectBoundedList(active, limit);
|
|
475
|
+
const register = await readPlaceRegister(observation.repository);
|
|
476
|
+
const observeTarget = deliveryTargetObserver(observation);
|
|
477
|
+
const rows = await Promise.all(selected.rows.map(async (selected) => {
|
|
478
|
+
const { state } = selected;
|
|
479
|
+
const attention = summaryAttention(await managedWorkspaceFacts(observation.repository, state, appointedWorkspace(observation.repository, register, state), await observeTarget(state)));
|
|
480
|
+
return { ...summaryFor(selected), ...(attention.length === 0 ? {} : { attention }) };
|
|
481
|
+
}));
|
|
212
482
|
return {
|
|
213
|
-
root: observation.repository.primaryWorktree,
|
|
214
|
-
state: observed.snapshot,
|
|
215
483
|
observedAt,
|
|
216
|
-
rows,
|
|
217
|
-
hasMore:
|
|
484
|
+
...(rows.length === 0 ? {} : { rows }),
|
|
485
|
+
...(selected.hasMore ? { more: true } : {}),
|
|
218
486
|
};
|
|
219
487
|
}
|
|
220
488
|
/**
|
|
@@ -238,11 +506,30 @@ export async function readContractObservation(observation, id) {
|
|
|
238
506
|
if (state === null)
|
|
239
507
|
return { kind: "missing", id };
|
|
240
508
|
const endpoints = await afterEndpointMap(observation, new Map([[id, state]]), state.terms.after);
|
|
241
|
-
const rows = await hydrateRows(observation, selectedContractStates(observed.journals), endpoints);
|
|
242
|
-
return {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
509
|
+
const rows = await hydrateRows(observation, selectedContractStates(observed.journals), endpoints, [], true);
|
|
510
|
+
return { kind: "present", row: rows[0] };
|
|
511
|
+
}
|
|
512
|
+
/** The exact selected read carries its physical issue; only that physical read can turn unavailable. */
|
|
513
|
+
async function selectedDetailWithIssue(repository, state, row, targetObservation) {
|
|
514
|
+
const delivery = state.delivery;
|
|
515
|
+
if (delivery === null)
|
|
516
|
+
return row;
|
|
517
|
+
const integration = state.currentIntegration ?? delivery.data.integration;
|
|
518
|
+
try {
|
|
519
|
+
const issue = await observeCurrentPhysicalIssue(repository, {
|
|
520
|
+
phase: row.phase,
|
|
521
|
+
target: state.coordinates.target,
|
|
522
|
+
delivery: row.delivery,
|
|
523
|
+
observedHead: targetObservation?.head ?? null,
|
|
524
|
+
}, integration.predecessor);
|
|
525
|
+
return issue === undefined ? row : { ...row, issue };
|
|
526
|
+
}
|
|
527
|
+
catch (error) {
|
|
528
|
+
return {
|
|
529
|
+
...row,
|
|
530
|
+
issue: { kind: "unavailable", diagnostic: error instanceof Error ? error.message : String(error) },
|
|
531
|
+
};
|
|
532
|
+
}
|
|
246
533
|
}
|
|
247
534
|
/** Observe one Contract and its target from one fresh ref epoch. */
|
|
248
535
|
export async function readContractObservationAt(repository, channel, id) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReconcileResult } from "../git/reconcile.js";
|
|
2
|
+
import type { ProtocolProgress } from "./progress.js";
|
|
2
3
|
import type { ContractId, ContractState } from "../core/facts/types.js";
|
|
3
4
|
import type { WorktreeHooks } from "../git/hooks.js";
|
|
4
5
|
import type { GitDecodeChannel } from "../git/read-observation.js";
|
|
@@ -32,5 +33,6 @@ export declare function reconcileAllOperation(input: Readonly<{
|
|
|
32
33
|
scope: RepositoryScope;
|
|
33
34
|
channel: GitDecodeChannel;
|
|
34
35
|
states: readonly ContractState[];
|
|
36
|
+
progress?: ProtocolProgress;
|
|
35
37
|
}> & ReconcileOptions): Promise<RepoReconcileReport>;
|
|
36
38
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reconcile,
|
|
1
|
+
import { reconcile, reconcileObservationFailure } from "../git/reconcile.js";
|
|
2
2
|
import { observeContractWorld } from "../git/observe.js";
|
|
3
3
|
import { withGitReadObservation } from "../git/read-observation.js";
|
|
4
4
|
import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
@@ -30,15 +30,16 @@ export async function worldContractStates(input) {
|
|
|
30
30
|
return [...observation.contracts.values()].flatMap((value) => (value.state === null ? [] : [value.state]));
|
|
31
31
|
}
|
|
32
32
|
export async function reconcileAllOperation(input) {
|
|
33
|
-
const contracts =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
const contracts = [];
|
|
34
|
+
for (const state of input.states) {
|
|
35
|
+
const place = input.places?.get(state.id);
|
|
36
|
+
const observed = await reconcileOperation({
|
|
37
|
+
...input,
|
|
38
|
+
contractId: state.id,
|
|
39
|
+
retainTerminalWorktree: input.retainTerminalWorktree ?? false,
|
|
40
|
+
...(place === undefined ? {} : { place }),
|
|
41
|
+
});
|
|
42
|
+
contracts.push({ contractId: state.id, ...observed });
|
|
43
|
+
}
|
|
43
44
|
return { contracts };
|
|
44
45
|
}
|
|
@@ -10,7 +10,6 @@ import { type ProtocolTerminal } from "./run.js";
|
|
|
10
10
|
import { type PlacementExecutionFailure } from "./placement.js";
|
|
11
11
|
type TargetMissing = Readonly<{
|
|
12
12
|
kind: "target-missing";
|
|
13
|
-
contractId: ContractId;
|
|
14
13
|
}>;
|
|
15
14
|
type ReintegrationRefusal = ReintegrateRefusal | TargetMissing | IntegrationPreparationRefusal | TargetWorkspaceRefusal;
|
|
16
15
|
export type ReintegrationResult = (AcceptedAdmission & Readonly<{
|
|
@@ -17,7 +17,7 @@ async function prepareExternalReintegration(input) {
|
|
|
17
17
|
async function planReintegrationArtifacts(input, state, recordedIntegrations) {
|
|
18
18
|
if (state.delivery === null || state.currentIntegration === null)
|
|
19
19
|
return { kind: "defer" };
|
|
20
|
-
const planned = await planIntegration(input.repository, {
|
|
20
|
+
const planned = await planIntegration(input.repository, { coordinates: state.coordinates }, await persistedTender(input.repository, state.delivery.data.tenderSnapshot), state.delivery.data.policy.requireBranchesToBeUpToDate);
|
|
21
21
|
if (planned.kind === "refused")
|
|
22
22
|
return { kind: "refused", refusal: planned.refusal };
|
|
23
23
|
const snapshot = (await reusableIntegrationSnapshot(input.repository, planned.data.tree, planned.data.predecessor, recordedIntegrations)) ??
|
|
@@ -33,7 +33,7 @@ function assembleReintegrationAttempt(input, observation, external) {
|
|
|
33
33
|
const state = contractState(observation.decision, input.contractId);
|
|
34
34
|
if (state === null) {
|
|
35
35
|
return external.kind === "unavailable"
|
|
36
|
-
? { kind: "unavailable", refusal: { kind: "contract-missing"
|
|
36
|
+
? { kind: "unavailable", refusal: { kind: "contract-missing" } }
|
|
37
37
|
: STALE_PRIVATE_STATE_PREPARATION;
|
|
38
38
|
}
|
|
39
39
|
if (external.kind === "unavailable")
|
|
@@ -41,7 +41,7 @@ function assembleReintegrationAttempt(input, observation, external) {
|
|
|
41
41
|
if (external.witness.head !== state.head)
|
|
42
42
|
return STALE_PRIVATE_STATE_PREPARATION;
|
|
43
43
|
if (state.delivery === null || state.currentIntegration === null) {
|
|
44
|
-
return { kind: "unavailable", refusal: { kind: "delivery-missing"
|
|
44
|
+
return { kind: "unavailable", refusal: { kind: "delivery-missing" } };
|
|
45
45
|
}
|
|
46
46
|
return external.artifacts.kind === "defer" ? STALE_PRIVATE_STATE_PREPARATION : external.artifacts;
|
|
47
47
|
}
|
|
@@ -57,7 +57,7 @@ async function runReintegration(input) {
|
|
|
57
57
|
return assembled;
|
|
58
58
|
const state = contractState(observation.decision, input.contractId);
|
|
59
59
|
if (state !== null) {
|
|
60
|
-
const refusal = targetContractRefusal(observation.decision, state.
|
|
60
|
+
const refusal = targetContractRefusal(observation.decision, state.coordinates.target);
|
|
61
61
|
if (refusal !== undefined)
|
|
62
62
|
return { kind: "refused", refusal };
|
|
63
63
|
}
|