@deksden-com/dd-flow-cli 0.9.0-beta.106 → 0.9.0-beta.107

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @deksden-com/dd-flow-cli
2
2
 
3
+ ## 0.9.0-beta.107
4
+
5
+ ### Patch Changes
6
+
7
+ - Give a corrective successor only for proven no-effect PROTOCOLIZE, PLAN, PLAN-REVIEW, and Work input errors, including invalid corrected PLAN schemas and missing evidence references; keep broken runtime artifacts fatal. Tell PLAN reviewers the exact workspace-relative PLAN path. Apply ZCode's profile as one unarmed configuration phase and verify the final native profile before productive work, so transient native mode notifications cannot masquerade as drift.
8
+
3
9
  ## 0.9.0-beta.106
4
10
 
5
11
  ### Patch Changes
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "cli_package": "@deksden-com/dd-flow-cli",
3
- "cli_version": "0.9.0-beta.106",
4
- "cli_commit": "41377cb4915163be7220cc90928ea8a0f50683d0",
5
- "built_at": "2026-09-27T00:48:48.042Z",
3
+ "cli_version": "0.9.0-beta.107",
4
+ "cli_commit": "b1e4fba26b8d9dea7b9b4f6de05aec6be3e21dc2",
5
+ "built_at": "2026-09-27T03:02:31.051Z",
6
6
  "built_with_canon": {
7
7
  "version": "4.1.1",
8
8
  "commit": "678daa038287c948ada5b2d785a6dcc925c7b891",
@@ -666,6 +666,8 @@ async function controlledIdentity(bridge, options) {
666
666
  }
667
667
 
668
668
  async function applyProfile(bridge, sessionId, requested, assertDispatch = () => {}) {
669
+ const identity = bridge.modelSessions?.get(sessionId);
670
+ if (identity) identity.armed = false;
669
671
  assertDispatch();
670
672
  if (requested.mode) await bridge.request("session/set_mode", { sessionId, modeId: requested.mode });
671
673
  assertDispatch();
@@ -674,10 +676,11 @@ async function applyProfile(bridge, sessionId, requested, assertDispatch = () =>
674
676
  if (requested.model) await bridge.request("session/setModel", { sessionId, modelId: requested.provider ? `${requested.provider}\\${requested.model}` : requested.model });
675
677
  assertDispatch();
676
678
  const read = await bridge.request("zcode/session/read", { sessionId });
679
+ await bridge.notifications;
677
680
  const observed = observedProfile(read);
678
681
  await bridge.recordModel?.(sessionId, observed, "zcode/session/read.applied");
679
682
  const receipt = assertProfile(requested, observed);
680
- const identity = bridge.modelSessions?.get(sessionId); if (identity) identity.armed = true;
683
+ if (identity) identity.armed = true;
681
684
  return receipt;
682
685
  }
683
686
 
@@ -1302,8 +1302,6 @@ export async function awaitLifecycleInvocation(context, input) {
1302
1302
  checkCommand(initial, input.command);
1303
1303
  // A terminal command is immutable evidence. Do not require a now-gone
1304
1304
  // caller payload merely to replay its recorded result.
1305
- if (["issued", "observed"].includes(initial.status))
1306
- await input.prepare?.();
1307
1305
  }
1308
1306
  catch (error) {
1309
1307
  if (!(error instanceof AppError) || !(["usage", "invocation_command_mismatch", "invocation_command_invalid"].includes(error.code) || error.details.phase === "prepare"))
@@ -1311,6 +1309,22 @@ export async function awaitLifecycleInvocation(context, input) {
1311
1309
  Object.assign(error.details, settleLifecyclePreparationRejection(context, input.id, error));
1312
1310
  throw error;
1313
1311
  }
1312
+ if (["issued", "observed"].includes(initial.status)) {
1313
+ try {
1314
+ await input.prepare?.();
1315
+ }
1316
+ catch (error) {
1317
+ if (!(error instanceof AppError) || (error.details.effect !== undefined && error.details.effect !== "no_effect"))
1318
+ throw error;
1319
+ const details = { ...error.details, phase: "prepare", effect: "no_effect" };
1320
+ const recoverable = error.exitCode === 2 && ["validation", "schema_validation"].includes(error.code)
1321
+ ? error.details.recoverable !== false
1322
+ : isRetryableLifecycleRejection(error.code, details);
1323
+ Object.assign(error.details, { phase: "prepare", effect: "no_effect", recoverable });
1324
+ Object.assign(error.details, settleLifecyclePreparationRejection(context, input.id, error));
1325
+ throw error;
1326
+ }
1327
+ }
1314
1328
  const timeoutMs = input.timeoutMs ?? 30000;
1315
1329
  if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > 60000)
1316
1330
  throw new AppError("invocation_timeout_invalid", "Receipt timeout must be within 1..60000 ms", 1);
@@ -265,7 +265,7 @@ function finishPlanReviewOwned(context, input) {
265
265
  if (evidenceFailures.length)
266
266
  throw new AppError("review_evidence_invalid", "PLAN-REVIEW reviewer evidence is incomplete, stale, or not isolated", 2, { errors: evidenceFailures });
267
267
  if (decision.outcome !== "accepted")
268
- throw new AppError("validation", "Unsupported PLAN-REVIEW decision outcome", 2, { outcome: decision.outcome });
268
+ throw new AppError("validation", "Unsupported PLAN-REVIEW decision outcome", 2, { outcome: decision.outcome, phase: "prepare", effect: "no_effect", recoverable: true });
269
269
  // A completed reviewer can legitimately report `blocked` when an upstream
270
270
  // plan uncertainty prevents it from approving its aspect. That is evidence
271
271
  // for the coordinator to classify and fix in this one review pass, not an
@@ -283,21 +283,21 @@ function finishPlanReviewOwned(context, input) {
283
283
  throw new AppError("review_evidence_invalid", "Reviewer findings and coordinator decisions must use unique known canonical references, with every material finding decided", 2, { material_finding_ids: materialFindingIds, decided_finding_ids: decisionFindingIds, unknown_decisions: unknownDecisions });
284
284
  if (needsCorrection) {
285
285
  if (decision.correction.status !== "applied")
286
- throw new AppError("validation", "Reviewer findings require an in-place correction receipt", 2);
286
+ throw new AppError("validation", "Reviewer findings require an in-place correction receipt", 2, { phase: "prepare", effect: "no_effect", recoverable: true });
287
287
  if (decision.correction.previous_plan_revision !== reviewedPlanRevision || planRevision <= reviewedPlanRevision || decision.correction.changed_paths.length === 0)
288
- throw new AppError("validation", "Applied PLAN correction must advance revision and list changed paths", 2, { reviewed_plan_revision: reviewedPlanRevision, final_plan_revision: planRevision });
288
+ throw new AppError("validation", "Applied PLAN correction must advance revision and list changed paths", 2, { reviewed_plan_revision: reviewedPlanRevision, final_plan_revision: planRevision, phase: "prepare", effect: "no_effect", recoverable: true });
289
289
  }
290
290
  else if (decision.correction.status !== "not_required" || planRevision !== reviewedPlanRevision || currentPlanChecksum !== contextFile.system?.plan_checksum) {
291
- throw new AppError("validation", "A clean PLAN review must not claim an unverified correction", 2);
291
+ throw new AppError("validation", "A clean PLAN review must not claim an unverified correction", 2, { phase: "prepare", effect: "no_effect", recoverable: true });
292
292
  }
293
293
  const prepared = prepareVnextPlanArtifacts(context, { projectRoot, workspaceRoot: run.workspace_root, runId: run.id, home, protocols: protocolIdsForReview(home) });
294
294
  if (prepared.failures.length)
295
- throw new AppError("validation", "Corrected PLAN artifacts have validation errors", 2, { errors: prepared.failures });
295
+ throw new AppError("validation", "Corrected PLAN artifacts have validation errors", 2, { errors: prepared.failures, phase: "prepare", effect: "no_effect", recoverable: true });
296
296
  if (needsCorrection) {
297
297
  // Regeneration above is authoritative. A valid PLAN correction need not
298
298
  // change the derived CODE tasks (for example, a clarified explanation).
299
299
  if (decision.correction.changed_paths.some((item) => item.endsWith("code-work-batch.json")))
300
- throw new AppError("validation", "Generated CODE batch must not be listed as an agent-authored correction", 2, { changed_paths: decision.correction.changed_paths });
300
+ throw new AppError("validation", "Generated CODE batch must not be listed as an agent-authored correction", 2, { changed_paths: decision.correction.changed_paths, phase: "prepare", effect: "no_effect", recoverable: true });
301
301
  }
302
302
  const finalPlanChecksum = planSetChecksum(home, run.workspace_root);
303
303
  const finalBatchChecksum = prepared.batchChecksum;
@@ -358,7 +358,7 @@ function reviewGroups(home, workspaceRoot) {
358
358
  if (dependencyGroup && dependencyGroup !== key)
359
359
  dependencies.add(dependencyGroup);
360
360
  }
361
- groups.push({ key, protocol_id: protocolId, aspect_ids: group.aspect_ids, depends_on: [...dependencies].sort(), task: `Review PLAN group ${key}: ${group.aspect_ids.join(", ")}. Read run://${path.basename(home)}/03-plan/${protocolId}/aspect-map.json and the referenced plan. Try to falsify ambiguous behavior and missing verification. For every selected check that starts fixture/reset, service, or client processes, verify that they share the intended data/configuration world and that any runtime entrypoint requiring change is explicit in a Work task and verification and ordered before its consumer. planned_write_areas are coordination hints, not ownership. Do not edit plan or product files. Return one aspect entry for every assigned aspect, with exact evidence references and concise findings. Finish with the JSON contract supplied in your work prompt.` });
361
+ groups.push({ key, protocol_id: protocolId, aspect_ids: group.aspect_ids, depends_on: [...dependencies].sort(), task: `Review PLAN group ${key}: ${group.aspect_ids.join(", ")}. Read run://${path.basename(home)}/03-plan/${protocolId}/aspect-map.json and .memory-bank/protocol/${protocolId}/plan.json under workspace_root. Cite the PLAN using that workspace-relative path, not a run:// ref. Try to falsify ambiguous behavior and missing verification. For every selected check that starts fixture/reset, service, or client processes, verify that they share the intended data/configuration world and that any runtime entrypoint requiring change is explicit in a Work task and verification and ordered before its consumer. planned_write_areas are coordination hints, not ownership. Do not edit plan or product files. Return one aspect entry for every assigned aspect, with exact evidence references and concise findings. Finish with the JSON contract supplied in your work prompt.` });
362
362
  }
363
363
  }
364
364
  return groups;
@@ -126,7 +126,7 @@ export function prepareVnextPlanFinish(context, input) {
126
126
  assertProtocolWorkspace(run.workspace_root, protocols);
127
127
  const prepared = prepareVnextPlanArtifacts(context, { projectRoot, workspaceRoot: run.workspace_root, runId: run.id, home, protocols });
128
128
  if (prepared.failures.length)
129
- throw new AppError("validation", "PLAN artifacts have validation errors", 2, { errors: prepared.failures });
129
+ throw new AppError("validation", "PLAN artifacts have validation errors", 2, { errors: prepared.failures, phase: "prepare", effect: "no_effect", recoverable: true });
130
130
  return prepared;
131
131
  }
132
132
  export function finishVnextPlan(context, input) {
@@ -148,7 +148,7 @@ function finishVnextPlanOwned(context, input) {
148
148
  const batch = path.join(root, "code-work-batch.json");
149
149
  const prepared = input.prepared ?? prepareVnextPlanFinish(context, input);
150
150
  if (prepared.failures.length)
151
- throw new AppError("validation", "PLAN artifacts have validation errors", 2, { errors: prepared.failures });
151
+ throw new AppError("validation", "PLAN artifacts have validation errors", 2, { errors: prepared.failures, phase: "prepare", effect: "no_effect", recoverable: true });
152
152
  const work = context.db.get("SELECT work_id FROM works WHERE project_id = ? AND run_id = ? AND task = ? AND status = 'running' ORDER BY created_at DESC LIMIT 1", [project.id, run.id, planTask]);
153
153
  if (!work)
154
154
  throw new AppError("invalid_work_state", "PLAN has no running Work", 1);
@@ -183,11 +183,19 @@ export function finishVnextProtocolize(context, input) {
183
183
  const resultFile = prepareProtocolizeResultPath(requireRunHome(run), input.resultFile);
184
184
  const result = input.result ?? readResult(resultFile, { projectRoot, ddFlowHome: context.ddFlowHome, runId: run.id, runRoot: requireRunHome(run) });
185
185
  validateSchema({ schemaName: "vnext-protocolize-result", file: resultFile, data: result, projectRoot, ddFlowHome: context.ddFlowHome, runId: run.id, runRoot: requireRunHome(run) });
186
- if (result.outcome !== "protocolized")
187
- throw new AppError("validation", "PROTOCOLIZE may finish only as protocolized; use stage pause for every user question", 2);
188
186
  const acceptedObligations = acceptedSpecifyObligations(context, projectRoot, run.id, path.join(requireRunHome(run), "01-specify", "specify.json"));
189
- const obligations = effectiveObligations(result, acceptedObligations);
190
- validateDelivery(projectRoot, result, obligations);
187
+ let obligations;
188
+ try {
189
+ if (result.outcome !== "protocolized")
190
+ throw new AppError("validation", "PROTOCOLIZE may finish only as protocolized; use stage pause for every user question", 2);
191
+ obligations = effectiveObligations(result, acceptedObligations);
192
+ validateDelivery(projectRoot, result, obligations);
193
+ }
194
+ catch (error) {
195
+ if (!(error instanceof AppError) || error.code !== "validation" || error.exitCode !== 2)
196
+ throw error;
197
+ throw new AppError(error.code, error.message, error.exitCode, { ...error.details, phase: "prepare", effect: "no_effect", recoverable: true });
198
+ }
191
199
  const resolvedPolicy = requireVnextWorkspaceRoute({ projectRoot, runId: run.id, runHome: requireRunHome(run), workspaceRoot: run.workspace_root, stage: "protocolize" });
192
200
  const receipt = readWorkspaceRouteReceipt(root);
193
201
  const workspaceRoot = run.workspace_root;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deksden-com/dd-flow-cli",
3
- "version": "0.9.0-beta.106",
3
+ "version": "0.9.0-beta.107",
4
4
  "description": "Mechanical runtime CLI for dd-flow workflows.",
5
5
  "type": "module",
6
6
  "bin": {