@deksden-com/dd-flow-cli 0.9.0-beta.8 → 0.9.0-beta.81
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/CHANGELOG.md +402 -0
- package/README.md +65 -0
- package/dist/build-info.json +8 -8
- package/dist/cli/command-inputs.js +300 -0
- package/dist/cli/help.js +81 -9
- package/dist/cli/hook-ingress.js +82 -0
- package/dist/cli/input-preparation.js +115 -0
- package/dist/cli/run-cli.js +1344 -376
- package/dist/cli.js +6 -2
- package/dist/harness-runtime/bin/dd-agy.mjs +37 -0
- package/dist/harness-runtime/bin/dd-codex.mjs +25 -0
- package/dist/harness-runtime/bin/dd-droid.mjs +33 -0
- package/dist/harness-runtime/bin/dd-grok.mjs +30 -0
- package/dist/harness-runtime/bin/dd-opencode.mjs +21 -0
- package/dist/harness-runtime/bin/dd-zcode.mjs +83 -0
- package/dist/harness-runtime/lib/daemon-operations.mjs +215 -0
- package/dist/harness-runtime/lib/dd-agy-daemon.mjs +423 -0
- package/dist/harness-runtime/lib/dd-agy.mjs +59 -0
- package/dist/harness-runtime/lib/dd-codex-daemon.d.mts +1 -0
- package/dist/harness-runtime/lib/dd-codex-daemon.mjs +146 -0
- package/dist/harness-runtime/lib/dd-codex.mjs +562 -0
- package/dist/harness-runtime/lib/dd-droid-daemon.mjs +125 -0
- package/dist/harness-runtime/lib/dd-droid.mjs +471 -0
- package/dist/harness-runtime/lib/dd-grok-daemon.mjs +274 -0
- package/dist/harness-runtime/lib/dd-grok.mjs +174 -0
- package/dist/harness-runtime/lib/dd-opencode-daemon.mjs +198 -0
- package/dist/harness-runtime/lib/dd-opencode.mjs +98 -0
- package/dist/harness-runtime/lib/dd-zcode-daemon.mjs +644 -0
- package/dist/harness-runtime/lib/dd-zcode.mjs +910 -0
- package/dist/harness-runtime/lib/delegation-instructions.d.mts +10 -0
- package/dist/harness-runtime/lib/delegation-instructions.mjs +130 -0
- package/dist/harness-runtime/lib/dispatch-fence.mjs +14 -0
- package/dist/harness-runtime/lib/driver-recovery.mjs +129 -0
- package/dist/harness-runtime/lib/droid-observation.mjs +66 -0
- package/dist/harness-runtime/lib/managed-daemon.mjs +260 -0
- package/dist/harness-runtime/lib/model-observations.mjs +77 -0
- package/dist/harness-runtime/lib/native-hook-command.d.mts +1 -0
- package/dist/harness-runtime/lib/native-hook-command.mjs +34 -0
- package/dist/harness-runtime/lib/observation-clock.mjs +36 -0
- package/dist/harness-runtime/lib/operation-context.mjs +5 -0
- package/dist/harness-runtime/lib/operation-errors.mjs +19 -0
- package/dist/harness-runtime/lib/process-json.mjs +70 -0
- package/dist/harness-runtime/lib/process-snapshot.mjs +10 -0
- package/dist/harness-runtime/lib/runner-events.mjs +200 -0
- package/dist/harness-runtime/lib/runner-lock.mjs +42 -0
- package/dist/harness-runtime/lib/session-settlement.mjs +30 -0
- package/dist/harness-runtime/lib/tool-observations.d.mts +17 -0
- package/dist/harness-runtime/lib/tool-observations.mjs +153 -0
- package/dist/schemas/agent-profile.schema.json +1 -1
- package/dist/schemas/code-review-result.schema.json +2 -2
- package/dist/schemas/code-work-batch.schema.json +4 -3
- package/dist/schemas/code-work-result.schema.json +4 -4
- package/dist/schemas/plan-review-result.schema.json +2 -2
- package/dist/schemas/run-control-receipt.schema.json +99 -0
- package/dist/schemas/run-control-request.schema.json +36 -0
- package/dist/schemas/vnext-protocol-plan.schema.json +2 -2
- package/dist/services/canon.js +11 -8
- package/dist/services/cleanup.js +57 -13
- package/dist/services/cli-operation-classifier.js +22 -24
- package/dist/services/code-checks.js +543 -96
- package/dist/services/codex-hook-delivery.js +28 -0
- package/dist/services/config.js +11 -8
- package/dist/services/controller-fanout.js +116 -0
- package/dist/services/dashboard.js +103 -31
- package/dist/services/engines.js +121 -76
- package/dist/services/eval-snapshots.js +750 -73
- package/dist/services/execution-policy.js +170 -0
- package/dist/services/external-work-launch.js +110 -0
- package/dist/services/harness-adapter.js +147 -24
- package/dist/services/harness-config.js +2 -0
- package/dist/services/hooks.js +575 -293
- package/dist/services/lanes.js +61 -53
- package/dist/services/lifecycle-command.js +87 -7
- package/dist/services/lifecycle-invocations.js +835 -0
- package/dist/services/managed-daemon-binding.js +38 -0
- package/dist/services/managed-processes.js +283 -27
- package/dist/services/merge-queue.js +179 -104
- package/dist/services/merge-server.js +73 -28
- package/dist/services/migrations.js +14 -9
- package/dist/services/native-daemon-history.js +49 -0
- package/dist/services/native-session-control.js +39 -0
- package/dist/services/plan-runtime.js +19 -8
- package/dist/services/plans.js +28 -25
- package/dist/services/projects.js +18 -5
- package/dist/services/prompts.js +23 -16
- package/dist/services/protocols.js +64 -20
- package/dist/services/recovery-observation-budget.js +61 -0
- package/dist/services/recovery-snapshot-database.js +107 -0
- package/dist/services/run-control-receipt.js +56 -0
- package/dist/services/run-control-worker.js +363 -0
- package/dist/services/run-control.js +876 -0
- package/dist/services/run-controller-adapter.js +222 -0
- package/dist/services/run-controller-capture.js +134 -0
- package/dist/services/run-controller-process.js +189 -0
- package/dist/services/run-controller-recovery.js +222 -0
- package/dist/services/run-controller-state.js +36 -0
- package/dist/services/run-controller.js +779 -0
- package/dist/services/run-engine-bindings.js +1 -1
- package/dist/services/run-fork.js +138 -0
- package/dist/services/run-observations.js +112 -0
- package/dist/services/run-recovery-runtime.js +69 -0
- package/dist/services/run-recovery.js +343 -0
- package/dist/services/runs.js +368 -74
- package/dist/services/runtime-budget.js +434 -0
- package/dist/services/runtime-scope-capture.js +50 -0
- package/dist/services/runtime-scope-control.js +450 -0
- package/dist/services/runtime-scope-resume.js +565 -0
- package/dist/services/runtime-scope-stop.js +99 -0
- package/dist/services/runtime-scope-worker.js +243 -0
- package/dist/services/runtime-service.js +97 -0
- package/dist/services/schema-validation.js +10 -8
- package/dist/services/sessions.js +35 -69
- package/dist/services/stage-blocker.js +17 -7
- package/dist/services/stage-context.js +44 -18
- package/dist/services/stage-lifecycle.js +99 -102
- package/dist/services/stage-pause.js +69 -28
- package/dist/services/usage.js +37 -93
- package/dist/services/vnext-code-review.js +189 -85
- package/dist/services/vnext-code.js +257 -243
- package/dist/services/vnext-execution-profile.js +5 -3
- package/dist/services/vnext-fanout.js +134 -19
- package/dist/services/vnext-merge.js +285 -102
- package/dist/services/vnext-plan-review.js +148 -94
- package/dist/services/vnext-plan.js +141 -72
- package/dist/services/vnext-protocolize.js +129 -56
- package/dist/services/vnext-specify.js +87 -64
- package/dist/services/work-registry.js +701 -164
- package/dist/services/workspace-bootstrap.js +76 -0
- package/dist/services/worktrees.js +85 -35
- package/dist/shared/entity-references.js +8 -0
- package/dist/shared/errors.js +12 -0
- package/dist/storage/database.js +444 -32
- package/dist/storage/paths.js +17 -4
- package/dist/storage/work-references.js +23 -0
- package/dist/storage/writer-contract.js +77 -0
- package/dist/storage/writer-migration.js +102 -0
- package/package.json +11 -4
- package/tools/repair-paused-run-status.mjs +59 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
|
|
3
|
+
/** Canonical physical-session tool accounting. Native decoding lives below;
|
|
4
|
+
* consumers never have to inspect provider envelopes or aggregate tokens. */
|
|
5
|
+
export class ToolObservations {
|
|
6
|
+
constructor() { this.calls = new Map(); this.gaps = new Set(); }
|
|
7
|
+
add(event) {
|
|
8
|
+
if (!event) return;
|
|
9
|
+
if (event.reason) { this.gaps.add(event.reason); return; }
|
|
10
|
+
const { harness_id, session_id } = event.session ?? {};
|
|
11
|
+
if (!harness_id || !session_id || !event.call_id) { this.gaps.add("tool_identity_missing"); return; }
|
|
12
|
+
const key = JSON.stringify([harness_id, session_id, event.epoch ?? "", event.call_id]);
|
|
13
|
+
const old = this.calls.get(key);
|
|
14
|
+
// Replay and late starts cannot undo a terminal outcome. Conflicting
|
|
15
|
+
// terminal facts remain visible rather than silently choosing success.
|
|
16
|
+
const terminal = value => ["completed", "failed"].includes(value);
|
|
17
|
+
if (old && terminal(old.status) && terminal(event.status) && old.status !== event.status) this.gaps.add("conflicting_tool_outcomes");
|
|
18
|
+
this.calls.set(key, { ...old, ...event, name: event.name ?? old?.name ?? "unknown",
|
|
19
|
+
status: old?.status === "failed" || event.status === "failed" ? "failed" : terminal(old?.status) ? old.status : event.status ?? old?.status ?? "unknown" });
|
|
20
|
+
}
|
|
21
|
+
summary(sessionId, cursor) {
|
|
22
|
+
const by_tool = {}, sessions = new Map(), reasons = new Set(this.gaps); let total = 0, failures = 0, pending = 0;
|
|
23
|
+
for (const [key, value] of this.calls) {
|
|
24
|
+
if (sessionId !== undefined && value.session.session_id !== sessionId || cursor?.has(key)) continue;
|
|
25
|
+
const id = JSON.stringify(value.session);
|
|
26
|
+
if (value.name === "unknown") reasons.add("tool_start_missing");
|
|
27
|
+
const session = sessions.get(id) ?? { session: value.session, parent_session: value.parent_session ?? null, total: 0, failures: 0, pending: 0, by_tool: {} };
|
|
28
|
+
total++; session.total++; by_tool[value.name] = (by_tool[value.name] ?? 0) + 1; session.by_tool[value.name] = (session.by_tool[value.name] ?? 0) + 1;
|
|
29
|
+
if (value.status === "failed") { failures++; session.failures++; }
|
|
30
|
+
if (!["completed", "failed"].includes(value.status)) { pending++; session.pending++; }
|
|
31
|
+
sessions.set(id, session);
|
|
32
|
+
}
|
|
33
|
+
return { schema_id: "dd-flow/tool-summary@1", scope: "physical_sessions", measurement: "observed_invocations", origin: "native_tool_events", aggregation: cursor ? "delta" : "cumulative", total, failures, pending, by_tool,
|
|
34
|
+
sessions: [...sessions.values()], completeness: reasons.size ? "partial" : "complete", outcome_completeness: pending ? "partial" : "complete", reasons: [...reasons] };
|
|
35
|
+
}
|
|
36
|
+
cursor() { return new Set(this.calls.keys()); }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** For adapters whose raw transcript is not portable, retain only normalized
|
|
40
|
+
* tool facts in the existing owned journal. Repeated snapshots are idempotent. */
|
|
41
|
+
export function journalToolObservations(file, events, previous) {
|
|
42
|
+
const batch = new ToolObservations();
|
|
43
|
+
for (const event of events) batch.add(event);
|
|
44
|
+
const records = [...batch.calls.values(), ...[...batch.gaps].map(reason => ({ reason }))];
|
|
45
|
+
for (const event of records) {
|
|
46
|
+
const key = JSON.stringify([event.session, event.epoch, event.call_id, event.reason]);
|
|
47
|
+
const encoded = JSON.stringify(event);
|
|
48
|
+
if (previous.get(key) === encoded) continue;
|
|
49
|
+
fs.appendFileSync(file, `${JSON.stringify({ kind: "tool_observation", schema_id: "dd-flow/tool-observation@1", observed_at: new Date().toISOString(), event })}\n`, { mode: 0o600 });
|
|
50
|
+
previous.set(key, encoded);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const identity = (harness_id, session_id) => ({ harness_id, session_id });
|
|
55
|
+
const status = value => ["error", "failed", "ERROR"].includes(value) ? "failed" : ["completed", "success", "DONE"].includes(value) ? "completed" : "running";
|
|
56
|
+
export function zcodePhysicalSession(update, rootSessionId) {
|
|
57
|
+
const native = update?._meta?.zcodeRuntime ?? {};
|
|
58
|
+
if (native.source === "subagent" && !native.childSessionId) return null;
|
|
59
|
+
return native.childSessionId ?? rootSessionId;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function acpToolObservation(message, { harness = "zcode-acp", rootSessionId, adapterSessionId } = {}) {
|
|
63
|
+
if (!["session/update", "_x.ai/session_notification"].includes(message?.method)) return null;
|
|
64
|
+
const update = message.params?.update;
|
|
65
|
+
if (!["tool_call", "tool_call_update"].includes(update?.sessionUpdate)) return null;
|
|
66
|
+
const transport = message.params?.sessionId;
|
|
67
|
+
if (adapterSessionId && transport !== adapterSessionId) return null;
|
|
68
|
+
const root = rootSessionId ?? transport;
|
|
69
|
+
const session = harness === "zcode-acp" ? zcodePhysicalSession(update, root) : root;
|
|
70
|
+
if (!session || !update.toolCallId) return { reason: "tool_identity_missing" };
|
|
71
|
+
return { session: identity(harness, session), parent_session: session !== root ? identity(harness, root) : null,
|
|
72
|
+
transport_session_id: transport, call_id: update.toolCallId, name: update._meta?.["x.ai/tool"]?.name ?? update._meta?.claudeCode?.toolName ?? update.title?.split(":", 1)[0], status: status(update.status) };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function droidToolObservations(record, sessionId) {
|
|
76
|
+
return (Array.isArray(record.message?.content) ? record.message.content : []).flatMap(block => {
|
|
77
|
+
if (block.type === "tool_use") return [{ session: identity("droid-cli", sessionId), call_id: block.id, name: block.name, status: "running" }];
|
|
78
|
+
if (block.type === "tool_result") return [{ session: identity("droid-cli", sessionId), call_id: block.tool_use_id, status: block.is_error ? "failed" : "completed" }];
|
|
79
|
+
return [];
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function codexToolObservation(record, sessionId) {
|
|
84
|
+
if (record.type !== "response_item") return null;
|
|
85
|
+
const p = record.payload ?? {};
|
|
86
|
+
if (["function_call", "custom_tool_call"].includes(p.type)) return { session: identity("codex-desktop", sessionId), call_id: p.call_id, name: p.name, status: "running" };
|
|
87
|
+
if (["function_call_output", "custom_tool_call_output"].includes(p.type)) {
|
|
88
|
+
return { session: identity("codex-desktop", sessionId), call_id: p.call_id, status: containsFailure(p) ? "failed" : "completed" };
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function containsFailure(value) {
|
|
94
|
+
if (Array.isArray(value)) return value.some(containsFailure);
|
|
95
|
+
if (typeof value === "string") {
|
|
96
|
+
if (/(?:^|\n)exit=(?:[1-9]\d*)\b|Process exited with code [1-9]\d*/.test(value)) return true;
|
|
97
|
+
if (/^[{[]/.test(value.trim())) { try { return containsFailure(JSON.parse(value)); } catch {} }
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (!value || typeof value !== "object") return false;
|
|
101
|
+
if (value.ok === false || value.is_error === true || value.isError === true || value.error === true || typeof value.error === "string") return true;
|
|
102
|
+
if (typeof value.exit_code === "number" && value.exit_code !== 0) return true;
|
|
103
|
+
return Object.values(value).some(containsFailure);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function openCodeToolObservation(part, sessionId, messageId) {
|
|
107
|
+
if (part.type !== "tool") return null;
|
|
108
|
+
return { session: identity("opencode-server", part.sessionID ?? sessionId), call_id: part.callID ?? part.id,
|
|
109
|
+
epoch: messageId, name: part.tool, status: status(part.state?.status) };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function agyToolObservation(step, rootSessionId) {
|
|
113
|
+
if (step.step_type !== "tool") return null;
|
|
114
|
+
const sessionId = step.conversation_id ?? rootSessionId;
|
|
115
|
+
return { session: identity("antigravity-cli", sessionId), parent_session: sessionId !== rootSessionId ? identity("antigravity-cli", rootSessionId) : null,
|
|
116
|
+
call_id: step.step_id ?? step.stepId ?? step.id ?? step.tool_call_id ?? step.toolCallId ?? (Number.isInteger(step.step_index) ? String(step.step_index) : null),
|
|
117
|
+
name: step.tool_name ?? step.tool_info?.name, status: step.tool_info?.error ? "failed" : status(step.state) };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Read-only replay, shared by accounting and offline diagnosis. A journal
|
|
121
|
+
* carries physical identities; an ACP connection identity never crosses out. */
|
|
122
|
+
export function replayToolJournal(file, options, reducer = new ToolObservations()) {
|
|
123
|
+
let bytes;
|
|
124
|
+
try { bytes = fs.readFileSync(file, "utf8"); } catch (error) { reducer.gaps.add(error.code === "ENOENT" ? "journal_missing" : "journal_unreadable"); return reducer; }
|
|
125
|
+
const lines = bytes.split("\n"); let session = options.rootSessionId, transport = options.adapterSessionId;
|
|
126
|
+
for (const [index, line] of lines.entries()) {
|
|
127
|
+
if (!line.trim()) continue;
|
|
128
|
+
let e; try { e = JSON.parse(line); } catch { reducer.gaps.add(index === lines.length - 1 ? "journal_partial_tail" : "journal_invalid_record"); continue; }
|
|
129
|
+
const add = event => { if (event) reducer.add({ ...event, source: { journal: file, line: index + 1 }, observed_at: e.observed_at ?? e.timestamp ?? e.at ?? e.ts ?? null }); };
|
|
130
|
+
if (e.kind === "tool_observation" && e.schema_id === "dd-flow/tool-observation@1") { add(e.event); continue; }
|
|
131
|
+
if (e.kind === "notification_failure") reducer.gaps.add("notification_failure");
|
|
132
|
+
const m = e.payload ?? e;
|
|
133
|
+
if (options.harness === "zcode-acp" || options.harness === "grok-acp") {
|
|
134
|
+
if (m.method === "zcode/session/allocated" && m.params?.provider_session_id === session) transport = m.params.adapter_session_id;
|
|
135
|
+
if (e.kind === "inbound" || m.method) add(acpToolObservation(m, { ...options, rootSessionId: session, adapterSessionId: transport }));
|
|
136
|
+
} else if (options.harness === "codex-desktop") {
|
|
137
|
+
if (e.type === "session_meta" && e.payload?.id !== session) { reducer.gaps.add("session_identity_mismatch"); break; }
|
|
138
|
+
add(codexToolObservation(e, session));
|
|
139
|
+
} else if (options.harness === "droid-cli") {
|
|
140
|
+
if (e.type === "session_start" && e.id !== session) { reducer.gaps.add("session_identity_mismatch"); break; }
|
|
141
|
+
for (const event of droidToolObservations(e, session)) add(event);
|
|
142
|
+
} else if (options.harness === "antigravity-cli") {
|
|
143
|
+
const native = m.event ?? e;
|
|
144
|
+
if (native.event === "step_update") add(agyToolObservation(native.step_update ?? {}, session));
|
|
145
|
+
} else if (options.harness === "opencode-server") {
|
|
146
|
+
// Native SSE message.part.updated, retained in the adapter journal.
|
|
147
|
+
const event = m.event ?? m;
|
|
148
|
+
const part = event.properties?.part;
|
|
149
|
+
if (part) add(openCodeToolObservation(part, session, part.messageID));
|
|
150
|
+
} else reducer.gaps.add("tool_observation_unsupported");
|
|
151
|
+
}
|
|
152
|
+
return reducer;
|
|
153
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"properties": {
|
|
8
8
|
"schema_id": {"const": "dd-flow/agent-profile@1"},
|
|
9
9
|
"id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"},
|
|
10
|
-
"harness": {"enum": ["codex", "zcode", "agy", "opencode", "grok"]},
|
|
10
|
+
"harness": {"enum": ["codex", "zcode", "agy", "opencode", "grok", "droid"]},
|
|
11
11
|
"provider": {"type": "string", "minLength": 1},
|
|
12
12
|
"model": {"type": "string", "minLength": 1},
|
|
13
13
|
"reasoning": {"type": "string", "minLength": 1},
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"schema_id": {"const": "dd-flow/code-review-result@1"},
|
|
9
9
|
"verdict": {"enum": ["pass", "findings", "blocked"]},
|
|
10
10
|
"summary": {"type": "string", "minLength": 1},
|
|
11
|
-
"aspects": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["aspect_id", "verdict", "summary", "evidence_refs"], "properties": {"aspect_id": {"type": "string", "minLength": 1}, "verdict": {"enum": ["pass", "findings", "blocked"]}, "summary": {"type": "string", "minLength": 1}, "evidence_refs": {"type": "array", "items": {"type": "string"}}}}},
|
|
12
|
-
"findings": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["finding_id", "aspect_id", "priority", "problem", "impact", "evidence_refs", "obligation_refs"], "properties": {"finding_id": {"type": "string", "pattern": "^FIND-[0-9]{3}$"}, "aspect_id": {"type": "string", "minLength": 1}, "priority": {"enum": ["p0", "p1", "p2", "p3"]}, "problem": {"type": "string", "minLength": 1}, "impact": {"type": "string", "minLength": 1}, "evidence_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}, "obligation_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}}}}
|
|
11
|
+
"aspects": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["aspect_id", "verdict", "summary", "evidence_refs"], "properties": {"aspect_id": {"type": "string", "minLength": 1}, "verdict": {"enum": ["pass", "findings", "blocked"]}, "summary": {"type": "string", "minLength": 1}, "evidence_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}}}},
|
|
12
|
+
"findings": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["finding_id", "aspect_id", "priority", "problem", "impact", "required_outcome", "evidence_refs", "obligation_refs"], "properties": {"finding_id": {"type": "string", "pattern": "^FIND-[0-9]{3}$"}, "aspect_id": {"type": "string", "minLength": 1}, "priority": {"enum": ["p0", "p1", "p2", "p3"]}, "problem": {"type": "string", "minLength": 1}, "impact": {"type": "string", "minLength": 1}, "required_outcome": {"type": "string", "minLength": 1}, "evidence_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}, "obligation_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}}}}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
"spine": {"type": "object", "additionalProperties": false, "required": ["user_outcome", "component_responsibility", "must_preserve", "non_goals", "acceptance_contribution"], "properties": {"user_outcome": {"type": "string", "minLength": 1}, "component_responsibility": {"type": "string", "minLength": 1}, "must_preserve": {"$ref": "#/$defs/strings"}, "non_goals": {"$ref": "#/$defs/stringList"}, "acceptance_contribution": {"type": "string", "minLength": 1}}},
|
|
17
17
|
"obligation": {"type": "object", "additionalProperties": false, "required": ["id", "statement"], "properties": {"id": {"type": "string", "minLength": 1}, "statement": {"type": "string", "minLength": 1}}},
|
|
18
18
|
"acceptance": {"type": "object", "additionalProperties": false, "required": ["criterion_id", "path", "environment", "fixtures", "cleanup", "check_refs", "expected_evidence", "proof_limits", "gate"], "properties": {"criterion_id": {"type": "string", "pattern": "^AC-[0-9]+$"}, "path": {"type": "string", "minLength": 1}, "environment": {"type": "string", "minLength": 1}, "fixtures": {"$ref": "#/$defs/stringList"}, "cleanup": {"type": "string", "minLength": 1}, "check_refs": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}, "expected_evidence": {"$ref": "#/$defs/strings"}, "proof_limits": {"$ref": "#/$defs/strings"}, "gate": {"type": "string", "minLength": 1}}},
|
|
19
|
-
"check": {"type": "object", "additionalProperties": false, "required": ["id", "command", "purpose", "run_at", "availability"], "properties": {"id": {"type": "string", "pattern": "^CHK-[A-Za-z0-9-]+$"}, "command": {"type": "string", "minLength": 1}, "purpose": {"type": "string", "minLength": 1}, "run_at": {"enum": ["work", "code", "readiness", "merge", "release"
|
|
19
|
+
"check": {"type": "object", "additionalProperties": false, "required": ["id", "command", "purpose", "run_at", "availability"], "properties": {"id": {"type": "string", "pattern": "^CHK-[A-Za-z0-9-]+$"}, "command": {"type": "string", "minLength": 1}, "purpose": {"type": "string", "minLength": 1}, "run_at": {"enum": ["work", "code", "readiness", "merge", "release"]}, "availability": {"enum": ["available", "planned"]}, "provided_by": {"type": "string", "minLength": 1}, "definition": {"type": "string", "minLength": 1}, "required_artifacts": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}, "ports": {"type": "array", "uniqueItems": true, "items": {"type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_]*$"}}, "inputs": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}, "reuse": {"const": "deterministic"}}, "allOf": [{"if": {"properties": {"availability": {"const": "planned"}}, "required": ["availability"]}, "then": {"required": ["provided_by", "definition"], "properties": {"command": {"pattern": "^@check/"}}}}]},
|
|
20
20
|
"documentUpdate": {"type": "object", "additionalProperties": false, "required": ["path", "action", "owner", "reason", "baseline_sha256"], "properties": {"path": {"type": "string", "minLength": 1}, "action": {"enum": ["create", "update"]}, "owner": {"type": "string", "minLength": 1}, "reason": {"type": "string", "minLength": 1}, "baseline_sha256": {"type": ["string", "null"], "pattern": "^[a-f0-9]{64}$"}}},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"reviewFinding": {"type": "object", "additionalProperties": false, "required": ["finding_ref", "priority", "problem", "impact", "required_outcome", "evidence_refs", "obligation_refs", "decision_reason", "check_refs"], "properties": {"finding_ref": {"type": "string", "minLength": 1}, "priority": {"enum": ["p0", "p1", "p2", "p3"]}, "problem": {"type": "string", "minLength": 1}, "impact": {"type": "string", "minLength": 1}, "required_outcome": {"type": "string", "minLength": 1}, "evidence_refs": {"$ref": "#/$defs/strings"}, "obligation_refs": {"$ref": "#/$defs/strings"}, "decision_reason": {"type": "string", "minLength": 1}, "check_refs": {"$ref": "#/$defs/strings"}}},
|
|
22
|
+
"repair": {"type": "object", "additionalProperties": false, "required": ["origin_work_ids", "verification_check_refs"], "anyOf": [{"required": ["check_receipt_id", "failure_receipt_path"]}, {"required": ["review_findings"]}, {"required": ["semantic_unresolved", "verification_path"]}], "properties": {"origin_work_ids": {"$ref": "#/$defs/strings"}, "check_receipt_id": {"type": "string", "minLength": 1}, "failure_receipt_path": {"type": "string", "minLength": 1}, "review_findings": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/reviewFinding"}}, "semantic_unresolved": {"$ref": "#/$defs/strings"}, "verification_path": {"type": "string", "minLength": 1}, "verification_check_refs": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/check"}}}},
|
|
23
|
+
"work": {"type": "object", "additionalProperties": false, "required": ["schema_id", "key", "launch_policy", "source", "task", "semantic_spine", "requirements", "acceptance", "document_updates", "required_read", "discovery_boundary", "planned_write_areas", "checks", "provides_checks", "stop_conditions", "depends_on", "result_schema"], "properties": {"schema_id": {"const": "dd-flow/code-work-packet@5"}, "key": {"type": "string", "minLength": 1}, "launch_policy": {"const": "fresh_agent_required"}, "source": {"$ref": "#/$defs/source"}, "repair": {"$ref": "#/$defs/repair"}, "task": {"type": "string", "minLength": 1}, "semantic_spine": {"$ref": "#/$defs/spine"}, "requirements": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/obligation"}}, "acceptance": {"type": "array", "items": {"$ref": "#/$defs/acceptance"}}, "document_updates": {"type": "array", "items": {"$ref": "#/$defs/documentUpdate"}}, "required_read": {"$ref": "#/$defs/strings", "description": "Mandatory starting sources, not a read allowlist."}, "discovery_boundary": {"$ref": "#/$defs/strings", "description": "Likely discovery areas; additional project-local reads are allowed."}, "planned_write_areas": {"type": "array", "items": {"type": "string", "minLength": 1}, "description": "Soft coordination hints only. A worker may change any necessary project file inside the RUN workspace."}, "checks": {"type": "array", "items": {"$ref": "#/$defs/check"}}, "provides_checks": {"type": "array", "items": {"$ref": "#/$defs/check"}}, "stop_conditions": {"$ref": "#/$defs/strings", "description": "Hard semantic or external stop conditions; path prediction drift is not a stop condition."}, "depends_on": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}, "result_schema": {"const": "dd-flow/code-work-result@3"}}}
|
|
23
24
|
}
|
|
24
25
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "dd-flow/code-work-result@
|
|
3
|
+
"$id": "dd-flow/code-work-result@3",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"additionalProperties": false,
|
|
6
6
|
"required": ["schema_id", "summary", "changed_paths", "evidence", "deviations", "blockers"],
|
|
7
7
|
"properties": {
|
|
8
|
-
"schema_id": {"const": "dd-flow/code-work-result@
|
|
8
|
+
"schema_id": {"const": "dd-flow/code-work-result@3"},
|
|
9
9
|
"summary": {"type": "string", "minLength": 1},
|
|
10
10
|
"changed_paths": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}},
|
|
11
|
-
"evidence": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["
|
|
11
|
+
"evidence": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["obligation_ref", "refs"], "properties": {"obligation_ref": {"type": "string", "minLength": 1}, "refs": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}}}},
|
|
12
12
|
"deviations": {"type": "array", "items": {"type": "string", "minLength": 1}},
|
|
13
13
|
"blockers": {"type": "array", "items": {"type": "string", "minLength": 1}},
|
|
14
|
-
"
|
|
14
|
+
"resolutions": {"type": "array", "uniqueItems": true, "items": {"type": "object", "additionalProperties": false, "required": ["finding_ref", "summary", "evidence_refs"], "properties": {"finding_ref": {"type": "string", "minLength": 1}, "summary": {"type": "string", "minLength": 1}, "evidence_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "minLength": 1}}}}}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"aspect_id": {"type": "string", "minLength": 1},
|
|
21
21
|
"verdict": {"enum": ["pass", "watch", "needs_changes", "blocked"]},
|
|
22
22
|
"summary": {"type": "string", "minLength": 1},
|
|
23
|
-
"evidence_refs": {"type": "array", "items": {"type": "string", "minLength": 1}},
|
|
23
|
+
"evidence_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
|
|
24
24
|
"findings": {
|
|
25
25
|
"type": "array",
|
|
26
26
|
"items": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"finding_id": {"type": "string", "pattern": "^FIND-[0-9]{3}$"},
|
|
32
32
|
"severity": {"enum": ["blocker", "high", "medium", "low", "info"]},
|
|
33
33
|
"summary": {"type": "string", "minLength": 1},
|
|
34
|
-
"evidence_refs": {"type": "array", "items": {"type": "string", "minLength": 1}}
|
|
34
|
+
"evidence_refs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "dd-flow/run-control-receipt@1",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["schema_id", "ok", "request_id", "control_id", "scope", "generation", "requested_mode", "applied_mode", "state", "settled", "nodes", "unsettled_reasons", "resumability"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema_id": { "const": "dd-flow/run-control-receipt@1" },
|
|
9
|
+
"ok": { "const": true },
|
|
10
|
+
"request_id": { "type": ["string", "null"], "minLength": 1, "maxLength": 128 },
|
|
11
|
+
"control_id": { "type": ["string", "null"], "pattern": "^CTL-[A-Za-z0-9][A-Za-z0-9._-]*$" },
|
|
12
|
+
"scope": {
|
|
13
|
+
"type": "object", "additionalProperties": false,
|
|
14
|
+
"required": ["project_id", "run_id"],
|
|
15
|
+
"properties": {
|
|
16
|
+
"project_id": { "type": "string", "minLength": 1 },
|
|
17
|
+
"run_id": { "type": "string", "pattern": "^RUN-[A-Za-z0-9][A-Za-z0-9._-]*$" }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"generation": { "type": "integer", "minimum": 0 },
|
|
21
|
+
"requested_mode": { "enum": [null, "pause", "stop", "resume"] },
|
|
22
|
+
"applied_mode": { "enum": [null, "pause", "stop", "resume"] },
|
|
23
|
+
"state": { "enum": ["not_requested", "pause_requested", "paused", "stop_requested", "stopped", "resuming", "running", "terminal_noop", "superseded", "recovery_required"] },
|
|
24
|
+
"settled": { "type": "boolean" },
|
|
25
|
+
"nodes": {
|
|
26
|
+
"type": "array",
|
|
27
|
+
"items": {
|
|
28
|
+
"type": "object", "additionalProperties": false,
|
|
29
|
+
"required": ["id", "role", "status", "acknowledged", "settled", "reason"],
|
|
30
|
+
"properties": {
|
|
31
|
+
"id": { "type": "string", "minLength": 1 },
|
|
32
|
+
"role": { "enum": ["subject", "worker", "merge", "judge", "probe", "check", "process", "unknown"] },
|
|
33
|
+
"status": { "enum": ["pending", "unknown", "idle", "stopped", "completed"] },
|
|
34
|
+
"acknowledged": { "type": "boolean" },
|
|
35
|
+
"settled": { "type": "boolean" },
|
|
36
|
+
"reason": { "type": ["string", "null"] },
|
|
37
|
+
"receipt_path": { "type": "string", "minLength": 1 },
|
|
38
|
+
"details": { "type": "object" }
|
|
39
|
+
},
|
|
40
|
+
"allOf": [{
|
|
41
|
+
"if": { "properties": { "settled": { "const": true } } },
|
|
42
|
+
"then": { "properties": { "status": { "enum": ["idle", "stopped", "completed"] } } }
|
|
43
|
+
}]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"unsettled_reasons": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
|
|
47
|
+
"resumability": { "enum": ["pending", "same_session", "replacement_allowed", "recovery_required", "not_applicable"] },
|
|
48
|
+
"recovery_id": { "type": ["string", "null"] },
|
|
49
|
+
"reused": { "type": "boolean" },
|
|
50
|
+
"next_cursor": { "type": "integer", "minimum": 0 },
|
|
51
|
+
"run_status": { "type": "string" },
|
|
52
|
+
"control": { "type": ["object", "null"] },
|
|
53
|
+
"operations": { "type": "array", "items": { "type": "object" } },
|
|
54
|
+
"worker": { "type": ["object", "null"] },
|
|
55
|
+
"resume_operation": { "type": ["object", "null"] },
|
|
56
|
+
"controller": { "type": "object" },
|
|
57
|
+
"operation_id": { "type": "string", "minLength": 1 },
|
|
58
|
+
"status": { "type": "string" },
|
|
59
|
+
"action": { "enum": ["pause", "stop", "resume"] },
|
|
60
|
+
"progress": {
|
|
61
|
+
"type": "array",
|
|
62
|
+
"items": { "type": "object", "additionalProperties": false, "required": ["phase", "message", "at"], "properties": { "phase": { "enum": ["start", "running", "done", "failed"] }, "message": { "type": "string" }, "at": { "type": "string" }, "detail": { "type": "object" } } }
|
|
63
|
+
},
|
|
64
|
+
"warnings": { "type": "array", "items": { "type": "object" } },
|
|
65
|
+
"response_file": { "type": "string", "minLength": 1 },
|
|
66
|
+
"response_file_error": { "type": "string" }
|
|
67
|
+
},
|
|
68
|
+
"allOf": [
|
|
69
|
+
{
|
|
70
|
+
"if": { "properties": { "state": { "not": { "enum": ["not_requested", "terminal_noop"] } } } },
|
|
71
|
+
"then": { "properties": { "control_id": { "type": "string" }, "request_id": { "type": "string" }, "requested_mode": { "type": "string" } } }
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"if": { "properties": { "state": { "enum": ["paused", "stopped"] } } },
|
|
75
|
+
"then": { "properties": { "settled": { "const": true } } }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"if": { "properties": { "state": { "const": "paused" } } },
|
|
79
|
+
"then": { "properties": { "applied_mode": { "const": "pause" } } }
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"if": { "properties": { "state": { "const": "stopped" } } },
|
|
83
|
+
"then": { "properties": { "applied_mode": { "const": "stop" } } }
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"if": { "properties": { "settled": { "const": true } } },
|
|
87
|
+
"then": {
|
|
88
|
+
"properties": {
|
|
89
|
+
"nodes": { "items": { "properties": { "settled": { "const": true } } } },
|
|
90
|
+
"unsettled_reasons": { "maxItems": 0 }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"if": { "properties": { "settled": { "const": false } } },
|
|
96
|
+
"then": { "properties": { "unsettled_reasons": { "minItems": 1 }, "resumability": { "enum": ["pending", "recovery_required", "not_applicable"] } } }
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "dd-flow/run-control-request@1",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["schema_id", "request_id", "project_root", "run_id", "action"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema_id": { "const": "dd-flow/run-control-request@1" },
|
|
9
|
+
"request_id": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$" },
|
|
10
|
+
"project_root": { "type": "string", "minLength": 1, "pattern": "^(?:/|[A-Za-z]:[\\\\/]|\\\\\\\\)" },
|
|
11
|
+
"run_id": { "type": "string", "pattern": "^RUN-[A-Za-z0-9][A-Za-z0-9._-]*$" },
|
|
12
|
+
"action": { "enum": ["pause", "stop", "resume"] },
|
|
13
|
+
"wait_ms": { "type": "integer", "minimum": 0, "maximum": 60000, "default": 0 },
|
|
14
|
+
"grace_ms": { "type": "integer", "minimum": 0, "maximum": 3600000, "default": 30000 },
|
|
15
|
+
"escalate": { "const": "interrupt" },
|
|
16
|
+
"force": { "type": "boolean" },
|
|
17
|
+
"from": { "type": "string", "pattern": "^CTL-[A-Za-z0-9][A-Za-z0-9._-]*$" }
|
|
18
|
+
},
|
|
19
|
+
"allOf": [
|
|
20
|
+
{
|
|
21
|
+
"if": { "properties": { "action": { "const": "pause" } } },
|
|
22
|
+
"then": { "not": { "anyOf": [{ "required": ["force"] }, { "required": ["from"] }] } }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"if": { "properties": { "action": { "const": "stop" } } },
|
|
26
|
+
"then": { "not": { "anyOf": [{ "required": ["grace_ms"] }, { "required": ["escalate"] }, { "required": ["from"] }] } }
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"if": { "properties": { "action": { "const": "resume" } } },
|
|
30
|
+
"then": {
|
|
31
|
+
"required": ["from"],
|
|
32
|
+
"not": { "anyOf": [{ "required": ["grace_ms"] }, { "required": ["escalate"] }, { "required": ["force"] }] }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"documentUpdate": {"type": "object", "additionalProperties": false, "required": ["path", "action", "owner", "reason"], "properties": {"path": {"type": "string", "minLength": 1}, "action": {"enum": ["create", "update"]}, "owner": {"type": "string", "minLength": 1}, "reason": {"type": "string", "minLength": 1}}},
|
|
30
30
|
"spine": {"type": "object", "additionalProperties": false, "required": ["user_outcome", "component_responsibility", "must_preserve", "non_goals", "acceptance_contribution"], "properties": {"user_outcome": {"type": "string", "minLength": 1}, "component_responsibility": {"type": "string", "minLength": 1}, "must_preserve": {"$ref": "#/$defs/strings"}, "non_goals": {"type": "array", "items": {"type": "string", "minLength": 1}}, "acceptance_contribution": {"type": "string", "minLength": 1}}},
|
|
31
31
|
"execution": {"type": "object", "additionalProperties": false, "required": ["required_read", "discovery_boundary", "planned_write_areas", "stop_conditions"], "properties": {"required_read": {"$ref": "#/$defs/strings", "description": "Mandatory starting sources. This is not a read allowlist."}, "discovery_boundary": {"$ref": "#/$defs/strings", "description": "Likely discovery areas. A worker may inspect other project-local sources when necessary."}, "planned_write_areas": {"type": "array", "items": {"type": "string", "minLength": 1}, "description": "Optional file or directory hints used only to coordinate concurrent Works. They never grant or deny write permission."}, "stop_conditions": {"$ref": "#/$defs/strings", "description": "Semantic contradictions or external blockers that require the worker to stop."}}},
|
|
32
|
-
"check": {"type": "object", "additionalProperties": false, "required": ["id", "command", "purpose", "run_at", "availability"], "properties": {"id": {"type": "string", "pattern": "^CHK-[A-Za-z0-9-]+$"}, "command": {"type": "string", "minLength": 1}, "purpose": {"type": "string", "minLength": 1}, "run_at": {"enum": ["work", "code", "readiness", "merge", "release"
|
|
32
|
+
"check": {"type": "object", "additionalProperties": false, "required": ["id", "command", "purpose", "run_at", "availability"], "properties": {"id": {"type": "string", "pattern": "^CHK-[A-Za-z0-9-]+$"}, "command": {"type": "string", "minLength": 1}, "purpose": {"type": "string", "minLength": 1}, "run_at": {"enum": ["work", "code", "readiness", "merge", "release"]}, "availability": {"enum": ["available", "planned"]}, "provided_by": {"type": "string", "pattern": "^P[0-9]+$"}, "definition": {"type": "string", "minLength": 1}, "required_artifacts": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}, "ports": {"type": "array", "uniqueItems": true, "items": {"type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_]*$"}}, "inputs": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}, "reuse": {"const": "deterministic"}}, "allOf": [{"if": {"properties": {"availability": {"const": "planned"}}, "required": ["availability"]}, "then": {"required": ["provided_by", "definition"], "properties": {"command": {"pattern": "^@check/"}}}}, {"if": {"properties": {"command": {"pattern": "^@check/"}}}, "then": {"required": ["definition"]}}]},
|
|
33
33
|
"verification": {"type": "object", "additionalProperties": false, "required": ["check_refs"], "properties": {"check_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "pattern": "^CHK-[A-Za-z0-9-]+$"}}}},
|
|
34
34
|
"item": {"type": "object", "additionalProperties": false, "required": ["id", "title", "summary", "details", "depends_on", "requirement_refs", "semantic_spine", "execution_context", "verification"], "properties": {"id": {"type": "string", "pattern": "^P[0-9]+$"}, "title": {"type": "string", "minLength": 1}, "summary": {"type": "string", "minLength": 1}, "details": {"type": "string", "minLength": 1}, "depends_on": {"type": "array", "uniqueItems": true, "items": {"type": "string", "pattern": "^P[0-9]+$"}}, "requirement_refs": {"$ref": "#/$defs/strings"}, "semantic_spine": {"$ref": "#/$defs/spine"}, "execution_context": {"$ref": "#/$defs/execution"}, "verification": {"$ref": "#/$defs/verification"}}},
|
|
35
|
-
"acceptance": {"type": "object", "additionalProperties": false, "required": ["criterion_id", "plan_item_ids", "changed_surfaces", "path", "environment", "fixtures", "cleanup", "check_refs", "expected_evidence", "proof_limits", "gate"], "properties": {"criterion_id": {"type": "string", "pattern": "^AC-[0-9]+$"}, "plan_item_ids": {"type": "array", "minItems": 1, "items": {"type": "string", "pattern": "^P[0-9]+$"}}, "changed_surfaces": {"$ref": "#/$defs/strings"}, "path": {"type": "string", "minLength": 1}, "environment": {"type": "string", "minLength": 1}, "fixtures": {"type": "array", "items": {"type": "string", "minLength": 1}}, "cleanup": {"type": "string", "minLength": 1}, "check_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "pattern": "^CHK-[A-Za-z0-9-]+$"}}, "expected_evidence": {"$ref": "#/$defs/strings"}, "proof_limits": {"$ref": "#/$defs/strings"}, "gate": {"enum": ["work", "code", "readiness", "merge", "release"
|
|
35
|
+
"acceptance": {"type": "object", "additionalProperties": false, "required": ["criterion_id", "plan_item_ids", "changed_surfaces", "path", "environment", "fixtures", "cleanup", "check_refs", "expected_evidence", "proof_limits", "gate"], "properties": {"criterion_id": {"type": "string", "pattern": "^AC-[0-9]+$"}, "plan_item_ids": {"type": "array", "minItems": 1, "items": {"type": "string", "pattern": "^P[0-9]+$"}}, "changed_surfaces": {"$ref": "#/$defs/strings"}, "path": {"type": "string", "minLength": 1}, "environment": {"type": "string", "minLength": 1}, "fixtures": {"type": "array", "items": {"type": "string", "minLength": 1}}, "cleanup": {"type": "string", "minLength": 1}, "check_refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "pattern": "^CHK-[A-Za-z0-9-]+$"}}, "expected_evidence": {"$ref": "#/$defs/strings"}, "proof_limits": {"$ref": "#/$defs/strings"}, "gate": {"enum": ["work", "code", "readiness", "merge", "release"]}}}
|
|
36
36
|
}
|
|
37
37
|
}
|
package/dist/services/canon.js
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { AppError } from "../shared/errors.js";
|
|
5
|
+
import { prepareError } from "../cli/input-preparation.js";
|
|
4
6
|
const canonRootKey = "canon.root";
|
|
5
|
-
export function
|
|
7
|
+
export function prepareCanonRegistration(context, input) {
|
|
8
|
+
if (typeof input.root !== "string" || !input.root.trim())
|
|
9
|
+
return prepareError(new AppError("validation", "Canon root must be a non-empty path", 2));
|
|
6
10
|
const resolution = resolveCanonRoot(context, { explicitRoot: input.root, allowRegistered: false });
|
|
7
11
|
if (!resolution.ok || !resolution.canon) {
|
|
8
|
-
return {
|
|
9
|
-
...resolution,
|
|
10
|
-
action: "register",
|
|
11
|
-
exit_code: 1
|
|
12
|
-
};
|
|
12
|
+
return prepareError(new AppError("validation", "Canon root cannot be registered", 2, { root: input.root, blockers: resolution.blockers, candidates: resolution.candidates, bootstrap: resolution.bootstrap }));
|
|
13
13
|
}
|
|
14
|
+
return resolution.canon;
|
|
15
|
+
}
|
|
16
|
+
export function registerCanonRoot(context, input, canon = prepareCanonRegistration(context, input)) {
|
|
14
17
|
const now = context.now();
|
|
15
18
|
context.db.run(`INSERT INTO runtime_config (key, value_json, created_at, updated_at)
|
|
16
19
|
VALUES (?, ?, ?, ?)
|
|
17
20
|
ON CONFLICT(key) DO UPDATE SET
|
|
18
21
|
value_json = excluded.value_json,
|
|
19
|
-
updated_at = excluded.updated_at`, [canonRootKey, JSON.stringify({ root:
|
|
22
|
+
updated_at = excluded.updated_at`, [canonRootKey, JSON.stringify({ root: canon.root }), now, now]);
|
|
20
23
|
return {
|
|
21
24
|
ok: true,
|
|
22
25
|
action: "register",
|
|
23
26
|
canon: {
|
|
24
|
-
...
|
|
27
|
+
...canon,
|
|
25
28
|
source: "registered"
|
|
26
29
|
},
|
|
27
30
|
db_path: context.db.path
|