muse-crew 0.7.18 → 0.7.19

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.
@@ -499,48 +499,6 @@ function parseUnifiedDiff(diffText) {
499
499
  return files;
500
500
  }
501
501
 
502
- // Compare the artifact builder's reported applied-changes against the diff's
503
- // expected changes. Every added/removed line must match exactly per path,
504
- // and the file counts must match — the builder applies exactly the carried
505
- // change, nothing more, nothing less. Pure function — no I/O, no clock.
506
- // OBSERVATION INPUT ONLY (2026-09-12, task 23ca8f3f): the applied report
507
- // has a demonstrated false-negative mode (applied:[] for a diff the builder
508
- // had actually applied), and it is derived from the carried diff, so a match
509
- // certifies nothing either. A mismatch is logged as observation; it never
510
- // parks and never blocks the stamp. The verification is the independent
511
- // read-back (docs/publish-verification.md).
512
- function verifyAppliedChanges(expected, applied) {
513
- if (!Array.isArray(applied)) {
514
- return { ok: false, reason: "builder returned no applied-changes list" };
515
- }
516
- function sorted(a) { return (a || []).slice().sort(); }
517
- function eq(a, b) {
518
- a = sorted(a); b = sorted(b);
519
- if (a.length !== b.length) return false;
520
- for (var i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
521
- return true;
522
- }
523
- for (var i = 0; i < expected.length; i++) {
524
- var exp = expected[i];
525
- var got = null;
526
- for (var j = 0; j < applied.length; j++) {
527
- if (applied[j] && applied[j].path === exp.path) { got = applied[j]; break; }
528
- }
529
- if (!got) {
530
- return { ok: false, reason: "builder did not report changing '" + exp.path + "'" };
531
- }
532
- if (!eq(exp.added, got.added)) {
533
- return { ok: false, reason: "added lines for '" + exp.path + "' do not match the carried diff" };
534
- }
535
- if (!eq(exp.removed, got.removed)) {
536
- return { ok: false, reason: "removed lines for '" + exp.path + "' do not match the carried diff" };
537
- }
538
- }
539
- if (applied.length !== expected.length) {
540
- return { ok: false, reason: "builder reported changing " + applied.length + " file(s), diff carries " + expected.length };
541
- }
542
- return { ok: true };
543
- }
544
502
 
545
503
  // Publish read-back request (currently unavailable): the verbatim_request
546
504
  // the parent protocol (docs/publish-verification.md) would hand to an
@@ -554,35 +512,12 @@ function verifyAppliedChanges(expected, applied) {
554
512
  // finding. Until a read-back path exists, the parent cannot independently
555
513
  // confirm content and verification parks at "publish: verification-requested"
556
514
  // (see docs/publish-verification.md). This preserves the circularity break
557
- // that hollowed canary run 8 (2026-09-11): verifyAppliedChanges compares the
558
- // builder's applied-report against the diff the report was derived from — a
559
- // fabricated report passes by construction. Independent read-back cannot be
515
+ // that hollowed canary run 8 (2026-09-11): the old verifyAppliedChanges
516
+ // compared the builder's applied-report against the diff the report was
517
+ // derived from — a fabricated report passed by construction. The report
518
+ // itself is gone now (2026-09-16 fire-and-forget trigger). Independent
519
+ // read-back cannot be
560
520
  // fabricated from the diff; it must match the artifact's real content.
561
- // Pre-publish base observation (diagnostic, 2026-09-12): instruction fragment
562
- // for the builder's edit request, asking it to report the sha256 of each
563
- // touched file's CURRENT content BEFORE applying the diff. Pure function —
564
- // no I/O, no clock.
565
- //
566
- // Why: the builder applies the carried diff to its own source tree, whose
567
- // base state is unrecorded. The post-hoc read-back only checks the changed
568
- // regions AFTER the edit; it cannot tell us what base the diff landed on.
569
- // If the tree was dirty or drifted before the edit, the read-back still
570
- // passes (the diff's lines are present) while the artifact silently carries
571
- // uncommitted content — the production validateRepoPath incident
572
- // (2026-09-12), where the live artifact contained code absent from every git
573
- // ref. These pre-hashes, compared against the workflow-computed expected
574
- // base hashes (merge parent), reveal what the publish actually read.
575
- // Observation only — the workflow logs mismatches but never parks on them.
576
- function buildPreHashInstruction(files) {
577
- var paths = files.map(function(f) { return f.path; }).join(", ");
578
- return (
579
- "- BEFORE applying anything, compute the sha256 hash of each file below as it CURRENTLY exists in your source tree (before your changes). Use the exact bytes of the current file content.\n" +
580
- "- Report these hashes in the \"pre_hashes\" field of your return JSON, as { \"<path>\": \"<sha256 hex>\" }.\n" +
581
- "- If a file does not exist in your tree, report its hash as the string \"MISSING\".\n" +
582
- "- Do this BEFORE applying the diff — the hashes must reflect the pre-edit state.\n" +
583
- " Files: " + paths + "\n"
584
- );
585
- }
586
521
 
587
522
  // Durable publish-attempt ledger (2026-09-12): every artifact publish
588
523
  // attempt is recorded append-only at $CREW_HOME/.publish-ledger/<slug>.jsonl
@@ -1524,38 +1459,8 @@ while (i < STEPS.length) {
1524
1459
  if (expectedChanges.length === 0) {
1525
1460
  return await parkTask("Publish diff parsed to zero files for commit " + (mergeCommitForPublish || "unknown") + " — cannot verify application. Human attention needed.");
1526
1461
  }
1527
- // Pre-publish base observation (diagnostic, 2026-09-12): the builder
1528
- // applies the diff to its own source tree, whose base state is
1529
- // unrecorded. Compute the trustworthy expected base — the sha256 of
1530
- // each touched file at the merge parent commit — so the builder's
1531
- // self-reported pre-edit hashes (see buildPreHashInstruction) can be
1532
- // compared against it. Observation only: a mismatch is logged loudly
1533
- // but never parks. The observation tells us what the publish actually
1534
- // reads, so the subsequent fix can require the right base.
1535
- var expectedBaseHashes = {};
1536
- if (publishBase === EMPTY_TREE_SHA) {
1537
- // First publish: every file in the diff is new to the artifact.
1538
- expectedChanges.forEach(function (f) { expectedBaseHashes[f.path] = "NEW-FILE"; });
1539
- log("Publish expected base hashes for task " + taskId + ": empty tree (first publish) — all " + expectedChanges.length + " file(s) new");
1540
- } else try {
1541
- // Shell-quote helper (no regex-with-quote: the test parser does not
1542
- // understand regex literals containing quotes).
1543
- var sq = function(s) { return "'" + String(s).split("'").join("'\\''") + "'"; };
1544
- var baseHashResult = await agent(
1545
- "Run: cd " + REPO_PATH + " && parent=" + sq(publishBase) + " && for f in " + expectedChanges.map(function(f) { return sq(f.path); }).join(" ") + "; do printf '%s:' \"$f\"; git show \"$parent:$f\" 2>/dev/null | sha256sum | cut -d' ' -f1; done\n" +
1546
- "Return JSON { \"hashes\": \"<newline-separated <path>:<sha256> lines, empty hash means the file is new in this diff>\" } and nothing else.",
1547
- { key: attemptKey("publish-base-hashes-" + taskId, reworkCount), label: "Computing expected base content hashes",
1548
- schema: { type: "object", properties: { hashes: { type: "string" } }, required: ["hashes"] } }
1549
- );
1550
- (baseHashResult.hashes || "").split("\n").forEach(function(line) {
1551
- var m = /^([^:]+):([0-9a-f]*)$/.exec(line.trim());
1552
- if (m) expectedBaseHashes[m[1]] = m[2] || "NEW-FILE";
1553
- });
1554
- log("Publish expected base hashes for task " + taskId + " (stamped base " + publishBase.slice(0, 12) + "): " + JSON.stringify(expectedBaseHashes));
1555
- } catch (e) {
1556
- log("Publish expected base hash computation failed for task " + taskId + " (non-fatal, observation degraded): " + (e && e.message ? e.message : e));
1557
- }
1558
1462
  var rebuildPrompt =
1463
+ ARTIFACT_LOAD_PREAMBLE +
1559
1464
  "Call artifact_edit with slug \"" + PUBLISH_SLUG + "\" and verbatim_request:\n" +
1560
1465
  "'Apply the following change to your source tree, then rebuild and deploy.\n" +
1561
1466
  "\n" +
@@ -1568,70 +1473,36 @@ while (i < STEPS.length) {
1568
1473
  "- For a deleted file (+++ /dev/null), delete it.\n" +
1569
1474
  "- If any hunk does not apply cleanly, STOP and report the failure — do not improvise or skip hunks.\n" +
1570
1475
  "- Do not make any other source changes.\n" +
1571
- "- After applying, rebuild and deploy.\n" +
1572
- "- Report, for each file you changed: its path, the exact lines you added, and the exact lines you removed.\n" +
1573
- buildPreHashInstruction(expectedChanges) + "'\n" +
1574
- ARTIFACT_LOAD_PREAMBLE +
1575
- "If artifact_edit is still not available after the load, do NOT improvise — return { \"edit_started\": false, \"build_agent_id\": null, \"error\": \"artifact_tools missing after load\", \"applied\": [] }.\n" +
1576
- "RECEIPT CAPTURE (receipt-chained publish, 2026-09-13): the edit is only half the contract — you must also capture the platform build's receipt, the in-flight correlation ID the follow-up poll chains to.\n" +
1577
- "- The artifact namespace is already loaded (see below). BEFORE calling artifact_edit, call artifact_status with slug \"" + PUBLISH_SLUG + "\" and note the running build's agent_id (or null when no build is running). This is the pre-edit baseline.\n" +
1578
- "- Call artifact_edit as instructed above.\n" +
1579
- "- IMMEDIATELY after artifact_edit returns, call artifact_status again. If a build is running whose agent_id DIFFERS from the pre-edit baseline (or the baseline was null), that build is this edit's — its agent_id is the receipt.\n" +
1580
- "- If the post-edit status shows the SAME agent_id as the baseline, or no build at all, wait about 15 seconds and check artifact_status again, up to 4 more times. If a build with a NEW agent_id appears, that is the receipt.\n" +
1581
- "- If no new build appears, the receipt is null: the build may be pending_init-invisible, may have finished before the capture, or may be queued behind the earlier build. Return null — do NOT guess, and do NOT substitute the baseline build's agent_id.\n" +
1582
- "Make no other calls. Return JSON { \"edit_started\": <true if the edit was accepted, false otherwise>, \"build_agent_id\": <the receipt agent_id string, or null when no build could be attributed to this edit>, \"error\": \"<details or empty string>\", \"applied\": [{\"path\": \"<file path>\", \"added\": [\"<added lines>\"], \"removed\": [\"<removed lines>\"]}], \"pre_hashes\": {\"<file path>\": \"<sha256 of that file's content BEFORE you applied the diff, or \"MISSING\">\"} } and nothing else.";
1583
- var rebuildSchema =
1584
- { type: "object",
1585
- properties: {
1586
- edit_started: { type: "boolean" },
1587
- build_agent_id: {
1588
- type: ["string", "null"],
1589
- description: "Receipt-chained publish (2026-09-13): the platform build's in-flight correlation ID (build.agent_id from artifact_status) captured immediately after the edit was accepted — the receipt the follow-up poll chains to. Null when no build could be attributed to this edit. Required: an accepted edit with a null receipt parks fail-closed as unknown."
1590
- },
1591
- error: { type: "string" },
1592
- applied: {
1593
- type: "array",
1594
- items: {
1595
- type: "object",
1596
- properties: {
1597
- path: { type: "string" },
1598
- added: { type: "array", items: { type: "string" } },
1599
- removed: { type: "array", items: { type: "string" } }
1600
- },
1601
- required: ["path", "added", "removed"]
1602
- }
1603
- },
1604
- pre_hashes: {
1605
- type: "object",
1606
- description: "Diagnostic (2026-09-12): sha256 of each touched file's content BEFORE the builder applied the diff, as reported by the builder. Compared against the workflow-computed expected base hashes (merge parent) — observation only, never gating."
1607
- }
1608
- },
1609
- required: ["edit_started", "build_agent_id", "applied"] };
1610
- var rebuildTrigger = null;
1611
- var rebuildReportMissing = false; // true if the edit went through but the agent returned no applied report (structured-output failure) — the smoke-check is skipped; the parent's independent read-back is the verification
1612
- var rebuildEvidenceNote = null; // human-readable evidence line for the ledger when the edit is confirmed via fallback evidence (in-flight poll or durable audit dir) rather than the trigger's own report
1476
+ "- After applying, rebuild and deploy.'\n" +
1477
+ "Edit-request contract (read carefully):\n" +
1478
+ "- Call artifact_edit exactly once with the slug and verbatim_request above. Never retry the edit yourself: if the edit is not accepted, do NOT call artifact_edit again — end your turn.\n" +
1479
+ "- If artifact_edit is not available after the load, do NOT improvise — end your turn.\n" +
1480
+ "- You do NOT call setprovenance, artifact_inspect, or post-deploy yourself.\n" +
1481
+ "No report is needed: do not return JSON, do not summarize what you did, do not echo the diff. End your turn after the artifact_edit call.\n";
1613
1482
  // The trigger key of the attempt that last ran, for the publish ledger.
1614
1483
  // Minted once here (not re-minted per use site) so the ledger always
1615
1484
  // records the exact key that was issued — and so a re-minted duplicate
1616
1485
  // can never drift from it.
1617
1486
  var rebuildAttemptKey = attemptKey("publish-artifact-rebuild-" + taskId, reworkCount);
1618
- // The artifact build's agent_id, captured from artifact_status when the
1619
- // trigger's outcome is ambiguous (structured-output failure). The
1620
- // agent_id is the artifact system's in-flight correlation ID (not durable post-completion)
1621
- // (research 2026-09-12): artifact.edit returns pending_init with NO
1622
- // agent_id, but artifact_status exposes build.agent_id immediately
1623
- // after acceptance, stable across polls. Recorded in the ledger so an
1624
- // ambiguous attempt correlates to the exact builder run; null when no
1625
- // build was ever observed.
1487
+ // The artifact build's agent_id, attributed to this edit by the
1488
+ // workflow-owned observation below. The agent_id is the artifact
1489
+ // system's in-flight correlation ID (research 2026-09-12):
1490
+ // artifact.edit returns pending_init with NO agent_id, but
1491
+ // artifact_status exposes build.agent_id immediately after
1492
+ // acceptance, stable across polls. Recorded in the ledger so an
1493
+ // attempt correlates to the exact builder run; null when no build
1494
+ // was ever observed.
1626
1495
  var rebuildAgentId = null;
1627
- // The builder's applied-report is an observation, not a gate
1628
- // (2026-09-12, task 23ca8f3f): computed once the trigger outcome is
1629
- // known, logged loudly, never a park.
1630
- var publishAppliedObservation = null; // "match" | "mismatch: <reason>" | "missing-report" — observation only, never a park
1631
- // Durable-evidence snapshot (2026-09-14): the structured-output
1632
- // fallback below only observes IN-FLIGHT builds. A build that
1633
- // finished before the poll leaves no in-flight trace — but the
1634
- // platform's audit harness leaves a durable one:
1496
+ // The builder's applied report is gone (2026-09-16): it rode on the
1497
+ // trigger's JSON closeout contract, which is removed below. The
1498
+ // parent's independent read-back (docs/publish-verification.md) is
1499
+ // the verification — this field stays "missing-report" on every
1500
+ // ledger line the workflow writes.
1501
+ var publishAppliedObservation = "missing-report";
1502
+ // Durable-evidence snapshot (2026-09-14): the observation below only
1503
+ // detects IN-FLIGHT builds. A build that finished before the
1504
+ // observation leaves no in-flight trace — but the platform's audit
1505
+ // harness leaves a durable one:
1635
1506
  // ~/workspace/ts-spaces/<slug>/audits/<timestamp>-<id>/ per
1636
1507
  // completed build. Snapshot the listing BEFORE the trigger so the
1637
1508
  // fallback can diff before/after: a directory appearing during the
@@ -1654,238 +1525,219 @@ while (i < STEPS.length) {
1654
1525
  } catch (auditBeforeErr) {
1655
1526
  log("Publish audit-dir snapshot before trigger failed for task " + taskId + " (non-fatal, durable-evidence check degraded): " + (auditBeforeErr && auditBeforeErr.message ? auditBeforeErr.message : auditBeforeErr));
1656
1527
  }
1528
+ // Fire-and-forget trigger + workflow-owned observation (2026-09-16,
1529
+ // clean-room task e2a8d9f8): the trigger's JSON closeout contract
1530
+ // traveled over the stochastic text channel, and the runtime's
1531
+ // JSON-candidate heuristic misfired on it ("workflow agent output
1532
+ // was not JSON: no JSON object or array found in final response"),
1533
+ // parking a task whose edit may have gone through. The contract's
1534
+ // content was already observation-only (the applied report never
1535
+ // gated; the pre_hashes were diagnostic-only), so the contract is
1536
+ // removed: the trigger carries NO schema and its return value is
1537
+ // never consumed, which takes the extraction heuristic out of this
1538
+ // call entirely. The workflow attributes the edit itself through
1539
+ // the tiny schema'd reads below — no prose is parsed for the
1540
+ // trigger outcome.
1541
+ // (Probe, 2026-09-16: the workflow scope exposes only agent() —
1542
+ // tool_search, artifact_edit and artifact_status are undefined
1543
+ // there — so the workflow cannot call the artifact tools directly;
1544
+ // observation still goes through minimal child calls with tiny
1545
+ // schemas, never a broad JSON contract.)
1546
+ //
1547
+ // Pre-trigger toolcheck (tiny, schema'd): the artifact namespace is
1548
+ // deferred for workflow children — the child self-loads it and emits
1549
+ // one exact signal line, read mechanically (never English prose).
1550
+ // Explicit negative evidence (missing) gets one bounded retry with a
1551
+ // fresh key, then parks: without the tools the edit provably did NOT
1552
+ // go through, so this is the one safe retry on the publish path.
1553
+ var publishToolsOk = false;
1554
+ for (var toolcheckAttempt = 1; toolcheckAttempt <= 2 && !publishToolsOk; toolcheckAttempt++) {
1555
+ try {
1556
+ var toolcheckResult = await agent(
1557
+ "Check whether the artifact tool namespace is available.\n" +
1558
+ "Call tool_search.load_tool_namespace with paths [\"artifact\"].\n" +
1559
+ "Then emit exactly one line and nothing else: ARTIFACT_TOOLS: <ok if the load succeeded and artifact_edit and artifact_status are now functions, missing otherwise>.\n" +
1560
+ "Return JSON { \"signal\": \"<the exact ARTIFACT_TOOLS line>\" } and nothing else.",
1561
+ { key: attemptKey("publish-artifact-toolcheck-" + taskId + (toolcheckAttempt === 1 ? "" : "-retry2"), reworkCount),
1562
+ label: "Checking artifact tool availability" + (toolcheckAttempt === 1 ? "" : " (retry)"),
1563
+ schema: { type: "object", properties: { signal: { type: "string" } }, required: ["signal"] } }
1564
+ );
1565
+ publishToolsOk = /ARTIFACT_TOOLS:\s*ok/.test(String((toolcheckResult && toolcheckResult.signal) || ""));
1566
+ log("Publish artifact toolcheck for task " + taskId + " (attempt " + toolcheckAttempt + " of 2): " + (publishToolsOk ? "tools ok" : "tools missing"));
1567
+ } catch (toolcheckErr) {
1568
+ log("Publish artifact toolcheck for task " + taskId + " (attempt " + toolcheckAttempt + " of 2) failed (" + (toolcheckErr && toolcheckErr.message ? toolcheckErr.message : toolcheckErr) + ") — counted as missing for this attempt");
1569
+ }
1570
+ }
1571
+ if (!publishToolsOk) {
1572
+ await recordPublishLedger({
1573
+ commit: mergeCommitForPublish,
1574
+ attempt: rebuildAttemptKey,
1575
+ agent_id: null,
1576
+ applied_report: null,
1577
+ outcome: "rejected",
1578
+ detail: "artifact tool namespace missing in two toolcheck attempts (explicit negative evidence): the edit provably did not go through — no trigger issued, no blind retry"
1579
+ }, reworkCount);
1580
+ return await parkTask("Publish cannot proceed for task " + taskId + ": the artifact tool namespace was missing in two toolcheck attempts (explicit negative evidence — the edit provably did not go through, so no trigger was issued and nothing was retried blindly). Human attention needed.");
1581
+ }
1582
+ // Pre-trigger build-state baseline (tiny, schema'd): one read of
1583
+ // artifact_status. The post-trigger observation diffs against this
1584
+ // baseline — a build whose agent_id was absent from (or differs
1585
+ // from) the baseline is attributed to our edit; a build already in
1586
+ // flight at baseline predates the trigger and is never attributed
1587
+ // to it. If the baseline read itself fails, receipt attribution is
1588
+ // skipped and the durable audit-dir evidence below is the only
1589
+ // positive signal.
1590
+ var baselineAgentId = null;
1591
+ var baselineFailed = false;
1592
+ try {
1593
+ var publishBaseline = await agent(
1594
+ ARTIFACT_LOAD_PREAMBLE +
1595
+ "Call artifact_status with slug \"" + PUBLISH_SLUG + "\" once.\n" +
1596
+ "Return JSON { \"build\": <the raw \"build\" value exactly as returned, or null when there is none> } and nothing else.",
1597
+ { key: attemptKey("publish-artifact-baseline-" + taskId, reworkCount), label: "Reading pre-trigger build state",
1598
+ schema: { type: "object", properties: { build: { type: ["object", "null"] } }, required: ["build"] } }
1599
+ );
1600
+ baselineAgentId = (publishBaseline && publishBaseline.build && typeof publishBaseline.build.agent_id === "string" && publishBaseline.build.agent_id) || null;
1601
+ log("Publish pre-trigger baseline for task " + taskId + ": " + (baselineAgentId ? "build " + baselineAgentId + " already in flight (predates the trigger — never attributed to this edit)" : "no build in flight"));
1602
+ } catch (baselineErr) {
1603
+ baselineFailed = true;
1604
+ log("Publish pre-trigger baseline read failed for task " + taskId + " (" + (baselineErr && baselineErr.message ? baselineErr.message : baselineErr) + ") — receipt attribution skipped; durable audit-dir evidence is the only positive signal");
1605
+ }
1606
+ // The trigger itself: fire-and-forget transport for the
1607
+ // artifact_edit call. NO schema — the return value is not consumed,
1608
+ // so the runtime's JSON-candidate heuristic never runs on this
1609
+ // call. A transport throw is possible and inconclusive: the edit
1610
+ // may still have gone through, so the outcome stays unknown until
1611
+ // the observation below confirms it — never inferred from the
1612
+ // throw, and never blind-retried (a blind re-trigger duplicated the
1613
+ // edit on 2026-09-12).
1614
+ var rebuildTrigger = null;
1657
1615
  try {
1658
- rebuildTrigger = await agent(rebuildPrompt,
1659
- { key: rebuildAttemptKey, label: "Triggering artifact rebuild", schema: rebuildSchema });
1660
- } catch (rebuildErr) {
1661
- // Structured-output failure (canary run 9, 2026-09-11): the agent
1662
- // called artifact_edit (tool_call_count > 0) but returned prose
1663
- // instead of JSON. The side effect may have happened — the outcome
1664
- // is UNKNOWN, not "did not go through". The old code asked a child
1665
- // for derived booleans and retried on all-false; that check issued
1666
- // the DUPLICATE artifact_edit on 2026-09-12.
1667
- //
1668
- // Build-ID research (2026-09-12) corrected the model: artifact.edit
1669
- // returns pending_init with NO agent_id, but artifact_status exposes
1670
- // the build's agent_id (the artifact system's in-flight build
1671
- // correlation ID, stable across polls while the build runs)
1672
- // immediately after acceptance.
1673
- // So the recovery no longer asks the child to derive booleans —
1674
- // the layer where the 2026-09-12 signal was lost. It reads the RAW
1675
- // build object and extracts build.agent_id mechanically in the
1676
- // workflow script. An observed agent_id is positive evidence the
1677
- // edit went through; no build after a bounded poll is still
1678
- // inconclusive (unknown), never proof the edit failed. Mechanical
1679
- // rule: never blind-retry on unknown — record the attempt and park
1680
- // fail-closed; correlate via the ledger, never by re-issuing.
1681
- log("Publish rebuild trigger: structured-output failure (" + (rebuildErr && rebuildErr.message ? rebuildErr.message : rebuildErr) + ") — checking build state before deciding; outcome unknown until state confirms it");
1682
- var buildState = null;
1683
- var buildStateFailed = false;
1616
+ var triggerResultLength = String(await agent(rebuildPrompt,
1617
+ { key: rebuildAttemptKey, label: "Triggering artifact rebuild" }) || "").length;
1618
+ log("Publish rebuild trigger for task " + taskId + " returned (" + triggerResultLength + " chars, fire-and-forget: not consumed)");
1619
+ } catch (triggerErr) {
1620
+ log("Publish rebuild trigger for task " + taskId + " threw (" + (triggerErr && triggerErr.message ? triggerErr.message : triggerErr) + ") — outcome unknown until observation confirms it; the edit may have gone through");
1621
+ }
1622
+ // Post-trigger observation (primary, not fallback): the workflow
1623
+ // attributes the edit itself. First the in-flight build state — a
1624
+ // build whose agent_id is new relative to the pre-trigger baseline
1625
+ // is this edit's receipt. Then the durable audit-dir diff — a
1626
+ // timestamped directory appearing during the trigger window proves
1627
+ // the edit went through and the build completed even when no
1628
+ // in-flight build was ever observed (the 2026-09-14 attempt-7 gap).
1629
+ // Absence of both signals proves nothing: the outcome is UNKNOWN,
1630
+ // never "did not go through". No blind retry — record the attempt
1631
+ // and park fail-closed; correlate via the ledger, never by
1632
+ // re-issuing.
1633
+ log("Publish rebuild trigger issued for task " + taskId + " — observing build state to attribute the edit");
1634
+ var buildState = null;
1635
+ var buildStateFailed = false;
1636
+ try {
1637
+ buildState = await agent(
1638
+ ARTIFACT_LOAD_PREAMBLE +
1639
+ "Call artifact_status with slug \"" + PUBLISH_SLUG + "\".\n" +
1640
+ "Poll up to 3 times, about 20 seconds apart, until the response shows a build (the \"build\" value is an object, not null). " +
1641
+ "Return the raw \"build\" value verbatim as JSON — the build object exactly as returned, with its agent_id, operation, status, and any other fields untouched. " +
1642
+ "Do not summarize, interpret, or derive booleans from it. " +
1643
+ "If no build appears after 3 polls, return null. " +
1644
+ "Return JSON { \"build\": <the raw build object or null> } and nothing else.",
1645
+ { key: attemptKey("publish-artifact-buildcheck-" + taskId, reworkCount), label: "Reading artifact build state after trigger",
1646
+ schema: { type: "object", properties: { build: { type: ["object", "null"] } }, required: ["build"] } }
1647
+ );
1648
+ } catch (buildCheckErr) {
1649
+ buildStateFailed = true;
1650
+ log("Publish post-trigger build-state check failed for task " + taskId + " (" + (buildCheckErr && buildCheckErr.message ? buildCheckErr.message : buildCheckErr) + ") — this signal is unknown, not negative");
1651
+ }
1652
+ var observedAgentId = (buildState && buildState.build && typeof buildState.build.agent_id === "string" && buildState.build.agent_id) || null;
1653
+ var receiptAgentId = (!buildStateFailed && !baselineFailed && observedAgentId && observedAgentId !== baselineAgentId) ? observedAgentId : null;
1654
+ if (receiptAgentId) {
1655
+ // The edit went through — a build with a new agent_id appeared
1656
+ // after the trigger. The parent's independent read-back
1657
+ // (docs/publish-verification.md) is the verification, not any
1658
+ // builder report.
1659
+ rebuildTrigger = { edit_started: true };
1660
+ rebuildAgentId = receiptAgentId;
1661
+ log("Publish rebuild trigger for task " + taskId + ": artifact_status shows build " + receiptAgentId + " for slug " + PUBLISH_SLUG + " (new relative to the pre-trigger baseline) — the edit went through.");
1662
+ await recordPublishLedger({
1663
+ commit: mergeCommitForPublish,
1664
+ attempt: rebuildAttemptKey,
1665
+ agent_id: rebuildAgentId,
1666
+ applied_report: publishAppliedObservation,
1667
+ outcome: "submitted",
1668
+ detail: "fire-and-forget trigger; build receipt captured by workflow-owned build-state observation (pre/post-trigger diff)"
1669
+ }, reworkCount);
1670
+ } else {
1671
+ var newAuditDirs = [];
1684
1672
  try {
1685
- buildState = await agent(
1686
- ARTIFACT_LOAD_PREAMBLE +
1687
- "Call artifact_status with slug \"" + PUBLISH_SLUG + "\".\n" +
1688
- "Poll up to 3 times, about 20 seconds apart, until the response shows a build (the \"build\" value is an object, not null). " +
1689
- "Return the raw \"build\" value verbatim as JSON — the build object exactly as returned, with its agent_id, operation, status, and any other fields untouched. " +
1690
- "Do not summarize, interpret, or derive booleans from it. " +
1691
- "If no build appears after 3 polls, return null. " +
1692
- "Return JSON { \"build\": <the raw build object or null> } and nothing else.",
1693
- { key: attemptKey("publish-artifact-buildcheck-" + taskId, reworkCount), label: "Reading artifact build state after trigger failure",
1694
- schema: { type: "object", properties: { build: { type: ["object", "null"] } }, required: ["build"] } }
1673
+ var auditAfter = await agent(
1674
+ "List the artifact audit directories for slug \"" + PUBLISH_SLUG + "\" (best-effort, never a gate).\n" +
1675
+ "Run: ls -1 ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/ 2>/dev/null\n" +
1676
+ "Return JSON { \"dirs\": \"<newline-separated names, empty string when the audits directory does not exist or is empty>\" } and nothing else.",
1677
+ { key: attemptKey("publish-audit-after-" + taskId, reworkCount), label: "Re-listing audit dirs after trigger",
1678
+ schema: { type: "object", properties: { dirs: { type: "string" } }, required: ["dirs"] } }
1695
1679
  );
1696
- } catch (buildCheckErr) {
1697
- buildStateFailed = true;
1698
- log("Publish rebuild trigger: build-state check itself failed (" + (buildCheckErr && buildCheckErr.message ? buildCheckErr.message : buildCheckErr) + ") — treating the outcome as unknown");
1680
+ var auditDirsAfterTrigger = String((auditAfter && auditAfter.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
1681
+ // Only timestamped build dirs count — the "latest" symlink
1682
+ // and anything else are not builds.
1683
+ newAuditDirs = auditDirsAfterTrigger.filter(function (d) {
1684
+ return auditDirsBeforeTrigger.indexOf(d) === -1 && /^20\d\d-\d\d-\d\dT\d\d-\d\d-\d\dZ-/.test(d);
1685
+ });
1686
+ } catch (auditAfterErr) {
1687
+ log("Publish audit-dir re-list after trigger failed for task " + taskId + " (non-fatal, durable-evidence check degraded): " + (auditAfterErr && auditAfterErr.message ? auditAfterErr.message : auditAfterErr));
1699
1688
  }
1700
- var acceptedAgentId = (buildState && buildState.build && typeof buildState.build.agent_id === "string" && buildState.build.agent_id) || null;
1701
- if (!buildStateFailed && acceptedAgentId) {
1702
- // The edit went through — the agent just failed to return JSON.
1703
- // The build's agent_id is positive evidence: it appears in
1704
- // artifact_status immediately after our accepted edit (pending_init
1705
- // acceptance is followed by a visible build with a stable agent_id,
1706
- // per the 2026-09-12 research). No applied report to smoke-check;
1707
- // the parent's independent read-back (docs/publish-verification.md)
1708
- // is the real verification, not the circular applied-report. The
1709
- // agent_id is recorded in the ledger so this attempt correlates to
1710
- // the exact builder run, not just commit + attempt key.
1711
- log("Publish rebuild trigger: artifact_status shows build " + acceptedAgentId + " for slug " + PUBLISH_SLUG + " — the edit went through despite the structured-output failure. Skipping applied-report smoke-check; parent read-back is the verification.");
1712
- rebuildTrigger = { edit_started: true, error: "", applied: null };
1713
- rebuildReportMissing = true;
1714
- rebuildAgentId = acceptedAgentId;
1715
- rebuildEvidenceNote = "edit confirmed via build-state poll after structured-output failure (build " + acceptedAgentId + "); builder applied-report missing";
1716
- } else {
1717
- // Durable completion check (2026-09-14): the in-flight poll
1718
- // above only sees RUNNING builds. Attempt 7 (2026-09-14) proved
1719
- // the gap: the trigger child applied the edit, the build ran
1720
- // and completed — the platform's audit harness captured it
1721
- // mid-window — then the child failed to return JSON. The
1722
- // fallback poll saw no in-flight build, so a successful publish
1723
- // parked as "unknown". Diff the audit-dir listing against the
1724
- // pre-trigger snapshot: a timestamped directory that appeared
1725
- // during the trigger window is positive evidence the edit went
1726
- // through and the build completed. This never re-issues the
1727
- // edit and never stamps provenance — it only routes to the
1728
- // parent's independent content read-back, which remains the
1729
- // real verification.
1730
- var newAuditDirs = [];
1731
- try {
1732
- var auditAfter = await agent(
1733
- "List the artifact audit directories for slug \"" + PUBLISH_SLUG + "\" (best-effort, never a gate).\n" +
1734
- "Run: ls -1 ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/ 2>/dev/null\n" +
1735
- "Return JSON { \"dirs\": \"<newline-separated names, empty string when the audits directory does not exist or is empty>\" } and nothing else.",
1736
- { key: attemptKey("publish-audit-after-" + taskId, reworkCount), label: "Re-listing audit dirs after trigger failure",
1737
- schema: { type: "object", properties: { dirs: { type: "string" } }, required: ["dirs"] } }
1738
- );
1739
- var auditDirsAfterTrigger = String((auditAfter && auditAfter.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
1740
- // Only timestamped build dirs count — the "latest" symlink
1741
- // and anything else are not builds.
1742
- newAuditDirs = auditDirsAfterTrigger.filter(function (d) {
1743
- return auditDirsBeforeTrigger.indexOf(d) === -1 && /^20\d\d-\d\d-\d\dT\d\d-\d\d-\d\dZ-/.test(d);
1744
- });
1745
- } catch (auditAfterErr) {
1746
- log("Publish audit-dir re-list after trigger failure failed for task " + taskId + " (non-fatal, durable-evidence check degraded): " + (auditAfterErr && auditAfterErr.message ? auditAfterErr.message : auditAfterErr));
1747
- }
1748
- if (newAuditDirs.length > 0) {
1749
- log("Publish rebuild trigger: new audit dir(s) during the trigger window (" + newAuditDirs.join(", ") + ") — the edit went through and the build completed despite the structured-output failure. Skipping applied-report smoke-check; parent read-back is the verification.");
1750
- rebuildTrigger = { edit_started: true, error: "", applied: null };
1751
- rebuildReportMissing = true;
1752
- rebuildAgentId = null;
1753
- rebuildEvidenceNote = "edit confirmed via durable audit evidence after structured-output failure (new audit dir " + newAuditDirs[0] + "); builder applied-report missing";
1754
- } else {
1755
- // No build observed — but that proves nothing (a fast-completing
1756
- // build can finish between polls, or the check itself failed). The
1757
- // outcome is UNKNOWN. No retry: re-issuing the edit here duplicated
1758
- // it on 2026-09-12. Record the attempt durably and park fail-closed;
1759
- // correlate via the ledger, never by guessing from a blind poll.
1760
- log("Publish rebuild trigger: no build observed after structured-output failure — outcome UNKNOWN. Recording the attempt and parking fail-closed; no blind retry.");
1689
+ if (newAuditDirs.length > 0) {
1690
+ rebuildTrigger = { edit_started: true };
1691
+ rebuildAgentId = null;
1692
+ log("Publish rebuild trigger for task " + taskId + ": new audit dir(s) during the trigger window (" + newAuditDirs.join(", ") + ") — the edit went through and the build completed; no in-flight receipt was observed.");
1761
1693
  await recordPublishLedger({
1762
1694
  commit: mergeCommitForPublish,
1763
1695
  attempt: rebuildAttemptKey,
1764
1696
  agent_id: null,
1765
- applied_report: null,
1766
- outcome: "unknown",
1767
- detail: "structured-output failure on rebuild trigger; build-state poll saw no build (or the check itself failed); edit may have been accepted as pending_init"
1697
+ applied_report: publishAppliedObservation,
1698
+ outcome: "submitted",
1699
+ detail: "fire-and-forget trigger; edit confirmed via durable audit evidence (new audit dir " + newAuditDirs[0] + "); no in-flight receipt observed"
1768
1700
  }, reworkCount);
1769
- return await parkTask("Publish outcome unknown: the rebuild trigger's child did not return JSON, and the follow-up build-state poll could not observe a build for slug " + PUBLISH_SLUG + ". The edit may have been accepted as pending_init, so no retry was issued — a blind retry duplicated the edit on 2026-09-12. The attempt is recorded in the publish ledger at " + crewHome + "/.publish-ledger/" + PUBLISH_SLUG + ".jsonl (commit " + String(mergeCommitForPublish || "unknown").slice(0, 12) + "). Correlate the accepted edit via the ledger and the builder's eventual completion before re-driving Publish. Fail-closed.");
1770
- }
1771
- }
1772
- }
1773
- if (!rebuildReportMissing && !rebuildTrigger.edit_started && rebuildTrigger.error === "artifact_tools missing after load") {
1774
- log("Publish rebuild trigger: artifact_tools missing after load — one bounded retry with a fresh key");
1775
- rebuildTrigger = await agent(rebuildPrompt,
1776
- { key: attemptKey("publish-artifact-rebuild-" + taskId + "-retry2", reworkCount), label: "Triggering artifact rebuild (retry)", schema: rebuildSchema });
1777
- rebuildAttemptKey = attemptKey("publish-artifact-rebuild-" + taskId + "-retry2", reworkCount);
1778
- }
1779
- // Receipt chaining (2026-09-13): adopt the trigger's build receipt,
1780
- // or park on an uncorrelated acceptance. The trigger's closeout schema
1781
- // requires build_agent_id — the platform build's in-flight correlation
1782
- // ID captured immediately after the edit was accepted.
1783
- // An accepted edit (edit_started=true) with a null receipt is UNKNOWN,
1784
- // not "did not go through": the build may be pending_init-invisible,
1785
- // may have finished before the capture window, or may be queued behind
1786
- // a still-running earlier build. No re-trigger is issued on unknown —
1787
- // a blind re-trigger duplicated the edit on 2026-09-12, and the platform
1788
- // offers no idempotency proof that would make re-issue safe.
1789
- // (Retry-semantics reconciliation, 2026-09-13: the "no receipt → safe
1790
- // re-trigger" sketch assumed the edit command idempotently publishes
1791
- // what's on git; the duplicate-edit incident disproves the assumption,
1792
- // and the standing rule retries only on explicit negative evidence.
1793
- // Re-trigger stays exactly where it was: the edit_started=false
1794
- // explicit-rejection path above.) Record the attempt and park
1795
- // fail-closed; correlate via the ledger and the parent's content
1796
- // read-back before re-driving Publish.
1797
- if (rebuildTrigger && rebuildTrigger.edit_started && !rebuildReportMissing) {
1798
- var triggerAgentId = (typeof rebuildTrigger.build_agent_id === "string" && rebuildTrigger.build_agent_id.length > 0) ? rebuildTrigger.build_agent_id : null;
1799
- if (!triggerAgentId) {
1800
- var uncorrelatedObservation = (function () { var c = verifyAppliedChanges(expectedChanges, rebuildTrigger.applied); return c.ok ? "match" : "mismatch: " + c.reason; })();
1801
- log("Publish receipt missing for task " + taskId + ": the trigger reported edit_started=true but captured no build receipt (build_agent_id null) — no build attributable to this edit. Parking fail-closed without re-triggering.");
1701
+ } else {
1702
+ // No attributable build and no durable evidence — but that
1703
+ // proves nothing (a fast-completing build can finish between
1704
+ // polls, or the checks themselves failed). The outcome is
1705
+ // UNKNOWN. No retry: re-issuing the edit here duplicated it on
1706
+ // 2026-09-12. Record the attempt durably and park fail-closed;
1707
+ // correlate via the ledger, never by guessing from a blind poll.
1708
+ log("Publish rebuild trigger for task " + taskId + ": no attributable build observed and no new audit dir — outcome UNKNOWN. Recording the attempt and parking fail-closed; no blind retry.");
1802
1709
  await recordPublishLedger({
1803
1710
  commit: mergeCommitForPublish,
1804
1711
  attempt: rebuildAttemptKey,
1805
1712
  agent_id: null,
1806
- applied_report: uncorrelatedObservation,
1713
+ applied_report: null,
1807
1714
  outcome: "unknown",
1808
- detail: "edit accepted (edit_started=true) but the trigger captured no build receipt in its capture window: no build attributable to this edit (pending_init-invisible, finished before capture, or queued behind an earlier build). No re-trigger issued — a blind re-trigger on an unknown outcome duplicated the edit on 2026-09-12 and the platform offers no idempotency proof."
1715
+ detail: "fire-and-forget trigger; post-trigger build-state poll saw no attributable build (or the check failed) and the audit-dir diff found no new dir; the edit may have been accepted as pending_init"
1809
1716
  }, reworkCount);
1810
- return await parkTask("Publish outcome unknown: the rebuild trigger reported the edit was accepted but captured no build receipt (build_agent_id null) — no build could be attributed to this edit in the capture window. The edit may be pending_init-invisible, already finished, or queued behind an earlier build, so no re-trigger was issued: a blind retry duplicated the edit on 2026-09-12. The attempt is recorded in the publish ledger at " + crewHome + "/.publish-ledger/" + PUBLISH_SLUG + ".jsonl (commit " + String(mergeCommitForPublish || "unknown").slice(0, 12) + "). Correlate via the ledger and re-drive Publish only after the parent's content read-back resolves what actually landed. Fail-closed.");
1717
+ return await parkTask("Publish outcome unknown for task " + taskId + ": the rebuild trigger was issued fire-and-forget (no JSON closeout for the runtime heuristic to misfire on), and the follow-up observation could not attribute a build to the edit for slug " + PUBLISH_SLUG + " — no in-flight build with a new agent_id appeared in the poll window and no new audit dir landed. The edit may have been accepted as pending_init, so no retry was issued: a blind retry duplicated the edit on 2026-09-12. The attempt is recorded in the publish ledger at " + crewHome + "/.publish-ledger/" + PUBLISH_SLUG + ".jsonl (commit " + String(mergeCommitForPublish || "unknown").slice(0, 12) + "). Correlate the accepted edit via the ledger and the builder's eventual completion before re-driving Publish. Fail-closed.");
1811
1718
  }
1812
- rebuildAgentId = triggerAgentId;
1813
- log("Publish receipt chained for task " + taskId + ": build " + triggerAgentId + " — the follow-up poll waits on this build only.");
1814
1719
  }
1720
+
1815
1721
  // Durable publish-attempt ledger: record the trigger outcome while the
1816
1722
  // attempt key and commit are in scope. Every attempt lands here with
1817
1723
  // its outcome — submitted, rejected, or unknown (unknown is recorded
1818
1724
  // at the park site above). A later run or human matches commit hash +
1819
1725
  // attempt key against the builder's eventual completion.
1820
- if (rebuildTrigger && rebuildTrigger.edit_started) {
1821
- // Applied-report observation (2026-09-12, task 23ca8f3f): the
1822
- // builder's applied-report is logged as observation only — it
1823
- // never parks. The report is derived from the carried diff, so a
1824
- // "match" certifies nothing (canary run 8); and it has a
1825
- // demonstrated false-negative mode (applied:[] for a diff the
1826
- // builder had actually applied). The independent read-back below
1827
- // plus the parent protocol (docs/publish-verification.md) are the
1828
- // verification — this block always proceeds to them.
1829
- publishAppliedObservation = rebuildReportMissing
1830
- ? "missing-report"
1831
- : (function () { var c = verifyAppliedChanges(expectedChanges, rebuildTrigger.applied); return c.ok ? "match" : "mismatch: " + c.reason; })();
1832
- log("Publish applied-report observation for task " + taskId + ": " + publishAppliedObservation + " — observation only, never a park: the applied report is derived from the carried diff and proved unreliable in the false-negative direction (task 23ca8f3f, 2026-09-12: applied:[] for a diff the builder had applied). The independent read-back below plus the parent protocol are the verification.");
1833
- await recordPublishLedger({
1834
- commit: mergeCommitForPublish,
1835
- attempt: rebuildAttemptKey,
1836
- agent_id: rebuildAgentId,
1837
- applied_report: publishAppliedObservation,
1838
- outcome: "submitted",
1839
- detail: rebuildReportMissing
1840
- ? (rebuildEvidenceNote || "edit confirmed via build-state poll after structured-output failure (build " + (rebuildAgentId || "agent_id unknown") + "); builder applied-report missing")
1841
- : "edit accepted; builder applied-report received"
1842
- }, reworkCount);
1843
- } else if (rebuildTrigger) {
1844
- await recordPublishLedger({
1845
- commit: mergeCommitForPublish,
1846
- attempt: rebuildAttemptKey,
1847
- applied_report: null,
1848
- outcome: "rejected",
1849
- detail: "edit not accepted: " + (rebuildTrigger.error || "no error detail")
1850
- }, reworkCount);
1851
- }
1726
+ // (2026-09-16) The trigger is fire-and-forget: the observation above
1727
+ // already recorded the ledger's submitted line on both positive paths
1728
+ // and parked on unknown — there is no applied report to observe and
1729
+ // no rejection signal to record.
1852
1730
  var publishFailure = null;
1853
1731
  if (rebuildTrigger.edit_started) {
1854
- // STEP 1b (observation only): publishAppliedObservation was
1855
- // computed and logged above, inside the ledger block — the
1856
- // builder's applied-report never parks and never blocks the stamp.
1857
- // Task 23ca8f3f (2026-09-12) proved its false-negative mode:
1858
- // applied:[] for a diff the builder had actually applied, which
1859
- // parked a successful publish as unverified. A "match" certifies
1860
- // nothing either — the report is derived from the carried diff
1861
- // (canary run 8). The flow proceeds to the build poll and the
1862
- // independent read-back trigger regardless of what the report
1863
- // claimed; real verification is the parent's read-back
1864
- // (docs/publish-verification.md) before the provenance stamp.
1865
- // Pre-publish base observation (diagnostic, 2026-09-12): compare
1866
- // the builder's self-reported pre-edit hashes against the
1867
- // workflow-computed expected base (merge parent). This tells us
1868
- // what base state the publish actually read. OBSERVATION ONLY —
1869
- // a mismatch is logged loudly but never parks and never blocks
1870
- // the stamp. If the tree was dirty or drifted, the evidence is
1871
- // here; the fix (requiring the right base) comes after we see it.
1872
- try {
1873
- var preHashes = (rebuildTrigger && rebuildTrigger.pre_hashes) || {};
1874
- var baseLines = expectedChanges.map(function(f) {
1875
- var expected = expectedBaseHashes[f.path];
1876
- var actual = preHashes[f.path];
1877
- var expShort = (expected || "UNKNOWN").slice(0, 12);
1878
- var actShort = String(actual || "NOT-REPORTED").slice(0, 12);
1879
- var match = (expected !== undefined && actual !== undefined) ? (expected === actual) : "unknown";
1880
- return " " + f.path + ": expected_base=" + expShort + " builder_pre=" + actShort + " match=" + match;
1881
- });
1882
- var anyMismatch = expectedChanges.some(function(f) {
1883
- return expectedBaseHashes[f.path] !== undefined && preHashes[f.path] !== undefined && expectedBaseHashes[f.path] !== preHashes[f.path];
1884
- });
1885
- log("Publish pre-tree base observation for task " + taskId + (anyMismatch ? " — BASE MISMATCH DETECTED (tree was not at the expected merge-parent state when the diff was applied):" : " — base matches expected merge-parent state:") + "\n" + baseLines.join("\n"));
1886
- } catch (e) {
1887
- log("Publish pre-tree base observation failed for task " + taskId + " (non-fatal): " + (e && e.message ? e.message : e));
1888
- }
1732
+ // (2026-09-16) There is no builder report: the fire-and-forget
1733
+ // trigger carries no JSON contract, so there is nothing to
1734
+ // compare and no pre-hash diagnostic. The builder's old
1735
+ // self-report was circular by construction (canary run 8) with a
1736
+ // demonstrated false-negative mode (task 23ca8f3f, 2026-09-12:
1737
+ // applied:[] for a diff the builder had applied). The flow
1738
+ // proceeds to the build poll regardless; real verification is the
1739
+ // parent's independent read-back (docs/publish-verification.md)
1740
+ // before the provenance stamp.
1889
1741
  // STEP 1b (mechanical): bounded poll for build completion, chunked so
1890
1742
  // the merge-lock lease is refreshed before it can expire. The 600s
1891
1743
  // lease is shorter than the worst-case 10-minute build poll, so the
@@ -1973,9 +1825,9 @@ while (i < STEPS.length) {
1973
1825
  if (buildPoll.build_done && pollSawOurBuild) {
1974
1826
  // STEP 1c (mechanical): NO provenance stamp here. Canary run 8
1975
1827
  // (2026-09-11) proved the stamp cannot certify content: the
1976
- // builder's applied-report is derived from the carried diff, so
1977
- // verifyAppliedChanges above is circular — a fabricated report
1978
- // passes by construction, and every phase went green on a hollow
1828
+ // builder's applied-report was derived from the carried diff, so
1829
+ // the old report check was circular — a fabricated report
1830
+ // passed by construction, and every phase went green on a hollow
1979
1831
  // build. The stamp moves to the parent (docs/publish-verification.md);
1980
1832
  // the independent read-back step is currently unavailable (no
1981
1833
  // agent-callable read-back tool exists — artifact_inspect was
@@ -2099,7 +1951,9 @@ while (i < STEPS.length) {
2099
1951
  }
2100
1952
  }
2101
1953
  } else {
2102
- publishFailure = "Artifact rebuild trigger failed: " + (rebuildTrigger.error || "artifact_edit not accepted") + ". The publish did not land.";
1954
+ // Unreachable: the observation above either attributes the edit
1955
+ // (edit_started) or parks. Defensive only — never a silent pass.
1956
+ publishFailure = "Artifact rebuild trigger failed: the edit was not attributed to any observed build. The publish did not land.";
2103
1957
  }
2104
1958
  } // end: publishSkippedNoLock — no rebuild, no stamp, nothing to ship
2105
1959
  // STEP 2 (mechanical, always — skip path included): post-deploy