intentdna 1.9.0 → 1.9.3

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.
Files changed (131) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +227 -87
  4. package/dist/cli/commands/run-lifecycle.d.ts +61 -11
  5. package/dist/cli/commands/run-lifecycle.js +184 -50
  6. package/dist/cli/commands/run-observer.d.ts +15 -0
  7. package/dist/cli/commands/run-observer.js +210 -0
  8. package/dist/cli/commands/run.d.ts +16 -20
  9. package/dist/cli/commands/run.js +461 -659
  10. package/dist/cli/commands/sync.js +16 -12
  11. package/dist/cli/index.js +14 -5
  12. package/dist/compiler/compile.d.ts +1 -0
  13. package/dist/compiler/compile.js +1 -1
  14. package/dist/compiler/controller.d.ts +16 -0
  15. package/dist/compiler/controller.js +693 -0
  16. package/dist/compiler/input-resolver.d.ts +2 -0
  17. package/dist/compiler/input-resolver.js +22 -6
  18. package/dist/hooks/cli.d.ts +45 -0
  19. package/dist/hooks/cli.js +263 -31
  20. package/dist/hooks/host-event.d.ts +57 -0
  21. package/dist/hooks/host-event.js +187 -0
  22. package/dist/hooks/index.d.ts +1 -0
  23. package/dist/hooks/index.js +1 -0
  24. package/dist/hooks/protocol.d.ts +7 -0
  25. package/dist/hooks/schema.d.ts +1 -0
  26. package/dist/hooks/schema.js +89 -1
  27. package/dist/hooks/state.d.ts +23 -1
  28. package/dist/hooks/state.js +9 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/mcp/index.js +2 -0
  32. package/dist/mcp/tools-run.d.ts +4 -0
  33. package/dist/mcp/tools-run.js +419 -0
  34. package/dist/mcp/tools-state.d.ts +1 -1
  35. package/dist/mcp/tools-state.js +13 -241
  36. package/dist/runtime/artifact-store.d.ts +146 -0
  37. package/dist/runtime/artifact-store.js +1436 -0
  38. package/dist/runtime/canonical-attempt-outcome.d.ts +12 -0
  39. package/dist/runtime/canonical-attempt-outcome.js +195 -0
  40. package/dist/runtime/canonical-json.d.ts +10 -0
  41. package/dist/runtime/canonical-json.js +105 -0
  42. package/dist/runtime/canonical-run-application.d.ts +93 -0
  43. package/dist/runtime/canonical-run-application.js +229 -0
  44. package/dist/runtime/canonical-run-service.d.ts +454 -0
  45. package/dist/runtime/canonical-run-service.js +4760 -0
  46. package/dist/runtime/canonical-runtime-composition.d.ts +22 -0
  47. package/dist/runtime/canonical-runtime-composition.js +34 -0
  48. package/dist/runtime/canonical-runtime-projection.d.ts +3 -0
  49. package/dist/runtime/canonical-runtime-projection.js +4 -0
  50. package/dist/runtime/canonical-target-compiler.d.ts +46 -0
  51. package/dist/runtime/canonical-target-compiler.js +514 -0
  52. package/dist/runtime/claude-agent-identity.d.ts +2 -0
  53. package/dist/runtime/claude-agent-identity.js +21 -0
  54. package/dist/runtime/executable-run-plan.d.ts +328 -0
  55. package/dist/runtime/executable-run-plan.js +1485 -0
  56. package/dist/runtime/execution-authority.d.ts +83 -0
  57. package/dist/runtime/execution-authority.js +98 -0
  58. package/dist/runtime/handoff-resolver.js +4 -1
  59. package/dist/runtime/harness-pull-adapter.d.ts +146 -0
  60. package/dist/runtime/harness-pull-adapter.js +315 -0
  61. package/dist/runtime/index.d.ts +39 -14
  62. package/dist/runtime/index.js +29 -7
  63. package/dist/runtime/local-execution-authority.d.ts +194 -0
  64. package/dist/runtime/local-execution-authority.js +2897 -0
  65. package/dist/runtime/local-execution-reconciliation.d.ts +20 -0
  66. package/dist/runtime/local-execution-reconciliation.js +107 -0
  67. package/dist/runtime/local-execution-supervisor-script.d.ts +7 -0
  68. package/dist/runtime/local-execution-supervisor-script.js +793 -0
  69. package/dist/runtime/local-provider-sandbox.d.ts +42 -0
  70. package/dist/runtime/local-provider-sandbox.js +154 -0
  71. package/dist/runtime/local-verifier-execution.d.ts +24 -0
  72. package/dist/runtime/local-verifier-execution.js +290 -0
  73. package/dist/runtime/local-windows-execution-supervisor-script.d.ts +6 -0
  74. package/dist/runtime/local-windows-execution-supervisor-script.js +788 -0
  75. package/dist/runtime/plan-store.d.ts +30 -0
  76. package/dist/runtime/plan-store.js +231 -0
  77. package/dist/runtime/process-tree.d.ts +9 -0
  78. package/dist/runtime/process-tree.js +97 -24
  79. package/dist/runtime/providers/codex.js +2 -2
  80. package/dist/runtime/push-driver.d.ts +184 -0
  81. package/dist/runtime/push-driver.js +1002 -0
  82. package/dist/runtime/result-store.d.ts +34 -3
  83. package/dist/runtime/result-store.js +1073 -2
  84. package/dist/runtime/run-binding.d.ts +68 -0
  85. package/dist/runtime/run-binding.js +278 -0
  86. package/dist/runtime/run-contracts.d.ts +575 -0
  87. package/dist/runtime/run-contracts.js +58 -7
  88. package/dist/runtime/run-controller.d.ts +1 -6
  89. package/dist/runtime/run-controller.js +0 -41
  90. package/dist/runtime/run-store.d.ts +85 -7
  91. package/dist/runtime/run-store.js +2528 -186
  92. package/dist/runtime/skill-adapter.d.ts +18 -7
  93. package/dist/runtime/skill-adapter.js +100 -742
  94. package/dist/runtime/structured-output-validator.d.ts +44 -0
  95. package/dist/runtime/structured-output-validator.js +171 -0
  96. package/dist/runtime/verifier-command-binding.d.ts +22 -0
  97. package/dist/runtime/verifier-command-binding.js +162 -0
  98. package/dist/runtime/verifier.d.ts +46 -6
  99. package/dist/runtime/verifier.js +355 -53
  100. package/dist/runtime/windows-job-keeper.d.ts +47 -0
  101. package/dist/runtime/windows-job-keeper.js +231 -0
  102. package/dist/runtime/worker-executor.d.ts +17 -1
  103. package/dist/runtime/worker-executor.js +26 -5
  104. package/dist/runtime/workflow-plan-adapter.d.ts +19 -0
  105. package/dist/runtime/workflow-plan-adapter.js +502 -6
  106. package/dist/runtime/workflow-runtime-manifest.d.ts +1 -0
  107. package/dist/runtime/workflow-runtime-manifest.js +5 -0
  108. package/dist/runtime/workspace-isolation.d.ts +29 -2
  109. package/dist/runtime/workspace-isolation.js +488 -11
  110. package/dist/runtime/workspace-observation.d.ts +44 -0
  111. package/dist/runtime/workspace-observation.js +216 -0
  112. package/dist/schema/controller-registry.d.ts +0 -7
  113. package/dist/schema/controller-registry.js +0 -8
  114. package/dist/schema/types.d.ts +84 -10
  115. package/dist/schema/types.js +2 -0
  116. package/dist/schema/validate.js +151 -1
  117. package/dist/schema/validators/controllers.d.ts +1 -1
  118. package/dist/schema/validators/controllers.js +126 -41
  119. package/dist/schema/workflow-authoring-contract.js +2 -0
  120. package/dist/schema/yaml-parser.js +1 -1
  121. package/dist/templates/flutter-rewrite-new.dna.yaml +1 -0
  122. package/dist/templates/flutter-rewrite.dna.yaml +87 -60
  123. package/dist/templates/safe-refactoring.dna.yaml +1 -0
  124. package/native/windows-job-keeper/README.md +80 -0
  125. package/native/windows-job-keeper/bin/aarch64/intentdna-windows-job-keeper.exe +0 -0
  126. package/native/windows-job-keeper/bin/x86_64/intentdna-windows-job-keeper.exe +0 -0
  127. package/native/windows-job-keeper/keeper.c +979 -0
  128. package/native/windows-job-keeper/manifest.json +33 -0
  129. package/package.json +6 -2
  130. package/scripts/build-windows-job-keeper.mjs +172 -0
  131. package/scripts/verify-windows-job-keeper.mjs +184 -0
@@ -4,117 +4,15 @@
4
4
  * Tools for reading/writing DNA governance state via MCP:
5
5
  * - dna_status: Overview of DNA state
6
6
  * - dna_workflow_read: Read current workflow state
7
- * - dna_workflow_write: Update workflow state
7
+ * - dna_workflow_write: Close legacy workflow state
8
8
  * - dna_trace_query: Query legacy diagnostic trace data with filters
9
9
  */
10
10
  import { resolve } from "node:path";
11
11
  import { readWorkflowState, writeWorkflowState, readRuntimeDecisionEvents, readTraces, listSessions } from "../hooks/state.js";
12
12
  import { validateRuntimeDecisionEvent } from "../governance/index.js";
13
- import { loadCompiledIR, loadCompiledIRResult } from "../runtime/plugin-adapter.js";
13
+ import { loadCompiledIR } from "../runtime/plugin-adapter.js";
14
14
  import { validateWorkflowRuntimeManifest } from "../runtime/workflow-runtime-manifest.js";
15
15
  import { errorResult, textResult } from "./server.js";
16
- function isStringRecord(value) {
17
- return typeof value === "object" && value !== null && !Array.isArray(value) &&
18
- Object.values(value).every(v => typeof v === "string");
19
- }
20
- function sameStringRecord(a, b) {
21
- const aKeys = Object.keys(a).sort();
22
- const bKeys = Object.keys(b).sort();
23
- return aKeys.length === bKeys.length && aKeys.every((key, index) => key === bKeys[index] && a[key] === b[key]);
24
- }
25
- const RUNTIME_ARGUMENT_NAMES = ["ARGUMENTS", "arguments", "task_id"];
26
- function compatibleManifestInputCandidate(binding, candidate) {
27
- if (!candidate)
28
- return { ignored: [] };
29
- const allowed = new Set([...binding.runtime_input_refs, ...RUNTIME_ARGUMENT_NAMES]);
30
- const entries = Object.entries(candidate);
31
- return {
32
- candidate: Object.fromEntries(entries.filter(([name]) => allowed.has(name))),
33
- ignored: entries.filter(([name]) => !allowed.has(name)).map(([name]) => name).sort(),
34
- };
35
- }
36
- async function lookupRuntimeBinding(projectDir, workflow) {
37
- const result = await loadCompiledIRResult(resolve(projectDir, ".dna", "compiled", "ir.json"));
38
- if (result.status === "missing") {
39
- return { status: "error", kind: "invalid_ir", message: "No compiled IR found. Run `dna sync` before starting or continuing this workflow." };
40
- }
41
- if (result.status === "invalid") {
42
- return { status: "error", kind: "invalid_ir", message: `Invalid compiled IR: ${result.reason}. Run \`dna sync\` before starting or continuing this workflow.` };
43
- }
44
- const compiled = result.compiled;
45
- if (!Object.prototype.hasOwnProperty.call(compiled, "workflow_runtime")) {
46
- return { status: "legacy", compiledIrHash: compiled.compiled_ir_hash };
47
- }
48
- if (typeof compiled.compiled_ir_hash !== "string" ||
49
- typeof compiled.ir.compiled_ir_hash !== "string" ||
50
- compiled.compiled_ir_hash !== compiled.ir.compiled_ir_hash) {
51
- return {
52
- status: "error",
53
- kind: "invalid_ir",
54
- message: "Invalid compiled IR: workflow runtime bindings require matching wrapper and IR hashes. Run `dna sync` before starting or continuing this workflow.",
55
- };
56
- }
57
- const validation = validateWorkflowRuntimeManifest(compiled.workflow_runtime, compiled.compiled_ir_hash);
58
- if (!validation.valid) {
59
- return {
60
- status: "error",
61
- kind: "invalid_manifest",
62
- compiledIrHash: compiled.compiled_ir_hash,
63
- message: `Invalid compiled workflow runtime manifest: ${validation.reason}. Run \`dna sync\` before starting or continuing this workflow.`,
64
- };
65
- }
66
- if (!Object.prototype.hasOwnProperty.call(validation.manifest.workflows, workflow)) {
67
- return {
68
- status: "error",
69
- kind: "workflow_missing",
70
- compiledIrHash: validation.manifest.compiled_ir_hash,
71
- message: `Workflow ${workflow} is not present in the compiled workflow runtime manifest. Run \`dna sync\` to refresh generated runtime artifacts.`,
72
- };
73
- }
74
- const binding = validation.manifest.workflows[workflow];
75
- return {
76
- status: "found",
77
- binding,
78
- manifestHash: validation.manifest.manifest_hash,
79
- compiledIrHash: validation.manifest.compiled_ir_hash,
80
- };
81
- }
82
- function normalizeManifestInputs(binding, candidate) {
83
- const rawInputs = { ...(candidate ?? {}) };
84
- const allowed = new Set([...binding.runtime_input_refs, ...RUNTIME_ARGUMENT_NAMES]);
85
- const unexpected = Object.keys(rawInputs).filter((name) => !allowed.has(name));
86
- if (unexpected.length > 0) {
87
- return { valid: false, message: `Workflow inputs are not declared by the compiled runtime binding: ${unexpected.join(", ")}` };
88
- }
89
- const argumentValues = RUNTIME_ARGUMENT_NAMES
90
- .map((name) => rawInputs[name])
91
- .filter((value) => value !== undefined);
92
- const distinctArgumentValues = [...new Set(argumentValues)];
93
- if (distinctArgumentValues.length > 1) {
94
- return { valid: false, message: "ARGUMENTS, arguments, and task_id must identify the same runtime input." };
95
- }
96
- const argumentValue = distinctArgumentValues[0];
97
- if (!binding.requires_arguments && argumentValue !== undefined) {
98
- return { valid: true, note: "Ignored legacy argument input for an argument-free workflow." };
99
- }
100
- if (binding.requires_arguments && (!argumentValue || argumentValue.trim() === "")) {
101
- return { valid: false, message: "This workflow requires a non-empty ARGUMENTS input." };
102
- }
103
- const inputs = {};
104
- for (const name of binding.runtime_input_refs) {
105
- if (RUNTIME_ARGUMENT_NAMES.includes(name)) {
106
- if (argumentValue !== undefined)
107
- inputs[name] = argumentValue;
108
- }
109
- else if (rawInputs[name] !== undefined) {
110
- inputs[name] = rawInputs[name];
111
- }
112
- else {
113
- return { valid: false, message: `This workflow requires runtime input ${name}.` };
114
- }
115
- }
116
- return { valid: true, inputs: Object.keys(inputs).length > 0 ? inputs : undefined };
117
- }
118
16
  export function createStateTools(projectDir) {
119
17
  return [
120
18
  // ── dna_status ────────────────────────────────────────
@@ -207,7 +105,7 @@ export function createStateTools(projectDir) {
207
105
  // ── dna_workflow_write ────────────────────────────────
208
106
  {
209
107
  name: "dna_workflow_write",
210
- description: "Update workflow state. Template variables and workflow asset identity are initialized from the compiled runtime manifest.",
108
+ description: "Close-only compatibility operation for an already-active legacy workflow. New and continuing runs must use the canonical run tools.",
211
109
  inputSchema: {
212
110
  type: "object",
213
111
  properties: {
@@ -227,148 +125,22 @@ export function createStateTools(projectDir) {
227
125
  const sessionId = typeof args.session_id === "string" ? args.session_id : undefined;
228
126
  const existing = await readWorkflowState(projectDir, sessionId, 0);
229
127
  const workflow = String(args.workflow);
230
- if (existing?.active && existing.workflow !== workflow) {
231
- return errorResult(`Workflow ${existing.workflow} is already active. Deactivate it before starting or writing state for ${workflow}.`);
128
+ if (args.active !== false) {
129
+ return errorResult("dna_workflow_write is close-only after the canonical runtime cutover; use dna_run_start/dna_run_next for executable workflows.");
232
130
  }
233
- const sameActiveWorkflow = existing?.active === true && existing.workflow === workflow;
234
- const closingWorkflow = args.active === false;
235
- if (sameActiveWorkflow && closingWorkflow) {
236
- const state = {
237
- ...existing,
238
- active: false,
239
- current_step: String(args.current_step),
240
- current_role: String(args.current_role),
241
- iteration: typeof args.iteration === "number" ? args.iteration : existing.iteration,
242
- };
243
- await writeWorkflowState(projectDir, state, sessionId);
244
- return textResult(`Workflow state updated: ${state.workflow} step=${state.current_step} role=${state.current_role} iteration=${state.iteration}\n`
245
- + "Terminal deactivation preserved the run's pinned state and ignored replacement runtime bindings.");
131
+ if (!existing?.active) {
132
+ return errorResult("dna_workflow_write is close-only and no active legacy workflow exists for this session.");
246
133
  }
247
- const runtimeBinding = await lookupRuntimeBinding(projectDir, workflow);
248
- const hasPinnedRuntimeBinding = sameActiveWorkflow &&
249
- existing?.resolved_variables_source === "compiled_manifest" &&
250
- typeof existing.workflow_runtime_manifest_hash === "string" &&
251
- typeof existing.workflow_runtime_compiled_ir_hash === "string";
252
- if (runtimeBinding.status === "error" && !hasPinnedRuntimeBinding) {
253
- return errorResult(runtimeBinding.message);
254
- }
255
- const currentCompiledIrHash = runtimeBinding.compiledIrHash;
256
- if (hasPinnedRuntimeBinding &&
257
- currentCompiledIrHash !== existing.workflow_runtime_compiled_ir_hash &&
258
- !closingWorkflow) {
259
- return errorResult("The compiled IR changed during this active workflow. Restart the workflow so one run cannot execute against multiple policy revisions.");
260
- }
261
- if (args.inputs !== undefined && !isStringRecord(args.inputs)) {
262
- return errorResult("Workflow inputs must be an object whose values are strings.");
263
- }
264
- const providedInputs = isStringRecord(args.inputs) ? args.inputs : undefined;
265
- let inputs;
266
- let workflowInputsPinned = sameActiveWorkflow ? existing?.workflow_inputs_pinned : undefined;
267
- let workflowAsset;
268
- let resolvedVariables;
269
- let resolvedVariablesSource;
270
- let workflowRuntimeManifestHash;
271
- let workflowRuntimeCompiledIrHash;
272
- const notes = [];
273
- if (hasPinnedRuntimeBinding) {
274
- workflowAsset = existing.workflow_asset;
275
- resolvedVariables = existing.resolved_variables;
276
- resolvedVariablesSource = "compiled_manifest";
277
- workflowRuntimeManifestHash = existing.workflow_runtime_manifest_hash;
278
- workflowRuntimeCompiledIrHash = existing.workflow_runtime_compiled_ir_hash;
279
- workflowInputsPinned = true;
280
- if (providedInputs) {
281
- const normalized = runtimeBinding.status === "found"
282
- ? normalizeManifestInputs(runtimeBinding.binding, providedInputs)
283
- : { valid: true, inputs: providedInputs };
284
- if (!normalized.valid)
285
- return errorResult(normalized.message);
286
- if (!sameStringRecord(existing.inputs ?? {}, normalized.inputs ?? {})) {
287
- return errorResult("Workflow inputs are pinned for an active run and cannot be changed. Finish or restart the workflow to use different inputs.");
288
- }
289
- }
290
- inputs = existing.inputs;
291
- if (args.resolved_variables !== undefined) {
292
- notes.push("Deprecated resolved_variables input ignored; active workflow bindings are pinned.");
293
- }
294
- if (runtimeBinding.status === "found" && runtimeBinding.manifestHash !== workflowRuntimeManifestHash) {
295
- notes.push("A newer compiled workflow runtime manifest exists; this active workflow remains pinned to its start-time bindings.");
296
- }
297
- else if (runtimeBinding.status === "error") {
298
- notes.push("The compiled workflow manifest is invalid or unavailable; this run remains pinned to the same compiled IR revision. Run `dna sync` before the next workflow.");
299
- }
300
- else if (runtimeBinding.status === "legacy") {
301
- notes.push("The compiled runtime manifest is unavailable; this active workflow remains pinned, but `dna sync` is required before the next workflow.");
302
- }
303
- }
304
- else if (runtimeBinding.status === "found") {
305
- let candidateInputs = providedInputs ?? (sameActiveWorkflow ? existing?.inputs : undefined);
306
- if (sameActiveWorkflow && existing?.resolved_variables_source !== "compiled_manifest") {
307
- const existingCandidate = compatibleManifestInputCandidate(runtimeBinding.binding, existing.inputs);
308
- const providedCandidate = compatibleManifestInputCandidate(runtimeBinding.binding, providedInputs);
309
- const normalizedExisting = normalizeManifestInputs(runtimeBinding.binding, existingCandidate.candidate);
310
- const normalizedProvided = providedInputs
311
- ? normalizeManifestInputs(runtimeBinding.binding, providedCandidate.candidate)
312
- : null;
313
- if (normalizedExisting.valid && normalizedExisting.inputs) {
314
- if (normalizedProvided?.valid && normalizedProvided.inputs &&
315
- !sameStringRecord(normalizedExisting.inputs, normalizedProvided.inputs)) {
316
- return errorResult("Workflow inputs are pinned for an active legacy run and cannot be changed during migration.");
317
- }
318
- candidateInputs = existingCandidate.candidate;
319
- }
320
- else {
321
- candidateInputs = { ...existingCandidate.candidate, ...providedCandidate.candidate };
322
- }
323
- const ignored = [...new Set([...existingCandidate.ignored, ...providedCandidate.ignored])];
324
- if (ignored.length > 0) {
325
- notes.push(`Ignored legacy workflow input metadata during migration: ${ignored.join(", ")}.`);
326
- }
327
- }
328
- const normalizedInputs = normalizeManifestInputs(runtimeBinding.binding, candidateInputs);
329
- if (!normalizedInputs.valid)
330
- return errorResult(normalizedInputs.message);
331
- inputs = normalizedInputs.inputs;
332
- workflowInputsPinned = true;
333
- workflowAsset = runtimeBinding.binding.workflow_asset;
334
- resolvedVariables = runtimeBinding.binding.resolved_variables;
335
- resolvedVariablesSource = "compiled_manifest";
336
- workflowRuntimeManifestHash = runtimeBinding.manifestHash;
337
- workflowRuntimeCompiledIrHash = runtimeBinding.compiledIrHash;
338
- if (normalizedInputs.note)
339
- notes.push(normalizedInputs.note);
340
- if (args.resolved_variables !== undefined) {
341
- notes.push("Deprecated resolved_variables input ignored; compiled workflow runtime manifest is authoritative.");
342
- }
343
- if (sameActiveWorkflow && existing?.resolved_variables_source !== "compiled_manifest") {
344
- notes.push("Legacy workflow state upgraded to compiled workflow runtime bindings.");
345
- }
346
- }
347
- else {
348
- return errorResult("This project has a legacy compiled IR without deterministic workflow runtime bindings. Run `dna sync` with the upgraded IntentDNA CLI, then retry the workflow. Model-supplied workflow_asset and resolved_variables are not trusted.");
134
+ if (existing.workflow !== workflow) {
135
+ return errorResult(`Legacy workflow ${existing.workflow} is active; close it with the same workflow id before starting a canonical run.`);
349
136
  }
350
137
  const state = {
351
- active: typeof args.active === "boolean" ? args.active : true,
352
- workflow_asset: workflowAsset,
353
- workflow,
354
- current_step: String(args.current_step),
355
- current_role: String(args.current_role),
356
- iteration: typeof args.iteration === "number" ? args.iteration : (sameActiveWorkflow ? existing?.iteration ?? 1 : 1),
357
- session_id: sessionId ?? (sameActiveWorkflow ? existing?.session_id : undefined) ?? "",
358
- started_at: sameActiveWorkflow ? existing.started_at : new Date().toISOString(),
359
- inputs,
360
- resolved_variables: resolvedVariables,
361
- resolved_variables_source: resolvedVariablesSource,
362
- workflow_runtime_manifest_hash: workflowRuntimeManifestHash,
363
- workflow_runtime_compiled_ir_hash: workflowRuntimeCompiledIrHash,
364
- workflow_inputs_pinned: workflowInputsPinned,
365
- completed_artifacts: sameActiveWorkflow ? existing?.completed_artifacts : undefined,
138
+ ...existing,
139
+ active: false,
366
140
  };
367
141
  await writeWorkflowState(projectDir, state, sessionId);
368
- return textResult([
369
- `Workflow state updated: ${state.workflow} step=${state.current_step} role=${state.current_role} iteration=${state.iteration}`,
370
- ...notes,
371
- ].join("\n"));
142
+ return textResult(`Legacy workflow closed: ${state.workflow} step=${state.current_step} role=${state.current_role} iteration=${state.iteration}\n`
143
+ + "Existing legacy progress was preserved; no scheduler, handoff, or result authority was transferred to the canonical runtime.");
372
144
  },
373
145
  },
374
146
  // ── dna_trace_query ──────────────────────────────────
@@ -0,0 +1,146 @@
1
+ export declare const DIRECTORY_ARTIFACT_SCHEMA_VERSION: "intentdna.directory_artifact.v1";
2
+ export declare const GIT_COMMIT_ARTIFACT_SCHEMA_VERSION: "intentdna.git_commit_artifact.v1";
3
+ export type ArtifactKind = "file" | "directory" | "git_commit";
4
+ export type CapturableArtifactKind = Exclude<ArtifactKind, "git_commit">;
5
+ export interface FileArtifactEntry {
6
+ readonly kind: "file";
7
+ readonly path: string;
8
+ readonly artifact_id: string;
9
+ readonly size_bytes: number;
10
+ }
11
+ export interface DirectoryArtifactEntry {
12
+ readonly kind: "directory";
13
+ readonly path: string;
14
+ }
15
+ export type ArtifactEntry = FileArtifactEntry | DirectoryArtifactEntry;
16
+ export interface FileArtifactObject {
17
+ readonly artifact_id: string;
18
+ readonly kind: "file";
19
+ readonly size_bytes: number;
20
+ }
21
+ export interface DirectoryArtifactObject {
22
+ readonly artifact_id: string;
23
+ readonly kind: "directory";
24
+ readonly size_bytes: number;
25
+ readonly manifest: readonly ArtifactEntry[];
26
+ }
27
+ export interface GitCommitArtifactObject {
28
+ readonly artifact_id: string;
29
+ readonly kind: "git_commit";
30
+ readonly size_bytes: number;
31
+ readonly repository_id: string;
32
+ readonly object_format: "sha1" | "sha256";
33
+ readonly commit_oid: string;
34
+ }
35
+ export type ArtifactObject = FileArtifactObject | DirectoryArtifactObject | GitCommitArtifactObject;
36
+ export interface ArtifactCaptureRef {
37
+ readonly capture_id: string;
38
+ readonly artifact_id: string;
39
+ readonly artifact_kind: ArtifactKind;
40
+ readonly run_id: string;
41
+ readonly activation_id: string;
42
+ readonly attempt_id: string;
43
+ readonly output_name: string;
44
+ readonly source_workspace_id: string;
45
+ readonly source_path: string;
46
+ readonly captured_at: string;
47
+ }
48
+ export interface CaptureArtifactRequest {
49
+ readonly kind: ArtifactKind;
50
+ readonly workspace_root: string;
51
+ readonly source_path: string;
52
+ readonly run_id: string;
53
+ readonly activation_id: string;
54
+ readonly attempt_id: string;
55
+ readonly output_name: string;
56
+ readonly source_workspace_id: string;
57
+ }
58
+ export interface CaptureArtifactResponse {
59
+ readonly object: ArtifactObject;
60
+ readonly capture: ArtifactCaptureRef;
61
+ }
62
+ export interface CaptureExistingArtifactRequest extends ArtifactLocator {
63
+ readonly run_id: string;
64
+ readonly activation_id: string;
65
+ readonly attempt_id: string;
66
+ readonly output_name: string;
67
+ readonly source_workspace_id: string;
68
+ readonly source_path: string;
69
+ }
70
+ export interface ArtifactLocator {
71
+ readonly artifact_id: string;
72
+ readonly artifact_kind: ArtifactKind;
73
+ }
74
+ export interface ArtifactStoreOptions {
75
+ readonly root_directory: string;
76
+ readonly now?: () => Date;
77
+ readonly max_file_size_bytes?: number;
78
+ readonly max_directory_size_bytes?: number;
79
+ readonly max_directory_entries?: number;
80
+ readonly max_manifest_size_bytes?: number;
81
+ }
82
+ export interface MaterializeArtifactRequest extends ArtifactLocator {
83
+ readonly destination_root: string;
84
+ readonly binding_id: string;
85
+ }
86
+ export interface MaterializedArtifact extends ArtifactLocator {
87
+ readonly materialized_path: string;
88
+ }
89
+ export type ArtifactStoreErrorCode = "invalid_options" | "invalid_request" | "unsupported_artifact_kind" | "source_not_found" | "source_outside_workspace" | "source_kind_mismatch" | "symlink_not_allowed" | "special_file_not_allowed" | "limit_exceeded" | "source_drift" | "git_repository_invalid" | "git_commit_invalid" | "artifact_not_found" | "artifact_corrupt" | "unsafe_destination" | "materialization_conflict" | "materialization_verification_failed";
90
+ export declare class ArtifactStoreError extends Error {
91
+ readonly code: ArtifactStoreErrorCode;
92
+ constructor(code: ArtifactStoreErrorCode, message: string);
93
+ }
94
+ export declare class ArtifactStore {
95
+ private readonly options;
96
+ private readonly now;
97
+ constructor(options: ArtifactStoreOptions);
98
+ /**
99
+ * The caller must stop the producer and hold exclusive mutation authority for
100
+ * the workspace namespace until this promise settles.
101
+ */
102
+ capture(request: CaptureArtifactRequest): Promise<CaptureArtifactResponse>;
103
+ captureExisting(request: CaptureExistingArtifactRequest): Promise<CaptureArtifactResponse>;
104
+ resolve(locator: ArtifactLocator): Promise<ArtifactObject | null>;
105
+ require(locator: ArtifactLocator): Promise<ArtifactObject>;
106
+ readFileBytes(artifactId: string): Promise<Buffer>;
107
+ readGitCommitBytes(artifactId: string): Promise<Buffer>;
108
+ verifyGitCommitInWorkspace(locator: ArtifactLocator, workspaceRoot: string): Promise<GitCommitArtifactObject>;
109
+ verifyGitCommitProducedByAttempt(locator: ArtifactLocator, workspaceRoot: string, baselineCommitOid: string, expectedBranchRef: string | null): Promise<GitCommitArtifactObject>;
110
+ protected beforeSourceRevalidation(_sourcePath: string, _kind: CapturableArtifactKind): Promise<void>;
111
+ private ensureLayout;
112
+ private fileObjectsDirectory;
113
+ private directoryObjectsDirectory;
114
+ private gitCommitObjectsDirectory;
115
+ private temporaryDirectory;
116
+ private fileObjectPath;
117
+ private directoryObjectPath;
118
+ private gitCommitObjectPath;
119
+ private resolveSource;
120
+ private assertSourceResolutionStable;
121
+ private captureGitCommit;
122
+ private inspectGitCommit;
123
+ private captureFile;
124
+ private captureDirectory;
125
+ private scanDirectory;
126
+ private signatureMapsEqual;
127
+ private publishNoReplace;
128
+ private readFileObject;
129
+ private readDirectoryObject;
130
+ private readGitCommitObject;
131
+ }
132
+ export declare class ArtifactMaterializer {
133
+ private readonly store;
134
+ constructor(store: ArtifactStore);
135
+ materialize(request: MaterializeArtifactRequest): Promise<MaterializedArtifact>;
136
+ /** Reuses an existing target only after verifying the complete immutable artifact. */
137
+ materializeReplaySafe(request: MaterializeArtifactRequest): Promise<MaterializedArtifact>;
138
+ private materializeWithExistingTargetPolicy;
139
+ protected beforePostCopyVerification(_materializedPath: string, _object: ArtifactObject): Promise<void>;
140
+ private materializeFile;
141
+ private materializeDirectory;
142
+ private verifyExistingMaterialization;
143
+ private verifyMaterializedFile;
144
+ private verifyMaterializedDirectory;
145
+ }
146
+ export { ArtifactStore as ImmutableArtifactStore };