muse-crew 0.13.3 → 0.14.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.
@@ -440,6 +440,7 @@ async function recordPublishLedger(entry, rework) {
440
440
  attempt: entry.attempt || null,
441
441
  agent_id: entry.agent_id || null,
442
442
  applied_report: entry.applied_report || null,
443
+ manifest_before: entry.manifest_before || null,
443
444
  outcome: entry.outcome,
444
445
  detail: entry.detail || ""
445
446
  });
@@ -1442,20 +1443,36 @@ while (i < STEPS.length) {
1442
1443
  // See docs/decisions/publish-path.md#durable-evidence-snapshot: snapshot the audit-dir listing BEFORE the trigger; fallback diffs before/after.
1443
1444
  var auditDirsBeforeTrigger = [];
1444
1445
  var auditBeforeOk = false;
1446
+ // Pre-trigger baselines (design §1.9): the audit-dir listing and the
1447
+ // manifest snapshot. The verified-path freshness check compares the
1448
+ // post-trigger manifest against the baseline (built_at advance +
1449
+ // content_sha256 change). Best-effort, never gates — a missing
1450
+ // manifest baseline fails the verified path closed.
1451
+ var preTriggerManifest = null;
1445
1452
  try {
1446
1453
  var auditBefore = await agent(
1447
- "List the artifact audit directories for slug \"" + PUBLISH_SLUG + "\" (best-effort snapshot, never a gate).\n" +
1448
- "Run: ls -1 ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/ 2>/dev/null\n" +
1449
- "Return JSON { \"dirs\": \"<newline-separated names, empty string when the audits directory does not exist or is empty>\" } and nothing else.",
1450
- { key: attemptKey("publish-audit-before-" + taskId, totalReworkCount), label: "Snapshotting audit dirs before rebuild trigger",
1451
- schema: { type: "object", properties: { dirs: { type: "string" } }, required: ["dirs"] } }
1454
+ "Capture pre-trigger baselines for slug \"" + PUBLISH_SLUG + "\" (best-effort snapshots, never gates).\n" +
1455
+ "Run: ls -1 ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/audits/ 2>/dev/null; echo ---MANIFEST---; cat ~/workspace/ts-spaces/" + PUBLISH_SLUG + "/.space-build/manifest.json 2>/dev/null\n" +
1456
+ "Return JSON { \"dirs\": \"<newline-separated names, empty string when missing>\", \"manifest\": \"<the manifest's full text, or empty string when missing/unreadable>\" } and nothing else.",
1457
+ { key: attemptKey("publish-baseline-before-" + taskId, totalReworkCount), label: "Snapshotting baselines before rebuild trigger",
1458
+ schema: { type: "object", properties: { dirs: { type: "string" }, manifest: { type: "string" } }, required: ["dirs", "manifest"] } }
1452
1459
  );
1453
1460
  auditDirsBeforeTrigger = String((auditBefore && auditBefore.dirs) || "").split("\n").map(function (s) { return s.trim(); }).filter(function (s) { return s.length > 0; });
1461
+ var manifestText = String((auditBefore && auditBefore.manifest) || "").trim();
1462
+ if (manifestText) {
1463
+ var manifestJson = JSON.parse(manifestText);
1464
+ preTriggerManifest = {
1465
+ built_at: typeof manifestJson.built_at === "string" ? manifestJson.built_at : null,
1466
+ content_sha256: typeof manifestJson.content_sha256 === "string" ? manifestJson.content_sha256 : null,
1467
+ };
1468
+ }
1469
+ // Arm only after both baselines parse.
1454
1470
  auditBeforeOk = true;
1455
- log("Publish audit-dir snapshot before trigger for task " + taskId + ": " + auditDirsBeforeTrigger.length + " entries");
1471
+ log("Publish pre-trigger baselines for task " + taskId + ": " + auditDirsBeforeTrigger.length + " audit dirs, manifest " + (preTriggerManifest ? "built_at=" + preTriggerManifest.built_at : "none"));
1456
1472
  } catch (auditBeforeErr) {
1457
- log("Publish audit-dir snapshot before trigger failed for task " + taskId + " (non-fatal): audit fallback DISABLED for this attempt — without a baseline, historical dirs would look new: " + (auditBeforeErr && auditBeforeErr.message ? auditBeforeErr.message : auditBeforeErr));
1473
+ log("Publish pre-trigger baselines failed for task " + taskId + " (non-fatal): audit fallback DISABLED for this attempt — without a baseline, historical dirs would look new: " + (auditBeforeErr && auditBeforeErr.message ? auditBeforeErr.message : auditBeforeErr));
1458
1474
  }
1475
+
1459
1476
  // See docs/decisions/publish-path.md#fire-and-forget-trigger: the trigger child returns immediately; the workflow owns observation and verdict.
1460
1477
  var publishToolsOk = false;
1461
1478
  var publishToolsMissing = false;
@@ -1660,6 +1677,7 @@ while (i < STEPS.length) {
1660
1677
  attempt: rebuildAttemptKey,
1661
1678
  agent_id: rebuildAgentId,
1662
1679
  applied_report: publishAppliedObservation,
1680
+ manifest_before: preTriggerManifest,
1663
1681
  outcome: "submitted",
1664
1682
  detail: "fire-and-forget trigger; build receipt captured by workflow-owned build-state observation (pre/post-trigger diff)"
1665
1683
  }, totalReworkCount);
@@ -1730,7 +1748,8 @@ while (i < STEPS.length) {
1730
1748
  attempt: rebuildAttemptKey,
1731
1749
  agent_id: null,
1732
1750
  applied_report: publishAppliedObservation,
1733
- outcome: "submitted",
1751
+ manifest_before: preTriggerManifest,
1752
+ outcome: "build-observed",
1734
1753
  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)"
1735
1754
  }, totalReworkCount);
1736
1755
  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.");
@@ -2002,7 +2021,8 @@ while (i < STEPS.length) {
2002
2021
  attempt: rebuildAttemptKey,
2003
2022
  agent_id: rebuildAgentId,
2004
2023
  applied_report: publishAppliedObservation,
2005
- outcome: "submitted",
2024
+ manifest_before: preTriggerManifest,
2025
+ outcome: "build-observed",
2006
2026
  detail: "durable audit evidence shows a build completed during the attempt window (audit dir " + newestAuditDirAfterPoll + ", report ok=true); routed to parent verification"
2007
2027
  }, totalReworkCount);
2008
2028
  } else if (auditOkAfterPoll === false) {
@@ -2740,6 +2760,7 @@ while (i < STEPS.length) {
2740
2760
  // means the parent's independent read-back has not happened yet; this
2741
2761
  // park is NOT proof the content is correct.
2742
2762
  return await parkTask("publish: verification-requested " + mergeCommitForPublish +
2763
+ " attempt=" + rebuildAttemptKey +
2743
2764
  " Do NOT republish: a duplicate build would re-publish the same change. " +
2744
2765
  "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. " +
2745
2766
  "Appendix: build=" + (rebuildAgentId || "agent_id unobserved") + "; provenance=unstamped; content_check=pending.");
@@ -104,7 +104,7 @@ let telemetryBuffer = [];
104
104
  async function telemetryStart(workflowName) {
105
105
  try {
106
106
  const out = await agent(crewCmd("record-run-start", {
107
- task_id: taskId, workflow: workflowName, launched_by: "cron"
107
+ task_id: taskId, workflow: workflowName, launched_by: inputs.launched_by
108
108
  }), { key: "telemetry-start", label: "Recording run start" });
109
109
  const parsed = typeof out === "string" ? JSON.parse(out) : out;
110
110
  if (parsed && parsed.run_id) telemetryRunId = parsed.run_id;