@astrosheep/keiyaku 4.6.4 → 4.6.7
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 +7 -0
- package/build/{integrations/marketplace → plugins}/.agents/plugins/marketplace.json +1 -1
- package/build/plugins/.claude-plugin/marketplace.json +5 -0
- package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/.claude-plugin/plugin.json +1 -1
- package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-akuma/SKILL.md +43 -8
- package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-bind/SKILL.md +7 -8
- package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-workflow/SKILL.md +3 -3
- package/build/{integrations/marketplace/plugins/keiyaku → plugins/codex}/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +44 -0
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +130 -0
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +269 -0
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +65 -0
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +216 -0
- package/build/plugins/codex/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/plugins/codex/skills/keiyaku-task/SKILL.md +104 -0
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +129 -0
- package/build/plugins/opencode/package.json +6 -0
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +44 -0
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +130 -0
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +269 -0
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +65 -0
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +216 -0
- package/build/plugins/opencode/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/plugins/opencode/skills/keiyaku-task/SKILL.md +104 -0
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +129 -0
- package/build/skills/keiyaku/SKILL.md +44 -0
- package/build/skills/keiyaku-akuma/SKILL.md +130 -0
- package/build/skills/keiyaku-akuma/references/automation.md +269 -0
- package/build/skills/keiyaku-babysit/SKILL.md +65 -0
- package/build/skills/keiyaku-bind/SKILL.md +216 -0
- package/build/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/skills/keiyaku-task/SKILL.md +104 -0
- package/build/skills/keiyaku-workflow/SKILL.md +129 -0
- package/build/src/akuma/akuma-instance.js +7 -5
- package/build/src/akuma/akuma-observe.d.ts +22 -15
- package/build/src/akuma/akuma-observe.js +87 -16
- package/build/src/akuma/akuma-owner.d.ts +3 -2
- package/build/src/akuma/akuma-owner.js +28 -10
- package/build/src/akuma/akuma-selection-execution.d.ts +3 -1
- package/build/src/akuma/akuma-selection-execution.js +2 -1
- package/build/src/akuma/akuma-wait.d.ts +6 -4
- package/build/src/akuma/akuma-wait.js +78 -53
- package/build/src/akuma/akuma.d.ts +6 -4
- package/build/src/akuma/akuma.js +4 -0
- package/build/src/akuma/body.d.ts +1 -0
- package/build/src/akuma/body.js +12 -23
- package/build/src/akuma/call-initial-tell.d.ts +2 -2
- package/build/src/akuma/call-initial-tell.js +1 -1
- package/build/src/akuma/call-request.d.ts +2 -2
- package/build/src/akuma/heart/index.d.ts +7 -2
- package/build/src/akuma/heart/index.js +50 -5
- package/build/src/akuma/heart/tells.d.ts +33 -2
- package/build/src/akuma/heart/tells.js +24 -18
- package/build/src/akuma/heart/timeline.d.ts +23 -1
- package/build/src/akuma/heart/timeline.js +28 -21
- package/build/src/akuma/projection.d.ts +10 -10
- package/build/src/akuma/providers/pi/index.js +72 -39
- package/build/src/akuma/selection-observation.d.ts +20 -20
- package/build/src/akuma/selection-owner-port.d.ts +1 -1
- package/build/src/akuma/selection-owner-port.js +16 -5
- package/build/src/akuma/selection-request.d.ts +2 -0
- package/build/src/akuma/selection-request.js +2 -1
- package/build/src/akuma-body.js +5 -2
- package/build/src/alias/index.d.ts +0 -1
- package/build/src/alias/index.js +0 -4
- package/build/src/body/amend.d.ts +0 -4
- package/build/src/body/amend.js +0 -3
- package/build/src/body/region.d.ts +0 -1
- package/build/src/body/region.js +0 -3
- package/build/src/body/verification.d.ts +0 -1
- package/build/src/cli/commands/akuma-grammar.js +23 -66
- package/build/src/cli/commands/akuma.js +23 -42
- package/build/src/cli/commands/contract-grammar.d.ts +14 -1
- package/build/src/cli/commands/contract-grammar.js +54 -21
- package/build/src/cli/commands/contract-help.d.ts +9 -8
- package/build/src/cli/commands/contract-help.js +14 -7
- package/build/src/cli/commands/contract.js +57 -117
- package/build/src/cli/commands/install.d.ts +5 -5
- package/build/src/cli/commands/install.js +4 -7
- package/build/src/cli/commands/task-grammar.js +10 -66
- package/build/src/cli/commands/task.d.ts +0 -1
- package/build/src/cli/commands/task.js +34 -53
- package/build/src/cli/coordinates.d.ts +1 -2
- package/build/src/cli/coordinates.js +1 -4
- package/build/src/cli/parse.d.ts +2 -3
- package/build/src/cli/parse.js +24 -66
- package/build/src/cli/render/akuma.d.ts +3 -16
- package/build/src/cli/render/akuma.js +1 -13
- package/build/src/cli/render/audit.js +1 -1
- package/build/src/cli/render/contract.js +34 -32
- package/build/src/cli/render/kanshi-akuma.d.ts +8 -2
- package/build/src/cli/render/kanshi-akuma.js +14 -7
- package/build/src/cli/render/kanshi.d.ts +3 -1
- package/build/src/cli/render/kanshi.js +44 -32
- package/build/src/cli/render/receipt.js +6 -1
- package/build/src/cli/render/task.d.ts +1 -1
- package/build/src/cli/render/task.js +3 -27
- package/build/src/cli/render/terminal.d.ts +6 -2
- package/build/src/cli/render/terminal.js +8 -2
- package/build/src/cli/runtime.js +3 -16
- package/build/src/cli/scan.d.ts +26 -0
- package/build/src/cli/scan.js +82 -0
- package/build/src/cli/streams.d.ts +5 -0
- package/build/src/cli/streams.js +11 -0
- package/build/src/contract-worktree.js +38 -21
- package/build/src/core/facts/codec.d.ts +1 -2
- package/build/src/core/facts/codec.js +5 -11
- package/build/src/core/facts/types.d.ts +16 -2
- package/build/src/core/facts/types.js +15 -0
- package/build/src/core/verbs/abandon.js +3 -9
- package/build/src/core/verbs/amend.js +2 -9
- package/build/src/core/verbs/arc.js +6 -13
- package/build/src/core/verbs/attestation.js +2 -9
- package/build/src/core/verbs/bind.js +2 -9
- package/build/src/core/verbs/deliver.js +2 -9
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +2 -9
- package/build/src/core/verbs/reintegrate.d.ts +1 -1
- package/build/src/core/verbs/reintegrate.js +2 -9
- package/build/src/dispatch/index.d.ts +2 -2
- package/build/src/dispatch/index.js +33 -11
- package/build/src/git/hooks.d.ts +2 -4
- package/build/src/git/hooks.js +0 -12
- package/build/src/git/integration.d.ts +5 -3
- package/build/src/git/integration.js +36 -25
- package/build/src/git/nuke.js +4 -4
- package/build/src/git/observe.d.ts +4 -4
- package/build/src/git/observe.js +5 -5
- package/build/src/git/process.d.ts +1 -4
- package/build/src/git/process.js +1 -11
- package/build/src/git/read-observation.js +1 -1
- package/build/src/git/reconcile.d.ts +1 -1
- package/build/src/git/reconcile.js +15 -13
- package/build/src/git/repository.d.ts +2 -6
- package/build/src/git/repository.js +18 -31
- package/build/src/git/scratch.d.ts +6 -6
- package/build/src/git/scratch.js +110 -46
- package/build/src/git/target-placement.d.ts +5 -5
- package/build/src/git/target-placement.js +18 -33
- package/build/src/git/tender.d.ts +6 -2
- package/build/src/git/tender.js +19 -12
- package/build/src/git/terminal-reconcile.js +24 -13
- package/build/src/git/terminal-seal.d.ts +2 -5
- package/build/src/git/terminal-seal.js +5 -3
- package/build/src/git/workspace.d.ts +17 -13
- package/build/src/git/workspace.js +58 -41
- package/build/src/kanshi/index.d.ts +2 -2
- package/build/src/kanshi/index.js +1 -1
- package/build/src/kanshi/read.d.ts +8 -1
- package/build/src/kanshi/read.js +72 -7
- package/build/src/kanshi/report.d.ts +12 -0
- package/build/src/library/akuma-creation.d.ts +4 -4
- package/build/src/library/akuma-creation.js +21 -19
- package/build/src/library/bind.d.ts +1 -63
- package/build/src/library/bind.js +3 -9
- package/build/src/library/contract-creation.js +2 -30
- package/build/src/library/contract-execution.d.ts +0 -1
- package/build/src/library/contract-execution.js +9 -34
- package/build/src/library/contract-operations.d.ts +5 -1
- package/build/src/library/contract-operations.js +7 -3
- package/build/src/library/contract-types.d.ts +1 -1
- package/build/src/library/delivery.d.ts +91 -93
- package/build/src/library/delivery.js +2 -1
- package/build/src/library/input.d.ts +0 -2
- package/build/src/library/input.js +0 -4
- package/build/src/library/invocation.d.ts +0 -1
- package/build/src/library/invocation.js +3 -25
- package/build/src/library/outcome.d.ts +651 -602
- package/build/src/library/outcome.js +4 -4
- package/build/src/library/reconcile.d.ts +6 -0
- package/build/src/library/reconcile.js +31 -1
- package/build/src/library/repo.d.ts +0 -1
- package/build/src/library/selection.d.ts +1 -10
- package/build/src/library/selection.js +19 -17
- package/build/src/plugin/akuma-signals.d.ts +10 -11
- package/build/src/plugin/akuma-signals.js +36 -20
- package/build/src/plugin/public.d.ts +5 -0
- package/build/src/plugin/runtime.d.ts +1 -0
- package/build/src/plugin/runtime.js +34 -23
- package/build/src/protocol/abandon.d.ts +1 -1
- package/build/src/protocol/abandon.js +3 -10
- package/build/src/protocol/amend.js +2 -5
- package/build/src/protocol/arc.d.ts +1 -1
- package/build/src/protocol/arc.js +2 -9
- package/build/src/protocol/attempt.d.ts +3 -20
- package/build/src/protocol/attempt.js +6 -5
- package/build/src/protocol/audit.d.ts +1 -0
- package/build/src/protocol/audit.js +10 -11
- package/build/src/protocol/completion.d.ts +129 -55
- package/build/src/protocol/completion.js +62 -73
- package/build/src/protocol/deliver.d.ts +7 -5
- package/build/src/protocol/deliver.js +74 -44
- package/build/src/protocol/execution-observation.d.ts +2 -4
- package/build/src/protocol/execution-observation.js +3 -7
- package/build/src/protocol/intent.d.ts +1 -1
- package/build/src/protocol/intent.js +1 -0
- package/build/src/protocol/operations.d.ts +24 -12
- package/build/src/protocol/operations.js +36 -15
- package/build/src/protocol/placement.d.ts +2 -1
- package/build/src/protocol/placement.js +21 -5
- package/build/src/protocol/progress.d.ts +1 -1
- package/build/src/protocol/read/status.js +58 -41
- package/build/src/protocol/reintegrate.d.ts +1 -1
- package/build/src/protocol/reintegrate.js +10 -19
- package/build/src/protocol/review.d.ts +3 -28
- package/build/src/protocol/review.js +10 -37
- package/build/src/protocol/run.d.ts +19 -7
- package/build/src/protocol/run.js +19 -9
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/holder.d.ts +2 -4
- package/build/src/settlement/holder.js +3 -6
- package/build/src/task/board.d.ts +6 -0
- package/build/src/task/board.js +30 -1
- package/build/src/task/catalog.js +1 -4
- package/build/src/task/compose.d.ts +0 -1
- package/build/src/task/compose.js +0 -1
- package/build/src/task/context.d.ts +0 -1
- package/build/src/task/context.js +0 -3
- package/build/src/task/created-observation.d.ts +5 -1
- package/build/src/task/created-observation.js +12 -5
- package/build/src/task/index.d.ts +1 -1
- package/build/src/task/index.js +7 -6
- package/build/src/task/input.d.ts +0 -6
- package/build/src/task/input.js +2 -14
- package/build/src/task/mutation.d.ts +3 -4
- package/build/src/task/mutation.js +11 -39
- package/build/src/task/operations.d.ts +2 -7
- package/build/src/task/operations.js +37 -49
- package/build/src/task/query.d.ts +0 -1
- package/build/src/task/query.js +1 -4
- package/build/src/task/store.d.ts +0 -2
- package/build/src/task/store.js +27 -11
- package/build/src/verification/declaration.js +3 -2
- package/build/src/verification/execution.d.ts +3 -2
- package/build/src/verification/execution.js +10 -6
- package/build/src/workspace-place.d.ts +0 -1
- package/build/src/workspace-place.js +0 -11
- package/package.json +13 -9
- package/build/integrations/marketplace/.claude-plugin/marketplace.json +0 -5
- package/build/integrations/marketplace/plugins/keiyaku/package.json +0 -17
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku/SKILL.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-akuma/references/automation.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-babysit/SKILL.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-bind/agents/openai.yaml +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-task/SKILL.md +0 -0
- /package/build/{integrations/marketplace/plugins/keiyaku/opencode.js → plugins/opencode/index.js} +0 -0
- /package/build/{integrations → plugins}/pi/keiyaku.ts +0 -0
|
@@ -10,22 +10,9 @@ import type { AttemptContext } from "../core/decide.js";
|
|
|
10
10
|
import type { Offer } from "../core/facts/offer.js";
|
|
11
11
|
import { type ContractId, type ContractState, type EntryUlid, type JournalEntry } from "../core/facts/types.js";
|
|
12
12
|
export declare const entryUlidSchema: z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>;
|
|
13
|
-
export declare function mintEntryUlids(count: number): readonly EntryUlid[];
|
|
14
13
|
export declare function mintAttempts(input: Readonly<{
|
|
15
14
|
entryCount: number;
|
|
16
15
|
}>): readonly AttemptContext[];
|
|
17
|
-
export type UnknownAttemptClassification = Readonly<{
|
|
18
|
-
kind: "accepted";
|
|
19
|
-
}> | Readonly<{
|
|
20
|
-
kind: "redecide";
|
|
21
|
-
}> | Readonly<{
|
|
22
|
-
kind: "collision";
|
|
23
|
-
contractId: ContractId;
|
|
24
|
-
planned: JournalEntry;
|
|
25
|
-
observed: JournalEntry;
|
|
26
|
-
plannedBytes: string;
|
|
27
|
-
observedBytes: string;
|
|
28
|
-
}>;
|
|
29
16
|
export type AcceptedAdmission = Readonly<{
|
|
30
17
|
kind: "accepted";
|
|
31
18
|
facts: readonly JournalEntry[];
|
|
@@ -46,18 +33,14 @@ export type DecidedOfferResult<Refusal = never> = AcceptedAdmission | AttemptTer
|
|
|
46
33
|
}>;
|
|
47
34
|
/** Admit one decided offer without making another legal decision. */
|
|
48
35
|
export declare function admitDecidedOffer<Refusal = never>(input: Readonly<{
|
|
36
|
+
scope: GitRepository;
|
|
49
37
|
channel: GitDecodeChannel;
|
|
50
|
-
|
|
38
|
+
contractId: ContractId;
|
|
51
39
|
seat: PrivateStatePublicationSeat;
|
|
52
|
-
|
|
40
|
+
observation: GitDecisionObservation;
|
|
53
41
|
attempt: AttemptContext;
|
|
54
42
|
offer: Offer;
|
|
55
|
-
primaryContract: ContractId;
|
|
56
43
|
assertions?: readonly GitRefAssertion[];
|
|
57
44
|
validateAdmission?: (observation: GitDecisionObservation) => Refusal | undefined | Promise<Refusal | undefined>;
|
|
58
45
|
progress?: ProtocolProgress;
|
|
59
46
|
}>): Promise<DecidedOfferResult<Refusal>>;
|
|
60
|
-
/** Classify an unknown atomic-publication outcome using only a captured Git observation. */
|
|
61
|
-
export declare function classifyUnknownAttempt(observation: Readonly<{
|
|
62
|
-
contracts: GitDecisionObservation["journals"];
|
|
63
|
-
}>, offer: Offer): UnknownAttemptClassification;
|
|
@@ -34,7 +34,7 @@ function nextEntryUlid() {
|
|
|
34
34
|
}
|
|
35
35
|
return entryUlid(value);
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
function mintEntryUlids(count) {
|
|
38
38
|
return Array.from({ length: count }, nextEntryUlid);
|
|
39
39
|
}
|
|
40
40
|
export function mintAttempts(input) {
|
|
@@ -104,7 +104,8 @@ async function publicationPremiseMoved(repository, observation, offer, assertion
|
|
|
104
104
|
}
|
|
105
105
|
/** Admit one decided offer without making another legal decision. */
|
|
106
106
|
export async function admitDecidedOffer(input) {
|
|
107
|
-
const {
|
|
107
|
+
const { seat, observation: decisionObservation, attempt, offer, contractId: primaryContract } = input;
|
|
108
|
+
const repository = input.scope;
|
|
108
109
|
const assertions = input.assertions ?? [];
|
|
109
110
|
validateOffer(offer, attempt);
|
|
110
111
|
const primary = primaryAppend(offer, primaryContract);
|
|
@@ -115,7 +116,7 @@ export async function admitDecidedOffer(input) {
|
|
|
115
116
|
}
|
|
116
117
|
const admission = await admit(repository, offer, decisionObservation.admission, assertions);
|
|
117
118
|
if (admission.kind === "accepted") {
|
|
118
|
-
confirmPrivateStatePublication(
|
|
119
|
+
confirmPrivateStatePublication(seat);
|
|
119
120
|
input.progress?.recordPublication(primaryContract, admission.heads[primary.contractId], offerEntries(offer));
|
|
120
121
|
const accepted = {
|
|
121
122
|
kind: "accepted",
|
|
@@ -135,7 +136,7 @@ export async function admitDecidedOffer(input) {
|
|
|
135
136
|
const recovered = await withGitDecodeChannel(recoveryRepository, async (recoveryChannel) => observeContractsForAdmissionAt(recoveryRepository, recoveryChannel, offer.facts.map((append) => append.contractId)));
|
|
136
137
|
const classification = classifyUnknownAttempt({ contracts: recovered.journals }, offer);
|
|
137
138
|
if (classification.kind === "accepted") {
|
|
138
|
-
const accepted = confirmRecoveredAcceptance(
|
|
139
|
+
const accepted = confirmRecoveredAcceptance(seat, { contracts: recovered.journals }, offer, primaryContract);
|
|
139
140
|
input.progress?.recordAdmission(accepted);
|
|
140
141
|
return accepted;
|
|
141
142
|
}
|
|
@@ -147,7 +148,7 @@ function confirmRecoveredAcceptance(seat, observation, offer, primaryContract) {
|
|
|
147
148
|
return recovered;
|
|
148
149
|
}
|
|
149
150
|
/** Classify an unknown atomic-publication outcome using only a captured Git observation. */
|
|
150
|
-
|
|
151
|
+
function classifyUnknownAttempt(observation, offer) {
|
|
151
152
|
let exact = 0;
|
|
152
153
|
let missing = 0;
|
|
153
154
|
for (const append of offer.facts) {
|
|
@@ -75,6 +75,7 @@ export declare const auditReportSchema: z.ZodObject<{
|
|
|
75
75
|
path: z.ZodString;
|
|
76
76
|
}, z.core.$strict>;
|
|
77
77
|
identity: z.ZodObject<{
|
|
78
|
+
note: z.ZodOptional<z.ZodString>;
|
|
78
79
|
tenderSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>;
|
|
79
80
|
integration: z.ZodObject<{
|
|
80
81
|
predecessor: z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>;
|
|
@@ -11,7 +11,7 @@ import { readManagedWorktreeAppointment } from "../workspace-place.js";
|
|
|
11
11
|
import { currentVerifiedAttestation, verifyDelivery } from "./intent.js";
|
|
12
12
|
import { accepted, admitted } from "./outcome.js";
|
|
13
13
|
import { prepareDelivery } from "./deliver.js";
|
|
14
|
-
import { timestamp, unpackVerificationOutcome } from "./operations.js";
|
|
14
|
+
import { recordedIntegrationSnapshots, timestamp, unpackVerificationOutcome } from "./operations.js";
|
|
15
15
|
export const auditReportSchema = z
|
|
16
16
|
.object({
|
|
17
17
|
candidate: z.union([
|
|
@@ -63,15 +63,15 @@ async function auditWorkspace(repository, state) {
|
|
|
63
63
|
return appointed;
|
|
64
64
|
return { kind: "ready", answer: { kind: "worktree", path: appointed.path }, appointment: appointed };
|
|
65
65
|
}
|
|
66
|
-
function auditDeliveryRelation(state, candidate,
|
|
66
|
+
function auditDeliveryRelation(state, candidate, declaration) {
|
|
67
67
|
const recorded = state.delivery?.data.integration.changeId;
|
|
68
68
|
if (recorded === undefined)
|
|
69
69
|
return undefined;
|
|
70
|
-
const verification = currentVerifiedAttestation(state);
|
|
70
|
+
const verification = declaration == null ? undefined : currentVerifiedAttestation(state);
|
|
71
71
|
return {
|
|
72
72
|
changeId: recorded,
|
|
73
73
|
relation: recorded === candidate.integration.changeId ? "identical" : "differs",
|
|
74
|
-
verification:
|
|
74
|
+
verification: declaration == null
|
|
75
75
|
? { kind: "undeclared" }
|
|
76
76
|
: verification === undefined
|
|
77
77
|
? { kind: "unrecorded" }
|
|
@@ -95,15 +95,13 @@ async function auditCandidateVerification(input, state, snapshot, definition) {
|
|
|
95
95
|
throw new Error("audit verification preparation unexpectedly produced no attempt");
|
|
96
96
|
return unpackVerificationOutcome(verification);
|
|
97
97
|
}
|
|
98
|
-
function auditVerificationAnswer(verified,
|
|
99
|
-
if (
|
|
98
|
+
function auditVerificationAnswer(verified, declaration) {
|
|
99
|
+
if (declaration === null)
|
|
100
100
|
return { kind: "undeclared" };
|
|
101
101
|
if (verified === undefined)
|
|
102
|
-
|
|
102
|
+
throw new Error("declared audit Verification produced no attempt");
|
|
103
103
|
if (verified.stop !== undefined)
|
|
104
104
|
return { kind: "stopped", stop: verified.stop };
|
|
105
|
-
if (verified.reuse !== undefined)
|
|
106
|
-
return { kind: "reused", ...verified.reuse };
|
|
107
105
|
if (verified.counts === undefined)
|
|
108
106
|
throw new Error("terminal Verification is missing producer counts");
|
|
109
107
|
return {
|
|
@@ -172,6 +170,7 @@ export async function auditOperation(input) {
|
|
|
172
170
|
const prepared = await prepareDelivery(input.scope, {
|
|
173
171
|
contractId: state.id,
|
|
174
172
|
coordinates: state.coordinates,
|
|
173
|
+
recordedIntegrations: recordedIntegrationSnapshots(observed.journals.get(state.id)?.entries ?? []),
|
|
175
174
|
...(workspace.appointment === undefined ? {} : { appointment: workspace.appointment }),
|
|
176
175
|
}, {
|
|
177
176
|
title: derivation.title,
|
|
@@ -187,8 +186,8 @@ export async function auditOperation(input) {
|
|
|
187
186
|
const verified = derivation.verification.data === null
|
|
188
187
|
? undefined
|
|
189
188
|
: await auditCandidateVerification(input, state, prepared.data.integration.snapshot, derivation.verification.data);
|
|
190
|
-
const verification = auditVerificationAnswer(verified, derivation.verification.data
|
|
191
|
-
const delivery = auditDeliveryRelation(verified?.admission?.state ?? state, prepared.data, derivation.verification.data
|
|
189
|
+
const verification = auditVerificationAnswer(verified, derivation.verification.data);
|
|
190
|
+
const delivery = auditDeliveryRelation(verified?.admission?.state ?? state, prepared.data, derivation.verification.data);
|
|
192
191
|
input.progress?.recordAudit(state.id, { verification, ...(delivery === undefined ? {} : { delivery }) });
|
|
193
192
|
const target = await auditTargetAnswer(input.scope, state, prepared.data);
|
|
194
193
|
input.progress?.recordAudit(state.id, { target });
|
|
@@ -4,49 +4,27 @@ import type { GitRepository } from "../git/process.js";
|
|
|
4
4
|
import type { GitDecodeChannel } from "../git/read-observation.js";
|
|
5
5
|
import { type ContractCheckpoint, type ProtocolProgress, type ExecutionStop } from "./progress.js";
|
|
6
6
|
import type { DocumentDerivation, PlacementStop, VerificationStop } from "./operations.js";
|
|
7
|
-
declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export declare const completionEvidenceSchema: z.ZodObject<{
|
|
29
|
-
completion: z.ZodOptional<z.ZodObject<{
|
|
30
|
-
integration: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
31
|
-
predecessor: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
|
|
32
|
-
target: z.ZodOptional<z.ZodString>;
|
|
33
|
-
scope: z.ZodOptional<z.ZodObject<{
|
|
34
|
-
deletions: z.ZodNumber;
|
|
35
|
-
filesChanged: z.ZodNumber;
|
|
36
|
-
insertions: z.ZodNumber;
|
|
37
|
-
}, z.core.$strict>>;
|
|
38
|
-
verification: z.ZodOptional<z.ZodObject<{
|
|
39
|
-
mode: z.ZodEnum<{
|
|
40
|
-
reused: "reused";
|
|
41
|
-
ran: "ran";
|
|
42
|
-
}>;
|
|
43
|
-
verdict: z.ZodEnum<{
|
|
44
|
-
satisfied: "satisfied";
|
|
45
|
-
unsatisfied: "unsatisfied";
|
|
46
|
-
}>;
|
|
47
|
-
}, z.core.$strict>>;
|
|
48
|
-
}, z.core.$strict>>;
|
|
49
|
-
verification: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
7
|
+
declare const verificationEvidenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
8
|
+
snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
9
|
+
verdict: z.ZodEnum<{
|
|
10
|
+
satisfied: "satisfied";
|
|
11
|
+
unsatisfied: "unsatisfied";
|
|
12
|
+
}>;
|
|
13
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
14
|
+
kind: z.ZodLiteral<"ran">;
|
|
15
|
+
entry: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>>;
|
|
16
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
17
|
+
snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
18
|
+
verdict: z.ZodEnum<{
|
|
19
|
+
satisfied: "satisfied";
|
|
20
|
+
unsatisfied: "unsatisfied";
|
|
21
|
+
}>;
|
|
22
|
+
entry: z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>;
|
|
23
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
24
|
+
kind: z.ZodLiteral<"reused">;
|
|
25
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
26
|
+
kind: z.ZodLiteral<"stopped">;
|
|
27
|
+
stop: z.ZodUnion<readonly [z.ZodObject<{
|
|
50
28
|
refusal: z.ZodUnion<readonly [z.ZodObject<{
|
|
51
29
|
kind: z.ZodEnum<{
|
|
52
30
|
terminal: "terminal";
|
|
@@ -116,27 +94,123 @@ export declare const completionEvidenceSchema: z.ZodObject<{
|
|
|
116
94
|
kind: z.ZodLiteral<"spawn-error">;
|
|
117
95
|
diagnostic: z.ZodString;
|
|
118
96
|
}, z.core.$strict>]>;
|
|
119
|
-
}, z.core.$strict>]>]
|
|
120
|
-
|
|
121
|
-
|
|
97
|
+
}, z.core.$strict>]>]>;
|
|
98
|
+
}, z.core.$strict>], "kind">;
|
|
99
|
+
export type VerificationEvidence = z.infer<typeof verificationEvidenceSchema>;
|
|
100
|
+
declare const candidateCompletionSchema: z.ZodObject<{
|
|
101
|
+
integration: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
102
|
+
predecessor: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
|
|
103
|
+
target: z.ZodOptional<z.ZodString>;
|
|
104
|
+
scope: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
deletions: z.ZodNumber;
|
|
106
|
+
filesChanged: z.ZodNumber;
|
|
107
|
+
insertions: z.ZodNumber;
|
|
108
|
+
}, z.core.$strict>>;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
export type CandidateCompletion = z.infer<typeof candidateCompletionSchema>;
|
|
111
|
+
export declare const completionEvidenceSchema: z.ZodObject<{
|
|
112
|
+
completion: z.ZodOptional<z.ZodObject<{
|
|
113
|
+
integration: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
114
|
+
predecessor: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>>;
|
|
115
|
+
target: z.ZodOptional<z.ZodString>;
|
|
116
|
+
scope: z.ZodOptional<z.ZodObject<{
|
|
117
|
+
deletions: z.ZodNumber;
|
|
118
|
+
filesChanged: z.ZodNumber;
|
|
119
|
+
insertions: z.ZodNumber;
|
|
120
|
+
}, z.core.$strict>>;
|
|
121
|
+
}, z.core.$strict>>;
|
|
122
|
+
verification: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
123
|
+
snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
122
124
|
verdict: z.ZodEnum<{
|
|
123
125
|
satisfied: "satisfied";
|
|
124
126
|
unsatisfied: "unsatisfied";
|
|
125
127
|
}>;
|
|
126
128
|
summary: z.ZodOptional<z.ZodString>;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
ran: "ran";
|
|
132
|
-
}>;
|
|
129
|
+
kind: z.ZodLiteral<"ran">;
|
|
130
|
+
entry: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>>;
|
|
131
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
132
|
+
snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
133
133
|
verdict: z.ZodEnum<{
|
|
134
134
|
satisfied: "satisfied";
|
|
135
135
|
unsatisfied: "unsatisfied";
|
|
136
136
|
}>;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
entry: z.ZodPipe<z.ZodString, z.ZodTransform<EntryUlid, string>>;
|
|
138
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
139
|
+
kind: z.ZodLiteral<"reused">;
|
|
140
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
+
kind: z.ZodLiteral<"stopped">;
|
|
142
|
+
stop: z.ZodUnion<readonly [z.ZodObject<{
|
|
143
|
+
refusal: z.ZodUnion<readonly [z.ZodObject<{
|
|
144
|
+
kind: z.ZodEnum<{
|
|
145
|
+
terminal: "terminal";
|
|
146
|
+
"contract-missing": "contract-missing";
|
|
147
|
+
}>;
|
|
148
|
+
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
|
|
149
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
150
|
+
kind: z.ZodLiteral<"verification-declaration-invalid">;
|
|
151
|
+
contractId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>>;
|
|
152
|
+
}, z.core.$strict>]>;
|
|
153
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
154
|
+
retry: z.ZodUnion<readonly [z.ZodObject<{
|
|
155
|
+
kind: z.ZodEnum<{
|
|
156
|
+
exhausted: "exhausted";
|
|
157
|
+
collision: "collision";
|
|
158
|
+
}>;
|
|
159
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
160
|
+
kind: z.ZodLiteral<"publication-failed">;
|
|
161
|
+
diagnostic: z.ZodString;
|
|
162
|
+
}, z.core.$strict>]>;
|
|
163
|
+
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
|
|
164
|
+
stdout: z.ZodOptional<z.ZodString>;
|
|
165
|
+
stderr: z.ZodOptional<z.ZodString>;
|
|
166
|
+
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
167
|
+
failure: z.ZodEnum<{
|
|
168
|
+
cancelled: "cancelled";
|
|
169
|
+
"unknown-exit": "unknown-exit";
|
|
170
|
+
}>;
|
|
171
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
172
|
+
stdout: z.ZodOptional<z.ZodString>;
|
|
173
|
+
stderr: z.ZodOptional<z.ZodString>;
|
|
174
|
+
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
175
|
+
failure: z.ZodEnum<{
|
|
176
|
+
"spawn-error": "spawn-error";
|
|
177
|
+
"candidate-unavailable": "candidate-unavailable";
|
|
178
|
+
}>;
|
|
179
|
+
diagnostic: z.ZodString;
|
|
180
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
181
|
+
stdout: z.ZodOptional<z.ZodString>;
|
|
182
|
+
stderr: z.ZodOptional<z.ZodString>;
|
|
183
|
+
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
184
|
+
failure: z.ZodLiteral<"environment-failure">;
|
|
185
|
+
diagnostic: z.ZodString;
|
|
186
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
187
|
+
stdout: z.ZodOptional<z.ZodString>;
|
|
188
|
+
stderr: z.ZodOptional<z.ZodString>;
|
|
189
|
+
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
190
|
+
failure: z.ZodLiteral<"environment-failure">;
|
|
191
|
+
name: z.ZodString;
|
|
192
|
+
detail: z.ZodUnion<readonly [z.ZodObject<{
|
|
193
|
+
kind: z.ZodLiteral<"exit">;
|
|
194
|
+
code: z.ZodNumber;
|
|
195
|
+
stdout: z.ZodString;
|
|
196
|
+
stderr: z.ZodString;
|
|
197
|
+
truncated: z.ZodBoolean;
|
|
198
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
199
|
+
stdout: z.ZodOptional<z.ZodString>;
|
|
200
|
+
stderr: z.ZodOptional<z.ZodString>;
|
|
201
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
202
|
+
kind: z.ZodLiteral<"timeout">;
|
|
203
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
204
|
+
stdout: z.ZodOptional<z.ZodString>;
|
|
205
|
+
stderr: z.ZodOptional<z.ZodString>;
|
|
206
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
207
|
+
kind: z.ZodLiteral<"unknown-exit">;
|
|
208
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
209
|
+
kind: z.ZodLiteral<"spawn-error">;
|
|
210
|
+
diagnostic: z.ZodString;
|
|
211
|
+
}, z.core.$strict>]>;
|
|
212
|
+
}, z.core.$strict>]>]>;
|
|
213
|
+
}, z.core.$strict>], "kind">>;
|
|
140
214
|
placement: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
141
215
|
refusal: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
142
216
|
kind: z.ZodEnum<{
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { snapshotIdSchema, verdictSchema, verificationStopSchema, placementStopSchema } from "./operations.js";
|
|
3
|
-
import { verificationReuseSchema } from "./intent.js";
|
|
2
|
+
import { snapshotIdSchema, verdictSchema, verificationStopSchema, placementStopSchema, entryUlidSchema, } from "./operations.js";
|
|
4
3
|
import { deliveryDiffScopeSchema, readDeliveryScope } from "../git/integration.js";
|
|
5
4
|
import { currentVerifiedAttestation, verifyDelivery } from "./intent.js";
|
|
6
|
-
import { admitPlacement, observeTargetPlacement } from "./placement.js";
|
|
5
|
+
import { admitPlacement, observeTargetPlacement, observeIntegrationTargetMovement } from "./placement.js";
|
|
7
6
|
import { reintegrateOperation } from "./reintegrate.js";
|
|
8
7
|
import { contractCheckpoint, executionStop, isOperationalFailure, isOperationalStop, } from "./progress.js";
|
|
9
8
|
import { placementStop, timestamp, unpackVerificationOutcome } from "./operations.js";
|
|
10
|
-
import { VERIFIED } from "../verification/declaration.js";
|
|
11
9
|
const MAX_REINTEGRATION_CYCLES = 3;
|
|
12
|
-
const
|
|
10
|
+
const verificationVerdictSchema = z.object({
|
|
11
|
+
snapshot: snapshotIdSchema,
|
|
12
|
+
verdict: verdictSchema,
|
|
13
|
+
entry: entryUlidSchema,
|
|
14
|
+
summary: z.string().optional(),
|
|
15
|
+
});
|
|
16
|
+
const verificationEvidenceSchema = z.discriminatedUnion("kind", [
|
|
17
|
+
verificationVerdictSchema.extend({ kind: z.literal("ran"), entry: entryUlidSchema.optional() }).strict(),
|
|
18
|
+
verificationVerdictSchema.extend({ kind: z.literal("reused") }).strict(),
|
|
19
|
+
z.object({ kind: z.literal("stopped"), stop: verificationStopSchema }).strict(),
|
|
20
|
+
]);
|
|
13
21
|
const candidateCompletionSchema = z
|
|
14
22
|
.object({
|
|
15
23
|
integration: snapshotIdSchema,
|
|
@@ -19,20 +27,12 @@ const candidateCompletionSchema = z
|
|
|
19
27
|
.refine((value) => value.trim() !== "")
|
|
20
28
|
.optional(),
|
|
21
29
|
scope: deliveryDiffScopeSchema.omit({ paths: true }).optional(),
|
|
22
|
-
verification: verdictProvenanceSchema.optional(),
|
|
23
30
|
})
|
|
24
31
|
.strict();
|
|
25
|
-
const verificationSubjectSchema = verdictProvenanceSchema.extend({ snapshot: snapshotIdSchema }).strict();
|
|
26
32
|
export const completionEvidenceSchema = z
|
|
27
33
|
.object({
|
|
28
34
|
completion: candidateCompletionSchema.optional(),
|
|
29
|
-
verification:
|
|
30
|
-
verificationReuse: verificationReuseSchema.optional(),
|
|
31
|
-
verificationSubject: verificationSubjectSchema.optional(),
|
|
32
|
-
verificationSummary: z
|
|
33
|
-
.string()
|
|
34
|
-
.refine((value) => value.trim() !== "")
|
|
35
|
-
.optional(),
|
|
35
|
+
verification: verificationEvidenceSchema.optional(),
|
|
36
36
|
placement: placementStopSchema.optional(),
|
|
37
37
|
})
|
|
38
38
|
.strict();
|
|
@@ -53,18 +53,19 @@ async function verifyCurrentCandidate(input, cursor) {
|
|
|
53
53
|
cursor.evidence = {};
|
|
54
54
|
cursor.ran = undefined;
|
|
55
55
|
input.progress.recordCandidate(state.id, cursor.evidence);
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
cursor.evidence = {
|
|
59
|
-
verificationReuse: current,
|
|
60
|
-
verificationSubject: { snapshot, mode: "reused", verdict: current.verdict },
|
|
61
|
-
};
|
|
56
|
+
const declaration = input.deriveDocument(state).verification;
|
|
57
|
+
if (declaration.kind === "refused") {
|
|
58
|
+
cursor.evidence = { verification: { kind: "stopped", stop: { refusal: declaration.refusal } } };
|
|
62
59
|
input.progress.recordCandidate(state.id, cursor.evidence);
|
|
63
60
|
return;
|
|
64
61
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
if (declaration.data === null)
|
|
63
|
+
return;
|
|
64
|
+
const current = currentVerifiedAttestation(state);
|
|
65
|
+
if (current?.verdict === "satisfied") {
|
|
66
|
+
cursor.evidence = {
|
|
67
|
+
verification: { kind: "reused", snapshot, ...current },
|
|
68
|
+
};
|
|
68
69
|
input.progress.recordCandidate(state.id, cursor.evidence);
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
@@ -78,7 +79,7 @@ async function verifyCurrentCandidate(input, cursor) {
|
|
|
78
79
|
snapshot,
|
|
79
80
|
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
80
81
|
progress: input.progress,
|
|
81
|
-
|
|
82
|
+
verification: declaration.data,
|
|
82
83
|
});
|
|
83
84
|
if (result === null)
|
|
84
85
|
return;
|
|
@@ -88,19 +89,22 @@ async function verifyCurrentCandidate(input, cursor) {
|
|
|
88
89
|
input.progress.recordResidue(state.id, verified.admission);
|
|
89
90
|
cursor.ran = verified.admission.facts.find((fact) => fact.kind === "attestation" && fact.data.gate === "verified")?.entry;
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
if (verified.reuse !== undefined)
|
|
93
|
+
cursor.ran = verified.reuse.entry;
|
|
94
|
+
const verification = verified.stop !== undefined
|
|
95
|
+
? { kind: "stopped", stop: verified.stop }
|
|
96
|
+
: verified.reuse !== undefined
|
|
97
|
+
? { kind: "reused", snapshot, ...verified.reuse }
|
|
98
|
+
: verified.counts === undefined
|
|
99
|
+
? undefined
|
|
100
|
+
: {
|
|
101
|
+
kind: "ran",
|
|
102
|
+
snapshot,
|
|
103
|
+
verdict: verified.counts.verdict,
|
|
104
|
+
...(cursor.ran === undefined ? {} : { entry: cursor.ran }),
|
|
105
|
+
...(verified.counts.verdict === "unsatisfied" ? { summary: verified.counts.summary } : {}),
|
|
106
|
+
};
|
|
107
|
+
cursor.evidence = verification === undefined ? {} : { verification };
|
|
104
108
|
input.progress.recordCandidate(state.id, cursor.evidence);
|
|
105
109
|
}
|
|
106
110
|
async function observeCandidateTarget(input, cursor) {
|
|
@@ -139,39 +143,27 @@ async function completedResult(input, cursor) {
|
|
|
139
143
|
...(predecessor === undefined || target === undefined ? {} : { predecessor, target }),
|
|
140
144
|
};
|
|
141
145
|
input.progress.recordCompletion(state.id, cursor.completion);
|
|
142
|
-
|
|
143
|
-
const current = currentVerifiedAttestation(state);
|
|
146
|
+
const declaration = input.deriveDocument(state).verification;
|
|
147
|
+
const current = declaration.data == null ? undefined : currentVerifiedAttestation(state);
|
|
144
148
|
const verification = current === undefined
|
|
145
149
|
? undefined
|
|
146
|
-
: {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
};
|
|
150
|
-
cursor.completion = { ...cursor.completion, ...(verification === undefined ? {} : { verification }) };
|
|
151
|
-
input.progress.recordCompletion(state.id, cursor.completion);
|
|
150
|
+
: { kind: cursor.ran === current.entry ? "ran" : "reused", snapshot: integration, ...current };
|
|
151
|
+
cursor.evidence = verification === undefined ? {} : { verification };
|
|
152
|
+
input.progress.recordCandidate(state.id, { ...cursor.evidence, completion: cursor.completion });
|
|
152
153
|
const scope = predecessor === undefined ? undefined : await readDeliveryScope(input.repository, predecessor, integration, false);
|
|
153
|
-
const { verificationSummary: _oldSummary, verificationReuse: _oldReuse, verificationSubject: _oldSubject, ...evidence } = cursor.evidence;
|
|
154
154
|
const completion = {
|
|
155
155
|
integration,
|
|
156
156
|
...(predecessor === undefined || target === undefined ? {} : { predecessor, target }),
|
|
157
157
|
...(scope === undefined
|
|
158
158
|
? {}
|
|
159
159
|
: { scope: { filesChanged: scope.filesChanged, insertions: scope.insertions, deletions: scope.deletions } }),
|
|
160
|
-
...(verification === undefined ? {} : { verification }),
|
|
161
160
|
};
|
|
162
161
|
cursor.completion = completion;
|
|
163
162
|
input.progress.recordCompletion(state.id, completion);
|
|
164
163
|
return {
|
|
165
164
|
kind: "completed",
|
|
166
165
|
checkpoint: cursor.checkpoint,
|
|
167
|
-
evidence: {
|
|
168
|
-
...evidence,
|
|
169
|
-
completion,
|
|
170
|
-
...(current === undefined || verification?.mode !== "reused" ? {} : { verificationReuse: current }),
|
|
171
|
-
...(current?.verdict !== "unsatisfied" || current.summary === undefined
|
|
172
|
-
? {}
|
|
173
|
-
: { verificationSummary: current.summary }),
|
|
174
|
-
},
|
|
166
|
+
evidence: { ...cursor.evidence, completion },
|
|
175
167
|
};
|
|
176
168
|
}
|
|
177
169
|
function stoppedResult(cursor, stop) {
|
|
@@ -226,34 +218,34 @@ async function placeCurrentCandidate(input, cursor) {
|
|
|
226
218
|
}
|
|
227
219
|
return result;
|
|
228
220
|
}
|
|
229
|
-
/** Verification blocks completion only when the Contract selected the verified gate; placement owns gate eligibility. */
|
|
230
|
-
function verificationBlocks(state) {
|
|
231
|
-
return state.terms.gates.includes(VERIFIED);
|
|
232
|
-
}
|
|
233
221
|
async function verifyCandidateReadiness(input, cursor) {
|
|
234
222
|
const observedPlacement = await observeCandidateTarget(input, cursor);
|
|
235
223
|
await verifyCurrentCandidate(input, cursor);
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
if (blocking || observedPlacement !== undefined) {
|
|
224
|
+
const stop = cursor.evidence.verification?.kind === "stopped" ? cursor.evidence.verification.stop : observedPlacement;
|
|
225
|
+
if (stop !== undefined) {
|
|
239
226
|
return {
|
|
240
227
|
kind: "stopped",
|
|
241
228
|
checkpoint: cursor.checkpoint,
|
|
242
229
|
evidence: { ...cursor.evidence, ...(observedPlacement === undefined ? {} : { placement: observedPlacement }) },
|
|
243
|
-
stop
|
|
230
|
+
stop,
|
|
244
231
|
};
|
|
245
232
|
}
|
|
246
233
|
return undefined;
|
|
247
234
|
}
|
|
248
235
|
async function advanceCandidate(input, cursor) {
|
|
249
|
-
if (input.start === "verification") {
|
|
250
|
-
const stopped = await verifyCandidateReadiness(input, cursor);
|
|
251
|
-
if (stopped !== undefined)
|
|
252
|
-
return stopped;
|
|
253
|
-
}
|
|
254
236
|
const target = cursor.checkpoint.state.coordinates.target;
|
|
255
|
-
let
|
|
237
|
+
let needsVerification = input.start === "verification";
|
|
256
238
|
for (let cycles = 0;; cycles += 1) {
|
|
239
|
+
input.signal?.throwIfAborted();
|
|
240
|
+
let placement = await observeIntegrationTargetMovement(input.repository, cursor.checkpoint.state);
|
|
241
|
+
if (placement === undefined) {
|
|
242
|
+
if (needsVerification) {
|
|
243
|
+
const stopped = await verifyCandidateReadiness(input, cursor);
|
|
244
|
+
if (stopped !== undefined)
|
|
245
|
+
return stopped;
|
|
246
|
+
}
|
|
247
|
+
placement = await placeCurrentCandidate(input, cursor);
|
|
248
|
+
}
|
|
257
249
|
if (placement.kind === "accepted")
|
|
258
250
|
return await completedResult(input, cursor);
|
|
259
251
|
if (placement.kind !== "target-moved" || target === undefined || placement.observedTreeEqualsCandidate) {
|
|
@@ -287,10 +279,7 @@ async function advanceCandidate(input, cursor) {
|
|
|
287
279
|
return stoppedResult(cursor, reintegrationStop(reintegrated));
|
|
288
280
|
cursor.checkpoint = contractCheckpoint(reintegrated);
|
|
289
281
|
input.progress.recordResidue(reintegrated.state.id, reintegrated);
|
|
290
|
-
|
|
291
|
-
if (stopped !== undefined)
|
|
292
|
-
return stopped;
|
|
293
|
-
placement = await placeCurrentCandidate(input, cursor);
|
|
282
|
+
needsVerification = true;
|
|
294
283
|
}
|
|
295
284
|
}
|
|
296
285
|
/** Advance one contract. The trigger owns the leading act; this node owns no other contract. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import type { ActorId, ContractId, ContractState, DeliverData } from "../core/facts/types.js";
|
|
2
|
+
import { candidateContentChangeSchema } from "./operations.js";
|
|
3
|
+
import type { ActorId, ContractId, ContractState, DeliverData, SnapshotId } from "../core/facts/types.js";
|
|
4
4
|
import { type CurrentVerifiedAttestation } from "./intent.js";
|
|
5
5
|
import type { LeadingOutcome } from "./outcome.js";
|
|
6
6
|
import type { CompletionEvidence } from "./completion.js";
|
|
@@ -14,21 +14,22 @@ export declare const deliverLeadingSchema: z.ZodObject<{
|
|
|
14
14
|
"already-admitted": "already-admitted";
|
|
15
15
|
}>;
|
|
16
16
|
fact: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").EntryUlid, string>>;
|
|
17
|
+
reusedIntegration: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>>;
|
|
17
18
|
}, z.core.$strict>;
|
|
18
19
|
type DeliverLeading = z.infer<typeof deliverLeadingSchema>;
|
|
19
20
|
type DeliverValue = DeliveryIdentity & CompletionEvidence & Readonly<{
|
|
20
21
|
leading: DeliverLeading;
|
|
22
|
+
contentChange?: z.infer<typeof candidateContentChangeSchema>;
|
|
21
23
|
}>;
|
|
22
|
-
export type AppointedWorkspace = z.infer<typeof worktreeWorkspaceSchema>;
|
|
23
24
|
export declare const materializedConflictSchema: z.ZodObject<{
|
|
24
25
|
kind: z.ZodLiteral<"integration-conflict-materialized">;
|
|
25
|
-
targetHead: z.ZodPipe<z.ZodString, z.ZodTransform<
|
|
26
|
+
targetHead: z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>;
|
|
26
27
|
conflictPaths: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
27
28
|
workspace: z.ZodObject<{
|
|
28
29
|
kind: z.ZodLiteral<"worktree">;
|
|
29
30
|
path: z.ZodString;
|
|
30
31
|
}, z.core.$strict>;
|
|
31
|
-
handoffBase: z.ZodPipe<z.ZodString, z.ZodTransform<
|
|
32
|
+
handoffBase: z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>;
|
|
32
33
|
recovery: z.ZodObject<{
|
|
33
34
|
materialize: z.ZodLiteral<"deliver --materialize-conflict --include-dirty">;
|
|
34
35
|
deliver: z.ZodLiteral<"deliver --include-dirty">;
|
|
@@ -49,6 +50,7 @@ type DeliverOperationRefusal = import("../core/verbs/deliver.js").DeliverRefusal
|
|
|
49
50
|
export declare function prepareDelivery(repository: import("../git/process.js").GitRepository, stage: Readonly<{
|
|
50
51
|
contractId: ContractId;
|
|
51
52
|
coordinates: ContractState["coordinates"];
|
|
53
|
+
recordedIntegrations?: readonly SnapshotId[];
|
|
52
54
|
appointment?: Extract<ManagedWorktreeAppointment, {
|
|
53
55
|
kind: "appointed";
|
|
54
56
|
}>;
|