@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
|
@@ -1,521 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-lines -- Contract owns one coherent forwarded result boundary. */
|
|
2
|
-
import { decodeJournalEntry } from "../core/facts/codec.js";
|
|
3
|
-
import { changeId, contractHead, contractId, entryUlid, gate, snapshotId } from "../core/facts/types.js";
|
|
4
|
-
import { formatTaskId, parseTaskId } from "../task/identity.js";
|
|
5
|
-
import { KeiyakuRefused, KeiyakuRetry } from "./refusal.js";
|
|
6
|
-
import { reconciliationLagSchema } from "./contract-forwarding-reconciliation-result.js";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
function canonical(decode, message) {
|
|
9
|
-
return z.string().transform((value, context) => {
|
|
10
|
-
try {
|
|
11
|
-
return decode(value);
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
context.addIssue({ code: "custom", message });
|
|
15
|
-
return z.NEVER;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function withoutUndefined(value, optional) {
|
|
20
|
-
const result = { ...value };
|
|
21
|
-
for (const key of optional) {
|
|
22
|
-
const field = result[key];
|
|
23
|
-
delete result[key];
|
|
24
|
-
if (field !== undefined)
|
|
25
|
-
result[key] = field;
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
const nonblankStringSchema = z.string().refine((value) => value.trim() !== "");
|
|
30
|
-
const contractIdSchema = canonical(contractId, "expected ContractId");
|
|
31
|
-
const contractHeadSchema = canonical(contractHead, "expected ContractHead");
|
|
32
|
-
const snapshotIdSchema = canonical(snapshotId, "expected SnapshotId");
|
|
33
|
-
const changeIdSchema = canonical(changeId, "expected ChangeId");
|
|
34
|
-
const taskIdSchema = z.string().transform((value, context) => {
|
|
35
|
-
try {
|
|
36
|
-
const id = formatTaskId(parseTaskId(value));
|
|
37
|
-
if (id !== value)
|
|
38
|
-
throw new Error("not canonical");
|
|
39
|
-
return id;
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
context.addIssue({ code: "custom", message: "expected canonical TaskId" });
|
|
43
|
-
return z.NEVER;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const journalFactSchema = z.unknown().transform((value, context) => {
|
|
47
|
-
try {
|
|
48
|
-
return decodeJournalEntry(value);
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
context.addIssue({ code: "custom", message: "expected journal entry" });
|
|
52
|
-
return z.NEVER;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const settlementLagSchema = z
|
|
56
|
-
.object({
|
|
57
|
-
kind: z.literal("settlement-failed"),
|
|
58
|
-
surface: z.enum(["task-holder", "task", "namespace-context"]),
|
|
59
|
-
contractId: contractIdSchema,
|
|
60
|
-
taskId: taskIdSchema.optional(),
|
|
61
|
-
path: nonblankStringSchema.optional(),
|
|
62
|
-
diagnostic: nonblankStringSchema,
|
|
63
|
-
})
|
|
64
|
-
.strict()
|
|
65
|
-
.transform((lag) => withoutUndefined(lag, ["taskId", "path"]));
|
|
66
|
-
const completionSchema = z
|
|
67
|
-
.object({
|
|
68
|
-
integration: snapshotIdSchema,
|
|
69
|
-
verification: z
|
|
70
|
-
.object({ mode: z.enum(["ran", "reused"]), verdict: z.enum(["satisfied", "unsatisfied"]) })
|
|
71
|
-
.strict()
|
|
72
|
-
.optional(),
|
|
73
|
-
})
|
|
74
|
-
.strict()
|
|
75
|
-
.transform((completion) => withoutUndefined(completion, ["verification"]));
|
|
76
|
-
const integrationSchema = z
|
|
77
|
-
.object({ predecessor: snapshotIdSchema, snapshot: snapshotIdSchema, changeId: changeIdSchema })
|
|
78
|
-
.strict();
|
|
79
|
-
const policySchema = z.object({ requireBranchesToBeUpToDate: z.boolean() }).strict();
|
|
80
|
-
const gateSchema = canonical(gate, "expected Gate");
|
|
81
|
-
const contractIdentityRefusalSchema = z
|
|
82
|
-
.object({
|
|
83
|
-
kind: z.enum([
|
|
84
|
-
"terminal",
|
|
85
|
-
"terms-moved",
|
|
86
|
-
"unknown-prerequisite",
|
|
87
|
-
"cyclic-prerequisite",
|
|
88
|
-
"document-moved",
|
|
89
|
-
"contract-exists",
|
|
90
|
-
"invalid-after",
|
|
91
|
-
"fork-source-moved",
|
|
92
|
-
"worktree-missing",
|
|
93
|
-
"target-missing",
|
|
94
|
-
"delivery-missing",
|
|
95
|
-
]),
|
|
96
|
-
contractId: contractIdSchema,
|
|
97
|
-
})
|
|
98
|
-
.strict();
|
|
99
|
-
const contractMissingRefusalSchema = z
|
|
100
|
-
.object({ kind: z.literal("contract-missing"), contractId: contractIdSchema })
|
|
101
|
-
.strict();
|
|
102
|
-
const targetInputRefusalSchema = z.union([
|
|
103
|
-
z.object({ kind: z.literal("invalid-target") }).strict(),
|
|
104
|
-
z.object({ kind: z.literal("target-missing") }).strict(),
|
|
105
|
-
z.object({ kind: z.literal("unborn-head") }).strict(),
|
|
106
|
-
]);
|
|
107
|
-
const verificationDeclarationRefusalSchema = z
|
|
108
|
-
.object({ kind: z.literal("verification-declaration-invalid"), contractId: contractIdSchema.optional() })
|
|
109
|
-
.strict()
|
|
110
|
-
.transform((refusal) => withoutUndefined(refusal, ["contractId"]));
|
|
111
|
-
const workspaceSchema = z.object({ kind: z.literal("worktree"), path: nonblankStringSchema }).strict();
|
|
112
|
-
const mergeStateRefusalSchema = z
|
|
113
|
-
.object({ kind: z.literal("merge-state-present"), contractId: contractIdSchema, workspace: workspaceSchema })
|
|
114
|
-
.strict();
|
|
115
|
-
const unmergedPathsRefusalSchema = z
|
|
116
|
-
.object({ kind: z.literal("unmerged-paths"), contractId: contractIdSchema, paths: z.array(nonblankStringSchema) })
|
|
117
|
-
.strict();
|
|
118
|
-
const dirtyWorkspaceRefusalSchema = z
|
|
119
|
-
.object({
|
|
120
|
-
kind: z.literal("dirty-workspace"),
|
|
121
|
-
contractId: contractIdSchema,
|
|
122
|
-
staged: z.array(nonblankStringSchema),
|
|
123
|
-
unstaged: z.array(nonblankStringSchema),
|
|
124
|
-
untracked: z.array(nonblankStringSchema),
|
|
125
|
-
submodules: z.array(nonblankStringSchema),
|
|
126
|
-
shortStat: z
|
|
127
|
-
.object({
|
|
128
|
-
filesChanged: z.number().int().nonnegative(),
|
|
129
|
-
insertions: z.number().int().nonnegative(),
|
|
130
|
-
deletions: z.number().int().nonnegative(),
|
|
131
|
-
})
|
|
132
|
-
.strict(),
|
|
133
|
-
})
|
|
134
|
-
.strict();
|
|
135
|
-
const integrationFailureSchema = z
|
|
136
|
-
.object({
|
|
137
|
-
kind: z.literal("integration-failed"),
|
|
138
|
-
contractId: contractIdSchema,
|
|
139
|
-
reason: z.enum(["not-based-on-target", "unrelated-histories", "conflict"]),
|
|
140
|
-
targetHead: snapshotIdSchema,
|
|
141
|
-
conflictPaths: z.array(nonblankStringSchema).optional(),
|
|
142
|
-
})
|
|
143
|
-
.strict()
|
|
144
|
-
.transform((failure) => withoutUndefined(failure, ["conflictPaths"]));
|
|
145
|
-
const integrationPreparationRefusalSchema = z.union([
|
|
146
|
-
integrationFailureSchema,
|
|
147
|
-
z
|
|
148
|
-
.object({
|
|
149
|
-
kind: z.literal("integration-unsupported"),
|
|
150
|
-
contractId: contractIdSchema,
|
|
151
|
-
requiredGit: z.literal("2.38"),
|
|
152
|
-
})
|
|
153
|
-
.strict(),
|
|
154
|
-
]);
|
|
155
|
-
const integrationRefusalSchema = z.union([
|
|
156
|
-
integrationPreparationRefusalSchema,
|
|
157
|
-
z
|
|
158
|
-
.object({
|
|
159
|
-
kind: z.literal("integration-failed"),
|
|
160
|
-
contractId: contractIdSchema,
|
|
161
|
-
reason: z.literal("conflict"),
|
|
162
|
-
targetHead: snapshotIdSchema,
|
|
163
|
-
conflictPaths: z.array(nonblankStringSchema),
|
|
164
|
-
recovery: z
|
|
165
|
-
.object({
|
|
166
|
-
materialize: z.literal("deliver --materialize-conflict"),
|
|
167
|
-
continue: z.literal("deliver --include-dirty"),
|
|
168
|
-
})
|
|
169
|
-
.strict(),
|
|
170
|
-
})
|
|
171
|
-
.strict(),
|
|
172
|
-
]);
|
|
173
|
-
const checkoutRefusalSchema = z
|
|
174
|
-
.object({
|
|
175
|
-
kind: z.literal("checkout-not-followable"),
|
|
176
|
-
contractId: contractIdSchema,
|
|
177
|
-
target: nonblankStringSchema,
|
|
178
|
-
path: nonblankStringSchema,
|
|
179
|
-
reason: z.enum(["staged", "conflict", "untracked"]),
|
|
180
|
-
paths: z.array(nonblankStringSchema),
|
|
181
|
-
})
|
|
182
|
-
.strict();
|
|
183
|
-
const gateCurrentSchema = z.union([
|
|
184
|
-
z
|
|
185
|
-
.object({
|
|
186
|
-
kind: z.literal("attested"),
|
|
187
|
-
verdict: z.enum(["satisfied", "unsatisfied"]),
|
|
188
|
-
summary: z.string().optional(),
|
|
189
|
-
at: z.string(),
|
|
190
|
-
})
|
|
191
|
-
.strict()
|
|
192
|
-
.transform((current) => withoutUndefined(current, ["summary"])),
|
|
193
|
-
z.object({ kind: z.literal("stale"), priorVerdict: z.enum(["satisfied", "unsatisfied"]) }).strict(),
|
|
194
|
-
z.object({ kind: z.literal("missing") }).strict(),
|
|
195
|
-
]);
|
|
196
|
-
const placementRefusalSchema = z.union([
|
|
197
|
-
z
|
|
198
|
-
.object({
|
|
199
|
-
kind: z.literal("gates-unsatisfied"),
|
|
200
|
-
contractId: contractIdSchema,
|
|
201
|
-
unmet: z.array(z.object({ gate: gateSchema, current: gateCurrentSchema }).strict()),
|
|
202
|
-
})
|
|
203
|
-
.strict(),
|
|
204
|
-
z
|
|
205
|
-
.object({
|
|
206
|
-
kind: z.literal("prerequisites-unsatisfied"),
|
|
207
|
-
contractId: contractIdSchema,
|
|
208
|
-
unmet: z.array(z.object({ contractId: contractIdSchema, state: z.enum(["missing", "active", "abandoned"]) }).strict()),
|
|
209
|
-
})
|
|
210
|
-
.strict(),
|
|
211
|
-
]);
|
|
212
|
-
const nukeRefusalSchema = z.union([
|
|
213
|
-
z.object({ kind: z.literal("nuke-confirmation-required"), world: nonblankStringSchema }).strict(),
|
|
214
|
-
z
|
|
215
|
-
.object({ kind: z.literal("nuke-confirmation-mismatch"), world: nonblankStringSchema, confirmation: z.string() })
|
|
216
|
-
.strict(),
|
|
217
|
-
]);
|
|
218
|
-
const forkSourceRefusalSchema = z
|
|
219
|
-
.object({
|
|
220
|
-
kind: z.enum(["fork-source-missing", "fork-source-unavailable", "fork-source-invalid", "fork-source-moved"]),
|
|
221
|
-
contractId: contractIdSchema,
|
|
222
|
-
})
|
|
223
|
-
.strict();
|
|
224
|
-
const refusalSchema = z.union([
|
|
225
|
-
contractMissingRefusalSchema,
|
|
226
|
-
contractIdentityRefusalSchema,
|
|
227
|
-
targetInputRefusalSchema,
|
|
228
|
-
verificationDeclarationRefusalSchema,
|
|
229
|
-
mergeStateRefusalSchema,
|
|
230
|
-
unmergedPathsRefusalSchema,
|
|
231
|
-
dirtyWorkspaceRefusalSchema,
|
|
232
|
-
integrationRefusalSchema,
|
|
233
|
-
checkoutRefusalSchema,
|
|
234
|
-
placementRefusalSchema,
|
|
235
|
-
nukeRefusalSchema,
|
|
236
|
-
forkSourceRefusalSchema,
|
|
237
|
-
]);
|
|
238
|
-
const retrySchema = z.union([
|
|
239
|
-
z.object({ kind: z.literal("exhausted") }).strict(),
|
|
240
|
-
z.object({ kind: z.literal("collision") }).strict(),
|
|
241
|
-
z.object({ kind: z.literal("publication-failed"), diagnostic: z.string() }).strict(),
|
|
242
|
-
]);
|
|
243
|
-
const materializedConflictSchema = z
|
|
244
|
-
.object({
|
|
245
|
-
kind: z.literal("integration-conflict-materialized"),
|
|
246
|
-
targetHead: snapshotIdSchema,
|
|
247
|
-
conflictPaths: z.array(nonblankStringSchema),
|
|
248
|
-
workspace: z.object({ kind: z.literal("worktree"), path: nonblankStringSchema }).strict(),
|
|
249
|
-
})
|
|
250
|
-
.strict();
|
|
251
|
-
const hookFailureSchema = z.union([
|
|
252
|
-
z
|
|
253
|
-
.object({
|
|
254
|
-
kind: z.literal("exit"),
|
|
255
|
-
code: z.number().int(),
|
|
256
|
-
stdout: z.string(),
|
|
257
|
-
stderr: z.string(),
|
|
258
|
-
truncated: z.boolean(),
|
|
259
|
-
})
|
|
260
|
-
.strict(),
|
|
261
|
-
z.object({ kind: z.literal("timeout") }).strict(),
|
|
262
|
-
z.object({ kind: z.literal("spawn-error"), diagnostic: z.string() }).strict(),
|
|
263
|
-
z.object({ kind: z.literal("unknown-exit") }).strict(),
|
|
264
|
-
]);
|
|
265
|
-
const attestationRefusalSchema = z
|
|
266
|
-
.object({ kind: z.enum(["contract-missing", "terminal"]), contractId: contractIdSchema })
|
|
267
|
-
.strict();
|
|
268
|
-
const verificationStopSchema = z.union([
|
|
269
|
-
z.object({ refusal: z.union([attestationRefusalSchema, verificationDeclarationRefusalSchema]) }).strict(),
|
|
270
|
-
z.object({ retry: retrySchema }).strict(),
|
|
271
|
-
z.object({ failure: z.enum(["unknown-exit", "cancelled"]) }).strict(),
|
|
272
|
-
z.object({ failure: z.enum(["candidate-unavailable", "spawn-error"]), diagnostic: z.string() }).strict(),
|
|
273
|
-
z.object({ failure: z.literal("environment-failure"), diagnostic: z.string() }).strict(),
|
|
274
|
-
z
|
|
275
|
-
.object({ failure: z.literal("environment-failure"), command: z.number().int(), detail: hookFailureSchema })
|
|
276
|
-
.strict(),
|
|
277
|
-
]);
|
|
278
|
-
const verificationReuseSchema = z
|
|
279
|
-
.object({
|
|
280
|
-
entry: canonical(entryUlid, "expected EntryUlid"),
|
|
281
|
-
verdict: z.enum(["satisfied", "unsatisfied"]),
|
|
282
|
-
summary: z.string().optional(),
|
|
283
|
-
})
|
|
284
|
-
.strict()
|
|
285
|
-
.transform((reuse) => withoutUndefined(reuse, ["summary"]));
|
|
286
|
-
const placementStepRefusalSchema = z.union([
|
|
287
|
-
z
|
|
288
|
-
.object({ kind: z.enum(["contract-missing", "delivery-missing", "terminal"]), contractId: contractIdSchema })
|
|
289
|
-
.strict(),
|
|
290
|
-
placementRefusalSchema,
|
|
291
|
-
checkoutRefusalSchema,
|
|
292
|
-
integrationFailureSchema,
|
|
293
|
-
z
|
|
294
|
-
.object({
|
|
295
|
-
kind: z.literal("integration-unsupported"),
|
|
296
|
-
contractId: contractIdSchema,
|
|
297
|
-
requiredGit: z.literal("2.38"),
|
|
298
|
-
})
|
|
299
|
-
.strict(),
|
|
300
|
-
z.object({ kind: z.literal("target-missing"), contractId: contractIdSchema }).strict(),
|
|
301
|
-
]);
|
|
302
|
-
const placementStopSchema = z.union([
|
|
303
|
-
z.object({ refusal: placementStepRefusalSchema }).strict(),
|
|
304
|
-
z.object({ retry: retrySchema }).strict(),
|
|
305
|
-
z
|
|
306
|
-
.object({
|
|
307
|
-
failure: z.literal("target-moved"),
|
|
308
|
-
contractId: contractIdSchema,
|
|
309
|
-
target: nonblankStringSchema,
|
|
310
|
-
expected: snapshotIdSchema,
|
|
311
|
-
observed: snapshotIdSchema.nullable(),
|
|
312
|
-
observedTreeEqualsCandidate: z.boolean(),
|
|
313
|
-
})
|
|
314
|
-
.strict(),
|
|
315
|
-
z
|
|
316
|
-
.object({
|
|
317
|
-
failure: z.literal("target-moved"),
|
|
318
|
-
contractId: contractIdSchema,
|
|
319
|
-
target: nonblankStringSchema,
|
|
320
|
-
integratedAt: snapshotIdSchema,
|
|
321
|
-
observed: snapshotIdSchema.nullable(),
|
|
322
|
-
attempts: z.number().int(),
|
|
323
|
-
observedTreeEqualsCandidate: z.boolean(),
|
|
324
|
-
})
|
|
325
|
-
.strict(),
|
|
326
|
-
z.object({ failure: z.literal("target-placement-failed"), diagnostic: z.string() }).strict(),
|
|
327
|
-
]);
|
|
328
|
-
const cleanupSchema = z
|
|
329
|
-
.object({ phase: z.literal("destroy"), command: z.number().int(), detail: hookFailureSchema })
|
|
330
|
-
.strict();
|
|
331
|
-
const leakSchema = z.object({ path: z.string(), diagnostic: z.string() }).strict();
|
|
332
|
-
const continuationSchema = z
|
|
333
|
-
.object({
|
|
334
|
-
claimed: z.array(contractIdSchema),
|
|
335
|
-
stopped: z.array(z
|
|
336
|
-
.object({
|
|
337
|
-
contractId: contractIdSchema,
|
|
338
|
-
stop: z.union([placementStopSchema, z.object({ kind: z.literal("already-terminal") }).strict()]),
|
|
339
|
-
})
|
|
340
|
-
.strict()),
|
|
341
|
-
})
|
|
342
|
-
.strict();
|
|
343
|
-
const workspaceDeltaSchema = z
|
|
344
|
-
.object({
|
|
345
|
-
staged: z.array(z.string()),
|
|
346
|
-
unstaged: z.array(z.string()),
|
|
347
|
-
untracked: z.array(z.string()),
|
|
348
|
-
shortStat: z
|
|
349
|
-
.object({ filesChanged: z.number().int(), insertions: z.number().int(), deletions: z.number().int() })
|
|
350
|
-
.strict(),
|
|
351
|
-
})
|
|
352
|
-
.strict();
|
|
353
|
-
const deliveryValueSchema = z
|
|
354
|
-
.object({
|
|
355
|
-
tenderSnapshot: snapshotIdSchema,
|
|
356
|
-
integration: integrationSchema,
|
|
357
|
-
method: z.literal("squash"),
|
|
358
|
-
policy: policySchema,
|
|
359
|
-
completion: completionSchema.optional(),
|
|
360
|
-
verification: verificationStopSchema.optional(),
|
|
361
|
-
verificationReuse: verificationReuseSchema.optional(),
|
|
362
|
-
verificationSummary: nonblankStringSchema.optional(),
|
|
363
|
-
placement: placementStopSchema.optional(),
|
|
364
|
-
cleanup: cleanupSchema.optional(),
|
|
365
|
-
leak: leakSchema.optional(),
|
|
366
|
-
continuation: continuationSchema.optional(),
|
|
367
|
-
})
|
|
368
|
-
.strict()
|
|
369
|
-
.transform((value) => withoutUndefined(value, [
|
|
370
|
-
"completion",
|
|
371
|
-
"verification",
|
|
372
|
-
"verificationReuse",
|
|
373
|
-
"verificationSummary",
|
|
374
|
-
"placement",
|
|
375
|
-
"cleanup",
|
|
376
|
-
"leak",
|
|
377
|
-
"continuation",
|
|
378
|
-
]));
|
|
379
|
-
const reviewValueSchema = z
|
|
380
|
-
.object({
|
|
381
|
-
completion: completionSchema.optional(),
|
|
382
|
-
verification: verificationStopSchema.optional(),
|
|
383
|
-
verificationReuse: verificationReuseSchema.optional(),
|
|
384
|
-
verificationSummary: nonblankStringSchema.optional(),
|
|
385
|
-
placement: placementStopSchema.optional(),
|
|
386
|
-
cleanup: cleanupSchema.optional(),
|
|
387
|
-
leak: leakSchema.optional(),
|
|
388
|
-
continuation: continuationSchema.optional(),
|
|
389
|
-
workspace: workspaceDeltaSchema.optional(),
|
|
390
|
-
})
|
|
391
|
-
.strict()
|
|
392
|
-
.transform((value) => withoutUndefined(value, [
|
|
393
|
-
"completion",
|
|
394
|
-
"verification",
|
|
395
|
-
"verificationReuse",
|
|
396
|
-
"verificationSummary",
|
|
397
|
-
"placement",
|
|
398
|
-
"cleanup",
|
|
399
|
-
"leak",
|
|
400
|
-
"continuation",
|
|
401
|
-
"workspace",
|
|
402
|
-
]));
|
|
403
|
-
const deliveryPreparationRefusalSchema = z.union([
|
|
404
|
-
z.object({ kind: z.enum(["target-missing", "worktree-missing"]), contractId: contractIdSchema }).strict(),
|
|
405
|
-
dirtyWorkspaceRefusalSchema,
|
|
406
|
-
unmergedPathsRefusalSchema,
|
|
407
|
-
integrationPreparationRefusalSchema,
|
|
408
|
-
mergeStateRefusalSchema,
|
|
409
|
-
checkoutRefusalSchema,
|
|
410
|
-
]);
|
|
411
|
-
const auditReadyCandidateSchema = z
|
|
412
|
-
.object({
|
|
413
|
-
kind: z.literal("ready"),
|
|
414
|
-
workspace: z.object({ kind: z.literal("worktree"), path: nonblankStringSchema }).strict(),
|
|
415
|
-
identity: z
|
|
416
|
-
.object({
|
|
417
|
-
tenderSnapshot: snapshotIdSchema,
|
|
418
|
-
integration: integrationSchema,
|
|
419
|
-
method: z.literal("squash"),
|
|
420
|
-
policy: policySchema,
|
|
421
|
-
})
|
|
422
|
-
.strict(),
|
|
423
|
-
scope: z
|
|
424
|
-
.object({
|
|
425
|
-
filesChanged: z.number().int(),
|
|
426
|
-
insertions: z.number().int(),
|
|
427
|
-
deletions: z.number().int(),
|
|
428
|
-
paths: z.array(z.string()).optional(),
|
|
429
|
-
})
|
|
430
|
-
.strict()
|
|
431
|
-
.transform((scope) => withoutUndefined(scope, ["paths"])),
|
|
432
|
-
diff: z.string().optional(),
|
|
433
|
-
})
|
|
434
|
-
.strict()
|
|
435
|
-
.transform((candidate) => withoutUndefined(candidate, ["diff"]));
|
|
436
|
-
const auditCandidateSchema = z.union([
|
|
437
|
-
z.object({ kind: z.literal("blocked"), refusal: deliveryPreparationRefusalSchema }).strict(),
|
|
438
|
-
auditReadyCandidateSchema,
|
|
439
|
-
]);
|
|
440
|
-
const auditVerificationSchema = z.union([
|
|
441
|
-
z.object({ kind: z.literal("not-run") }).strict(),
|
|
442
|
-
z.object({ kind: z.literal("stopped"), stop: verificationStopSchema }).strict(),
|
|
443
|
-
z
|
|
444
|
-
.object({
|
|
445
|
-
kind: z.enum(["satisfied", "unsatisfied"]),
|
|
446
|
-
passed: z.number(),
|
|
447
|
-
total: z.number(),
|
|
448
|
-
summary: z.string().optional(),
|
|
449
|
-
})
|
|
450
|
-
.strict()
|
|
451
|
-
.transform((verification) => withoutUndefined(verification, ["summary"])),
|
|
452
|
-
]);
|
|
453
|
-
const auditTargetSchema = z.union([
|
|
454
|
-
z.object({ kind: z.literal("not-observed") }).strict(),
|
|
455
|
-
z.object({ kind: z.literal("placeable"), ref: z.string(), head: snapshotIdSchema }).strict(),
|
|
456
|
-
z
|
|
457
|
-
.object({
|
|
458
|
-
kind: z.literal("moved"),
|
|
459
|
-
ref: z.string(),
|
|
460
|
-
expected: snapshotIdSchema,
|
|
461
|
-
observed: snapshotIdSchema.nullable(),
|
|
462
|
-
})
|
|
463
|
-
.strict(),
|
|
464
|
-
z.object({ kind: z.literal("refused"), refusal: checkoutRefusalSchema }).strict(),
|
|
465
|
-
z.object({ kind: z.literal("failed"), diagnostic: z.string() }).strict(),
|
|
466
|
-
]);
|
|
467
|
-
export const auditReportSchema = z
|
|
468
|
-
.object({
|
|
469
|
-
candidate: auditCandidateSchema,
|
|
470
|
-
verification: auditVerificationSchema,
|
|
471
|
-
target: auditTargetSchema,
|
|
472
|
-
delivery: z
|
|
473
|
-
.object({ changeId: changeIdSchema, relation: z.enum(["identical", "differs"]) })
|
|
474
|
-
.strict()
|
|
475
|
-
.optional(),
|
|
476
|
-
})
|
|
477
|
-
.strict()
|
|
478
|
-
.transform((report) => withoutUndefined(report, ["delivery"]));
|
|
479
|
-
const mutationResultSchema = (value) => z
|
|
480
|
-
.object({
|
|
481
|
-
facts: z.array(journalFactSchema),
|
|
482
|
-
head: contractHeadSchema,
|
|
483
|
-
value,
|
|
484
|
-
lags: z.array(reconciliationLagSchema),
|
|
485
|
-
settlementLags: z.array(settlementLagSchema),
|
|
486
|
-
recoverySnapshot: snapshotIdSchema.optional(),
|
|
487
|
-
cleanup: cleanupSchema.optional(),
|
|
488
|
-
leak: leakSchema.optional(),
|
|
489
|
-
})
|
|
490
|
-
.strict()
|
|
491
|
-
.transform((result) => withoutUndefined(result, ["recoverySnapshot", "cleanup", "leak"]));
|
|
492
|
-
const deliveryMutationResultSchema = mutationResultSchema(deliveryValueSchema);
|
|
493
|
-
const reviewMutationResultSchema = mutationResultSchema(reviewValueSchema);
|
|
494
|
-
const auditMutationResultSchema = mutationResultSchema(auditReportSchema);
|
|
495
|
-
export const deliveryResultSchema = z.union([
|
|
496
|
-
deliveryMutationResultSchema,
|
|
497
|
-
materializedConflictSchema,
|
|
498
|
-
]);
|
|
499
|
-
export const reviewResultSchema = reviewMutationResultSchema;
|
|
500
|
-
export const auditResultSchema = auditMutationResultSchema;
|
|
501
|
-
const contractLiveFailureSchema = z.union([
|
|
502
|
-
z.object({ kind: z.literal("refused"), refusal: refusalSchema }).strict(),
|
|
503
|
-
z.object({ kind: z.literal("retry"), reason: retrySchema }).strict(),
|
|
504
|
-
]);
|
|
505
|
-
export function encodeContractLiveFailure(error) {
|
|
506
|
-
if (error instanceof KeiyakuRefused) {
|
|
507
|
-
return { kind: "refused", refusal: error.refusal };
|
|
508
|
-
}
|
|
509
|
-
if (error instanceof KeiyakuRetry) {
|
|
510
|
-
return { kind: "retry", reason: error.reason };
|
|
511
|
-
}
|
|
512
|
-
return null;
|
|
513
|
-
}
|
|
514
|
-
export function decodeContractLiveFailure(value) {
|
|
515
|
-
const parsed = contractLiveFailureSchema.safeParse(value);
|
|
516
|
-
if (!parsed.success)
|
|
517
|
-
return null;
|
|
518
|
-
return parsed.data.kind === "refused"
|
|
519
|
-
? new KeiyakuRefused(parsed.data.refusal)
|
|
520
|
-
: new KeiyakuRetry(parsed.data.reason);
|
|
521
|
-
}
|