muse-crew 0.14.4 → 0.14.6

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.
@@ -296,14 +296,6 @@ var TOOL_CHECK_PREAMBLE =
296
296
  "2. Write exactly one line: artifact_tools: ok - or artifact_tools: missing if the call failed or the tool does not exist.\n" +
297
297
  "3. Run the shell command: echo tool-probe-ok - then write exactly one line: shell_transport: ok - or shell_transport: unavailable if you cannot run shell commands.\n" +
298
298
  "Then do the assignment below.\n\n";
299
- // ARTIFACT_LOAD_PREAMBLE - the one-line load instruction that precedes every
300
- // special-purpose prompt calling artifact tools (rebuild trigger, provenance
301
- // stamp, publish verification). The artifact tool namespace is deferred for
302
- // workflow children: present but invisible until the child loads it via
303
- // tool_search.load_tool_namespace (bug 3472bf36 root cause). Byte-identical
304
- // across standard/bugfix/chore - pinned by tests/artifact-tools.test.js.
305
- var ARTIFACT_LOAD_PREAMBLE =
306
- "First call tool_search.load_tool_namespace with paths [\"artifact\"] - the artifact tool namespace is deferred and invisible until loaded.\n";
307
299
  function buildTransportRetryTrailer(stepName, repoPath, taskId, attempt, reason) {
308
300
  // reason: "discarded" (the runtime threw the output away - it could not be
309
301
  // machine-read), "empty" (agent() returned without throwing but produced
@@ -451,10 +443,10 @@ function hydrateReleaseDecision(rec) {
451
443
  }
452
444
 
453
445
  // See docs/decisions/publish-path.md#publish-attempt-ledger: every trigger outcome is recorded in the durable ledger.
454
- // keyTag (optional): same-outcome ledger writes in one pass need distinct
455
- // agent-call keys — the runtime replays cached calls by key, so a shared key
456
- // silently drops the second write (2026-09-19, submitted-on-issuance).
457
- async function recordPublishLedger(entry, rework, keyTag) {
446
+ // (2026-09-20, one-party worker-owned publish) No keyTag: every ledger
447
+ // write in a Publish pass is followed by a return, so no pass can write two
448
+ // same-outcome entries — the runtime replay key can never collide in-pass.
449
+ async function recordPublishLedger(entry, rework) {
458
450
  try {
459
451
  var ledgerDir = crewHome + "/.publish-ledger";
460
452
  var line = JSON.stringify({
@@ -472,6 +464,20 @@ async function recordPublishLedger(entry, rework, keyTag) {
472
464
  // D1 (2026-09-19): issued_at = upper bound on the trigger-issuance
473
465
  // instant (null when no trigger); ts = ledger-write instant.
474
466
  issued_at: entry.issued_at || null,
467
+ // (2026-09-20, one-party worker-owned publish) issuer = which party
468
+ // wrote the entry ("workflow" for the intent entry, "tick-worker" for
469
+ // the worker's own issuance); diff_path/diff_sha256 locate the
470
+ // checksummed diff the worker issues. The workflow never writes an
471
+ // issuance ("submitted") entry — it did not issue.
472
+ issuer: entry.issuer || null,
473
+ diff_path: entry.diff_path || null,
474
+ diff_sha256: entry.diff_sha256 || null,
475
+ base: entry.base || null,
476
+ // (0.14.6) Numeric publication attempt + the attempt's deterministic
477
+ // version. Attempt 1 is staged here by the workflow; attempts 2-3 are
478
+ // staged by scan-ack-pending's re-issue path with fresh versions.
479
+ publish_attempt: entry.publish_attempt || null,
480
+ version: entry.version || null,
475
481
  });
476
482
  var sq = function(s) { return "'" + String(s).split("'").join("'\\''") + "'"; };
477
483
  var res = await agent(
@@ -479,13 +485,19 @@ async function recordPublishLedger(entry, rework, keyTag) {
479
485
  "Run: mkdir -p " + sq(ledgerDir) + " && printf '%s\n' " + sq(line) +
480
486
  " | sed \"s/@LEDGER_TS@/$(date -u +%Y-%m-%dT%H:%M:%SZ)/\" >> " + sq(ledgerDir + "/" + PUBLISH_SLUG + ".jsonl") + " && echo LEDGER_OK\n" +
481
487
  "Return JSON { \"result\": \"<verbatim output>\" } and nothing else.",
482
- { key: attemptKey("publish-ledger-" + taskId + "-" + entry.outcome + (keyTag ? "-" + keyTag : ""), rework),
488
+ { key: attemptKey("publish-ledger-" + taskId + "-" + entry.outcome, rework),
483
489
  label: "Recording publish attempt in ledger",
484
490
  schema: { type: "object", properties: { result: { type: "string" } }, required: ["result"] } }
485
491
  );
486
- log("Noted publish outcome '" + entry.outcome + "' for task " + taskId + " in ledger");
492
+ // (2026-09-20 REVIEW) The intent entry is the machine's anchor — the
493
+ // caller gates on this return. LEDGER_OK in the agent's verbatim output
494
+ // is the only mechanical proof the line landed.
495
+ var ok = res && typeof res.result === "string" && res.result.indexOf("LEDGER_OK") !== -1;
496
+ log("Noted publish outcome '" + entry.outcome + "' for task " + taskId + " in ledger" + (ok ? "" : " (WRITE UNCONFIRMED)"));
497
+ return ok;
487
498
  } catch (e) {
488
499
  log("Publish ledger: write failed for task " + taskId + " (non-fatal, observability only): " + (e && e.message ? e.message : e));
500
+ return false;
489
501
  }
490
502
  }
491
503
 
@@ -511,11 +523,6 @@ function extractAlreadyMerged(workerText) {
511
523
  return m ? { sha: m[1].toLowerCase() } : { sha: null };
512
524
  }
513
525
 
514
- // See docs/decisions/publish-path.md#refusal-signal: the refusal signal must be the ENTIRE trimmed turn output.
515
- function extractRefusal(workerText) {
516
- var m = /^ARTIFACT_EDIT_REFUSED:\s*(.+?)\s*$/.exec(String(workerText || "").trim());
517
- return m ? m[1].slice(0, 300) : null;
518
- }
519
526
 
520
527
  // See docs/decisions/qa-reproduce.md#worktree-confinement: the Build agent must declare its worktree.
521
528
  function extractWorktree(workerText) {
@@ -1225,10 +1232,41 @@ while (i < STEPS.length) {
1225
1232
  "VERDICT: PASS\n\n";
1226
1233
  } else if (PUBLISH_TYPE === "artifact") {
1227
1234
  // See docs/decisions/publish-path.md#deterministic-artifact-publish: the work agent never publishes; the parent runs the deterministic publish script.
1228
- var artifactPublish = null;
1235
+ // Blocker 22 (one-party publish, room #24): verified re-entry guard.
1236
+ // The workflow parks at publish intent; the tick worker issues
1237
+ // artifact_edit, verifies by read-back, stamps provenance, and
1238
+ // re-queues. The dispatcher resumes this task at the Publish step
1239
+ // (the parked session's own step — the failed→retry path). If the
1240
+ // stamped provenance names THIS task and its source_commit is the
1241
+ // repo's current HEAD, the merge commit was already published and
1242
+ // verified by the parent: issuance is skipped entirely (the
1243
+ // empty-diff park below must NOT fire on this branch) and the
1244
+ // Publish work agent runs with the verified framing instead. A guard
1245
+ // failure never claims verification — it proceeds down the normal path.
1246
+ var publishAlreadyVerified = false;
1247
+ try {
1248
+ var reentryCheck = await agent(
1249
+ "Run in shell and return the stdout verbatim:\n" + crewCmd("get-provenance", { project_id: LAUNCH_PROJECT_ID }) + "\n" +
1250
+ "Then run in shell and return the stdout verbatim: cd " + REPO_PATH + " && git rev-parse HEAD\n" +
1251
+ "Return JSON { \"source_commit\": \"<provenance.source_commit, empty string when null>\", \"stamp_task_id\": \"<provenance.task_id, empty string when null>\", \"head\": \"<the rev-parse output, trimmed>\" } and nothing else.",
1252
+ { key: attemptKey("publish-reentry-guard-" + taskId, reworkCount), label: "Checking for a verified publish re-entry",
1253
+ schema: { type: "object", properties: { source_commit: { type: "string" }, stamp_task_id: { type: "string" }, head: { type: "string" } }, required: ["source_commit", "stamp_task_id", "head"] } }
1254
+ );
1255
+ var reentrySC = String((reentryCheck && reentryCheck.source_commit) || "").trim();
1256
+ var reentryTID = String((reentryCheck && reentryCheck.stamp_task_id) || "").trim();
1257
+ var reentryHEAD = String((reentryCheck && reentryCheck.head) || "").trim();
1258
+ if (reentrySC && reentryHEAD && reentrySC === reentryHEAD && reentryTID === taskId) {
1259
+ publishAlreadyVerified = true;
1260
+ log("Publish verified re-entry for task " + taskId + ": provenance stamps " + reentrySC + " == HEAD for this task — the parent already published and verified it; issuance skipped");
1261
+ }
1262
+ } catch (reentryErr) {
1263
+ log("Publish re-entry guard threw for task " + taskId + " (" + (reentryErr && reentryErr.message ? reentryErr.message : reentryErr) + ") — proceeding with the normal publish path; a guard failure never claims verification");
1264
+ }
1265
+ // publishAlreadyVerified is consumed by the intent-tail edit (next
1266
+ // chunk): on the verified branch the workflow skips to the Publish
1267
+ // work agent with the verified framing and proceeds to QA.
1229
1268
  var publishLockRefreshed = false;
1230
1269
  var publishSkippedNoLock = false;
1231
- var publishBuildLanded = false; // true once the artifact build poll completes: content exists to verify; the provenance stamp is deferred to the parent (docs/publish-verification.md)
1232
1270
  try {
1233
1271
  // STEP 0 (mechanical): read the merge-lock state explicitly — never
1234
1272
  // infer it from prose. An empty-diff Integrate (MERGED_EMPTY)
@@ -1252,7 +1290,11 @@ while (i < STEPS.length) {
1252
1290
  publishLockRefreshed = true;
1253
1291
  }
1254
1292
  // See docs/decisions/publish-path.md#step1-builder-source: the builder's source tree is NOT the crew's repo; verify report before stamping.
1255
- if (!publishSkippedNoLock) {
1293
+ // (2026-09-20, one-party worker-owned publish) A verified re-entry
1294
+ // skips the whole issuance tail: the edit already went out, was
1295
+ // verified by the parent read-back, and was stamped. The empty-diff
1296
+ // park must not fire on this branch.
1297
+ if (!publishSkippedNoLock && !publishAlreadyVerified) {
1256
1298
  // The trigger key of the attempt that last ran, for the publish ledger.
1257
1299
  // Minted once here (not re-minted per use site) so the ledger always
1258
1300
  // records the exact key that was issued — and so a re-minted duplicate
@@ -1352,7 +1394,7 @@ while (i < STEPS.length) {
1352
1394
  var publishDiffFile = crewHome + "/.publish-diffs/" + taskId + (reworkCount > 0 ? "-r" + reworkCount : "") + ".diff";
1353
1395
  var diffResult = await agent(
1354
1396
  "Run exactly one command and nothing else:\n" +
1355
- "node " + COMPUTE_DIFF + " --repo-path \"" + REPO_PATH + "\" --base " + publishBase + " --out \"" + publishDiffFile + "\"\n" +
1397
+ "node " + COMPUTE_DIFF + " --repo-path \"" + REPO_PATH + "\" --base " + publishBase + " --task-id \"" + taskId + "\" --attempt 1 --out \"" + publishDiffFile + "\"\n" +
1356
1398
  "The script prints one small JSON object to stdout. Return the stdout verbatim as { \"output\": \"<verbatim stdout>\" } and nothing else. Do not interpret it.",
1357
1399
  { key: attemptKey("publish-artifact-diff-" + taskId, reworkCount), label: "Computing publish diff from stamped base",
1358
1400
  schema: { type: "object", properties: { output: { type: "string" } }, required: ["output"] } }
@@ -1375,6 +1417,18 @@ while (i < STEPS.length) {
1375
1417
  var mergeCommitForPublish = String(diffSummary.commit || "").trim();
1376
1418
  var mergeCommitShortForPublish = String(mergeCommitForPublish).substring(0, 7) || "unknown";
1377
1419
  var publishDiffSha256 = String(diffSummary.sha256 || "");
1420
+ // (0.14.6) The per-attempt publish version, synthesized into the
1421
+ // staged diff as .crew-publish-version-<task_id> (per-task receipt —
1422
+ // two same-project tasks can publish concurrently) by the
1423
+ // deterministic script.
1424
+ // The workflow never invents it: the script derives it from
1425
+ // task+commit+attempt, and the intent scan re-derives it before
1426
+ // claiming. A missing/malformed version parks — never publish blind.
1427
+ var publishVersion = String(diffSummary.version || "");
1428
+ // Mirrors isPublishVersion() in lib/crew-api.js: <40-hex commit>:<attempt>.
1429
+ if (!/^[0-9a-f]{40}:[1-9][0-9]*$/.test(publishVersion)) {
1430
+ return await parkTask("Publish diff for commit " + (mergeCommitForPublish || "unknown") + " carries no usable publish version — cannot stage a verifiable intent. Human attention needed.");
1431
+ }
1378
1432
  if (!diffSummary.bytes) {
1379
1433
  return await parkTask("Publish diff is empty for commit " + (mergeCommitForPublish || "unknown") + " — a merge lock was held but there is no change to carry. Human attention needed.");
1380
1434
  }
@@ -1396,685 +1450,59 @@ while (i < STEPS.length) {
1396
1450
  if (!diffSummary.file_count) {
1397
1451
  return await parkTask("Publish diff parsed to zero files for commit " + (mergeCommitForPublish || "unknown") + " — cannot verify application. Human attention needed.");
1398
1452
  }
1399
- // The trigger agent reads the diff from the checksummed file — the
1453
+ // The tick worker reads the diff from the checksummed file — the
1400
1454
  // workflow never holds diff bytes (room #14, 2026-09-17). The file
1401
- // is small by construction: the 200-line budget above gates the
1402
- // trigger. The sha256 check is the agent's only verification step;
1403
- // a mismatch stops the trigger before any artifact_edit call.
1404
- var rebuildPrompt =
1405
- ARTIFACT_LOAD_PREAMBLE +
1406
- "The change to apply is the unified diff in the file \"" + publishDiffFile + "\" (sha256 " + publishDiffSha256 + ").\n" +
1407
- "1. Verify the file: run sha256sum on it. If the printed hash is not exactly " + publishDiffSha256 + ", STOP and end your turn — do not call artifact_edit.\n" +
1408
- "2. Read the file's full content.\n" +
1409
- "3. Call artifact_edit with slug \"" + PUBLISH_SLUG + "\" and verbatim_request:\n" +
1410
- "'Apply the following change to your source tree, then rebuild and deploy.\n" +
1411
- "\n" +
1412
- "UNIFIED DIFF (relative to your source tree):\n" +
1413
- "```diff\n<the full content of the verified file, pasted verbatim>\n```\n" +
1414
- "\n" +
1415
- "Rules:\n" +
1416
- "- For each file in the diff, apply its hunks to the same path in your source tree (use git apply or equivalent).\n" +
1417
- "- For a new file (--- /dev/null), create it with the added (+) lines as its full content.\n" +
1418
- "- For a deleted file (+++ /dev/null), delete it.\n" +
1419
- "- If any hunk does not apply cleanly, STOP and report the failure — do not improvise or skip hunks.\n" +
1420
- "- Do not make any other source changes.\n" +
1421
- "- After applying, rebuild and deploy.'\n" +
1422
- "Edit-request contract (read carefully):\n" +
1423
- "- 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" +
1424
- "- If artifact_edit explicitly refuses the edit (the call is rejected — e.g. the artifact does not exist), do NOT call artifact_edit again: end your turn with exactly one line and nothing else: ARTIFACT_EDIT_REFUSED: <the refusal text, one line>.\n" +
1425
- "- If artifact_edit is not available after the load, do NOT improvise — end your turn.\n" +
1426
- "- You do NOT call setprovenance, artifact_inspect, or post-deploy yourself.\n" +
1427
- "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";
1428
- // See docs/decisions/publish-path.md#agent-id-attribution: the artifact build's agent_id is attributed to the edit call.
1429
- var rebuildAgentId = null;
1430
- // See docs/decisions/publish-path.md#applied-report-gone: the builder's applied report is gone; the workflow verifies differently.
1431
- var publishAppliedObservation = "missing-report";
1432
- // See docs/decisions/publish-path.md#durable-evidence-snapshot: snapshot the audit-dir listing BEFORE the trigger; fallback diffs before/after.
1433
- var auditDirsBeforeTrigger = [];
1434
- var auditBeforeOk = false;
1435
- // Pre-trigger baselines (design §1.9): the audit-dir listing and the
1436
- // manifest snapshot. The verified-path freshness check compares the
1437
- // post-trigger manifest against the baseline (built_at advance +
1438
- // content_sha256 change). Best-effort, never gates — a missing
1439
- // manifest baseline fails the verified path closed.
1440
- var preTriggerManifest = null;
1441
- try {
1442
- var auditBefore = await agent(
1443
- "Capture pre-trigger baselines for slug \"" + PUBLISH_SLUG + "\" (best-effort snapshots, never gates).\n" +
1444
- "Run: ls -1 ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/ 2>/dev/null; echo ---MANIFEST---; cat ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/.space-build/manifest.json 2>/dev/null\n" +
1445
- "Return JSON { \"dirs\": \"<newline-separated names, empty string when missing>\", \"manifest\": \"<the manifest's full text, or empty string when missing/unreadable>\" } and nothing else.",
1446
- { key: attemptKey("publish-baseline-before-" + taskId, reworkCount), label: "Snapshotting baselines before rebuild trigger",
1447
- schema: { type: "object", properties: { dirs: { type: "string" }, manifest: { type: "string" } }, required: ["dirs", "manifest"] } }
1448
- );
1449
- auditDirsBeforeTrigger = String((auditBefore && auditBefore.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
1450
- var manifestText = String((auditBefore && auditBefore.manifest) || "").trim();
1451
- if (manifestText) {
1452
- var manifestJson = JSON.parse(manifestText);
1453
- preTriggerManifest = {
1454
- built_at: typeof manifestJson.built_at === "string" ? manifestJson.built_at : null,
1455
- content_sha256: typeof manifestJson.content_sha256 === "string" ? manifestJson.content_sha256 : null,
1456
- };
1457
- }
1458
- // Arm only after both baselines parse.
1459
- auditBeforeOk = true;
1460
- log("Publish pre-trigger baselines for task " + taskId + ": " + auditDirsBeforeTrigger.length + " audit dirs, manifest " + (preTriggerManifest ? "built_at=" + preTriggerManifest.built_at : "none"));
1461
- } catch (auditBeforeErr) {
1462
- log("Publish pre-trigger baselines 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));
1463
- }
1464
-
1465
- // See docs/decisions/publish-path.md#fire-and-forget-trigger: the trigger child returns immediately; the workflow owns observation and verdict.
1466
- var publishToolsOk = false;
1467
- var publishToolsMissing = false;
1468
- for (var toolcheckAttempt = 1; toolcheckAttempt <= 2 && !publishToolsOk; toolcheckAttempt++) {
1469
- try {
1470
- var toolcheckResult = await agent(
1471
- "Check whether the artifact tool namespace is available.\n" +
1472
- "Call tool_search.load_tool_namespace with paths [\"artifact\"].\n" +
1473
- "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" +
1474
- "Return JSON { \"signal\": \"<the exact ARTIFACT_TOOLS line>\" } and nothing else.",
1475
- { key: attemptKey("publish-artifact-toolcheck-" + taskId + (toolcheckAttempt === 1 ? "" : "-retry2"), reworkCount),
1476
- label: "Checking artifact tool availability" + (toolcheckAttempt === 1 ? "" : " (retry)"),
1477
- schema: { type: "object", properties: { signal: { type: "string" } }, required: ["signal"] } }
1478
- );
1479
- var toolSignal = String((toolcheckResult && toolcheckResult.signal) || "");
1480
- if (/ARTIFACT_TOOLS:\s*ok/.test(toolSignal)) {
1481
- publishToolsOk = true;
1482
- } else if (/ARTIFACT_TOOLS:\s*missing/.test(toolSignal)) {
1483
- publishToolsMissing = true;
1484
- }
1485
- log("Publish artifact toolcheck for task " + taskId + " (attempt " + toolcheckAttempt + " of 2): " +
1486
- (publishToolsOk ? "tools ok" : publishToolsMissing ? "tools missing (explicit parsed signal)" : "inconclusive (no ARTIFACT_TOOLS signal parsed)"));
1487
- } catch (toolcheckErr) {
1488
- 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");
1489
- }
1490
- }
1491
- if (!publishToolsOk && !publishToolsMissing) {
1492
- await recordPublishLedger({
1493
- commit: mergeCommitForPublish,
1494
- attempt: rebuildAttemptKey,
1495
- agent_id: null,
1496
- applied_report: null,
1497
- outcome: "unknown",
1498
- 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"
1499
- }, reworkCount);
1500
- 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.");
1501
- }
1502
- if (!publishToolsOk) {
1503
- await recordPublishLedger({
1504
- commit: mergeCommitForPublish,
1505
- attempt: rebuildAttemptKey,
1506
- agent_id: null,
1507
- applied_report: null,
1508
- outcome: "rejected",
1509
- 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"
1510
- }, reworkCount);
1511
- 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.");
1512
- }
1513
- // See docs/decisions/publish-path.md#pretrigger-baseline: a tiny schema'd baseline is captured before the trigger.
1514
- var baselineAgentId = null;
1515
- var baselineFailed = false;
1516
- try {
1517
- var publishBaseline = await agent(
1518
- ARTIFACT_LOAD_PREAMBLE +
1519
- "Call artifact_status with slug \"" + PUBLISH_SLUG + "\" once.\n" +
1520
- "Return JSON { \"build\": <the raw \"build\" value exactly as returned, or null when there is none> } and nothing else.",
1521
- { key: attemptKey("publish-artifact-baseline-" + taskId, reworkCount), label: "Reading pre-trigger build state",
1522
- schema: { type: "object", properties: { build: { type: ["object", "null"] } }, required: ["build"] } }
1523
- );
1524
- baselineAgentId = (publishBaseline && publishBaseline.build && typeof publishBaseline.build.agent_id === "string" && publishBaseline.build.agent_id) || null;
1525
- 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"));
1526
- } catch (baselineErr) {
1527
- baselineFailed = true;
1528
- 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");
1529
- }
1530
- // See docs/decisions/publish-path.md#trigger-await: the artifact_edit call is awaited.
1531
- var rebuildTrigger = null, triggerThrew = false;
1532
- try {
1533
- var triggerText = String(await agent(rebuildPrompt,
1534
- { key: rebuildAttemptKey, label: "Triggering artifact rebuild" }) || "");
1535
- log("Publish rebuild trigger for task " + taskId + " returned (" + triggerText.length + " chars; awaited; scanned only for the explicit refusal signal)");
1536
- // See docs/decisions/publish-path.md#explicit-refusal-16: the child must explicitly refuse artifact work.
1537
- var refusalText = extractRefusal(triggerText);
1538
- if (refusalText) {
1539
- await recordPublishLedger({
1540
- commit: mergeCommitForPublish,
1541
- attempt: rebuildAttemptKey,
1542
- agent_id: null,
1543
- applied_report: null,
1544
- outcome: "rejected",
1545
- detail: "artifact_edit explicitly refused the edit (parsed ARTIFACT_EDIT_REFUSED signal): " + refusalText + " — conclusive negative: the edit provably did not go through, no observation polling, no blind retry"
1546
- }, reworkCount);
1547
- return await parkTask("Publish cannot proceed for task " + taskId + ": artifact_edit explicitly refused the edit (" + refusalText + "). This is conclusive (rejected, not unknown): the edit did not go through. Repair or provision the artifact target, then re-run Publish. Human attention needed.");
1548
- }
1549
- } catch (triggerErr) {
1550
- 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");
1551
- triggerThrew = true;
1552
- }
1553
- // D1 (2026-09-19; F-A1 upper-bound 2026-09-20): issued_at is an UPPER
1554
- // bound on issuance — captured AFTER the trigger-agent call returns,
1555
- // ferried from one shell date call (workflows have no clock) and
1556
- // validated mechanically; null when unobserved (fallback: ts).
1557
- // See docs/decisions/publish-path.md#d1-issuance-time.
1558
- var triggerIssuedAt = null;
1559
- try {
1560
- var issuedAtFerry = await agent(
1561
- "Run: date -u +%Y-%m-%dT%H:%M:%SZ\n" +
1562
- "Return JSON { \"ts\": \"<the date output, verbatim>\" } and nothing else.",
1563
- { key: attemptKey("publish-issued-at-" + taskId, reworkCount), label: "Capturing post-trigger instant (upper bound on issuance)",
1564
- schema: { type: "object", properties: { ts: { type: "string" } }, required: ["ts"] } }
1565
- );
1566
- var issuedAtRaw = String((issuedAtFerry && issuedAtFerry.ts) || "").trim();
1567
- if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(issuedAtRaw)) triggerIssuedAt = issuedAtRaw;
1568
- } catch (issuedAtErr) { /* issued_at stays null: the verifier falls back to ts */ }
1569
- if (!triggerIssuedAt) log("Publish issuance instant unobserved for task " + taskId + " — issued_at null; the freshness gate falls back to ledger-write ts");
1570
- // (2026-09-19, room #22) Submitted-on-issuance: see docs/decisions/publish-path.md#submitted-on-issuance.
1571
- await recordPublishLedger({
1455
+ // is small by construction: the 200-line budget above gates it. The
1456
+ // worker verifies the sha256 from the intent entry before issuing;
1457
+ // a mismatch stops issuance. (2026-09-20, one-party worker-owned
1458
+ // publish: the workflow no longer issues the edit itself.)
1459
+ // (2026-09-20, one-party worker-owned publish) The workflow exits
1460
+ // Publish at intent. Everything above — preflight, provenance base,
1461
+ // checksummed diff — is read-only. (2026-09-20 REVIEW: the
1462
+ // pre-trigger baselines, artifact toolcheck, and pre-trigger build
1463
+ // state agent steps were deleted — their outputs fed only the
1464
+ // retired content-verdict/receipt-attribution machinery, and the
1465
+ // toolcheck ran in a workflow child that cannot reach artifact_edit.
1466
+ // Issuance belongs to the session-carrying tick worker, which
1467
+ // handles tool-unavailability as inconclusive per the tick protocol.)
1468
+ // Publish at intent. Everything above — preflight, provenance base,
1469
+ // checksummed diff, toolcheck, pre-trigger baselines — is read-only.
1470
+ // Issuance belongs to the session-carrying tick worker
1471
+ // (scan-publish-intent's intent bucket), the only caller class that
1472
+ // can reach artifact_edit. This entry is issuer-written BY THE
1473
+ // WORKFLOW and names the intent: outcome "publish-intent", never
1474
+ // "submitted" — the workflow issued nothing. The worker claims it
1475
+ // via the park note below.
1476
+ // (2026-09-20 REVIEW) The intent ledger entry is the anchor the
1477
+ // whole machine depends on. If the ferry drops it, the task would
1478
+ // park with publish-requested and no anchor — unclaimable forever.
1479
+ // Fail loudly instead of parking an orphan intent.
1480
+ var intentAnchored = await recordPublishLedger({
1572
1481
  commit: mergeCommitForPublish,
1573
1482
  attempt: rebuildAttemptKey,
1483
+ // (0.14.6) Attempt 1, staged here. The version is the attempt's
1484
+ // deterministic receipt string, synthesized into the staged diff;
1485
+ // the ack scan re-derives it from task+commit+attempt before the
1486
+ // tick worker may issue the edit.
1487
+ publish_attempt: 1,
1488
+ version: publishVersion,
1574
1489
  agent_id: null,
1575
- applied_report: publishAppliedObservation,
1576
- manifest_before: preTriggerManifest,
1577
- outcome: "submitted",
1578
- issued_at: triggerIssuedAt,
1579
- detail: "trigger issuance: rebuild-trigger agent invoked; receipt/observation pending. Invocation only - not evidence of artifact_edit or build acceptance." + (triggerThrew ? "; trigger-threw" : "; trigger-returned")
1580
- }, reworkCount, "issuance");
1581
- // Post-trigger observation (primary, not fallback): the workflow
1582
- // attributes the edit itself. First the in-flight build state — a
1583
- // build whose agent_id is new relative to the pre-trigger baseline
1584
- // is this edit's receipt. Then the durable audit-dir diff — a
1585
- // timestamped directory appearing during the trigger window proves
1586
- // the edit went through and the build completed even when no
1587
- // in-flight build was ever observed (the 2026-09-14 attempt-7 gap).
1588
- // Absence of both signals proves nothing: the outcome is UNKNOWN,
1589
- // never "did not go through". No blind retry — record the attempt
1590
- // and park fail-closed; correlate via the ledger, never by
1591
- // re-issuing.
1592
- log("Publish rebuild trigger issued for task " + taskId + " — observing build state to attribute the edit");
1593
- var buildState = null;
1594
- var buildStateFailed = false;
1595
- try {
1596
- buildState = await agent(
1597
- ARTIFACT_LOAD_PREAMBLE +
1598
- "Call artifact_status with slug \"" + PUBLISH_SLUG + "\".\n" +
1599
- "Poll up to 3 times, about 20 seconds apart, until the response shows a build (the \"build\" value is an object, not null). " +
1600
- "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. " +
1601
- "Do not summarize, interpret, or derive booleans from it. " +
1602
- "If no build appears after 3 polls, return null. " +
1603
- "Return JSON { \"build\": <the raw build object or null> } and nothing else.",
1604
- { key: attemptKey("publish-artifact-buildcheck-" + taskId, reworkCount), label: "Reading artifact build state after trigger",
1605
- schema: { type: "object", properties: { build: { type: ["object", "null"] } }, required: ["build"] } }
1606
- );
1607
- } catch (buildCheckErr) {
1608
- buildStateFailed = true;
1609
- log("Publish post-trigger build-state check failed for task " + taskId + " (" + (buildCheckErr && buildCheckErr.message ? buildCheckErr.message : buildCheckErr) + ") — this signal is unknown, not negative");
1610
- }
1611
- var observedAgentId = (buildState && buildState.build && typeof buildState.build.agent_id === "string" && buildState.build.agent_id) || null;
1612
- // See docs/decisions/publish-path.md#attribution-limitation: attribution is timing-based; content verification bounds the risk.
1613
- var receiptAgentId = (!buildStateFailed && !baselineFailed && observedAgentId && observedAgentId !== baselineAgentId) ? observedAgentId : null;
1614
- // auditReportOk: pure tri-state read of a report.json body —
1615
- // true (build ok), false (build failed), null (missing or
1616
- // unreadable — not evidence either way). The child returns the
1617
- // raw body verbatim; interpretation lives here, never in prose.
1618
- // Hoisted to Publish-step scope (before the receipt branch) so both
1619
- // the immediate and post-poll audit fallbacks share it on every path —
1620
- // the receipt path skips the else below, which must not leave these
1621
- // undefined.
1622
- var auditReportOk = function (raw) {
1623
- if (typeof raw !== "string") return null;
1624
- var trimmed = raw.trim();
1625
- if (trimmed === "" || trimmed === "MISSING") return null;
1626
- var parsed;
1627
- try { parsed = JSON.parse(trimmed); } catch (e) { return null; }
1628
- if (parsed && typeof parsed.ok === "boolean") return parsed.ok;
1629
- return null;
1630
- };
1631
- // (2026-09-18, H2 verdict-first) Publish-verdict vocabulary. The
1632
- // verdict is one of "landed" | "unknown". Decided once,
1633
- // before the receipt poll, and dispatched on — never re-derived.
1634
- // Pure and self-contained: unit-tested by
1635
- // tests/publish-verdict-first.test.js.
1636
- // See docs/decisions/publish-path.md#h2-verdict-dispatch.
1637
- var decidePublishVerdict = function (opts) {
1638
- var immediateReport = (opts && "immediateReport" in opts) ? opts.immediateReport : null;
1639
- var newDirCount = (opts && typeof opts.newDirCount === "number") ? opts.newDirCount : 0;
1640
- if (newDirCount === 1 && immediateReport === true) return { verdict: "landed", unattributableReason: null };
1641
- if (newDirCount === 1 && immediateReport === false) return { verdict: "unknown", unattributableReason: "audit-report-ok-false" };
1642
- if (newDirCount === 1) return { verdict: "unknown", unattributableReason: "audit-report-unreadable-or-missing" };
1643
- if (newDirCount === 0) return { verdict: "unknown", unattributableReason: "no-new-audit-dir-in-window" };
1644
- return { verdict: "unknown", unattributableReason: "audit-dir-ambiguity", ambiguousDirCount: newDirCount };
1645
- };
1646
- // (2026-09-18, H2 message contract, design §1.5) The human line is
1647
- // the output of a mechanical field→template mapping: the trigger
1648
- // commit short-sha, one plain clause per unattributable reason, the
1649
- // no-republish warning, the ledger path with (outcome: unknown), and
1650
- // the unknown-recovery clause. The appendix carries every machine
1651
- // field. Pure and self-contained: unit-tested by
1652
- // tests/publish-verdict-first.test.js.
1653
- var composeUnattributedParkReason = function (fields) {
1654
- var f = fields || {};
1655
- var task = f.taskId || taskId;
1656
- var reason = f.unattributableReason || "unknown-outcome";
1657
- var shortSha = String(f.commitShortSha || "").substring(0, 7) || "unknown";
1658
- var reasonClauses = {
1659
- "no-new-audit-dir-in-window": "no build could be tied to this attempt",
1660
- "audit-report-unreadable-or-missing": "the build's report is unreadable",
1661
- "audit-dir-ambiguity": "more than one build appeared in the check window",
1662
- "stranger-build-observed-during-poll": "a different build was running during the check",
1663
- "status-read-errors-during-poll": "status reads kept failing"
1664
- };
1665
- var clause = reasonClauses[reason] || "no build could be tied to this attempt";
1666
- return "Publish outcome unknown for task " + task +
1667
- ": the trigger was sent for commit " + shortSha + " but the outcome could not be confirmed — " + clause + ". " +
1668
- "Do NOT republish: if the trigger was accepted, a retry duplicates the build (2026-09-12). " +
1669
- "The attempt is in the ledger at " + crewHome + "/.publish-ledger/" + PUBLISH_SLUG + ".jsonl (outcome: unknown) " +
1670
- "and the crew's unknown-recovery will re-examine it. " +
1671
- "Appendix: unattributable_reason=" + reason +
1672
- "; poll_end_state=" + (f.pollEndState || "not-polled") +
1673
- "; saw_our_build=" + (f.sawOurBuild ? "true" : "false") +
1674
- "; new_audit_dirs=" + (f.newAuditDirCount == null ? 0 : f.newAuditDirCount) +
1675
- "; poll_chunks_failed=" + (f.chunkFailures == null ? 0 : f.chunkFailures) +
1676
- "; poll_status_errors=" + (f.pollStatusErrors == null ? 0 : f.pollStatusErrors) + ".";
1677
- };
1678
- // publishFailure is declared here (per-Publish-pass scope) so the
1679
- // post-poll explicit build failure survives to the final routing
1680
- // below; publishUnknownFields carries the structured unknown fields
1681
- // for the single composed fail-closed park. Both re-initialize on
1682
- // every pass — a rework re-entry never leaks a stale verdict.
1683
- var publishFailure = null;
1684
- var publishUnknownFields = null;
1685
- if (receiptAgentId) {
1686
- // The edit went through — a build with a new agent_id appeared
1687
- // after the trigger. The parent's independent read-back
1688
- // (docs/publish-verification.md) is the verification, not any
1689
- // builder report.
1690
- rebuildTrigger = { edit_started: true };
1691
- rebuildAgentId = receiptAgentId;
1692
- 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.");
1693
- await recordPublishLedger({
1694
- commit: mergeCommitForPublish,
1695
- attempt: rebuildAttemptKey,
1696
- agent_id: rebuildAgentId,
1697
- applied_report: publishAppliedObservation,
1698
- manifest_before: preTriggerManifest,
1699
- outcome: "submitted",
1700
- issued_at: triggerIssuedAt,
1701
- detail: "fire-and-forget trigger; build receipt captured by workflow-owned build-state observation (pre/post-trigger diff); observation, not re-issuance"
1702
- }, reworkCount, "receipt");
1703
- } else {
1704
- var newAuditDirs = [];
1705
- try {
1706
- var auditAfter = await agent(
1707
- "List the artifact audit directories for slug \"" + PUBLISH_SLUG + "\" (best-effort, never a gate).\n" +
1708
- "Run: ls -1 ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/ 2>/dev/null\n" +
1709
- "Return JSON { \"dirs\": \"<newline-separated names, empty string when the audits directory does not exist or is empty>\" } and nothing else.",
1710
- { key: attemptKey("publish-audit-after-" + taskId, reworkCount), label: "Re-listing audit dirs after trigger",
1711
- schema: { type: "object", properties: { dirs: { type: "string" } }, required: ["dirs"] } }
1712
- );
1713
- var auditDirsAfterTrigger = String((auditAfter && auditAfter.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
1714
- // Only timestamped build dirs count — the "latest" symlink
1715
- // and anything else are not builds. Gated on auditBeforeOk:
1716
- // without a baseline every historical dir would look new.
1717
- newAuditDirs = auditBeforeOk ? auditDirsAfterTrigger.filter(function (d) {
1718
- return auditDirsBeforeTrigger.indexOf(d) === -1 && /^20\d\d-\d\d-\d\dT\d\d-\d\d-\d\dZ-/.test(d);
1719
- }) : [];
1720
- } catch (auditAfterErr) {
1721
- log("Publish audit-dir re-list after trigger failed for task " + taskId + " (non-fatal, durable-evidence check degraded): " + (auditAfterErr && auditAfterErr.message ? auditAfterErr.message : auditAfterErr));
1722
- }
1723
- if (newAuditDirs.length > 0) {
1724
- rebuildAgentId = null;
1725
- newAuditDirs.sort();
1726
- var newestImmediateDir = newAuditDirs[newAuditDirs.length - 1];
1727
- 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.");
1728
- // (2026-09-18, H2 verdict-first) Durable audit evidence exists,
1729
- // but there is no receipt agent_id to chain the completion poll
1730
- // to — polling with a null receipt can only observe strangers
1731
- // (any running build differs from "null") or nothing, burning
1732
- // 10.5 minutes to park unknown. Read the build report now instead
1733
- // of polling, then decide the verdict ONCE via
1734
- // decidePublishVerdict: exactly one new dir with ok=true lands
1735
- // (attribution by window, not identity — never poll blind);
1736
- // ok=false is UNKNOWN with the failure evidence preserved in the
1737
- // ledger detail (the evidence is explicit, the attribution is
1738
- // not); unreadable / zero / ambiguous dirs are UNKNOWN.
1739
- // Verdict-first: landed bypasses the poll below, unknown falls
1740
- // through to post-deploy. STEP 2 runs on every path.
1741
- // See docs/decisions/publish-path.md#h2-verdict-dispatch.
1742
- var immediateReportOk = null;
1743
- // (N1) Read the report only when exactly one new dir exists:
1744
- // ambiguity (>1) forces UNKNOWN regardless — don't shell out to
1745
- // read a report that will be discarded.
1746
- if (newAuditDirs.length === 1) {
1747
- try {
1748
- var immediateOkRead = await agent(
1749
- "Read the artifact build report for slug \"" + PUBLISH_SLUG + "\".\n" +
1750
- "Run: cat ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/" + newestImmediateDir + "/report.json 2>/dev/null || echo MISSING\n" +
1751
- "Return JSON { \"raw\": \"<verbatim file contents, or the literal string MISSING when the file does not exist>\" } and nothing else.",
1752
- { key: attemptKey("publish-audit-ok-immediate-" + taskId, reworkCount), label: "Reading build report for audit-confirmed build",
1753
- schema: { type: "object", properties: { raw: { type: "string" } }, required: ["raw"] } }
1754
- );
1755
- immediateReportOk = auditReportOk(immediateOkRead && immediateOkRead.raw);
1756
- } catch (immediateOkErr) {
1757
- log("Publish build-report read for audit-confirmed dir failed for task " + taskId + " (treated as unknown): " + (immediateOkErr && immediateOkErr.message ? immediateOkErr.message : immediateOkErr));
1758
- immediateReportOk = null;
1759
- }
1760
- }
1761
- var immediateVerdict = decidePublishVerdict({ editStarted: true, immediateReport: immediateReportOk, newDirCount: newAuditDirs.length });
1762
- if (immediateVerdict.verdict === "landed") {
1763
- publishBuildLanded = true;
1764
- artifactPublish = { source_commit: mergeCommitForPublish, pending_parent_verification: true };
1765
- await recordPublishLedger({
1766
- commit: mergeCommitForPublish,
1767
- attempt: rebuildAttemptKey,
1768
- agent_id: null,
1769
- applied_report: publishAppliedObservation,
1770
- manifest_before: preTriggerManifest,
1771
- outcome: "build-observed",
1772
- detail: "durable audit evidence shows a build completed during the attempt window (no receipt agent_id — attribution by window, not identity; receipt poll bypassed (verdict decided), routed to parent verification)"
1773
- }, reworkCount);
1774
- log("Publish verdict LANDED for task " + taskId + ": a completed build was observed during the attempt window — receipt poll bypassed (verdict decided, no receipt to chain to), routing directly to parent verification.");
1775
- } else {
1776
- // Verdict UNKNOWN on the immediate path. ok=false is explicit
1777
- // failure evidence but not an attributable failure — the ledger
1778
- // records unknown with the evidence preserved in the detail,
1779
- // and the flow continues to post-deploy (never parks early).
1780
- publishUnknownFields = {
1781
- taskId: taskId,
1782
- unattributableReason: immediateVerdict.unattributableReason,
1783
- pollEndState: "not-polled",
1784
- sawOurBuild: false,
1785
- newAuditDirCount: newAuditDirs.length,
1786
- chunkFailures: 0,
1787
- pollStatusErrors: 0
1788
- };
1789
- var immediateDetail = "durable audit-dir fallback could not prove a completed build for this attempt (unattributable_reason=" + immediateVerdict.unattributableReason + ", no receipt agent_id)";
1790
- if (immediateReportOk === false) {
1791
- immediateDetail += "; explicit failure evidence preserved: report ok=false for audit dir " + newestImmediateDir;
1792
- }
1793
- if (immediateVerdict.unattributableReason === "audit-dir-ambiguity") {
1794
- immediateDetail += "; audit-dir ambiguity: " + newAuditDirs.length + " new dirs in window";
1795
- }
1796
- await recordPublishLedger({
1797
- commit: mergeCommitForPublish,
1798
- attempt: rebuildAttemptKey,
1799
- agent_id: null,
1800
- applied_report: publishAppliedObservation,
1801
- outcome: "unknown",
1802
- detail: immediateDetail
1803
- }, reworkCount);
1804
- log("Publish verdict UNKNOWN for task " + taskId + ": " + immediateDetail + " — continuing to post-deploy; never polling blind and never parking early.");
1805
- }
1806
- } else {
1807
- // See docs/decisions/publish-path.md#no-attributable-build: no attributable build and no durable evidence means no publish.
1808
- publishUnknownFields = {
1809
- taskId: taskId,
1810
- unattributableReason: decidePublishVerdict({ editStarted: true, immediateReport: null, newDirCount: 0 }).unattributableReason,
1811
- pollEndState: "not-polled",
1812
- sawOurBuild: false,
1813
- newAuditDirCount: 0,
1814
- chunkFailures: 0,
1815
- pollStatusErrors: 0
1816
- };
1817
- await recordPublishLedger({
1818
- commit: mergeCommitForPublish,
1819
- attempt: rebuildAttemptKey,
1820
- agent_id: null,
1821
- applied_report: publishAppliedObservation,
1822
- outcome: "unknown",
1823
- detail: "no new audit dir appeared in the trigger window and no receipt agent_id was observed — the edit was issued fire-and-forget, so completion is unproven; never poll blind on a null receipt"
1824
- }, reworkCount);
1825
- log("Publish verdict UNKNOWN for task " + taskId + ": no new audit dir in window and no receipt — continuing to post-deploy; never polling blind and never parking early.");
1826
- }
1490
+ applied_report: null,
1491
+ outcome: "publish-intent",
1492
+ issuer: "workflow",
1493
+ diff_path: publishDiffFile,
1494
+ diff_sha256: publishDiffSha256,
1495
+ // (2026-09-20, critic-0145 F-A4) The base the diff was computed
1496
+ // against: scan-publish-intent's intent branch compares it with
1497
+ // current stamped provenance and re-queues the task when it went
1498
+ // stale — never issues the stale diff.
1499
+ base: publishBase,
1500
+ detail: "publish intent: preflight and checksummed diff are complete; issuance is owned by the session-carrying tick worker. The workflow performed no artifact_edit and wrote no issuance."
1501
+ }, reworkCount);
1502
+ if (!intentAnchored) {
1503
+ throw new Error("publish-intent ledger anchor write unconfirmed for task " + taskId + " — refusing to park an unclaimable intent; the Publish phase fails loudly instead");
1827
1504
  }
1828
- // Durable publish-attempt ledger: record the trigger outcome while the
1829
- // attempt key and commit are in scope. Every attempt lands here with
1830
- // its outcome — submitted, rejected, or unknown (unknown is recorded
1831
- // at the park site above). A later run or human matches commit hash +
1832
- // attempt key against the builder's eventual completion.
1833
- // (2026-09-18, H2 verdict-first) The verdict was decided exactly
1834
- // once above; dispatch on it. landed bypasses the receipt poll
1835
- // (the audit evidence already proved completion); an explicit
1836
- // publishFailure is preserved verbatim through post-deploy.
1837
- // Otherwise the verdict is open — but the poll below is only
1838
- // legitimate against a real receipt: the null-safe assertion records
1839
- // UNKNOWN and continues to STEP 2 instead of polling blind.
1840
- // See docs/decisions/publish-path.md#h2-verdict-dispatch.
1841
- if (publishBuildLanded) {
1842
- log("Publish verdict already LANDED for task " + taskId + " — bypassing receipt poll.");
1843
- } else if (publishFailure) {
1844
- // design §1.2 pre-poll branch — currently unassigned; kept for the converged dispatch shape.
1845
- log("Publish verdict already FAILED for task " + taskId + " — preserved verbatim through post-deploy.");
1846
- } else if (!rebuildTrigger || !rebuildTrigger.edit_started) {
1847
- // Loud defensive assertion (replaces the old lying "Unreachable"
1848
- // else): with no receipt state the poll would observe strangers or
1849
- // nothing — record UNKNOWN and continue to STEP 2. Never park
1850
- // early here; never poll blind.
1851
- if (!publishUnknownFields) {
1852
- publishUnknownFields = {
1853
- taskId: taskId,
1854
- unattributableReason: "no-receipt-state",
1855
- pollEndState: "not-polled",
1856
- sawOurBuild: false,
1857
- newAuditDirCount: 0,
1858
- chunkFailures: 0,
1859
- pollStatusErrors: 0
1860
- };
1861
- await recordPublishLedger({
1862
- commit: mergeCommitForPublish,
1863
- attempt: rebuildAttemptKey,
1864
- agent_id: null,
1865
- applied_report: publishAppliedObservation,
1866
- outcome: "unknown",
1867
- detail: "no receipt state was recorded for this attempt — never polling blind; continuing to post-deploy"
1868
- }, reworkCount);
1869
- }
1870
- log("Publish verdict UNKNOWN for task " + taskId + ": no receipt state recorded — never polling blind, continuing to post-deploy.");
1871
- } else {
1872
- // (2026-09-16) There is no builder report: the fire-and-forget
1873
- // trigger carries no JSON contract, so there is nothing to
1874
- // compare and no pre-hash diagnostic. The builder's old
1875
- // self-report was circular by construction (canary run 8) with a
1876
- // demonstrated false-negative mode (task 23ca8f3f, 2026-09-12:
1877
- // applied:[] for a diff the builder had applied). The flow
1878
- // proceeds to the build poll regardless; real verification is the
1879
- // parent's independent read-back (docs/publish-verification.md)
1880
- // before the provenance stamp.
1881
- // STEP 1b (mechanical): bounded poll for build completion, chunked so
1882
- // the merge-lock lease is refreshed before it can expire. The 600s
1883
- // lease is shorter than the worst-case 10-minute build poll, so the
1884
- // poll runs in three chunks (7 checks x 30s ~= 3.5 min each) with a
1885
- // holder-only lease refresh between chunks. If a refresh fails, the
1886
- // lock was lost: stop the run and park the task — never continue to
1887
- // a provenance stamp or version assignment without holding the lock.
1888
- var buildPoll = null;
1889
- // STEP 1b poll-signal accumulators (2026-09-15, task aadeccc3):
1890
- // the durable audit-dir fallback below needs the poll's own
1891
- // observations, not just its final verdict — whether our build was
1892
- // ever seen, whether a stranger's build was ever in flight, and
1893
- // what the last check observed. OR-ed across all three chunks so
1894
- // a signal seen in any chunk survives the chunk boundary.
1895
- var pollSawOurBuild = false;
1896
- var pollSawStranger = false;
1897
- var lastObservedAgentId = null;
1898
- // Poll-chunk failure record (2026-09-16, task 1febe8eb): chunk
1899
- // agent calls that threw instead of returning a verdict —
1900
- // recorded for the post-poll diagnosis, never terminal alone.
1901
- var chunkFailures = [];
1902
- // Poll status-read error count (2026-09-16): a failed
1903
- // artifact_status read (rate limiting / TOO_MANY_REQUESTS /
1904
- // 429, network error, or any non-build response) is
1905
- // inconclusive — it is NOT evidence of absence and must never
1906
- // be folded into the no-build-observed signal. Counted for
1907
- // the post-poll diagnosis only; never terminal alone.
1908
- var pollStatusErrors = 0;
1909
- for (var chunk = 1; chunk <= 3; chunk++) {
1910
- if (chunk > 1) {
1911
- var refreshPoll = await agent(
1912
- "Refresh the merge lock for task " + taskId + ".\n" +
1913
- "Run: " + LIFECYCLE_ENV + " refresh-lock " + taskId + "\n" +
1914
- "If the output contains REFRESHED, return JSON { \"held\": true } and nothing else. Otherwise return JSON { \"held\": false, \"output\": \"<verbatim output>\" } and nothing else.",
1915
- { key: attemptKey("publish-lock-refresh-poll-" + taskId + "-c" + chunk, reworkCount), label: "Refreshing merge lock during build poll",
1916
- schema: { type: "object", properties: { held: { type: "boolean" }, output: { type: "string" } }, required: ["held"] },
1917
- timeoutMs: 60000 }
1918
- );
1919
- if (!refreshPoll || refreshPoll.held !== true) {
1920
- return await parkTask("Merge-lock lease lost during the artifact build poll (refresh before chunk " + chunk + " of 3 failed: " + ((refreshPoll && refreshPoll.output) || "no output") + "). Fail-closed: stopping before any provenance stamp or version assignment.");
1921
- }
1922
- }
1923
- // Chunk 1 keeps the original stable key; later chunks use -c<N>
1924
- // suffixed keys. All are attemptKey-scoped so rework passes stay
1925
- // disjoint (replay-key contract).
1926
- var pollKey = (chunk === 1)
1927
- ? attemptKey("publish-artifact-poll-" + taskId, reworkCount)
1928
- : attemptKey("publish-artifact-poll-" + taskId + "-c" + chunk, reworkCount);
1929
- try {
1930
- buildPoll = await agent(
1931
- "First call tool_search.load_tool_namespace with paths [\"artifact\"]. Then poll artifact_status for slug \"" + PUBLISH_SLUG + "\" \u2014 for OUR build only, the one whose agent_id is \"" + rebuildAgentId + "\" (the receipt captured when the edit was accepted; the agent_id is the artifact system's in-flight build correlation ID, stable across polls while the build runs). Check every 30 seconds, up to 7 checks (3.5 minutes max). On each check, read the raw build object:\n" +
1932
- "If an artifact_status call itself FAILS (rate limiting / TOO_MANY_REQUESTS / 429, network error, or any response that is not a build object): that check is inconclusive \u2014 do NOT record it as \"no build\". Stop polling immediately and return with status_error: true. A failed read is not evidence of absence and must never be folded into the no-build-observed signal.\n" +
1933
- "On every check, record whether you have positively OBSERVED our build: a running build whose agent_id equals \"" + rebuildAgentId + "\", or a completed-build record whose agent_id equals \"" + rebuildAgentId + "\" (if the tool surfaces one \u2014 match it mechanically, never assume).\n" +
1934
- "- If no build is running (build is null) and you have NOT observed our build: our build's completion is UNPROVEN. Absence of a running build is not evidence our build ran. Do NOT report done.\n" +
1935
- "- If no build is running (build is null) and you previously observed our build running: our build finished. Stop and report done.\n" +
1936
- "- If the running build's agent_id equals \"" + rebuildAgentId + "\": still ours \u2014 keep waiting.\n" +
1937
- "- If the running build's agent_id is present but DIFFERENT: that is a stranger's build. Do NOT attribute its completion to our attempt and do NOT wait on it \u2014 keep checking within budget; if the budget expires without observing our build, report done=false. Record it in saw_stranger regardless of what else you observe.\n" +
1938
- "Return JSON { \"build_done\": <true ONLY when you positively observed our build and it is no longer running, false otherwise>, \"saw_our_build\": <true if you observed our build at any check, false if never>, \"saw_stranger\": true if at ANY check a running build had an agent_id different from ours (\"" + rebuildAgentId + "\"), false otherwise, \"status\": \"<final status or timeout note>\", \"observed_agent_id\": \"<the agent_id seen on the last check, or null when no build was running>\", \"status_error\": <true ONLY when a status read failed as described above, false or omitted otherwise> } and nothing else.",
1939
- { key: pollKey, label: "Waiting for artifact build to complete (chunk " + chunk + " of 3)",
1940
- schema: { type: "object", properties: { build_done: { type: "boolean" }, saw_our_build: { type: "boolean" }, saw_stranger: { type: "boolean" }, status: { type: "string" }, observed_agent_id: { type: ["string", "null"] }, status_error: { type: "boolean" } }, required: ["build_done"] },
1941
- timeoutMs: 270000 }
1942
- );
1943
- } catch (chunkErr) {
1944
- // See docs/decisions/publish-path.md#hung-chunk: a hung or failed chunk is inconclusive, never terminal.
1945
- chunkFailures.push("chunk " + chunk + ": " + (chunkErr && chunkErr.message ? chunkErr.message : chunkErr));
1946
- log("Artifact build poll chunk " + chunk + " of 3 failed (" + (chunkErr && chunkErr.message ? chunkErr.message : chunkErr) + ") \u2014 continuing to the next chunk; build completion still unproven.");
1947
- }
1948
- if (buildPoll) {
1949
- pollSawOurBuild = pollSawOurBuild || (buildPoll.saw_our_build === true);
1950
- pollSawStranger = pollSawStranger || (buildPoll.saw_stranger === true);
1951
- lastObservedAgentId = buildPoll.observed_agent_id || null;
1952
- if (buildPoll.status_error === true) { pollStatusErrors++; log("Artifact build poll chunk " + chunk + " of 3 hit a status-read error \u2014 recorded as inconclusive, continuing to the next chunk; a failed read is not evidence of absence."); }
1953
- if (buildPoll.build_done) { break; }
1954
- }
1955
- }
1956
- if (!buildPoll || !buildPoll.build_done) {
1957
- buildPoll = { build_done: false, status: (buildPoll && buildPoll.status) || "build still running after the 10.5-minute bounded poll" };
1958
- }
1959
- if (buildPoll.build_done && pollSawOurBuild) {
1960
- // See docs/decisions/publish-path.md#step-1c-no-stamp: no provenance stamp in STEP 1c.
1961
- publishBuildLanded = true;
1962
- artifactPublish = { source_commit: mergeCommitForPublish, pending_parent_verification: true };
1963
- log("Publish build landed for task " + taskId + " — provenance stamp deferred to parent content verification");
1964
- } else {
1965
- // STEP 1b durable audit-dir fallback (2026-09-15, task aadeccc3):
1966
- // the poll observes only in-flight builds; a build that finished
1967
- // inside the window leaves a durable audit dir. Diff the audit
1968
- // listing against the pre-trigger snapshot: a new timestamped dir
1969
- // is evidence a build completed. Attribution is by window, not by build identity: any
1970
- // observed stranger blocks it. Never re-issues, never stamps;
1971
- // ok=true routes to the parent's read-back (the verification).
1972
- //
1973
- // The poll end-state is read from the poll's own observations,
1974
- // not from build_done alone: a build in flight at the last check
1975
- // means the budget was shorter than the latency (or the build is
1976
- // stuck) — NOT that no build ever started; nothing observed at
1977
- // any check is the never-started signal.
1978
- var pollEndState = lastObservedAgentId ? "build-still-running-at-poll-end"
1979
- : (pollSawOurBuild ? "our-build-observed-then-unconfirmed" : "no-build-observed-in-window");
1980
- var strangerObserved = pollSawStranger;
1981
- var newAuditDirsAfterPoll = [];
1982
- try {
1983
- var auditAfterPoll = await agent(
1984
- "List the artifact audit directories for slug \"" + PUBLISH_SLUG + "\" (best-effort, never a gate).\n" +
1985
- "Run: ls -1 ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/ 2>/dev/null\n" +
1986
- "Return JSON { \"dirs\": \"<newline-separated names, empty string when the audits directory does not exist or is empty>\" } and nothing else.",
1987
- { key: attemptKey("publish-audit-after-poll-" + taskId, reworkCount), label: "Re-listing audit dirs after build poll",
1988
- schema: { type: "object", properties: { dirs: { type: "string" } }, required: ["dirs"] } }
1989
- );
1990
- var auditDirsAfterPollList = String((auditAfterPoll && auditAfterPoll.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
1991
- // Gated on auditBeforeOk (critic finding 4): without a baseline
1992
- // every historical dir would look new.
1993
- newAuditDirsAfterPoll = auditBeforeOk ? auditDirsAfterPollList.filter(function (d) {
1994
- return auditDirsBeforeTrigger.indexOf(d) === -1 && /^20\d\d-\d\d-\d\dT\d\d-\d\d-\d\dZ-/.test(d);
1995
- }) : [];
1996
- log("Publish audit-dir re-list after build poll for task " + taskId + ": " + newAuditDirsAfterPoll.length + " new timestamped dir(s)");
1997
- } catch (auditAfterPollErr) {
1998
- 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));
1999
- }
2000
- // The shared auditReportOk (defined with the immediate fallback
2001
- // above) interprets the raw body here too.
2002
- var auditOkAfterPoll = null;
2003
- var newestAuditDirAfterPoll = null;
2004
- if (newAuditDirsAfterPoll.length > 0 && !strangerObserved) {
2005
- newAuditDirsAfterPoll.sort();
2006
- newestAuditDirAfterPoll = newAuditDirsAfterPoll[newAuditDirsAfterPoll.length - 1];
2007
- try {
2008
- var auditOkRead = await agent(
2009
- "Read the build report for artifact slug \"" + PUBLISH_SLUG + "\", audit dir \"" + newestAuditDirAfterPoll + "\" (verbatim read, never interpreted, never a gate).\n" +
2010
- "Run: cat ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/" + newestAuditDirAfterPoll + "/report.json 2>/dev/null || echo MISSING\n" +
2011
- "Return JSON { \"raw\": \"<verbatim file contents, or the literal string MISSING when the file does not exist>\" } and nothing else.",
2012
- { key: attemptKey("publish-audit-ok-after-poll-" + taskId, reworkCount), label: "Reading build report after build poll",
2013
- schema: { type: "object", properties: { raw: { type: "string" } }, required: ["raw"] } }
2014
- );
2015
- auditOkAfterPoll = auditReportOk(auditOkRead && auditOkRead.raw);
2016
- } catch (auditOkReadErr) {
2017
- log("Publish build-report read after build poll failed for task " + taskId + " (non-fatal, treated as unknown): " + (auditOkReadErr && auditOkReadErr.message ? auditOkReadErr.message : auditOkReadErr));
2018
- auditOkAfterPoll = null;
2019
- }
2020
- }
2021
- if (auditOkAfterPoll === true) {
2022
- publishBuildLanded = true;
2023
- artifactPublish = { source_commit: mergeCommitForPublish, pending_parent_verification: true };
2024
- log("Publish build landed for task " + taskId + " via durable audit evidence — provenance stamp deferred to parent content verification");
2025
- await recordPublishLedger({
2026
- commit: mergeCommitForPublish,
2027
- attempt: rebuildAttemptKey,
2028
- agent_id: rebuildAgentId,
2029
- applied_report: publishAppliedObservation,
2030
- manifest_before: preTriggerManifest,
2031
- outcome: "build-observed",
2032
- detail: "durable audit evidence shows a build completed during the attempt window (audit dir " + newestAuditDirAfterPoll + ", report ok=true); routed to parent verification"
2033
- }, reworkCount);
2034
- } else if (auditOkAfterPoll === false) {
2035
- // Explicit negative evidence under the stranger guard: a build
2036
- // ran and failed during the poll window with no stranger in
2037
- // flight. This is an attributable failure — preserved verbatim
2038
- // through post-deploy. Message contract unchanged.
2039
- publishFailure = "Artifact build FAILED for slug " + PUBLISH_SLUG + " (audit dir " + newestAuditDirAfterPoll + ", report ok=false). Explicit negative evidence: a build ran and failed (attribution by window, not by build identity — no stranger build was observed in flight during the poll). The publish did not land — provenance was not stamped — your change was NOT published. Build log: ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/" + newestAuditDirAfterPoll + "/. This explicit failure is not auto-retried. Appendix: attribution=window; report=ok=false; provenance=unstamped.";
2040
- await recordPublishLedger({
2041
- commit: mergeCommitForPublish,
2042
- attempt: rebuildAttemptKey,
2043
- agent_id: rebuildAgentId,
2044
- applied_report: publishAppliedObservation,
2045
- outcome: "failed",
2046
- detail: "a build ran and failed (attribution by window, not by build identity): audit dir " + newestAuditDirAfterPoll + " report ok=false; no stranger build observed in flight during the poll"
2047
- }, reworkCount);
2048
- } else {
2049
- var unattributableReason = strangerObserved ? "stranger-build-observed-during-poll"
2050
- : ((pollStatusErrors > 0 && !pollSawOurBuild) ? "status-read-errors-during-poll"
2051
- : (pollEndState === "build-still-running-at-poll-end" ? "build-still-running-at-poll-end"
2052
- : (newAuditDirsAfterPoll.length === 0 ? "no-new-audit-dir-in-window" : "audit-report-unreadable-or-missing")));
2053
- // Verdict UNKNOWN (poll path): the build cannot be attributed
2054
- // to this attempt. The fields feed the single composed
2055
- // fail-closed park reason after post-deploy — never a
2056
- // fabricated verdict, never a silent pass.
2057
- publishUnknownFields = {
2058
- taskId: taskId,
2059
- unattributableReason: unattributableReason,
2060
- pollEndState: pollEndState,
2061
- sawOurBuild: pollSawOurBuild,
2062
- newAuditDirCount: newAuditDirsAfterPoll.length,
2063
- chunkFailures: chunkFailures.length,
2064
- pollStatusErrors: pollStatusErrors
2065
- };
2066
- await recordPublishLedger({
2067
- commit: mergeCommitForPublish,
2068
- attempt: rebuildAttemptKey,
2069
- agent_id: rebuildAgentId,
2070
- applied_report: publishAppliedObservation,
2071
- outcome: "unknown",
2072
- detail: "durable audit-dir fallback could not attribute a completed build to this attempt (unattributable_reason=" + unattributableReason + ", poll_end_state=" + pollEndState + ")"
2073
- }, reworkCount);
2074
- }
2075
- }
2076
- }
2077
-
1505
+ return await parkTask("publish: publish-requested " + mergeCommitForPublish + " attempt=1 — Publish intent recorded for task " + taskId + ": the merged change is staged as a checksummed diff (" + publishDiffFile + ", sha256 " + publishDiffSha256 + ") carrying the per-attempt publish version for the crew's publish worker to issue. The worker issues the edit directly and the acknowledgement scan owns the task from there; no action needed.");
2078
1506
  } // end: publishSkippedNoLock — no rebuild, no stamp, nothing to ship
2079
1507
  // STEP 2 (mechanical, always — skip path included): post-deploy
2080
1508
  // commits builder leftovers if any, removes the worktree, and releases
@@ -2087,34 +1515,17 @@ while (i < STEPS.length) {
2087
1515
  { key: attemptKey("publish-postdeploy-" + taskId, reworkCount), label: "Finalizing publish (post-deploy)",
2088
1516
  schema: { type: "object", properties: { deployed: { type: "boolean" }, output: { type: "string" } }, required: ["deployed"] } }
2089
1517
  );
2090
- if (publishSkippedNoLock) {
1518
+ // (2026-09-20, one-party worker-owned publish) Verified re-entry:
1519
+ // the intent park's terminal-cleanup already released the lock and
1520
+ // reclaimed the worktree. Post-deploy above is best-effort hygiene
1521
+ // on this branch — never a gate, never a park.
1522
+ if (publishAlreadyVerified) {
1523
+ log("Publish verified re-entry for task " + taskId + " — post-deploy ran forgivingly; continuing to the verified work-agent framing");
1524
+ } else if (publishSkippedNoLock) {
2091
1525
  if (!postDeploy.deployed) {
2092
1526
  return await parkTask("Post-deploy failed after a skipped publish: " + (postDeploy.output || "no output") + ". Nothing was published; worktree cleanup and lock state unknown — human attention needed.");
2093
1527
  }
2094
1528
  log("Publish skipped cleanly for task " + taskId + " (no lock held) — post-deploy step finished");
2095
- } else {
2096
- if (publishFailure) {
2097
- return await parkTask(publishFailure + (postDeploy.deployed
2098
- ? " Post-deploy step finished (cleanup status unknown)."
2099
- : " Post-deploy also failed (" + (postDeploy.output || "no output") + ") — worktree and lock state unknown."));
2100
- }
2101
- if (!publishBuildLanded) {
2102
- // Verdict UNKNOWN (single fail-closed park — post-deploy always
2103
- // runs first; no early parks anywhere above). Machine contract:
2104
- // "unattributable_reason=" and "poll_end_state=" are always
2105
- // present; attribution is by window, not identity.
2106
- // (2026-09-18, H2 message contract) Thread the commit short-sha
2107
- // through the unknown fields so the human line names the trigger
2108
- // commit (design §1.5: "the trigger was sent for commit <short-sha>").
2109
- if (publishUnknownFields) publishUnknownFields.commitShortSha = mergeCommitShortForPublish;
2110
- return await parkTask(composeUnattributedParkReason(publishUnknownFields) + (postDeploy.deployed
2111
- ? " Post-deploy step finished (cleanup status unknown)."
2112
- : " Post-deploy also failed (" + (postDeploy.output || "no output") + ") — worktree and lock state unknown."));
2113
- }
2114
- if (!postDeploy.deployed) {
2115
- return await parkTask("Post-deploy failed after the artifact build landed: " + (postDeploy.output || "no output") + ". The build may have landed but worktree cleanup and lock release are unknown — human attention needed.");
2116
- }
2117
- log("Deterministic artifact publish completed for task " + taskId + ": build at " + artifactPublish.source_commit + ", provenance PENDING parent content verification");
2118
1529
  }
2119
1530
  } catch (pubErr) {
2120
1531
  // Best-effort cleanup: if the lock was refreshed, try to release it
@@ -2135,7 +1546,16 @@ while (i < STEPS.length) {
2135
1546
  // The work agent no longer performs the publish — it reports on the
2136
1547
  // mechanical outcome above. It must not rebuild or re-stamp: a second
2137
1548
  // artifact_edit would trigger a duplicate build.
2138
- if (publishSkippedNoLock) {
1549
+ // (2026-09-20, one-party worker-owned publish) On a verified re-entry
1550
+ // the publish was issued by the crew worker, verified by the parent
1551
+ // read-back, and stamped — the work agent reports that, VERDICT: PASS.
1552
+ if (publishAlreadyVerified) {
1553
+ 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" +
1554
+ "The crew's publish worker issued the artifact edit for the merged commit, the parent's independent content read-back confirmed the artifact contains the merged change, and provenance was stamped (docs/publish-verification.md). This Publish pass is a verified re-entry after the stamp: there is nothing to issue and nothing to re-verify.\n\n" +
1555
+ "For the change summary, run: cd " + REPO_PATH + " && git log -1 --stat\n\n" +
1556
+ "Write plain prose describing what was published, then on its own line: VERDICT: PASS\n" +
1557
+ "The VERDICT line must be the last line of your report.";
1558
+ } else if (publishSkippedNoLock) {
2139
1559
  instructions = "Publish was skipped deterministically by the workflow before your step — do NOT call artifact_edit, artifact_status, setprovenance, or post-deploy yourself; doing so would disturb the finalized state.\n\n" +
2140
1560
  "Integrate reported MERGED_EMPTY (the task branch had no commits ahead of the integration target), so no merge lock was taken and there is nothing to ship. Post-deploy step finished per its return — do NOT run post-deploy yourself.\n\n" +
2141
1561
  "Write plain prose describing the skip, then on its own line: VERDICT: PASS\n" +
@@ -2464,10 +1884,10 @@ while (i < STEPS.length) {
2464
1884
  } // end: !npmPublishSkipped — a skipped publish has nothing to verify
2465
1885
  }
2466
1886
 
2467
- // Parent-owned verification (docs/publish-verification.md): the parent's
2468
- // scan builds the request via lib/build-readback-request.js and ferries
2469
- // the inspection; a skipped or failed publish has nothing to verify.
2470
- // See docs/decisions/publish-path.md#parent-owned-verification for history.
1887
+ // Version acknowledgement (docs/publish-verification.md): the tick worker
1888
+ // issues the edit directly and the ack scan owns the task from there —
1889
+ // the exact per-attempt version on the artifact's disk is the sole positive
1890
+ // completion criterion. A skipped or failed publish has nothing to ack.
2471
1891
  let summary;
2472
1892
  var workerMarkers = extractMarkerLines(workerText);
2473
1893
  if (step.name === "Publish" && PUBLISH_TYPE === "npm" && publishTarget && (publishVerified || npmPublishSkipped)) {
@@ -2553,20 +1973,6 @@ while (i < STEPS.length) {
2553
1973
  return { status: "failed", task_id: taskId, reason: "Publish failed: " + summary };
2554
1974
  }
2555
1975
 
2556
- // See docs/decisions/publish-path.md#verification-park: the build landed but provenance is unstamped until parent verification.
2557
- if (passed && step.name === "Publish" && PUBLISH_TYPE === "artifact" && PUBLISH_SLUG && !publishSkippedNoLock && publishBuildLanded) {
2558
- // Success contract (2026-09-18, H2): the parent asked for exactly
2559
- // one build for this publish. The build landed — do NOT republish: a
2560
- // duplicate build would re-publish the same change. content_check=pending
2561
- // means the parent's independent read-back has not happened yet; this
2562
- // park is NOT proof the content is correct.
2563
- return await parkTask("publish: verification-requested " + mergeCommitForPublish +
2564
- " attempt=" + rebuildAttemptKey +
2565
- " Do NOT republish: a duplicate build would re-publish the same change. " +
2566
- "Artifact build landed, post-deploy finalized, provenance not stamped — the crew has not yet independently confirmed the live artifact contains exactly the change; waiting on the manual read-back in docs/publish-verification.md. " +
2567
- "Appendix: build=" + (rebuildAgentId || "agent_id unobserved") + "; provenance=unstamped; content_check=pending.");
2568
- }
2569
-
2570
1976
  i++;
2571
1977
  }
2572
1978