@astrosheep/keiyaku 4.6.7 → 4.6.9
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 +46 -16
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/opencode/index.js +1 -1
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/pi/keiyaku.ts +0 -5
- package/build/skills/keiyaku/SKILL.md +5 -6
- package/build/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/src/akuma/akuma-call.d.ts +2 -0
- package/build/src/akuma/akuma-call.js +8 -2
- package/build/src/akuma/akuma-instance.d.ts +14 -1
- package/build/src/akuma/akuma-instance.js +37 -7
- package/build/src/akuma/akuma-observe.d.ts +33 -8
- package/build/src/akuma/akuma-observe.js +89 -63
- package/build/src/akuma/akuma-owner.d.ts +14 -2
- package/build/src/akuma/akuma-owner.js +49 -35
- package/build/src/akuma/akuma-selection-execution.js +9 -1
- package/build/src/akuma/akuma-stream.d.ts +22 -0
- package/build/src/akuma/akuma-stream.js +116 -0
- package/build/src/akuma/akuma-wait.d.ts +1 -40
- package/build/src/akuma/akuma-wait.js +23 -84
- package/build/src/akuma/akuma.d.ts +52 -16
- package/build/src/akuma/akuma.js +10 -10
- package/build/src/akuma/allowed.d.ts +7 -12
- package/build/src/akuma/allowed.js +13 -4
- package/build/src/akuma/archetype.d.ts +7 -15
- package/build/src/akuma/archetype.js +36 -35
- package/build/src/akuma/body-supervisor.d.ts +5 -5
- package/build/src/akuma/body-supervisor.js +22 -20
- package/build/src/akuma/body.d.ts +5 -3
- package/build/src/akuma/body.js +57 -8
- package/build/src/akuma/call-request.d.ts +30 -32
- package/build/src/akuma/call-request.js +10 -3
- package/build/src/akuma/caller.d.ts +39 -0
- package/build/src/akuma/caller.js +36 -0
- package/build/src/akuma/dispatch-association.d.ts +0 -1
- package/build/src/akuma/dispatch-association.js +0 -3
- package/build/src/akuma/heart/activity-schema.d.ts +12 -0
- package/build/src/akuma/heart/activity-schema.js +6 -0
- package/build/src/akuma/heart/facts.d.ts +16 -12
- package/build/src/akuma/heart/facts.js +8 -0
- package/build/src/akuma/heart/index.d.ts +61 -9
- package/build/src/akuma/heart/index.js +89 -24
- package/build/src/akuma/heart/rows.d.ts +3 -3
- package/build/src/akuma/heart/rows.js +5 -3
- package/build/src/akuma/heart/soul.d.ts +10 -1
- package/build/src/akuma/heart/soul.js +34 -24
- package/build/src/akuma/heart/storage.d.ts +20 -0
- package/build/src/akuma/heart/storage.js +62 -3
- package/build/src/akuma/heart/timeline.d.ts +7 -0
- package/build/src/akuma/heart/timeline.js +10 -0
- package/build/src/akuma/identity.d.ts +0 -1
- package/build/src/akuma/identity.js +2 -5
- package/build/src/akuma/index.d.ts +6 -2
- package/build/src/akuma/index.js +1 -0
- package/build/src/akuma/nuke.js +6 -28
- package/build/src/akuma/projection.d.ts +25 -11
- package/build/src/akuma/projection.js +24 -7
- package/build/src/akuma/provider-recipe.d.ts +18 -6
- package/build/src/akuma/provider-recipe.js +24 -1
- package/build/src/akuma/provider.d.ts +31 -10
- package/build/src/akuma/provider.js +105 -14
- package/build/src/akuma/providers/acp/events.js +29 -19
- package/build/src/akuma/providers/acp/index.js +2 -3
- package/build/src/akuma/providers/claude/events.js +110 -69
- package/build/src/akuma/providers/claude/index.d.ts +2 -2
- package/build/src/akuma/providers/claude/index.js +4 -8
- package/build/src/akuma/providers/codex-app-server/events.js +17 -2
- package/build/src/akuma/providers/codex-app-server/index.js +17 -11
- package/build/src/akuma/providers/decode.d.ts +33 -0
- package/build/src/akuma/providers/decode.js +65 -0
- package/build/src/akuma/providers/execution-environment.d.ts +2 -1
- package/build/src/akuma/providers/execution-environment.js +3 -0
- package/build/src/akuma/providers/grok-build/index.js +16 -48
- package/build/src/akuma/providers/index.js +2 -0
- package/build/src/akuma/providers/lifecycle.d.ts +9 -0
- package/build/src/akuma/providers/lifecycle.js +10 -0
- package/build/src/akuma/providers/opencode-sdk/event-stream.d.ts +3 -3
- package/build/src/akuma/providers/opencode-sdk/event-stream.js +2 -25
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +7 -43
- package/build/src/akuma/providers/opencode-sdk/events.js +146 -296
- package/build/src/akuma/providers/opencode-sdk/index.js +270 -431
- package/build/src/akuma/providers/opencode-sdk/native-http.d.ts +9 -0
- package/build/src/akuma/providers/opencode-sdk/native-http.js +69 -0
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +42 -36
- package/build/src/akuma/providers/opencode-sdk/session.js +75 -84
- package/build/src/akuma/providers/paseo/events.d.ts +33 -0
- package/build/src/akuma/providers/paseo/events.js +204 -0
- package/build/src/akuma/providers/paseo/index.d.ts +9 -0
- package/build/src/akuma/providers/paseo/index.js +357 -0
- package/build/src/akuma/providers/pi/events.d.ts +2 -0
- package/build/src/akuma/providers/pi/events.js +36 -38
- package/build/src/akuma/providers/pi/index.js +21 -35
- package/build/src/akuma/publication.d.ts +2 -0
- package/build/src/akuma/publication.js +5 -0
- package/build/src/akuma/request-lifecycle.d.ts +4 -2
- package/build/src/akuma/request-lifecycle.js +27 -12
- package/build/src/akuma/request-rendezvous.js +38 -55
- package/build/src/akuma/request-serve.d.ts +1 -1
- package/build/src/akuma/request-serve.js +77 -113
- package/build/src/akuma/requests.d.ts +3 -1
- package/build/src/akuma/requests.js +32 -0
- package/build/src/akuma/selection-observation.d.ts +129 -53
- package/build/src/akuma/selection-observation.js +3 -9
- package/build/src/akuma/turn-drive.d.ts +3 -0
- package/build/src/akuma/turn-drive.js +28 -10
- package/build/src/akuma-body.js +12 -22
- package/build/src/cli/akuma-caller.d.ts +3 -0
- package/build/src/cli/akuma-caller.js +31 -0
- package/build/src/cli/commands/akuma-grammar.js +10 -16
- package/build/src/cli/commands/akuma.js +25 -55
- package/build/src/cli/commands/contract-grammar.d.ts +9 -7
- package/build/src/cli/commands/contract-grammar.js +40 -47
- package/build/src/cli/commands/contract-help.d.ts +17 -7
- package/build/src/cli/commands/contract-help.js +50 -11
- package/build/src/cli/commands/contract.js +34 -63
- package/build/src/cli/commands/debt-grammar.d.ts +19 -0
- package/build/src/cli/commands/debt-grammar.js +323 -0
- package/build/src/cli/commands/debt-query.d.ts +5 -0
- package/build/src/cli/commands/{task-query.js → debt-query.js} +9 -9
- package/build/src/cli/commands/{task.d.ts → debt.d.ts} +2 -2
- package/build/src/cli/commands/{task.js → debt.js} +87 -164
- package/build/src/cli/coordinates.d.ts +1 -1
- package/build/src/cli/coordinates.js +1 -1
- package/build/src/cli/parse.d.ts +5 -5
- package/build/src/cli/parse.js +17 -16
- package/build/src/cli/render/akuma-activity.d.ts +11 -83
- package/build/src/cli/render/akuma-activity.js +20 -382
- package/build/src/cli/render/catalog.d.ts +4 -7
- package/build/src/cli/render/catalog.js +5 -5
- package/build/src/cli/render/contract-history.js +3 -6
- package/build/src/cli/render/contract.js +17 -52
- package/build/src/cli/render/debt.d.ts +28 -0
- package/build/src/cli/render/{task.js → debt.js} +55 -133
- package/build/src/cli/render/kanshi.js +28 -28
- package/build/src/cli/render/marks.d.ts +5 -5
- package/build/src/cli/render/marks.js +4 -10
- package/build/src/cli/render/nuke.js +1 -1
- package/build/src/cli/render/receipt.js +3 -10
- package/build/src/cli/runtime.d.ts +1 -1
- package/build/src/cli/runtime.js +14 -20
- package/build/src/cli/scan.d.ts +1 -1
- package/build/src/cli/selectors.d.ts +3 -6
- package/build/src/cli/selectors.js +22 -53
- package/build/src/cli/usage.d.ts +1 -1
- package/build/src/cli/usage.js +4 -4
- package/build/src/contract-worktree.js +3 -3
- package/build/src/debt/board.d.ts +160 -0
- package/build/src/{task → debt}/board.js +89 -89
- package/build/src/debt/catalog.d.ts +11 -0
- package/build/src/debt/catalog.js +59 -0
- package/build/src/{task → debt}/context.d.ts +1 -1
- package/build/src/{task → debt}/context.js +1 -1
- package/build/src/{task → debt}/created-observation.d.ts +6 -10
- package/build/src/{task → debt}/created-observation.js +7 -7
- package/build/src/debt/document.d.ts +37 -0
- package/build/src/{task → debt}/document.js +37 -37
- package/build/src/debt/identity.d.ts +21 -0
- package/build/src/{task → debt}/identity.js +35 -35
- package/build/src/debt/index.d.ts +111 -0
- package/build/src/debt/index.js +203 -0
- package/build/src/{task → debt}/input.d.ts +8 -8
- package/build/src/{task → debt}/input.js +21 -21
- package/build/src/debt/lifecycle-operations.d.ts +6 -0
- package/build/src/{task → debt}/lifecycle-operations.js +27 -31
- package/build/src/debt/mutation-result.d.ts +981 -0
- package/build/src/debt/mutation-result.js +109 -0
- package/build/src/debt/mutation.d.ts +424 -0
- package/build/src/debt/mutation.js +223 -0
- package/build/src/debt/operation-types.d.ts +71 -0
- package/build/src/debt/operations.d.ts +28 -0
- package/build/src/{task → debt}/operations.js +59 -60
- package/build/src/debt/query.d.ts +76 -0
- package/build/src/{task → debt}/query.js +55 -55
- package/build/src/{task → debt}/store.d.ts +13 -13
- package/build/src/{task → debt}/store.js +58 -49
- package/build/src/debt/view.d.ts +4 -0
- package/build/src/debt/view.js +7 -0
- package/build/src/dispatch/index.d.ts +3 -3
- package/build/src/dispatch/index.js +1 -2
- package/build/src/git/observe.d.ts +6 -2
- package/build/src/git/observe.js +6 -2
- package/build/src/identity/coordinates.d.ts +1 -1
- package/build/src/index.d.ts +17 -17
- package/build/src/index.js +11 -11
- package/build/src/kanshi/index.d.ts +2 -2
- package/build/src/kanshi/read.js +54 -39
- package/build/src/kanshi/report.d.ts +7 -7
- package/build/src/kanshi/select.js +4 -4
- package/build/src/library/address.js +2 -4
- package/build/src/library/akuma-creation.d.ts +5 -1
- package/build/src/library/akuma-creation.js +27 -47
- package/build/src/library/akumas.d.ts +7 -7
- package/build/src/library/akumas.js +13 -9
- package/build/src/library/bind.d.ts +17 -17
- package/build/src/library/bind.js +16 -12
- package/build/src/library/contract-address.d.ts +9 -0
- package/build/src/library/contract-address.js +71 -0
- package/build/src/library/contract-composition.d.ts +4 -7
- package/build/src/library/contract-composition.js +6 -18
- package/build/src/library/contract-creation.d.ts +3 -5
- package/build/src/library/contract-creation.js +24 -22
- package/build/src/library/contract-execution.js +21 -26
- package/build/src/library/contract-outcomes.d.ts +2 -14
- package/build/src/library/contract-outcomes.js +2 -13
- package/build/src/library/contract-types.d.ts +38 -4
- package/build/src/library/delivery.d.ts +0 -2
- package/build/src/library/delivery.js +2 -5
- package/build/src/library/input.d.ts +2 -2
- package/build/src/library/input.js +5 -5
- package/build/src/library/invocation.js +2 -2
- package/build/src/library/keiyaku.d.ts +0 -5
- package/build/src/library/keiyaku.js +6 -12
- package/build/src/library/nuke.js +3 -3
- package/build/src/library/outcome.d.ts +626 -625
- package/build/src/library/outcome.js +13 -3
- package/build/src/library/reconcile.js +8 -16
- package/build/src/library/refusal.d.ts +2 -2
- package/build/src/library/repo.d.ts +3 -2
- package/build/src/library/repo.js +10 -5
- package/build/src/library/selection.d.ts +5 -8
- package/build/src/library/selection.js +22 -73
- package/build/src/plugin/akuma-signals.d.ts +2 -0
- package/build/src/plugin/akuma-signals.js +4 -0
- package/build/src/plugin/public.d.ts +32 -2
- package/build/src/plugin/runtime.js +5 -3
- package/build/src/protocol/amend.js +3 -2
- package/build/src/protocol/attempt.js +3 -8
- package/build/src/protocol/bind.d.ts +2 -2
- package/build/src/protocol/bind.js +1 -1
- package/build/src/protocol/deliver.js +3 -3
- package/build/src/protocol/operations.d.ts +1 -3
- package/build/src/protocol/operations.js +0 -8
- package/build/src/protocol/outcome.d.ts +1 -2
- package/build/src/protocol/outcome.js +1 -13
- package/build/src/protocol/placement.js +3 -10
- package/build/src/protocol/read/status.js +31 -70
- package/build/src/protocol/reintegrate.js +3 -10
- package/build/src/protocol/review.js +3 -3
- package/build/src/protocol/run.d.ts +5 -1
- package/build/src/protocol/run.js +3 -3
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/fence.d.ts +3 -3
- package/build/src/settlement/fence.js +4 -4
- package/build/src/settlement/holder.d.ts +16 -16
- package/build/src/settlement/holder.js +69 -63
- package/build/src/settlement/settle.d.ts +5 -5
- package/build/src/settlement/settle.js +53 -53
- package/package.json +19 -9
- package/plugins/paseo/plugin/index.server.ts +17 -0
- package/plugins/paseo/plugin/paseo-plugin.json +4 -0
- package/plugins/paseo/plugin/server/attach.ts +52 -0
- package/plugins/paseo/plugin/server/keiyaku.ts +44 -0
- package/plugins/paseo/plugin/server/message.ts +60 -0
- package/plugins/paseo/plugin/server/mirror.ts +193 -0
- package/plugins/paseo/plugin/server/model.ts +14 -0
- package/plugins/paseo/plugin/server/provider.ts +276 -0
- package/plugins/paseo/plugin/server/sdk-worker.ts +237 -0
- package/plugins/paseo/plugin/server/sdk.ts +289 -0
- package/plugins/paseo/plugin/server/stop.ts +26 -0
- package/plugins/paseo/plugin/server/transport.ts +35 -0
- package/plugins/paseo/plugin/shared/attach-rpc.ts +10 -0
- package/plugins/paseo/plugin/shared/refresh-rpc.ts +6 -0
- package/plugins/paseo/plugin/tsconfig.json +6 -0
- package/plugins/pi/keiyaku.ts +57 -0
- package/skills/keiyaku/SKILL.md +43 -0
- package/skills/keiyaku-akuma/SKILL.md +130 -0
- package/skills/keiyaku-akuma/references/automation.md +269 -0
- package/skills/keiyaku-babysit/SKILL.md +65 -0
- package/skills/keiyaku-bind/SKILL.md +216 -0
- package/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/skills/keiyaku-debt/SKILL.md +91 -0
- package/skills/keiyaku-workflow/SKILL.md +129 -0
- package/build/plugins/claude/skills/keiyaku-task/SKILL.md +0 -104
- package/build/plugins/codex/skills/keiyaku-task/SKILL.md +0 -104
- package/build/plugins/opencode/skills/keiyaku-task/SKILL.md +0 -104
- package/build/skills/keiyaku-task/SKILL.md +0 -104
- package/build/src/cli/commands/amend.d.ts +0 -12
- package/build/src/cli/commands/amend.js +0 -10
- package/build/src/cli/commands/bind.d.ts +0 -11
- package/build/src/cli/commands/bind.js +0 -23
- package/build/src/cli/commands/task-grammar.d.ts +0 -19
- package/build/src/cli/commands/task-grammar.js +0 -384
- package/build/src/cli/commands/task-query.d.ts +0 -5
- package/build/src/cli/render/task.d.ts +0 -41
- package/build/src/dispatch/association.d.ts +0 -1
- package/build/src/dispatch/association.js +0 -1
- package/build/src/task/board.d.ts +0 -168
- package/build/src/task/catalog.d.ts +0 -11
- package/build/src/task/catalog.js +0 -59
- package/build/src/task/compose-language.d.ts +0 -57
- package/build/src/task/compose-language.js +0 -364
- package/build/src/task/compose-parser.d.ts +0 -32
- package/build/src/task/compose-parser.js +0 -180
- package/build/src/task/compose.d.ts +0 -16
- package/build/src/task/compose.js +0 -189
- package/build/src/task/document.d.ts +0 -39
- package/build/src/task/identity.d.ts +0 -21
- package/build/src/task/index.d.ts +0 -138
- package/build/src/task/index.js +0 -269
- package/build/src/task/lifecycle-operations.d.ts +0 -6
- package/build/src/task/mutation-result.d.ts +0 -1726
- package/build/src/task/mutation-result.js +0 -198
- package/build/src/task/mutation.d.ts +0 -590
- package/build/src/task/mutation.js +0 -262
- package/build/src/task/operation-types.d.ts +0 -71
- package/build/src/task/operations.d.ts +0 -28
- package/build/src/task/query.d.ts +0 -76
- package/build/src/task/view.d.ts +0 -4
- package/build/src/task/view.js +0 -7
- /package/build/src/{task → debt}/operation-types.js +0 -0
|
@@ -7,26 +7,32 @@ import { withGitDecodeChannel } from "../git/read-observation.js";
|
|
|
7
7
|
import { executionStop, isOperationalFailure, isOperationalStop } from "../protocol/progress.js";
|
|
8
8
|
import { readManagedWorktreeAppointment } from "../workspace-place.js";
|
|
9
9
|
import { admitForkBindWithAppointment, prepareMarkdownBind } from "./bind.js";
|
|
10
|
-
import { acceptedOutcome,
|
|
10
|
+
import { acceptedOutcome, expected, retainAdmission } from "./contract-outcomes.js";
|
|
11
11
|
import { captureLocalContractComposition, derivedGates, derivedHooks, gateNames, } from "./contract-settings.js";
|
|
12
|
-
import { actorOption, normalizedList, requireInput, requireMarkdown,
|
|
12
|
+
import { actorOption, normalizedList, requireInput, requireMarkdown, debtOption } from "./input.js";
|
|
13
13
|
import { InvocationAccumulator } from "./invocation.js";
|
|
14
14
|
import { project, validated } from "./outcome.js";
|
|
15
15
|
import { reconcileAffectedContracts } from "./reconcile.js";
|
|
16
16
|
import { observeRegion } from "./region.js";
|
|
17
17
|
import { scopeForRepo } from "./repo.js";
|
|
18
|
+
/** The one place a caller's omitted target becomes product behavior. */
|
|
19
|
+
function bindTargetSelection(target) {
|
|
20
|
+
if (target === undefined)
|
|
21
|
+
return { kind: "current-branch" };
|
|
22
|
+
return target === null ? { kind: "targetless" } : { kind: "explicit", target };
|
|
23
|
+
}
|
|
18
24
|
function bindInput(input, composition) {
|
|
19
25
|
return validated(() => {
|
|
20
26
|
const values = requireInput(input, "Keiyaku.bind input");
|
|
21
27
|
const forkOf = values.forkOf;
|
|
22
28
|
const allowed = forkOf === undefined
|
|
23
|
-
? ["repo", "markdown", "
|
|
29
|
+
? ["repo", "markdown", "debt", "target", "workspace", "actor", "after", "gates"]
|
|
24
30
|
: ["repo", "forkOf", "target", "workspace", "actor"];
|
|
25
31
|
requireInput(input, "Keiyaku.bind input", allowed);
|
|
26
32
|
if ((values.workspace ?? "worktree") !== "worktree")
|
|
27
33
|
throw new TypeError("workspace must be worktree");
|
|
28
|
-
if (values.target !== undefined && typeof values.target !== "string")
|
|
29
|
-
throw new TypeError("target must be a string");
|
|
34
|
+
if (values.target !== undefined && values.target !== null && typeof values.target !== "string")
|
|
35
|
+
throw new TypeError("target must be a string or null");
|
|
30
36
|
const actor = actorOption(values.actor);
|
|
31
37
|
const document = forkOf === undefined ? parseMarkdown(requireMarkdown(values.markdown)) : undefined;
|
|
32
38
|
if (forkOf !== undefined) {
|
|
@@ -40,18 +46,17 @@ function bindInput(input, composition) {
|
|
|
40
46
|
document,
|
|
41
47
|
actor,
|
|
42
48
|
target: values.target,
|
|
43
|
-
|
|
49
|
+
debt: forkOf === undefined ? debtOption(values.debt) : undefined,
|
|
44
50
|
gates: derived,
|
|
45
51
|
after: forkOf === undefined ? normalizedList(values.after, "after", contractId) : undefined,
|
|
46
52
|
};
|
|
47
53
|
});
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
50
|
-
* One Contract bind.
|
|
51
|
-
*
|
|
52
|
-
* composition leaves it targetless, while the CLI names the invocation branch.
|
|
56
|
+
* One Contract bind. An omitted Markdown target names the current branch of the caller's explicit
|
|
57
|
+
* Repo worktree coordinate, `null` is deliberately targetless, and a string is that literal target.
|
|
53
58
|
*/
|
|
54
|
-
export async function bindKeiyaku(input, createHandle, execution = localExecutionContext(), composition = captureLocalContractComposition()
|
|
59
|
+
export async function bindKeiyaku(input, createHandle, execution = localExecutionContext(), composition = captureLocalContractComposition()) {
|
|
55
60
|
const prepared = bindInput(input, composition);
|
|
56
61
|
const hooks = derivedHooks(composition);
|
|
57
62
|
const { forkOf, scope, document, target, actor } = prepared;
|
|
@@ -84,7 +89,7 @@ export async function bindKeiyaku(input, createHandle, execution = localExecutio
|
|
|
84
89
|
}
|
|
85
90
|
if (document === undefined)
|
|
86
91
|
throw new Error("Markdown bind requires its prepared document");
|
|
87
|
-
return await markdownBind(prepared, document, hooks, scope, channel, accumulator, handle
|
|
92
|
+
return await markdownBind(prepared, document, hooks, scope, channel, accumulator, handle);
|
|
88
93
|
})();
|
|
89
94
|
return completed;
|
|
90
95
|
}, (error) => {
|
|
@@ -109,19 +114,16 @@ export async function bindKeiyaku(input, createHandle, execution = localExecutio
|
|
|
109
114
|
throw projected.error;
|
|
110
115
|
return projected.outcome;
|
|
111
116
|
}
|
|
112
|
-
function bindValue(keiyaku, region, warnings
|
|
113
|
-
|
|
117
|
+
function bindValue(keiyaku, region, warnings) {
|
|
118
|
+
return {
|
|
114
119
|
keiyaku,
|
|
115
|
-
...(workspace === undefined ? {} : { workspace }),
|
|
116
120
|
...(warnings.length === 0 ? {} : { warnings }),
|
|
117
121
|
...region,
|
|
118
122
|
};
|
|
119
|
-
void appointmentLag;
|
|
120
|
-
return base;
|
|
121
123
|
}
|
|
122
124
|
// eslint-disable-next-line max-params -- Keep this local operation's custody, admission, and policy witnesses explicit.
|
|
123
125
|
async function bindComplete(accumulator, id, scope, channel, leading, hooks, value) {
|
|
124
|
-
retainAdmission(accumulator, id, leading
|
|
126
|
+
retainAdmission(accumulator, id, leading);
|
|
125
127
|
await reconcileAffectedContracts(accumulator, id, scope, channel, hooks);
|
|
126
128
|
try {
|
|
127
129
|
const appointment = await readManagedWorktreeAppointment(scope, id);
|
|
@@ -136,15 +138,15 @@ async function bindComplete(accumulator, id, scope, channel, leading, hooks, val
|
|
|
136
138
|
accumulator.recordStop(executionStop(id, "reconciliation", error, scope.signal));
|
|
137
139
|
}
|
|
138
140
|
const built = { ...(await value()), ...accumulator.conclusions(id) };
|
|
139
|
-
accumulator.extendConclusions(id,
|
|
141
|
+
accumulator.extendConclusions(id, built);
|
|
140
142
|
return built;
|
|
141
143
|
}
|
|
142
144
|
// eslint-disable-next-line max-params -- Keep this local operation's custody, admission, and policy witnesses explicit.
|
|
143
|
-
async function markdownBind(prepared, document, hooks, scope, channel, accumulator, handle
|
|
144
|
-
const {
|
|
145
|
+
async function markdownBind(prepared, document, hooks, scope, channel, accumulator, handle) {
|
|
146
|
+
const { debt, target, actor, gates, after } = prepared;
|
|
145
147
|
if (gates === undefined || after === undefined)
|
|
146
148
|
throw new Error("Markdown bind requires prepared terms");
|
|
147
|
-
const targetSelection = target
|
|
149
|
+
const targetSelection = bindTargetSelection(target);
|
|
148
150
|
const admission = await prepareMarkdownBind({
|
|
149
151
|
scope,
|
|
150
152
|
channel,
|
|
@@ -154,7 +156,7 @@ async function markdownBind(prepared, document, hooks, scope, channel, accumulat
|
|
|
154
156
|
after,
|
|
155
157
|
workspace: "worktree",
|
|
156
158
|
targetSelection,
|
|
157
|
-
...(
|
|
159
|
+
...(debt === undefined ? {} : { debt }),
|
|
158
160
|
...actor,
|
|
159
161
|
});
|
|
160
162
|
const leading = admission.admission === null ? admission.result : admission.admission.result;
|
|
@@ -16,10 +16,10 @@ import { admitDeliveryOperation } from "../protocol/deliver.js";
|
|
|
16
16
|
import { withScopeAbortSignal, } from "../protocol/operations.js";
|
|
17
17
|
import { executionStop, isOperationalFailure, isOperationalStop, } from "../protocol/progress.js";
|
|
18
18
|
import { admitReviewOperation } from "../protocol/review.js";
|
|
19
|
-
import {
|
|
19
|
+
import { releaseDebtHolder, releaseDebtHolderWithFence, debtHolderObservationSelection } from "../settlement/holder.js";
|
|
20
20
|
import { continueDeliveredDependents } from "./continuation.js";
|
|
21
21
|
import { requestForwardedContractLive } from "./contract-operations.js";
|
|
22
|
-
import { acceptedOutcome,
|
|
22
|
+
import { acceptedOutcome, expected, retainAdmission } from "./contract-outcomes.js";
|
|
23
23
|
import { derivedContractPolicy, derivedGates, derivedHooks, gateNames, } from "./contract-settings.js";
|
|
24
24
|
import { deliveryForContract } from "./delivery.js";
|
|
25
25
|
import { actorOption, contractTerms, documentDerivation, normalizedList, optionalBoolean, optionalNonblank, optionalSignal, requireInput, requireMarkdown, } from "./input.js";
|
|
@@ -66,7 +66,7 @@ export class ContractExecution {
|
|
|
66
66
|
});
|
|
67
67
|
let changedSections;
|
|
68
68
|
return await this.local("amend", async (accumulator, channel, scope) => {
|
|
69
|
-
const admission =
|
|
69
|
+
const admission = await amendOperation({
|
|
70
70
|
scope,
|
|
71
71
|
channel,
|
|
72
72
|
contractId: this.id,
|
|
@@ -87,20 +87,18 @@ export class ContractExecution {
|
|
|
87
87
|
: contractTerms(amended, gates ?? source.gates, prerequisites ?? source.after);
|
|
88
88
|
return { terms, verification: documentDerivation(amended, terms.gates, this.id).verification };
|
|
89
89
|
},
|
|
90
|
-
})
|
|
90
|
+
});
|
|
91
91
|
if (admission.kind !== "accepted")
|
|
92
92
|
return expected(this.id, admission);
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const diff = documentDiff("before", "after", accepted.value.source.document.bytes, accepted.value.terms.document.bytes);
|
|
93
|
+
const changes = changedAmendTerms(admission.value.source, admission.value.terms);
|
|
94
|
+
const diff = documentDiff("before", "after", admission.value.source.document.bytes, admission.value.terms.document.bytes);
|
|
96
95
|
accumulator.extendConclusions(this.id, { documentDiff: diff, changes });
|
|
97
|
-
const region = await observeChangedRegion(scope, this.id, changedSections, decodeContractDocument(
|
|
96
|
+
const region = await observeChangedRegion(scope, this.id, changedSections, decodeContractDocument(admission.value.terms.document.bytes).region);
|
|
98
97
|
const value = await this.conclude(accumulator, {
|
|
99
98
|
scope,
|
|
100
99
|
channel,
|
|
101
|
-
leading:
|
|
100
|
+
leading: admission,
|
|
102
101
|
hooks,
|
|
103
|
-
verificationResidueRecorded: false,
|
|
104
102
|
value: () => ({
|
|
105
103
|
documentDiff: diff,
|
|
106
104
|
changes,
|
|
@@ -247,27 +245,26 @@ export class ContractExecution {
|
|
|
247
245
|
});
|
|
248
246
|
const hooks = derivedHooks(this.composition);
|
|
249
247
|
return await this.local("abandon", async (accumulator, channel, scope) => {
|
|
250
|
-
const admission =
|
|
248
|
+
const admission = (await releaseDebtHolderWithFence(scope, channel, this.id, () => abandonOperation({
|
|
251
249
|
scope,
|
|
252
250
|
channel,
|
|
253
251
|
contractId: this.id,
|
|
254
252
|
...actor,
|
|
255
253
|
...(note === undefined ? {} : { note }),
|
|
256
|
-
observationSelection:
|
|
254
|
+
observationSelection: debtHolderObservationSelection(),
|
|
257
255
|
progress: accumulator,
|
|
258
256
|
decorateOffer: async ({ observation, contractId: owner }) => {
|
|
259
|
-
const companion = await
|
|
257
|
+
const companion = await releaseDebtHolder(channel, observation, owner);
|
|
260
258
|
return companion === null ? [] : [companion];
|
|
261
259
|
},
|
|
262
|
-
}))).result
|
|
260
|
+
}))).result;
|
|
263
261
|
if (admission.kind !== "accepted")
|
|
264
262
|
return expected(this.id, admission);
|
|
265
263
|
await this.conclude(accumulator, {
|
|
266
264
|
scope,
|
|
267
265
|
channel,
|
|
268
|
-
leading: admission
|
|
266
|
+
leading: admission,
|
|
269
267
|
hooks,
|
|
270
|
-
verificationResidueRecorded: false,
|
|
271
268
|
value: () => ({}),
|
|
272
269
|
});
|
|
273
270
|
return acceptedOutcome("abandon", this.id, accumulator, undefined);
|
|
@@ -283,22 +280,21 @@ export class ContractExecution {
|
|
|
283
280
|
});
|
|
284
281
|
const hooks = derivedHooks(this.composition);
|
|
285
282
|
return await this.local("arc", async (accumulator, channel, scope) => {
|
|
286
|
-
const admission =
|
|
283
|
+
const admission = await arcOperation({
|
|
287
284
|
scope,
|
|
288
285
|
channel,
|
|
289
286
|
contractId: this.id,
|
|
290
287
|
...actor,
|
|
291
288
|
chapter,
|
|
292
289
|
progress: accumulator,
|
|
293
|
-
})
|
|
290
|
+
});
|
|
294
291
|
if (admission.kind !== "accepted")
|
|
295
292
|
return expected(this.id, admission);
|
|
296
293
|
await this.conclude(accumulator, {
|
|
297
294
|
scope,
|
|
298
295
|
channel,
|
|
299
|
-
leading: admission
|
|
296
|
+
leading: admission,
|
|
300
297
|
hooks,
|
|
301
|
-
verificationResidueRecorded: false,
|
|
302
298
|
value: () => ({}),
|
|
303
299
|
});
|
|
304
300
|
return acceptedOutcome("arc", this.id, accumulator, undefined);
|
|
@@ -327,7 +323,7 @@ export class ContractExecution {
|
|
|
327
323
|
});
|
|
328
324
|
const { hooks, requireBranchesToBeUpToDate } = derivedContractPolicy(this.composition);
|
|
329
325
|
return await this.local("audit", async (accumulator, localChannel, scope) => {
|
|
330
|
-
const admission =
|
|
326
|
+
const admission = await auditOperation({
|
|
331
327
|
scope,
|
|
332
328
|
channel: localChannel,
|
|
333
329
|
progress: accumulator,
|
|
@@ -338,15 +334,14 @@ export class ContractExecution {
|
|
|
338
334
|
requireBranchesToBeUpToDate,
|
|
339
335
|
...(signal === undefined ? {} : { signal }),
|
|
340
336
|
...(this.composition.actor === undefined ? {} : { actor: this.composition.actor }),
|
|
341
|
-
})
|
|
337
|
+
});
|
|
342
338
|
if (admission.kind !== "accepted")
|
|
343
339
|
return expected(this.id, admission);
|
|
344
340
|
const report = await this.conclude(accumulator, {
|
|
345
341
|
scope,
|
|
346
342
|
channel: localChannel,
|
|
347
|
-
leading: admission
|
|
343
|
+
leading: admission,
|
|
348
344
|
hooks,
|
|
349
|
-
verificationResidueRecorded: false,
|
|
350
345
|
value: (value) => value,
|
|
351
346
|
});
|
|
352
347
|
return acceptedOutcome("audit", this.id, accumulator, report);
|
|
@@ -380,9 +375,9 @@ export class ContractExecution {
|
|
|
380
375
|
return projected.outcome;
|
|
381
376
|
}
|
|
382
377
|
async conclude(accumulator, input) {
|
|
383
|
-
retainAdmission(accumulator, this.id, input.leading
|
|
378
|
+
retainAdmission(accumulator, this.id, input.leading);
|
|
384
379
|
const value = input.value(input.leading.value);
|
|
385
|
-
accumulator.extendConclusions(this.id,
|
|
380
|
+
accumulator.extendConclusions(this.id, value);
|
|
386
381
|
await reconcileAffectedContracts(accumulator, this.id, input.scope, input.channel, input.hooks);
|
|
387
382
|
return value;
|
|
388
383
|
}
|
|
@@ -41,17 +41,6 @@ export type BindResult = BindOutcome;
|
|
|
41
41
|
type AcceptedIntent<Value> = Extract<IntentOutcome<Value>, {
|
|
42
42
|
kind: "accepted";
|
|
43
43
|
}>;
|
|
44
|
-
type Admission<Value, Refusal> = Readonly<{
|
|
45
|
-
kind: "accepted";
|
|
46
|
-
accepted: AcceptedIntent<Value>;
|
|
47
|
-
}> | Readonly<{
|
|
48
|
-
kind: "refused";
|
|
49
|
-
refusal: Refusal;
|
|
50
|
-
}> | Readonly<{
|
|
51
|
-
kind: "retry";
|
|
52
|
-
reason: IntentRetry;
|
|
53
|
-
}>;
|
|
54
|
-
export declare function admissionOf<Value, Refusal>(outcome: IntentOutcome<Value, Refusal>): Admission<Value, Refusal>;
|
|
55
44
|
/** The refused/retry arms are value-agnostic, so every operation can return them unchanged. */
|
|
56
45
|
type ExpectedProjection<Refusal> = Readonly<{
|
|
57
46
|
kind: "refused";
|
|
@@ -62,10 +51,9 @@ type ExpectedProjection<Refusal> = Readonly<{
|
|
|
62
51
|
contract?: ContractId;
|
|
63
52
|
reason: IntentRetry;
|
|
64
53
|
}>;
|
|
65
|
-
export declare function expected<Refusal>(contract: ContractId | undefined, admission: Exclude<
|
|
54
|
+
export declare function expected<Refusal>(contract: ContractId | undefined, admission: Exclude<IntentOutcome<unknown, Refusal>, {
|
|
66
55
|
kind: "accepted";
|
|
67
56
|
}>): ExpectedProjection<Refusal>;
|
|
68
57
|
export declare function acceptedOutcome<Operation extends ContractVerb, Value>(operation: Operation, contract: ContractId, accumulator: InvocationAccumulator, value: Value): OutcomeProjection<Operation, Value, never>;
|
|
69
|
-
export declare function
|
|
70
|
-
export declare function retainAdmission<Value>(accumulator: InvocationAccumulator, contract: ContractId, leading: AcceptedIntent<Value>, verificationResidueRecorded: boolean): void;
|
|
58
|
+
export declare function retainAdmission<Value>(accumulator: InvocationAccumulator, contract: ContractId, leading: AcceptedIntent<Value>): void;
|
|
71
59
|
export {};
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export function admissionOf(outcome) {
|
|
2
|
-
if (outcome.kind === "accepted")
|
|
3
|
-
return { kind: "accepted", accepted: outcome };
|
|
4
|
-
return outcome.kind === "refused"
|
|
5
|
-
? { kind: "refused", refusal: outcome.refusal }
|
|
6
|
-
: { kind: "retry", reason: outcome.reason };
|
|
7
|
-
}
|
|
8
1
|
export function expected(contract, admission) {
|
|
9
2
|
return admission.kind === "refused"
|
|
10
3
|
? {
|
|
@@ -21,12 +14,8 @@ export function acceptedOutcome(operation, contract, accumulator, value) {
|
|
|
21
14
|
throw new Error("missing leading admission receipt");
|
|
22
15
|
return { kind: "accepted", contract, head, value };
|
|
23
16
|
}
|
|
24
|
-
export function
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
export function retainAdmission(accumulator, contract, leading, verificationResidueRecorded) {
|
|
17
|
+
export function retainAdmission(accumulator, contract, leading) {
|
|
28
18
|
accumulator.recordPublication(contract, leading.head, leading.facts);
|
|
29
19
|
accumulator.recordResidue(contract, leading);
|
|
30
|
-
|
|
31
|
-
accumulator.recordVerification(contract, undefined, leading);
|
|
20
|
+
accumulator.recordVerification(contract, undefined, leading);
|
|
32
21
|
}
|
|
@@ -2,7 +2,7 @@ import type { AttestationData, ContractId, JournalEntry, SnapshotId } from "../c
|
|
|
2
2
|
import type { Dispatch } from "../dispatch/index.js";
|
|
3
3
|
import type { ContractBoard, ContractRow } from "../protocol/read/status.js";
|
|
4
4
|
import type { Settings } from "../settings.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { DebtId } from "../debt/identity.js";
|
|
6
6
|
import type { Repo } from "./repo.js";
|
|
7
7
|
/** Public gate words remain ordinary strings; private policy interprets them. */
|
|
8
8
|
export type Gate = string;
|
|
@@ -25,8 +25,9 @@ export type ContractHistory = Readonly<{
|
|
|
25
25
|
type MarkdownBindInput = Readonly<{
|
|
26
26
|
repo: Repo;
|
|
27
27
|
markdown: string;
|
|
28
|
-
|
|
29
|
-
target
|
|
28
|
+
debt?: DebtId;
|
|
29
|
+
/** A literal target branch; `null` is deliberately targetless; omitted is the Repo worktree's current branch. */
|
|
30
|
+
target?: string | null;
|
|
30
31
|
workspace?: "worktree";
|
|
31
32
|
actor?: string;
|
|
32
33
|
after?: readonly ContractId[];
|
|
@@ -35,7 +36,8 @@ type MarkdownBindInput = Readonly<{
|
|
|
35
36
|
type ForkBindInput = Readonly<{
|
|
36
37
|
repo: Repo;
|
|
37
38
|
forkOf: ContractId;
|
|
38
|
-
target
|
|
39
|
+
/** A literal target branch; `null` clears the source target; omitted inherits it. */
|
|
40
|
+
target?: string | null;
|
|
39
41
|
workspace?: "worktree";
|
|
40
42
|
actor?: string;
|
|
41
43
|
}>;
|
|
@@ -72,6 +74,38 @@ export type KeiyakuSelectInput = Readonly<{
|
|
|
72
74
|
repo: Repo;
|
|
73
75
|
id: ContractId;
|
|
74
76
|
}>;
|
|
77
|
+
export type ContractResolveInput = Readonly<{
|
|
78
|
+
repo: Repo;
|
|
79
|
+
selector?: string;
|
|
80
|
+
cwd?: string;
|
|
81
|
+
}>;
|
|
82
|
+
export type ContractSelectorRefusal = Readonly<{
|
|
83
|
+
kind: "invalid-selector";
|
|
84
|
+
selector: string;
|
|
85
|
+
diagnostic: string;
|
|
86
|
+
}> | Readonly<{
|
|
87
|
+
kind: "redundant-short-selector";
|
|
88
|
+
selector: string;
|
|
89
|
+
}> | Readonly<{
|
|
90
|
+
kind: "unknown-short-selector";
|
|
91
|
+
selector: string;
|
|
92
|
+
}> | Readonly<{
|
|
93
|
+
kind: "ambiguous-selector";
|
|
94
|
+
selector: string;
|
|
95
|
+
}> | Readonly<{
|
|
96
|
+
kind: "ambiguous-selector";
|
|
97
|
+
cwd: string;
|
|
98
|
+
}> | Readonly<{
|
|
99
|
+
kind: "no-contextual-match";
|
|
100
|
+
cwd: string;
|
|
101
|
+
}>;
|
|
102
|
+
export type ContractResolution = Readonly<{
|
|
103
|
+
kind: "resolved";
|
|
104
|
+
id: ContractId;
|
|
105
|
+
}> | Readonly<{
|
|
106
|
+
kind: "refused";
|
|
107
|
+
refusal: ContractSelectorRefusal;
|
|
108
|
+
}>;
|
|
75
109
|
export type ReviewInput = ActorOptions & Readonly<{
|
|
76
110
|
verdict: AttestationData["verdict"];
|
|
77
111
|
summary?: string;
|
|
@@ -544,8 +544,6 @@ type HandleType<T extends object> = Readonly<{
|
|
|
544
544
|
[Symbol.hasInstance](value: unknown): boolean;
|
|
545
545
|
}>;
|
|
546
546
|
export declare const Delivery: HandleType<DeliveryHandle>;
|
|
547
|
-
export declare function deliveryHandle(delivery: DeliveryValue, readDiff: () => Promise<string | null>): Delivery & DeliveryValue;
|
|
548
|
-
export declare function deliveryHandle(delivery: Pick<DeliveryValue, "tenderSnapshot" | "integration" | "method" | "policy"> & Partial<DeliveryValue>, readDiff: () => Promise<string | null>): Delivery;
|
|
549
547
|
export declare function deliveryForContract(scope: RepositoryScope, delivery: DeliveryValue): Delivery & DeliveryValue;
|
|
550
548
|
export declare function deliveryForContract(scope: RepositoryScope, delivery: Pick<DeliveryValue, "tenderSnapshot" | "integration" | "method" | "policy">): Delivery;
|
|
551
549
|
export {};
|
|
@@ -30,13 +30,10 @@ export const Delivery = Object.freeze({
|
|
|
30
30
|
prototype: DeliveryHandle.prototype,
|
|
31
31
|
[Symbol.hasInstance]: (value) => value instanceof DeliveryHandle,
|
|
32
32
|
});
|
|
33
|
-
export function deliveryHandle(delivery, readDiff) {
|
|
34
|
-
return new DeliveryHandle(delivery, readDiff, delivery);
|
|
35
|
-
}
|
|
36
33
|
export function deliveryForContract(scope, delivery) {
|
|
37
|
-
return
|
|
34
|
+
return new DeliveryHandle(delivery, () => deliveryDiffOperation({
|
|
38
35
|
scope,
|
|
39
36
|
integrationPredecessor: delivery.integration.predecessor,
|
|
40
37
|
integrationSnapshot: delivery.integration.snapshot,
|
|
41
|
-
}));
|
|
38
|
+
}), delivery);
|
|
42
39
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { DecodedContractDocument } from "../body/types.js";
|
|
2
2
|
import { type ActorId, type ContractId, type ContractTerms, type Gate } from "../core/facts/types.js";
|
|
3
|
-
import { type
|
|
3
|
+
import { type DebtId } from "../debt/identity.js";
|
|
4
4
|
import type { DocumentDerivation } from "../protocol/operations.js";
|
|
5
5
|
export declare function actorOption(actor: unknown): Readonly<{
|
|
6
6
|
actor?: ActorId;
|
|
7
7
|
}>;
|
|
8
8
|
export declare function requireMarkdown(value: unknown, label?: string): string;
|
|
9
9
|
export declare function requireInput(value: unknown, label: string, allowed?: readonly string[]): Record<string, unknown>;
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function debtOption(value: unknown): DebtId | undefined;
|
|
11
11
|
export declare function optionalNonblank(value: unknown, label: string): string | undefined;
|
|
12
12
|
export declare function optionalBoolean(value: unknown, label: string): boolean | undefined;
|
|
13
13
|
export declare function optionalSignal(value: unknown): AbortSignal | undefined;
|
|
@@ -3,7 +3,7 @@ import { decodeContractDocument } from "../body/decode.js";
|
|
|
3
3
|
import { validated } from "./outcome.js";
|
|
4
4
|
import { verificationDefinition } from "../body/decode.js";
|
|
5
5
|
import { actorId } from "../core/facts/types.js";
|
|
6
|
-
import {
|
|
6
|
+
import { parseDebtId } from "../debt/identity.js";
|
|
7
7
|
import { prepareVerificationDeclaration } from "../verification/declaration.js";
|
|
8
8
|
export function actorOption(actor) {
|
|
9
9
|
if (actor === undefined)
|
|
@@ -32,16 +32,16 @@ export function requireInput(value, label, allowed) {
|
|
|
32
32
|
}
|
|
33
33
|
return value;
|
|
34
34
|
}
|
|
35
|
-
export function
|
|
35
|
+
export function debtOption(value) {
|
|
36
36
|
if (value === undefined)
|
|
37
37
|
return undefined;
|
|
38
38
|
if (typeof value !== "string")
|
|
39
|
-
throw new TypeError("
|
|
39
|
+
throw new TypeError("debt must be a DebtId");
|
|
40
40
|
try {
|
|
41
|
-
|
|
41
|
+
parseDebtId(value);
|
|
42
42
|
}
|
|
43
43
|
catch (error) {
|
|
44
|
-
throw new TypeError(error instanceof Error ? error.message : "
|
|
44
|
+
throw new TypeError(error instanceof Error ? error.message : "debt must be a DebtId");
|
|
45
45
|
}
|
|
46
46
|
return value;
|
|
47
47
|
}
|
|
@@ -27,12 +27,12 @@ export class InvocationAccumulator {
|
|
|
27
27
|
this.observer = observer;
|
|
28
28
|
}
|
|
29
29
|
beginReset(world) {
|
|
30
|
-
this.resetState = { world, removed: { refs: 0, worktrees: 0,
|
|
30
|
+
this.resetState = { world, removed: { refs: 0, worktrees: 0, debts: 0 } };
|
|
31
31
|
}
|
|
32
32
|
recordResetRemoved(counts) {
|
|
33
33
|
if (this.resetState === undefined)
|
|
34
34
|
throw new Error("reset progress requires its World");
|
|
35
|
-
for (const key of ["refs", "worktrees", "
|
|
35
|
+
for (const key of ["refs", "worktrees", "debts"])
|
|
36
36
|
this.resetState.removed[key] += counts[key] ?? 0;
|
|
37
37
|
}
|
|
38
38
|
observe(event) {
|
|
@@ -32,11 +32,6 @@ export declare class Keiyaku {
|
|
|
32
32
|
abandon(input?: AbandonInput): Promise<AbandonOutcome>;
|
|
33
33
|
arc(input: ArcInput): Promise<ArcOutcome>;
|
|
34
34
|
audit(input?: AuditInput, options?: MutationObservation): Promise<AuditOutcome>;
|
|
35
|
-
/**
|
|
36
|
-
* Reads answer with a value or `null` for legitimate absence. Corrupt authority stays exceptional
|
|
37
|
-
* and keeps its original native cause instead of being disguised as a raw native exception.
|
|
38
|
-
*/
|
|
39
|
-
private read;
|
|
40
35
|
}
|
|
41
36
|
/** Internal constructor capability; callers select a Contract through Keiyaku.with. */
|
|
42
37
|
export declare function createKeiyakuHandle(id: ContractId, scope: RepositoryScope, execution: ExecutionContext, composition: LocalContractCompositionCapture): Keiyaku;
|
|
@@ -7,7 +7,8 @@ import { observeContractsForAdmissionInObservationAt } from "../git/observe.js";
|
|
|
7
7
|
import { withGitDecodeChannel, withGitReadObservation } from "../git/read-observation.js";
|
|
8
8
|
import { contractObservationOperation, deliveryOperation, stateOperation, } from "../protocol/operations.js";
|
|
9
9
|
import { readManagedWorktreeAppointment } from "../workspace-place.js";
|
|
10
|
-
import { composeContractLibrary
|
|
10
|
+
import { composeContractLibrary } from "./contract-composition.js";
|
|
11
|
+
import { readContractValue } from "./outcome.js";
|
|
11
12
|
import { ContractExecution } from "./contract-execution.js";
|
|
12
13
|
import { deliveryForContract } from "./delivery.js";
|
|
13
14
|
const KEIYAKU_HANDLE = Symbol("Keiyaku handle");
|
|
@@ -41,10 +42,10 @@ export class Keiyaku {
|
|
|
41
42
|
return { contract: this.id };
|
|
42
43
|
}
|
|
43
44
|
async state() {
|
|
44
|
-
return await
|
|
45
|
+
return await readContractValue(() => withGitDecodeChannel(this.scope, (channel) => stateOperation({ scope: this.scope, channel, contractId: this.id })));
|
|
45
46
|
}
|
|
46
47
|
async history() {
|
|
47
|
-
return await
|
|
48
|
+
return await readContractValue(() => withGitDecodeChannel(this.scope, (channel) => withGitReadObservation(this.scope, channel, async (observation) => {
|
|
48
49
|
const [journals, dispatches] = await Promise.all([
|
|
49
50
|
observeContractsForAdmissionInObservationAt(observation, [this.id]),
|
|
50
51
|
readDispatchesAt(observation),
|
|
@@ -84,7 +85,7 @@ export class Keiyaku {
|
|
|
84
85
|
})));
|
|
85
86
|
}
|
|
86
87
|
async guidance() {
|
|
87
|
-
return await
|
|
88
|
+
return await readContractValue(() => withGitDecodeChannel(this.scope, async (channel) => {
|
|
88
89
|
const observed = await contractObservationOperation({ scope: this.scope, channel, contractId: this.id });
|
|
89
90
|
if (observed.kind === "missing")
|
|
90
91
|
return null;
|
|
@@ -93,7 +94,7 @@ export class Keiyaku {
|
|
|
93
94
|
}));
|
|
94
95
|
}
|
|
95
96
|
async delivery() {
|
|
96
|
-
const delivery = await
|
|
97
|
+
const delivery = await readContractValue(() => withGitDecodeChannel(this.scope, (channel) => deliveryOperation({ scope: this.scope, channel, contractId: this.id })));
|
|
97
98
|
return delivery === null ? null : deliveryForContract(this.scope, delivery);
|
|
98
99
|
}
|
|
99
100
|
async amend(input) {
|
|
@@ -114,13 +115,6 @@ export class Keiyaku {
|
|
|
114
115
|
async audit(input, options) {
|
|
115
116
|
return await this.operations.audit(input, options);
|
|
116
117
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Reads answer with a value or `null` for legitimate absence. Corrupt authority stays exceptional
|
|
119
|
-
* and keeps its original native cause instead of being disguised as a raw native exception.
|
|
120
|
-
*/
|
|
121
|
-
async read(operation) {
|
|
122
|
-
return await readContractValue(operation);
|
|
123
|
-
}
|
|
124
118
|
}
|
|
125
119
|
/** Internal constructor capability; callers select a Contract through Keiyaku.with. */
|
|
126
120
|
export function createKeiyakuHandle(id, scope, execution, composition) {
|
|
@@ -4,7 +4,7 @@ import { resolve } from "node:path";
|
|
|
4
4
|
import { AkumaResetStopError, stopAkuma } from "../akuma/nuke.js";
|
|
5
5
|
import { GitResetStopError, nukeGit } from "../git/nuke.js";
|
|
6
6
|
import { isOperationalFailure } from "../protocol/progress.js";
|
|
7
|
-
import {
|
|
7
|
+
import { nukeDebt } from "../debt/operations.js";
|
|
8
8
|
import { World } from "../world.js";
|
|
9
9
|
import { requireInput, requireMarkdown } from "./input.js";
|
|
10
10
|
import { InvocationAccumulator } from "./invocation.js";
|
|
@@ -73,8 +73,8 @@ export async function nukeKeiyaku(input, gitOptions) {
|
|
|
73
73
|
diagnostic: result.closeLag.diagnostic,
|
|
74
74
|
});
|
|
75
75
|
}),
|
|
76
|
-
runOwner("
|
|
77
|
-
await
|
|
76
|
+
runOwner("debt", async () => {
|
|
77
|
+
await nukeDebt(world, { onRemoved: (debts) => accumulator.recordResetRemoved({ debts }) });
|
|
78
78
|
}),
|
|
79
79
|
]);
|
|
80
80
|
await runOwner("world", () => removeEmptyWorldMarker(world));
|