@abelxiaoxing/cadence 1.6.0 → 1.8.0
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 +25 -4
- package/config/.env.example +6 -0
- package/config/plan-draft.example.json +3 -0
- package/config/plan-draft.multiple-tasks.example.json +30 -0
- package/package.json +1 -1
- package/prompts/abel-design.md +33 -3
- package/prompts/abel-implement.md +36 -4
- package/src/apply-transaction.ts +28 -8
- package/src/build-windows-job.mjs +95 -0
- package/src/candidate-workspace.ts +6 -0
- package/src/change-verification.ts +764 -67
- package/src/contracts.ts +8 -0
- package/src/delivery-compiler.ts +452 -9
- package/src/design-control.ts +2 -2
- package/src/design-diagnostics.ts +6 -4
- package/src/durable-contracts.ts +21 -3
- package/src/durable-workflow.ts +55 -40
- package/src/execution-profile.ts +28 -2
- package/src/execution-retention.ts +77 -0
- package/src/implement-continuation.ts +559 -0
- package/src/implement-graph.ts +114 -0
- package/src/implement-plan.ts +2 -0
- package/src/index.ts +151 -1
- package/src/isolation-backend.ts +2 -1
- package/src/operator-cli.mjs +664 -104
- package/src/operator-tools.ts +7 -1
- package/src/package-state.ts +11 -0
- package/src/package-verification.ts +66 -18
- package/src/package-workflow.ts +6 -0
- package/src/phase-execution.ts +18 -7
- package/src/plan-draft-summary.ts +385 -7
- package/src/plan-draft.ts +9 -0
- package/src/remove-path.ts +32 -0
- package/src/subagent-activity.ts +3 -1
- package/src/verification-capability.ts +18 -6
- package/src/verification-environment-io.ts +123 -14
- package/src/verification-environment.ts +50 -3
- package/src/windows-job-backend.ts +419 -0
- package/src/windows-job.c +149 -0
- package/src/workflow-policy.ts +296 -5
- package/src/workflow-recovery-policy.ts +2 -0
- package/src/workflow-state-machine.ts +314 -80
- package/src/workflow-status.ts +251 -59
- package/src/workspace-io-entry.mjs +2 -2
- package/src/workspace-io-worker.mjs +207 -110
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { compareCanonicalStrings } from "./canonical.ts";
|
|
2
|
+
import {
|
|
3
|
+
isValidRelativePath,
|
|
4
|
+
LIMITS,
|
|
5
|
+
verificationInputPaths,
|
|
6
|
+
} from "./contracts.ts";
|
|
7
|
+
import type { ImplementPlan, PlanTaskDraft } from "./implement-plan.ts";
|
|
3
8
|
import { expandSingleTaskDraft } from "./single-task-draft.ts";
|
|
9
|
+
import { declarationPathsConflict, taskConflicts } from "./workflow-policy.ts";
|
|
4
10
|
|
|
5
11
|
/** Review data only: no executable callbacks, evidence cache or approval authority. */
|
|
6
12
|
function record(value: unknown): Record<string, unknown> {
|
|
@@ -8,12 +14,156 @@ function record(value: unknown): Record<string, unknown> {
|
|
|
8
14
|
? (value as Record<string, unknown>)
|
|
9
15
|
: {};
|
|
10
16
|
}
|
|
17
|
+
|
|
18
|
+
type SerializationCause =
|
|
19
|
+
| {
|
|
20
|
+
kind: "producer-output" | "declared-dependency";
|
|
21
|
+
waitingTaskId: string;
|
|
22
|
+
dependencyTaskId: string;
|
|
23
|
+
outputIds: string[];
|
|
24
|
+
}
|
|
25
|
+
| { kind: "declared-task-conflict" }
|
|
26
|
+
| { kind: "declared-resource"; resources: string[] }
|
|
27
|
+
| {
|
|
28
|
+
kind: "shared-writes";
|
|
29
|
+
paths: Array<{ left: string; right: string }>;
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
kind: "shared-write-read";
|
|
33
|
+
paths: Array<{ writer: string; reader: string }>;
|
|
34
|
+
}
|
|
35
|
+
| { kind: "verification-lock"; locks: string[] }
|
|
36
|
+
| { kind: "agents-target"; targets: string[] };
|
|
37
|
+
|
|
38
|
+
function taskAncestors(
|
|
39
|
+
taskId: string,
|
|
40
|
+
tasks: ReadonlyMap<string, PlanTaskDraft>,
|
|
41
|
+
): Set<string> {
|
|
42
|
+
const ancestors = new Set<string>();
|
|
43
|
+
const pending = [...(tasks.get(taskId)?.dependsOn ?? [])];
|
|
44
|
+
while (pending.length > 0) {
|
|
45
|
+
const dependency = pending.pop() as string;
|
|
46
|
+
if (ancestors.has(dependency)) continue;
|
|
47
|
+
ancestors.add(dependency);
|
|
48
|
+
pending.push(...(tasks.get(dependency)?.dependsOn ?? []));
|
|
49
|
+
}
|
|
50
|
+
return ancestors;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function declarations(task: PlanTaskDraft) {
|
|
54
|
+
const reads = new Set<string>();
|
|
55
|
+
const writes = new Set<string>();
|
|
56
|
+
const locks = new Set<string>();
|
|
57
|
+
for (const phase of Object.values(task.phases)) {
|
|
58
|
+
for (const entry of phase.read) reads.add(entry);
|
|
59
|
+
for (const entry of phase.write) writes.add(entry);
|
|
60
|
+
for (const entry of phase.delete) writes.add(entry);
|
|
61
|
+
if (phase.verificationLock) locks.add(phase.verificationLock);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
reads: [...reads].sort(compareCanonicalStrings),
|
|
65
|
+
writes: [...writes].sort(compareCanonicalStrings),
|
|
66
|
+
locks: [...locks].sort(compareCanonicalStrings),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function conflictingPathPairs(
|
|
71
|
+
left: readonly string[],
|
|
72
|
+
right: readonly string[],
|
|
73
|
+
): Array<{ left: string; right: string }> {
|
|
74
|
+
return left.flatMap((leftPath) =>
|
|
75
|
+
right.flatMap((rightPath) =>
|
|
76
|
+
declarationPathsConflict(leftPath, rightPath)
|
|
77
|
+
? [{ left: leftPath, right: rightPath }]
|
|
78
|
+
: [],
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function conflictCauses(
|
|
84
|
+
left: PlanTaskDraft,
|
|
85
|
+
right: PlanTaskDraft,
|
|
86
|
+
truncate: () => void,
|
|
87
|
+
): SerializationCause[] {
|
|
88
|
+
const causes: SerializationCause[] = [];
|
|
89
|
+
if (
|
|
90
|
+
left.scheduling.conflicts.includes(right.taskId) ||
|
|
91
|
+
right.scheduling.conflicts.includes(left.taskId)
|
|
92
|
+
) {
|
|
93
|
+
causes.push({ kind: "declared-task-conflict" });
|
|
94
|
+
}
|
|
95
|
+
const resources = left.scheduling.resources
|
|
96
|
+
.filter((resource) => right.scheduling.resources.includes(resource))
|
|
97
|
+
.sort(compareCanonicalStrings);
|
|
98
|
+
if (resources.length > 8) truncate();
|
|
99
|
+
if (resources.length > 0) {
|
|
100
|
+
causes.push({
|
|
101
|
+
kind: "declared-resource",
|
|
102
|
+
resources: resources.slice(0, 8),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const leftDeclarations = declarations(left);
|
|
107
|
+
const rightDeclarations = declarations(right);
|
|
108
|
+
const sharedWrites = conflictingPathPairs(
|
|
109
|
+
leftDeclarations.writes,
|
|
110
|
+
rightDeclarations.writes,
|
|
111
|
+
);
|
|
112
|
+
const leftWriteReads = conflictingPathPairs(
|
|
113
|
+
leftDeclarations.writes,
|
|
114
|
+
rightDeclarations.reads,
|
|
115
|
+
);
|
|
116
|
+
const rightWriteReads = conflictingPathPairs(
|
|
117
|
+
rightDeclarations.writes,
|
|
118
|
+
leftDeclarations.reads,
|
|
119
|
+
).map(({ left: writer, right: reader }) => ({ writer, reader }));
|
|
120
|
+
if (sharedWrites.length > 8) truncate();
|
|
121
|
+
if (sharedWrites.length > 0) {
|
|
122
|
+
causes.push({ kind: "shared-writes", paths: sharedWrites.slice(0, 8) });
|
|
123
|
+
}
|
|
124
|
+
const writeReads = [
|
|
125
|
+
...leftWriteReads.map(({ left: writer, right: reader }) => ({
|
|
126
|
+
writer,
|
|
127
|
+
reader,
|
|
128
|
+
})),
|
|
129
|
+
...rightWriteReads,
|
|
130
|
+
];
|
|
131
|
+
if (writeReads.length > 8) truncate();
|
|
132
|
+
if (writeReads.length > 0) {
|
|
133
|
+
causes.push({
|
|
134
|
+
kind: "shared-write-read",
|
|
135
|
+
paths: writeReads.slice(0, 8),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (
|
|
139
|
+
left.agents.impact !== "none" &&
|
|
140
|
+
right.agents.impact !== "none" &&
|
|
141
|
+
left.agents.target &&
|
|
142
|
+
left.agents.target === right.agents.target
|
|
143
|
+
) {
|
|
144
|
+
causes.push({ kind: "agents-target", targets: [left.agents.target] });
|
|
145
|
+
}
|
|
146
|
+
const locks = leftDeclarations.locks
|
|
147
|
+
.filter((lock) => rightDeclarations.locks.includes(lock))
|
|
148
|
+
.sort(compareCanonicalStrings);
|
|
149
|
+
if (locks.length > 8) truncate();
|
|
150
|
+
if (locks.length > 0) {
|
|
151
|
+
causes.push({ kind: "verification-lock", locks: locks.slice(0, 8) });
|
|
152
|
+
}
|
|
153
|
+
return causes;
|
|
154
|
+
}
|
|
11
155
|
export function planAuthoringSummary(
|
|
12
156
|
plan: ImplementPlan,
|
|
13
157
|
authoredDraft?: unknown,
|
|
14
158
|
) {
|
|
15
159
|
const quick = record(authoredDraft).singleTask !== undefined;
|
|
16
160
|
const authored = record(expandSingleTaskDraft(authoredDraft));
|
|
161
|
+
const authoredTask = (taskId: string) =>
|
|
162
|
+
record(
|
|
163
|
+
Array.isArray(authored.tasks)
|
|
164
|
+
? authored.tasks.find((item) => record(item).taskId === taskId)
|
|
165
|
+
: undefined,
|
|
166
|
+
);
|
|
17
167
|
const derivations: Array<{ field: string; source: string; taskId?: string }> =
|
|
18
168
|
[];
|
|
19
169
|
let derivationsTruncated = false;
|
|
@@ -30,11 +180,17 @@ export function planAuthoringSummary(
|
|
|
30
180
|
if (plan.changeContract && !Object.hasOwn(authored, "changeContract"))
|
|
31
181
|
derived("changeContract", "approved-gate-a");
|
|
32
182
|
for (const task of plan.tasks) {
|
|
33
|
-
const input =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
183
|
+
const input = authoredTask(task.taskId);
|
|
184
|
+
if (
|
|
185
|
+
task.baselineVerification &&
|
|
186
|
+
!Object.hasOwn(input, "baselineVerification")
|
|
187
|
+
) {
|
|
188
|
+
derived(
|
|
189
|
+
"baselineVerification",
|
|
190
|
+
"affected-safe-original-inputs",
|
|
191
|
+
task.taskId,
|
|
192
|
+
);
|
|
193
|
+
}
|
|
38
194
|
for (const [phase, boundary] of Object.entries(task.phases)) {
|
|
39
195
|
const phaseInput = record(record(input.phases)[phase]);
|
|
40
196
|
if (!Object.hasOwn(phaseInput, "verificationInputs"))
|
|
@@ -112,8 +268,21 @@ export function planAuthoringSummary(
|
|
|
112
268
|
classification: boundary.verification.classification,
|
|
113
269
|
verificationInputs: boundary.verificationInputs.slice(0, 32),
|
|
114
270
|
})),
|
|
271
|
+
baselineVerification: task.baselineVerification?.id ?? null,
|
|
115
272
|
affectedVerification: task.affectedVerification.id,
|
|
116
273
|
repairVerification: task.repairVerification.id,
|
|
274
|
+
verificationSources: {
|
|
275
|
+
baseline:
|
|
276
|
+
authoredDraft === undefined
|
|
277
|
+
? "compiled-plan"
|
|
278
|
+
: Object.hasOwn(authoredTask(task.taskId), "baselineVerification")
|
|
279
|
+
? "author-input"
|
|
280
|
+
: task.baselineVerification
|
|
281
|
+
? "affected-safe-original-inputs"
|
|
282
|
+
: "retained-legacy",
|
|
283
|
+
affected: authoredDraft === undefined ? "compiled-plan" : "author-input",
|
|
284
|
+
repair: authoredDraft === undefined ? "compiled-plan" : "author-input",
|
|
285
|
+
},
|
|
117
286
|
agentsImpact: task.agents.impact,
|
|
118
287
|
}));
|
|
119
288
|
if (
|
|
@@ -126,8 +295,216 @@ export function planAuthoringSummary(
|
|
|
126
295
|
)
|
|
127
296
|
)
|
|
128
297
|
truncated = true;
|
|
298
|
+
|
|
299
|
+
const projectedTasks = [...plan.tasks]
|
|
300
|
+
.sort((left, right) => compareCanonicalStrings(left.taskId, right.taskId))
|
|
301
|
+
.slice(0, 16);
|
|
302
|
+
const tasksById = new Map(plan.tasks.map((task) => [task.taskId, task]));
|
|
303
|
+
const ancestors = new Map(
|
|
304
|
+
plan.tasks.map((task) => [
|
|
305
|
+
task.taskId,
|
|
306
|
+
taskAncestors(task.taskId, tasksById),
|
|
307
|
+
]),
|
|
308
|
+
);
|
|
309
|
+
const outputsById = new Map(
|
|
310
|
+
plan.outputs.map((output) => [output.id, output]),
|
|
311
|
+
);
|
|
312
|
+
const consumedOutputsByTask = new Map<string, string[]>();
|
|
313
|
+
const consumedOutputIds = (task: PlanTaskDraft) => {
|
|
314
|
+
const cached = consumedOutputsByTask.get(task.taskId);
|
|
315
|
+
if (cached) return cached;
|
|
316
|
+
const ids = new Set(
|
|
317
|
+
Object.values(task.phases).flatMap((phase) =>
|
|
318
|
+
phase.verificationInputs.flatMap((binding) =>
|
|
319
|
+
binding.kind === "output" ? [binding.outputId] : [],
|
|
320
|
+
),
|
|
321
|
+
),
|
|
322
|
+
);
|
|
323
|
+
const finalInputs = new Set([
|
|
324
|
+
...verificationInputPaths(task.affectedVerification),
|
|
325
|
+
...verificationInputPaths(task.repairVerification),
|
|
326
|
+
]);
|
|
327
|
+
for (const output of plan.outputs) {
|
|
328
|
+
if (finalInputs.has(output.path)) ids.add(output.id);
|
|
329
|
+
}
|
|
330
|
+
const consumed = [...ids].sort(compareCanonicalStrings);
|
|
331
|
+
consumedOutputsByTask.set(task.taskId, consumed);
|
|
332
|
+
return consumed;
|
|
333
|
+
};
|
|
334
|
+
const dependencyCause = (
|
|
335
|
+
waitingTask: PlanTaskDraft,
|
|
336
|
+
dependencyTaskId: string,
|
|
337
|
+
): Extract<
|
|
338
|
+
SerializationCause,
|
|
339
|
+
{ kind: "producer-output" | "declared-dependency" }
|
|
340
|
+
> => {
|
|
341
|
+
const outputIds = consumedOutputIds(waitingTask).filter(
|
|
342
|
+
(outputId) =>
|
|
343
|
+
outputsById.get(outputId)?.producer.taskId === dependencyTaskId,
|
|
344
|
+
);
|
|
345
|
+
if (outputIds.length > 16) truncated = true;
|
|
346
|
+
return {
|
|
347
|
+
kind: outputIds.length > 0 ? "producer-output" : "declared-dependency",
|
|
348
|
+
waitingTaskId: waitingTask.taskId,
|
|
349
|
+
dependencyTaskId,
|
|
350
|
+
outputIds: outputIds.slice(0, 16),
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
const waiting: Array<{
|
|
354
|
+
taskId: string;
|
|
355
|
+
dependencyTaskId: string;
|
|
356
|
+
reason: "producer-output" | "declared-dependency";
|
|
357
|
+
outputIds: string[];
|
|
358
|
+
}> = [];
|
|
359
|
+
for (const task of projectedTasks) {
|
|
360
|
+
for (const dependencyTaskId of [...task.dependsOn].sort(
|
|
361
|
+
compareCanonicalStrings,
|
|
362
|
+
)) {
|
|
363
|
+
if (waiting.length >= 128) {
|
|
364
|
+
truncated = true;
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
const cause = dependencyCause(task, dependencyTaskId);
|
|
368
|
+
waiting.push({
|
|
369
|
+
taskId: task.taskId,
|
|
370
|
+
dependencyTaskId,
|
|
371
|
+
reason: cause.kind,
|
|
372
|
+
outputIds: cause.outputIds,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const staticEligiblePairs: Array<{ taskIds: [string, string] }> = [];
|
|
377
|
+
const serializations: Array<{
|
|
378
|
+
taskIds: [string, string];
|
|
379
|
+
causes: SerializationCause[];
|
|
380
|
+
}> = [];
|
|
381
|
+
for (const [index, left] of projectedTasks.entries()) {
|
|
382
|
+
for (const right of projectedTasks.slice(index + 1)) {
|
|
383
|
+
const leftWaits = ancestors.get(left.taskId)?.has(right.taskId) ?? false;
|
|
384
|
+
const rightWaits = ancestors.get(right.taskId)?.has(left.taskId) ?? false;
|
|
385
|
+
const conflict = taskConflicts(left, right);
|
|
386
|
+
if (
|
|
387
|
+
!leftWaits &&
|
|
388
|
+
!rightWaits &&
|
|
389
|
+
!conflict.taskLifetime &&
|
|
390
|
+
!conflict.verification
|
|
391
|
+
) {
|
|
392
|
+
if (staticEligiblePairs.length < 64) {
|
|
393
|
+
staticEligiblePairs.push({ taskIds: [left.taskId, right.taskId] });
|
|
394
|
+
} else {
|
|
395
|
+
truncated = true;
|
|
396
|
+
}
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
const causes: SerializationCause[] = [];
|
|
400
|
+
if (leftWaits) causes.push(dependencyCause(left, right.taskId));
|
|
401
|
+
if (rightWaits) causes.push(dependencyCause(right, left.taskId));
|
|
402
|
+
if (conflict.taskLifetime || conflict.verification) {
|
|
403
|
+
causes.push(...conflictCauses(left, right, () => (truncated = true)));
|
|
404
|
+
}
|
|
405
|
+
if (serializations.length < 64) {
|
|
406
|
+
serializations.push({ taskIds: [left.taskId, right.taskId], causes });
|
|
407
|
+
} else {
|
|
408
|
+
truncated = true;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const initiallyEligibleTasks = projectedTasks.filter(
|
|
413
|
+
(task) => task.dependsOn.length === 0,
|
|
414
|
+
);
|
|
415
|
+
const initiallyRunnableTasks: PlanTaskDraft[] = [];
|
|
416
|
+
for (const task of initiallyEligibleTasks) {
|
|
417
|
+
if (initiallyRunnableTasks.length >= LIMITS.maxActiveChildSessions) break;
|
|
418
|
+
if (
|
|
419
|
+
initiallyRunnableTasks.some((selected) => {
|
|
420
|
+
const conflict = taskConflicts(task, selected);
|
|
421
|
+
return conflict.taskLifetime || conflict.verification;
|
|
422
|
+
})
|
|
423
|
+
) {
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
initiallyRunnableTasks.push(task);
|
|
427
|
+
}
|
|
428
|
+
const checkpoint = plan.verification.agentsCheckpoint;
|
|
429
|
+
const bounded = (values: readonly string[]) => {
|
|
430
|
+
if (values.length > 32) truncated = true;
|
|
431
|
+
return values.slice(0, 32);
|
|
432
|
+
};
|
|
433
|
+
const contract = plan.changeContract;
|
|
434
|
+
// Review the outer recovery envelope as well as the initial task paths.
|
|
435
|
+
// This projection never grants authority or certifies runtime readiness.
|
|
436
|
+
const implementation = {
|
|
437
|
+
authority: "review-only" as const,
|
|
438
|
+
decisionOwner: "parent" as const,
|
|
439
|
+
userDecisionStage: "abel-design" as const,
|
|
440
|
+
policySource: contract
|
|
441
|
+
? ("structured-change-contract" as const)
|
|
442
|
+
: ("retained-legacy-boundaries" as const),
|
|
443
|
+
acceptanceIds: bounded(contract?.acceptance.map((entry) => entry.id) ?? []),
|
|
444
|
+
constraintIds: bounded(
|
|
445
|
+
contract?.constraints.map((entry) => entry.id) ?? [],
|
|
446
|
+
),
|
|
447
|
+
amendmentPolicy: contract
|
|
448
|
+
? {
|
|
449
|
+
writeRoots: bounded(contract.policy.writeRoots),
|
|
450
|
+
dependencies: bounded(contract.policy.dependencies),
|
|
451
|
+
verificationModes: [...contract.policy.verificationModes],
|
|
452
|
+
}
|
|
453
|
+
: null,
|
|
454
|
+
recovery: {
|
|
455
|
+
strategy: "repair-replan-resume" as const,
|
|
456
|
+
preservesAcceptance: true,
|
|
457
|
+
preservesConsumedBudget: true,
|
|
458
|
+
},
|
|
459
|
+
runtimePrerequisites: "not-assessed" as const,
|
|
460
|
+
};
|
|
129
461
|
return {
|
|
130
462
|
tasks,
|
|
463
|
+
implementation,
|
|
464
|
+
parallelism: {
|
|
465
|
+
assessment: "static-plan" as const,
|
|
466
|
+
authority: "review-only" as const,
|
|
467
|
+
runtimePrerequisites: "not-assessed" as const,
|
|
468
|
+
initiallyEligibleScope: "individual-dependency-free" as const,
|
|
469
|
+
initiallyEligible: initiallyEligibleTasks.map((task) => task.taskId),
|
|
470
|
+
initiallyRunnableGroup: {
|
|
471
|
+
taskIds: initiallyRunnableTasks.map((task) => task.taskId),
|
|
472
|
+
maximumSize: LIMITS.maxActiveChildSessions,
|
|
473
|
+
basis: "dependency-free-task-conflict-policy" as const,
|
|
474
|
+
capacityAssumption: "all-shared-slots-available" as const,
|
|
475
|
+
},
|
|
476
|
+
staticEligiblePairsScope: "eventual-compatibility" as const,
|
|
477
|
+
staticEligiblePairs,
|
|
478
|
+
waiting,
|
|
479
|
+
serializations,
|
|
480
|
+
globalBarriers: [
|
|
481
|
+
{
|
|
482
|
+
kind: "cumulative-verification" as const,
|
|
483
|
+
required: true,
|
|
484
|
+
verificationId: plan.verification.change.fullSuite.id,
|
|
485
|
+
requires: ["all-tasks-verified" as const],
|
|
486
|
+
taskIds: projectedTasks.map((task) => task.taskId),
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
kind: "agents-checkpoint" as const,
|
|
490
|
+
required: checkpoint.required,
|
|
491
|
+
verificationId: checkpoint.verification?.id ?? null,
|
|
492
|
+
requires: ["cumulative-verification" as const],
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
kind: "post-apply-verification" as const,
|
|
496
|
+
required: true,
|
|
497
|
+
verificationId: plan.verification.change.postApply.id,
|
|
498
|
+
requires: [
|
|
499
|
+
"cumulative-verification" as const,
|
|
500
|
+
...(checkpoint.required
|
|
501
|
+
? (["agents-checkpoint" as const] as const)
|
|
502
|
+
: []),
|
|
503
|
+
"transactional-apply" as const,
|
|
504
|
+
],
|
|
505
|
+
},
|
|
506
|
+
],
|
|
507
|
+
},
|
|
131
508
|
recovery: {
|
|
132
509
|
artifactCorrection: plan.verification.artifactCorrection.maxAttempts,
|
|
133
510
|
repair: plan.verification.repair.maxAttempts,
|
|
@@ -141,6 +518,7 @@ export function planAuthoringSummary(
|
|
|
141
518
|
derivationRules: [
|
|
142
519
|
"tracking:task-ids",
|
|
143
520
|
"verificationInputs:contract-and-declared-outputs",
|
|
521
|
+
"baselineVerification:affected-safe-original-inputs",
|
|
144
522
|
"relatedTests:declared-writers",
|
|
145
523
|
"verification-identities:stable-task-and-purpose",
|
|
146
524
|
],
|
package/src/plan-draft.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface PlanTaskInput
|
|
|
53
53
|
PlanTaskDraft,
|
|
54
54
|
| "phases"
|
|
55
55
|
| "impactClosure"
|
|
56
|
+
| "baselineVerification"
|
|
56
57
|
| "affectedVerification"
|
|
57
58
|
| "repairVerification"
|
|
58
59
|
| "agents"
|
|
@@ -64,6 +65,7 @@ export interface PlanTaskInput
|
|
|
64
65
|
refactor?: PlanPhaseDraft;
|
|
65
66
|
};
|
|
66
67
|
affectedVerification: DraftVerification;
|
|
68
|
+
baselineVerification?: DraftVerification;
|
|
67
69
|
repairVerification: DraftVerification;
|
|
68
70
|
agents: Omit<PlanTaskDraft["agents"], "managedOnly"> & { managedOnly?: true };
|
|
69
71
|
impactClosure: Omit<PlanTaskDraft["impactClosure"], "relatedTests"> & {
|
|
@@ -324,6 +326,13 @@ export function expandPlanDraft(value: unknown): unknown {
|
|
|
324
326
|
}
|
|
325
327
|
for (const field of ["affectedVerification", "repairVerification"])
|
|
326
328
|
task[field] = expand(task[field], field, "expected-green", taskId);
|
|
329
|
+
if (task.baselineVerification !== undefined)
|
|
330
|
+
task.baselineVerification = expand(
|
|
331
|
+
task.baselineVerification,
|
|
332
|
+
"baselineVerification",
|
|
333
|
+
"expected-green",
|
|
334
|
+
taskId,
|
|
335
|
+
);
|
|
327
336
|
}
|
|
328
337
|
if (isRecord(draft.verification)) {
|
|
329
338
|
const verification = draft.verification;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { lstatSync, readdirSync, rmdirSync, rmSync, unlinkSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
/** Remove owned paths without following directory links. Node 24.13's Windows
|
|
5
|
+
* rmSync uses narrow std::filesystem paths and can silently miss Unicode names.
|
|
6
|
+
* The libuv-backed unlink/rmdir APIs preserve the original UTF-16 path. */
|
|
7
|
+
export function removePathSync(
|
|
8
|
+
target: string,
|
|
9
|
+
options: { recursive?: boolean; force?: boolean } = {},
|
|
10
|
+
): void {
|
|
11
|
+
if (process.platform !== "win32") {
|
|
12
|
+
rmSync(target, options);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let stat: import("node:fs").Stats;
|
|
16
|
+
try {
|
|
17
|
+
stat = lstatSync(target);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (options.force && (error as NodeJS.ErrnoException).code === "ENOENT")
|
|
20
|
+
return;
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
if (stat.isDirectory() && !stat.isSymbolicLink()) {
|
|
24
|
+
if (!options.recursive)
|
|
25
|
+
throw Object.assign(new Error("Path is a directory"), {
|
|
26
|
+
code: "ERR_FS_EISDIR",
|
|
27
|
+
});
|
|
28
|
+
for (const name of readdirSync(target))
|
|
29
|
+
removePathSync(path.join(target, name), options);
|
|
30
|
+
rmdirSync(target);
|
|
31
|
+
} else unlinkSync(target);
|
|
32
|
+
}
|
package/src/subagent-activity.ts
CHANGED
|
@@ -501,7 +501,9 @@ function hasAutomaticContinuation(result: Record<string, unknown>): boolean {
|
|
|
501
501
|
asRecord(result.pause)?.code !== "operation-cancelled" &&
|
|
502
502
|
continuation?.owner === "parent" &&
|
|
503
503
|
continuation.automatic === true &&
|
|
504
|
-
(continuation.action === "amend" ||
|
|
504
|
+
(continuation.action === "amend" ||
|
|
505
|
+
continuation.command === "resume" ||
|
|
506
|
+
continuation.kind === "inspect-recovery")
|
|
505
507
|
);
|
|
506
508
|
}
|
|
507
509
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
type StructuredVerificationContract,
|
|
12
12
|
VERIFICATION_CONFIGURATION_PATHS,
|
|
13
13
|
type VerificationAdapterCode,
|
|
14
|
+
type VerificationInputObservation,
|
|
14
15
|
validateVerificationContract,
|
|
15
16
|
verificationBoundInputPaths,
|
|
16
17
|
verificationInputPaths,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
snapshotFile,
|
|
24
25
|
snapshotFiles,
|
|
25
26
|
} from "./file-snapshot.ts";
|
|
26
|
-
import {
|
|
27
|
+
import { observeSafePath } from "./safe-path.ts";
|
|
27
28
|
import { verificationEnvironmentDigest } from "./verification-identity.ts";
|
|
28
29
|
|
|
29
30
|
export type VerificationCapabilityDiagnostic =
|
|
@@ -38,6 +39,7 @@ export type VerificationCapabilityDiagnostic =
|
|
|
38
39
|
code: VerificationAdapterCode;
|
|
39
40
|
verificationId: string;
|
|
40
41
|
message: string;
|
|
42
|
+
inputObservation?: VerificationInputObservation;
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
export type VerificationCapabilityResult =
|
|
@@ -118,10 +120,17 @@ function adapterFailure(
|
|
|
118
120
|
verificationId: string,
|
|
119
121
|
code: VerificationAdapterCode,
|
|
120
122
|
message: string,
|
|
123
|
+
inputObservation?: VerificationInputObservation,
|
|
121
124
|
): VerificationCapabilityResult {
|
|
122
125
|
return {
|
|
123
126
|
ok: false,
|
|
124
|
-
diagnostic: {
|
|
127
|
+
diagnostic: {
|
|
128
|
+
kind: "verification-adapter",
|
|
129
|
+
code,
|
|
130
|
+
verificationId,
|
|
131
|
+
message,
|
|
132
|
+
...(inputObservation ? { inputObservation } : {}),
|
|
133
|
+
},
|
|
125
134
|
};
|
|
126
135
|
}
|
|
127
136
|
|
|
@@ -829,7 +838,7 @@ function validateAtomicCapability(
|
|
|
829
838
|
continue;
|
|
830
839
|
if (
|
|
831
840
|
lstatSync(path.join(root, relative)).size > 64 * 1024 ||
|
|
832
|
-
(executionProfile().mode
|
|
841
|
+
(executionProfile().mode === "isolated" &&
|
|
833
842
|
unsupportedExecutionConfiguration(
|
|
834
843
|
readFileSync(path.join(root, relative), "utf8"),
|
|
835
844
|
))
|
|
@@ -1154,11 +1163,14 @@ function validateAcceptedVerificationCapability(
|
|
|
1154
1163
|
): VerificationCapabilityResult {
|
|
1155
1164
|
if (requireInputAvailability) {
|
|
1156
1165
|
for (const input of verificationInputPaths(verification)) {
|
|
1157
|
-
|
|
1166
|
+
const status = fileStatus(root, input);
|
|
1167
|
+
if (status !== "regular") {
|
|
1168
|
+
const inputObservation = { path: input, kind: status } as const;
|
|
1158
1169
|
return adapterFailure(
|
|
1159
1170
|
verification.id,
|
|
1160
|
-
"input-missing",
|
|
1161
|
-
`verification input ${input} is
|
|
1171
|
+
status === "absent" ? "input-missing" : "input-unsafe",
|
|
1172
|
+
`verification input ${input} is ${status}`,
|
|
1173
|
+
inputObservation,
|
|
1162
1174
|
);
|
|
1163
1175
|
}
|
|
1164
1176
|
}
|