muse-crew 0.11.0 → 0.12.0
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/API.md +5 -3
- package/docs/guide.md +1 -1
- package/docs/publish-verification.md +13 -0
- package/docs/state-boundary-spec.md +78 -0
- package/lib/AGENTS.md +6 -2
- package/lib/advance-publish-base.js +250 -0
- package/lib/classify-surface.js +109 -0
- package/lib/commit-scaffold.js +121 -0
- package/lib/compose-evidence-caption.js +55 -7
- package/lib/compute-publish-diff.js +145 -0
- package/lib/crew-api.js +34 -3
- package/lib/setup-project-repo.js +57 -11
- package/package.json +1 -1
- package/seed/cron-body-template.md +5 -4
- package/workflows/bugfix.js +58 -65
- package/workflows/chore.js +58 -65
- package/workflows/crew-dispatch.js +21 -6
- package/workflows/crew-init.js +113 -58
- package/workflows/standard.js +58 -65
package/workflows/standard.js
CHANGED
|
@@ -89,9 +89,15 @@ const PUBLISH_NPM = RUN_LIB + "/publish-npm.sh";
|
|
|
89
89
|
const CREW_API_PINNED = RUN_LIB + "/crew-api.js";
|
|
90
90
|
const SCHEMA_SQL_SRC = crewHome + "/lib/schema.sql";
|
|
91
91
|
const SCHEMA_SQL_PINNED = RUN_LIB + "/schema.sql";
|
|
92
|
-
|
|
92
|
+
const COMPUTE_DIFF_SRC = crewHome + "/current/lib/compute-publish-diff.js";
|
|
93
|
+
const COMPUTE_DIFF = RUN_LIB + "/compute-publish-diff.js";
|
|
94
|
+
// The six basenames the pin step must materialize — asserted mechanically
|
|
93
95
|
// by workflow code from the verbatim listing, never from agent prose.
|
|
94
|
-
|
|
96
|
+
// COMPUTE_DIFF is the deterministic publish-diff computer (room #14,
|
|
97
|
+
// 2026-09-17): the diff is computed by this script, never ferried as an
|
|
98
|
+
// agent JSON string. Pinned like the other publish-critical modules so a
|
|
99
|
+
// mid-run release swap cannot change it under the workflow.
|
|
100
|
+
const PIN_BASENAMES = [LIFECYCLE, MERGE_LOCK, PUBLISH_NPM, CREW_API_PINNED, SCHEMA_SQL_PINNED, COMPUTE_DIFF].map(function (p) { return p.split("/").pop(); });
|
|
95
101
|
|
|
96
102
|
// Project config — passed by dispatcher, falls back to dashboard defaults
|
|
97
103
|
const projectConfig = inputs.project_config || {};
|
|
@@ -267,7 +273,7 @@ function attemptKey(base, reworkCount) {
|
|
|
267
273
|
return base + (reworkCount > 0 ? "-r" + reworkCount : "");
|
|
268
274
|
}
|
|
269
275
|
// pinLifecycle(key) — snapshot the lifecycle scripts into RUN_LIB and return
|
|
270
|
-
// the verbatim `ls -1` listing so WORKFLOW CODE asserts the
|
|
276
|
+
// the verbatim `ls -1` listing so WORKFLOW CODE asserts the six pinned
|
|
271
277
|
// basenames; the agent cannot self-certify. (The pin step was the one place
|
|
272
278
|
// the workflows trusted agent prose: task 24be1cd6 walked to Publish on an
|
|
273
279
|
// empty pin dir.) Byte-identical across standard/bugfix/chore — pinned by
|
|
@@ -275,7 +281,7 @@ function attemptKey(base, reworkCount) {
|
|
|
275
281
|
function pinLifecycle(key) {
|
|
276
282
|
return agent(
|
|
277
283
|
"Snapshot lifecycle scripts for version pinning.\n" +
|
|
278
|
-
"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 + " && chmod +x " + LIFECYCLE + " " + MERGE_LOCK + " " + PUBLISH_NPM + " && ls -1 " + RUN_LIB + "\n" +
|
|
284
|
+
"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 + " && chmod +x " + LIFECYCLE + " " + MERGE_LOCK + " " + PUBLISH_NPM + " && ls -1 " + RUN_LIB + "\n" +
|
|
279
285
|
"Return the verbatim output of the ls -1 command as { \"listing\": \"<verbatim output>\" } and nothing else.",
|
|
280
286
|
{ key: key, label: "Pinning lifecycle scripts",
|
|
281
287
|
schema: { type: "object", properties: { listing: { type: "string" } }, required: ["listing"] } }
|
|
@@ -456,37 +462,6 @@ function hydrateReleaseDecision(rec) {
|
|
|
456
462
|
return null;
|
|
457
463
|
}
|
|
458
464
|
|
|
459
|
-
// Publish diff transport: parse a unified diff into per-file {path, added,
|
|
460
|
-
// removed} line lists. Pure function — no I/O, no clock. Used by Publish to
|
|
461
|
-
// verify the artifact builder applied the carried change (canary run 4,
|
|
462
|
-
// 2026-09-11: the builder's source tree was stale and disconnected from the
|
|
463
|
-
// crew's repo; "rebuild from current source" rebuilt stale code and the
|
|
464
|
-
// workflow stamped the new commit hash on it — provenance fiction).
|
|
465
|
-
function parseUnifiedDiff(diffText) {
|
|
466
|
-
var files = [];
|
|
467
|
-
var current = null;
|
|
468
|
-
var lines = (diffText || "").split("\n");
|
|
469
|
-
for (var i = 0; i < lines.length; i++) {
|
|
470
|
-
var line = lines[i];
|
|
471
|
-
var m = /^diff --git a\/(.*) b\/(.*)$/.exec(line);
|
|
472
|
-
if (m) {
|
|
473
|
-
current = { path: m[2], added: [], removed: [] };
|
|
474
|
-
files.push(current);
|
|
475
|
-
continue;
|
|
476
|
-
}
|
|
477
|
-
if (!current) continue;
|
|
478
|
-
if (/^--- /.test(line) || /^\+\+\+ /.test(line)) continue;
|
|
479
|
-
if (/^@@ /.test(line)) continue;
|
|
480
|
-
if (line.charAt(0) === "+") {
|
|
481
|
-
current.added.push(line.slice(1));
|
|
482
|
-
} else if (line.charAt(0) === "-") {
|
|
483
|
-
current.removed.push(line.slice(1));
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
return files;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
|
|
490
465
|
// Publish read-back request (agent path currently unavailable): the
|
|
491
466
|
// verbatim_request the parent protocol (docs/publish-verification.md) would
|
|
492
467
|
// hand to an independent read-back tool after the artifact build lands.
|
|
@@ -1467,59 +1442,77 @@ while (i < STEPS.length) {
|
|
|
1467
1442
|
} else if (!/^[0-9a-f]{40}$/.test(publishBase)) {
|
|
1468
1443
|
return await parkTask("Publish base '" + publishBase + "' is not a valid commit SHA — cannot compute the publish diff. Human attention needed.");
|
|
1469
1444
|
}
|
|
1470
|
-
//
|
|
1471
|
-
//
|
|
1472
|
-
//
|
|
1473
|
-
//
|
|
1474
|
-
//
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1445
|
+
// Publish diff transport (room #14, 2026-09-17): the diff used to be
|
|
1446
|
+
// ferried as a JSON string field in the agent's response — the agent
|
|
1447
|
+
// produced a valid 700-line diff on disk but the JSON ferry dropped
|
|
1448
|
+
// it, and the parse saw zero files ("Publish diff parsed to zero
|
|
1449
|
+
// files"). The diff now travels git -> file -> deterministic script
|
|
1450
|
+
// summary; the LLM never carries diff bytes. The agent is pure hands:
|
|
1451
|
+
// it runs exactly one command (the PINNED compute-publish-diff.js —
|
|
1452
|
+
// a mid-run release swap cannot change it under the workflow) and
|
|
1453
|
+
// returns the small JSON summary verbatim. All fail-closed parks
|
|
1454
|
+
// below are unchanged in meaning.
|
|
1455
|
+
var publishDiffFile = crewHome + "/.publish-diffs/" + taskId + (totalReworkCount > 0 ? "-r" + totalReworkCount : "") + ".diff";
|
|
1478
1456
|
var diffResult = await agent(
|
|
1479
|
-
"Run
|
|
1480
|
-
|
|
1481
|
-
"
|
|
1482
|
-
"if [ \"$ANCESTOR\" = yes ]; then echo '---DIFF---' && git diff \"$BASE\" \"$HEAD\" && echo '---NAMES---' && git diff-tree --no-commit-id --name-only -r \"$BASE\" \"$HEAD\"; fi\n" +
|
|
1483
|
-
"Return JSON { \"commit\": \"<HEAD trimmed>\", \"base\": \"<BASE trimmed>\", \"ancestor\": \"<yes|no>\", \"diff\": \"<raw unified diff, may be multi-line>\", \"files\": \"<newline-separated paths>\" } and nothing else.",
|
|
1457
|
+
"Run exactly one command and nothing else:\n" +
|
|
1458
|
+
"node " + COMPUTE_DIFF + " --repo-path \"" + REPO_PATH + "\" --base " + publishBase + " --out \"" + publishDiffFile + "\"\n" +
|
|
1459
|
+
"The script prints one small JSON object to stdout. Return the stdout verbatim as { \"output\": \"<verbatim stdout>\" } and nothing else. Do not interpret it.",
|
|
1484
1460
|
{ key: attemptKey("publish-artifact-diff-" + taskId, totalReworkCount), label: "Computing publish diff from stamped base",
|
|
1485
|
-
schema: { type: "object", properties: {
|
|
1461
|
+
schema: { type: "object", properties: { output: { type: "string" } }, required: ["output"] } }
|
|
1486
1462
|
);
|
|
1487
|
-
|
|
1488
|
-
|
|
1463
|
+
var diffSummary = null;
|
|
1464
|
+
try {
|
|
1465
|
+
diffSummary = JSON.parse((diffResult.output || "").trim());
|
|
1466
|
+
} catch (e) {
|
|
1467
|
+
return await parkTask("Publish diff computation returned unparseable output — cannot verify application. Human attention needed.");
|
|
1468
|
+
}
|
|
1469
|
+
if (!diffSummary || diffSummary.ok !== true) {
|
|
1470
|
+
if (diffSummary && diffSummary.error === "not-ancestor") {
|
|
1471
|
+
return await parkTask("Publish base " + publishBase.slice(0, 12) + " is not an ancestor of HEAD " + String(diffSummary.commit || "").slice(0, 12) + " — the stamped provenance does not lead to the integrated commit. Human attention needed.");
|
|
1472
|
+
}
|
|
1473
|
+
return await parkTask("Publish diff computation failed (" + ((diffSummary && diffSummary.error) || "unknown error") + ") — cannot verify application. Human attention needed.");
|
|
1489
1474
|
}
|
|
1490
|
-
if (
|
|
1491
|
-
return await parkTask("Publish diff base mismatch:
|
|
1475
|
+
if (diffSummary.base !== publishBase) {
|
|
1476
|
+
return await parkTask("Publish diff base mismatch: script reported '" + String(diffSummary.base || "").slice(0, 12) + "' but the stamped base is '" + publishBase.slice(0, 12) + "'. Human attention needed.");
|
|
1492
1477
|
}
|
|
1493
|
-
var mergeCommitForPublish = (
|
|
1494
|
-
var
|
|
1495
|
-
if (!
|
|
1478
|
+
var mergeCommitForPublish = String(diffSummary.commit || "").trim();
|
|
1479
|
+
var publishDiffSha256 = String(diffSummary.sha256 || "");
|
|
1480
|
+
if (!diffSummary.bytes) {
|
|
1496
1481
|
return await parkTask("Publish diff is empty for commit " + (mergeCommitForPublish || "unknown") + " — a merge lock was held but there is no change to carry. Human attention needed.");
|
|
1497
1482
|
}
|
|
1498
|
-
if (
|
|
1499
|
-
return await parkTask("Publish diff contains binary files — the
|
|
1483
|
+
if (diffSummary.has_binary) {
|
|
1484
|
+
return await parkTask("Publish diff contains binary files — the diff transport cannot carry them. Human attention needed.");
|
|
1500
1485
|
}
|
|
1501
|
-
if (
|
|
1486
|
+
if (diffSummary.has_rename) {
|
|
1502
1487
|
return await parkTask("Publish diff contains a rename — the diff transport cannot carry renames. Human attention needed.");
|
|
1503
1488
|
}
|
|
1504
|
-
var expectedChanges = parseUnifiedDiff(mergeDiff);
|
|
1505
1489
|
// Budget counts CHANGED lines (added + removed), not raw unified-diff
|
|
1506
1490
|
// output lines: context lines and file headers inflated the old
|
|
1507
1491
|
// split("\n").length count ~2x, parking a 95-line change against a
|
|
1508
|
-
// 200-line budget (Gate 1 Journey 3 attempt 3, 2026-09-13).
|
|
1509
|
-
|
|
1492
|
+
// 200-line budget (Gate 1 Journey 3 attempt 3, 2026-09-13). The count
|
|
1493
|
+
// now comes from the deterministic script summary, never from the LLM.
|
|
1494
|
+
var mergeDiffChangedLines = diffSummary.changed_lines || 0;
|
|
1510
1495
|
if (mergeDiffChangedLines > 200) {
|
|
1511
1496
|
return await parkTask("Publish diff changes " + mergeDiffChangedLines + " lines (budget 200) — too large for the diff transport. Human attention needed.");
|
|
1512
1497
|
}
|
|
1513
|
-
if (
|
|
1498
|
+
if (!diffSummary.file_count) {
|
|
1514
1499
|
return await parkTask("Publish diff parsed to zero files for commit " + (mergeCommitForPublish || "unknown") + " — cannot verify application. Human attention needed.");
|
|
1515
1500
|
}
|
|
1501
|
+
// The trigger agent reads the diff from the checksummed file — the
|
|
1502
|
+
// workflow never holds diff bytes (room #14, 2026-09-17). The file
|
|
1503
|
+
// is small by construction: the 200-line budget above gates the
|
|
1504
|
+
// trigger. The sha256 check is the agent's only verification step;
|
|
1505
|
+
// a mismatch stops the trigger before any artifact_edit call.
|
|
1516
1506
|
var rebuildPrompt =
|
|
1517
1507
|
ARTIFACT_LOAD_PREAMBLE +
|
|
1518
|
-
"
|
|
1508
|
+
"The change to apply is the unified diff in the file \"" + publishDiffFile + "\" (sha256 " + publishDiffSha256 + ").\n" +
|
|
1509
|
+
"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" +
|
|
1510
|
+
"2. Read the file's full content.\n" +
|
|
1511
|
+
"3. Call artifact_edit with slug \"" + PUBLISH_SLUG + "\" and verbatim_request:\n" +
|
|
1519
1512
|
"'Apply the following change to your source tree, then rebuild and deploy.\n" +
|
|
1520
1513
|
"\n" +
|
|
1521
1514
|
"UNIFIED DIFF (relative to your source tree):\n" +
|
|
1522
|
-
"```diff\n
|
|
1515
|
+
"```diff\n<the full content of the verified file, pasted verbatim>\n```\n" +
|
|
1523
1516
|
"\n" +
|
|
1524
1517
|
"Rules:\n" +
|
|
1525
1518
|
"- For each file in the diff, apply its hunks to the same path in your source tree (use git apply or equivalent).\n" +
|