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