muse-crew 0.7.19 → 0.7.20

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.
@@ -1347,9 +1347,10 @@ while (i < STEPS.length) {
1347
1347
  // 2026-09-11), so the stamp moved to the parent — after the build
1348
1348
  // lands, the workflow records the session completed and parks with
1349
1349
  // "publish: verification-requested". The parent owns verification
1350
- // (docs/publish-verification.md); the independent read-back step is
1351
- // currently unavailable (no agent-callable read-back tool exists —
1352
- // artifact_inspect was removed by the platform 2026-09-14).
1350
+ // (docs/publish-verification.md); the primary sensor is the
1351
+ // deterministic lib/readback-disk.js (the agent-callable read-back
1352
+ // tool is unavailable — artifact_inspect was removed by the platform
1353
+ // 2026-09-14 — so the LLM-inspector path is manual-fallback only).
1353
1354
  // Chore has no QA: the parent's verification is the final gate.
1354
1355
  var artifactPublish = null;
1355
1356
  var publishLockRefreshed = false;
@@ -1496,8 +1497,10 @@ while (i < STEPS.length) {
1496
1497
  // The builder's applied report is gone (2026-09-16): it rode on the
1497
1498
  // trigger's JSON closeout contract, which is removed below. The
1498
1499
  // 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.
1500
+ // the verification — this field stays "missing-report" on ledger
1501
+ // lines for issued triggers; pre-trigger parks (toolcheck
1502
+ // rejected/inconclusive) and unattributed-unknown parks write null
1503
+ // (no trigger was observed, so there is nothing to report).
1501
1504
  var publishAppliedObservation = "missing-report";
1502
1505
  // Durable-evidence snapshot (2026-09-14): the observation below only
1503
1506
  // detects IN-FLIGHT builds. A build that finished before the
@@ -1508,10 +1511,13 @@ while (i < STEPS.length) {
1508
1511
  // fallback can diff before/after: a directory appearing during the
1509
1512
  // trigger window is positive evidence the edit went through and
1510
1513
  // the build completed. Best-effort and non-gating: if the snapshot
1511
- // fails, the durable check is skipped and the fallback behaves as
1512
- // before. No wall-clock in-script (deterministic replay) — the
1514
+ // fails, auditBeforeOk stays false and BOTH fallback comparisons
1515
+ // are disabled (2026-09-16, critic finding 4) — without a baseline,
1516
+ // an empty before-list would make every historical audit dir look
1517
+ // "new". No wall-clock in-script (deterministic replay) — the
1513
1518
  // comparison is a pure before/after set diff.
1514
1519
  var auditDirsBeforeTrigger = [];
1520
+ var auditBeforeOk = false;
1515
1521
  try {
1516
1522
  var auditBefore = await agent(
1517
1523
  "List the artifact audit directories for slug \"" + PUBLISH_SLUG + "\" (best-effort snapshot, never a gate).\n" +
@@ -1521,9 +1527,10 @@ while (i < STEPS.length) {
1521
1527
  schema: { type: "object", properties: { dirs: { type: "string" } }, required: ["dirs"] } }
1522
1528
  );
1523
1529
  auditDirsBeforeTrigger = String((auditBefore && auditBefore.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
1530
+ auditBeforeOk = true;
1524
1531
  log("Publish audit-dir snapshot before trigger for task " + taskId + ": " + auditDirsBeforeTrigger.length + " entries");
1525
1532
  } catch (auditBeforeErr) {
1526
- log("Publish audit-dir snapshot before trigger failed for task " + taskId + " (non-fatal, durable-evidence check degraded): " + (auditBeforeErr && auditBeforeErr.message ? auditBeforeErr.message : auditBeforeErr));
1533
+ log("Publish audit-dir snapshot before trigger failed for task " + taskId + " (non-fatal): audit fallback DISABLED for this attempt — without a baseline, historical dirs would look new: " + (auditBeforeErr && auditBeforeErr.message ? auditBeforeErr.message : auditBeforeErr));
1527
1534
  }
1528
1535
  // Fire-and-forget trigger + workflow-owned observation (2026-09-16,
1529
1536
  // clean-room task e2a8d9f8): the trigger's JSON closeout contract
@@ -1547,10 +1554,16 @@ while (i < STEPS.length) {
1547
1554
  // Pre-trigger toolcheck (tiny, schema'd): the artifact namespace is
1548
1555
  // deferred for workflow children — the child self-loads it and emits
1549
1556
  // 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.
1557
+ // Only a parsed ARTIFACT_TOOLS: missing signal is explicit negative
1558
+ // evidence: it gets one bounded retry with a fresh key, then parks
1559
+ // rejected — without the tools the edit provably did NOT go through,
1560
+ // so this is the one safe retry on the publish path. A throw (or an
1561
+ // unparseable signal) is INCONCLUSIVE transport noise, never
1562
+ // evidence of missing tools (2026-09-16, critic finding 3): it is
1563
+ // recorded, it retries once in case the flake clears, but it can
1564
+ // never take the rejected path.
1553
1565
  var publishToolsOk = false;
1566
+ var publishToolsMissing = false;
1554
1567
  for (var toolcheckAttempt = 1; toolcheckAttempt <= 2 && !publishToolsOk; toolcheckAttempt++) {
1555
1568
  try {
1556
1569
  var toolcheckResult = await agent(
@@ -1562,12 +1575,29 @@ while (i < STEPS.length) {
1562
1575
  label: "Checking artifact tool availability" + (toolcheckAttempt === 1 ? "" : " (retry)"),
1563
1576
  schema: { type: "object", properties: { signal: { type: "string" } }, required: ["signal"] } }
1564
1577
  );
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"));
1578
+ var toolSignal = String((toolcheckResult && toolcheckResult.signal) || "");
1579
+ if (/ARTIFACT_TOOLS:\s*ok/.test(toolSignal)) {
1580
+ publishToolsOk = true;
1581
+ } else if (/ARTIFACT_TOOLS:\s*missing/.test(toolSignal)) {
1582
+ publishToolsMissing = true;
1583
+ }
1584
+ log("Publish artifact toolcheck for task " + taskId + " (attempt " + toolcheckAttempt + " of 2): " +
1585
+ (publishToolsOk ? "tools ok" : publishToolsMissing ? "tools missing (explicit parsed signal)" : "inconclusive (no ARTIFACT_TOOLS signal parsed)"));
1567
1586
  } 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");
1587
+ log("Publish artifact toolcheck for task " + taskId + " (attempt " + toolcheckAttempt + " of 2) threw (" + (toolcheckErr && toolcheckErr.message ? toolcheckErr.message : toolcheckErr) + ") — inconclusive: a throw proves nothing about tool availability, never counted as missing");
1569
1588
  }
1570
1589
  }
1590
+ if (!publishToolsOk && !publishToolsMissing) {
1591
+ await recordPublishLedger({
1592
+ commit: mergeCommitForPublish,
1593
+ attempt: rebuildAttemptKey,
1594
+ agent_id: null,
1595
+ applied_report: null,
1596
+ outcome: "unknown",
1597
+ detail: "artifact toolcheck inconclusive after two attempts (throws or unparseable signals — never an explicit ARTIFACT_TOOLS: missing): tool availability unproven, so the trigger was NOT issued; unknown parks fail closed with no blind retry"
1598
+ }, reworkCount);
1599
+ return await parkTask("Publish cannot proceed for task " + taskId + ": the artifact toolcheck was inconclusive after two attempts (no explicit ARTIFACT_TOOLS signal parsed — a throw is transport noise, not evidence). Tool availability is unproven, so no edit was issued and nothing was retried blindly. Human attention needed.");
1600
+ }
1571
1601
  if (!publishToolsOk) {
1572
1602
  await recordPublishLedger({
1573
1603
  commit: mergeCommitForPublish,
@@ -1575,9 +1605,9 @@ while (i < STEPS.length) {
1575
1605
  agent_id: null,
1576
1606
  applied_report: null,
1577
1607
  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"
1608
+ detail: "artifact tool namespace explicitly missing (parsed ARTIFACT_TOOLS: missing signal, one bounded retry spent): the edit provably did not go through — no trigger issued, no blind retry"
1579
1609
  }, 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.");
1610
+ return await parkTask("Publish cannot proceed for task " + taskId + ": the artifact tool namespace was explicitly missing (parsed signal — the edit provably did not go through, so no trigger was issued and nothing was retried blindly). Human attention needed.");
1581
1611
  }
1582
1612
  // Pre-trigger build-state baseline (tiny, schema'd): one read of
1583
1613
  // artifact_status. The post-trigger observation diffs against this
@@ -1603,19 +1633,26 @@ while (i < STEPS.length) {
1603
1633
  baselineFailed = true;
1604
1634
  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
1635
  }
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).
1636
+ // The trigger itself: the artifact_edit call is AWAITED (the workflow
1637
+ // waits for it to complete) but its return value is intentionally
1638
+ // UNCONSUMED — NO schema, so no schema validation can fail this
1639
+ // call: a schema-less call resolves to the child's raw response as
1640
+ // a plain string (probed live 2026-09-16 — never parsed, never
1641
+ // throws on content). One caveat, also probed: the runtime still
1642
+ // scans the response for a JSON candidate, and an unparseable
1643
+ // {...}-looking substring in the child's prose throws ("response
1644
+ // JSON candidate", probe P6). The prompt tells the child to end its
1645
+ // turn with no prose at all, which keeps the common case clean —
1646
+ // but the channel is stochastic, so any throw is possible and
1647
+ // inconclusive: the edit may still have gone through, so the
1648
+ // outcome stays unknown until the observation below confirms it —
1649
+ // never inferred from the throw, and never blind-retried (a blind
1650
+ // re-trigger duplicated the edit on 2026-09-12).
1614
1651
  var rebuildTrigger = null;
1615
1652
  try {
1616
1653
  var triggerResultLength = String(await agent(rebuildPrompt,
1617
1654
  { key: rebuildAttemptKey, label: "Triggering artifact rebuild" }) || "").length;
1618
- log("Publish rebuild trigger for task " + taskId + " returned (" + triggerResultLength + " chars, fire-and-forget: not consumed)");
1655
+ log("Publish rebuild trigger for task " + taskId + " returned (" + triggerResultLength + " chars; awaited but return intentionally unconsumed)");
1619
1656
  } catch (triggerErr) {
1620
1657
  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
1658
  }
@@ -1650,6 +1687,16 @@ while (i < STEPS.length) {
1650
1687
  log("Publish post-trigger build-state check failed for task " + taskId + " (" + (buildCheckErr && buildCheckErr.message ? buildCheckErr.message : buildCheckErr) + ") — this signal is unknown, not negative");
1651
1688
  }
1652
1689
  var observedAgentId = (buildState && buildState.build && typeof buildState.build.agent_id === "string" && buildState.build.agent_id) || null;
1690
+ // Known limitation (failure-mode audit 2026-09-16): attribution
1691
+ // is timing-based — any agent_id new relative to the baseline is
1692
+ // treated as this edit's receipt. A stranger's build starting inside
1693
+ // the trigger window is indistinguishable by timing and would be
1694
+ // misattributed here. The consequence is bounded: the completion
1695
+ // poll below tracks the recorded id, and the parent's mechanical
1696
+ // content read-back (docs/publish-verification.md) certifies the
1697
+ // exact commit's content — a wrong build's content fails closed as
1698
+ // verification-failed, never stamped. Timing narrows the candidate;
1699
+ // content decides.
1653
1700
  var receiptAgentId = (!buildStateFailed && !baselineFailed && observedAgentId && observedAgentId !== baselineAgentId) ? observedAgentId : null;
1654
1701
  if (receiptAgentId) {
1655
1702
  // The edit went through — a build with a new agent_id appeared
@@ -1669,6 +1716,31 @@ while (i < STEPS.length) {
1669
1716
  }, reworkCount);
1670
1717
  } else {
1671
1718
  var newAuditDirs = [];
1719
+ // auditReportOk: pure tri-state read of a report.json body —
1720
+ // true (build ok), false (build failed), null (missing or
1721
+ // unreadable — not evidence either way). The child returns the
1722
+ // raw body verbatim; interpretation lives here, never in prose.
1723
+ // Defined here so both the immediate and post-poll audit
1724
+ // fallbacks share it.
1725
+ var auditReportOk = function (raw) {
1726
+ if (typeof raw !== "string") return null;
1727
+ var trimmed = raw.trim();
1728
+ if (trimmed === "" || trimmed === "MISSING") return null;
1729
+ var parsed;
1730
+ try { parsed = JSON.parse(trimmed); } catch (e) { return null; }
1731
+ if (parsed && typeof parsed.ok === "boolean") return parsed.ok;
1732
+ return null;
1733
+ };
1734
+ // (2026-09-16, critic finding 2) When durable audit evidence
1735
+ // confirms (or refutes) the build, there is no receipt agent_id
1736
+ // to chain the completion poll to — skipReceiptPoll bypasses the
1737
+ // poll below, which with a null receipt could only observe
1738
+ // strangers or nothing.
1739
+ var skipReceiptPoll = false;
1740
+ // publishFailure is declared here (moved up from below) so the
1741
+ // immediate audit fallback can record an explicit build failure
1742
+ // without the later declaration resetting it.
1743
+ var publishFailure = null;
1672
1744
  try {
1673
1745
  var auditAfter = await agent(
1674
1746
  "List the artifact audit directories for slug \"" + PUBLISH_SLUG + "\" (best-effort, never a gate).\n" +
@@ -1679,25 +1751,77 @@ while (i < STEPS.length) {
1679
1751
  );
1680
1752
  var auditDirsAfterTrigger = String((auditAfter && auditAfter.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
1681
1753
  // Only timestamped build dirs count — the "latest" symlink
1682
- // and anything else are not builds.
1683
- newAuditDirs = auditDirsAfterTrigger.filter(function (d) {
1754
+ // and anything else are not builds. Gated on auditBeforeOk:
1755
+ // without a baseline every historical dir would look new.
1756
+ newAuditDirs = auditBeforeOk ? auditDirsAfterTrigger.filter(function (d) {
1684
1757
  return auditDirsBeforeTrigger.indexOf(d) === -1 && /^20\d\d-\d\d-\d\dT\d\d-\d\d-\d\dZ-/.test(d);
1685
- });
1758
+ }) : [];
1686
1759
  } catch (auditAfterErr) {
1687
1760
  log("Publish audit-dir re-list after trigger failed for task " + taskId + " (non-fatal, durable-evidence check degraded): " + (auditAfterErr && auditAfterErr.message ? auditAfterErr.message : auditAfterErr));
1688
1761
  }
1689
1762
  if (newAuditDirs.length > 0) {
1690
1763
  rebuildTrigger = { edit_started: true };
1691
1764
  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.");
1693
- await recordPublishLedger({
1694
- commit: mergeCommitForPublish,
1695
- attempt: rebuildAttemptKey,
1696
- agent_id: null,
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"
1700
- }, reworkCount);
1765
+ newAuditDirs.sort();
1766
+ var newestImmediateDir = newAuditDirs[newAuditDirs.length - 1];
1767
+ log("Publish rebuild trigger for task " + taskId + ": new audit dir(s) during the trigger window (" + newAuditDirs.join(", ") + ") — the edit went through and a build completed; no in-flight receipt was observed.");
1768
+ // (2026-09-16, critic finding 2) Durable audit evidence exists,
1769
+ // but there is no receipt agent_id to chain the completion poll
1770
+ // to — polling with a null receipt can only observe strangers
1771
+ // (any running build differs from "null") or nothing, burning
1772
+ // 10.5 minutes to park unknown. Read the build report now
1773
+ // instead of polling: ok=true confirms completion and routes
1774
+ // directly to parent verification (the poll is skipped);
1775
+ // ok=false is explicit failure; unreadable is unknown.
1776
+ var immediateReportOk = null;
1777
+ try {
1778
+ var immediateOkRead = await agent(
1779
+ "Read the artifact build report for slug \"" + PUBLISH_SLUG + "\".\n" +
1780
+ "Run: cat ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/" + newestImmediateDir + "/report.json 2>/dev/null || echo MISSING\n" +
1781
+ "Return JSON { \"raw\": \"<verbatim file contents, or the literal string MISSING when the file does not exist>\" } and nothing else.",
1782
+ { key: attemptKey("publish-audit-ok-immediate-" + taskId, reworkCount), label: "Reading build report for audit-confirmed build",
1783
+ schema: { type: "object", properties: { raw: { type: "string" } }, required: ["raw"] } }
1784
+ );
1785
+ immediateReportOk = auditReportOk(immediateOkRead && immediateOkRead.raw);
1786
+ } catch (immediateOkErr) {
1787
+ log("Publish build-report read for audit-confirmed dir failed for task " + taskId + " (treated as unknown): " + (immediateOkErr && immediateOkErr.message ? immediateOkErr.message : immediateOkErr));
1788
+ immediateReportOk = null;
1789
+ }
1790
+ if (immediateReportOk === true) {
1791
+ publishBuildLanded = true;
1792
+ artifactPublish = { source_commit: mergeCommitForPublish, pending_parent_verification: true };
1793
+ skipReceiptPoll = true;
1794
+ log("Publish build landed for task " + taskId + " via immediate durable audit evidence (audit dir " + newestImmediateDir + ", report ok=true) — receipt poll skipped (no receipt to chain to), routing directly to parent verification");
1795
+ await recordPublishLedger({
1796
+ commit: mergeCommitForPublish,
1797
+ attempt: rebuildAttemptKey,
1798
+ agent_id: null,
1799
+ applied_report: publishAppliedObservation,
1800
+ outcome: "submitted",
1801
+ detail: "durable audit evidence shows a build completed during the attempt window (audit dir " + newestImmediateDir + ", report ok=true); receipt poll skipped (no receipt agent_id), routed to parent verification"
1802
+ }, reworkCount);
1803
+ } else if (immediateReportOk === false) {
1804
+ skipReceiptPoll = true;
1805
+ publishFailure = "Artifact build FAILED for slug " + PUBLISH_SLUG + " (audit dir " + newestImmediateDir + ", report ok=false — immediate audit evidence, no receipt observed). Explicit negative evidence: a build ran and failed. The publish did not land — provenance was not stamped. Fail-closed.";
1806
+ await recordPublishLedger({
1807
+ commit: mergeCommitForPublish,
1808
+ attempt: rebuildAttemptKey,
1809
+ agent_id: null,
1810
+ applied_report: publishAppliedObservation,
1811
+ outcome: "failed",
1812
+ detail: "a build ran and failed: audit dir " + newestImmediateDir + " report ok=false (immediate audit evidence, no receipt)"
1813
+ }, reworkCount);
1814
+ } else {
1815
+ await recordPublishLedger({
1816
+ commit: mergeCommitForPublish,
1817
+ attempt: rebuildAttemptKey,
1818
+ agent_id: null,
1819
+ applied_report: null,
1820
+ outcome: "unknown",
1821
+ detail: "new audit dir " + newestImmediateDir + " appeared during the trigger window but its build report is unreadable/missing; no receipt agent_id to poll — outcome unknown, fail-closed with no blind retry"
1822
+ }, reworkCount);
1823
+ return await parkTask("Publish outcome unknown for task " + taskId + ": a new audit dir (" + newestImmediateDir + ") appeared during the trigger window but its build report is unreadable, and no in-flight receipt was observed to poll. The edit may have completed. Correlate the accepted edit via the publish ledger at " + crewHome + "/.publish-ledger/" + PUBLISH_SLUG + ".jsonl — do NOT reissue the edit blindly: if the trigger was accepted, a retry duplicates it (2026-09-12). Verify independently whether the build completed (audit dir + report, or the parent's content read-back) before deciding the next step. Fail-closed.");
1824
+ }
1701
1825
  } else {
1702
1826
  // No attributable build and no durable evidence — but that
1703
1827
  // proves nothing (a fast-completing build can finish between
@@ -1714,7 +1838,7 @@ while (i < STEPS.length) {
1714
1838
  outcome: "unknown",
1715
1839
  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"
1716
1840
  }, reworkCount);
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.");
1841
+ return await parkTask("Publish outcome unknown for task " + taskId + ": the rebuild trigger was issued fire-and-forget (no schema, so no validation failure mode; a candidate-parse throw stays possible and is inconclusive), 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 — do NOT reissue the edit blindly. Verify independently whether the build completed before deciding the next step. Fail-closed.");
1718
1842
  }
1719
1843
  }
1720
1844
 
@@ -1727,8 +1851,9 @@ while (i < STEPS.length) {
1727
1851
  // already recorded the ledger's submitted line on both positive paths
1728
1852
  // and parked on unknown — there is no applied report to observe and
1729
1853
  // no rejection signal to record.
1730
- var publishFailure = null;
1731
- if (rebuildTrigger.edit_started) {
1854
+ // (publishFailure is declared with the immediate audit fallback
1855
+ // above so an explicit build failure there survives to here.)
1856
+ if (rebuildTrigger.edit_started && !skipReceiptPoll) {
1732
1857
  // (2026-09-16) There is no builder report: the fire-and-forget
1733
1858
  // trigger carries no JSON contract, so there is nothing to
1734
1859
  // compare and no pre-hash diagnostic. The builder's old
@@ -1829,11 +1954,14 @@ while (i < STEPS.length) {
1829
1954
  // the old report check was circular — a fabricated report
1830
1955
  // passed by construction, and every phase went green on a hollow
1831
1956
  // build. The stamp moves to the parent (docs/publish-verification.md);
1832
- // the independent read-back step is currently unavailable (no
1833
- // agent-callable read-back tool exists — artifact_inspect was
1834
- // removed by the platform 2026-09-14), so the parent cannot
1835
- // confirm content and the task parks for verification.
1957
+ // the deterministic lib/readback-disk.js is the primary sensor
1958
+ // (the agent-callable read-back tool is unavailable —
1959
+ // artifact_inspect was removed by the platform 2026-09-14 — so
1960
+ // the LLM-inspector path is manual-fallback only), and the task
1961
+ // parks for parent verification.
1836
1962
  // Chore has no QA: the parent's verification is the final gate.
1963
+ // An unverified publish fails loudly in QA instead of passing
1964
+ // silently here.
1837
1965
  publishBuildLanded = true;
1838
1966
  artifactPublish = { source_commit: mergeCommitForPublish, pending_parent_verification: true };
1839
1967
  log("Publish build landed for task " + taskId + " — provenance stamp deferred to parent content verification");
@@ -1873,26 +2001,17 @@ while (i < STEPS.length) {
1873
2001
  schema: { type: "object", properties: { dirs: { type: "string" } }, required: ["dirs"] } }
1874
2002
  );
1875
2003
  var auditDirsAfterPollList = String((auditAfterPoll && auditAfterPoll.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
1876
- newAuditDirsAfterPoll = auditDirsAfterPollList.filter(function (d) {
2004
+ // Gated on auditBeforeOk (critic finding 4): without a baseline
2005
+ // every historical dir would look new.
2006
+ newAuditDirsAfterPoll = auditBeforeOk ? auditDirsAfterPollList.filter(function (d) {
1877
2007
  return auditDirsBeforeTrigger.indexOf(d) === -1 && /^20\d\d-\d\d-\d\dT\d\d-\d\d-\d\dZ-/.test(d);
1878
- });
2008
+ }) : [];
1879
2009
  log("Publish audit-dir re-list after build poll for task " + taskId + ": " + newAuditDirsAfterPoll.length + " new timestamped dir(s)");
1880
2010
  } catch (auditAfterPollErr) {
1881
2011
  log("Publish audit-dir re-list after build poll failed for task " + taskId + " (non-fatal, durable-evidence check degraded): " + (auditAfterPollErr && auditAfterPollErr.message ? auditAfterPollErr.message : auditAfterPollErr));
1882
2012
  }
1883
- // auditReportOk: pure tri-state read of a report.json body —
1884
- // true (build ok), false (build failed), null (missing or
1885
- // unreadable — not evidence either way). The child returns the
1886
- // raw body verbatim; interpretation lives here, never in prose.
1887
- var auditReportOk = function (raw) {
1888
- if (typeof raw !== "string") return null;
1889
- var trimmed = raw.trim();
1890
- if (trimmed === "" || trimmed === "MISSING") return null;
1891
- var parsed;
1892
- try { parsed = JSON.parse(trimmed); } catch (e) { return null; }
1893
- if (parsed && typeof parsed.ok === "boolean") return parsed.ok;
1894
- return null;
1895
- };
2013
+ // The shared auditReportOk (defined with the immediate fallback
2014
+ // above) interprets the raw body here too.
1896
2015
  var auditOkAfterPoll = null;
1897
2016
  var newestAuditDirAfterPoll = null;
1898
2017
  if (newAuditDirsAfterPoll.length > 0 && !strangerObserved) {
@@ -1953,7 +2072,7 @@ while (i < STEPS.length) {
1953
2072
  } else {
1954
2073
  // Unreachable: the observation above either attributes the edit
1955
2074
  // (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.";
2075
+ publishFailure = "Artifact rebuild trigger failed: the edit was not attributed to any observed build. The publish is unattributed (not proven landed, not proven failed) — provenance was not stamped. Fail-closed.";
1957
2076
  }
1958
2077
  } // end: publishSkippedNoLock — no rebuild, no stamp, nothing to ship
1959
2078
  // STEP 2 (mechanical, always — skip path included): post-deploy