@abelxiaoxing/cadence 1.8.4 → 2.0.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 +324 -117
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/agents/design-explorer.md +14 -18
- package/agents/diagnosis-worker.md +14 -14
- package/agents/implementation-worker.md +16 -17
- package/config/workflow-task.example.json +7 -0
- package/docs/remote-access.md +60 -0
- package/docs/reuse-and-distribution.md +44 -0
- package/docs/service-management.md +108 -0
- package/licenses/bundled-web.txt +6245 -0
- package/licenses/pi-web-ui-MIT.txt +21 -0
- package/licenses/pi-web-ui-reuse.md +22 -0
- package/package.json +94 -21
- package/src/index.ts +21 -1802
- package/src/native-build.ts +6 -0
- package/src/native-client.ts +103 -0
- package/src/native-export.ts +58 -0
- package/src/native-history.ts +359 -0
- package/src/operator-cli.mjs +453 -1937
- package/src/plan-proposal.ts +87 -0
- package/src/sdk-worker.mjs +549 -0
- package/src/service/contracts/active.ts +82 -0
- package/src/service/contracts/budget.ts +148 -0
- package/src/service/contracts/build.ts +67 -0
- package/src/service/contracts/capture.ts +48 -0
- package/src/service/contracts/core.ts +33 -0
- package/src/service/contracts/current.ts +261 -0
- package/src/service/contracts/domain.ts +68 -0
- package/src/service/contracts/history.ts +2245 -0
- package/src/service/contracts/models.ts +139 -0
- package/src/service/coordination.ts +862 -0
- package/src/service/private-files.ts +204 -0
- package/src/service-cli.mjs +5592 -0
- package/src/service-client.ts +747 -0
- package/src/service-contract.ts +245 -0
- package/src/service-host.mjs +22382 -0
- package/src/service-http-client.ts +425 -0
- package/src/service-wire.ts +372 -0
- package/src/task-shell.ts +1045 -0
- package/src/task-store.ts +479 -0
- package/src/task-types.ts +184 -0
- package/src/verification-diagnostics.ts +29 -72
- package/src/worker-capture.mjs +1197 -0
- package/src/worker-public.mjs +1753 -0
- package/src/worker-redaction.mjs +608 -0
- package/src/worker-tools.mjs +202 -0
- package/web/dist/assets/KaTeX_AMS-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold.woff +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Bold.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-Bold.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Bold.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic.woff +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Italic.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-Italic.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Italic.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic.woff +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/web/dist/assets/KaTeX_Math-Italic.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-Italic.woff +0 -0
- package/web/dist/assets/KaTeX_Math-Italic.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Script-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Script-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Script-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/web/dist/assets/cadence.css +2 -0
- package/web/dist/assets/cadence.js +7 -0
- package/web/dist/assets/markdown.js +296 -0
- package/web/dist/assets/react.js +9 -0
- package/web/dist/assets/rolldown-runtime.js +1 -0
- package/web/dist/assets/timeline-client.js +41 -0
- package/web/dist/assets/vis-timeline.css +1274 -0
- package/web/dist/assets/vis-timeline.js +32 -0
- package/web/dist/index.html +18 -0
- package/web/dist/manifest.json +505 -0
- package/config/plan-draft.example.json +0 -125
- package/config/plan-draft.multiple-tasks.example.json +0 -375
- package/config/plan-draft.quick.example.json +0 -78
- package/prompts/abel-design.md +0 -382
- package/prompts/abel-diagnose.md +0 -71
- package/prompts/abel-implement.md +0 -284
- package/prompts/abel-init.md +0 -52
- package/src/activation.ts +0 -44
- package/src/activity-contracts.ts +0 -82
- package/src/agent-registry.ts +0 -53
- package/src/apply-transaction.ts +0 -1437
- package/src/artifact-store.ts +0 -213
- package/src/build-windows-job.mjs +0 -95
- package/src/candidate-artifact.ts +0 -143
- package/src/candidate-context.ts +0 -289
- package/src/candidate-patch.ts +0 -271
- package/src/candidate-workspace.ts +0 -80
- package/src/canonical.ts +0 -16
- package/src/change-contract-schema.ts +0 -191
- package/src/change-contract.ts +0 -324
- package/src/change-verification.ts +0 -1617
- package/src/contracts.ts +0 -2466
- package/src/control-contracts.ts +0 -382
- package/src/delivery-compiler.ts +0 -1805
- package/src/delivery-revision.ts +0 -42
- package/src/design-control.ts +0 -1299
- package/src/design-diagnostics.ts +0 -181
- package/src/design-journal.ts +0 -1773
- package/src/directory-sync.ts +0 -36
- package/src/durable-contracts.ts +0 -227
- package/src/durable-workflow.ts +0 -822
- package/src/evidence-draft.ts +0 -122
- package/src/execution-profile.ts +0 -64
- package/src/execution-retention.ts +0 -77
- package/src/file-snapshot.ts +0 -163
- package/src/implement-continuation.ts +0 -559
- package/src/implement-graph.ts +0 -690
- package/src/implement-plan.ts +0 -72
- package/src/install-config.d.mts +0 -6
- package/src/isolation-backend.ts +0 -353
- package/src/model-source.ts +0 -22
- package/src/openspec-cli.ts +0 -494
- package/src/operator-cli-entry.mjs +0 -24
- package/src/operator-tools.ts +0 -309
- package/src/package-candidate-process.ts +0 -206
- package/src/package-candidate.ts +0 -24
- package/src/package-delivery.ts +0 -486
- package/src/package-state.ts +0 -320
- package/src/package-verification.ts +0 -635
- package/src/package-workflow.ts +0 -305
- package/src/packet-runtime.ts +0 -459
- package/src/phase-execution.ts +0 -2163
- package/src/pi-adapter.ts +0 -19
- package/src/plan-draft-summary.ts +0 -527
- package/src/plan-draft.ts +0 -502
- package/src/remove-path.ts +0 -32
- package/src/run-state.ts +0 -420
- package/src/run-store.ts +0 -1179
- package/src/safe-path.ts +0 -77
- package/src/scoped-grep-worker.mjs +0 -23
- package/src/scoped-tools.ts +0 -775
- package/src/single-task-draft.ts +0 -142
- package/src/sqlite-schema.ts +0 -171
- package/src/state-root.ts +0 -215
- package/src/storage-schema.ts +0 -360
- package/src/subagent-activity.ts +0 -1417
- package/src/subagent-process.ts +0 -476
- package/src/task-ledger.ts +0 -1338
- package/src/transport-budget.ts +0 -50
- package/src/verification-capability.ts +0 -1191
- package/src/verification-environment-io.ts +0 -389
- package/src/verification-environment.ts +0 -162
- package/src/verification-identity.ts +0 -77
- package/src/verification-scan.ts +0 -64
- package/src/windows-job-backend.ts +0 -419
- package/src/windows-job.c +0 -149
- package/src/workflow-engine.ts +0 -28
- package/src/workflow-policy.ts +0 -1670
- package/src/workflow-recovery-policy.ts +0 -97
- package/src/workflow-scheduling.ts +0 -105
- package/src/workflow-state-machine.ts +0 -4341
- package/src/workflow-status.ts +0 -576
- package/src/workspace-io-entry.mjs +0 -76
- package/src/workspace-io-worker.mjs +0 -1312
- package/src/workspace-io.ts +0 -89
- package/src/workspace-store.ts +0 -634
package/src/pi-adapter.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { PackageContext } from "./model-source.ts";
|
|
3
|
-
|
|
4
|
-
/** Project only the model capabilities used by the control services. */
|
|
5
|
-
export function packageContext(
|
|
6
|
-
context: Pick<ExtensionContext, "cwd" | "model" | "modelRegistry">,
|
|
7
|
-
): PackageContext {
|
|
8
|
-
return {
|
|
9
|
-
cwd: context.cwd,
|
|
10
|
-
get model() {
|
|
11
|
-
return context.model;
|
|
12
|
-
},
|
|
13
|
-
modelRegistry: {
|
|
14
|
-
getProvider: (id) => context.modelRegistry.getProvider(id),
|
|
15
|
-
getApiKeyAndHeaders: (model) =>
|
|
16
|
-
context.modelRegistry.getApiKeyAndHeaders(model),
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,527 +0,0 @@
|
|
|
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";
|
|
8
|
-
import { expandSingleTaskDraft } from "./single-task-draft.ts";
|
|
9
|
-
import { declarationPathsConflict, taskConflicts } from "./workflow-policy.ts";
|
|
10
|
-
|
|
11
|
-
/** Review data only: no executable callbacks, evidence cache or approval authority. */
|
|
12
|
-
function record(value: unknown): Record<string, unknown> {
|
|
13
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
14
|
-
? (value as Record<string, unknown>)
|
|
15
|
-
: {};
|
|
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
|
-
}
|
|
155
|
-
export function planAuthoringSummary(
|
|
156
|
-
plan: ImplementPlan,
|
|
157
|
-
authoredDraft?: unknown,
|
|
158
|
-
) {
|
|
159
|
-
const quick = record(authoredDraft).singleTask !== undefined;
|
|
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
|
-
);
|
|
167
|
-
const derivations: Array<{ field: string; source: string; taskId?: string }> =
|
|
168
|
-
[];
|
|
169
|
-
let derivationsTruncated = false;
|
|
170
|
-
const derived = (field: string, source: string, taskId?: string) => {
|
|
171
|
-
if (derivations.length >= 128) {
|
|
172
|
-
derivationsTruncated = true;
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
derivations.push({ field, source, ...(taskId ? { taskId } : {}) });
|
|
176
|
-
};
|
|
177
|
-
if (quick) derived("singleTask", "single-task-author-input");
|
|
178
|
-
if (authoredDraft !== undefined) {
|
|
179
|
-
if (!Object.hasOwn(authored, "tracking")) derived("tracking", "task-ids");
|
|
180
|
-
if (plan.changeContract && !Object.hasOwn(authored, "changeContract"))
|
|
181
|
-
derived("changeContract", "approved-gate-a");
|
|
182
|
-
for (const task of plan.tasks) {
|
|
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
|
-
}
|
|
194
|
-
for (const [phase, boundary] of Object.entries(task.phases)) {
|
|
195
|
-
const phaseInput = record(record(input.phases)[phase]);
|
|
196
|
-
if (!Object.hasOwn(phaseInput, "verificationInputs"))
|
|
197
|
-
derived(
|
|
198
|
-
`phases.${phase}.verificationInputs`,
|
|
199
|
-
"contract-and-declared-outputs",
|
|
200
|
-
task.taskId,
|
|
201
|
-
);
|
|
202
|
-
if (Object.hasOwn(input, "read"))
|
|
203
|
-
derived(
|
|
204
|
-
`phases.${phase}.read`,
|
|
205
|
-
"common-and-phase-reads",
|
|
206
|
-
task.taskId,
|
|
207
|
-
);
|
|
208
|
-
const verification = record(phaseInput.verification);
|
|
209
|
-
if (typeof verification.use === "string")
|
|
210
|
-
derived(
|
|
211
|
-
`phases.${phase}.verification`,
|
|
212
|
-
`definition:${verification.use}`,
|
|
213
|
-
task.taskId,
|
|
214
|
-
);
|
|
215
|
-
if (!Object.hasOwn(verification, "id"))
|
|
216
|
-
derived(
|
|
217
|
-
`phases.${phase}.verification.id`,
|
|
218
|
-
"stable-task-purpose-command",
|
|
219
|
-
task.taskId,
|
|
220
|
-
);
|
|
221
|
-
if (!Object.hasOwn(verification, "classification"))
|
|
222
|
-
derived(
|
|
223
|
-
`phases.${phase}.verification.classification`,
|
|
224
|
-
boundary.verification.classification,
|
|
225
|
-
task.taskId,
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
const tests = record(input.impactClosure).relatedTests;
|
|
229
|
-
if (
|
|
230
|
-
Array.isArray(tests) &&
|
|
231
|
-
tests.some((test) => !Object.hasOwn(record(test), "disposition"))
|
|
232
|
-
)
|
|
233
|
-
derived("impactClosure.relatedTests", "declared-writers", task.taskId);
|
|
234
|
-
if (!Object.hasOwn(record(input.agents), "managedOnly"))
|
|
235
|
-
derived("agents.managedOnly", "parent-managed-boundary", task.taskId);
|
|
236
|
-
}
|
|
237
|
-
const verification = record(authored.verification);
|
|
238
|
-
for (const [group, keys] of [
|
|
239
|
-
["baseline", ["target", "affected", "failureIdentity"]],
|
|
240
|
-
["change", ["affected"]],
|
|
241
|
-
[
|
|
242
|
-
"repair",
|
|
243
|
-
["inBoundaryOnly", "approvalOnBoundaryExpansion", "attribution"],
|
|
244
|
-
],
|
|
245
|
-
] as const) {
|
|
246
|
-
for (const key of keys)
|
|
247
|
-
if (!Object.hasOwn(record(verification[group]), key))
|
|
248
|
-
derived(`verification.${group}.${key}`, "fixed-execution-contract");
|
|
249
|
-
}
|
|
250
|
-
if (!Object.hasOwn(verification, "agentsCheckpoint"))
|
|
251
|
-
derived("verification.agentsCheckpoint", "explicit-none-impacts");
|
|
252
|
-
}
|
|
253
|
-
let truncated = plan.tasks.length > 16;
|
|
254
|
-
const paths = (values: readonly string[]) => {
|
|
255
|
-
const safe = values.filter(isValidRelativePath);
|
|
256
|
-
if (safe.length !== values.length || safe.length > 32) truncated = true;
|
|
257
|
-
return safe.slice(0, 32);
|
|
258
|
-
};
|
|
259
|
-
const tasks = plan.tasks.slice(0, 16).map((task) => ({
|
|
260
|
-
taskId: task.taskId,
|
|
261
|
-
dependsOn: task.dependsOn.slice(0, 16),
|
|
262
|
-
phases: Object.entries(task.phases).map(([phase, boundary]) => ({
|
|
263
|
-
phase,
|
|
264
|
-
read: paths(boundary.read),
|
|
265
|
-
write: paths(boundary.write),
|
|
266
|
-
delete: paths(boundary.delete),
|
|
267
|
-
verificationId: boundary.verification.id,
|
|
268
|
-
classification: boundary.verification.classification,
|
|
269
|
-
verificationInputs: boundary.verificationInputs.slice(0, 32),
|
|
270
|
-
})),
|
|
271
|
-
baselineVerification: task.baselineVerification?.id ?? null,
|
|
272
|
-
affectedVerification: task.affectedVerification.id,
|
|
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
|
-
},
|
|
286
|
-
agentsImpact: task.agents.impact,
|
|
287
|
-
}));
|
|
288
|
-
if (
|
|
289
|
-
plan.tasks.some(
|
|
290
|
-
(task) =>
|
|
291
|
-
task.dependsOn.length > 16 ||
|
|
292
|
-
Object.values(task.phases).some(
|
|
293
|
-
(phase) => phase.verificationInputs.length > 32,
|
|
294
|
-
),
|
|
295
|
-
)
|
|
296
|
-
)
|
|
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
|
-
};
|
|
461
|
-
return {
|
|
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
|
-
},
|
|
508
|
-
recovery: {
|
|
509
|
-
artifactCorrection: plan.verification.artifactCorrection.maxAttempts,
|
|
510
|
-
repair: plan.verification.repair.maxAttempts,
|
|
511
|
-
},
|
|
512
|
-
verifications: {
|
|
513
|
-
baseline: plan.verification.baseline.fullSuite.id,
|
|
514
|
-
fullSuite: plan.verification.change.fullSuite.id,
|
|
515
|
-
postApply: plan.verification.change.postApply.id,
|
|
516
|
-
},
|
|
517
|
-
derivations,
|
|
518
|
-
derivationRules: [
|
|
519
|
-
"tracking:task-ids",
|
|
520
|
-
"verificationInputs:contract-and-declared-outputs",
|
|
521
|
-
"baselineVerification:affected-safe-original-inputs",
|
|
522
|
-
"relatedTests:declared-writers",
|
|
523
|
-
"verification-identities:stable-task-and-purpose",
|
|
524
|
-
],
|
|
525
|
-
truncated: truncated || derivationsTruncated,
|
|
526
|
-
};
|
|
527
|
-
}
|