@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
|
@@ -2,7 +2,6 @@ import { z } from "zod";
|
|
|
2
2
|
import type { DecideInput, OfferDecision } from "../core/decide.js";
|
|
3
3
|
import type { ActorId, ContractId, ContractState, DeliverData, DocumentKey, JournalEntry, SnapshotId } from "../core/facts/types.js";
|
|
4
4
|
import type { IntegrationPreparationRefusal } from "../git/integration.js";
|
|
5
|
-
import { type PrivateStateSeatOutcome } from "../git/private-state-seat.js";
|
|
6
5
|
import type { GitRepository } from "../git/process.js";
|
|
7
6
|
import { type GitDecodeChannel } from "../git/read-observation.js";
|
|
8
7
|
import type { WorktreeLeak } from "../git/scratch.js";
|
|
@@ -389,8 +388,8 @@ export declare const intentRefusalSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
389
388
|
}, z.core.$strict>>>;
|
|
390
389
|
}, z.core.$strict>]>, z.ZodObject<{
|
|
391
390
|
kind: z.ZodEnum<{
|
|
392
|
-
"unborn-head": "unborn-head";
|
|
393
391
|
"target-missing": "target-missing";
|
|
392
|
+
"unborn-head": "unborn-head";
|
|
394
393
|
"invalid-target": "invalid-target";
|
|
395
394
|
}>;
|
|
396
395
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -630,7 +629,6 @@ export type AttemptDecision<Value, Refusal = IntentRefusal> = (AcceptedAdmission
|
|
|
630
629
|
kind: "publication-failed";
|
|
631
630
|
}>;
|
|
632
631
|
export declare function timestamp(): string;
|
|
633
|
-
export declare function attemptDecisionWithSeatClose<Value, Refusal = IntentRefusal>(outcome: PrivateStateSeatOutcome<AttemptDecision<Value, Refusal>>): AttemptDecision<Value, Refusal>;
|
|
634
632
|
export declare function unpackVerificationOutcome(verification: VerificationResult): Readonly<{
|
|
635
633
|
cleanup?: VerificationCleanupFailure;
|
|
636
634
|
leak?: WorktreeLeak;
|
|
@@ -4,7 +4,6 @@ import { gate } from "../core/facts/types.js";
|
|
|
4
4
|
import { changeIdSchema, contractIdSchema, snapshotIdSchema } from "../git/identity.js";
|
|
5
5
|
import { integrationPreparationRefusalSchema, readDeliveryDiff } from "../git/integration.js";
|
|
6
6
|
import { currentBranch, observeContractAt } from "../git/observe.js";
|
|
7
|
-
import { appendPrivateStateSeatClose, mergePrivateStateSeatClose, } from "../git/private-state-seat.js";
|
|
8
7
|
import { withGitReadObservation } from "../git/read-observation.js";
|
|
9
8
|
import { repositoryAt } from "../git/repository.js";
|
|
10
9
|
import { checkoutNotFollowableRefusalSchema } from "../git/target-placement.js";
|
|
@@ -216,13 +215,6 @@ export const placementStopSchema = z.union([
|
|
|
216
215
|
export function timestamp() {
|
|
217
216
|
return new Date().toISOString();
|
|
218
217
|
}
|
|
219
|
-
export function attemptDecisionWithSeatClose(outcome) {
|
|
220
|
-
return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
|
|
221
|
-
if (value.kind !== "accepted")
|
|
222
|
-
throw new Error(closeLag.diagnostic);
|
|
223
|
-
return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
218
|
function stepStop(result) {
|
|
227
219
|
if (result.kind === "accepted")
|
|
228
220
|
return undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ContractHead, ContractState, JournalEntry } from "../core/facts/types.js";
|
|
2
2
|
import type { WorktreeLeak } from "../git/scratch.js";
|
|
3
3
|
import type { ReconcileResult } from "../git/reconcile.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { PrivateStateSeatCloseLag } from "../git/private-state-seat.js";
|
|
5
5
|
import type { AcceptedAdmission } from "./attempt.js";
|
|
6
6
|
import type { VerificationCleanupFailure } from "./intent.js";
|
|
7
7
|
import type { ProtocolResult, ProtocolTerminal } from "./run.js";
|
|
@@ -38,5 +38,4 @@ export type IntentOutcome<Value, Refusal = never> = Readonly<{
|
|
|
38
38
|
export declare function accepted<Value, Refusal = never>(state: ContractState, facts: readonly JournalEntry[], value: Value, physical?: ReconcileResult, obligations?: AcceptedObligations): IntentOutcome<Value, Refusal>;
|
|
39
39
|
export declare function admitted<Value, Refusal = never>(admission: AcceptedProtocolStep, value: Value): IntentOutcome<Value, Refusal>;
|
|
40
40
|
export declare function complete<Value, Refusal>(result: ProtocolResult<Refusal>, value: Value): IntentOutcome<Value, Refusal>;
|
|
41
|
-
export declare function intentOutcomeWithSeatClose<Value, Refusal>(outcome: PrivateStateSeatOutcome<IntentOutcome<Value, Refusal>>): IntentOutcome<Value, Refusal>;
|
|
42
41
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { appendPrivateStateSeatClose, mergePrivateStateSeatClose, } from "../git/private-state-seat.js";
|
|
2
1
|
export function accepted(state, facts, value, physical, obligations) {
|
|
3
2
|
if (state.head === null)
|
|
4
3
|
throw new Error("accepted contract is missing its journal head");
|
|
@@ -16,12 +15,8 @@ export function accepted(state, facts, value, physical, obligations) {
|
|
|
16
15
|
function seatCloseObligations(seatClose) {
|
|
17
16
|
return seatClose === undefined || seatClose.length === 0 ? {} : { seatClose };
|
|
18
17
|
}
|
|
19
|
-
function admissionObligations(admission) {
|
|
20
|
-
const seatClose = admission.seatClose;
|
|
21
|
-
return seatClose === undefined || seatClose.length === 0 ? undefined : { seatClose };
|
|
22
|
-
}
|
|
23
18
|
export function admitted(admission, value) {
|
|
24
|
-
return accepted(admission.state, admission.facts, value, admission.physical,
|
|
19
|
+
return accepted(admission.state, admission.facts, value, admission.physical, admission.seatClose === undefined ? undefined : { seatClose: admission.seatClose });
|
|
25
20
|
}
|
|
26
21
|
export function complete(result, value) {
|
|
27
22
|
if (result.kind === "refused")
|
|
@@ -30,10 +25,3 @@ export function complete(result, value) {
|
|
|
30
25
|
return { kind: "retry", reason: result };
|
|
31
26
|
return admitted(result, value);
|
|
32
27
|
}
|
|
33
|
-
export function intentOutcomeWithSeatClose(outcome) {
|
|
34
|
-
return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
|
|
35
|
-
if (value.kind !== "accepted")
|
|
36
|
-
throw new Error(closeLag.diagnostic);
|
|
37
|
-
return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
|
|
38
|
-
});
|
|
39
|
-
}
|
|
@@ -3,12 +3,12 @@ import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
|
3
3
|
import { contractState } from "../core/facts/observation.js";
|
|
4
4
|
import { decidePlacement } from "../core/verbs/placement.js";
|
|
5
5
|
import { observeContractsForAdmissionAt, observeGitForAdmissionAt } from "../git/observe.js";
|
|
6
|
-
import {
|
|
6
|
+
import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
|
|
7
7
|
import { reconcileEffectFailure } from "../git/reconcile.js";
|
|
8
8
|
import { GitPlumbingError } from "../git/process.js";
|
|
9
9
|
import { acquireTargetPlacementFence, followTargetPlacement, prepareTargetPlacement, prepareTargetPlacementChanges, observeTargetHead, observedTreeEqualsCandidate, } from "../git/target-placement.js";
|
|
10
10
|
import { admitDecidedOffer, mintAttempts } from "./attempt.js";
|
|
11
|
-
import { prepareProtocolAttempt, runProtocol } from "./run.js";
|
|
11
|
+
import { prepareProtocolAttempt, protocolSeatClose, runProtocol, } from "./run.js";
|
|
12
12
|
export { observeTargetPlacement } from "../git/target-placement.js";
|
|
13
13
|
export async function observeIntegrationTargetMovement(repository, state) {
|
|
14
14
|
const target = state.coordinates.target;
|
|
@@ -39,13 +39,6 @@ function expectedOperationalDiagnostic(error) {
|
|
|
39
39
|
function expectedPlacementFailure(error) {
|
|
40
40
|
return { kind: "placement-failed", diagnostic: expectedOperationalDiagnostic(error) };
|
|
41
41
|
}
|
|
42
|
-
function placementResultWithSeatClose(outcome) {
|
|
43
|
-
return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
|
|
44
|
-
if (value.kind !== "accepted")
|
|
45
|
-
throw new Error(closeLag.diagnostic);
|
|
46
|
-
return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
42
|
async function placementChangesHint(repository, channel, contractId) {
|
|
50
43
|
const observation = await observeContractsForAdmissionAt(repository, channel, [contractId]);
|
|
51
44
|
const state = contractState(observation.decision, contractId);
|
|
@@ -63,7 +56,7 @@ async function runFencedPlacement(repository, input, protocol) {
|
|
|
63
56
|
(changes?.predecessor !== movement.expectedOid || changes.candidate !== movement.newOid))
|
|
64
57
|
changes = await prepareTargetPlacementChanges(repository, movement);
|
|
65
58
|
let preparedPhysical;
|
|
66
|
-
const result =
|
|
59
|
+
const result = protocolSeatClose(await withPrivateStatePublicationSeat(repository, async (seat) => {
|
|
67
60
|
// The hint carries no acceptance authority. Form a fresh semantic offer under the seat.
|
|
68
61
|
const prepared = await prepareProtocolAttempt(protocol, protocol.attempts[index]);
|
|
69
62
|
if (prepared.kind !== "offered")
|
|
@@ -57,9 +57,6 @@ function appointedWorkspace(repository, register, state) {
|
|
|
57
57
|
? undefined
|
|
58
58
|
: { contractId: state.id, place: appointed.place, workspace: worktreePath(repository, appointed.place) };
|
|
59
59
|
}
|
|
60
|
-
async function readSelectedHandoffs(observation, workspaces) {
|
|
61
|
-
return await readConflictHandoffs(observation.repository, observation.readBlobs, workspaces.flatMap((workspace) => (workspace === undefined ? [] : [workspace])));
|
|
62
|
-
}
|
|
63
60
|
async function managedWorkspaceFacts(repository, state, appointed, targetObservation, handoff) {
|
|
64
61
|
if (appointed === undefined) {
|
|
65
62
|
return {
|
|
@@ -101,10 +98,10 @@ function afterEdges(state, endpoints) {
|
|
|
101
98
|
endpoint: afterEndpoint(endpoints.get(contractId)),
|
|
102
99
|
}));
|
|
103
100
|
}
|
|
104
|
-
function reverseDependents(id,
|
|
105
|
-
return
|
|
106
|
-
.filter((
|
|
107
|
-
.map((
|
|
101
|
+
function reverseDependents(id, states) {
|
|
102
|
+
return states
|
|
103
|
+
.filter(({ state }) => state.terminal === null && state.terms.after.includes(id))
|
|
104
|
+
.map(({ state }) => ({ contractId: state.id, phase: phaseFor(state) }))
|
|
108
105
|
.sort((left, right) => left.contractId.localeCompare(right.contractId));
|
|
109
106
|
}
|
|
110
107
|
async function rowFor(input) {
|
|
@@ -148,6 +145,25 @@ async function afterEndpointMap(observation, known, ids) {
|
|
|
148
145
|
const extra = await observeContractsForAdmissionInObservationAt(observation, missing);
|
|
149
146
|
return new Map([...known, ...[...extra.journals].map(([id, record]) => [id, record.state])]);
|
|
150
147
|
}
|
|
148
|
+
async function hydrateRows(observation, states, endpoints, dependentStates = []) {
|
|
149
|
+
const register = await readPlaceRegister(observation.repository);
|
|
150
|
+
const selected = states.map((value) => ({
|
|
151
|
+
...value,
|
|
152
|
+
workspace: appointedWorkspace(observation.repository, register, value.state),
|
|
153
|
+
}));
|
|
154
|
+
const handoffs = await readConflictHandoffs(observation.repository, observation.readBlobs, selected.flatMap(({ workspace }) => (workspace === undefined ? [] : [workspace])));
|
|
155
|
+
return await Promise.all(selected.map(async ({ state, bindAt, lastJournalAt, workspace }) => await rowFor({
|
|
156
|
+
repository: observation.repository,
|
|
157
|
+
state,
|
|
158
|
+
bindAt,
|
|
159
|
+
lastJournalAt,
|
|
160
|
+
targetObservation: await observeDeliveryTargetAt(observation, state),
|
|
161
|
+
workspace,
|
|
162
|
+
handoff: handoffs.get(state.id),
|
|
163
|
+
after: afterEdges(state, endpoints),
|
|
164
|
+
dependents: reverseDependents(state.id, dependentStates),
|
|
165
|
+
})));
|
|
166
|
+
}
|
|
151
167
|
/** Build the Contract board from one immutable git observation. */
|
|
152
168
|
export async function readContractBoard(observation, include) {
|
|
153
169
|
const observedAt = new Date().toISOString();
|
|
@@ -165,29 +181,8 @@ export async function readContractBoard(observation, include) {
|
|
|
165
181
|
endpoints = new Map(await afterEndpointMap(observation, endpoints, record.state.terms.after));
|
|
166
182
|
}
|
|
167
183
|
}
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
? []
|
|
171
|
-
: [
|
|
172
|
-
{
|
|
173
|
-
...value,
|
|
174
|
-
state: value.state,
|
|
175
|
-
workspace: appointedWorkspace(observation.repository, register, value.state),
|
|
176
|
-
},
|
|
177
|
-
]);
|
|
178
|
-
const handoffs = await readSelectedHandoffs(observation, selected.map(({ workspace }) => workspace));
|
|
179
|
-
const projected = await Promise.all(selected.map(async ({ state, entries, workspace }) => await rowFor({
|
|
180
|
-
repository: observation.repository,
|
|
181
|
-
state,
|
|
182
|
-
bindAt: entries[0].at,
|
|
183
|
-
lastJournalAt: lastJournalAtFor(entries),
|
|
184
|
-
targetObservation: await observeDeliveryTargetAt(observation, state),
|
|
185
|
-
workspace,
|
|
186
|
-
handoff: handoffs.get(state.id),
|
|
187
|
-
after: afterEdges(state, endpoints),
|
|
188
|
-
dependents: [],
|
|
189
|
-
})));
|
|
190
|
-
const rows = projected.map((row) => ({ ...row, dependents: reverseDependents(row.id, projected) }));
|
|
184
|
+
const selected = selectedContractStates(contracts);
|
|
185
|
+
const rows = await hydrateRows(observation, selected, endpoints, selected);
|
|
191
186
|
return {
|
|
192
187
|
root: observation.repository.primaryWorktree,
|
|
193
188
|
state: observed.snapshot,
|
|
@@ -199,8 +194,8 @@ function compareRecentContracts(left, right) {
|
|
|
199
194
|
return (right.lastJournalAt.localeCompare(left.lastJournalAt) ||
|
|
200
195
|
Buffer.compare(Buffer.from(left.state.id), Buffer.from(right.state.id)));
|
|
201
196
|
}
|
|
202
|
-
function
|
|
203
|
-
return [...contracts.values()].flatMap((record) => record.state === null
|
|
197
|
+
function selectedContractStates(contracts) {
|
|
198
|
+
return [...contracts.values()].flatMap((record) => record.state === null
|
|
204
199
|
? []
|
|
205
200
|
: [
|
|
206
201
|
{
|
|
@@ -210,37 +205,15 @@ function activeContractStates(contracts) {
|
|
|
210
205
|
},
|
|
211
206
|
]);
|
|
212
207
|
}
|
|
213
|
-
function reverseDependentsFromStates(id, states) {
|
|
214
|
-
return states
|
|
215
|
-
.filter(({ state }) => state.terms.after.includes(id))
|
|
216
|
-
.map(({ state }) => ({ contractId: state.id, phase: phaseFor(state) }))
|
|
217
|
-
.sort((left, right) => left.contractId.localeCompare(right.contractId));
|
|
218
|
-
}
|
|
219
208
|
/** Observe a bounded recent active Contract catalogue from one immutable git observation. */
|
|
220
209
|
export async function readContractCatalogue(observation, limit) {
|
|
221
210
|
const observedAt = new Date().toISOString();
|
|
222
211
|
const observed = await observeActiveContractWorld(observation);
|
|
223
|
-
const active =
|
|
212
|
+
const active = selectedContractStates(observed.contracts).filter(({ state }) => state.terminal === null);
|
|
224
213
|
const selected = projectBoundedList([...active].sort(compareRecentContracts), limit);
|
|
225
214
|
const afterIds = selected.rows.flatMap(({ state }) => state.terms.after);
|
|
226
215
|
const endpoints = await afterEndpointMap(observation, new Map(observed.eligibility), afterIds);
|
|
227
|
-
const
|
|
228
|
-
const selectedWorkspaces = selected.rows.map((value) => ({
|
|
229
|
-
...value,
|
|
230
|
-
workspace: appointedWorkspace(observation.repository, register, value.state),
|
|
231
|
-
}));
|
|
232
|
-
const handoffs = await readSelectedHandoffs(observation, selectedWorkspaces.map(({ workspace }) => workspace));
|
|
233
|
-
const rows = await Promise.all(selectedWorkspaces.map(async ({ state, bindAt, lastJournalAt, workspace }) => await rowFor({
|
|
234
|
-
repository: observation.repository,
|
|
235
|
-
state,
|
|
236
|
-
bindAt,
|
|
237
|
-
lastJournalAt,
|
|
238
|
-
targetObservation: await observeDeliveryTargetAt(observation, state),
|
|
239
|
-
workspace,
|
|
240
|
-
handoff: handoffs.get(state.id),
|
|
241
|
-
after: afterEdges(state, endpoints),
|
|
242
|
-
dependents: reverseDependentsFromStates(state.id, active),
|
|
243
|
-
})));
|
|
216
|
+
const rows = await hydrateRows(observation, selected.rows, endpoints, active);
|
|
244
217
|
return {
|
|
245
218
|
root: observation.repository.primaryWorktree,
|
|
246
219
|
state: observed.snapshot,
|
|
@@ -270,22 +243,10 @@ export async function readContractObservation(observation, id) {
|
|
|
270
243
|
if (state === null)
|
|
271
244
|
return { kind: "missing", id };
|
|
272
245
|
const endpoints = await afterEndpointMap(observation, new Map([[id, state]]), state.terms.after);
|
|
273
|
-
const
|
|
274
|
-
const workspace = appointedWorkspace(observation.repository, register, state);
|
|
275
|
-
const handoffs = await readSelectedHandoffs(observation, [workspace]);
|
|
246
|
+
const rows = await hydrateRows(observation, selectedContractStates(observed.journals), endpoints);
|
|
276
247
|
return {
|
|
277
248
|
kind: "present",
|
|
278
|
-
row:
|
|
279
|
-
repository: observation.repository,
|
|
280
|
-
state,
|
|
281
|
-
bindAt: record.entries[0].at,
|
|
282
|
-
lastJournalAt: lastJournalAtFor(record.entries),
|
|
283
|
-
targetObservation: await observeDeliveryTargetAt(observation, state),
|
|
284
|
-
workspace,
|
|
285
|
-
handoff: handoffs.get(state.id),
|
|
286
|
-
after: afterEdges(state, endpoints),
|
|
287
|
-
dependents: [],
|
|
288
|
-
}),
|
|
249
|
+
row: rows[0],
|
|
289
250
|
};
|
|
290
251
|
}
|
|
291
252
|
/** Observe one Contract and its target from one fresh ref epoch. */
|
|
@@ -2,18 +2,11 @@ import { contractState } from "../core/facts/observation.js";
|
|
|
2
2
|
import { decideReintegrate } from "../core/verbs/reintegrate.js";
|
|
3
3
|
import { materializeReintegrationSnapshot, persistedTender, planIntegration, reusableIntegrationSnapshot, } from "../git/integration.js";
|
|
4
4
|
import { observeContractsForAdmissionAt } from "../git/observe.js";
|
|
5
|
-
import {
|
|
5
|
+
import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
|
|
6
6
|
import { admitDecidedOffer, mintAttempts } from "./attempt.js";
|
|
7
7
|
import { recordedIntegrationSnapshots, timestamp } from "./operations.js";
|
|
8
|
-
import { externalPreparation, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
|
|
8
|
+
import { externalPreparation, protocolSeatClose, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
|
|
9
9
|
import { runUnderTargetPlacementFence } from "./placement.js";
|
|
10
|
-
function reintegrationResultWithSeatClose(outcome) {
|
|
11
|
-
return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
|
|
12
|
-
if (value.kind !== "accepted")
|
|
13
|
-
throw new Error(closeLag.diagnostic);
|
|
14
|
-
return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
10
|
/** Plan and materialize the target-specific reintegration artifacts outside the publication seat. */
|
|
18
11
|
async function prepareExternalReintegration(input) {
|
|
19
12
|
return await externalPreparation({ ...input, scope: input.repository }, (observation, state) => planReintegrationArtifacts(input, state, recordedIntegrationSnapshots(observation.journals.get(state.id)?.entries ?? [])));
|
|
@@ -54,7 +47,7 @@ async function runReintegration(input) {
|
|
|
54
47
|
for (let index = 0; index < attempts.length; index += 1) {
|
|
55
48
|
const attempt = attempts[index];
|
|
56
49
|
const external = await prepareExternalReintegration(input);
|
|
57
|
-
const result =
|
|
50
|
+
const result = protocolSeatClose(await withPrivateStatePublicationSeat(input.repository, async (seat) => {
|
|
58
51
|
const observation = await observeContractsForAdmissionAt(input.repository, input.channel, [input.contractId]);
|
|
59
52
|
const assembled = assembleReintegrationAttempt(input, observation, external);
|
|
60
53
|
if (assembled.kind === "stale")
|
|
@@ -4,14 +4,14 @@ import { worktreeChangeId } from "../git/integration.js";
|
|
|
4
4
|
import { captureTender, dirtyTenderDelta, dirtyTenderRefusal } from "../git/tender.js";
|
|
5
5
|
import { observeContractsForAdmissionAt } from "../git/observe.js";
|
|
6
6
|
import { unmergedWorkspacePaths, worktreePath } from "../git/workspace.js";
|
|
7
|
-
import { externalPreparation, privateStateSeatAttempt, runBoundedAttempts, sameWorktreeWitness, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
|
|
7
|
+
import { externalPreparation, privateStateSeatAttempt, protocolSeatClose, runBoundedAttempts, sameWorktreeWitness, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
|
|
8
8
|
import { dependencyKeySet } from "../core/subject.js";
|
|
9
9
|
import { contractState } from "../core/facts/observation.js";
|
|
10
10
|
import { gate } from "../core/facts/types.js";
|
|
11
11
|
import { decideAttestation } from "../core/verbs/attestation.js";
|
|
12
12
|
import { admitDecidedOffer, mintAttempts } from "./attempt.js";
|
|
13
13
|
import { appointmentFor, readPlaceRegister } from "../workspace-place.js";
|
|
14
|
-
import {
|
|
14
|
+
import { timestamp } from "./operations.js";
|
|
15
15
|
const REVIEWED = gate("reviewed");
|
|
16
16
|
const reviewWorkspaceEvidenceSchema = workspaceDirtyDeltaSchema
|
|
17
17
|
.extend({ unmergedPaths: z.array(z.string().refine((value) => value.trim() !== "")).readonly() })
|
|
@@ -153,7 +153,7 @@ async function reviewAttempt(input, attempt) {
|
|
|
153
153
|
if (assembled.kind === "stale")
|
|
154
154
|
return STALE_PRIVATE_STATE_PREPARATION;
|
|
155
155
|
return await decideAndAdmitReview(input, attempt, seat, observation, assembled);
|
|
156
|
-
},
|
|
156
|
+
}, protocolSeatClose);
|
|
157
157
|
}
|
|
158
158
|
export async function admitReviewOperation(input) {
|
|
159
159
|
const result = await runBoundedAttempts(mintAttempts({ entryCount: 1 }), (attempt) => reviewAttempt(input, attempt));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { ProtocolProgress } from "./progress.js";
|
|
3
3
|
import { type GitDecisionObservation } from "../git/observe.js";
|
|
4
|
-
import { type PrivateStatePublicationSeat, type PrivateStateSeatOutcome } from "../git/private-state-seat.js";
|
|
4
|
+
import { type PrivateStatePublicationSeat, type PrivateStateSeatCloseLag, type PrivateStateSeatOutcome } from "../git/private-state-seat.js";
|
|
5
5
|
import type { GitDecodeChannel, GitTreeSelection } from "../git/read-observation.js";
|
|
6
6
|
import type { GitRepository } from "../git/process.js";
|
|
7
7
|
import { type GitRefAssertion } from "../git/repository.js";
|
|
@@ -177,6 +177,10 @@ export declare function externalPreparation<Artifacts>(input: Readonly<{
|
|
|
177
177
|
artifacts: Artifacts;
|
|
178
178
|
}>>;
|
|
179
179
|
export declare function privateStateSeatAttempt<T>(repository: GitRepository, action: (seat: PrivateStatePublicationSeat) => Promise<T>, wrap: (outcome: PrivateStateSeatOutcome<T>) => T): Promise<T | AttemptTerminal>;
|
|
180
|
+
export declare function protocolSeatClose<T extends Readonly<{
|
|
181
|
+
kind: string;
|
|
182
|
+
seatClose?: readonly PrivateStateSeatCloseLag[];
|
|
183
|
+
}>>(outcome: PrivateStateSeatOutcome<T>): T;
|
|
180
184
|
/** Form one decided offer without admitting or reinterpreting it. */
|
|
181
185
|
export declare function prepareProtocolAttempt<Input extends Readonly<{
|
|
182
186
|
contractId: ContractId;
|
|
@@ -122,7 +122,7 @@ async function admitDecidedProtocolOffer(admission, primaryContract, seat, decis
|
|
|
122
122
|
assertions: decided.assertions,
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
export function protocolSeatClose(outcome) {
|
|
126
126
|
return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
|
|
127
127
|
if (value.kind !== "accepted")
|
|
128
128
|
throw new Error(closeLag.diagnostic);
|
|
@@ -137,7 +137,7 @@ async function runDirectProtocolAttempt(input, attempt) {
|
|
|
137
137
|
input: input.input,
|
|
138
138
|
assertions: [],
|
|
139
139
|
});
|
|
140
|
-
},
|
|
140
|
+
}, protocolSeatClose);
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* One full attempt: repeatable preparation outside custody, then a single in-custody cycle of
|
|
@@ -160,7 +160,7 @@ async function runSplitProtocolAttempt(input, attempt) {
|
|
|
160
160
|
input: assembled.input,
|
|
161
161
|
assertions,
|
|
162
162
|
});
|
|
163
|
-
},
|
|
163
|
+
}, protocolSeatClose);
|
|
164
164
|
}
|
|
165
165
|
/** Form one decided offer without admitting or reinterpreting it. */
|
|
166
166
|
export async function prepareProtocolAttempt(input, baseAttempt) {
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HeldSqliteTransactionLock } from "../coordination/sqlite-transaction-lock.js";
|
|
2
2
|
import type { GitRepository } from "../git/process.js";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function settlementFencePath(repository: GitRepository,
|
|
5
|
-
export declare function
|
|
3
|
+
import type { DebtId } from "../debt/identity.js";
|
|
4
|
+
export declare function settlementFencePath(repository: GitRepository, debtId: DebtId): string;
|
|
5
|
+
export declare function acquireDebtSettlementFence(repository: GitRepository, debtId: DebtId): Promise<HeldSqliteTransactionLock>;
|
|
@@ -2,13 +2,13 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { acquireSqliteTransactionLock, } from "../coordination/sqlite-transaction-lock.js";
|
|
4
4
|
import { commonGitDirectory } from "../git/repository.js";
|
|
5
|
-
export function settlementFencePath(repository,
|
|
6
|
-
const locator = createHash("sha256").update(
|
|
5
|
+
export function settlementFencePath(repository, debtId) {
|
|
6
|
+
const locator = createHash("sha256").update(debtId).digest("hex");
|
|
7
7
|
return resolve(commonGitDirectory(repository), "keiyaku", "locks", "settlement", `${locator}.sqlite`);
|
|
8
8
|
}
|
|
9
|
-
export function
|
|
9
|
+
export function acquireDebtSettlementFence(repository, debtId) {
|
|
10
10
|
return acquireSqliteTransactionLock({
|
|
11
|
-
path: settlementFencePath(repository,
|
|
11
|
+
path: settlementFencePath(repository, debtId),
|
|
12
12
|
mode: "immediate",
|
|
13
13
|
});
|
|
14
14
|
}
|
|
@@ -4,31 +4,31 @@ import type { GitDecisionObservation } from "../git/observe.js";
|
|
|
4
4
|
import { type PrivateStatePublicationSeat } from "../git/private-state-seat.js";
|
|
5
5
|
import type { GitRepository } from "../git/process.js";
|
|
6
6
|
import { type GitDecodeChannel, type GitReadObservation, type GitTreeSelection } from "../git/read-observation.js";
|
|
7
|
-
import { type
|
|
8
|
-
export declare function
|
|
9
|
-
export type
|
|
7
|
+
import { type DebtId } from "../debt/identity.js";
|
|
8
|
+
export declare function debtHolderObservationSelection(): GitTreeSelection;
|
|
9
|
+
export type DebtHolder = Readonly<{
|
|
10
10
|
version: 1;
|
|
11
|
-
|
|
11
|
+
debtId: DebtId;
|
|
12
12
|
contractId: ContractId;
|
|
13
13
|
disposition: "held" | "released";
|
|
14
14
|
}>;
|
|
15
|
-
export type
|
|
16
|
-
export declare function
|
|
15
|
+
export type DebtHolderProjection = ReadonlyMap<ContractId, DebtHolder>;
|
|
16
|
+
export declare function claimDebtHolder(debtId: DebtId, owner: ContractId): TreeUpdate;
|
|
17
17
|
type AdmissionOutcome = Readonly<{
|
|
18
18
|
kind: string;
|
|
19
19
|
}>;
|
|
20
|
-
type
|
|
20
|
+
type DebtHolderAdmission<T extends AdmissionOutcome> = Readonly<{
|
|
21
21
|
kind: "completed";
|
|
22
22
|
result: T;
|
|
23
23
|
}> | Readonly<{
|
|
24
24
|
kind: "accepted-release-failed";
|
|
25
25
|
result: T;
|
|
26
|
-
|
|
26
|
+
debtId: DebtId;
|
|
27
27
|
diagnostic: string;
|
|
28
28
|
}>;
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
31
|
-
type
|
|
29
|
+
export declare function admitWithDebtHolderFence<T extends AdmissionOutcome>(repository: GitRepository, debtId: DebtId, action: () => T | Promise<T>): Promise<DebtHolderAdmission<T>>;
|
|
30
|
+
export declare function releaseDebtHolder(channel: GitDecodeChannel, observation: GitDecisionObservation, owner: ContractId): Promise<TreeUpdate | null>;
|
|
31
|
+
type DebtHolderReleasePublication = Readonly<{
|
|
32
32
|
kind: "released";
|
|
33
33
|
}> | Readonly<{
|
|
34
34
|
kind: "not-held";
|
|
@@ -37,9 +37,9 @@ type TaskHolderReleasePublication = Readonly<{
|
|
|
37
37
|
diagnostic: string;
|
|
38
38
|
}>;
|
|
39
39
|
/** Publish the released holder against the same frozen observation that decided the release. */
|
|
40
|
-
export declare function
|
|
41
|
-
export declare function
|
|
42
|
-
export declare function
|
|
43
|
-
export declare function
|
|
44
|
-
export declare function
|
|
40
|
+
export declare function publishDebtHolderRelease(repository: GitRepository, channel: GitDecodeChannel, observation: GitDecisionObservation, owner: ContractId, seat: PrivateStatePublicationSeat): Promise<DebtHolderReleasePublication>;
|
|
41
|
+
export declare function readDebtHolderProjectionFromDecision(channel: GitDecodeChannel, observation: GitDecisionObservation): Promise<DebtHolderProjection>;
|
|
42
|
+
export declare function releaseDebtHolderWithFence<T extends AdmissionOutcome>(repository: GitRepository, channel: GitDecodeChannel, owner: ContractId, action: () => T | Promise<T>): Promise<DebtHolderAdmission<T>>;
|
|
43
|
+
export declare function readDebtHoldersAt(observation: Pick<GitReadObservation, "snapshot" | "readBlobs">): Promise<readonly DebtHolder[]>;
|
|
44
|
+
export declare function readDebtHolderProjectionAt(observation: GitReadObservation): Promise<DebtHolderProjection>;
|
|
45
45
|
export {};
|