@astrosheep/keiyaku 4.5.11 → 4.5.13
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/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +135 -377
- package/build/integrations/pi/keiyaku.ts +11 -116
- package/build/src/akuma/akuma-errors.d.ts +1 -0
- package/build/src/akuma/akuma-errors.js +1 -0
- package/build/src/akuma/akuma-handle.d.ts +1 -0
- package/build/src/akuma/akuma-handle.js +6 -7
- package/build/src/akuma/akuma-product.d.ts +6 -8
- package/build/src/akuma/akuma-product.js +141 -57
- package/build/src/akuma/akuma.d.ts +5 -7
- package/build/src/akuma/akuma.js +1 -22
- package/build/src/akuma/archetype.d.ts +6 -5
- package/build/src/akuma/archetype.js +137 -38
- package/build/src/akuma/body.d.ts +5 -5
- package/build/src/akuma/body.js +223 -63
- package/build/src/akuma/call-input.d.ts +4 -0
- package/build/src/akuma/call-input.js +21 -0
- package/build/src/akuma/call-request.d.ts +5 -8
- package/build/src/akuma/call-request.js +28 -73
- package/build/src/akuma/fleet-execution.d.ts +26 -0
- package/build/src/akuma/fleet-execution.js +109 -0
- package/build/src/{library/fleet-result.d.ts → akuma/fleet-observation.d.ts} +13 -57
- package/build/src/{library/fleet-result.js → akuma/fleet-observation.js} +4 -25
- package/build/src/akuma/fleet-request.d.ts +122 -0
- package/build/src/akuma/fleet-request.js +168 -0
- package/build/src/akuma/heart/facts.d.ts +23 -0
- package/build/src/akuma/heart/facts.js +7 -0
- package/build/src/akuma/heart/index.d.ts +43 -4
- package/build/src/akuma/heart/index.js +107 -7
- package/build/src/akuma/heart/request-authority.d.ts +2 -0
- package/build/src/akuma/heart/request-authority.js +28 -3
- package/build/src/akuma/heart/request-rows.d.ts +2 -0
- package/build/src/akuma/heart/request-rows.js +24 -5
- package/build/src/akuma/heart/rows.d.ts +4 -1
- package/build/src/akuma/heart/rows.js +46 -19
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +28 -6
- package/build/src/akuma/heart/storage.d.ts +1 -1
- package/build/src/akuma/heart/tells.d.ts +29 -0
- package/build/src/akuma/heart/tells.js +136 -5
- package/build/src/akuma/heart/timeline.js +9 -3
- package/build/src/akuma/projection-read.js +36 -3
- package/build/src/akuma/projection.js +3 -4
- package/build/src/akuma/provider.d.ts +4 -0
- package/build/src/akuma/provider.js +56 -3
- package/build/src/akuma/providers/claude/index.js +3 -0
- package/build/src/akuma/providers/codex-app-server/index.js +14 -12
- package/build/src/akuma/providers/pi/index.js +7 -1
- package/build/src/akuma/publication.js +65 -49
- package/build/src/akuma/request-lifecycle.d.ts +5 -4
- package/build/src/akuma/request-lifecycle.js +29 -16
- package/build/src/akuma/request-rendezvous.d.ts +15 -12
- package/build/src/akuma/request-rendezvous.js +80 -51
- package/build/src/akuma/request-serve.d.ts +1 -2
- package/build/src/akuma/request-serve.js +94 -39
- package/build/src/akuma/request-wire.d.ts +57 -26
- package/build/src/akuma/request-wire.js +64 -25
- package/build/src/akuma/turn-drive.d.ts +5 -4
- package/build/src/akuma/turn-drive.js +27 -11
- package/build/src/akuma-body.d.ts +4 -6
- package/build/src/akuma-body.js +19 -17
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +14 -0
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +1 -0
- package/build/src/cli/commands/akuma-invoke.js +1 -25
- package/build/src/cli/commands/contract-help.d.ts +5 -2
- package/build/src/cli/commands/contract-help.js +62 -12
- package/build/src/cli/commands/contract-invoke.d.ts +5 -0
- package/build/src/cli/commands/contract-invoke.js +26 -1
- package/build/src/cli/commands/contract.js +50 -18
- package/build/src/cli/commands/task-invoke.js +10 -2
- package/build/src/cli/commands/task-query.js +3 -4
- package/build/src/cli/coordinates.d.ts +13 -0
- package/build/src/cli/coordinates.js +38 -24
- package/build/src/cli/draft.d.ts +1 -1
- package/build/src/cli/invoke.js +14 -1
- package/build/src/cli/render/akuma-activity.d.ts +0 -1
- package/build/src/cli/render/akuma-activity.js +5 -38
- package/build/src/cli/render/akuma.js +4 -1
- package/build/src/cli/render/audit.js +4 -1
- package/build/src/cli/render/catalog.js +13 -39
- package/build/src/cli/render/contract.js +4 -14
- package/build/src/cli/render/kanshi-akuma.js +3 -8
- package/build/src/cli/render/kanshi.js +8 -34
- package/build/src/cli/render/nuke.js +7 -3
- package/build/src/cli/render/receipt.d.ts +1 -0
- package/build/src/cli/render/receipt.js +8 -0
- package/build/src/cli/render/refusal.js +4 -3
- package/build/src/cli/render/task.js +4 -37
- package/build/src/cli/render/terminal.d.ts +2 -6
- package/build/src/cli/render/terminal.js +4 -9
- package/build/src/cli/result.d.ts +2 -1
- package/build/src/contract-guidance.js +13 -3
- package/build/src/contract-worktree.d.ts +1 -0
- package/build/src/contract-worktree.js +26 -2
- package/build/src/core/facts/codec.d.ts +2 -1
- package/build/src/core/facts/codec.js +3 -0
- package/build/src/core/facts/gate.d.ts +2 -1
- package/build/src/core/facts/gate.js +63 -0
- package/build/src/core/verbs/abandon.d.ts +2 -1
- package/build/src/core/verbs/abandon.js +16 -0
- package/build/src/core/verbs/amend.d.ts +2 -1
- package/build/src/core/verbs/amend.js +20 -0
- package/build/src/core/verbs/arc.d.ts +2 -1
- package/build/src/core/verbs/arc.js +16 -0
- package/build/src/core/verbs/attestation.d.ts +2 -1
- package/build/src/core/verbs/attestation.js +16 -0
- package/build/src/core/verbs/bind.d.ts +2 -1
- package/build/src/core/verbs/bind.js +16 -0
- package/build/src/core/verbs/deliver.d.ts +2 -1
- package/build/src/core/verbs/deliver.js +16 -0
- package/build/src/core/verbs/placement.d.ts +2 -1
- package/build/src/core/verbs/placement.js +58 -1
- package/build/src/dispatch/association.d.ts +13 -0
- package/build/src/dispatch/association.js +20 -0
- package/build/src/dispatch/index.d.ts +6 -0
- package/build/src/dispatch/index.js +27 -3
- package/build/src/git/hooks.d.ts +9 -1
- package/build/src/git/hooks.js +79 -1
- package/build/src/git/nuke.d.ts +2 -1
- package/build/src/git/nuke.js +6 -11
- package/build/src/git/private-state-seat.d.ts +26 -1
- package/build/src/git/private-state-seat.js +78 -13
- package/build/src/git/process.d.ts +2 -0
- package/build/src/git/reconcile.d.ts +1 -2
- package/build/src/git/reconcile.js +0 -6
- package/build/src/git/repository.d.ts +0 -2
- package/build/src/git/repository.js +27 -25
- package/build/src/git/result-codec.d.ts +29 -0
- package/build/src/git/result-codec.js +306 -0
- package/build/src/git/target-placement.js +2 -8
- package/build/src/git/workspace.d.ts +2 -0
- package/build/src/git/workspace.js +4 -0
- package/build/src/index.d.ts +1 -0
- package/build/src/kanshi/fleet.js +1 -1
- package/build/src/kanshi/read.js +55 -28
- package/build/src/kanshi/report.d.ts +4 -3
- package/build/src/kanshi/select.js +14 -1
- package/build/src/library/address.d.ts +1 -0
- package/build/src/library/address.js +4 -7
- package/build/src/library/akuma-creation.d.ts +5 -3
- package/build/src/library/akuma-creation.js +90 -33
- package/build/src/library/audit.js +2 -1
- package/build/src/library/catalog.d.ts +10 -2
- package/build/src/library/catalog.js +65 -25
- package/build/src/library/composition.d.ts +1 -0
- package/build/src/library/composition.js +1 -0
- package/build/src/library/configuration.d.ts +4 -21
- package/build/src/library/configuration.js +2 -158
- package/build/src/library/continuation.d.ts +20 -1
- package/build/src/library/continuation.js +36 -0
- package/build/src/library/contract-bind.d.ts +1 -0
- package/build/src/library/contract-bind.js +16 -5
- package/build/src/library/contract-forwarding.d.ts +2 -2
- package/build/src/library/contract-forwarding.js +18 -4
- package/build/src/library/contract-handle.js +4 -3
- package/build/src/library/contract-operations.d.ts +5 -9
- package/build/src/library/contract-operations.js +34 -47
- package/build/src/library/contract.d.ts +11 -2
- package/build/src/library/contract.js +21 -1
- package/build/src/library/delivery.d.ts +4 -1
- package/build/src/library/delivery.js +47 -0
- package/build/src/library/fleet.d.ts +4 -136
- package/build/src/library/fleet.js +31 -315
- package/build/src/library/keiyaku.d.ts +7 -3
- package/build/src/library/keiyaku.js +1 -0
- package/build/src/library/mutation.d.ts +431 -3
- package/build/src/library/mutation.js +192 -19
- package/build/src/library/nuke.d.ts +7 -1
- package/build/src/library/nuke.js +18 -4
- package/build/src/library/reconcile.d.ts +14 -0
- package/build/src/library/reconcile.js +22 -8
- package/build/src/library/refusal.d.ts +9 -1
- package/build/src/library/refusal.js +76 -0
- package/build/src/library/region.d.ts +0 -8
- package/build/src/library/region.js +1 -29
- package/build/src/library/result-codec.d.ts +2 -0
- package/build/src/library/result-codec.js +12 -0
- package/build/src/markdown/lex.js +9 -2
- package/build/src/markdown/types.d.ts +2 -1
- package/build/src/markdown/types.js +3 -1
- package/build/src/plugin/akuma-signals.d.ts +12 -0
- package/build/src/plugin/akuma-signals.js +14 -0
- package/build/src/plugin/public.d.ts +51 -0
- package/build/src/plugin/public.js +1 -0
- package/build/src/plugin/runtime.d.ts +14 -0
- package/build/src/plugin/runtime.js +357 -0
- package/build/src/protocol/amend.js +3 -3
- package/build/src/protocol/attempt.d.ts +2 -1
- package/build/src/protocol/attempt.js +1 -1
- package/build/src/protocol/audit.d.ts +1 -1
- package/build/src/protocol/audit.js +1 -1
- package/build/src/protocol/bind.d.ts +3 -1
- package/build/src/protocol/bind.js +26 -0
- package/build/src/protocol/completion.js +0 -1
- package/build/src/protocol/deliver.d.ts +1 -1
- package/build/src/protocol/deliver.js +136 -57
- package/build/src/protocol/intent.d.ts +0 -1
- package/build/src/protocol/intent.js +0 -1
- package/build/src/protocol/operations.d.ts +9 -2
- package/build/src/protocol/operations.js +16 -1
- package/build/src/protocol/outcome.d.ts +3 -0
- package/build/src/protocol/outcome.js +17 -1
- package/build/src/protocol/placement.js +10 -3
- package/build/src/protocol/read/status.d.ts +8 -0
- package/build/src/protocol/read/status.js +49 -0
- package/build/src/protocol/reintegrate.js +10 -3
- package/build/src/protocol/result-codec.d.ts +22 -0
- package/build/src/protocol/result-codec.js +442 -0
- package/build/src/protocol/review.d.ts +1 -1
- package/build/src/protocol/review.js +81 -46
- package/build/src/protocol/run.d.ts +22 -2
- package/build/src/protocol/run.js +119 -29
- package/build/src/runtime/proc/lifecycle.js +1 -1
- package/build/src/runtime/proc/line-rpc.d.ts +7 -1
- package/build/src/runtime/proc/line-rpc.js +49 -9
- package/build/src/runtime/proc/run.d.ts +0 -1
- package/build/src/runtime/proc/run.js +1 -11
- package/build/src/runtime/proc/termination.d.ts +1 -0
- package/build/src/runtime/proc/termination.js +63 -18
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +10 -0
- package/build/src/settings.js +88 -2
- package/build/src/settlement/result-codec.d.ts +2 -0
- package/build/src/settlement/result-codec.js +56 -0
- package/build/src/settlement/settle.d.ts +5 -12
- package/build/src/settlement/settle.js +60 -55
- package/build/src/task/board.d.ts +3 -0
- package/build/src/task/board.js +22 -4
- package/build/src/task/catalog.d.ts +13 -2
- package/build/src/task/catalog.js +59 -5
- package/build/src/task/compose.d.ts +4 -2
- package/build/src/task/compose.js +56 -30
- package/build/src/task/created-observation.d.ts +39 -0
- package/build/src/task/created-observation.js +26 -0
- package/build/src/task/identity.d.ts +6 -0
- package/build/src/task/identity.js +48 -7
- package/build/src/task/index.d.ts +4 -3
- package/build/src/task/index.js +19 -16
- package/build/src/task/input.d.ts +3 -1
- package/build/src/task/input.js +7 -4
- package/build/src/task/lifecycle-operations.d.ts +6 -0
- package/build/src/task/lifecycle-operations.js +116 -0
- package/build/src/task/mutation-result.d.ts +762 -20
- package/build/src/task/mutation-result.js +34 -9
- package/build/src/task/mutation.d.ts +4 -9
- package/build/src/task/mutation.js +17 -52
- package/build/src/task/operation-types.d.ts +114 -0
- package/build/src/task/operation-types.js +1 -0
- package/build/src/task/operations.d.ts +6 -113
- package/build/src/task/operations.js +75 -117
- package/build/src/task/query.d.ts +8 -11
- package/build/src/task/query.js +7 -14
- package/build/src/task/store.d.ts +11 -1
- package/build/src/task/store.js +169 -55
- package/build/src/task/view.d.ts +4 -0
- package/build/src/task/view.js +7 -0
- package/build/src/verification/declaration.d.ts +1 -0
- package/build/src/verification/declaration.js +18 -1
- package/build/src/verification/execution.d.ts +0 -1
- package/build/src/verification/execution.js +5 -5
- package/build/src/world.d.ts +0 -2
- package/build/src/world.js +3 -7
- package/package.json +17 -5
- package/build/src/cli/square-edge.d.ts +0 -7
- package/build/src/cli/square-edge.js +0 -159
- package/build/src/git/ref-migration.d.ts +0 -22
- package/build/src/git/ref-migration.js +0 -55
- package/build/src/library/contract-forwarding-reconciliation-result.d.ts +0 -102
- package/build/src/library/contract-forwarding-reconciliation-result.js +0 -92
- package/build/src/library/contract-forwarding-result.d.ts +0 -4270
- package/build/src/library/contract-forwarding-result.js +0 -521
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { changeId, contractId, entryUlid, snapshotId } from "../core/facts/types.js";
|
|
2
|
+
import { decodeDeliverData } from "../core/facts/codec.js";
|
|
3
|
+
import { decodeAbandonRefusal } from "../core/verbs/abandon.js";
|
|
4
|
+
import { decodeAmendRefusal } from "../core/verbs/amend.js";
|
|
5
|
+
import { decodeArcRefusal } from "../core/verbs/arc.js";
|
|
6
|
+
import { decodeAttestationRefusal } from "../core/verbs/attestation.js";
|
|
7
|
+
import { decodeBindRefusal } from "../core/verbs/bind.js";
|
|
8
|
+
import { decodeDeliverRefusal } from "../core/verbs/deliver.js";
|
|
9
|
+
import { decodePlacementRefusal } from "../core/verbs/placement.js";
|
|
10
|
+
import { decodeAuditTargetAnswer, decodeCheckoutNotFollowableRefusal, decodeDirtyWorkspaceRefusal, decodeHookFailure, decodeIntegrationPreparationRefusal, decodePublicationFailed, decodeUnmergedPathsRefusal, decodeWorktreeLeak, decodeWorktreeMissingRefusal, decodeWorktreeWorkspace, decodeWorkspaceDirtyDelta, } from "../git/result-codec.js";
|
|
11
|
+
import { decodeVerificationDeclarationRefusal } from "../verification/declaration.js";
|
|
12
|
+
import { decodeForkSourceMovedRefusal, decodeTargetInputRefusal } from "./bind.js";
|
|
13
|
+
function fail() {
|
|
14
|
+
throw new Error("malformed protocol result");
|
|
15
|
+
}
|
|
16
|
+
function record(value, required, optional = []) {
|
|
17
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
18
|
+
fail();
|
|
19
|
+
const object = value;
|
|
20
|
+
const allowed = new Set([...required, ...optional]);
|
|
21
|
+
for (const key of Object.keys(object))
|
|
22
|
+
if (!allowed.has(key))
|
|
23
|
+
fail();
|
|
24
|
+
for (const key of required)
|
|
25
|
+
if (!(key in object))
|
|
26
|
+
fail();
|
|
27
|
+
return object;
|
|
28
|
+
}
|
|
29
|
+
function nonblank(value) {
|
|
30
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
31
|
+
fail();
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
function integer(value) {
|
|
35
|
+
if (typeof value !== "number" || !Number.isInteger(value))
|
|
36
|
+
fail();
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
function boolean(value) {
|
|
40
|
+
if (typeof value !== "boolean")
|
|
41
|
+
fail();
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
function strings(value) {
|
|
45
|
+
if (!Array.isArray(value))
|
|
46
|
+
fail();
|
|
47
|
+
return value.map(nonblank);
|
|
48
|
+
}
|
|
49
|
+
function decodeContractId(value) {
|
|
50
|
+
try {
|
|
51
|
+
return contractId(nonblank(value));
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
fail();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function decodeSnapshotId(value) {
|
|
58
|
+
try {
|
|
59
|
+
return snapshotId(nonblank(value));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
fail();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function first(value, decoders) {
|
|
66
|
+
for (const decode of decoders) {
|
|
67
|
+
try {
|
|
68
|
+
return decode(value);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
fail();
|
|
75
|
+
}
|
|
76
|
+
export function decodeProtocolTerminal(value) {
|
|
77
|
+
const object = record(value, ["kind"], ["diagnostic"]);
|
|
78
|
+
if (object.kind === "exhausted" || object.kind === "collision") {
|
|
79
|
+
if ("diagnostic" in object)
|
|
80
|
+
fail();
|
|
81
|
+
return { kind: object.kind };
|
|
82
|
+
}
|
|
83
|
+
return decodePublicationFailed(value);
|
|
84
|
+
}
|
|
85
|
+
export function decodeMergeStatePresentRefusal(value) {
|
|
86
|
+
const object = record(value, ["kind", "contractId", "workspace"]);
|
|
87
|
+
if (object.kind !== "merge-state-present")
|
|
88
|
+
fail();
|
|
89
|
+
return {
|
|
90
|
+
kind: "merge-state-present",
|
|
91
|
+
contractId: decodeContractId(object.contractId),
|
|
92
|
+
workspace: decodeWorktreeWorkspace(object.workspace),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function decodeDeliverConflictRefusal(value) {
|
|
96
|
+
const object = record(value, ["kind", "contractId", "reason", "targetHead", "conflictPaths", "recovery"]);
|
|
97
|
+
if (object.kind !== "integration-failed" || object.reason !== "conflict")
|
|
98
|
+
fail();
|
|
99
|
+
const recovery = record(object.recovery, ["materialize", "continue"]);
|
|
100
|
+
if (recovery.materialize !== "deliver --materialize-conflict --include-dirty")
|
|
101
|
+
fail();
|
|
102
|
+
if (recovery.continue !== "deliver --include-dirty")
|
|
103
|
+
fail();
|
|
104
|
+
return {
|
|
105
|
+
kind: "integration-failed",
|
|
106
|
+
contractId: decodeContractId(object.contractId),
|
|
107
|
+
reason: "conflict",
|
|
108
|
+
targetHead: decodeSnapshotId(object.targetHead),
|
|
109
|
+
conflictPaths: strings(object.conflictPaths),
|
|
110
|
+
recovery: {
|
|
111
|
+
materialize: "deliver --materialize-conflict --include-dirty",
|
|
112
|
+
continue: "deliver --include-dirty",
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function decodeTargetMissingRefusal(value) {
|
|
117
|
+
const object = record(value, ["kind", "contractId"]);
|
|
118
|
+
if (object.kind !== "target-missing")
|
|
119
|
+
fail();
|
|
120
|
+
return { kind: "target-missing", contractId: decodeContractId(object.contractId) };
|
|
121
|
+
}
|
|
122
|
+
export function decodeDeliveryPreparationRefusal(value) {
|
|
123
|
+
return first(value, [
|
|
124
|
+
decodeTargetMissingRefusal,
|
|
125
|
+
decodeWorktreeMissingRefusal,
|
|
126
|
+
decodeDirtyWorkspaceRefusal,
|
|
127
|
+
decodeUnmergedPathsRefusal,
|
|
128
|
+
decodeIntegrationPreparationRefusal,
|
|
129
|
+
decodeMergeStatePresentRefusal,
|
|
130
|
+
decodeCheckoutNotFollowableRefusal,
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
export function decodeIntentRefusal(value) {
|
|
134
|
+
return first(value, [
|
|
135
|
+
decodeAbandonRefusal,
|
|
136
|
+
decodeAmendRefusal,
|
|
137
|
+
decodeArcRefusal,
|
|
138
|
+
decodeBindRefusal,
|
|
139
|
+
decodeForkSourceMovedRefusal,
|
|
140
|
+
decodeDeliverRefusal,
|
|
141
|
+
decodeDeliveryPreparationRefusal,
|
|
142
|
+
decodeDeliverConflictRefusal,
|
|
143
|
+
decodePlacementRefusal,
|
|
144
|
+
decodeAttestationRefusal,
|
|
145
|
+
decodeTargetInputRefusal,
|
|
146
|
+
decodeVerificationDeclarationRefusal,
|
|
147
|
+
]);
|
|
148
|
+
}
|
|
149
|
+
export function decodeVerificationRuntimeStop(value) {
|
|
150
|
+
const object = record(value, ["failure"], ["diagnostic", "command", "detail"]);
|
|
151
|
+
if (object.failure === "unknown-exit" || object.failure === "cancelled") {
|
|
152
|
+
if ("diagnostic" in object || "command" in object || "detail" in object)
|
|
153
|
+
fail();
|
|
154
|
+
return { failure: object.failure };
|
|
155
|
+
}
|
|
156
|
+
if (object.failure === "candidate-unavailable" || object.failure === "spawn-error") {
|
|
157
|
+
if ("command" in object || "detail" in object)
|
|
158
|
+
fail();
|
|
159
|
+
return { failure: object.failure, diagnostic: nonblank(object.diagnostic) };
|
|
160
|
+
}
|
|
161
|
+
if (object.failure !== "environment-failure")
|
|
162
|
+
fail();
|
|
163
|
+
if ("command" in object || "detail" in object) {
|
|
164
|
+
if ("diagnostic" in object)
|
|
165
|
+
fail();
|
|
166
|
+
return {
|
|
167
|
+
failure: "environment-failure",
|
|
168
|
+
command: integer(object.command),
|
|
169
|
+
detail: decodeHookFailure(object.detail),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return { failure: "environment-failure", diagnostic: nonblank(object.diagnostic) };
|
|
173
|
+
}
|
|
174
|
+
function decodeVerificationStepRefusal(value) {
|
|
175
|
+
const object = record(value, ["refusal"]);
|
|
176
|
+
return {
|
|
177
|
+
refusal: first(object.refusal, [decodeAttestationRefusal, decodeVerificationDeclarationRefusal]),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function decodeVerificationStepRetry(value) {
|
|
181
|
+
const object = record(value, ["retry"]);
|
|
182
|
+
return { retry: decodeProtocolTerminal(object.retry) };
|
|
183
|
+
}
|
|
184
|
+
export function decodeVerificationStop(value) {
|
|
185
|
+
return first(value, [decodeVerificationStepRefusal, decodeVerificationStepRetry, decodeVerificationRuntimeStop]);
|
|
186
|
+
}
|
|
187
|
+
export function decodeVerificationReuse(value) {
|
|
188
|
+
const object = record(value, ["entry", "verdict"], ["summary"]);
|
|
189
|
+
if (object.verdict !== "satisfied" && object.verdict !== "unsatisfied")
|
|
190
|
+
fail();
|
|
191
|
+
let entry;
|
|
192
|
+
try {
|
|
193
|
+
entry = entryUlid(nonblank(object.entry));
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
fail();
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
entry,
|
|
200
|
+
verdict: object.verdict,
|
|
201
|
+
...(object.summary === undefined ? {} : { summary: typeof object.summary === "string" ? object.summary : fail() }),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function decodePlacementStepRefusal(value) {
|
|
205
|
+
return first(value, [
|
|
206
|
+
decodePlacementRefusal,
|
|
207
|
+
decodeCheckoutNotFollowableRefusal,
|
|
208
|
+
decodeIntegrationPreparationRefusal,
|
|
209
|
+
decodeTargetMissingRefusal,
|
|
210
|
+
]);
|
|
211
|
+
}
|
|
212
|
+
function decodePlacementRefusalStop(value) {
|
|
213
|
+
const object = record(value, ["refusal"]);
|
|
214
|
+
return { refusal: decodePlacementStepRefusal(object.refusal) };
|
|
215
|
+
}
|
|
216
|
+
function decodePlacementRetryStop(value) {
|
|
217
|
+
const object = record(value, ["retry"]);
|
|
218
|
+
return { retry: decodeProtocolTerminal(object.retry) };
|
|
219
|
+
}
|
|
220
|
+
function decodeTargetPlacementFailedStop(value) {
|
|
221
|
+
const object = record(value, ["failure", "diagnostic"]);
|
|
222
|
+
if (object.failure !== "target-placement-failed")
|
|
223
|
+
fail();
|
|
224
|
+
return { failure: "target-placement-failed", diagnostic: nonblank(object.diagnostic) };
|
|
225
|
+
}
|
|
226
|
+
function decodeTargetMovedWithAttemptsStop(value) {
|
|
227
|
+
const object = record(value, [
|
|
228
|
+
"failure",
|
|
229
|
+
"contractId",
|
|
230
|
+
"target",
|
|
231
|
+
"integratedAt",
|
|
232
|
+
"observed",
|
|
233
|
+
"attempts",
|
|
234
|
+
"observedTreeEqualsCandidate",
|
|
235
|
+
]);
|
|
236
|
+
if (object.failure !== "target-moved")
|
|
237
|
+
fail();
|
|
238
|
+
return {
|
|
239
|
+
failure: "target-moved",
|
|
240
|
+
contractId: decodeContractId(object.contractId),
|
|
241
|
+
target: nonblank(object.target),
|
|
242
|
+
integratedAt: decodeSnapshotId(object.integratedAt),
|
|
243
|
+
observed: object.observed === null ? null : decodeSnapshotId(object.observed),
|
|
244
|
+
attempts: integer(object.attempts),
|
|
245
|
+
observedTreeEqualsCandidate: boolean(object.observedTreeEqualsCandidate),
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function decodeTargetMovedExpectedStop(value) {
|
|
249
|
+
const object = record(value, [
|
|
250
|
+
"failure",
|
|
251
|
+
"contractId",
|
|
252
|
+
"target",
|
|
253
|
+
"expected",
|
|
254
|
+
"observed",
|
|
255
|
+
"observedTreeEqualsCandidate",
|
|
256
|
+
]);
|
|
257
|
+
if (object.failure !== "target-moved")
|
|
258
|
+
fail();
|
|
259
|
+
return {
|
|
260
|
+
failure: "target-moved",
|
|
261
|
+
contractId: decodeContractId(object.contractId),
|
|
262
|
+
target: nonblank(object.target),
|
|
263
|
+
expected: decodeSnapshotId(object.expected),
|
|
264
|
+
observed: object.observed === null ? null : decodeSnapshotId(object.observed),
|
|
265
|
+
observedTreeEqualsCandidate: boolean(object.observedTreeEqualsCandidate),
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
export function decodePlacementStop(value) {
|
|
269
|
+
return first(value, [
|
|
270
|
+
decodePlacementRefusalStop,
|
|
271
|
+
decodePlacementRetryStop,
|
|
272
|
+
decodeTargetPlacementFailedStop,
|
|
273
|
+
decodeTargetMovedWithAttemptsStop,
|
|
274
|
+
decodeTargetMovedExpectedStop,
|
|
275
|
+
]);
|
|
276
|
+
}
|
|
277
|
+
export function decodeVerificationCleanupFailure(value) {
|
|
278
|
+
const object = record(value, ["phase", "command", "detail"]);
|
|
279
|
+
if (object.phase !== "destroy")
|
|
280
|
+
fail();
|
|
281
|
+
return { phase: "destroy", command: integer(object.command), detail: decodeHookFailure(object.detail) };
|
|
282
|
+
}
|
|
283
|
+
export function decodeCandidateCompletion(value) {
|
|
284
|
+
const object = record(value, ["integration"], ["verification"]);
|
|
285
|
+
const completion = {
|
|
286
|
+
integration: decodeSnapshotId(object.integration),
|
|
287
|
+
...(object.verification === undefined
|
|
288
|
+
? {}
|
|
289
|
+
: {
|
|
290
|
+
verification: (() => {
|
|
291
|
+
const verification = record(object.verification, ["mode", "verdict"]);
|
|
292
|
+
if (verification.mode !== "ran" && verification.mode !== "reused")
|
|
293
|
+
fail();
|
|
294
|
+
if (verification.verdict !== "satisfied" && verification.verdict !== "unsatisfied")
|
|
295
|
+
fail();
|
|
296
|
+
return { mode: verification.mode, verdict: verification.verdict };
|
|
297
|
+
})(),
|
|
298
|
+
}),
|
|
299
|
+
};
|
|
300
|
+
return completion;
|
|
301
|
+
}
|
|
302
|
+
export function decodeCompletionEvidence(value) {
|
|
303
|
+
const object = record(value, [], ["completion", "verification", "verificationReuse", "verificationSummary", "placement", "cleanup", "leak"]);
|
|
304
|
+
return {
|
|
305
|
+
...(object.completion === undefined ? {} : { completion: decodeCandidateCompletion(object.completion) }),
|
|
306
|
+
...(object.verification === undefined ? {} : { verification: decodeVerificationStop(object.verification) }),
|
|
307
|
+
...(object.verificationReuse === undefined
|
|
308
|
+
? {}
|
|
309
|
+
: { verificationReuse: decodeVerificationReuse(object.verificationReuse) }),
|
|
310
|
+
...(object.verificationSummary === undefined ? {} : { verificationSummary: nonblank(object.verificationSummary) }),
|
|
311
|
+
...(object.placement === undefined ? {} : { placement: decodePlacementStop(object.placement) }),
|
|
312
|
+
...(object.cleanup === undefined ? {} : { cleanup: decodeVerificationCleanupFailure(object.cleanup) }),
|
|
313
|
+
...(object.leak === undefined ? {} : { leak: decodeWorktreeLeak(object.leak) }),
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
export function decodeMaterializedConflict(value) {
|
|
317
|
+
const object = record(value, ["kind", "targetHead", "conflictPaths", "workspace"]);
|
|
318
|
+
if (object.kind !== "integration-conflict-materialized")
|
|
319
|
+
fail();
|
|
320
|
+
return {
|
|
321
|
+
kind: "integration-conflict-materialized",
|
|
322
|
+
targetHead: decodeSnapshotId(object.targetHead),
|
|
323
|
+
conflictPaths: strings(object.conflictPaths),
|
|
324
|
+
workspace: decodeWorktreeWorkspace(object.workspace),
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function decodeAuditReadyCandidate(value) {
|
|
328
|
+
const object = record(value, ["kind", "workspace", "identity", "scope"], ["diff"]);
|
|
329
|
+
if (object.kind !== "ready")
|
|
330
|
+
fail();
|
|
331
|
+
const scope = record(object.scope, ["filesChanged", "insertions", "deletions"], ["paths"]);
|
|
332
|
+
return {
|
|
333
|
+
kind: "ready",
|
|
334
|
+
workspace: decodeWorktreeWorkspace(object.workspace),
|
|
335
|
+
identity: decodeDeliverData(object.identity),
|
|
336
|
+
scope: {
|
|
337
|
+
filesChanged: integer(scope.filesChanged),
|
|
338
|
+
insertions: integer(scope.insertions),
|
|
339
|
+
deletions: integer(scope.deletions),
|
|
340
|
+
...(scope.paths === undefined
|
|
341
|
+
? {}
|
|
342
|
+
: {
|
|
343
|
+
paths: Array.isArray(scope.paths)
|
|
344
|
+
? scope.paths.map((path) => (typeof path === "string" ? path : fail()))
|
|
345
|
+
: fail(),
|
|
346
|
+
}),
|
|
347
|
+
},
|
|
348
|
+
...(object.diff === undefined ? {} : { diff: typeof object.diff === "string" ? object.diff : fail() }),
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function decodeAuditBlockedCandidate(value) {
|
|
352
|
+
const object = record(value, ["kind", "refusal"]);
|
|
353
|
+
if (object.kind !== "blocked")
|
|
354
|
+
fail();
|
|
355
|
+
return { kind: "blocked", refusal: decodeDeliveryPreparationRefusal(object.refusal) };
|
|
356
|
+
}
|
|
357
|
+
function decodeAuditVerification(value) {
|
|
358
|
+
return first(value, [
|
|
359
|
+
(input) => {
|
|
360
|
+
const object = record(input, ["kind"]);
|
|
361
|
+
if (object.kind !== "not-run")
|
|
362
|
+
fail();
|
|
363
|
+
return { kind: "not-run" };
|
|
364
|
+
},
|
|
365
|
+
(input) => {
|
|
366
|
+
const object = record(input, ["kind", "stop"]);
|
|
367
|
+
if (object.kind !== "stopped")
|
|
368
|
+
fail();
|
|
369
|
+
return { kind: "stopped", stop: decodeVerificationStop(object.stop) };
|
|
370
|
+
},
|
|
371
|
+
(input) => {
|
|
372
|
+
const object = record(input, ["kind", "passed", "total"], ["summary"]);
|
|
373
|
+
if (object.kind !== "satisfied" && object.kind !== "unsatisfied")
|
|
374
|
+
fail();
|
|
375
|
+
return {
|
|
376
|
+
kind: object.kind,
|
|
377
|
+
passed: typeof object.passed === "number" ? object.passed : fail(),
|
|
378
|
+
total: typeof object.total === "number" ? object.total : fail(),
|
|
379
|
+
...(object.summary === undefined
|
|
380
|
+
? {}
|
|
381
|
+
: { summary: typeof object.summary === "string" ? object.summary : fail() }),
|
|
382
|
+
};
|
|
383
|
+
},
|
|
384
|
+
]);
|
|
385
|
+
}
|
|
386
|
+
function decodeNotObservedAuditTarget(value) {
|
|
387
|
+
const object = record(value, ["kind"]);
|
|
388
|
+
if (object.kind !== "not-observed")
|
|
389
|
+
fail();
|
|
390
|
+
return { kind: "not-observed" };
|
|
391
|
+
}
|
|
392
|
+
function decodeAuditTarget(value) {
|
|
393
|
+
return first(value, [decodeNotObservedAuditTarget, decodeAuditTargetAnswer]);
|
|
394
|
+
}
|
|
395
|
+
export function decodeAuditReport(value) {
|
|
396
|
+
const object = record(value, ["candidate", "verification", "target"], ["delivery"]);
|
|
397
|
+
return {
|
|
398
|
+
candidate: first(object.candidate, [decodeAuditBlockedCandidate, decodeAuditReadyCandidate]),
|
|
399
|
+
verification: decodeAuditVerification(object.verification),
|
|
400
|
+
target: decodeAuditTarget(object.target),
|
|
401
|
+
...(object.delivery === undefined
|
|
402
|
+
? {}
|
|
403
|
+
: {
|
|
404
|
+
delivery: (() => {
|
|
405
|
+
const delivery = record(object.delivery, ["changeId", "relation"]);
|
|
406
|
+
if (delivery.relation !== "identical" && delivery.relation !== "differs")
|
|
407
|
+
fail();
|
|
408
|
+
try {
|
|
409
|
+
return { changeId: changeId(nonblank(delivery.changeId)), relation: delivery.relation };
|
|
410
|
+
}
|
|
411
|
+
catch {
|
|
412
|
+
fail();
|
|
413
|
+
}
|
|
414
|
+
})(),
|
|
415
|
+
}),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
export function decodeReviewValue(value) {
|
|
419
|
+
const object = record(value, [], [
|
|
420
|
+
"completion",
|
|
421
|
+
"verification",
|
|
422
|
+
"verificationReuse",
|
|
423
|
+
"verificationSummary",
|
|
424
|
+
"placement",
|
|
425
|
+
"cleanup",
|
|
426
|
+
"leak",
|
|
427
|
+
"workspace",
|
|
428
|
+
]);
|
|
429
|
+
const evidence = decodeCompletionEvidence({
|
|
430
|
+
...(object.completion === undefined ? {} : { completion: object.completion }),
|
|
431
|
+
...(object.verification === undefined ? {} : { verification: object.verification }),
|
|
432
|
+
...(object.verificationReuse === undefined ? {} : { verificationReuse: object.verificationReuse }),
|
|
433
|
+
...(object.verificationSummary === undefined ? {} : { verificationSummary: object.verificationSummary }),
|
|
434
|
+
...(object.placement === undefined ? {} : { placement: object.placement }),
|
|
435
|
+
...(object.cleanup === undefined ? {} : { cleanup: object.cleanup }),
|
|
436
|
+
...(object.leak === undefined ? {} : { leak: object.leak }),
|
|
437
|
+
});
|
|
438
|
+
return {
|
|
439
|
+
...evidence,
|
|
440
|
+
...(object.workspace === undefined ? {} : { workspace: decodeWorkspaceDirtyDelta(object.workspace) }),
|
|
441
|
+
};
|
|
442
|
+
}
|
|
@@ -16,6 +16,7 @@ type ReviewOperationInput = MutationOperationInput & Readonly<{
|
|
|
16
16
|
export type ReviewValue = CompletionEvidence & Readonly<{
|
|
17
17
|
workspace?: WorkspaceDirtyDelta;
|
|
18
18
|
}>;
|
|
19
|
+
export { decodeReviewValue } from "./result-codec.js";
|
|
19
20
|
export declare function prepareReview(repository: RepositoryScope, stage: Readonly<{
|
|
20
21
|
contractId: import("../core/facts/types.js").ContractId;
|
|
21
22
|
coordinates: ContractState["coordinates"];
|
|
@@ -30,4 +31,3 @@ export declare function prepareReview(repository: RepositoryScope, stage: Readon
|
|
|
30
31
|
refusal: ReviewPreparationRefusal;
|
|
31
32
|
}>;
|
|
32
33
|
export declare function reviewOperation(input: ReviewOperationInput): Promise<IntentOutcome<ReviewValue, ReviewRefusal>>;
|
|
33
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { worktreeChangeId } from "../git/integration.js";
|
|
2
2
|
import { captureTender, dirtyTenderDelta, dirtyTenderRefusal, } from "../git/tender.js";
|
|
3
3
|
import { observeContractsForAdmissionAt } from "../git/observe.js";
|
|
4
|
-
import {
|
|
4
|
+
import { matchingPrivateRootObservation, privateStateSeatAttempt, sameSpeculativeWorktreeInput, } from "./run.js";
|
|
5
5
|
import { dependencyKeySet } from "../core/subject.js";
|
|
6
6
|
import { contractState } from "../core/facts/observation.js";
|
|
7
7
|
import { gate } from "../core/facts/types.js";
|
|
@@ -10,8 +10,9 @@ import { admitDecidedOffer, mintAttempts } from "./attempt.js";
|
|
|
10
10
|
import { admitted } from "./outcome.js";
|
|
11
11
|
import { completeCandidate } from "./completion.js";
|
|
12
12
|
import { appointmentFor, readPlaceRegister } from "../workspace-place.js";
|
|
13
|
-
import { timestamp } from "./operations.js";
|
|
13
|
+
import { attemptDecisionWithSeatClose, timestamp } from "./operations.js";
|
|
14
14
|
const REVIEWED = gate("reviewed");
|
|
15
|
+
export { decodeReviewValue } from "./result-codec.js";
|
|
15
16
|
async function captureReviewableWorktree(repository, stage) {
|
|
16
17
|
const appointed = stage.coordinates.workspace === "worktree"
|
|
17
18
|
? appointmentFor(await readPlaceRegister(repository), stage.contractId)
|
|
@@ -53,49 +54,66 @@ function reviewValue(value, completion = {}) {
|
|
|
53
54
|
...completion,
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
return
|
|
57
|
+
function preparedReviewCapture(input, state, prepared) {
|
|
58
|
+
return {
|
|
59
|
+
kind: "prepared",
|
|
60
|
+
data: {
|
|
61
|
+
gate: REVIEWED,
|
|
62
|
+
subject: dependencyKeySet([
|
|
63
|
+
{ kind: "document", value: state.terms.document.key },
|
|
64
|
+
{ kind: "change", value: prepared.data.changeId },
|
|
65
|
+
]),
|
|
66
|
+
verdict: input.verdict,
|
|
67
|
+
...(input.summary === undefined ? {} : { summary: input.summary }),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
58
70
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
workspace = prepared.data.workspace;
|
|
87
|
-
tender = prepared.data.tender;
|
|
88
|
-
}
|
|
71
|
+
function reviewWorktreeInput(prepared) {
|
|
72
|
+
return {
|
|
73
|
+
tree: prepared.data.tender.tree,
|
|
74
|
+
head: prepared.data.tender.head,
|
|
75
|
+
...(prepared.data.tender.mergeHead === undefined ? {} : { mergeHead: prepared.data.tender.mergeHead }),
|
|
76
|
+
dirty: prepared.data.tender.dirty,
|
|
77
|
+
changeId: prepared.data.changeId,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async function recaptureReviewWorktree(input, state) {
|
|
81
|
+
const prepared = await captureReviewableWorktree(input.scope, {
|
|
82
|
+
contractId: state.id,
|
|
83
|
+
coordinates: state.coordinates,
|
|
84
|
+
});
|
|
85
|
+
return prepared.kind === "prepared" ? reviewWorktreeInput(prepared) : undefined;
|
|
86
|
+
}
|
|
87
|
+
async function speculateReview(input) {
|
|
88
|
+
const observation = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
|
|
89
|
+
const state = contractState(observation.decision, input.contractId);
|
|
90
|
+
if (state === null)
|
|
91
|
+
return { observation };
|
|
92
|
+
const prepared = await captureReviewableWorktree(input.scope, {
|
|
93
|
+
contractId: state.id,
|
|
94
|
+
coordinates: state.coordinates,
|
|
95
|
+
});
|
|
96
|
+
if (prepared.kind === "refused") {
|
|
97
|
+
return { observation, preparation: { kind: "refused", refusal: prepared.refusal } };
|
|
89
98
|
}
|
|
99
|
+
return {
|
|
100
|
+
observation,
|
|
101
|
+
preparation: preparedReviewCapture(input, state, prepared),
|
|
102
|
+
...(prepared.data.workspace === undefined ? {} : { workspace: prepared.data.workspace }),
|
|
103
|
+
tender: prepared.data.tender,
|
|
104
|
+
worktree: reviewWorktreeInput(prepared),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async function decideAndAdmitReview(input, attempt, seat, observation, speculated) {
|
|
90
108
|
const decision = decideAttestation({
|
|
91
109
|
input: {
|
|
92
110
|
contractId: input.contractId,
|
|
93
111
|
...(input.actor === undefined ? {} : { actor: input.actor }),
|
|
94
112
|
at: timestamp(),
|
|
95
|
-
...(preparation === undefined ? {} : { preparation }),
|
|
113
|
+
...(speculated.preparation === undefined ? {} : { preparation: speculated.preparation }),
|
|
96
114
|
},
|
|
97
115
|
attempt,
|
|
98
|
-
observation:
|
|
116
|
+
observation: observation.decision,
|
|
99
117
|
});
|
|
100
118
|
if (decision.kind === "refused")
|
|
101
119
|
return { kind: "refused", refusal: decision.refusal };
|
|
@@ -103,20 +121,37 @@ async function reviewAttemptInPrivateStateSeat(input, attempt, seat) {
|
|
|
103
121
|
channel: input.channel,
|
|
104
122
|
repository: input.scope,
|
|
105
123
|
seat,
|
|
106
|
-
decisionObservation,
|
|
124
|
+
decisionObservation: observation,
|
|
107
125
|
attempt,
|
|
108
126
|
offer: decision.offer,
|
|
109
127
|
primaryContract: input.contractId,
|
|
110
128
|
});
|
|
111
|
-
if (admission.kind
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
}
|
|
119
|
-
|
|
129
|
+
if (admission.kind !== "accepted")
|
|
130
|
+
return admission;
|
|
131
|
+
return {
|
|
132
|
+
...admission,
|
|
133
|
+
value: {
|
|
134
|
+
...(speculated.workspace === undefined ? {} : { workspace: speculated.workspace }),
|
|
135
|
+
...(speculated.tender === undefined ? {} : { tender: speculated.tender }),
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
async function reviewAttemptInPrivateStateSeat(input, attempt, seat, speculated) {
|
|
140
|
+
const observation = await matchingPrivateRootObservation(input.scope, input.channel, input.contractId, speculated.observation, async (fresh) => {
|
|
141
|
+
if (speculated.worktree === undefined)
|
|
142
|
+
return true;
|
|
143
|
+
const state = contractState(fresh.decision, input.contractId);
|
|
144
|
+
if (state === null)
|
|
145
|
+
return false;
|
|
146
|
+
return sameSpeculativeWorktreeInput(speculated.worktree, await recaptureReviewWorktree(input, state));
|
|
147
|
+
});
|
|
148
|
+
return "kind" in observation
|
|
149
|
+
? observation
|
|
150
|
+
: await decideAndAdmitReview(input, attempt, seat, observation, speculated);
|
|
151
|
+
}
|
|
152
|
+
async function reviewAttempt(input, attempt) {
|
|
153
|
+
const speculated = await speculateReview(input);
|
|
154
|
+
return await privateStateSeatAttempt(input.scope, async (seat) => await reviewAttemptInPrivateStateSeat(input, attempt, seat, speculated), attemptDecisionWithSeatClose);
|
|
120
155
|
}
|
|
121
156
|
export async function reviewOperation(input) {
|
|
122
157
|
const git = input.scope;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { type GitDecisionObservation } from "../git/observe.js";
|
|
2
|
+
import { type PrivateStatePublicationSeat, type PrivateStateSeatOutcome } from "../git/private-state-seat.js";
|
|
2
3
|
import type { GitDecodeChannel, GitTreeSelection } from "../git/read-observation.js";
|
|
3
4
|
import type { GitRepository } from "../git/process.js";
|
|
4
|
-
import type
|
|
5
|
+
import { type GitOid, type GitRefAssertion } from "../git/repository.js";
|
|
5
6
|
import type { AttemptContext, DecideInput, OfferDecision } from "../core/decide.js";
|
|
6
7
|
import type { Offer, TreeUpdate } from "../core/facts/offer.js";
|
|
7
|
-
import { type ContractId } from "../core/facts/types.js";
|
|
8
|
+
import { type ChangeId, type ContractId, type SnapshotId } from "../core/facts/types.js";
|
|
8
9
|
import { type AcceptedAdmission, type AttemptTerminal } from "./attempt.js";
|
|
10
|
+
import type { GitObjectId } from "../git/identity.js";
|
|
11
|
+
export declare const STALE_PRIVATE_STATE_PREPARATION: {
|
|
12
|
+
readonly kind: "publication-failed";
|
|
13
|
+
readonly diagnostic: "stale private-state preparation";
|
|
14
|
+
};
|
|
9
15
|
export type ProtocolTerminal = Readonly<{
|
|
10
16
|
kind: "exhausted";
|
|
11
17
|
}> | AttemptTerminal;
|
|
@@ -68,6 +74,20 @@ export type PreparedProtocolAttempt<Refusal> = Readonly<{
|
|
|
68
74
|
offer: Offer;
|
|
69
75
|
assertions: readonly GitRefAssertion[];
|
|
70
76
|
}>;
|
|
77
|
+
export declare function privateRootCommit(observation: GitDecisionObservation): GitOid | null;
|
|
78
|
+
export declare function samePrivateRootObservation(prepared: GitDecisionObservation, fresh: GitDecisionObservation): boolean;
|
|
79
|
+
export type SpeculativeWorktreeInput = Readonly<{
|
|
80
|
+
tree: GitObjectId;
|
|
81
|
+
head: SnapshotId;
|
|
82
|
+
mergeHead?: SnapshotId;
|
|
83
|
+
dirty: boolean;
|
|
84
|
+
changeId: ChangeId;
|
|
85
|
+
}>;
|
|
86
|
+
export declare function sameSpeculativeWorktreeInput(prepared: SpeculativeWorktreeInput | undefined, fresh: SpeculativeWorktreeInput | undefined): boolean;
|
|
87
|
+
export declare function privateStateAssertionsMatch(repository: GitRepository, assertions: readonly GitRefAssertion[]): Promise<boolean>;
|
|
88
|
+
export declare function publicationFailedFromSeatError(error: unknown): AttemptTerminal;
|
|
89
|
+
export declare function matchingPrivateRootObservation(repository: GitRepository, channel: GitDecodeChannel, contractId: ContractId, prepared: GitDecisionObservation, revalidate?: (fresh: GitDecisionObservation) => boolean | Promise<boolean>): Promise<GitDecisionObservation | typeof STALE_PRIVATE_STATE_PREPARATION>;
|
|
90
|
+
export declare function privateStateSeatAttempt<T>(repository: GitRepository, action: (seat: PrivateStatePublicationSeat) => Promise<T>, wrap: (outcome: PrivateStateSeatOutcome<T>) => T): Promise<T | AttemptTerminal>;
|
|
71
91
|
/** Form one decided offer without admitting or reinterpreting it. */
|
|
72
92
|
export declare function prepareProtocolAttempt<Input extends Readonly<{
|
|
73
93
|
contractId: ContractId;
|