muse-crew 0.14.6 → 0.14.8
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/API.md +45 -5
- package/docs/decisions/AGENTS.md +2 -0
- package/docs/decisions/publish-path.md +56 -8
- package/docs/decisions/qa-reproduce.md +30 -0
- package/lib/AGENTS.md +6 -5
- package/lib/crew-api.js +403 -7
- package/lib/merge-lock.sh +153 -41
- package/lib/qa-db.js +132 -0
- package/lib/schema.sql +50 -0
- package/lib/serve-artifact.js +46 -2
- package/lib/test-detached-integrate.sh +122 -0
- package/lib/test-merge-lock.sh +30 -1
- package/lib/worktree-lifecycle.sh +284 -34
- package/package.json +1 -1
- package/seed/cron-body-template.md +6 -6
- package/workflows/AGENTS.md +1 -1
- package/workflows/bugfix.js +657 -104
- package/workflows/chore.js +461 -106
- package/workflows/crew-dispatch.js +57 -4
- package/workflows/docs.js +24 -2
- package/workflows/standard.js +662 -109
- package/workflows/upgrade.js +13 -1
package/workflows/standard.js
CHANGED
|
@@ -163,6 +163,62 @@ function extractVerdict(workerText) {
|
|
|
163
163
|
if (uniq.length !== 1) return { ok: false, count: matches.length };
|
|
164
164
|
return { ok: true, passed: last.value === "PASS" };
|
|
165
165
|
}
|
|
166
|
+
// Room #26 blocker 38 (2026-09-21): content-finding attribution. Hazel
|
|
167
|
+
// reports user-visible content observations in a machine-readable
|
|
168
|
+
// CONTENT-FINDINGS block; the workflow classifies each against the task's
|
|
169
|
+
// publish diff — mechanical set membership, never prose judgment. A finding
|
|
170
|
+
// is attributable to the task's change iff its subject file is in the
|
|
171
|
+
// publish diff. The special subject "live-data" (content in the artifact's
|
|
172
|
+
// runtime data stores — decks, cards, rows) is never in a git diff, so it
|
|
173
|
+
// always classifies environment-attributable: the crew has no live-DB write
|
|
174
|
+
// path (blocker 32: QA writes go to a fresh per-run temp DB), so live
|
|
175
|
+
// content is never the task's change. Findings are always recorded — never
|
|
176
|
+
// suppressed for looking audit-y — but environment-attributable findings
|
|
177
|
+
// never park the journey and never spawn an artifact bugfix. The
|
|
178
|
+
// platform-side half (audit sessions writing to production via the
|
|
179
|
+
// shared-concurrent path) is out of crew scope; see
|
|
180
|
+
// docs/decisions/qa-reproduce.md#content-finding-attribution.
|
|
181
|
+
function extractContentFindings(workerText) {
|
|
182
|
+
// The block is the LAST "CONTENT-FINDINGS:" line; the JSON array follows
|
|
183
|
+
// on the same line. Fail closed (ok:false) when missing or malformed —
|
|
184
|
+
// the caller blocks the phase for retry; unknown attribution must never
|
|
185
|
+
// degrade to "no findings" (the prose grounds stay preserved in the
|
|
186
|
+
// session notes).
|
|
187
|
+
var text = workerText || "";
|
|
188
|
+
var regex = /^CONTENT-FINDINGS:\s*(\[.*\])\s*$/gim;
|
|
189
|
+
var matches = [];
|
|
190
|
+
var m;
|
|
191
|
+
while ((m = regex.exec(text)) !== null) {
|
|
192
|
+
matches.push(m[1]);
|
|
193
|
+
}
|
|
194
|
+
if (matches.length === 0) return { ok: false, reason: "no CONTENT-FINDINGS block" };
|
|
195
|
+
var findings;
|
|
196
|
+
try {
|
|
197
|
+
findings = JSON.parse(matches[matches.length - 1]);
|
|
198
|
+
} catch (e) {
|
|
199
|
+
return { ok: false, reason: "CONTENT-FINDINGS block is not valid JSON" };
|
|
200
|
+
}
|
|
201
|
+
if (!Array.isArray(findings)) return { ok: false, reason: "CONTENT-FINDINGS is not an array" };
|
|
202
|
+
for (var i = 0; i < findings.length; i++) {
|
|
203
|
+
var f = findings[i];
|
|
204
|
+
if (!f || typeof f !== "object" || typeof f.subject !== "string" || typeof f.observation !== "string") {
|
|
205
|
+
return { ok: false, reason: "finding " + i + " needs string subject and observation" };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return { ok: true, findings: findings };
|
|
209
|
+
}
|
|
210
|
+
function classifyContentFinding(finding, diffFiles) {
|
|
211
|
+
// diffFiles: the task's publish-diff file set (repo-relative paths).
|
|
212
|
+
// Pure set membership — no prose, no judgment.
|
|
213
|
+
var subject = finding.subject;
|
|
214
|
+
if (subject === "live-data") {
|
|
215
|
+
return { attribution: "environment-attributable", reason: "live-data is never in a git publish diff — the crew has no live-DB write path (blocker 32)" };
|
|
216
|
+
}
|
|
217
|
+
if (diffFiles.indexOf(subject) !== -1) {
|
|
218
|
+
return { attribution: "task-change", reason: "subject is in the task's publish diff" };
|
|
219
|
+
}
|
|
220
|
+
return { attribution: "environment-attributable", reason: "subject is not in the task's publish diff" };
|
|
221
|
+
}
|
|
166
222
|
// See docs/decisions/workflow-core.md#verdict-reask: a report that fails extractVerdict gets bounded re-ask calls.
|
|
167
223
|
function verdictReaskKey(stepName, reworkSuffix, attempt) {
|
|
168
224
|
return "verdict-reask-" + stepName + reworkSuffix + "-a" + attempt;
|
|
@@ -264,6 +320,142 @@ function buildTransportRetryTrailer(stepName, repoPath, taskId, attempt, reason)
|
|
|
264
320
|
"if the " + stepName + " work is already complete, report on what was done rather than duplicating side effects. " +
|
|
265
321
|
"Then return your report as JSON in exactly the shape specified above.";
|
|
266
322
|
}
|
|
323
|
+
// parseClassifyFerry — room #26 blocker 42 (2026-09-21). Shape-constrained
|
|
324
|
+
// ferry parser for the classify-branch agent() call. The schema buys SHAPE,
|
|
325
|
+
// not provenance: the fields are LLM-authored, so the parser stays
|
|
326
|
+
// defensive. Byte-identical across standard.js, bugfix.js, chore.js
|
|
327
|
+
// (pinned by tests/already-merged.test.js). Triplication is structural:
|
|
328
|
+
// each workflow ships as a standalone launch payload (240 KiB budget,
|
|
329
|
+
// individually git-archived) — there is no shared module to hold it.
|
|
330
|
+
// The schema is the guard; the prompt is instruction, never load-bearing.
|
|
331
|
+
// Returns { state, diagField, diagText, failReason }:
|
|
332
|
+
// state: "has-work" | "already-merged:<40-hex>" | "empty-no-work" | null
|
|
333
|
+
// (null = unparseable/ambiguous/channel violation — UNKNOWN)
|
|
334
|
+
// diagField: "stderr" | "stdout" | null (which field sourced the DIAG pin)
|
|
335
|
+
// diagText: the matched DIAG line, or ""
|
|
336
|
+
// failReason: computed reason, for the retry trailer and the park note
|
|
337
|
+
function parseClassifyFerry(bsResult) {
|
|
338
|
+
var bsStdout = (bsResult && typeof bsResult.stdout === "string") ? bsResult.stdout : null;
|
|
339
|
+
var bsStderr = (bsResult && typeof bsResult.stderr === "string") ? bsResult.stderr : null;
|
|
340
|
+
if (bsStdout === null || bsStderr === null) {
|
|
341
|
+
return { state: null, diagField: null, diagText: "",
|
|
342
|
+
failReason: "classifier return fields missing or non-string (stdout and stderr must both be strings)" };
|
|
343
|
+
}
|
|
344
|
+
// State channel: stdout ONLY. A BRANCH_STATE match on stderr is never
|
|
345
|
+
// trusted — workers merge streams constantly, and trusting a channel
|
|
346
|
+
// swap as truth is the wrong shape. Search, never anchor (blocker 11):
|
|
347
|
+
// the ferry labels output ("stdout: BRANCH_STATE: has-work"). Collect
|
|
348
|
+
// ALL matches and dedupe normalized values: exactly one distinct value
|
|
349
|
+
// is truth; zero or two-or-more is UNKNOWN — alternation order never
|
|
350
|
+
// adjudicates.
|
|
351
|
+
var bsRe = /\bBRANCH_STATE:\s*(has-work|already-merged:[0-9a-f]{40}|empty-no-work)(?![\w-])/gi;
|
|
352
|
+
var bsSeen = {};
|
|
353
|
+
var bsM;
|
|
354
|
+
while ((bsM = bsRe.exec(bsStdout)) !== null) {
|
|
355
|
+
bsSeen[bsM[1].toLowerCase()] = true;
|
|
356
|
+
}
|
|
357
|
+
var bsStates = Object.keys(bsSeen);
|
|
358
|
+
if (bsStates.length !== 1) {
|
|
359
|
+
return { state: null, diagField: null, diagText: "",
|
|
360
|
+
failReason: bsStates.length === 0
|
|
361
|
+
? "no BRANCH_STATE match in the stdout field"
|
|
362
|
+
: "ambiguous BRANCH_STATE values in stdout (" + bsStates.length + " distinct)" };
|
|
363
|
+
}
|
|
364
|
+
var bsState = bsStates[0];
|
|
365
|
+
// DIAG pin: search both fields, stderr first. Keep the DIAG: prefix — a
|
|
366
|
+
// prose mention without it must not satisfy the pin.
|
|
367
|
+
var bsDiagRe = /DIAG:\s*classify-branch\s+records=\d+\s+resolvable=\d+/;
|
|
368
|
+
var bsDiagField = bsDiagRe.test(bsStderr) ? "stderr" : (bsDiagRe.test(bsStdout) ? "stdout" : null);
|
|
369
|
+
var bsDiagText = "";
|
|
370
|
+
if (bsDiagField !== null) {
|
|
371
|
+
bsDiagText = bsDiagRe.exec(bsDiagField === "stderr" ? bsStderr : bsStdout)[0];
|
|
372
|
+
}
|
|
373
|
+
if (bsState.indexOf("already-merged:") === 0 && bsDiagField === null) {
|
|
374
|
+
// already-merged's sha flows into Cass's `git diff <sha>^1 <sha>` — a
|
|
375
|
+
// hallucinated-but-well-formed sha is a false-PASS vector. The script
|
|
376
|
+
// emits exactly one DIAG on every path that emits a BRANCH_STATE, so a
|
|
377
|
+
// missing pin means stderr wasn't faithfully ferried: UNKNOWN.
|
|
378
|
+
// Residual risk, named (blocker-42 fib 4): a worker could fabricate
|
|
379
|
+
// BOTH fields wholesale — the pin is a tripwire, not proof of
|
|
380
|
+
// execution. The workflow has no exec channel for a deterministic
|
|
381
|
+
// cross-check; if the platform ever offers one, verify the sha
|
|
382
|
+
// against the task's durable merge records directly.
|
|
383
|
+
return { state: null, diagField: null, diagText: "",
|
|
384
|
+
failReason: "already-merged without the DIAG pin — stderr not faithfully ferried" };
|
|
385
|
+
}
|
|
386
|
+
return { state: bsState, diagField: bsDiagField, diagText: bsDiagText, failReason: "" };
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// classifyRetryTrailer — room #26 blocker 42 (2026-09-21). Corrective (not
|
|
390
|
+
// flat) trailer for the in-place classify retries. The failure mode was
|
|
391
|
+
// systematic labeling, not a coin flip: the trailer carries the COMPUTED
|
|
392
|
+
// parse-failure reason, the failed return truncated as a negative example,
|
|
393
|
+
// and the explicit field mapping — feedback from the actual failure,
|
|
394
|
+
// following the buildTransportRetryTrailer idiom. Bound: 2 retries
|
|
395
|
+
// (unmeasured house convention, matches the shared rework bound of 2 —
|
|
396
|
+
// against room retry data). Byte-identical across the three workflows
|
|
397
|
+
// (pinned by tests/already-merged.test.js).
|
|
398
|
+
function classifyRetryTrailer(reason, failedReturn) {
|
|
399
|
+
// Pass-2 simplification: the reason string already carries the truth
|
|
400
|
+
// (throw vs parse failure), so one neutral sentence replaces the
|
|
401
|
+
// throw/parse branch — the stringly-typed prefix contract between the
|
|
402
|
+
// call site and this function is deleted, not moved. Prompt accuracy,
|
|
403
|
+
// not prompt hardening.
|
|
404
|
+
return "\n\nCLASSIFY RETRY: the previous classifier attempt failed (" + reason + "). " +
|
|
405
|
+
"Return ONLY the two named fields: { \"stdout\": \"<the command's exact stdout>\", \"stderr\": \"<the command's exact stderr>\" }. " +
|
|
406
|
+
"Put each stream in its named field — do not add labels like \"stdout:\" in front of the content. " +
|
|
407
|
+
"Previous attempt detail (do not repeat this shape): " + String(failedReturn).slice(0, 200);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// parseVersionFerry — review pass 2, blocker-42 class (2026-09-21). The npm
|
|
411
|
+
// version-check ferry had the full pre-42 shape: schema-less agent(),
|
|
412
|
+
// line-anchored parser, and an unparseable fallback asserting a POSITIVE
|
|
413
|
+
// touched claim that spent the shared rework budget. Same treatment as
|
|
414
|
+
// parseClassifyFerry: shape-constrained {stdout} schema, search-and-dedupe
|
|
415
|
+
// parse, UNKNOWN on unparseable with in-place retries, honest park.
|
|
416
|
+
// Byte-identical across standard.js, bugfix.js, chore.js
|
|
417
|
+
// (pinned by tests/already-merged.test.js).
|
|
418
|
+
// Returns { versionState, failReason }:
|
|
419
|
+
// versionState: "touched" | "clean" | null (null = UNKNOWN)
|
|
420
|
+
// failReason: computed reason, for the retry trailer and the park note
|
|
421
|
+
function parseVersionFerry(vtResult) {
|
|
422
|
+
var vtStdout = (vtResult && typeof vtResult.stdout === "string") ? vtResult.stdout : null;
|
|
423
|
+
if (vtStdout === null) {
|
|
424
|
+
return { versionState: null,
|
|
425
|
+
failReason: "version-check return field missing or non-string (stdout must be a string)" };
|
|
426
|
+
}
|
|
427
|
+
// Search, never anchor (blocker 11): the ferry labels output
|
|
428
|
+
// ("stdout: VERSION_CLEAN"). Collect ALL matches and dedupe normalized
|
|
429
|
+
// values: exactly one distinct value is truth; zero or two-or-more is
|
|
430
|
+
// UNKNOWN — alternation order never adjudicates.
|
|
431
|
+
var vtRe = /\bVERSION_(TOUCHED|CLEAN)(?![\w-])/gi;
|
|
432
|
+
var vtSeen = {};
|
|
433
|
+
var vtM;
|
|
434
|
+
while ((vtM = vtRe.exec(vtStdout)) !== null) {
|
|
435
|
+
vtSeen[vtM[1].toUpperCase()] = true;
|
|
436
|
+
}
|
|
437
|
+
var vtStates = Object.keys(vtSeen);
|
|
438
|
+
if (vtStates.length !== 1) {
|
|
439
|
+
return { versionState: null,
|
|
440
|
+
failReason: vtStates.length === 0
|
|
441
|
+
? "no VERSION_(TOUCHED|CLEAN) match in the stdout field"
|
|
442
|
+
: "ambiguous VERSION values in stdout (" + vtStates.length + " distinct)" };
|
|
443
|
+
}
|
|
444
|
+
return { versionState: vtStates[0] === "CLEAN" ? "clean" : "touched", failReason: "" };
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// versionRetryTrailer — review pass 2, blocker-42 class (2026-09-21).
|
|
448
|
+
// Neutral corrective trailer for the in-place version-check retries: the
|
|
449
|
+
// computed parse-failure reason plus the failed return as a negative
|
|
450
|
+
// example. Byte-identical across the three workflows
|
|
451
|
+
// (pinned by tests/already-merged.test.js).
|
|
452
|
+
function versionRetryTrailer(reason, failedReturn) {
|
|
453
|
+
return "\n\nVERSION-CHECK RETRY: the previous version-check attempt failed (" + reason + "). " +
|
|
454
|
+
"Return ONLY the named field: { \"stdout\": \"<the command's exact stdout>\" }. " +
|
|
455
|
+
"Put the command's stdout in the named field — do not add labels like \"stdout:\" in front of the content. " +
|
|
456
|
+
"Previous attempt detail (do not repeat this shape): " + String(failedReturn).slice(0, 200);
|
|
457
|
+
}
|
|
458
|
+
|
|
267
459
|
// parseToolSignals - bug 3472bf36. The work agent's TOOL CHECK emits two
|
|
268
460
|
// exact signal lines: artifact_tools: ok|missing and
|
|
269
461
|
// shell_transport: ok|unavailable. The workflow reads ONLY these lines.
|
|
@@ -466,13 +658,6 @@ function extractMarkerLines(workerText) {
|
|
|
466
658
|
return markers.join("\n");
|
|
467
659
|
}
|
|
468
660
|
|
|
469
|
-
// See docs/decisions/publish-path.md#already-merged-idem2: idempotency for already-merged tasks.
|
|
470
|
-
function extractAlreadyMerged(workerText) {
|
|
471
|
-
var m = /repo_diff:\s*none\s*\(already-merged:\s*([0-9a-f]{7,40})(?=[\s)]|$)/i.exec(workerText || "");
|
|
472
|
-
return m ? { sha: m[1].toLowerCase() } : { sha: null };
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
476
661
|
// See docs/decisions/qa-reproduce.md#worktree-confinement: the Build agent must declare its worktree.
|
|
477
662
|
function extractWorktree(workerText) {
|
|
478
663
|
var lines = (workerText || "").split("\n");
|
|
@@ -630,12 +815,24 @@ let mapGateBounceCount = 0;
|
|
|
630
815
|
// rationalized a skip against explicit instruction text — text alone did not
|
|
631
816
|
// hold, so the decision now lives in workflow code, not agent judgment.
|
|
632
817
|
let releaseDecision = null; // { release: "yes"|"no", version_bump: "patch"|"minor"|"major"|null }
|
|
633
|
-
// Already-merged
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
//
|
|
637
|
-
//
|
|
818
|
+
// Already-merged attribution (blocker 34, 2026-09-21): the sha of the
|
|
819
|
+
// task-attributed merge when classify-branch reports already-merged.
|
|
820
|
+
// Set ONLY from the classifier's mechanical output — never from agent
|
|
821
|
+
// prose. The agent-authored sha-bearing repo_diff declaration path is
|
|
822
|
+
// deleted; attribution is identity-first from git, then the task's own
|
|
823
|
+
// durable merge records.
|
|
638
824
|
let alreadyMergedSha = null;
|
|
825
|
+
// Room #26 blocker 34 (redesign, 2026-09-21): mechanical branch-state
|
|
826
|
+
// classification at Review entry. Git facts are never adjudicated by a
|
|
827
|
+
// reviewer — the workflow classifies the branch with `classify-branch`
|
|
828
|
+
// (pure git) before Cass is dispatched: "has-work",
|
|
829
|
+
// "already-merged:<sha>", or "empty-no-work". An empty branch with no
|
|
830
|
+
// verified sha and no `repo_diff: none` claim fails mechanically without
|
|
831
|
+
// dispatching Cass; reviewer prose is never parsed for git identity.
|
|
832
|
+
let branchState = null; // "has-work" | "already-merged:<sha>" | "empty-no-work"
|
|
833
|
+
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.
|
|
834
|
+
let versionTouched = false; // npm: branch changed package.json's `version` (mechanical git fact, blocker-34 follow-up)
|
|
835
|
+
let branchStateErr = ""; // classifier failure detail (retry trailer + park note grounds)
|
|
639
836
|
// Deterministic publish target — computed by the workflow (registry base +
|
|
640
837
|
// bumpVersion), never by the Publish agent.
|
|
641
838
|
let publishTarget = null; // { base, scope, target }
|
|
@@ -1104,55 +1301,202 @@ while (i < STEPS.length) {
|
|
|
1104
1301
|
"cd " + WORKTREE_HINT + "\n" +
|
|
1105
1302
|
"git add -A\n" +
|
|
1106
1303
|
"git commit -m \"" + safeTitle + "\"\n\n" +
|
|
1107
|
-
"If the task's deliverable is runtime state (a cron definition, scheduler change, or dashboard/config state created outside the repo) and the repository genuinely needs no change, do NOT fabricate a commit: leave the branch with no commits ahead of the integration target and declare `repo_diff: none` in your report, naming the runtime-state deliverable. If you verified the deliverable is already on the integration target (a prior merge
|
|
1304
|
+
"If the task's deliverable is runtime state (a cron definition, scheduler change, or dashboard/config state created outside the repo) and the repository genuinely needs no change, do NOT fabricate a commit: leave the branch with no commits ahead of the integration target and declare `repo_diff: none` in your report, naming the runtime-state deliverable. If you verified the deliverable is already on the integration target (a prior merge landed it — do NOT re-implement working code), make no commit and declare `repo_diff: none` in your report. The workflow verifies the claim mechanically from git — the task's own merge records, never your declaration, are the proof of delivery. Otherwise commit your changes normally.\n\n" +
|
|
1108
1305
|
(rejectionNotes ? "This is REWORK after rejection. Address these specific issues:\n" + rejectionNotes + "\n\n" : "") +
|
|
1109
1306
|
"Report back in plain prose: what you built and the outcome." +
|
|
1110
1307
|
(PUBLISH_TYPE === "npm" ? " End your report with the release: and version_bump: lines exactly as specified above — keep them on their own lines, lowercase, unrephrased — then a line `worktree: ` followed by the exact working directory path from above (copy it verbatim \u2014 it must match character-for-character), then a final line with exactly: VERDICT: PASS if the build is complete, VERDICT: FAIL if it is not." : " End your report with a line `worktree: ` followed by the exact working directory path from above (copy it verbatim \u2014 it must match character-for-character), then exactly one line: VERDICT: PASS if the build is complete, VERDICT: FAIL if it is not.");
|
|
1111
1308
|
|
|
1112
1309
|
} else if (step.name === "Review") {
|
|
1113
|
-
//
|
|
1114
|
-
|
|
1115
|
-
|
|
1310
|
+
// Room #26 blocker 34 (redesign, 2026-09-21): classify the branch
|
|
1311
|
+
// mechanically BEFORE Cass is dispatched. The classifier is pure git
|
|
1312
|
+
// (classify-branch in the lifecycle script): has-work |
|
|
1313
|
+
// already-merged:<sha> | empty-no-work. Attribution is identity-first
|
|
1314
|
+
// from git, then the task's own durable merge records — there is no
|
|
1315
|
+
// agent-authored declared-sha input.
|
|
1316
|
+
// Blocker 42 (2026-09-21): the classifier output crosses an agent()
|
|
1317
|
+
// ferry — the old comment's "no cross-process hydration ferry" was a
|
|
1318
|
+
// fib. Machine facts travel in structured fields ({stdout, stderr}
|
|
1319
|
+
// schema) now, never in prose to be "returned verbatim". The schema
|
|
1320
|
+
// is the guard; the prompt is instruction, never load-bearing.
|
|
1321
|
+
// Unparseable is UNKNOWN, never a positive empty-no-work claim (room
|
|
1322
|
+
// #27: a labeled ferry — "stdout: BRANCH_STATE: has-work" — defeated
|
|
1323
|
+
// the ^-anchored parsers, and the empty-no-work fallback burned the
|
|
1324
|
+
// whole shared rework budget on a branch with real work). UNKNOWN
|
|
1325
|
+
// retries the classify call IN PLACE (up to 2, fresh -u1/-u2 keys — a
|
|
1326
|
+
// full Build round cannot fix an instrument failure, and the only
|
|
1327
|
+
// in-process bounce path spends the shared budget unconditionally).
|
|
1328
|
+
// Instrumentation failures NEVER touch totalReworkCount: an instrument
|
|
1329
|
+
// failure is not a build-quality failure. Exhaustion parks honestly
|
|
1330
|
+
// as unclassifiable — "unknown keeps the task alive (bounded)"; the
|
|
1331
|
+
// park on exhaustion is the fail-closed part. The UNKNOWN path never
|
|
1332
|
+
// asserts empty-no-work: no log line or park note presents it as the
|
|
1333
|
+
// classification. The string can still appear inside quoted evidence
|
|
1334
|
+
// (the verbatim failed return travels in the trailer and the note).
|
|
1335
|
+
// INVARIANT: branchState leaves this block holding a known value, or
|
|
1336
|
+
// the step has parked — unknown never reaches any consumer below.
|
|
1337
|
+
// Re-classify on EVERY Review entry: rework rewinds this step
|
|
1338
|
+
// in-process, and the branch changed between rounds. The loop's
|
|
1339
|
+
// null-gate governs only the in-place instrument retries within
|
|
1340
|
+
// this pass — without the reset, a second Review pass would trust
|
|
1341
|
+
// the first pass's stale classification and a real fix commit
|
|
1342
|
+
// would never "become has-work".
|
|
1343
|
+
branchState = null;
|
|
1344
|
+
branchStateErr = "";
|
|
1345
|
+
alreadyMergedSha = null;
|
|
1346
|
+
var classifyFailedReturn = "";
|
|
1347
|
+
for (var classifyAttempt = 0; classifyAttempt <= 2 && branchState === null; classifyAttempt++) {
|
|
1348
|
+
var classifyPrompt =
|
|
1349
|
+
"Classify the task branch state. This is a mechanical git check, not a judgment call.\n" +
|
|
1350
|
+
"Run in shell: " + LIFECYCLE_ENV + LIFECYCLE + " classify-branch " + taskId + "\n" +
|
|
1351
|
+
"Return the two streams as the two named fields and nothing else: { \"stdout\": \"<the command's exact stdout>\", \"stderr\": \"<the command's exact stderr>\" }." +
|
|
1352
|
+
(classifyAttempt === 0 ? "" : classifyRetryTrailer(branchStateErr, classifyFailedReturn));
|
|
1116
1353
|
try {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
"
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
"NOTES:\n<the session's notes field, verbatim>",
|
|
1123
|
-
{ key: "hydrate-already-merged" + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""), label: "Hydrating already-merged verification" }
|
|
1354
|
+
var bsResult = await agent(
|
|
1355
|
+
classifyPrompt,
|
|
1356
|
+
{ key: "classify-branch" + (classifyAttempt === 0 ? "" : "-u" + classifyAttempt) + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""),
|
|
1357
|
+
label: "Classifying branch state (mechanical)" + (classifyAttempt === 0 ? "" : " (instrument retry " + classifyAttempt + " of 2)"),
|
|
1358
|
+
schema: { type: "object", properties: { stdout: { type: "string" }, stderr: { type: "string" } }, required: ["stdout", "stderr"] } }
|
|
1124
1359
|
);
|
|
1125
|
-
|
|
1126
|
-
|
|
1360
|
+
classifyFailedReturn = (bsResult && typeof bsResult === "object" ? JSON.stringify(bsResult) : String(bsResult)).slice(0, 500);
|
|
1361
|
+
var classifyParsed = parseClassifyFerry(bsResult);
|
|
1362
|
+
if (classifyParsed.state !== null) {
|
|
1363
|
+
branchState = classifyParsed.state;
|
|
1364
|
+
branchStateErr = "";
|
|
1365
|
+
// DIAG pin: advisory for has-work/empty-no-work (blocker-34 v2.1
|
|
1366
|
+
// semantics — logged with its source field so silent record loss
|
|
1367
|
+
// surfaces in the evidence); already-merged is gated on the pin
|
|
1368
|
+
// inside parseClassifyFerry.
|
|
1369
|
+
if (classifyParsed.diagField !== null) {
|
|
1370
|
+
log("classify-branch DIAG pin (" + classifyParsed.diagField + " field): " + classifyParsed.diagText);
|
|
1371
|
+
} else {
|
|
1372
|
+
log("classify-branch: no DIAG: record-scan counter returned (scan unverifiable)");
|
|
1373
|
+
}
|
|
1374
|
+
} else {
|
|
1375
|
+
branchStateErr = classifyParsed.failReason;
|
|
1376
|
+
if (classifyAttempt < 2) {
|
|
1377
|
+
log("classify-branch unparseable (" + branchStateErr + ") — retrying in place (attempt " + (classifyAttempt + 1) + " of 2)");
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
} catch (bsErr) {
|
|
1381
|
+
classifyFailedReturn = String(bsErr && bsErr.message || bsErr).slice(0, 500);
|
|
1382
|
+
branchStateErr = "classifier call failed: " + String(bsErr && bsErr.message || bsErr).slice(0, 120);
|
|
1383
|
+
if (classifyAttempt < 2) {
|
|
1384
|
+
log("classify-branch instrument failure (" + branchStateErr + ") — retrying in place (attempt " + (classifyAttempt + 1) + " of 2)");
|
|
1385
|
+
}
|
|
1127
1386
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1387
|
+
}
|
|
1388
|
+
if (branchState === null) {
|
|
1389
|
+
// Exhaustion: park honestly. An instrument failure is not a
|
|
1390
|
+
// measurement of emptiness — never "empty-no-work".
|
|
1391
|
+
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.");
|
|
1392
|
+
}
|
|
1393
|
+
if (branchState.indexOf("already-merged:") === 0) {
|
|
1394
|
+
alreadyMergedSha = branchState.slice("already-merged:".length);
|
|
1395
|
+
log("Branch state already-merged: " + alreadyMergedSha + " (DIAG pin present — tripwire satisfied) — Cass reviews the frozen merge diff");
|
|
1396
|
+
} else {
|
|
1397
|
+
log("Branch state: " + branchState);
|
|
1398
|
+
}
|
|
1399
|
+
// buildClaimedNoDiff was set at the Build gate from the full Build
|
|
1400
|
+
// report (same process only). Only an empty branch WITH this claim
|
|
1401
|
+
// goes to Cass for a plausibility judgment; without it, empty-no-work
|
|
1402
|
+
// fails mechanically and Cass is never dispatched.
|
|
1403
|
+
// Blocker-34 follow-up: the package.json `version` check is a mechanical
|
|
1404
|
+
// git fact, not a reviewer judgment. For npm projects the workflow checks
|
|
1405
|
+
// it here, before Cass is dispatched — a touched `version` fails Review
|
|
1406
|
+
// mechanically (versions are assigned at publish time, never in
|
|
1407
|
+
// branches). Review pass 2 (blocker-42 class): this ferry had the full
|
|
1408
|
+
// pre-42 shape — schema-less agent(), line-anchored parser, and an
|
|
1409
|
+
// unparseable fallback asserting a POSITIVE touched claim that spent the
|
|
1410
|
+
// shared rework budget. Same treatment as the classifier:
|
|
1411
|
+
// shape-constrained {stdout} schema, search-and-dedupe parse, UNKNOWN
|
|
1412
|
+
// with in-place retries, honest park. An instrument failure is not a
|
|
1413
|
+
// measurement of touched — never assert touched from unparseable output.
|
|
1414
|
+
if (PUBLISH_TYPE === "npm") {
|
|
1415
|
+
var versionState = null; // "touched" | "clean" | null (null = UNKNOWN)
|
|
1416
|
+
var versionStateErr = "";
|
|
1417
|
+
var versionFailedReturn = "";
|
|
1418
|
+
for (var versionAttempt = 0; versionAttempt <= 2 && versionState === null; versionAttempt++) {
|
|
1419
|
+
var versionPrompt =
|
|
1420
|
+
"Check whether the task branch changed package.json's `version` field. This is a mechanical git check, not a judgment call.\n" +
|
|
1421
|
+
"Run in shell: " + LIFECYCLE_ENV + LIFECYCLE + " version-check " + taskId + "\n" +
|
|
1422
|
+
"Return the command's exact stdout as the single named field and nothing else: { \"stdout\": \"<the command's exact stdout>\" }." +
|
|
1423
|
+
(versionAttempt === 0 ? "" : versionRetryTrailer(versionStateErr, versionFailedReturn));
|
|
1424
|
+
try {
|
|
1425
|
+
var vtResult = await agent(
|
|
1426
|
+
versionPrompt,
|
|
1427
|
+
{ key: "version-check" + (versionAttempt === 0 ? "" : "-u" + versionAttempt) + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""),
|
|
1428
|
+
label: "Checking package.json version (mechanical)" + (versionAttempt === 0 ? "" : " (instrument retry " + versionAttempt + " of 2)"),
|
|
1429
|
+
schema: { type: "object", properties: { stdout: { type: "string" } }, required: ["stdout"] } }
|
|
1430
|
+
);
|
|
1431
|
+
versionFailedReturn = (vtResult && typeof vtResult === "object" ? JSON.stringify(vtResult) : String(vtResult)).slice(0, 500);
|
|
1432
|
+
var vtParsed = parseVersionFerry(vtResult);
|
|
1433
|
+
if (vtParsed.versionState !== null) {
|
|
1434
|
+
versionState = vtParsed.versionState;
|
|
1435
|
+
versionStateErr = "";
|
|
1436
|
+
} else {
|
|
1437
|
+
versionStateErr = vtParsed.failReason;
|
|
1438
|
+
if (versionAttempt < 2) {
|
|
1439
|
+
log("version-check unparseable (" + versionStateErr + ") — retrying in place (attempt " + (versionAttempt + 1) + " of 2)");
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
} catch (vtErr) {
|
|
1443
|
+
versionFailedReturn = String(vtErr && vtErr.message || vtErr).slice(0, 500);
|
|
1444
|
+
versionStateErr = "version-check call failed: " + String(vtErr && vtErr.message || vtErr).slice(0, 120);
|
|
1445
|
+
if (versionAttempt < 2) {
|
|
1446
|
+
log("version-check instrument failure (" + versionStateErr + ") — retrying in place (attempt " + (versionAttempt + 1) + " of 2)");
|
|
1447
|
+
}
|
|
1138
1448
|
}
|
|
1139
1449
|
}
|
|
1450
|
+
if (versionState === null) {
|
|
1451
|
+
// Exhaustion: park honestly. An instrument failure is not a
|
|
1452
|
+
// measurement of touched — never assert touched.
|
|
1453
|
+
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.");
|
|
1454
|
+
}
|
|
1455
|
+
versionTouched = (versionState === "touched");
|
|
1456
|
+
log("Review: package.json `version` " + (versionTouched ? "touched by the branch — mechanical FAIL, Cass not dispatched" : "untouched — mechanical check clean"));
|
|
1457
|
+
}
|
|
1458
|
+
// The empty-branch rule Cass used to adjudicate is gone. What she
|
|
1459
|
+
// examines and what rule she applies depend on the classified state —
|
|
1460
|
+
// never on her own judgment of git identity.
|
|
1461
|
+
var reviewChangeExam, reviewBranchRule;
|
|
1462
|
+
if (branchState === "has-work") {
|
|
1463
|
+
reviewChangeExam =
|
|
1464
|
+
"Examine the code changes by running:\n" +
|
|
1465
|
+
LIFECYCLE_ENV + LIFECYCLE + " inspect " + taskId + "\n\n" +
|
|
1466
|
+
"The inspect output is authoritative: it prints the task branch's actual tip commit (TIP) and every commit ahead of the integration target (inspect prints the target name). Base your review ONLY on this output — do NOT run git log yourself to pick commits, and do NOT discuss commit hashes from any other source (they may come from stale rework rounds or a different repo).\n\n";
|
|
1467
|
+
reviewBranchRule =
|
|
1468
|
+
"MECHANICAL FACT (computed by the workflow from git — never by a reviewer): branch state = has-work. The branch has commits ahead of the integration target. Review their content; branch emptiness is settled and is not yours to judge.\n";
|
|
1469
|
+
} else if (branchState.indexOf("already-merged:") === 0) {
|
|
1470
|
+
reviewChangeExam =
|
|
1471
|
+
"The change under review is the frozen merge " + alreadyMergedSha + " — it is already on the integration target (see MECHANICAL FACT below). Examine it by running:\n" +
|
|
1472
|
+
"cd " + REPO_PATH + " && git diff " + alreadyMergedSha + "^1 " + alreadyMergedSha + "\n\n" +
|
|
1473
|
+
"That first-parent diff is the frozen, attributable change. Base your review ONLY on this diff — do NOT run git log to pick commits, and do NOT discuss commit hashes from any other source (they may come from stale rework rounds or a different repo).\n\n";
|
|
1474
|
+
reviewBranchRule =
|
|
1475
|
+
"MECHANICAL FACT (computed by the workflow from git — never by a reviewer): branch state = already-merged:" + alreadyMergedSha + ". The deliverable landed on the integration target via this task's own prior merge " + alreadyMergedSha + " (verified ancestor of the integration target). The branch is empty by design — emptiness is settled fact, not a finding.\n";
|
|
1476
|
+
} else if (buildClaimedNoDiff) {
|
|
1477
|
+
reviewChangeExam =
|
|
1478
|
+
"The branch has no commits ahead of the integration target (see MECHANICAL FACT below) — there is no diff to examine. Judge the Build report's `repo_diff: none` claim on its plausibility.\n\n";
|
|
1479
|
+
reviewBranchRule =
|
|
1480
|
+
"MECHANICAL FACT (computed by the workflow from git — never by a reviewer): the branch has no commits ahead of the integration target and no task-attributed merge on the target was verified; the Build report declares `repo_diff: none` (no repo change). Approve ONLY if the task's deliverable is plausibly runtime state (e.g. a cron definition, scheduler change, or dashboard/config state created outside the repo). Otherwise report 'no commits ahead of the integration target and no plausible runtime-state deliverable — the builder likely forgot to commit', then end your report with exactly this line: VERDICT: FAIL.\n";
|
|
1481
|
+
} else {
|
|
1482
|
+
// Mechanical FAIL — Cass is never dispatched (see the dispatch gate
|
|
1483
|
+
// below). Instructions are unused; keep the shape.
|
|
1484
|
+
reviewChangeExam = "";
|
|
1485
|
+
reviewBranchRule = "";
|
|
1140
1486
|
}
|
|
1141
1487
|
instructions = "Review independently and cold. You have NOT seen any reasoning from the builder.\nDo NOT access the task dashboard, event log, or any comments. Your review is based solely on the spec and the code.\n\n" +
|
|
1142
1488
|
(mapperSpec ? "MAPPER'S SPEC (the builder was asked to implement exactly this):\n" + mapperSpec + "\n\n" : "Read the spec at exactly " + SPEC_PATH + " (fall back to the task description if the file is absent).\n\n") +
|
|
1143
|
-
|
|
1144
|
-
LIFECYCLE_ENV + LIFECYCLE + " inspect " + taskId + "\n\n" +
|
|
1145
|
-
"The inspect output is authoritative: it prints the task branch's actual tip commit (TIP) and every commit ahead of the integration target (inspect prints the target name). Base your review ONLY on this output — do NOT run git log yourself to pick commits, and do NOT discuss commit hashes from any other source (they may come from stale rework rounds or a different repo).\n\n" +
|
|
1489
|
+
reviewChangeExam +
|
|
1146
1490
|
"You can also read specific files in the worktree at:\n" +
|
|
1147
1491
|
WORKTREE_HINT + "/\n\n" +
|
|
1148
1492
|
"Check quality, correctness, and spec compliance.\n" +
|
|
1149
1493
|
(SURFACE_TERMINAL ? "TERMINAL UX REVIEW: judge the CLI surface against " + UX_DOCTRINE_PATH + " — help accuracy, error quality, exit codes, output clarity. Reject when the bar is not met.\n" : "") +
|
|
1150
1494
|
(SURFACE_ARTIFACT ? "ARTIFACT UX REVIEW: judge the rendered surface against " + UX_DOCTRINE_PATH + " — alignment, spacing, hierarchy, composition, balance, finish, correctness. Reject when the bar is not met.\n" : "") +
|
|
1151
1495
|
"Check that public-affecting changes have matching public doc updates (API.md or the published API contract). If the docs are missing or inaccurate, report what is stale, then end your report with exactly this line: VERDICT: FAIL.\n" +
|
|
1152
|
-
|
|
1153
|
-
(PUBLISH_TYPE === "npm" ? "PACKAGE VERSION: this project publishes to the npm registry, and versions are assigned at publish time — never in branches
|
|
1154
|
-
"
|
|
1155
|
-
"
|
|
1496
|
+
reviewBranchRule +
|
|
1497
|
+
(PUBLISH_TYPE === "npm" ? "PACKAGE VERSION: this project publishes to the npm registry, and versions are assigned at publish time — never in branches.\n" +
|
|
1498
|
+
"MECHANICAL FACT (computed by the workflow from git — never by a reviewer): the task branch did not change package.json's `version` field. A branch that touches `version` fails Review mechanically before any reviewer is dispatched, so this is settled — do not re-check it.\n" +
|
|
1499
|
+
"The accepted Build report declares: " + releaseDecisionText() + ". " +
|
|
1156
1500
|
(releaseDecision
|
|
1157
1501
|
? "Validate this decision against the change: release must be 'yes' when the change is consumer-observable and 'no' when internal-only; the version_bump scope must fit the change (patch for fixes, minor for new behavior, major for breaking changes). If the decision is wrong or mis-scoped, report your notes, then end with exactly this line: VERDICT: FAIL."
|
|
1158
1502
|
: "The decision is missing or malformed — report 'Build report must end with release: yes|no and (when release is yes) version_bump: patch|minor|major lines', then end with exactly this line: VERDICT: FAIL.") + "\n" : "") +
|
|
@@ -1166,8 +1510,9 @@ while (i < STEPS.length) {
|
|
|
1166
1510
|
"Then run: "+ LIFECYCLE_ENV + "WORKFLOW_RUN_ID=" + lockHolder + " CREW_STAGED_BASE=<provenance.source_commit, empty when null> integrate " + taskId + " \"merge: " + safeTitle + "\\\"\\n" +
|
|
1167
1511
|
"The script merges, reconciles, records, and pushes under the merge lock. Informational only: RECONCILED, NO_REMOTE, NO_REMOTE_RECONCILE. Read the output:\n" +
|
|
1168
1512
|
"- STAGED_BASE_MISMATCH: the line left the staged base (stray checkout). VERDICT: FAIL.\n" +
|
|
1169
|
-
"- MERGED_EMPTY — check FIRST (it contains the word MERGED): either a runtime-state deliverable or
|
|
1513
|
+
"- MERGED_EMPTY — check FIRST (it contains the word MERGED): either a runtime-state deliverable or a task-attributed merge the workflow verified from the task's own merge records. No lock taken, no new commit. Report 'merged empty: no repo changes'. VERDICT: PASS.\n" +
|
|
1170
1514
|
"- MERGED: the merge landed; the script pushed inline. Read the push line: PUSHED — report the hash (detached prints PUSHED: origin/main (refspec HEAD:main)), VERDICT: PASS; NO_REMOTE_PUSH — no remote configured, VERDICT: PASS; ERROR after MERGED — a retry recovers the push; report it, VERDICT: FAIL.\n" +
|
|
1515
|
+
"- STALE_MERGE: the recorded merge no longer matches the task branch (rework moved it after the merge) — the script refused to push stale state. Report the STALE_MERGE line, VERDICT: FAIL.\n" +
|
|
1171
1516
|
"- LOCK_HELD: 10-minute backoff exhausted. VERDICT: FAIL.\n" +
|
|
1172
1517
|
"- CONFLICT: the plain merge failed — aborted, the target is clean, and your task still holds the merge lock. Do NOT fail yet. Resolve it:\n" +
|
|
1173
1518
|
"RESOLUTION:\n" +
|
|
@@ -1217,8 +1562,9 @@ while (i < STEPS.length) {
|
|
|
1217
1562
|
// See docs/decisions/publish-path.md#deterministic-artifact-publish: the work agent never publishes; the parent runs the deterministic publish script.
|
|
1218
1563
|
// Blocker 22 (one-party publish, room #24): verified re-entry guard.
|
|
1219
1564
|
// The workflow parks at publish intent; the tick worker issues
|
|
1220
|
-
// artifact_edit
|
|
1221
|
-
//
|
|
1565
|
+
// artifact_edit; the ack scan stamps provenance on exact per-attempt
|
|
1566
|
+
// version acknowledgement (sole positive completion criterion; no
|
|
1567
|
+
// read-back — docs/publish-verification.md) and re-queues. The dispatcher resumes this task at the Publish step
|
|
1222
1568
|
// (the parked session's own step — the failed→retry path). If the
|
|
1223
1569
|
// stamped provenance names THIS task and its source_commit is the
|
|
1224
1570
|
// repo's current HEAD, the merge commit was already published and
|
|
@@ -1274,8 +1620,10 @@ while (i < STEPS.length) {
|
|
|
1274
1620
|
}
|
|
1275
1621
|
// See docs/decisions/publish-path.md#step1-builder-source: the builder's source tree is NOT the crew's repo; verify report before stamping.
|
|
1276
1622
|
// (2026-09-20, one-party worker-owned publish) A verified re-entry
|
|
1277
|
-
// skips the whole issuance tail: the edit already went out,
|
|
1278
|
-
//
|
|
1623
|
+
// skips the whole issuance tail: the edit already went out, the
|
|
1624
|
+
// ack scan saw the exact per-attempt version acknowledged (sole
|
|
1625
|
+
// positive completion criterion; no read-back) and it was stamped.
|
|
1626
|
+
// The empty-diff
|
|
1279
1627
|
// park must not fire on this branch.
|
|
1280
1628
|
if (!publishSkippedNoLock && !publishAlreadyVerified) {
|
|
1281
1629
|
// The trigger key of the attempt that last ran, for the publish ledger.
|
|
@@ -1421,6 +1769,33 @@ while (i < STEPS.length) {
|
|
|
1421
1769
|
if (diffSummary.has_rename) {
|
|
1422
1770
|
return await parkTask("Publish diff contains a rename — the diff transport cannot carry renames. Human attention needed.");
|
|
1423
1771
|
}
|
|
1772
|
+
// Room #26 blocker 38 (2026-09-21): persist the publish-diff file
|
|
1773
|
+
// set for QA content-finding attribution. The workflow classifies
|
|
1774
|
+
// Hazel's content findings against this set mechanically at QA
|
|
1775
|
+
// closeout — the file list is the complete record of what the task
|
|
1776
|
+
// changed. The courier is pure hands: it writes the deterministic
|
|
1777
|
+
// script's own file list, never interprets it.
|
|
1778
|
+
// Blocker 40 (2026-09-21): this courier carries the same
|
|
1779
|
+
// {output: string} schema as the sibling diff-computation call.
|
|
1780
|
+
// The command is stdout-silent; schema-less, the runtime's
|
|
1781
|
+
// non-empty-result contract throws on the empty string and the
|
|
1782
|
+
// workflow parks fail-closed for a side effect that landed. Empty
|
|
1783
|
+
// stdout is schema-valid, so the contract no longer fires. "The
|
|
1784
|
+
// schema bypasses the contract" is INFERRED, not observed —
|
|
1785
|
+
// falsification: if a schema-carrying courier still parks on
|
|
1786
|
+
// silent stdout, the platform contract is deeper than the schema
|
|
1787
|
+
// and this is wrong; room evidence decides. (The file on disk is
|
|
1788
|
+
// not read as proof until QA closeout — the QA loader fails
|
|
1789
|
+
// closed to "unknown" attribution when it is absent.)
|
|
1790
|
+
var publishDiffFilesPath = crewHome + "/.publish-diffs/" + taskId + ".files.json";
|
|
1791
|
+
await agent(
|
|
1792
|
+
"Write the publish diff file list.\n" +
|
|
1793
|
+
"Run exactly this and return the stdout verbatim as { \"output\": \"<verbatim stdout>\" } and nothing else. Do not interpret it:\n" +
|
|
1794
|
+
"mkdir -p " + crewHome + "/.publish-diffs && cat > \"" + publishDiffFilesPath + "\" <<'DIFFFILES_EOF'\n" +
|
|
1795
|
+
JSON.stringify(diffSummary.files || []) + "\nDIFFFILES_EOF\n",
|
|
1796
|
+
{ key: attemptKey("publish-diff-files-" + taskId, totalReworkCount), label: "Persisting publish diff file list",
|
|
1797
|
+
schema: { type: "object", properties: { output: { type: "string" } }, required: ["output"] } }
|
|
1798
|
+
);
|
|
1424
1799
|
// Budget counts CHANGED lines (added + removed), not raw unified-diff
|
|
1425
1800
|
// output lines: context lines and file headers inflated the old
|
|
1426
1801
|
// split("\n").length count ~2x, parking a 95-line change against a
|
|
@@ -1530,11 +1905,13 @@ while (i < STEPS.length) {
|
|
|
1530
1905
|
// mechanical outcome above. It must not rebuild or re-stamp: a second
|
|
1531
1906
|
// artifact_edit would trigger a duplicate build.
|
|
1532
1907
|
// (2026-09-20, one-party worker-owned publish) On a verified re-entry
|
|
1533
|
-
// the publish was issued
|
|
1534
|
-
//
|
|
1908
|
+
// the publish was issued, the ack scan observed the artifact's exact
|
|
1909
|
+
// version acknowledgement, and provenance was stamped — already
|
|
1910
|
+
// verified, nothing to issue. The work agent reports that,
|
|
1911
|
+
// VERDICT: PASS.
|
|
1535
1912
|
if (publishAlreadyVerified) {
|
|
1536
1913
|
instructions = "Publish was already completed and verified for this task — do NOT call artifact_edit, artifact_status, setprovenance, or post-deploy yourself; doing so would disturb the finalized state.\n\n" +
|
|
1537
|
-
"
|
|
1914
|
+
"Provenance stamps this task's merge commit as published (docs/publish-verification.md): the tick worker issued the edit, the ack scan observed the artifact's exact version acknowledgement — the sole positive completion criterion — and the publish was stamped. Already verified, nothing to issue and nothing to re-verify.\n\n" +
|
|
1538
1915
|
"For the change summary, run: cd " + REPO_PATH + " && git log -1 --stat\n\n" +
|
|
1539
1916
|
"Write plain prose describing what was published, then on its own line: VERDICT: PASS\n" +
|
|
1540
1917
|
"The VERDICT line must be the last line of your report.";
|
|
@@ -1547,10 +1924,10 @@ while (i < STEPS.length) {
|
|
|
1547
1924
|
instructions = "Publish the merged code to the live artifact.\n\n" +
|
|
1548
1925
|
"The publish was performed deterministically by the workflow before your step — do NOT call artifact_edit, artifact_status, setprovenance, or post-deploy yourself; doing so would trigger a duplicate build or disturb the finalized state. You perform no publish actions.\n\n" +
|
|
1549
1926
|
"For the change summary, run: cd " + REPO_PATH + " && git log -1 --stat\n\n" +
|
|
1550
|
-
"Mechanical outcome (the workflow's mechanical steps;
|
|
1927
|
+
"Mechanical outcome (the workflow's mechanical steps; the ack scan's version-acknowledgement check is still pending):\n" +
|
|
1551
1928
|
"- merge lock refreshed: yes\n" +
|
|
1552
1929
|
"- artifact rebuild triggered and completed: yes\n" +
|
|
1553
|
-
"- provenance stamped: NO — not yet, and you must NOT stamp it. The
|
|
1930
|
+
"- provenance stamped: NO — not yet, and you must NOT stamp it. The ack scan stamps it when it observes the artifact's exact on-disk acknowledgement of this attempt's version — version acknowledgement is the sole positive completion criterion (docs/publish-verification.md). A stamped-but-hollow build is exactly how canary run 8 (2026-09-11) went green on stale content.\n" +
|
|
1554
1931
|
"- post-deploy finalized: yes (worktree removed, merge lock released)\n\n" +
|
|
1555
1932
|
"POLICY: The live artifact is rebuilt only in this phase, from the repo. Never use artifact_edit to change the artifact directly — fixes go through the repo and the loop. A source fix is not done until the artifact is rebuilt from it here.\n\n" +
|
|
1556
1933
|
"The repo push already happened in Integrate — do NOT push to git in this phase.\n\n" +
|
|
@@ -1564,6 +1941,17 @@ while (i < STEPS.length) {
|
|
|
1564
1941
|
"Report the situation in prose, then end your report with exactly this line: VERDICT: FAIL.";
|
|
1565
1942
|
}
|
|
1566
1943
|
} else if (step.name === "QA") {
|
|
1944
|
+
// Room #26 blocker 38 (2026-09-21): content-finding attribution
|
|
1945
|
+
// protocol. Hazel reports user-visible content/data observations in a
|
|
1946
|
+
// machine-readable CONTENT-FINDINGS block; the workflow classifies each
|
|
1947
|
+
// against the task's publish diff and files follow-ups itself — Hazel
|
|
1948
|
+
// never files bugfixes for content findings directly, and
|
|
1949
|
+
// environment-attributable content never fails her verdict alone.
|
|
1950
|
+
var contentFindingsProtocol =
|
|
1951
|
+
"CONTENT FINDINGS (machine-read — room #26 blocker 38): if you observe user-visible content or data that looks wrong, stale, or out of place (decks, cards, rows, text, files in the artifact — anything this task did not obviously produce), report it here — do NOT file a follow-up task for it yourself and do NOT fail your verdict for it alone. Emit exactly one line in this shape, immediately BEFORE your final VERDICT line (the verdict stays the last line of your report):\n" +
|
|
1952
|
+
"CONTENT-FINDINGS: [{\"subject\": \"<repo-relative file path, or the literal live-data for content in the artifact's runtime data stores>\", \"observation\": \"<what you saw, one line>\"}, ...]\n" +
|
|
1953
|
+
"Use subject \"live-data\" for anything you saw in the running artifact (UI content, database rows, uploaded files) — you are code-blind and cannot name its file. Use a repo-relative file path only when you know the content lives in a specific file (e.g. from the task description or public docs). When you saw no such content, emit the empty array: CONTENT-FINDINGS: [].\n" +
|
|
1954
|
+
"The workflow classifies each finding against the task's publish diff: a finding whose subject file is in the diff is attributable to this task's change and the workflow files a bugfix for it; anything else is recorded with its attribution (environment-attributable, or unknown when the diff is unavailable) — the finding itself never spawns an artifact bugfix. No finding is ever dropped for looking like test residue: it is classified by attribution and recorded with it. Your VERDICT judges this task's change; content you cannot attribute to it is not a failure of this task.\n";
|
|
1567
1955
|
// Backstop for merge-time versioning: when the accepted Build summary
|
|
1568
1956
|
// declared release: yes, QA verifies the registry actually moved. A silent
|
|
1569
1957
|
// publish skip becomes a loud QA failure with evidence, not a pass.
|
|
@@ -1606,7 +1994,7 @@ while (i < STEPS.length) {
|
|
|
1606
1994
|
"1. Run: cd " + REPO_PATH + " && git merge-base --is-ancestor <provenance.source_commit> LIVE_HEAD && echo ANCESTOR_OK (substitute the real stamped hash and LIVE_HEAD; do not run the literal placeholders). If this command fails, FAIL: { \"passed\": false, \"summary\": \"provenance mismatch: stamped source_commit is not an ancestor of live HEAD\" }.\n" +
|
|
1607
1995
|
"2. Run: cd " + REPO_PATH + " && git log --format=%s <provenance.source_commit>..LIVE_HEAD (substitute real values). Every subject line MUST start with \"rebuild: \". If any line does not, report 'provenance mismatch: live HEAD moved past the stamped commit with non-rebuild source commits: [paste the offending subject lines]', then end your report with exactly this line: VERDICT: FAIL.\n" +
|
|
1608
1996
|
"If both pass, the source check passes — the only drift since the stamp is builder staging output committed by post-deploy. Continue to STEP 3.\n\n" +
|
|
1609
|
-
"STEP 3: File follow-up tasks for any related issues you discover.\n" +
|
|
1997
|
+
"STEP 3: File follow-up tasks for any related issues you discover — EXCEPT content findings (user-visible content/data): those go in the CONTENT-FINDINGS block at the end of these instructions, never through create-task. The workflow files follow-ups for attributable content itself.\n" +
|
|
1610
1998
|
"For each issue, run in shell:\n" +
|
|
1611
1999
|
"node " + CREW_API + " --crew-home " + crewHome + " create-task --json '{\"title\": \"<issue title>\", \"description\": \"<issue details>\", \"project\": \"" + LAUNCH_PROJECT_ID + "\", \"workflow\": \"bugfix\", \"filed_by\": \"hazel\"}'\n" +
|
|
1612
2000
|
"(replace <issue title> and <issue details> with the real values).\n\n" +
|
|
@@ -1634,7 +2022,7 @@ while (i < STEPS.length) {
|
|
|
1634
2022
|
"Run in shell and return the stdout verbatim:\n" + crewCmd("get-state", { events_limit: 1 }) + "\n" +
|
|
1635
2023
|
"Use the returned tasks, sessions, and events to check the task's data-level effects.\n" +
|
|
1636
2024
|
"DOCS GATE: If the change is public-affecting (it alters anything a user or consumer can observe: API actions, parameters, behavior, or errors), verify the public docs describe it. If public docs are missing or stale for a public-affecting change, report 'public docs missing/stale for [the change]', then end your report with exactly this line: VERDICT: FAIL. QA always fails when public-affecting changes lack public docs. Guide/tutorial gaps are lower priority — file a follow-up task for those instead of failing.\n\n" +
|
|
1637
|
-
"STEP 3: File follow-up tasks for any related issues you discover.\n" +
|
|
2025
|
+
"STEP 3: File follow-up tasks for any related issues you discover — EXCEPT content findings (user-visible content/data): those go in the CONTENT-FINDINGS block at the end of these instructions, never through create-task. The workflow files follow-ups for attributable content itself.\n" +
|
|
1638
2026
|
"For each issue, run in shell:\n" +
|
|
1639
2027
|
"node " + CREW_API + " --crew-home " + crewHome + " create-task --json '{\"title\": \"<issue title>\", \"description\": \"<issue details>\", \"project\": \"" + LAUNCH_PROJECT_ID + "\", \"workflow\": \"bugfix\", \"filed_by\": \"hazel\"}'\n" +
|
|
1640
2028
|
"(replace <issue title> and <issue details> with the real values).\n\n" +
|
|
@@ -1646,12 +2034,16 @@ while (i < STEPS.length) {
|
|
|
1646
2034
|
"Public docs (API.md, README) are NOT source code — read them freely, exactly as a user would.\n" +
|
|
1647
2035
|
"Verify the change is working as described in the task.\n" +
|
|
1648
2036
|
"DOCS GATE: If the change is public-affecting (it alters anything a user or consumer can observe: API actions, parameters, behavior, or errors), verify the public docs describe it. If public docs are missing or stale, report 'public docs missing/stale for [the change]', then end your report with exactly this line: VERDICT: FAIL. QA always fails when public-affecting changes lack public docs. Guide/tutorial gaps are lower priority — file a follow-up task for those instead of failing.\n" +
|
|
1649
|
-
"File follow-up tasks for related issues found by running in shell:\n" +
|
|
2037
|
+
"File follow-up tasks for related issues found (EXCEPT content findings — user-visible content/data goes in the CONTENT-FINDINGS block at the end of these instructions, never through create-task) by running in shell:\n" +
|
|
1650
2038
|
"node " + CREW_API + " --crew-home " + crewHome + " create-task --json '{\"title\": \"<issue title>\", \"description\": \"<issue details>\", \"project\": \"" + LAUNCH_PROJECT_ID + "\", \"workflow\": \"bugfix\", \"filed_by\": \"hazel\"}'\n" +
|
|
1651
2039
|
"(replace <issue title> and <issue details> with the real values).\n\n" +
|
|
1652
2040
|
npmPublishCheck +
|
|
1653
2041
|
"Report back in plain prose — what you tested and found. End your report with exactly one line: VERDICT: PASS or VERDICT: FAIL.";
|
|
1654
2042
|
}
|
|
2043
|
+
// The content-findings block is machine-read at closeout (blocker 38).
|
|
2044
|
+
// Hazel emits it immediately before the VERDICT line, so the verdict
|
|
2045
|
+
// keeps its trailing-window contract with extractVerdict.
|
|
2046
|
+
instructions += "\n" + contentFindingsProtocol;
|
|
1655
2047
|
// qaExperiential: Hazel owns the experiential verdict through the QA
|
|
1656
2048
|
// prompt built in the SURFACE_ARTIFACT / SURFACE_TERMINAL branches above
|
|
1657
2049
|
// (see-act loop or terminal loop + OODA report). There is no parent
|
|
@@ -1692,7 +2084,31 @@ while (i < STEPS.length) {
|
|
|
1692
2084
|
var workKeyBase = "work-" + step.name + (totalReworkCount > 0 ? "-r" + totalReworkCount : "");
|
|
1693
2085
|
var workerResult = null;
|
|
1694
2086
|
var workAttempts = [];
|
|
1695
|
-
|
|
2087
|
+
// Room #26 blocker 34 (redesign): an empty branch with no verified sha and
|
|
2088
|
+
// no repo_diff: none claim fails Review mechanically — Cass is never
|
|
2089
|
+
// dispatched, so no reviewer adjudicates the emptiness. The synthetic
|
|
2090
|
+
// report below is written by the workflow and flows through the same
|
|
2091
|
+
// verdict extraction, structured verdict recording, and rejection/bounce
|
|
2092
|
+
// path as a real FAIL.
|
|
2093
|
+
// Blocker-34 follow-up: the npm `version` check joins the mechanical gate.
|
|
2094
|
+
// Either mechanical fact fails Review without dispatching Cass.
|
|
2095
|
+
var mechanicalFailReason = (versionTouched ? "version-touched" : (branchState === "empty-no-work" && !buildClaimedNoDiff ? "empty-no-work" : null));
|
|
2096
|
+
var mechanicalReviewFail = (step.name === "Review" && mechanicalFailReason !== null);
|
|
2097
|
+
if (mechanicalReviewFail) {
|
|
2098
|
+
log("Review: " + mechanicalFailReason + " — mechanical FAIL, Cass not dispatched");
|
|
2099
|
+
workerResult =
|
|
2100
|
+
"MECHANICAL REVIEW VERDICT (written by the workflow — no reviewer was dispatched).\n" +
|
|
2101
|
+
(mechanicalFailReason === "version-touched"
|
|
2102
|
+
? "Package.json `version` (checked by the workflow from git): the task branch changed the `version` field. Versions are assigned at publish time — never in branches. Remove the version change.\n"
|
|
2103
|
+
: "Branch state (classified by the workflow from git): empty-no-work — the task branch has no commits ahead of the integration target, " +
|
|
2104
|
+
"no task-attributed merge on the target was verified" + (branchStateErr ? " (branch classification itself failed: " + branchStateErr + ")" : "") + ", " +
|
|
2105
|
+
"and the accepted Build report declared no `repo_diff: none` deliverable. " +
|
|
2106
|
+
"No change was reviewed because there is no change to review. The builder likely forgot to commit.\n") +
|
|
2107
|
+
"Worktree: " + WORKTREE_HINT + "\n" +
|
|
2108
|
+
"Recovery: commit the deliverable on the task branch in the worktree above and re-run Review. If the deliverable is genuinely runtime state outside the repo, declare `repo_diff: none` in the Build report instead of leaving the branch empty without a declaration.\n" +
|
|
2109
|
+
"VERDICT: FAIL";
|
|
2110
|
+
}
|
|
2111
|
+
for (var workAttempt = 0; workAttempt <= 2 && !mechanicalReviewFail; workAttempt++) {
|
|
1696
2112
|
var workKey = workAttempt === 0 ? workKeyBase : workRetryKey(step.name, (totalReworkCount > 0 ? "-r" + totalReworkCount : ""), workAttempt);
|
|
1697
2113
|
var prevAttempt = workAttempt === 0 ? null : workAttempts[workAttempt - 1];
|
|
1698
2114
|
var retryReason = workAttempt === 0 ? null : (prevAttempt.threw ? "discarded" : (prevAttempt.outcome === "missing-artifact-tools" ? "no-tools" : (prevAttempt.outcome === "unavailable-shell-transport" ? "no-transport" : "empty")));
|
|
@@ -1790,7 +2206,18 @@ while (i < STEPS.length) {
|
|
|
1790
2206
|
"Run in shell and return the stdout verbatim:\n" + crewCmd("record-phase", {
|
|
1791
2207
|
task_id: taskId,
|
|
1792
2208
|
session: { id: activeSessionId, task_id: taskId, identity: step.identity, step: step.name, status: "failed", notes: "Worker report had no single unambiguous VERDICT: PASS/FAIL line (bounded re-ask exhausted)" },
|
|
1793
|
-
event: { task_id: taskId, type: "failed", message: step.name + " verdict line missing or ambiguous, re-ask exhausted — phase failed, dispatcher will retry" }
|
|
2209
|
+
event: { task_id: taskId, type: "failed", message: step.name + " verdict line missing or ambiguous, re-ask exhausted — phase failed, dispatcher will retry" },
|
|
2210
|
+
// Room #26 blocker 33: INDETERMINATE verdict record — the report
|
|
2211
|
+
// could not be read at all, but its full text is still preserved
|
|
2212
|
+
// as grounds. Review-scoped; other verdict steps keep the
|
|
2213
|
+
// existing failed-session behavior with no verdict row.
|
|
2214
|
+
verdict: (step.name === "Review" ? {
|
|
2215
|
+
step: "Review",
|
|
2216
|
+
attempt: totalReworkCount,
|
|
2217
|
+
reviewer: step.identity,
|
|
2218
|
+
verdict: "INDETERMINATE",
|
|
2219
|
+
grounds: workerText
|
|
2220
|
+
} : null)
|
|
1794
2221
|
}),
|
|
1795
2222
|
{ key: "record-block-" + step.name, label: "Recording verdict failure" }
|
|
1796
2223
|
);
|
|
@@ -1837,40 +2264,13 @@ while (i < STEPS.length) {
|
|
|
1837
2264
|
}
|
|
1838
2265
|
log("Build worktree confinement passed: " + wt.path);
|
|
1839
2266
|
|
|
1840
|
-
//
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
{ key: "verify-already-merged" + (totalReworkCount > 0 ? "-r" + totalReworkCount : ""), label: "Verifying already-merged declaration" }
|
|
1848
|
-
);
|
|
1849
|
-
var amOut = (typeof amCheck === "string") ? amCheck : JSON.stringify(amCheck);
|
|
1850
|
-
if (!/ALREADY_MERGED_YES/.test(amOut)) {
|
|
1851
|
-
log("Build already-merged declaration failed verification — " + am.sha + " is not an ancestor of the integration target — marking failed for retry");
|
|
1852
|
-
await agent(
|
|
1853
|
-
"Record already-merged verification failure.\n" +
|
|
1854
|
-
"Run in shell and return the stdout verbatim:\n" + crewCmd("record-phase", {
|
|
1855
|
-
task_id: taskId,
|
|
1856
|
-
session: { id: activeSessionId, task_id: taskId, identity: step.identity, step: step.name, status: "failed",
|
|
1857
|
-
notes: "Build declared repo_diff: none (already-merged: " + am.sha + ") but " + am.sha + " is not an ancestor of the integration target in the configured repo. The declaration is fabricated or mistaken; the work is not on the integration target. Phase failed for retry" },
|
|
1858
|
-
event: { task_id: taskId, type: "failed", message: "Build already-merged declaration failed verification — " + am.sha + " not an ancestor of the integration target, phase failed, dispatcher will retry" }
|
|
1859
|
-
}),
|
|
1860
|
-
{ key: "record-already-merged-fail-" + step.name, label: "Recording already-merged verification failure" }
|
|
1861
|
-
);
|
|
1862
|
-
return {
|
|
1863
|
-
__hatchWorkflowControl: "blocked",
|
|
1864
|
-
result: {
|
|
1865
|
-
blocked_reason: "Build already-merged declaration failed verification",
|
|
1866
|
-
message: "The builder declared repo_diff: none (already-merged: " + am.sha + ") but " + am.sha + " is not an ancestor of the integration target. The work is not on the integration target; the phase is marked failed and the dispatcher will retry Build.",
|
|
1867
|
-
task_id: taskId
|
|
1868
|
-
}
|
|
1869
|
-
};
|
|
1870
|
-
}
|
|
1871
|
-
alreadyMergedSha = am.sha;
|
|
1872
|
-
log("Build already-merged declaration verified: " + am.sha + " is an ancestor of the integration target");
|
|
1873
|
-
}
|
|
2267
|
+
// Room #26 blocker 34 (redesign, 2026-09-21): capture the plain
|
|
2268
|
+
// `repo_diff: none` (no repo change) claim from the FULL Build report.
|
|
2269
|
+
// Each Build round sets this fresh from its own report; there is no
|
|
2270
|
+
// cross-process fallback. The agent-authored already-merged
|
|
2271
|
+
// declaration and its Build-closeout verification are deleted —
|
|
2272
|
+
// attribution is the classifier's job at Review entry.
|
|
2273
|
+
buildClaimedNoDiff = /repo_diff:\s*none/im.test(workerText || "");
|
|
1874
2274
|
}
|
|
1875
2275
|
|
|
1876
2276
|
// See docs/decisions/qa-reproduce.md#experiential-loop-guard: a PASS with missing experiential evidence parks fail-closed.
|
|
@@ -1915,6 +2315,116 @@ while (i < STEPS.length) {
|
|
|
1915
2315
|
log("QA " + qaLoopSurface + "-loop guard passed: experiential evidence present");
|
|
1916
2316
|
}
|
|
1917
2317
|
|
|
2318
|
+
// Room #26 blocker 38 (2026-09-21): content-finding attribution at QA
|
|
2319
|
+
// closeout. Hazel's CONTENT-FINDINGS block is extracted deterministically
|
|
2320
|
+
// and each finding is classified against the task's publish-diff file set
|
|
2321
|
+
// (persisted at Publish). Attributable findings become bugfix tasks filed
|
|
2322
|
+
// by the workflow; environment-attributable findings are recorded as task
|
|
2323
|
+
// note events with their attribution — never suppressed, never a bugfix,
|
|
2324
|
+
// never a park. No automatic FAIL override: if the QA agent still
|
|
2325
|
+
// reports FAIL, it stands — finding attribution informs follow-up
|
|
2326
|
+
// filing only.
|
|
2327
|
+
if (step.name === "QA") {
|
|
2328
|
+
var contentFindings = extractContentFindings(workerText);
|
|
2329
|
+
if (!contentFindings.ok) {
|
|
2330
|
+
// Unknown attribution fails closed: a missing or malformed
|
|
2331
|
+
// CONTENT-FINDINGS block blocks the phase for retry — the way an
|
|
2332
|
+
// unreadable VERDICT line does (record-phase failed + halted run).
|
|
2333
|
+
// It must never degrade to "no findings" (fail-open): unknown
|
|
2334
|
+
// attribution converted to an empty set silently drops the
|
|
2335
|
+
// observations the prose grounds carry. Do NOT re-ask an LLM to
|
|
2336
|
+
// repair a machine-readable contract — enforce the contract.
|
|
2337
|
+
log("QA CONTENT-FINDINGS unreadable (" + contentFindings.reason + ") — marking failed for retry");
|
|
2338
|
+
await agent(
|
|
2339
|
+
"Record content-findings failure.\n" +
|
|
2340
|
+
"Run in shell and return the stdout verbatim:\n" + crewCmd("record-phase", {
|
|
2341
|
+
task_id: taskId,
|
|
2342
|
+
session: { id: activeSessionId, task_id: taskId, identity: step.identity, step: step.name, status: "failed",
|
|
2343
|
+
notes: "QA report had no machine-readable CONTENT-FINDINGS block (" + contentFindings.reason + "); phase failed for retry" },
|
|
2344
|
+
event: { task_id: taskId, type: "failed", message: "QA CONTENT-FINDINGS block unreadable (" + contentFindings.reason + ") — phase failed, dispatcher will retry" }
|
|
2345
|
+
}),
|
|
2346
|
+
{ key: "record-block-" + step.name, label: "Recording content-findings failure" }
|
|
2347
|
+
);
|
|
2348
|
+
return {
|
|
2349
|
+
__hatchWorkflowControl: "blocked",
|
|
2350
|
+
result: {
|
|
2351
|
+
blocked_reason: "QA worker report had no machine-readable CONTENT-FINDINGS block (" + contentFindings.reason + ")",
|
|
2352
|
+
message: "The " + step.identity + " agent's work may be valid — its report did not carry a CONTENT-FINDINGS block the workflow could read, and the attribution contract fails closed rather than degrading to \"no findings\". The report is preserved in the workflow log.",
|
|
2353
|
+
task_id: taskId
|
|
2354
|
+
}
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
2357
|
+
// The publish-diff file set, persisted at Publish. Unreadable →
|
|
2358
|
+
// attribution unknown: every finding records "unknown" with the
|
|
2359
|
+
// reason naming the missing diff (never environment-attributable,
|
|
2360
|
+
// never a bugfix). The QA verdict stands on its own.
|
|
2361
|
+
var qaDiffFiles = [];
|
|
2362
|
+
var qaDiffFilesOk = false;
|
|
2363
|
+
try {
|
|
2364
|
+
var qaDiffFilesOut = await agent(
|
|
2365
|
+
"Run exactly one command and return the stdout verbatim:\n" +
|
|
2366
|
+
"cat \"" + crewHome + "/.publish-diffs/" + taskId + ".files.json\" 2>/dev/null || echo DIFF_FILES_MISSING\n" +
|
|
2367
|
+
"Return JSON { \"output\": \"<the command's full stdout, trimmed>\" } and nothing else.",
|
|
2368
|
+
{ key: attemptKey("qa-diff-files-" + taskId, totalReworkCount), label: "Loading publish diff file list",
|
|
2369
|
+
schema: { type: "object", properties: { output: { type: "string" } }, required: ["output"] } }
|
|
2370
|
+
);
|
|
2371
|
+
var qaDiffFilesRaw = ((qaDiffFilesOut && qaDiffFilesOut.output) || "").trim();
|
|
2372
|
+
if (qaDiffFilesRaw && qaDiffFilesRaw !== "DIFF_FILES_MISSING") {
|
|
2373
|
+
var qaDiffParsed = JSON.parse(qaDiffFilesRaw);
|
|
2374
|
+
if (Array.isArray(qaDiffParsed)) {
|
|
2375
|
+
qaDiffFiles = qaDiffParsed;
|
|
2376
|
+
qaDiffFilesOk = true;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
} catch (e) {
|
|
2380
|
+
log("QA diff file list unreadable: " + ((e && e.message ? e.message : String(e)) || "").slice(0, 200));
|
|
2381
|
+
}
|
|
2382
|
+
if (!qaDiffFilesOk) {
|
|
2383
|
+
log("QA publish diff file list unavailable — content findings record attribution unknown");
|
|
2384
|
+
}
|
|
2385
|
+
for (var cfi = 0; cfi < contentFindings.findings.length; cfi++) {
|
|
2386
|
+
var cf = contentFindings.findings[cfi];
|
|
2387
|
+
// Unknown attribution fails closed: when the diff file set is
|
|
2388
|
+
// unavailable we cannot attribute, so the finding is recorded as
|
|
2389
|
+
// "unknown" (never environment-attributable, never a bugfix) and the
|
|
2390
|
+
// QA verdict stands — the journey does not continue on unproven
|
|
2391
|
+
// attribution.
|
|
2392
|
+
var cfc = qaDiffFilesOk ? classifyContentFinding(cf, qaDiffFiles)
|
|
2393
|
+
: { attribution: "unknown", reason: "publish diff file set unavailable — cannot attribute" };
|
|
2394
|
+
if (cfc.attribution === "task-change") {
|
|
2395
|
+
log("QA content finding attributable to task change — filing bugfix: " + cf.subject + " :: " + cf.observation.slice(0, 120));
|
|
2396
|
+
await agent(
|
|
2397
|
+
"File the follow-up task.\n" +
|
|
2398
|
+
"Run in shell and return the stdout verbatim:\n" +
|
|
2399
|
+
"node " + CREW_API + " --crew-home " + crewHome + " create-task --json '" +
|
|
2400
|
+
JSON.stringify({ title: "QA content finding: " + cf.observation.slice(0, 120), description: "Content finding from QA on task " + taskId + " (subject: " + cf.subject + ", classified task-change: " + cfc.reason + "). Observation: " + cf.observation, project: LAUNCH_PROJECT_ID, workflow: "bugfix", filed_by: "hazel" }).split("'").join("'\\''") + "'\n",
|
|
2401
|
+
{ key: attemptKey("qa-content-bugfix-" + taskId + "-" + cfi, totalReworkCount), label: "Filing attributable content bugfix" }
|
|
2402
|
+
);
|
|
2403
|
+
} else {
|
|
2404
|
+
// environment-attributable and unknown findings are recorded as task
|
|
2405
|
+
// note events with their attribution — never suppressed, never a
|
|
2406
|
+
// bugfix, never a park by themselves. The QA verdict stands on its
|
|
2407
|
+
// own: we do not override a FAIL based on finding attribution, because
|
|
2408
|
+
// the verdict may rest on functional grounds the findings do not capture.
|
|
2409
|
+
log("QA content finding " + cfc.attribution + " — recording, no bugfix: " + cf.subject + " :: " + cf.observation.slice(0, 120));
|
|
2410
|
+
await agent(
|
|
2411
|
+
"Record the " + cfc.attribution + " content finding.\n" +
|
|
2412
|
+
"Run in shell and return the stdout verbatim:\n" +
|
|
2413
|
+
crewCmd("log-event", { task_id: taskId, type: "note", message: "content-finding: " + cfc.attribution + " — subject: " + cf.subject + " — " + cf.observation + " (" + cfc.reason + ")" }) + "\n",
|
|
2414
|
+
{ key: attemptKey("qa-content-record-" + taskId + "-" + cfi, totalReworkCount), label: "Recording " + cfc.attribution + " finding" }
|
|
2415
|
+
);
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
// No automatic FAIL override. The QA prompt instructs Hazel that her
|
|
2419
|
+
// VERDICT judges this task's change and unattributable content is not a
|
|
2420
|
+
// failure of this task; if she still reports FAIL, it stands. The
|
|
2421
|
+
// recorded finding attributions (above) give the human the evidence to
|
|
2422
|
+
// distinguish environment residue from task failure. Overriding a FAIL
|
|
2423
|
+
// merely because all listed findings are environment-attributable would
|
|
2424
|
+
// be too broad — the prose may name functional failures the findings do
|
|
2425
|
+
// not capture.
|
|
2426
|
+
}
|
|
2427
|
+
|
|
1918
2428
|
// Deterministic closeout: no formatter agent. The verdict is mechanical
|
|
1919
2429
|
// (extractVerdict above); the summary is the worker's report truncated.
|
|
1920
2430
|
// For verdict steps passed comes from the verdict; for non-verdict steps
|
|
@@ -1924,6 +2434,9 @@ while (i < STEPS.length) {
|
|
|
1924
2434
|
summary: workerText
|
|
1925
2435
|
};
|
|
1926
2436
|
let passed = stepResult.passed === true;
|
|
2437
|
+
// Blocker 38: content findings are recorded with their attribution in the
|
|
2438
|
+
// session notes above; the QA verdict stands on its own and is never
|
|
2439
|
+
// overridden by finding attribution.
|
|
1927
2440
|
|
|
1928
2441
|
// See docs/decisions/publish-path.md#integrate-verify: the agent cannot verify integrate mechanically; the workflow checks the diff.
|
|
1929
2442
|
if (step.name === "Integrate" && passed) {
|
|
@@ -2064,9 +2577,23 @@ while (i < STEPS.length) {
|
|
|
2064
2577
|
} else {
|
|
2065
2578
|
summary = (stepResult.summary || "Step completed").slice(0, 2000 - workerMarkers.length - 1) + (workerMarkers ? "\n" + workerMarkers : "");
|
|
2066
2579
|
}
|
|
2067
|
-
//
|
|
2068
|
-
|
|
2069
|
-
|
|
2580
|
+
// Room #26 blocker 34 (redesign, 2026-09-21): machine-readable review
|
|
2581
|
+
// basis, prepended to Review session notes for observability (proof
|
|
2582
|
+
// rooms read the summary to see what Review examined and why a
|
|
2583
|
+
// reviewer was or was not dispatched).
|
|
2584
|
+
if (step.name === "Review" && branchState) {
|
|
2585
|
+
var reviewBasisNote;
|
|
2586
|
+
if (mechanicalReviewFail) {
|
|
2587
|
+
reviewBasisNote = "REVIEW_BASIS: none — mechanical FAIL (" + mechanicalFailReason + "), no reviewer dispatched";
|
|
2588
|
+
} else if (branchState.indexOf("already-merged:") === 0) {
|
|
2589
|
+
var rbSha = branchState.slice("already-merged:".length);
|
|
2590
|
+
reviewBasisNote = "REVIEW_BASIS: frozen merge " + rbSha + " — reviewed via git diff " + rbSha + "^1 " + rbSha;
|
|
2591
|
+
} else if (branchState === "has-work") {
|
|
2592
|
+
reviewBasisNote = "REVIEW_BASIS: branch diff — reviewed via inspect output (task branch vs integration target)";
|
|
2593
|
+
} else {
|
|
2594
|
+
reviewBasisNote = "REVIEW_BASIS: runtime-state-none — no repo change; plausibility of Build's repo_diff: none claim";
|
|
2595
|
+
}
|
|
2596
|
+
summary = reviewBasisNote + "\n" + summary;
|
|
2070
2597
|
}
|
|
2071
2598
|
|
|
2072
2599
|
// Visual verdict evidence: for experiential artifact tasks, append the
|
|
@@ -2096,17 +2623,44 @@ while (i < STEPS.length) {
|
|
|
2096
2623
|
releaseDecision = extractReleaseDecision(workerText);
|
|
2097
2624
|
}
|
|
2098
2625
|
|
|
2626
|
+
// Room #26 blocker 34 (redesign, 2026-09-21): structured review basis
|
|
2627
|
+
// for the verdict row — what the review actually examined. A mechanical
|
|
2628
|
+
// FAIL has no reviewer and no basis beyond the mechanical fact. Only
|
|
2629
|
+
// computed for Review (branchState is null on other steps).
|
|
2630
|
+
var reviewBasis = null;
|
|
2631
|
+
if (step.name === "Review" && branchState) {
|
|
2632
|
+
reviewBasis =
|
|
2633
|
+
mechanicalReviewFail ? "mechanical-fail" :
|
|
2634
|
+
branchState.indexOf("already-merged:") === 0 ? "frozen-merge:" + branchState.slice("already-merged:".length) :
|
|
2635
|
+
branchState === "has-work" ? "branch-diff" : "runtime-state-none";
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2099
2638
|
// Record session result
|
|
2100
2639
|
await agent(
|
|
2101
2640
|
"Update the session and log the event.\n" +
|
|
2102
2641
|
"Run in shell and return the stdout verbatim:\n" + crewCmd("record-phase", {
|
|
2103
2642
|
task_id: taskId,
|
|
2104
|
-
// Room #
|
|
2105
|
-
//
|
|
2106
|
-
//
|
|
2107
|
-
//
|
|
2108
|
-
session: { id: activeSessionId, task_id: taskId, identity: step.identity, step: step.name, status: status, notes: summary
|
|
2109
|
-
event: { task_id: taskId, type: status, identity: step.identity, message: step.name + " " + status + " by " + step.identity }
|
|
2643
|
+
// Room #26 blocker 34 (2026-09-21): the already_merged_sha session
|
|
2644
|
+
// field is no longer written — the agent-authored declaration path
|
|
2645
|
+
// is deleted and nothing reads it. Removing the Crew API/database
|
|
2646
|
+
// column is a separate API-surface follow-up, not bundled here.
|
|
2647
|
+
session: { id: activeSessionId, task_id: taskId, identity: step.identity, step: step.name, status: status, notes: summary },
|
|
2648
|
+
event: { task_id: taskId, type: status, identity: step.identity, message: step.name + " " + status + " by " + step.identity },
|
|
2649
|
+
// Room #26 blocker 33: structured, non-lossy Review verdict record.
|
|
2650
|
+
// The session note above is truncated; the verdict row carries the
|
|
2651
|
+
// full worker report as grounds, written in the same transaction.
|
|
2652
|
+
// attempt is the rework round (0 = first Review).
|
|
2653
|
+
verdict: (step.name === "Review" && verdictPassed !== null ? {
|
|
2654
|
+
step: "Review",
|
|
2655
|
+
attempt: totalReworkCount,
|
|
2656
|
+
// Room #26 blocker 34 (redesign): a mechanical FAIL has no
|
|
2657
|
+
// reviewer — the workflow wrote the verdict. Identity rows still say
|
|
2658
|
+
// the Review step ran.
|
|
2659
|
+
reviewer: mechanicalReviewFail ? "workflow" : step.identity,
|
|
2660
|
+
verdict: verdictPassed ? "PASS" : "FAIL",
|
|
2661
|
+
review_basis: reviewBasis,
|
|
2662
|
+
grounds: workerText
|
|
2663
|
+
} : null)
|
|
2110
2664
|
}),
|
|
2111
2665
|
{
|
|
2112
2666
|
key: "record-" + step.name + (totalReworkCount > 0 ? "-r" + totalReworkCount : "") + (mapGateBounceCount > 0 ? "-g" + mapGateBounceCount : ""),
|
|
@@ -2116,21 +2670,20 @@ while (i < STEPS.length) {
|
|
|
2116
2670
|
|
|
2117
2671
|
// Handle rejection — bounce back to Build
|
|
2118
2672
|
if (!passed && (step.name === "Review" || step.name === "QA")) {
|
|
2673
|
+
// Room #26 blocker 34 (redesign, 2026-09-21): the false-negative guard,
|
|
2674
|
+
// the Case B budget skip, and the already-merged corrective are all
|
|
2675
|
+
// gone. Emptiness is classified mechanically before Review, so a
|
|
2676
|
+
// rejected Review is never re-adjudicated here — the workflow owns the
|
|
2677
|
+
// git facts, the reviewer owns quality/spec compliance, and the budget
|
|
2678
|
+
// applies uniformly to every rejection. A rejected frozen merge
|
|
2679
|
+
// bounces with the reviewer's notes; a real fix commit becomes
|
|
2680
|
+
// has-work, and a do-nothing loop exhausts the normal budget.
|
|
2119
2681
|
totalReworkCount++;
|
|
2120
2682
|
if (totalReworkCount > MAX_TOTAL_REWORK) {
|
|
2121
2683
|
log("Shared rework budget exhausted for task " + taskId + " — worktree preserved at " + WORKTREE_PRESERVED_HINT + " for manual inspection");
|
|
2122
2684
|
return await parkTask("Exceeded shared rework budget (" + MAX_TOTAL_REWORK + " total rework attempts across Review and QA) after " + step.name + " rejection. Worktree preserved.");
|
|
2123
2685
|
}
|
|
2124
2686
|
rejectionNotes = summary;
|
|
2125
|
-
// Already-merged corrective (room #16 blocker 11): when Review rejected
|
|
2126
|
-
// an empty branch but the work is already on the integration target (the workflow verified
|
|
2127
|
-
// the sha), Wren must declare it — not re-implement or re-commit
|
|
2128
|
-
// already-landed work. Scoped to the empty-branch rejection; any other
|
|
2129
|
-
// rejection already carries its own specific notes.
|
|
2130
|
-
if (step.name === "Review" && alreadyMergedSha && /no commits ahead of (main|the integration target)/i.test(summary)) {
|
|
2131
|
-
rejectionNotes += "\n\nCORRECTIVE (from the workflow, not the reviewer): the deliverable is already on the integration target — the workflow mechanically verified that " + alreadyMergedSha + " is an ancestor of the integration target. Do NOT re-implement the work and do NOT create a new commit for it. In your Build report, declare exactly: repo_diff: none (already-merged: " + alreadyMergedSha + ") — then end with VERDICT: PASS.";
|
|
2132
|
-
log("Rework corrective appended for task " + taskId + ": already-merged " + alreadyMergedSha + " — Wren must declare, not rebuild");
|
|
2133
|
-
}
|
|
2134
2687
|
i = BUILD_INDEX;
|
|
2135
2688
|
log(step.name + " rejected — bouncing to Build (rework #" + totalReworkCount + " of " + MAX_TOTAL_REWORK + ")");
|
|
2136
2689
|
continue;
|