muse-crew 0.14.3 → 0.14.5
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/AGENTS.md +2 -2
- package/docs/decisions/AGENTS.md +1 -0
- package/docs/decisions/publish-path.md +96 -3
- package/docs/guide.md +2 -2
- package/docs/publish-unknown-recovery.md +10 -3
- package/docs/publish-verification.md +126 -62
- package/docs/release-integrity.md +62 -0
- package/docs/reviews/critic-0144.md +83 -0
- package/docs/reviews/critic-0145.md +106 -0
- package/lib/AGENTS.md +12 -4
- package/lib/advance-publish-base.js +8 -0
- package/lib/append-ooda-step.js +12 -3
- package/lib/build-readback-request.js +10 -0
- package/lib/build-registry.js +8 -3
- package/lib/check-intent-freshness.js +101 -0
- package/lib/classify-publish-absence.js +11 -0
- package/lib/classify-surface.js +12 -2
- package/lib/commit-scaffold.js +22 -6
- package/lib/compose-evidence-caption.js +15 -4
- package/lib/compute-publish-diff.js +41 -11
- package/lib/crew-api.js +478 -26
- package/lib/crew-release.sh +233 -1
- package/lib/gitignore.js +23 -5
- package/lib/package.json +1 -0
- package/lib/publish-note-vocabulary.js +64 -0
- package/lib/read-ooda-verdict.js +11 -3
- package/lib/readback-disk.js +9 -0
- package/lib/render-html.js +17 -7
- package/lib/repo-orchestration.js +21 -5
- package/lib/retry-publish.js +116 -72
- package/lib/sample-project.js +22 -6
- package/lib/scaffold-crew.js +11 -2
- package/lib/see-act.js +17 -8
- package/lib/serve-artifact.js +12 -6
- package/lib/setup-project-repo.js +26 -7
- package/lib/update-watch.js +34 -17
- package/lib/ux-doctrine.js +31 -6
- package/lib/verify-publish.js +44 -6
- package/lib/write-ooda-verdict.js +12 -3
- package/package.json +1 -1
- package/seed/cron-body-template.md +50 -16
- package/workflows/bugfix.js +110 -643
- package/workflows/chore.js +110 -643
- package/workflows/crew-dispatch.js +36 -0
- package/workflows/standard.js +118 -633
- package/workflows/upgrade.js +4 -2
package/workflows/chore.js
CHANGED
|
@@ -127,8 +127,10 @@ const COMPUTE_DIFF_SRC = crewHome + "/current/lib/compute-publish-diff.js";
|
|
|
127
127
|
const COMPUTE_DIFF = RUN_LIB + "/compute-publish-diff.js";
|
|
128
128
|
const CLASSIFY_SURFACE_SRC = crewHome + "/current/lib/classify-surface.js";
|
|
129
129
|
const CLASSIFY_SURFACE = RUN_LIB + "/classify-surface.js";
|
|
130
|
+
const NOTE_VOCAB_SRC = crewHome + "/current/lib/publish-note-vocabulary.js";
|
|
131
|
+
const NOTE_VOCAB = RUN_LIB + "/publish-note-vocabulary.js";
|
|
130
132
|
// See docs/decisions/qa-reproduce.md#pin-basenames: the pin step materializes the required scripts.
|
|
131
|
-
const PIN_BASENAMES = [LIFECYCLE, MERGE_LOCK, PUBLISH_NPM, CREW_API_PINNED, SCHEMA_SQL_PINNED, COMPUTE_DIFF, CLASSIFY_SURFACE].map(function (p) { return p.split("/").pop(); });
|
|
133
|
+
const PIN_BASENAMES = [LIFECYCLE, MERGE_LOCK, PUBLISH_NPM, CREW_API_PINNED, SCHEMA_SQL_PINNED, COMPUTE_DIFF, CLASSIFY_SURFACE, NOTE_VOCAB].map(function (p) { return p.split("/").pop(); });
|
|
132
134
|
|
|
133
135
|
// Project config — passed by dispatcher, falls back to dashboard defaults
|
|
134
136
|
const projectConfig = inputs.project_config || {};
|
|
@@ -250,19 +252,12 @@ async function reaskVerdict(stepName, reworkSuffix, workerText) {
|
|
|
250
252
|
return verdict;
|
|
251
253
|
}
|
|
252
254
|
// Transport retry: the work-agent agent() call can throw even when the agent
|
|
253
|
-
// did the work
|
|
254
|
-
// the
|
|
255
|
-
//
|
|
256
|
-
//
|
|
257
|
-
//
|
|
258
|
-
//
|
|
259
|
-
// The verdict re-ask covers an unreadable verdict inside a RECEIVED report;
|
|
260
|
-
// this covers the report never arriving. The assignment is retried boundedly
|
|
261
|
-
// with fresh keys (never a cached replay) before failing closed. Re-entry is
|
|
262
|
-
// safe: lifecycle scripts answer REUSED for existing worktrees/branches, the
|
|
263
|
-
// retry trailer tells the agent to check existing state first and report
|
|
264
|
-
// rather than duplicate completed side effects, and the rework path already
|
|
265
|
-
// re-runs Build after rejection — Build re-entry is an established pattern.
|
|
255
|
+
// did the work — the runtime's JSON-candidate heuristic trips on brace-shaped
|
|
256
|
+
// prose. Retry the assignment boundedly with fresh keys (never a cached
|
|
257
|
+
// replay) before failing closed. Re-entry is safe: lifecycle scripts answer
|
|
258
|
+
// REUSED for existing worktrees/branches, the retry trailer tells the agent
|
|
259
|
+
// to check existing state first, and Build re-entry after rejection is an
|
|
260
|
+
// established pattern. Full history: docs/decisions/workflow-core.md.
|
|
266
261
|
function workRetryKey(stepName, reworkSuffix, attempt) {
|
|
267
262
|
return "work-" + stepName + reworkSuffix + "-t" + attempt;
|
|
268
263
|
}
|
|
@@ -274,7 +269,7 @@ function attemptKey(base, reworkCount) {
|
|
|
274
269
|
function pinLifecycle(key) {
|
|
275
270
|
return agent(
|
|
276
271
|
"Snapshot lifecycle scripts for version pinning.\n" +
|
|
277
|
-
"Run: mkdir -p " + RUN_LIB + " && cp " + LIFECYCLE_SRC + " " + LIFECYCLE + " && cp " + MERGE_LOCK_SRC + " " + MERGE_LOCK + " && cp " + PUBLISH_NPM_SRC + " " + PUBLISH_NPM + " && cp " + CREW_API_SRC + " " + CREW_API_PINNED + " && cp " + SCHEMA_SQL_SRC + " " + SCHEMA_SQL_PINNED + " && cp " + COMPUTE_DIFF_SRC + " " + COMPUTE_DIFF + " && cp " + CLASSIFY_SURFACE_SRC + " " + CLASSIFY_SURFACE + " && chmod +x " + LIFECYCLE + " " + MERGE_LOCK + " " + PUBLISH_NPM + " && ls -1 " + RUN_LIB + "\n" +
|
|
272
|
+
"Run: mkdir -p " + RUN_LIB + " && cp " + LIFECYCLE_SRC + " " + LIFECYCLE + " && cp " + MERGE_LOCK_SRC + " " + MERGE_LOCK + " && cp " + PUBLISH_NPM_SRC + " " + PUBLISH_NPM + " && cp " + CREW_API_SRC + " " + CREW_API_PINNED + " && cp " + SCHEMA_SQL_SRC + " " + SCHEMA_SQL_PINNED + " && cp " + COMPUTE_DIFF_SRC + " " + COMPUTE_DIFF + " && cp " + CLASSIFY_SURFACE_SRC + " " + CLASSIFY_SURFACE + " && cp " + NOTE_VOCAB_SRC + " " + NOTE_VOCAB + " && chmod +x " + LIFECYCLE + " " + MERGE_LOCK + " " + PUBLISH_NPM + " && ls -1 " + RUN_LIB + "\n" +
|
|
278
273
|
"Return the verbatim output of the ls -1 command as { \"listing\": \"<verbatim output>\" } and nothing else.",
|
|
279
274
|
{ key: key, label: "Pinning lifecycle scripts",
|
|
280
275
|
schema: { type: "object", properties: { listing: { type: "string" } }, required: ["listing"] } }
|
|
@@ -455,30 +450,11 @@ function hydrateReleaseDecision(rec) {
|
|
|
455
450
|
return null;
|
|
456
451
|
}
|
|
457
452
|
|
|
458
|
-
// Publish read-back request (currently unavailable): the verbatim_request
|
|
459
|
-
// the parent protocol (docs/publish-verification.md) would hand to an
|
|
460
|
-
// independent read-back tool after the artifact build lands. artifact_inspect
|
|
461
|
-
// was removed by the platform (2026-09-14); artifact.inspect is malfunction
|
|
462
|
-
// diagnosis, not a substitute — so no agent-callable read-back tool exists
|
|
463
|
-
// and this request cannot currently be issued. Pure function — no I/O, no
|
|
464
|
-
// clock. The request carries the merged diff as the expected change and asks
|
|
465
|
-
// for an independent read of the artifact's actual source: for each file, the
|
|
466
|
-
// exact current text of the changed regions plus a per-line present/absent
|
|
467
|
-
// finding. Until a read-back path exists, the parent cannot independently
|
|
468
|
-
// confirm content and verification parks at "publish: verification-requested"
|
|
469
|
-
// (see docs/publish-verification.md). This preserves the circularity break
|
|
470
|
-
// that hollowed canary run 8 (2026-09-11): the old verifyAppliedChanges
|
|
471
|
-
// compared the builder's applied-report against the diff the report was
|
|
472
|
-
// derived from — a fabricated report passed by construction. The report
|
|
473
|
-
// itself is gone now (2026-09-16 fire-and-forget trigger). Independent
|
|
474
|
-
// read-back cannot be
|
|
475
|
-
// fabricated from the diff; it must match the artifact's real content.
|
|
476
|
-
|
|
477
453
|
// See docs/decisions/publish-path.md#publish-attempt-ledger: every trigger outcome is recorded in the durable ledger.
|
|
478
|
-
//
|
|
479
|
-
//
|
|
480
|
-
//
|
|
481
|
-
async function recordPublishLedger(entry, rework
|
|
454
|
+
// (2026-09-20, one-party worker-owned publish) No keyTag: every ledger
|
|
455
|
+
// write in a Publish pass is followed by a return, so no pass can write two
|
|
456
|
+
// same-outcome entries — the runtime replay key can never collide in-pass.
|
|
457
|
+
async function recordPublishLedger(entry, rework) {
|
|
482
458
|
try {
|
|
483
459
|
var ledgerDir = crewHome + "/.publish-ledger";
|
|
484
460
|
var line = JSON.stringify({
|
|
@@ -492,7 +468,19 @@ async function recordPublishLedger(entry, rework, keyTag) {
|
|
|
492
468
|
applied_report: entry.applied_report || null,
|
|
493
469
|
manifest_before: entry.manifest_before || null,
|
|
494
470
|
outcome: entry.outcome,
|
|
495
|
-
detail: entry.detail || ""
|
|
471
|
+
detail: entry.detail || "",
|
|
472
|
+
// D1 (2026-09-19): issued_at = upper bound on the trigger-issuance
|
|
473
|
+
// instant (null when no trigger); ts = ledger-write instant.
|
|
474
|
+
issued_at: entry.issued_at || null,
|
|
475
|
+
// (2026-09-20, one-party worker-owned publish) issuer = which party
|
|
476
|
+
// wrote the entry ("workflow" for the intent entry, "tick-worker" for
|
|
477
|
+
// the worker's own issuance); diff_path/diff_sha256 locate the
|
|
478
|
+
// checksummed diff the worker issues. The workflow never writes an
|
|
479
|
+
// issuance ("submitted") entry — it did not issue.
|
|
480
|
+
issuer: entry.issuer || null,
|
|
481
|
+
diff_path: entry.diff_path || null,
|
|
482
|
+
diff_sha256: entry.diff_sha256 || null,
|
|
483
|
+
base: entry.base || null,
|
|
496
484
|
});
|
|
497
485
|
var sq = function(s) { return "'" + String(s).split("'").join("'\\''") + "'"; };
|
|
498
486
|
var res = await agent(
|
|
@@ -500,7 +488,7 @@ async function recordPublishLedger(entry, rework, keyTag) {
|
|
|
500
488
|
"Run: mkdir -p " + sq(ledgerDir) + " && printf '%s\n' " + sq(line) +
|
|
501
489
|
" | sed \"s/@LEDGER_TS@/$(date -u +%Y-%m-%dT%H:%M:%SZ)/\" >> " + sq(ledgerDir + "/" + PUBLISH_SLUG + ".jsonl") + " && echo LEDGER_OK\n" +
|
|
502
490
|
"Return JSON { \"result\": \"<verbatim output>\" } and nothing else.",
|
|
503
|
-
{ key: attemptKey("publish-ledger-" + taskId + "-" + entry.outcome
|
|
491
|
+
{ key: attemptKey("publish-ledger-" + taskId + "-" + entry.outcome, rework),
|
|
504
492
|
label: "Recording publish attempt in ledger",
|
|
505
493
|
schema: { type: "object", properties: { result: { type: "string" } }, required: ["result"] } }
|
|
506
494
|
);
|
|
@@ -532,11 +520,6 @@ function extractAlreadyMerged(workerText) {
|
|
|
532
520
|
return m ? { sha: m[1].toLowerCase() } : { sha: null };
|
|
533
521
|
}
|
|
534
522
|
|
|
535
|
-
// See docs/decisions/publish-path.md#refusal-signal: the refusal signal must be the ENTIRE trimmed turn output.
|
|
536
|
-
function extractRefusal(workerText) {
|
|
537
|
-
var m = /^ARTIFACT_EDIT_REFUSED:\s*(.+?)\s*$/.exec(String(workerText || "").trim());
|
|
538
|
-
return m ? m[1].slice(0, 300) : null;
|
|
539
|
-
}
|
|
540
523
|
|
|
541
524
|
// See docs/decisions/qa-reproduce.md#worktree-confinement: the Build agent must declare its worktree.
|
|
542
525
|
function extractWorktree(workerText) {
|
|
@@ -1246,10 +1229,41 @@ while (i < STEPS.length) {
|
|
|
1246
1229
|
"VERDICT: PASS\n\n";
|
|
1247
1230
|
} else if (PUBLISH_TYPE === "artifact") {
|
|
1248
1231
|
// See docs/decisions/publish-path.md#deterministic-artifact-publish: the work agent never publishes; the parent runs the deterministic publish script.
|
|
1249
|
-
|
|
1232
|
+
// Blocker 22 (one-party publish, room #24): verified re-entry guard.
|
|
1233
|
+
// The workflow parks at publish intent; the tick worker issues
|
|
1234
|
+
// artifact_edit, verifies by read-back, stamps provenance, and
|
|
1235
|
+
// re-queues. The dispatcher resumes this task at the Publish step
|
|
1236
|
+
// (the parked session's own step — the failed→retry path). If the
|
|
1237
|
+
// stamped provenance names THIS task and its source_commit is the
|
|
1238
|
+
// repo's current HEAD, the merge commit was already published and
|
|
1239
|
+
// verified by the parent: issuance is skipped entirely (the
|
|
1240
|
+
// empty-diff park below must NOT fire on this branch) and the
|
|
1241
|
+
// Publish work agent runs with the verified framing instead. A guard
|
|
1242
|
+
// failure never claims verification — it proceeds down the normal path.
|
|
1243
|
+
var publishAlreadyVerified = false;
|
|
1244
|
+
try {
|
|
1245
|
+
var reentryCheck = await agent(
|
|
1246
|
+
"Run in shell and return the stdout verbatim:\n" + crewCmd("get-provenance", { project_id: LAUNCH_PROJECT_ID }) + "\n" +
|
|
1247
|
+
"Then run in shell and return the stdout verbatim: cd " + REPO_PATH + " && git rev-parse HEAD\n" +
|
|
1248
|
+
"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.",
|
|
1249
|
+
{ key: attemptKey("publish-reentry-guard-" + taskId, reworkCount), label: "Checking for a verified publish re-entry",
|
|
1250
|
+
schema: { type: "object", properties: { source_commit: { type: "string" }, stamp_task_id: { type: "string" }, head: { type: "string" } }, required: ["source_commit", "stamp_task_id", "head"] } }
|
|
1251
|
+
);
|
|
1252
|
+
var reentrySC = String((reentryCheck && reentryCheck.source_commit) || "").trim();
|
|
1253
|
+
var reentryTID = String((reentryCheck && reentryCheck.stamp_task_id) || "").trim();
|
|
1254
|
+
var reentryHEAD = String((reentryCheck && reentryCheck.head) || "").trim();
|
|
1255
|
+
if (reentrySC && reentryHEAD && reentrySC === reentryHEAD && reentryTID === taskId) {
|
|
1256
|
+
publishAlreadyVerified = true;
|
|
1257
|
+
log("Publish verified re-entry for task " + taskId + ": provenance stamps " + reentrySC + " == HEAD for this task — the parent already published and verified it; issuance skipped");
|
|
1258
|
+
}
|
|
1259
|
+
} catch (reentryErr) {
|
|
1260
|
+
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");
|
|
1261
|
+
}
|
|
1262
|
+
// publishAlreadyVerified is consumed by the intent-tail edit (next
|
|
1263
|
+
// chunk): on the verified branch the workflow skips to the Publish
|
|
1264
|
+
// work agent with the verified framing and proceeds to QA.
|
|
1250
1265
|
var publishLockRefreshed = false;
|
|
1251
1266
|
var publishSkippedNoLock = false;
|
|
1252
|
-
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)
|
|
1253
1267
|
try {
|
|
1254
1268
|
// STEP 0 (mechanical): read the merge-lock state explicitly — never
|
|
1255
1269
|
// infer it from prose. An empty-diff Integrate (MERGED_EMPTY)
|
|
@@ -1273,7 +1287,11 @@ while (i < STEPS.length) {
|
|
|
1273
1287
|
publishLockRefreshed = true;
|
|
1274
1288
|
}
|
|
1275
1289
|
// See docs/decisions/publish-path.md#step1-builder-source: the builder's source tree is NOT the crew's repo; verify report before stamping.
|
|
1276
|
-
|
|
1290
|
+
// (2026-09-20, one-party worker-owned publish) A verified re-entry
|
|
1291
|
+
// skips the whole issuance tail: the edit already went out, was
|
|
1292
|
+
// verified by the parent read-back, and was stamped. The empty-diff
|
|
1293
|
+
// park must not fire on this branch.
|
|
1294
|
+
if (!publishSkippedNoLock && !publishAlreadyVerified) {
|
|
1277
1295
|
// The trigger key of the attempt that last ran, for the publish ledger.
|
|
1278
1296
|
// Minted once here (not re-minted per use site) so the ledger always
|
|
1279
1297
|
// records the exact key that was issued — and so a re-minted duplicate
|
|
@@ -1417,39 +1435,12 @@ while (i < STEPS.length) {
|
|
|
1417
1435
|
if (!diffSummary.file_count) {
|
|
1418
1436
|
return await parkTask("Publish diff parsed to zero files for commit " + (mergeCommitForPublish || "unknown") + " — cannot verify application. Human attention needed.");
|
|
1419
1437
|
}
|
|
1420
|
-
// The
|
|
1438
|
+
// The tick worker reads the diff from the checksummed file — the
|
|
1421
1439
|
// workflow never holds diff bytes (room #14, 2026-09-17). The file
|
|
1422
|
-
// is small by construction: the 200-line budget above gates
|
|
1423
|
-
//
|
|
1424
|
-
// a mismatch stops
|
|
1425
|
-
|
|
1426
|
-
ARTIFACT_LOAD_PREAMBLE +
|
|
1427
|
-
"The change to apply is the unified diff in the file \"" + publishDiffFile + "\" (sha256 " + publishDiffSha256 + ").\n" +
|
|
1428
|
-
"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" +
|
|
1429
|
-
"2. Read the file's full content.\n" +
|
|
1430
|
-
"3. Call artifact_edit with slug \"" + PUBLISH_SLUG + "\" and verbatim_request:\n" +
|
|
1431
|
-
"'Apply the following change to your source tree, then rebuild and deploy.\n" +
|
|
1432
|
-
"\n" +
|
|
1433
|
-
"UNIFIED DIFF (relative to your source tree):\n" +
|
|
1434
|
-
"```diff\n<the full content of the verified file, pasted verbatim>\n```\n" +
|
|
1435
|
-
"\n" +
|
|
1436
|
-
"Rules:\n" +
|
|
1437
|
-
"- For each file in the diff, apply its hunks to the same path in your source tree (use git apply or equivalent).\n" +
|
|
1438
|
-
"- For a new file (--- /dev/null), create it with the added (+) lines as its full content.\n" +
|
|
1439
|
-
"- For a deleted file (+++ /dev/null), delete it.\n" +
|
|
1440
|
-
"- If any hunk does not apply cleanly, STOP and report the failure — do not improvise or skip hunks.\n" +
|
|
1441
|
-
"- Do not make any other source changes.\n" +
|
|
1442
|
-
"- After applying, rebuild and deploy.'\n" +
|
|
1443
|
-
"Edit-request contract (read carefully):\n" +
|
|
1444
|
-
"- 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" +
|
|
1445
|
-
"- 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" +
|
|
1446
|
-
"- If artifact_edit is not available after the load, do NOT improvise — end your turn.\n" +
|
|
1447
|
-
"- You do NOT call setprovenance, artifact_inspect, or post-deploy yourself.\n" +
|
|
1448
|
-
"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";
|
|
1449
|
-
// See docs/decisions/publish-path.md#agent-id-attribution: the artifact build's agent_id is attributed to the edit call.
|
|
1450
|
-
var rebuildAgentId = null;
|
|
1451
|
-
// See docs/decisions/publish-path.md#applied-report-gone: the builder's applied report is gone; the workflow verifies differently.
|
|
1452
|
-
var publishAppliedObservation = "missing-report";
|
|
1440
|
+
// is small by construction: the 200-line budget above gates it. The
|
|
1441
|
+
// worker verifies the sha256 from the intent entry before issuing;
|
|
1442
|
+
// a mismatch stops issuance. (2026-09-20, one-party worker-owned
|
|
1443
|
+
// publish: the workflow no longer issues the edit itself.)
|
|
1453
1444
|
// See docs/decisions/publish-path.md#durable-evidence-snapshot: snapshot the audit-dir listing BEFORE the trigger; fallback diffs before/after.
|
|
1454
1445
|
var auditDirsBeforeTrigger = [];
|
|
1455
1446
|
var auditBeforeOk = false;
|
|
@@ -1548,535 +1539,33 @@ while (i < STEPS.length) {
|
|
|
1548
1539
|
baselineFailed = true;
|
|
1549
1540
|
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");
|
|
1550
1541
|
}
|
|
1551
|
-
//
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
await recordPublishLedger({
|
|
1561
|
-
commit: mergeCommitForPublish,
|
|
1562
|
-
attempt: rebuildAttemptKey,
|
|
1563
|
-
agent_id: null,
|
|
1564
|
-
applied_report: null,
|
|
1565
|
-
outcome: "rejected",
|
|
1566
|
-
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"
|
|
1567
|
-
}, reworkCount);
|
|
1568
|
-
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.");
|
|
1569
|
-
}
|
|
1570
|
-
} catch (triggerErr) {
|
|
1571
|
-
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");
|
|
1572
|
-
triggerThrew = true;
|
|
1573
|
-
}
|
|
1574
|
-
// (2026-09-19, room #22) Submitted-on-issuance: see docs/decisions/publish-path.md#submitted-on-issuance.
|
|
1542
|
+
// (2026-09-20, one-party worker-owned publish) The workflow exits
|
|
1543
|
+
// Publish at intent. Everything above — preflight, provenance base,
|
|
1544
|
+
// checksummed diff, toolcheck, pre-trigger baselines — is read-only.
|
|
1545
|
+
// Issuance belongs to the session-carrying tick worker
|
|
1546
|
+
// (scan-publish-unknown's intent bucket), the only caller class that
|
|
1547
|
+
// can reach artifact_edit. This entry is issuer-written BY THE
|
|
1548
|
+
// WORKFLOW and names the intent: outcome "publish-intent", never
|
|
1549
|
+
// "submitted" — the workflow issued nothing. The worker claims it
|
|
1550
|
+
// via the park note below.
|
|
1575
1551
|
await recordPublishLedger({
|
|
1576
1552
|
commit: mergeCommitForPublish,
|
|
1577
1553
|
attempt: rebuildAttemptKey,
|
|
1578
1554
|
agent_id: null,
|
|
1579
|
-
applied_report:
|
|
1555
|
+
applied_report: null,
|
|
1580
1556
|
manifest_before: preTriggerManifest,
|
|
1581
|
-
outcome: "
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
// and park fail-closed; correlate via the ledger, never by
|
|
1594
|
-
// re-issuing.
|
|
1595
|
-
log("Publish rebuild trigger issued for task " + taskId + " — observing build state to attribute the edit");
|
|
1596
|
-
var buildState = null;
|
|
1597
|
-
var buildStateFailed = false;
|
|
1598
|
-
try {
|
|
1599
|
-
buildState = await agent(
|
|
1600
|
-
ARTIFACT_LOAD_PREAMBLE +
|
|
1601
|
-
"Call artifact_status with slug \"" + PUBLISH_SLUG + "\".\n" +
|
|
1602
|
-
"Poll up to 3 times, about 20 seconds apart, until the response shows a build (the \"build\" value is an object, not null). " +
|
|
1603
|
-
"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. " +
|
|
1604
|
-
"Do not summarize, interpret, or derive booleans from it. " +
|
|
1605
|
-
"If no build appears after 3 polls, return null. " +
|
|
1606
|
-
"Return JSON { \"build\": <the raw build object or null> } and nothing else.",
|
|
1607
|
-
{ key: attemptKey("publish-artifact-buildcheck-" + taskId, reworkCount), label: "Reading artifact build state after trigger",
|
|
1608
|
-
schema: { type: "object", properties: { build: { type: ["object", "null"] } }, required: ["build"] } }
|
|
1609
|
-
);
|
|
1610
|
-
} catch (buildCheckErr) {
|
|
1611
|
-
buildStateFailed = true;
|
|
1612
|
-
log("Publish post-trigger build-state check failed for task " + taskId + " (" + (buildCheckErr && buildCheckErr.message ? buildCheckErr.message : buildCheckErr) + ") — this signal is unknown, not negative");
|
|
1613
|
-
}
|
|
1614
|
-
var observedAgentId = (buildState && buildState.build && typeof buildState.build.agent_id === "string" && buildState.build.agent_id) || null;
|
|
1615
|
-
// See docs/decisions/publish-path.md#attribution-limitation: attribution is timing-based; content verification bounds the risk.
|
|
1616
|
-
var receiptAgentId = (!buildStateFailed && !baselineFailed && observedAgentId && observedAgentId !== baselineAgentId) ? observedAgentId : null;
|
|
1617
|
-
// auditReportOk: pure tri-state read of a report.json body —
|
|
1618
|
-
// true (build ok), false (build failed), null (missing or
|
|
1619
|
-
// unreadable — not evidence either way). The child returns the
|
|
1620
|
-
// raw body verbatim; interpretation lives here, never in prose.
|
|
1621
|
-
// Hoisted to Publish-step scope (before the receipt branch) so both
|
|
1622
|
-
// the immediate and post-poll audit fallbacks share it on every path —
|
|
1623
|
-
// the receipt path skips the else below, which must not leave these
|
|
1624
|
-
// undefined.
|
|
1625
|
-
var auditReportOk = function (raw) {
|
|
1626
|
-
if (typeof raw !== "string") return null;
|
|
1627
|
-
var trimmed = raw.trim();
|
|
1628
|
-
if (trimmed === "" || trimmed === "MISSING") return null;
|
|
1629
|
-
var parsed;
|
|
1630
|
-
try { parsed = JSON.parse(trimmed); } catch (e) { return null; }
|
|
1631
|
-
if (parsed && typeof parsed.ok === "boolean") return parsed.ok;
|
|
1632
|
-
return null;
|
|
1633
|
-
};
|
|
1634
|
-
// (2026-09-18, H2 verdict-first) Publish-verdict vocabulary. The
|
|
1635
|
-
// verdict is one of "landed" | "unknown". Decided once,
|
|
1636
|
-
// before the receipt poll, and dispatched on — never re-derived.
|
|
1637
|
-
// Pure and self-contained: unit-tested by
|
|
1638
|
-
// tests/publish-verdict-first.test.js.
|
|
1639
|
-
// See docs/decisions/publish-path.md#h2-verdict-dispatch.
|
|
1640
|
-
var decidePublishVerdict = function (opts) {
|
|
1641
|
-
var immediateReport = (opts && "immediateReport" in opts) ? opts.immediateReport : null;
|
|
1642
|
-
var newDirCount = (opts && typeof opts.newDirCount === "number") ? opts.newDirCount : 0;
|
|
1643
|
-
if (newDirCount === 1 && immediateReport === true) return { verdict: "landed", unattributableReason: null };
|
|
1644
|
-
if (newDirCount === 1 && immediateReport === false) return { verdict: "unknown", unattributableReason: "audit-report-ok-false" };
|
|
1645
|
-
if (newDirCount === 1) return { verdict: "unknown", unattributableReason: "audit-report-unreadable-or-missing" };
|
|
1646
|
-
if (newDirCount === 0) return { verdict: "unknown", unattributableReason: "no-new-audit-dir-in-window" };
|
|
1647
|
-
return { verdict: "unknown", unattributableReason: "audit-dir-ambiguity", ambiguousDirCount: newDirCount };
|
|
1648
|
-
};
|
|
1649
|
-
// (2026-09-18, H2 message contract, design §1.5) The human line is
|
|
1650
|
-
// the output of a mechanical field→template mapping: the trigger
|
|
1651
|
-
// commit short-sha, one plain clause per unattributable reason, the
|
|
1652
|
-
// no-republish warning, the ledger path with (outcome: unknown), and
|
|
1653
|
-
// the unknown-recovery clause. The appendix carries every machine
|
|
1654
|
-
// field. Pure and self-contained: unit-tested by
|
|
1655
|
-
// tests/publish-verdict-first.test.js.
|
|
1656
|
-
var composeUnattributedParkReason = function (fields) {
|
|
1657
|
-
var f = fields || {};
|
|
1658
|
-
var task = f.taskId || taskId;
|
|
1659
|
-
var reason = f.unattributableReason || "unknown-outcome";
|
|
1660
|
-
var shortSha = String(f.commitShortSha || "").substring(0, 7) || "unknown";
|
|
1661
|
-
var reasonClauses = {
|
|
1662
|
-
"no-new-audit-dir-in-window": "no build could be tied to this attempt",
|
|
1663
|
-
"audit-report-unreadable-or-missing": "the build's report is unreadable",
|
|
1664
|
-
"audit-dir-ambiguity": "more than one build appeared in the check window",
|
|
1665
|
-
"stranger-build-observed-during-poll": "a different build was running during the check",
|
|
1666
|
-
"status-read-errors-during-poll": "status reads kept failing"
|
|
1667
|
-
};
|
|
1668
|
-
var clause = reasonClauses[reason] || "no build could be tied to this attempt";
|
|
1669
|
-
return "Publish outcome unknown for task " + task +
|
|
1670
|
-
": the trigger was sent for commit " + shortSha + " but the outcome could not be confirmed — " + clause + ". " +
|
|
1671
|
-
"Do NOT republish: if the trigger was accepted, a retry duplicates the build (2026-09-12). " +
|
|
1672
|
-
"The attempt is in the ledger at " + crewHome + "/.publish-ledger/" + PUBLISH_SLUG + ".jsonl (outcome: unknown) " +
|
|
1673
|
-
"and the crew's unknown-recovery will re-examine it. " +
|
|
1674
|
-
"Appendix: unattributable_reason=" + reason +
|
|
1675
|
-
"; poll_end_state=" + (f.pollEndState || "not-polled") +
|
|
1676
|
-
"; saw_our_build=" + (f.sawOurBuild ? "true" : "false") +
|
|
1677
|
-
"; new_audit_dirs=" + (f.newAuditDirCount == null ? 0 : f.newAuditDirCount) +
|
|
1678
|
-
"; poll_chunks_failed=" + (f.chunkFailures == null ? 0 : f.chunkFailures) +
|
|
1679
|
-
"; poll_status_errors=" + (f.pollStatusErrors == null ? 0 : f.pollStatusErrors) + ".";
|
|
1680
|
-
};
|
|
1681
|
-
// publishFailure is declared here (per-Publish-pass scope) so the
|
|
1682
|
-
// post-poll explicit build failure survives to the final routing
|
|
1683
|
-
// below; publishUnknownFields carries the structured unknown fields
|
|
1684
|
-
// for the single composed fail-closed park. Both re-initialize on
|
|
1685
|
-
// every pass — a rework re-entry never leaks a stale verdict.
|
|
1686
|
-
var publishFailure = null;
|
|
1687
|
-
var publishUnknownFields = null;
|
|
1688
|
-
if (receiptAgentId) {
|
|
1689
|
-
// The edit went through — a build with a new agent_id appeared
|
|
1690
|
-
// after the trigger. The parent's independent read-back
|
|
1691
|
-
// (docs/publish-verification.md) is the verification, not any
|
|
1692
|
-
// builder report.
|
|
1693
|
-
rebuildTrigger = { edit_started: true };
|
|
1694
|
-
rebuildAgentId = receiptAgentId;
|
|
1695
|
-
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.");
|
|
1696
|
-
await recordPublishLedger({
|
|
1697
|
-
commit: mergeCommitForPublish,
|
|
1698
|
-
attempt: rebuildAttemptKey,
|
|
1699
|
-
agent_id: rebuildAgentId,
|
|
1700
|
-
applied_report: publishAppliedObservation,
|
|
1701
|
-
manifest_before: preTriggerManifest,
|
|
1702
|
-
outcome: "submitted",
|
|
1703
|
-
detail: "fire-and-forget trigger; build receipt captured by workflow-owned build-state observation (pre/post-trigger diff); observation, not re-issuance"
|
|
1704
|
-
}, reworkCount, "receipt");
|
|
1705
|
-
} else {
|
|
1706
|
-
var newAuditDirs = [];
|
|
1707
|
-
try {
|
|
1708
|
-
var auditAfter = await agent(
|
|
1709
|
-
"List the artifact audit directories for slug \"" + PUBLISH_SLUG + "\" (best-effort, never a gate).\n" +
|
|
1710
|
-
"Run: ls -1 ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/ 2>/dev/null\n" +
|
|
1711
|
-
"Return JSON { \"dirs\": \"<newline-separated names, empty string when the audits directory does not exist or is empty>\" } and nothing else.",
|
|
1712
|
-
{ key: attemptKey("publish-audit-after-" + taskId, reworkCount), label: "Re-listing audit dirs after trigger",
|
|
1713
|
-
schema: { type: "object", properties: { dirs: { type: "string" } }, required: ["dirs"] } }
|
|
1714
|
-
);
|
|
1715
|
-
var auditDirsAfterTrigger = String((auditAfter && auditAfter.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
|
|
1716
|
-
// Only timestamped build dirs count — the "latest" symlink
|
|
1717
|
-
// and anything else are not builds. Gated on auditBeforeOk:
|
|
1718
|
-
// without a baseline every historical dir would look new.
|
|
1719
|
-
newAuditDirs = auditBeforeOk ? auditDirsAfterTrigger.filter(function (d) {
|
|
1720
|
-
return auditDirsBeforeTrigger.indexOf(d) === -1 && /^20\d\d-\d\d-\d\dT\d\d-\d\d-\d\dZ-/.test(d);
|
|
1721
|
-
}) : [];
|
|
1722
|
-
} catch (auditAfterErr) {
|
|
1723
|
-
log("Publish audit-dir re-list after trigger failed for task " + taskId + " (non-fatal, durable-evidence check degraded): " + (auditAfterErr && auditAfterErr.message ? auditAfterErr.message : auditAfterErr));
|
|
1724
|
-
}
|
|
1725
|
-
if (newAuditDirs.length > 0) {
|
|
1726
|
-
rebuildAgentId = null;
|
|
1727
|
-
newAuditDirs.sort();
|
|
1728
|
-
var newestImmediateDir = newAuditDirs[newAuditDirs.length - 1];
|
|
1729
|
-
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.");
|
|
1730
|
-
// (2026-09-18, H2 verdict-first) Durable audit evidence exists,
|
|
1731
|
-
// but there is no receipt agent_id to chain the completion poll
|
|
1732
|
-
// to — polling with a null receipt can only observe strangers
|
|
1733
|
-
// (any running build differs from "null") or nothing, burning
|
|
1734
|
-
// 10.5 minutes to park unknown. Read the build report now instead
|
|
1735
|
-
// of polling, then decide the verdict ONCE via
|
|
1736
|
-
// decidePublishVerdict: exactly one new dir with ok=true lands
|
|
1737
|
-
// (attribution by window, not identity — never poll blind);
|
|
1738
|
-
// ok=false is UNKNOWN with the failure evidence preserved in the
|
|
1739
|
-
// ledger detail (the evidence is explicit, the attribution is
|
|
1740
|
-
// not); unreadable / zero / ambiguous dirs are UNKNOWN.
|
|
1741
|
-
// Verdict-first: landed bypasses the poll below, unknown falls
|
|
1742
|
-
// through to post-deploy. STEP 2 runs on every path.
|
|
1743
|
-
// See docs/decisions/publish-path.md#h2-verdict-dispatch.
|
|
1744
|
-
var immediateReportOk = null;
|
|
1745
|
-
// (N1) Read the report only when exactly one new dir exists:
|
|
1746
|
-
// ambiguity (>1) forces UNKNOWN regardless — don't shell out to
|
|
1747
|
-
// read a report that will be discarded.
|
|
1748
|
-
if (newAuditDirs.length === 1) {
|
|
1749
|
-
try {
|
|
1750
|
-
var immediateOkRead = await agent(
|
|
1751
|
-
"Read the artifact build report for slug \"" + PUBLISH_SLUG + "\".\n" +
|
|
1752
|
-
"Run: cat ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/" + newestImmediateDir + "/report.json 2>/dev/null || echo MISSING\n" +
|
|
1753
|
-
"Return JSON { \"raw\": \"<verbatim file contents, or the literal string MISSING when the file does not exist>\" } and nothing else.",
|
|
1754
|
-
{ key: attemptKey("publish-audit-ok-immediate-" + taskId, reworkCount), label: "Reading build report for audit-confirmed build",
|
|
1755
|
-
schema: { type: "object", properties: { raw: { type: "string" } }, required: ["raw"] } }
|
|
1756
|
-
);
|
|
1757
|
-
immediateReportOk = auditReportOk(immediateOkRead && immediateOkRead.raw);
|
|
1758
|
-
} catch (immediateOkErr) {
|
|
1759
|
-
log("Publish build-report read for audit-confirmed dir failed for task " + taskId + " (treated as unknown): " + (immediateOkErr && immediateOkErr.message ? immediateOkErr.message : immediateOkErr));
|
|
1760
|
-
immediateReportOk = null;
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
var immediateVerdict = decidePublishVerdict({ editStarted: true, immediateReport: immediateReportOk, newDirCount: newAuditDirs.length });
|
|
1764
|
-
if (immediateVerdict.verdict === "landed") {
|
|
1765
|
-
publishBuildLanded = true;
|
|
1766
|
-
artifactPublish = { source_commit: mergeCommitForPublish, pending_parent_verification: true };
|
|
1767
|
-
await recordPublishLedger({
|
|
1768
|
-
commit: mergeCommitForPublish,
|
|
1769
|
-
attempt: rebuildAttemptKey,
|
|
1770
|
-
agent_id: null,
|
|
1771
|
-
applied_report: publishAppliedObservation,
|
|
1772
|
-
manifest_before: preTriggerManifest,
|
|
1773
|
-
outcome: "build-observed",
|
|
1774
|
-
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)"
|
|
1775
|
-
}, reworkCount);
|
|
1776
|
-
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.");
|
|
1777
|
-
} else {
|
|
1778
|
-
// Verdict UNKNOWN on the immediate path. ok=false is explicit
|
|
1779
|
-
// failure evidence but not an attributable failure — the ledger
|
|
1780
|
-
// records unknown with the evidence preserved in the detail,
|
|
1781
|
-
// and the flow continues to post-deploy (never parks early).
|
|
1782
|
-
publishUnknownFields = {
|
|
1783
|
-
taskId: taskId,
|
|
1784
|
-
unattributableReason: immediateVerdict.unattributableReason,
|
|
1785
|
-
pollEndState: "not-polled",
|
|
1786
|
-
sawOurBuild: false,
|
|
1787
|
-
newAuditDirCount: newAuditDirs.length,
|
|
1788
|
-
chunkFailures: 0,
|
|
1789
|
-
pollStatusErrors: 0
|
|
1790
|
-
};
|
|
1791
|
-
var immediateDetail = "durable audit-dir fallback could not prove a completed build for this attempt (unattributable_reason=" + immediateVerdict.unattributableReason + ", no receipt agent_id)";
|
|
1792
|
-
if (immediateReportOk === false) {
|
|
1793
|
-
immediateDetail += "; explicit failure evidence preserved: report ok=false for audit dir " + newestImmediateDir;
|
|
1794
|
-
}
|
|
1795
|
-
if (immediateVerdict.unattributableReason === "audit-dir-ambiguity") {
|
|
1796
|
-
immediateDetail += "; audit-dir ambiguity: " + newAuditDirs.length + " new dirs in window";
|
|
1797
|
-
}
|
|
1798
|
-
await recordPublishLedger({
|
|
1799
|
-
commit: mergeCommitForPublish,
|
|
1800
|
-
attempt: rebuildAttemptKey,
|
|
1801
|
-
agent_id: null,
|
|
1802
|
-
applied_report: publishAppliedObservation,
|
|
1803
|
-
outcome: "unknown",
|
|
1804
|
-
detail: immediateDetail
|
|
1805
|
-
}, reworkCount);
|
|
1806
|
-
log("Publish verdict UNKNOWN for task " + taskId + ": " + immediateDetail + " — continuing to post-deploy; never polling blind and never parking early.");
|
|
1807
|
-
}
|
|
1808
|
-
} else {
|
|
1809
|
-
// See docs/decisions/publish-path.md#no-attributable-build: no attributable build and no durable evidence means no publish.
|
|
1810
|
-
publishUnknownFields = {
|
|
1811
|
-
taskId: taskId,
|
|
1812
|
-
unattributableReason: decidePublishVerdict({ editStarted: true, immediateReport: null, newDirCount: 0 }).unattributableReason,
|
|
1813
|
-
pollEndState: "not-polled",
|
|
1814
|
-
sawOurBuild: false,
|
|
1815
|
-
newAuditDirCount: 0,
|
|
1816
|
-
chunkFailures: 0,
|
|
1817
|
-
pollStatusErrors: 0
|
|
1818
|
-
};
|
|
1819
|
-
await recordPublishLedger({
|
|
1820
|
-
commit: mergeCommitForPublish,
|
|
1821
|
-
attempt: rebuildAttemptKey,
|
|
1822
|
-
agent_id: null,
|
|
1823
|
-
applied_report: publishAppliedObservation,
|
|
1824
|
-
outcome: "unknown",
|
|
1825
|
-
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"
|
|
1826
|
-
}, reworkCount);
|
|
1827
|
-
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.");
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
// Durable publish-attempt ledger: record the trigger outcome while the
|
|
1831
|
-
// attempt key and commit are in scope. Every attempt lands here with
|
|
1832
|
-
// its outcome — submitted, rejected, or unknown (unknown is recorded
|
|
1833
|
-
// at the park site above). A later run or human matches commit hash +
|
|
1834
|
-
// attempt key against the builder's eventual completion.
|
|
1835
|
-
// (2026-09-18, H2 verdict-first) The verdict was decided exactly
|
|
1836
|
-
// once above; dispatch on it. landed bypasses the receipt poll
|
|
1837
|
-
// (the audit evidence already proved completion); an explicit
|
|
1838
|
-
// publishFailure is preserved verbatim through post-deploy.
|
|
1839
|
-
// Otherwise the verdict is open — but the poll below is only
|
|
1840
|
-
// legitimate against a real receipt: the null-safe assertion records
|
|
1841
|
-
// UNKNOWN and continues to STEP 2 instead of polling blind.
|
|
1842
|
-
// See docs/decisions/publish-path.md#h2-verdict-dispatch.
|
|
1843
|
-
if (publishBuildLanded) {
|
|
1844
|
-
log("Publish verdict already LANDED for task " + taskId + " — bypassing receipt poll.");
|
|
1845
|
-
} else if (publishFailure) {
|
|
1846
|
-
// design §1.2 pre-poll branch — currently unassigned; kept for the converged dispatch shape.
|
|
1847
|
-
log("Publish verdict already FAILED for task " + taskId + " — preserved verbatim through post-deploy.");
|
|
1848
|
-
} else if (!rebuildTrigger || !rebuildTrigger.edit_started) {
|
|
1849
|
-
// Loud defensive assertion (replaces the old lying "Unreachable"
|
|
1850
|
-
// else): with no receipt state the poll would observe strangers or
|
|
1851
|
-
// nothing — record UNKNOWN and continue to STEP 2. Never park
|
|
1852
|
-
// early here; never poll blind.
|
|
1853
|
-
if (!publishUnknownFields) {
|
|
1854
|
-
publishUnknownFields = {
|
|
1855
|
-
taskId: taskId,
|
|
1856
|
-
unattributableReason: "no-receipt-state",
|
|
1857
|
-
pollEndState: "not-polled",
|
|
1858
|
-
sawOurBuild: false,
|
|
1859
|
-
newAuditDirCount: 0,
|
|
1860
|
-
chunkFailures: 0,
|
|
1861
|
-
pollStatusErrors: 0
|
|
1862
|
-
};
|
|
1863
|
-
await recordPublishLedger({
|
|
1864
|
-
commit: mergeCommitForPublish,
|
|
1865
|
-
attempt: rebuildAttemptKey,
|
|
1866
|
-
agent_id: null,
|
|
1867
|
-
applied_report: publishAppliedObservation,
|
|
1868
|
-
outcome: "unknown",
|
|
1869
|
-
detail: "no receipt state was recorded for this attempt — never polling blind; continuing to post-deploy"
|
|
1870
|
-
}, reworkCount);
|
|
1871
|
-
}
|
|
1872
|
-
log("Publish verdict UNKNOWN for task " + taskId + ": no receipt state recorded — never polling blind, continuing to post-deploy.");
|
|
1873
|
-
} else {
|
|
1874
|
-
// (2026-09-16) There is no builder report: the fire-and-forget
|
|
1875
|
-
// trigger carries no JSON contract, so there is nothing to
|
|
1876
|
-
// compare and no pre-hash diagnostic. The builder's old
|
|
1877
|
-
// self-report was circular by construction (canary run 8) with a
|
|
1878
|
-
// demonstrated false-negative mode (task 23ca8f3f, 2026-09-12:
|
|
1879
|
-
// applied:[] for a diff the builder had applied). The flow
|
|
1880
|
-
// proceeds to the build poll regardless; real verification is the
|
|
1881
|
-
// parent's independent read-back (docs/publish-verification.md)
|
|
1882
|
-
// before the provenance stamp.
|
|
1883
|
-
// STEP 1b (mechanical): bounded poll for build completion, chunked so
|
|
1884
|
-
// the merge-lock lease is refreshed before it can expire. The 600s
|
|
1885
|
-
// lease is shorter than the worst-case 10-minute build poll, so the
|
|
1886
|
-
// poll runs in three chunks (7 checks x 30s ~= 3.5 min each) with a
|
|
1887
|
-
// holder-only lease refresh between chunks. If a refresh fails, the
|
|
1888
|
-
// lock was lost: stop the run and park the task — never continue to
|
|
1889
|
-
// a provenance stamp or version assignment without holding the lock.
|
|
1890
|
-
var buildPoll = null;
|
|
1891
|
-
// STEP 1b poll-signal accumulators (2026-09-15, task aadeccc3):
|
|
1892
|
-
// the durable audit-dir fallback below needs the poll's own
|
|
1893
|
-
// observations, not just its final verdict — whether our build was
|
|
1894
|
-
// ever seen, whether a stranger's build was ever in flight, and
|
|
1895
|
-
// what the last check observed. OR-ed across all three chunks so
|
|
1896
|
-
// a signal seen in any chunk survives the chunk boundary.
|
|
1897
|
-
var pollSawOurBuild = false;
|
|
1898
|
-
var pollSawStranger = false;
|
|
1899
|
-
var lastObservedAgentId = null;
|
|
1900
|
-
// Poll-chunk failure record (2026-09-16, task 1febe8eb): chunk
|
|
1901
|
-
// agent calls that threw instead of returning a verdict —
|
|
1902
|
-
// recorded for the post-poll diagnosis, never terminal alone.
|
|
1903
|
-
var chunkFailures = [];
|
|
1904
|
-
// Poll status-read error count (2026-09-16): a failed
|
|
1905
|
-
// artifact_status read (rate limiting / TOO_MANY_REQUESTS /
|
|
1906
|
-
// 429, network error, or any non-build response) is
|
|
1907
|
-
// inconclusive — it is NOT evidence of absence and must never
|
|
1908
|
-
// be folded into the no-build-observed signal. Counted for
|
|
1909
|
-
// the post-poll diagnosis only; never terminal alone.
|
|
1910
|
-
var pollStatusErrors = 0;
|
|
1911
|
-
for (var chunk = 1; chunk <= 3; chunk++) {
|
|
1912
|
-
if (chunk > 1) {
|
|
1913
|
-
var refreshPoll = await agent(
|
|
1914
|
-
"Refresh the merge lock for task " + taskId + ".\n" +
|
|
1915
|
-
"Run: " + LIFECYCLE_ENV + " refresh-lock " + taskId + "\n" +
|
|
1916
|
-
"If the output contains REFRESHED, return JSON { \"held\": true } and nothing else. Otherwise return JSON { \"held\": false, \"output\": \"<verbatim output>\" } and nothing else.",
|
|
1917
|
-
{ key: attemptKey("publish-lock-refresh-poll-" + taskId + "-c" + chunk, reworkCount), label: "Refreshing merge lock during build poll",
|
|
1918
|
-
schema: { type: "object", properties: { held: { type: "boolean" }, output: { type: "string" } }, required: ["held"] },
|
|
1919
|
-
timeoutMs: 60000 }
|
|
1920
|
-
);
|
|
1921
|
-
if (!refreshPoll || refreshPoll.held !== true) {
|
|
1922
|
-
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.");
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
// Chunk 1 keeps the original stable key; later chunks use -c<N>
|
|
1926
|
-
// suffixed keys. All are attemptKey-scoped so rework passes stay
|
|
1927
|
-
// disjoint (replay-key contract).
|
|
1928
|
-
var pollKey = (chunk === 1)
|
|
1929
|
-
? attemptKey("publish-artifact-poll-" + taskId, reworkCount)
|
|
1930
|
-
: attemptKey("publish-artifact-poll-" + taskId + "-c" + chunk, reworkCount);
|
|
1931
|
-
try {
|
|
1932
|
-
buildPoll = await agent(
|
|
1933
|
-
"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" +
|
|
1934
|
-
"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" +
|
|
1935
|
-
"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" +
|
|
1936
|
-
"- 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" +
|
|
1937
|
-
"- If no build is running (build is null) and you previously observed our build running: our build finished. Stop and report done.\n" +
|
|
1938
|
-
"- If the running build's agent_id equals \"" + rebuildAgentId + "\": still ours \u2014 keep waiting.\n" +
|
|
1939
|
-
"- 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" +
|
|
1940
|
-
"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.",
|
|
1941
|
-
{ key: pollKey, label: "Waiting for artifact build to complete (chunk " + chunk + " of 3)",
|
|
1942
|
-
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"] },
|
|
1943
|
-
timeoutMs: 270000 }
|
|
1944
|
-
);
|
|
1945
|
-
} catch (chunkErr) {
|
|
1946
|
-
// See docs/decisions/publish-path.md#hung-chunk: a hung or failed chunk is inconclusive, never terminal.
|
|
1947
|
-
chunkFailures.push("chunk " + chunk + ": " + (chunkErr && chunkErr.message ? chunkErr.message : chunkErr));
|
|
1948
|
-
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.");
|
|
1949
|
-
}
|
|
1950
|
-
if (buildPoll) {
|
|
1951
|
-
pollSawOurBuild = pollSawOurBuild || (buildPoll.saw_our_build === true);
|
|
1952
|
-
pollSawStranger = pollSawStranger || (buildPoll.saw_stranger === true);
|
|
1953
|
-
lastObservedAgentId = buildPoll.observed_agent_id || null;
|
|
1954
|
-
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."); }
|
|
1955
|
-
if (buildPoll.build_done) { break; }
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
if (!buildPoll || !buildPoll.build_done) {
|
|
1959
|
-
buildPoll = { build_done: false, status: (buildPoll && buildPoll.status) || "build still running after the 10.5-minute bounded poll" };
|
|
1960
|
-
}
|
|
1961
|
-
if (buildPoll.build_done && pollSawOurBuild) {
|
|
1962
|
-
// See docs/decisions/publish-path.md#step-1c-no-stamp: no provenance stamp in STEP 1c.
|
|
1963
|
-
publishBuildLanded = true;
|
|
1964
|
-
artifactPublish = { source_commit: mergeCommitForPublish, pending_parent_verification: true };
|
|
1965
|
-
log("Publish build landed for task " + taskId + " — provenance stamp deferred to parent content verification");
|
|
1966
|
-
} else {
|
|
1967
|
-
// STEP 1b durable audit-dir fallback (2026-09-15, task aadeccc3):
|
|
1968
|
-
// the poll observes only in-flight builds; a build that finished
|
|
1969
|
-
// inside the window leaves a durable audit dir. Diff the audit
|
|
1970
|
-
// listing against the pre-trigger snapshot: a new timestamped dir
|
|
1971
|
-
// is evidence a build completed. Attribution is by window, not by build identity: any
|
|
1972
|
-
// observed stranger blocks it. Never re-issues, never stamps;
|
|
1973
|
-
// ok=true routes to the parent's read-back (the verification).
|
|
1974
|
-
//
|
|
1975
|
-
// The poll end-state is read from the poll's own observations,
|
|
1976
|
-
// not from build_done alone: a build in flight at the last check
|
|
1977
|
-
// means the budget was shorter than the latency (or the build is
|
|
1978
|
-
// stuck) — NOT that no build ever started; nothing observed at
|
|
1979
|
-
// any check is the never-started signal.
|
|
1980
|
-
var pollEndState = lastObservedAgentId ? "build-still-running-at-poll-end"
|
|
1981
|
-
: (pollSawOurBuild ? "our-build-observed-then-unconfirmed" : "no-build-observed-in-window");
|
|
1982
|
-
var strangerObserved = pollSawStranger;
|
|
1983
|
-
var newAuditDirsAfterPoll = [];
|
|
1984
|
-
try {
|
|
1985
|
-
var auditAfterPoll = await agent(
|
|
1986
|
-
"List the artifact audit directories for slug \"" + PUBLISH_SLUG + "\" (best-effort, never a gate).\n" +
|
|
1987
|
-
"Run: ls -1 ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/ 2>/dev/null\n" +
|
|
1988
|
-
"Return JSON { \"dirs\": \"<newline-separated names, empty string when the audits directory does not exist or is empty>\" } and nothing else.",
|
|
1989
|
-
{ key: attemptKey("publish-audit-after-poll-" + taskId, reworkCount), label: "Re-listing audit dirs after build poll",
|
|
1990
|
-
schema: { type: "object", properties: { dirs: { type: "string" } }, required: ["dirs"] } }
|
|
1991
|
-
);
|
|
1992
|
-
var auditDirsAfterPollList = String((auditAfterPoll && auditAfterPoll.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
|
|
1993
|
-
// Gated on auditBeforeOk (critic finding 4): without a baseline
|
|
1994
|
-
// every historical dir would look new.
|
|
1995
|
-
newAuditDirsAfterPoll = auditBeforeOk ? auditDirsAfterPollList.filter(function (d) {
|
|
1996
|
-
return auditDirsBeforeTrigger.indexOf(d) === -1 && /^20\d\d-\d\d-\d\dT\d\d-\d\d-\d\dZ-/.test(d);
|
|
1997
|
-
}) : [];
|
|
1998
|
-
log("Publish audit-dir re-list after build poll for task " + taskId + ": " + newAuditDirsAfterPoll.length + " new timestamped dir(s)");
|
|
1999
|
-
} catch (auditAfterPollErr) {
|
|
2000
|
-
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));
|
|
2001
|
-
}
|
|
2002
|
-
// The shared auditReportOk (defined with the immediate fallback
|
|
2003
|
-
// above) interprets the raw body here too.
|
|
2004
|
-
var auditOkAfterPoll = null;
|
|
2005
|
-
var newestAuditDirAfterPoll = null;
|
|
2006
|
-
if (newAuditDirsAfterPoll.length > 0 && !strangerObserved) {
|
|
2007
|
-
newAuditDirsAfterPoll.sort();
|
|
2008
|
-
newestAuditDirAfterPoll = newAuditDirsAfterPoll[newAuditDirsAfterPoll.length - 1];
|
|
2009
|
-
try {
|
|
2010
|
-
var auditOkRead = await agent(
|
|
2011
|
-
"Read the build report for artifact slug \"" + PUBLISH_SLUG + "\", audit dir \"" + newestAuditDirAfterPoll + "\" (verbatim read, never interpreted, never a gate).\n" +
|
|
2012
|
-
"Run: cat ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/" + newestAuditDirAfterPoll + "/report.json 2>/dev/null || echo MISSING\n" +
|
|
2013
|
-
"Return JSON { \"raw\": \"<verbatim file contents, or the literal string MISSING when the file does not exist>\" } and nothing else.",
|
|
2014
|
-
{ key: attemptKey("publish-audit-ok-after-poll-" + taskId, reworkCount), label: "Reading build report after build poll",
|
|
2015
|
-
schema: { type: "object", properties: { raw: { type: "string" } }, required: ["raw"] } }
|
|
2016
|
-
);
|
|
2017
|
-
auditOkAfterPoll = auditReportOk(auditOkRead && auditOkRead.raw);
|
|
2018
|
-
} catch (auditOkReadErr) {
|
|
2019
|
-
log("Publish build-report read after build poll failed for task " + taskId + " (non-fatal, treated as unknown): " + (auditOkReadErr && auditOkReadErr.message ? auditOkReadErr.message : auditOkReadErr));
|
|
2020
|
-
auditOkAfterPoll = null;
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
if (auditOkAfterPoll === true) {
|
|
2024
|
-
publishBuildLanded = true;
|
|
2025
|
-
artifactPublish = { source_commit: mergeCommitForPublish, pending_parent_verification: true };
|
|
2026
|
-
log("Publish build landed for task " + taskId + " via durable audit evidence — provenance stamp deferred to parent content verification");
|
|
2027
|
-
await recordPublishLedger({
|
|
2028
|
-
commit: mergeCommitForPublish,
|
|
2029
|
-
attempt: rebuildAttemptKey,
|
|
2030
|
-
agent_id: rebuildAgentId,
|
|
2031
|
-
applied_report: publishAppliedObservation,
|
|
2032
|
-
manifest_before: preTriggerManifest,
|
|
2033
|
-
outcome: "build-observed",
|
|
2034
|
-
detail: "durable audit evidence shows a build completed during the attempt window (audit dir " + newestAuditDirAfterPoll + ", report ok=true); routed to parent verification"
|
|
2035
|
-
}, reworkCount);
|
|
2036
|
-
} else if (auditOkAfterPoll === false) {
|
|
2037
|
-
// Explicit negative evidence under the stranger guard: a build
|
|
2038
|
-
// ran and failed during the poll window with no stranger in
|
|
2039
|
-
// flight. This is an attributable failure — preserved verbatim
|
|
2040
|
-
// through post-deploy. Message contract unchanged.
|
|
2041
|
-
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.";
|
|
2042
|
-
await recordPublishLedger({
|
|
2043
|
-
commit: mergeCommitForPublish,
|
|
2044
|
-
attempt: rebuildAttemptKey,
|
|
2045
|
-
agent_id: rebuildAgentId,
|
|
2046
|
-
applied_report: publishAppliedObservation,
|
|
2047
|
-
outcome: "failed",
|
|
2048
|
-
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"
|
|
2049
|
-
}, reworkCount);
|
|
2050
|
-
} else {
|
|
2051
|
-
var unattributableReason = strangerObserved ? "stranger-build-observed-during-poll"
|
|
2052
|
-
: ((pollStatusErrors > 0 && !pollSawOurBuild) ? "status-read-errors-during-poll"
|
|
2053
|
-
: (pollEndState === "build-still-running-at-poll-end" ? "build-still-running-at-poll-end"
|
|
2054
|
-
: (newAuditDirsAfterPoll.length === 0 ? "no-new-audit-dir-in-window" : "audit-report-unreadable-or-missing")));
|
|
2055
|
-
// Verdict UNKNOWN (poll path): the build cannot be attributed
|
|
2056
|
-
// to this attempt. The fields feed the single composed
|
|
2057
|
-
// fail-closed park reason after post-deploy — never a
|
|
2058
|
-
// fabricated verdict, never a silent pass.
|
|
2059
|
-
publishUnknownFields = {
|
|
2060
|
-
taskId: taskId,
|
|
2061
|
-
unattributableReason: unattributableReason,
|
|
2062
|
-
pollEndState: pollEndState,
|
|
2063
|
-
sawOurBuild: pollSawOurBuild,
|
|
2064
|
-
newAuditDirCount: newAuditDirsAfterPoll.length,
|
|
2065
|
-
chunkFailures: chunkFailures.length,
|
|
2066
|
-
pollStatusErrors: pollStatusErrors
|
|
2067
|
-
};
|
|
2068
|
-
await recordPublishLedger({
|
|
2069
|
-
commit: mergeCommitForPublish,
|
|
2070
|
-
attempt: rebuildAttemptKey,
|
|
2071
|
-
agent_id: rebuildAgentId,
|
|
2072
|
-
applied_report: publishAppliedObservation,
|
|
2073
|
-
outcome: "unknown",
|
|
2074
|
-
detail: "durable audit-dir fallback could not attribute a completed build to this attempt (unattributable_reason=" + unattributableReason + ", poll_end_state=" + pollEndState + ")"
|
|
2075
|
-
}, reworkCount);
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
}
|
|
2079
|
-
|
|
1557
|
+
outcome: "publish-intent",
|
|
1558
|
+
issuer: "workflow",
|
|
1559
|
+
diff_path: publishDiffFile,
|
|
1560
|
+
diff_sha256: publishDiffSha256,
|
|
1561
|
+
// (2026-09-20, critic-0145 F-A4) The base the diff was computed
|
|
1562
|
+
// against: scan-publish-unknown's intent branch compares it with
|
|
1563
|
+
// current stamped provenance and re-queues the task when it went
|
|
1564
|
+
// stale — never issues the stale diff.
|
|
1565
|
+
base: publishBase,
|
|
1566
|
+
detail: "publish intent: preflight, checksummed diff, toolcheck, and pre-trigger baselines are complete; issuance is owned by the session-carrying tick worker. The workflow performed no artifact_edit and wrote no issuance."
|
|
1567
|
+
}, reworkCount);
|
|
1568
|
+
return await parkTask("publish: publish-requested " + mergeCommitForPublish + " " + rebuildAttemptKey + " — Publish intent recorded for task " + taskId + ": the merged change is staged as a checksummed diff (" + publishDiffFile + ", sha256 " + publishDiffSha256 + ") for the crew's publish worker to issue. The worker verifies the build and stamps provenance before this task resumes; no action needed.");
|
|
2080
1569
|
} // end: publishSkippedNoLock — no rebuild, no stamp, nothing to ship
|
|
2081
1570
|
// STEP 2 (mechanical, always — skip path included): post-deploy
|
|
2082
1571
|
// commits builder leftovers if any, removes the worktree, and releases
|
|
@@ -2089,34 +1578,17 @@ while (i < STEPS.length) {
|
|
|
2089
1578
|
{ key: attemptKey("publish-postdeploy-" + taskId, reworkCount), label: "Finalizing publish (post-deploy)",
|
|
2090
1579
|
schema: { type: "object", properties: { deployed: { type: "boolean" }, output: { type: "string" } }, required: ["deployed"] } }
|
|
2091
1580
|
);
|
|
2092
|
-
|
|
1581
|
+
// (2026-09-20, one-party worker-owned publish) Verified re-entry:
|
|
1582
|
+
// the intent park's terminal-cleanup already released the lock and
|
|
1583
|
+
// reclaimed the worktree. Post-deploy above is best-effort hygiene
|
|
1584
|
+
// on this branch — never a gate, never a park.
|
|
1585
|
+
if (publishAlreadyVerified) {
|
|
1586
|
+
log("Publish verified re-entry for task " + taskId + " — post-deploy ran forgivingly; continuing to the verified work-agent framing");
|
|
1587
|
+
} else if (publishSkippedNoLock) {
|
|
2093
1588
|
if (!postDeploy.deployed) {
|
|
2094
1589
|
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.");
|
|
2095
1590
|
}
|
|
2096
1591
|
log("Publish skipped cleanly for task " + taskId + " (no lock held) — post-deploy step finished");
|
|
2097
|
-
} else {
|
|
2098
|
-
if (publishFailure) {
|
|
2099
|
-
return await parkTask(publishFailure + (postDeploy.deployed
|
|
2100
|
-
? " Post-deploy step finished (cleanup status unknown)."
|
|
2101
|
-
: " Post-deploy also failed (" + (postDeploy.output || "no output") + ") — worktree and lock state unknown."));
|
|
2102
|
-
}
|
|
2103
|
-
if (!publishBuildLanded) {
|
|
2104
|
-
// Verdict UNKNOWN (single fail-closed park — post-deploy always
|
|
2105
|
-
// runs first; no early parks anywhere above). Machine contract:
|
|
2106
|
-
// "unattributable_reason=" and "poll_end_state=" are always
|
|
2107
|
-
// present; attribution is by window, not identity.
|
|
2108
|
-
// (2026-09-18, H2 message contract) Thread the commit short-sha
|
|
2109
|
-
// through the unknown fields so the human line names the trigger
|
|
2110
|
-
// commit (design §1.5: "the trigger was sent for commit <short-sha>").
|
|
2111
|
-
if (publishUnknownFields) publishUnknownFields.commitShortSha = mergeCommitShortForPublish;
|
|
2112
|
-
return await parkTask(composeUnattributedParkReason(publishUnknownFields) + (postDeploy.deployed
|
|
2113
|
-
? " Post-deploy step finished (cleanup status unknown)."
|
|
2114
|
-
: " Post-deploy also failed (" + (postDeploy.output || "no output") + ") — worktree and lock state unknown."));
|
|
2115
|
-
}
|
|
2116
|
-
if (!postDeploy.deployed) {
|
|
2117
|
-
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.");
|
|
2118
|
-
}
|
|
2119
|
-
log("Deterministic artifact publish completed for task " + taskId + ": build at " + artifactPublish.source_commit + ", provenance PENDING parent content verification");
|
|
2120
1592
|
}
|
|
2121
1593
|
} catch (pubErr) {
|
|
2122
1594
|
// Best-effort cleanup: if the lock was refreshed, try to release it
|
|
@@ -2137,7 +1609,16 @@ while (i < STEPS.length) {
|
|
|
2137
1609
|
// The work agent no longer performs the publish — it reports on the
|
|
2138
1610
|
// mechanical outcome above. It must not rebuild or re-stamp: a second
|
|
2139
1611
|
// artifact_edit would trigger a duplicate build.
|
|
2140
|
-
|
|
1612
|
+
// (2026-09-20, one-party worker-owned publish) On a verified re-entry
|
|
1613
|
+
// the publish was issued by the crew worker, verified by the parent
|
|
1614
|
+
// read-back, and stamped — the work agent reports that, VERDICT: PASS.
|
|
1615
|
+
if (publishAlreadyVerified) {
|
|
1616
|
+
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" +
|
|
1617
|
+
"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" +
|
|
1618
|
+
"For the change summary, run: cd " + REPO_PATH + " && git log -1 --stat\n\n" +
|
|
1619
|
+
"Write plain prose describing what was published, then on its own line: VERDICT: PASS\n" +
|
|
1620
|
+
"The VERDICT line must be the last line of your report.";
|
|
1621
|
+
} else if (publishSkippedNoLock) {
|
|
2141
1622
|
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" +
|
|
2142
1623
|
"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" +
|
|
2143
1624
|
"Write plain prose describing the skip, then on its own line: VERDICT: PASS\n" +
|
|
@@ -2555,20 +2036,6 @@ while (i < STEPS.length) {
|
|
|
2555
2036
|
return { status: "failed", task_id: taskId, reason: "Publish failed: " + summary };
|
|
2556
2037
|
}
|
|
2557
2038
|
|
|
2558
|
-
// See docs/decisions/publish-path.md#verification-park: the build landed but provenance is unstamped until parent verification.
|
|
2559
|
-
if (passed && step.name === "Publish" && PUBLISH_TYPE === "artifact" && PUBLISH_SLUG && !publishSkippedNoLock && publishBuildLanded) {
|
|
2560
|
-
// Success contract (2026-09-18, H2): the parent asked for exactly
|
|
2561
|
-
// one build for this publish. The build landed — do NOT republish: a
|
|
2562
|
-
// duplicate build would re-publish the same change. content_check=pending
|
|
2563
|
-
// means the parent's independent read-back has not happened yet; this
|
|
2564
|
-
// park is NOT proof the content is correct.
|
|
2565
|
-
return await parkTask("publish: verification-requested " + mergeCommitForPublish +
|
|
2566
|
-
" attempt=" + rebuildAttemptKey +
|
|
2567
|
-
" Do NOT republish: a duplicate build would re-publish the same change. " +
|
|
2568
|
-
"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. " +
|
|
2569
|
-
"Appendix: build=" + (rebuildAgentId || "agent_id unobserved") + "; provenance=unstamped; content_check=pending.");
|
|
2570
|
-
}
|
|
2571
|
-
|
|
2572
2039
|
i++;
|
|
2573
2040
|
}
|
|
2574
2041
|
|