muse-crew 0.14.7 → 0.14.9

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.
@@ -52,17 +52,24 @@ Applies to: standard, bugfix, chore.
52
52
  <a id="closeout-envelope"></a>
53
53
  ## Closeout transport envelope
54
54
 
55
- Invariant: the work agent returns the runtime's native transport envelope with no schema; the verdict is extracted mechanically by extractVerdict — never by an agent.
55
+ Invariant: the schema-less work-agent courier returns prose; the workflow
56
+ consumes the return as a plain string. Nothing parses a JSON envelope —
57
+ the prompt names none (blocker 43, 2026-09-22: the old "Return your work as
58
+ JSON in exactly this shape: {...}" invitation drew brace-shaped prose into
59
+ a channel where the runtime's JSON-candidate scan threw, and three
60
+ consecutive Integrate failures parked room #28's J1 at the retry cap; the
61
+ second REVIEW pass then reworded the retry trailer's "discarded" why off
62
+ "machine-read as JSON" to the true event — {...}-shaped fragments the scan
63
+ could not parse — since the old framing was an implicit JSON invitation).
64
+ The verdict is extracted mechanically by extractVerdict — never by an agent.
56
65
 
57
66
  Applies to: standard, bugfix, chore.
58
67
 
59
68
  ```
60
- // Work agent returns the runtime's native envelope {"status": "ok",
61
- // "result": "<prose>"} with no schema. The runtime requires JSON output;
62
- // the envelope is its own documented shape, so there is nothing for the
63
- // agent to improvise. The workflow receives the prose report as a plain
64
- // string. The verdict is still extracted deterministically from the report
65
- // text by extractVerdict below — never by an agent.
69
+ // Work agent returns prose on the schema-less courier; the workflow
70
+ // consumes the return as a plain string. The verdict is still extracted
71
+ // deterministically from the report text by extractVerdict — never by
72
+ // an agent.
66
73
  ```
67
74
 
68
75
  <a id="extract-verdict-contract"></a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muse-crew",
3
- "version": "0.14.7",
3
+ "version": "0.14.9",
4
4
  "description": "Opinionated orchestration for Muse — workflows, identities, and tooling for autonomous software development.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -131,7 +131,7 @@ if (!taskId) {
131
131
  throw new Error("task_id is required in args");
132
132
  }
133
133
 
134
- // See docs/decisions/workflow-core.md#closeout-envelope: the work agent returns the runtime's native envelope; verdict extracted mechanically.
134
+ // See docs/decisions/workflow-core.md#closeout-envelope: the schema-less work courier returns prose, consumed as a plain string; verdict extracted mechanically.
135
135
  const VERDICT_STEPS = ["Build", "Review", "QA", "Reproduce", "Integrate", "Publish"];
136
136
  function extractVerdict(workerText) {
137
137
  // The verdict is the LAST VERDICT: PASS/FAIL in the report (contract: end
@@ -221,7 +221,6 @@ function buildVerdictReaskPrompt(stepName, workerText) {
221
221
  "Decide from the report's own content whether the " + stepName + " step clearly describes successful completion: " +
222
222
  "if it does, the verdict is PASS; otherwise — failure, error, unfinished work, or unclear — the verdict is FAIL. " +
223
223
  "Do NOT copy any VERDICT line from the report — decide from the content.\n\n" +
224
- "Return your work as JSON in exactly this shape: {\"status\": \"ok\", \"result\": \"your verdict line here\"}. " +
225
224
  "The result must be exactly one line and nothing else: VERDICT: PASS or VERDICT: FAIL.";
226
225
  }
227
226
  async function reaskVerdict(stepName, reworkSuffix, workerText) {
@@ -294,8 +293,8 @@ var TOOL_CHECK_PREAMBLE =
294
293
  "3. Run the shell command: echo tool-probe-ok - then write exactly one line: shell_transport: ok - or shell_transport: unavailable if you cannot run shell commands.\n" +
295
294
  "Then do the assignment below.\n\n";
296
295
  function buildTransportRetryTrailer(stepName, repoPath, taskId, attempt, reason) {
297
- // reason: "discarded" (the runtime threw the output away - it could not be
298
- // machine-read), "empty" (agent() returned without throwing but produced
296
+ // reason: "discarded" (the runtime threw the output away — the JSON-candidate
297
+ // scan found {...}-shaped fragments it could not parse), "empty" (agent() returned without throwing but produced
299
298
  // nothing usable), "no-tools" (the worker's TOOL CHECK reported
300
299
  // artifact_tools: missing), or "no-transport" (the worker's TOOL CHECK
301
300
  // reported shell_transport: unavailable).
@@ -306,12 +305,148 @@ function buildTransportRetryTrailer(stepName, repoPath, taskId, attempt, reason)
306
305
  ? "your previous attempt's TOOL CHECK reported artifact_tools: missing (this is a fresh launch, so run the TOOL CHECK's load step again before the work)"
307
306
  : reason === "no-transport"
308
307
  ? "your previous attempt's TOOL CHECK reported shell_transport: unavailable (this is a fresh launch, so run the TOOL CHECK's shell probe again before the work)"
309
- : "your previous attempt's output could not be machine-read as JSON and was discarded";
308
+ : "your previous attempt's output was discarded by the transport because it contained {...}-shaped fragments the transport could not parse; write plain prose with no JSON-shaped fragments";
310
309
  return "\n\nTRANSPORT RETRY (attempt " + attempt + " of 2): " + why + ". " +
311
310
  "First check existing state (worktree/branch at " + repoPath + "/.worktrees/" + taskId + ", the task branch, dashboard sessions for this task) - " +
312
311
  "if the " + stepName + " work is already complete, report on what was done rather than duplicating side effects. " +
313
- "Then return your report as JSON in exactly the shape specified above.";
312
+ "Then return your report in exactly the shape specified above.";
314
313
  }
314
+ // parseClassifyFerry — room #26 blocker 42 (2026-09-21). Shape-constrained
315
+ // ferry parser for the classify-branch agent() call. The schema buys SHAPE,
316
+ // not provenance: the fields are LLM-authored, so the parser stays
317
+ // defensive. Byte-identical across standard.js, bugfix.js, chore.js
318
+ // (pinned by tests/already-merged.test.js). Triplication is structural:
319
+ // each workflow ships as a standalone launch payload (240 KiB budget,
320
+ // individually git-archived) — there is no shared module to hold it.
321
+ // The schema is the guard; the prompt is instruction, never load-bearing.
322
+ // Returns { state, diagField, diagText, failReason }:
323
+ // state: "has-work" | "already-merged:<40-hex>" | "empty-no-work" | null
324
+ // (null = unparseable/ambiguous/channel violation — UNKNOWN)
325
+ // diagField: "stderr" | "stdout" | null (which field sourced the DIAG pin)
326
+ // diagText: the matched DIAG line, or ""
327
+ // failReason: computed reason, for the retry trailer and the park note
328
+ function parseClassifyFerry(bsResult) {
329
+ var bsStdout = (bsResult && typeof bsResult.stdout === "string") ? bsResult.stdout : null;
330
+ var bsStderr = (bsResult && typeof bsResult.stderr === "string") ? bsResult.stderr : null;
331
+ if (bsStdout === null || bsStderr === null) {
332
+ return { state: null, diagField: null, diagText: "",
333
+ failReason: "classifier return fields missing or non-string (stdout and stderr must both be strings)" };
334
+ }
335
+ // State channel: stdout ONLY. A BRANCH_STATE match on stderr is never
336
+ // trusted — workers merge streams constantly, and trusting a channel
337
+ // swap as truth is the wrong shape. Search, never anchor (blocker 11):
338
+ // the ferry labels output ("stdout: BRANCH_STATE: has-work"). Collect
339
+ // ALL matches and dedupe normalized values: exactly one distinct value
340
+ // is truth; zero or two-or-more is UNKNOWN — alternation order never
341
+ // adjudicates.
342
+ var bsRe = /\bBRANCH_STATE:\s*(has-work|already-merged:[0-9a-f]{40}|empty-no-work)(?![\w-])/gi;
343
+ var bsSeen = {};
344
+ var bsM;
345
+ while ((bsM = bsRe.exec(bsStdout)) !== null) {
346
+ bsSeen[bsM[1].toLowerCase()] = true;
347
+ }
348
+ var bsStates = Object.keys(bsSeen);
349
+ if (bsStates.length !== 1) {
350
+ return { state: null, diagField: null, diagText: "",
351
+ failReason: bsStates.length === 0
352
+ ? "no BRANCH_STATE match in the stdout field"
353
+ : "ambiguous BRANCH_STATE values in stdout (" + bsStates.length + " distinct)" };
354
+ }
355
+ var bsState = bsStates[0];
356
+ // DIAG pin: search both fields, stderr first. Keep the DIAG: prefix — a
357
+ // prose mention without it must not satisfy the pin.
358
+ var bsDiagRe = /DIAG:\s*classify-branch\s+records=\d+\s+resolvable=\d+/;
359
+ var bsDiagField = bsDiagRe.test(bsStderr) ? "stderr" : (bsDiagRe.test(bsStdout) ? "stdout" : null);
360
+ var bsDiagText = "";
361
+ if (bsDiagField !== null) {
362
+ bsDiagText = bsDiagRe.exec(bsDiagField === "stderr" ? bsStderr : bsStdout)[0];
363
+ }
364
+ if (bsState.indexOf("already-merged:") === 0 && bsDiagField === null) {
365
+ // already-merged's sha flows into Cass's `git diff <sha>^1 <sha>` — a
366
+ // hallucinated-but-well-formed sha is a false-PASS vector. The script
367
+ // emits exactly one DIAG on every path that emits a BRANCH_STATE, so a
368
+ // missing pin means stderr wasn't faithfully ferried: UNKNOWN.
369
+ // Residual risk, named (blocker-42 fib 4): a worker could fabricate
370
+ // BOTH fields wholesale — the pin is a tripwire, not proof of
371
+ // execution. The workflow has no exec channel for a deterministic
372
+ // cross-check; if the platform ever offers one, verify the sha
373
+ // against the task's durable merge records directly.
374
+ return { state: null, diagField: null, diagText: "",
375
+ failReason: "already-merged without the DIAG pin — stderr not faithfully ferried" };
376
+ }
377
+ return { state: bsState, diagField: bsDiagField, diagText: bsDiagText, failReason: "" };
378
+ }
379
+
380
+ // classifyRetryTrailer — room #26 blocker 42 (2026-09-21). Corrective (not
381
+ // flat) trailer for the in-place classify retries. The failure mode was
382
+ // systematic labeling, not a coin flip: the trailer carries the COMPUTED
383
+ // parse-failure reason, the failed return truncated as a negative example,
384
+ // and the explicit field mapping — feedback from the actual failure,
385
+ // following the buildTransportRetryTrailer idiom. Bound: 2 retries
386
+ // (unmeasured house convention, matches the shared rework bound of 2 —
387
+ // against room retry data). Byte-identical across the three workflows
388
+ // (pinned by tests/already-merged.test.js).
389
+ function classifyRetryTrailer(reason, failedReturn) {
390
+ // Pass-2 simplification: the reason string already carries the truth
391
+ // (throw vs parse failure), so one neutral sentence replaces the
392
+ // throw/parse branch — the stringly-typed prefix contract between the
393
+ // call site and this function is deleted, not moved. Prompt accuracy,
394
+ // not prompt hardening.
395
+ return "\n\nCLASSIFY RETRY: the previous classifier attempt failed (" + reason + "). " +
396
+ "Return ONLY the two named fields: { \"stdout\": \"<the command's exact stdout>\", \"stderr\": \"<the command's exact stderr>\" }. " +
397
+ "Put each stream in its named field — do not add labels like \"stdout:\" in front of the content. " +
398
+ "Previous attempt detail (do not repeat this shape): " + String(failedReturn).slice(0, 200);
399
+ }
400
+
401
+ // parseVersionFerry — review pass 2, blocker-42 class (2026-09-21). The npm
402
+ // version-check ferry had the full pre-42 shape: schema-less agent(),
403
+ // line-anchored parser, and an unparseable fallback asserting a POSITIVE
404
+ // touched claim that spent the shared rework budget. Same treatment as
405
+ // parseClassifyFerry: shape-constrained {stdout} schema, search-and-dedupe
406
+ // parse, UNKNOWN on unparseable with in-place retries, honest park.
407
+ // Byte-identical across standard.js, bugfix.js, chore.js
408
+ // (pinned by tests/already-merged.test.js).
409
+ // Returns { versionState, failReason }:
410
+ // versionState: "touched" | "clean" | null (null = UNKNOWN)
411
+ // failReason: computed reason, for the retry trailer and the park note
412
+ function parseVersionFerry(vtResult) {
413
+ var vtStdout = (vtResult && typeof vtResult.stdout === "string") ? vtResult.stdout : null;
414
+ if (vtStdout === null) {
415
+ return { versionState: null,
416
+ failReason: "version-check return field missing or non-string (stdout must be a string)" };
417
+ }
418
+ // Search, never anchor (blocker 11): the ferry labels output
419
+ // ("stdout: VERSION_CLEAN"). Collect ALL matches and dedupe normalized
420
+ // values: exactly one distinct value is truth; zero or two-or-more is
421
+ // UNKNOWN — alternation order never adjudicates.
422
+ var vtRe = /\bVERSION_(TOUCHED|CLEAN)(?![\w-])/gi;
423
+ var vtSeen = {};
424
+ var vtM;
425
+ while ((vtM = vtRe.exec(vtStdout)) !== null) {
426
+ vtSeen[vtM[1].toUpperCase()] = true;
427
+ }
428
+ var vtStates = Object.keys(vtSeen);
429
+ if (vtStates.length !== 1) {
430
+ return { versionState: null,
431
+ failReason: vtStates.length === 0
432
+ ? "no VERSION_(TOUCHED|CLEAN) match in the stdout field"
433
+ : "ambiguous VERSION values in stdout (" + vtStates.length + " distinct)" };
434
+ }
435
+ return { versionState: vtStates[0] === "CLEAN" ? "clean" : "touched", failReason: "" };
436
+ }
437
+
438
+ // versionRetryTrailer — review pass 2, blocker-42 class (2026-09-21).
439
+ // Neutral corrective trailer for the in-place version-check retries: the
440
+ // computed parse-failure reason plus the failed return as a negative
441
+ // example. Byte-identical across the three workflows
442
+ // (pinned by tests/already-merged.test.js).
443
+ function versionRetryTrailer(reason, failedReturn) {
444
+ return "\n\nVERSION-CHECK RETRY: the previous version-check attempt failed (" + reason + "). " +
445
+ "Return ONLY the named field: { \"stdout\": \"<the command's exact stdout>\" }. " +
446
+ "Put the command's stdout in the named field — do not add labels like \"stdout:\" in front of the content. " +
447
+ "Previous attempt detail (do not repeat this shape): " + String(failedReturn).slice(0, 200);
448
+ }
449
+
315
450
  // parseToolSignals - bug 3472bf36. The work agent's TOOL CHECK emits two
316
451
  // exact signal lines: artifact_tools: ok|missing and
317
452
  // shell_transport: ok|unavailable. The workflow reads ONLY these lines.
@@ -737,7 +872,7 @@ let alreadyMergedSha = null;
737
872
  let branchState = null; // "has-work" | "already-merged:<sha>" | "empty-no-work"
738
873
  let buildClaimedNoDiff = false; // Build declared plain `repo_diff: none` (no repo change — runtime-state deliverable, or believed already-merged). Same-process Build report only; there is no cross-process hydration — an empty branch on a fresh dispatch with no task-attributed merge fails mechanically.
739
874
  let versionTouched = false; // npm: branch changed package.json's `version` (mechanical git fact, blocker-34 follow-up)
740
- let branchStateErr = ""; // classifier failure detail (fail-closed grounds)
875
+ let branchStateErr = ""; // classifier failure detail (retry trailer + park note grounds)
741
876
  // Deterministic publish target — computed by the workflow (registry base +
742
877
  // bumpVersion), never by the Publish agent.
743
878
  let publishTarget = null; // { base, scope, target }
@@ -1287,43 +1422,87 @@ while (i < STEPS.length) {
1287
1422
  // (classify-branch in the lifecycle script): has-work |
1288
1423
  // already-merged:<sha> | empty-no-work. Attribution is identity-first
1289
1424
  // from git, then the task's own durable merge records — there is no
1290
- // agent-authored declared-sha input and no cross-process hydration
1291
- // ferry (the re-entry case it served is covered by the durable record
1292
- // → classifier directly). An unparseable result fails closed as
1293
- // empty-no-work — an empty branch never passes Review silently, and
1294
- // the bounce to Build gives the next round a chance to classify.
1295
- try {
1296
- var bsResult = await agent(
1425
+ // agent-authored declared-sha input.
1426
+ // Blocker 42 (2026-09-21): the classifier output crosses an agent()
1427
+ // ferry — the old comment's "no cross-process hydration ferry" was a
1428
+ // fib. Machine facts travel in structured fields ({stdout, stderr}
1429
+ // schema) now, never in prose to be "returned verbatim". The schema
1430
+ // is the guard; the prompt is instruction, never load-bearing.
1431
+ // Unparseable is UNKNOWN, never a positive empty-no-work claim (room
1432
+ // #27: a labeled ferry — "stdout: BRANCH_STATE: has-work" — defeated
1433
+ // the ^-anchored parsers, and the empty-no-work fallback burned the
1434
+ // whole shared rework budget on a branch with real work). UNKNOWN
1435
+ // retries the classify call IN PLACE (up to 2, fresh -u1/-u2 keys — a
1436
+ // full Build round cannot fix an instrument failure, and the only
1437
+ // in-process bounce path spends the shared budget unconditionally).
1438
+ // Instrumentation failures NEVER touch totalReworkCount: an instrument
1439
+ // failure is not a build-quality failure. Exhaustion parks honestly
1440
+ // as unclassifiable — "unknown keeps the task alive (bounded)"; the
1441
+ // park on exhaustion is the fail-closed part. The UNKNOWN path never
1442
+ // asserts empty-no-work: no log line or park note presents it as the
1443
+ // classification. The string can still appear inside quoted evidence
1444
+ // (the verbatim failed return travels in the trailer and the note).
1445
+ // INVARIANT: branchState leaves this block holding a known value, or
1446
+ // the step has parked — unknown never reaches any consumer below.
1447
+ // Re-classify on EVERY Review entry: rework rewinds this step
1448
+ // in-process, and the branch changed between rounds. The loop's
1449
+ // null-gate governs only the in-place instrument retries within
1450
+ // this pass — without the reset, a second Review pass would trust
1451
+ // the first pass's stale classification and a real fix commit
1452
+ // would never "become has-work".
1453
+ branchState = null;
1454
+ branchStateErr = "";
1455
+ alreadyMergedSha = null;
1456
+ var classifyFailedReturn = "";
1457
+ for (var classifyAttempt = 0; classifyAttempt <= 2 && branchState === null; classifyAttempt++) {
1458
+ var classifyPrompt =
1297
1459
  "Classify the task branch state. This is a mechanical git check, not a judgment call.\n" +
1298
- "Run in shell and return the stdout verbatim, then the single stderr line starting with `DIAG:` verbatim:\n" +
1299
- LIFECYCLE_ENV + LIFECYCLE + " classify-branch " + taskId,
1300
- { key: "classify-branch" + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""), label: "Classifying branch state (mechanical)" }
1301
- );
1302
- var bsStr = (typeof bsResult === "string") ? bsResult : JSON.stringify(bsResult);
1303
- var bsMatch = /^\s*BRANCH_STATE:\s*(has-work|already-merged:[0-9a-f]{40}|empty-no-work)\s*$/im.exec(bsStr);
1304
- if (bsMatch) {
1305
- branchState = bsMatch[1].toLowerCase();
1306
- } else {
1307
- branchStateErr = "unparseable classifier output: " + bsStr.slice(0, 120);
1308
- }
1309
- // DIAG pin (blocker 34 design v2.1): the merge-record scan is
1310
- // load-bearing with no fallback — the classifier's stderr counter is
1311
- // logged verbatim so silent record loss surfaces in the evidence.
1312
- var bsDiagMatch = /^[ \t]*DIAG:\s*classify-branch\s+records=\d+\s+resolvable=\d+[ \t]*$/im.exec(bsStr);
1313
- if (bsDiagMatch) {
1314
- log(bsDiagMatch[0].trim());
1315
- } else {
1316
- log("classify-branch: no DIAG: record-scan counter returned (scan unverifiable)");
1460
+ "Run in shell: " + LIFECYCLE_ENV + LIFECYCLE + " classify-branch " + taskId + "\n" +
1461
+ "Return the two streams as the two named fields and nothing else: { \"stdout\": \"<the command's exact stdout>\", \"stderr\": \"<the command's exact stderr>\" }." +
1462
+ (classifyAttempt === 0 ? "" : classifyRetryTrailer(branchStateErr, classifyFailedReturn));
1463
+ try {
1464
+ var bsResult = await agent(
1465
+ classifyPrompt,
1466
+ { key: "classify-branch" + (classifyAttempt === 0 ? "" : "-u" + classifyAttempt) + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""),
1467
+ label: "Classifying branch state (mechanical)" + (classifyAttempt === 0 ? "" : " (instrument retry " + classifyAttempt + " of 2)"),
1468
+ schema: { type: "object", properties: { stdout: { type: "string" }, stderr: { type: "string" } }, required: ["stdout", "stderr"] } }
1469
+ );
1470
+ classifyFailedReturn = (bsResult && typeof bsResult === "object" ? JSON.stringify(bsResult) : String(bsResult)).slice(0, 500);
1471
+ var classifyParsed = parseClassifyFerry(bsResult);
1472
+ if (classifyParsed.state !== null) {
1473
+ branchState = classifyParsed.state;
1474
+ branchStateErr = "";
1475
+ // DIAG pin: advisory for has-work/empty-no-work (blocker-34 v2.1
1476
+ // semantics — logged with its source field so silent record loss
1477
+ // surfaces in the evidence); already-merged is gated on the pin
1478
+ // inside parseClassifyFerry.
1479
+ if (classifyParsed.diagField !== null) {
1480
+ log("classify-branch DIAG pin (" + classifyParsed.diagField + " field): " + classifyParsed.diagText);
1481
+ } else {
1482
+ log("classify-branch: no DIAG: record-scan counter returned (scan unverifiable)");
1483
+ }
1484
+ } else {
1485
+ branchStateErr = classifyParsed.failReason;
1486
+ if (classifyAttempt < 2) {
1487
+ log("classify-branch unparseable (" + branchStateErr + ") — retrying in place (attempt " + (classifyAttempt + 1) + " of 2)");
1488
+ }
1489
+ }
1490
+ } catch (bsErr) {
1491
+ classifyFailedReturn = String(bsErr && bsErr.message || bsErr).slice(0, 500);
1492
+ branchStateErr = "classifier call failed: " + String(bsErr && bsErr.message || bsErr).slice(0, 120);
1493
+ if (classifyAttempt < 2) {
1494
+ log("classify-branch instrument failure (" + branchStateErr + ") — retrying in place (attempt " + (classifyAttempt + 1) + " of 2)");
1495
+ }
1317
1496
  }
1318
- } catch (bsErr) {
1319
- branchStateErr = "classifier call failed: " + String(bsErr && bsErr.message || bsErr).slice(0, 120);
1320
1497
  }
1321
- if (!branchState) {
1322
- branchState = "empty-no-work";
1323
- log("Branch-state classification failed (" + branchStateErr + ") — failing closed as empty-no-work");
1324
- } else if (branchState.indexOf("already-merged:") === 0) {
1498
+ if (branchState === null) {
1499
+ // Exhaustion: park honestly. An instrument failure is not a
1500
+ // measurement of emptiness — never "empty-no-work".
1501
+ return await parkTask("Branch state unclassifiable after 2 instrument retries (" + branchStateErr + "; last failure: " + classifyFailedReturn + ") — the classifier instrument failed, not the branch. Human attention needed: inspect the task branch directly to determine its state — no trustworthy branch classification was produced.");
1502
+ }
1503
+ if (branchState.indexOf("already-merged:") === 0) {
1325
1504
  alreadyMergedSha = branchState.slice("already-merged:".length);
1326
- log("Branch state already-merged: " + alreadyMergedSha + " (mechanically verified) — Cass reviews the frozen merge diff");
1505
+ log("Branch state already-merged: " + alreadyMergedSha + " (DIAG pin present — tripwire satisfied) — Cass reviews the frozen merge diff");
1327
1506
  } else {
1328
1507
  log("Branch state: " + branchState);
1329
1508
  }
@@ -1335,23 +1514,55 @@ while (i < STEPS.length) {
1335
1514
  // git fact, not a reviewer judgment. For npm projects the workflow checks
1336
1515
  // it here, before Cass is dispatched — a touched `version` fails Review
1337
1516
  // mechanically (versions are assigned at publish time, never in
1338
- // branches). Fail closed: anything but an explicit VERSION_CLEAN counts
1339
- // as touched.
1517
+ // branches). Review pass 2 (blocker-42 class): this ferry had the full
1518
+ // pre-42 shape — schema-less agent(), line-anchored parser, and an
1519
+ // unparseable fallback asserting a POSITIVE touched claim that spent the
1520
+ // shared rework budget. Same treatment as the classifier:
1521
+ // shape-constrained {stdout} schema, search-and-dedupe parse, UNKNOWN
1522
+ // with in-place retries, honest park. An instrument failure is not a
1523
+ // measurement of touched — never assert touched from unparseable output.
1340
1524
  if (PUBLISH_TYPE === "npm") {
1341
- try {
1342
- var vtResult = await agent(
1525
+ var versionState = null; // "touched" | "clean" | null (null = UNKNOWN)
1526
+ var versionStateErr = "";
1527
+ var versionFailedReturn = "";
1528
+ for (var versionAttempt = 0; versionAttempt <= 2 && versionState === null; versionAttempt++) {
1529
+ var versionPrompt =
1343
1530
  "Check whether the task branch changed package.json's `version` field. This is a mechanical git check, not a judgment call.\n" +
1344
- "Run in shell and return the stdout verbatim:\n" +
1345
- LIFECYCLE_ENV + LIFECYCLE + " version-check " + taskId,
1346
- { key: "version-check" + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""), label: "Checking package.json version (mechanical)" }
1347
- );
1348
- var vtStr = (typeof vtResult === "string") ? vtResult : JSON.stringify(vtResult);
1349
- var vtMatch = /^\s*VERSION_(TOUCHED|CLEAN)\s*$/im.exec(vtStr);
1350
- versionTouched = !(vtMatch && vtMatch[1].toUpperCase() === "CLEAN");
1351
- } catch (vtErr) {
1352
- versionTouched = true;
1353
- log("Version check failed (" + String(vtErr && vtErr.message || vtErr).slice(0, 120) + ") — failing closed as touched");
1531
+ "Run in shell: " + LIFECYCLE_ENV + LIFECYCLE + " version-check " + taskId + "\n" +
1532
+ "Return the command's exact stdout as the single named field and nothing else: { \"stdout\": \"<the command's exact stdout>\" }." +
1533
+ (versionAttempt === 0 ? "" : versionRetryTrailer(versionStateErr, versionFailedReturn));
1534
+ try {
1535
+ var vtResult = await agent(
1536
+ versionPrompt,
1537
+ { key: "version-check" + (versionAttempt === 0 ? "" : "-u" + versionAttempt) + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""),
1538
+ label: "Checking package.json version (mechanical)" + (versionAttempt === 0 ? "" : " (instrument retry " + versionAttempt + " of 2)"),
1539
+ schema: { type: "object", properties: { stdout: { type: "string" } }, required: ["stdout"] } }
1540
+ );
1541
+ versionFailedReturn = (vtResult && typeof vtResult === "object" ? JSON.stringify(vtResult) : String(vtResult)).slice(0, 500);
1542
+ var vtParsed = parseVersionFerry(vtResult);
1543
+ if (vtParsed.versionState !== null) {
1544
+ versionState = vtParsed.versionState;
1545
+ versionStateErr = "";
1546
+ } else {
1547
+ versionStateErr = vtParsed.failReason;
1548
+ if (versionAttempt < 2) {
1549
+ log("version-check unparseable (" + versionStateErr + ") — retrying in place (attempt " + (versionAttempt + 1) + " of 2)");
1550
+ }
1551
+ }
1552
+ } catch (vtErr) {
1553
+ versionFailedReturn = String(vtErr && vtErr.message || vtErr).slice(0, 500);
1554
+ versionStateErr = "version-check call failed: " + String(vtErr && vtErr.message || vtErr).slice(0, 120);
1555
+ if (versionAttempt < 2) {
1556
+ log("version-check instrument failure (" + versionStateErr + ") — retrying in place (attempt " + (versionAttempt + 1) + " of 2)");
1557
+ }
1558
+ }
1354
1559
  }
1560
+ if (versionState === null) {
1561
+ // Exhaustion: park honestly. An instrument failure is not a
1562
+ // measurement of touched — never assert touched.
1563
+ return await parkTask("package.json `version` state unclassifiable after 2 instrument retries (" + versionStateErr + "; last failure: " + versionFailedReturn + ") — the version-check instrument failed, not the branch. Human attention needed: inspect the task branch directly to determine its state — no trustworthy version classification was produced.");
1564
+ }
1565
+ versionTouched = (versionState === "touched");
1355
1566
  log("Review: package.json `version` " + (versionTouched ? "touched by the branch — mechanical FAIL, Cass not dispatched" : "untouched — mechanical check clean"));
1356
1567
  }
1357
1568
  // The empty-branch rule Cass used to adjudicate is gone. What she
@@ -1674,13 +1885,26 @@ while (i < STEPS.length) {
1674
1885
  // closeout — the file list is the complete record of what the task
1675
1886
  // changed. The courier is pure hands: it writes the deterministic
1676
1887
  // script's own file list, never interprets it.
1888
+ // Blocker 40 (2026-09-21): this courier carries the same
1889
+ // {output: string} schema as the sibling diff-computation call.
1890
+ // The command is stdout-silent; schema-less, the runtime's
1891
+ // non-empty-result contract throws on the empty string and the
1892
+ // workflow parks fail-closed for a side effect that landed. Empty
1893
+ // stdout is schema-valid, so the contract no longer fires. "The
1894
+ // schema bypasses the contract" is INFERRED, not observed —
1895
+ // falsification: if a schema-carrying courier still parks on
1896
+ // silent stdout, the platform contract is deeper than the schema
1897
+ // and this is wrong; room evidence decides. (The file on disk is
1898
+ // not read as proof until QA closeout — the QA loader fails
1899
+ // closed to "unknown" attribution when it is absent.)
1677
1900
  var publishDiffFilesPath = crewHome + "/.publish-diffs/" + taskId + ".files.json";
1678
1901
  await agent(
1679
1902
  "Write the publish diff file list.\n" +
1680
- "Run exactly this and return the stdout verbatim:\n" +
1903
+ "Run exactly this and return the stdout verbatim as { \"output\": \"<verbatim stdout>\" } and nothing else. Do not interpret it:\n" +
1681
1904
  "mkdir -p " + crewHome + "/.publish-diffs && cat > \"" + publishDiffFilesPath + "\" <<'DIFFFILES_EOF'\n" +
1682
1905
  JSON.stringify(diffSummary.files || []) + "\nDIFFFILES_EOF\n",
1683
- { key: attemptKey("publish-diff-files-" + taskId, totalReworkCount), label: "Persisting publish diff file list" }
1906
+ { key: attemptKey("publish-diff-files-" + taskId, totalReworkCount), label: "Persisting publish diff file list",
1907
+ schema: { type: "object", properties: { output: { type: "string" } }, required: ["output"] } }
1684
1908
  );
1685
1909
  // Budget counts CHANGED lines (added + removed), not raw unified-diff
1686
1910
  // output lines: context lines and file headers inflated the old
@@ -1947,12 +2171,12 @@ while (i < STEPS.length) {
1947
2171
  "The returned events are filtered to this task. They contain notes and decisions from prior phases.\n\n";
1948
2172
  }
1949
2173
 
1950
- // Work agent returns the runtime's native envelope {"status": "ok",
1951
- // "result": "<prose>"} with no schema. The runtime requires JSON output;
1952
- // the envelope is its own documented shape, so there is nothing for the
1953
- // agent to improvise. The workflow receives the prose report as a plain
1954
- // string. The verdict is still extracted deterministically from the report
1955
- // text by extractVerdict below — never by an agent.
2174
+ // Work agent returns prose on the schema-less courier; the workflow
2175
+ // consumes the return as a plain string (blocker 43, 2026-09-22: the
2176
+ // prompt names no JSON envelope — nothing parses one, and the runtime's
2177
+ // JSON-candidate scan discards brace-shaped prose, which is what the
2178
+ // transport retry guards). The verdict is still extracted deterministically
2179
+ // from the report text by extractVerdict below — never by an agent.
1956
2180
  var workPromptBase =
1957
2181
  TOOL_CHECK_PREAMBLE +
1958
2182
  "Read the identity file at " + ORCH_PATH + "/identities/" + step.identity + ".md using the read tool, and embody that character fully.\n\n" +
@@ -1965,8 +2189,7 @@ while (i < STEPS.length) {
1965
2189
  "\n## Instructions\n\n" + eventPreamble + instructions + "\n\n" +
1966
2190
  "CONSTRAINT: Do NOT call logevent or upsertagentsession — the workflow handles all phase tracking after your step completes.\n\n" +
1967
2191
  "Stay in character. Do the work thoroughly.\n\n" +
1968
- "Return your work as JSON in exactly this shape: {\"status\": \"ok\", \"result\": \"your report here\"}. " +
1969
- "The result is plain prose describing what you did and found. For verdict steps, end the report with exactly one line: VERDICT: PASS or VERDICT: FAIL.";
2192
+ "Your report is plain prose describing what you did and found. For verdict steps, end the report with exactly one line: VERDICT: PASS or VERDICT: FAIL.";
1970
2193
  var workKeyBase = "work-" + step.name + (totalReworkCount > 0 ? "-r" + totalReworkCount : "");
1971
2194
  // See docs/decisions/qa-reproduce.md#wrong-layer-guard: reproduce must run at the correct layer.
1972
2195
  var reproEvidenceDir = crewHome + "/task-evidence/" + taskId + "/repro";