@dadado/agent-kit-cli 6.8.0 → 6.10.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.
Files changed (29) hide show
  1. package/dashboard/README.md +31 -5
  2. package/dashboard/art/atmospheric-purifier.webp +0 -0
  3. package/dashboard/art/rover-frozen-flats.webp +0 -0
  4. package/dashboard/art/seed-tree-crane.webp +0 -0
  5. package/dashboard/art/uplink-tower-road.webp +0 -0
  6. package/dashboard/dashboard-data.mjs +385 -9
  7. package/dashboard/dashboard.html +794 -75
  8. package/dashboard/lib/live-refresh.mjs +1 -0
  9. package/dashboard/lib/outcome-ledger.d.mts +115 -0
  10. package/dashboard/lib/outcome-ledger.mjs +595 -0
  11. package/dashboard/lib/ship-lane.mjs +690 -0
  12. package/dashboard/serve.mjs +20 -0
  13. package/dist/{chunk-BCX5NDQC.js → chunk-GQ6Q3P7C.js} +1 -1
  14. package/dist/{chunk-67G3236R.js → chunk-K5OCGZWA.js} +2 -2
  15. package/dist/{chunk-3LLXDHIU.js → chunk-LFWPB2JR.js} +1 -0
  16. package/dist/{chunk-GO3K752H.js → chunk-SC2DBY2R.js} +2 -0
  17. package/dist/{chunk-3Z4PGEEJ.js → chunk-TUZVOPKY.js} +1 -1
  18. package/dist/{doctor-PZT7EGLQ.js → doctor-E6LOBJYK.js} +2 -2
  19. package/dist/{guard-ZZRQW3DJ.js → guard-M3W3QE62.js} +14 -2
  20. package/dist/index.js +19 -11
  21. package/dist/{init-MGRZ7U7A.js → init-KKVT2RW4.js} +3 -3
  22. package/dist/{install-432KJISB.js → install-BPZTP5KT.js} +3 -3
  23. package/dist/{mission-control-MHQU73XC.js → mission-control-C2QV5D25.js} +1 -1
  24. package/dist/outcome-ledger-XLWHWPVQ.js +297 -0
  25. package/dist/{run-DXGTFYJK.js → run-326EEQYY.js} +34 -11
  26. package/dist/{run-plan-KWGS2SOZ.js → run-plan-2IFO4G4Y.js} +2 -2
  27. package/dist/{scan-UX4HARMJ.js → scan-BWA64R7I.js} +1 -1
  28. package/dist/{status-UDM55MHU.js → status-LNXVLDMP.js} +1 -1
  29. package/package.json +1 -1
@@ -35,19 +35,45 @@ and published as `docs/contracts/mission-control-snapshot.schema.json`. The Flig
35
35
  operator tickets (gate exits awaiting triage) read-only from `gateExit`
36
36
  (`lib/gate-exit-tickets.mjs`, the no-fetch mirror of `agent-kit ground-control status`).
37
37
 
38
- ## Git tab and DevOps tab
38
+ ## Colony section
39
39
 
40
- The Git tab (`#git`) keeps the pre-rendered `git log --graph` markdown block and adds a
40
+ **Colony** (`#colony`, in the More menu) is a single-player game panel over the snapshot's
41
+ `outcomeLedger` field (1.9.0, `lib/outcome-ledger.mjs`; ADR
42
+ `2026-10-23_colony-game-canon-outcome-ledger-art-policy.md`). A 61-tile hex map (SVG, no image
43
+ needed) turns from fog and grey ground to green as verified outcomes accrue: the ledger alone
44
+ greens up to 60% of it, finished buildings green the rest. Logic, Compute and Rare are the
45
+ ledger totals minus what the player spent. Building queues a structure for a real-time
46
+ duration; the player's state (spent resources, queue, buildings) lives only in this browser's
47
+ `localStorage` (`agent-kit-colony-state-v1`), and timers are `startedAt` + duration evaluated
48
+ when the panel renders: no timer, no extra polling, no server write. A streak of at least 3
49
+ to-dos closed in a row, the last within 2 hours (`outcomeLedger.flow`), runs builds 25% faster.
50
+ Art: at most 4 images, 400 KB together, in `art/` (re-encoded from the Colony app's curated
51
+ set); a host that cannot serve them gets the panel without images. An older engine without
52
+ `outcomeLedger` shows an update hint.
53
+
54
+ ## Git e CI/CD section
55
+
56
+ The former Git and DevOps tabs are one section, **Git e CI/CD** (`#git`; `#devops` and
57
+ `#git-cicd` still deep-link there through `SECTION_ALIASES`), laid out as a bento grid
58
+ (`.bento`, 6 columns on the skin tokens; one column below 900px). Tiles: Ship lane, Promotion
59
+ flow, Open pull requests, CI/CD pipeline, Deploy activity, Branch graph, and Changed files when
60
+ the tree is dirty. The Ship lane and Open pull requests tiles read the snapshot's `shipLane`
61
+ field (1.8.0, `lib/ship-lane.mjs`) and show an empty state on an older engine. Every action is
62
+ copy-only: the ship lane copy buttons carry their command in `data-ship-copy` and go through one
63
+ delegated listener into `copyForPaste`, with no inline handler. ADR
64
+ `2026-10-23_git-cicd-tab-read-in-mc-act-in-colony.md`.
65
+
66
+ The branch graph tile keeps the pre-rendered `git log --graph` markdown block and adds a
41
67
  second, state-colored visual tree next to it, reusing the `.now-stepper`/`.now-step-marker`
42
68
  timeline component built for the Current Mission panel (`renderGitVisualTree` in
43
69
  `dashboard.html`, parsing `SNAPSHOT.git.graph`). It is single-lane by design — the markdown
44
70
  block keeps the true branch-lane geometry; the stepper trades that for an at-a-glance
45
71
  promotion read (HEAD, promoted to `origin/main`/`origin/staging`, or neither).
46
72
 
47
- The DevOps tab (`#devops`) is scoped to CI/CD + deploy signal, separate from the
48
- local-process-only Processes tab. `dashboard-data.mjs`'s `collectPipelineRuns()` shells to
73
+ The CI/CD pipeline and Deploy activity tiles are scoped to CI/CD + deploy signal, separate
74
+ from the local-process-only Processes tab. `dashboard-data.mjs`'s `collectPipelineRuns()` shells to
49
75
  `gh run list` (budget-guarded via `withinSnapshotBudget()`, fails soft to an honest
50
76
  empty-state when `gh` is unavailable/unauthenticated); `collectDeploySignal()` reads `v*`
51
77
  git tags plus the latest non-`Unreleased` `CHANGELOG.md` entry as a best-effort "what
52
- shipped recently" proxy. Neither collector polls live infra/hosting — the DevOps tab never
78
+ shipped recently" proxy. Neither collector polls live infra/hosting — the section never
53
79
  implies monitoring it does not perform.
@@ -4,7 +4,7 @@
4
4
  // Scans .cursor/plans, HANDOFF, memory, config, git status, terminals, processes
5
5
  // Outputs JSON to stdout (consumed by dashboard.html)
6
6
 
7
- import { execFileSync } from "node:child_process";
7
+ import { execFile, execFileSync } from "node:child_process";
8
8
  import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
9
9
  import { dirname, join, resolve } from "node:path";
10
10
  import { collectChats } from "./lib/chat-sessions.mjs";
@@ -18,6 +18,19 @@ import {
18
18
  truncateStr,
19
19
  } from "./lib/guards.mjs";
20
20
  import { projectSlugFromRoot } from "./lib/live-refresh.mjs";
21
+ import {
22
+ deriveFlowSignal,
23
+ emptyOutcomeLedgerSummary,
24
+ extractOutcomeEvents,
25
+ foldOutcomeLedger,
26
+ fullReviewHeadSha,
27
+ parsePlanTodos,
28
+ persistOutcomeLedger,
29
+ readOutcomeLedgerFile,
30
+ readTestResults,
31
+ summarizeOutcomeLedger,
32
+ testCollectorStatus,
33
+ } from "./lib/outcome-ledger.mjs";
21
34
  import { PIPELINE_CACHE_ENV, readCachedPipeline } from "./lib/pipeline-cache.mjs";
22
35
  import { selectWorkspaceProcesses } from "./lib/processes.mjs";
23
36
  import { collectRunLogs } from "./lib/run-logs.mjs";
@@ -48,6 +61,22 @@ import {
48
61
  serializeFlightLogLedger,
49
62
  serializeMissionTimingLedger,
50
63
  } from "./lib/semantic-model.mjs";
64
+ import {
65
+ buildShipLaneRows,
66
+ classifyGhFailure,
67
+ FACTORY_PUBLIC_REPO,
68
+ isFactorySlug,
69
+ parseForgeRemote,
70
+ readCachedShipLaneRemote,
71
+ SHIP_LANE_CACHE_ENV,
72
+ SHIP_LANE_GH_TIMEOUT_MS,
73
+ SHIP_LANE_NPM_TIMEOUT_MS,
74
+ safeNpmName,
75
+ safeTagName,
76
+ shipLaneGhArgs,
77
+ shipLaneReasonNote,
78
+ trimShipLaneGraphql,
79
+ } from "./lib/ship-lane.mjs";
51
80
  import { buildTerminalSnapshotFields, MAX_TERMINAL_BYTES } from "./lib/terminal-snapshot.mjs";
52
81
 
53
82
  const KIT_ROOT = resolve(import.meta.dirname, "..");
@@ -135,7 +164,7 @@ function redactTerminalOutput(text) {
135
164
 
136
165
  const SNAPSHOT = {
137
166
  _schema: {
138
- version: "1.7.0",
167
+ version: "1.9.0",
139
168
  description: "Mission Control dashboard data model",
140
169
  fields: {
141
170
  generatedAt: "ISO-8601 timestamp of snapshot generation",
@@ -158,6 +187,10 @@ const SNAPSHOT = {
158
187
  "Pending operator tickets (read-only, never fetches): {marker: absent|ok|invalid, base, tickets[] (stamp, headline, askId, labels, trigger, openedAt, url, branch, branchState unmerged|merged|none, inMarker), skipped[] (latest launcher skip records), truncated} from .cursor/context/gate-exit.json and gate-exit/<stamp> branches; same contract as agent-kit ground-control status (1.6.0)",
159
188
  chats:
160
189
  "Saved agent chats of this workspace: {withheld, vendors[]} with one envelope per vendor {vendor: claude|codex|cursor, status: ok|unsupported|none, projectDir, sessions[] ({id, title, titleSource: custom|ai|first-prompt|none, modified unix ms, sizeBytes}, newest first, capped at 200), total}; same contract as agent-kit sessions --json. withheld is true (vendors empty) in broadcast mode: chat titles never leave the machine (1.7.0)",
190
+ shipLane:
191
+ "Release ship lane for the Git e CI/CD section (read-only, copy-only next commands): {lane: factory|consumer|null, repo, publicRepo, local {latestTag, version, mainRef, stagingAheadOfMain, mainInStaging, tagOnMain}, remote ({available, reason?, fetchedAt?, repo, tag, prs[] (number, capped title, base, head, draft, mergeable, mergeState, stackedOn, checks {state, total, failing[], pending, signatureScan}), prsTotal, originRelease, tagCi {workflow, runId, jobs[]}, public {release, syncPrs[]}, npm {name, version}}; one gh api graphql call + one npm registry read, run alongside gh run list and reused from serve.mjs for up to 120s; reason budget|gh-missing|gh-auth|timeout|call-failed|no-remote|provider-unsupported), rows[] ({id, label, state: green|red|pending|unknown, detail, next {text, destination}|null}) mirroring the /kit-prod Done rows} (1.8.0)",
192
+ outcomeLedger:
193
+ "Verified-outcome ledger (read-only, product-neutral; ADR 2026-10-23 colony-game-canon-outcome-ledger-art-policy): {available, reason (budget|unreadable)|null, version, path (.cursor/context/outcome-ledger.json), entries, totals {logic, compute, rare}, byKind {todo, test, ci, releaseCut, plan, review, releasePublished}, recent[] ({key, kind, resource, at, label}, newest 20), flow {plan, streak, lastClosedAt, brokenAt}|null (from mission-timing.json; a failed, gated or stopped tick breaks it), tests {configured, lastRun {at, ok, head}|null}}. Folded on every snapshot, idempotent by event key, entries never removed; never rewards lines of code, commits, diff size, tokens or time (1.9.0)",
161
194
  processes:
162
195
  "Running process snapshots (node, serve.mjs, git operations) with elapsed time and a generated narration per process",
163
196
  skills: "Available skills discovered in .cursor/skills/",
@@ -166,7 +199,7 @@ const SNAPSHOT = {
166
199
  },
167
200
  },
168
201
  generatedAt: new Date().toISOString(),
169
- dashboardDataVersion: "1.7.0",
202
+ dashboardDataVersion: "1.9.0",
170
203
  plans: [],
171
204
  system: {
172
205
  repoRoot: ROOT,
@@ -180,6 +213,7 @@ const SNAPSHOT = {
180
213
  runLogs: [],
181
214
  gateExit: { marker: "absent", base: "staging", tickets: [], skipped: [], truncated: false },
182
215
  chats: { withheld: false, vendors: [] },
216
+ outcomeLedger: emptyOutcomeLedgerSummary(),
183
217
  processes: [],
184
218
  skills: [],
185
219
  health: { status: "ok", checks: [] },
@@ -618,10 +652,10 @@ function collectPipelineRuns() {
618
652
  const fetchedAt = new Date().toISOString();
619
653
  try {
620
654
  // Trimmed to the fields renderDevopsPipelineCard() / navDevopsDot actually
621
- // read (workflow, status, conclusion, branch, event, createdAt). databaseId
622
- // and url are dropped: the pipeline card is display-only with no
623
- // paste-destination for a run URL (ADR 2026-07-25 copy-only convention),
624
- // so requesting them only adds payload cost without a consumer.
655
+ // read (workflow, status, conclusion, branch, event, createdAt) plus
656
+ // databaseId, the outcome ledger's identity for a passing run (1.9.0). url
657
+ // stays dropped: the pipeline card is display-only with no
658
+ // paste-destination for a run URL (ADR 2026-07-25 copy-only convention).
625
659
  const out = execFileSync(
626
660
  "gh",
627
661
  [
@@ -630,7 +664,7 @@ function collectPipelineRuns() {
630
664
  "--limit",
631
665
  String(MAX_PIPELINE_RUNS),
632
666
  "--json",
633
- "workflowName,status,conclusion,headBranch,event,createdAt",
667
+ "databaseId,workflowName,status,conclusion,headBranch,event,createdAt",
634
668
  ],
635
669
  { cwd: ROOT, encoding: "utf-8", timeout: GH_RUN_LIST_TIMEOUT_MS },
636
670
  );
@@ -639,6 +673,8 @@ function collectPipelineRuns() {
639
673
  return { available: false, runs: [], reason: "call-failed", fetchedAt };
640
674
  }
641
675
  const runs = rows.slice(0, MAX_PIPELINE_RUNS).map((r) => ({
676
+ // Run id: the outcome ledger's key for a passing CI run (never a link).
677
+ id: Number.isSafeInteger(r.databaseId) ? r.databaseId : null,
642
678
  workflow: truncateStr(String(r.workflowName || ""), MAX_PIPELINE_NAME_CHARS),
643
679
  status: String(r.status || ""),
644
680
  conclusion: r.conclusion ? String(r.conclusion) : null,
@@ -736,6 +772,181 @@ function collectDeploySignal() {
736
772
  return { tags, changelog };
737
773
  }
738
774
 
775
+ // 6c. Ship lane (Git e CI/CD section; ADR 2026-10-23
776
+ // git-cicd-tab-read-in-mc-act-in-colony). Local half: cheap git reads, every
777
+ // snapshot. Forge half: one `gh api graphql` call plus one npm registry read,
778
+ // started asynchronously right before collectPipelineRuns() so the two network
779
+ // waits overlap instead of adding up. That is why SNAPSHOT_BUDGET_MS did not
780
+ // grow with this collector: its reserve is checked against the same budget
781
+ // before gh run list starts, and the await at the end waits at most
782
+ // max(remaining gh graphql time, 0) after gh run list returns.
783
+ function readPackageManifest(rel) {
784
+ try {
785
+ const pkg = JSON.parse(readFileSync(join(ROOT, rel), "utf-8"));
786
+ return pkg && typeof pkg === "object" ? pkg : null;
787
+ } catch {
788
+ return null;
789
+ }
790
+ }
791
+
792
+ function collectShipLaneLocal() {
793
+ const gitOpts = {
794
+ cwd: ROOT,
795
+ encoding: "utf-8",
796
+ timeout: 5000,
797
+ stdio: ["ignore", "pipe", "ignore"],
798
+ };
799
+ const gitText = (args) => {
800
+ try {
801
+ return execFileSync("git", args, gitOpts).trim();
802
+ } catch {
803
+ return null;
804
+ }
805
+ };
806
+ /** true / false from an exit code (0 / 1); null when git itself failed. */
807
+ const isAncestor = (a, b) => {
808
+ try {
809
+ execFileSync("git", ["merge-base", "--is-ancestor", a, b], gitOpts);
810
+ return true;
811
+ } catch (err) {
812
+ return err?.status === 1 ? false : null;
813
+ }
814
+ };
815
+ const refExists = (ref) => gitText(["rev-parse", "--verify", "--quiet", ref]) != null;
816
+ const originUrl = gitText(["remote", "get-url", "origin"]);
817
+ const forge = parseForgeRemote(originUrl);
818
+ const lane = forge ? (isFactorySlug(forge.slug) ? "factory" : "consumer") : null;
819
+ let publicRepo = null;
820
+ if (lane === "factory") {
821
+ publicRepo =
822
+ parseForgeRemote(gitText(["remote", "get-url", "public"]))?.slug ?? FACTORY_PUBLIC_REPO;
823
+ }
824
+ const rawTag =
825
+ gitText([
826
+ "for-each-ref",
827
+ "--sort=-creatordate",
828
+ "--format=%(refname:short)",
829
+ "--count=1",
830
+ "refs/tags/v*",
831
+ ]) || null;
832
+ // Tag names reach copyable shell commands and the gh argv: drop unsafe ones.
833
+ const latestTag = safeTagName(rawTag);
834
+ const mainRef = refExists("origin/main")
835
+ ? "origin/main"
836
+ : refExists("origin/master")
837
+ ? "origin/master"
838
+ : null;
839
+ const hasStaging = refExists("origin/staging");
840
+ let stagingAheadOfMain = null;
841
+ if (mainRef && hasStaging) {
842
+ const n = Number.parseInt(
843
+ gitText(["rev-list", "--count", `${mainRef}..origin/staging`]) ?? "",
844
+ 10,
845
+ );
846
+ stagingAheadOfMain = Number.isFinite(n) ? n : null;
847
+ }
848
+ const manifest = readPackageManifest(
849
+ lane === "factory" ? "packages/cli/package.json" : "package.json",
850
+ );
851
+ const version = typeof manifest?.version === "string" ? manifest.version : null;
852
+ const npmName =
853
+ manifest && manifest.private !== true && !manifest.publishConfig?.registry
854
+ ? safeNpmName(manifest.name)
855
+ : null;
856
+ return {
857
+ forge,
858
+ lane,
859
+ publicRepo,
860
+ npmName,
861
+ local: {
862
+ latestTag,
863
+ unsafeTag: rawTag != null && latestTag == null,
864
+ version,
865
+ mainRef,
866
+ stagingAheadOfMain,
867
+ mainInStaging: mainRef && hasStaging ? isAncestor(mainRef, "origin/staging") : null,
868
+ tagOnMain: latestTag && mainRef ? isAncestor(latestTag, mainRef) : null,
869
+ },
870
+ };
871
+ }
872
+
873
+ /** execFile as a promise that never rejects: { err, stdout, stderr }. */
874
+ function execFileSettled(bin, args, timeout) {
875
+ return new Promise((resolveExec) => {
876
+ execFile(
877
+ bin,
878
+ args,
879
+ { cwd: ROOT, encoding: "utf-8", timeout, maxBuffer: 2 * 1024 * 1024 },
880
+ (err, stdout, stderr) =>
881
+ resolveExec({ err, stdout: String(stdout || ""), stderr: String(stderr || "") }),
882
+ );
883
+ });
884
+ }
885
+
886
+ /** Registry read in a child node (fetch + abort timeout); no npm CLI spawn. */
887
+ const NPM_LATEST_SCRIPT =
888
+ 'const n=process.argv[1];fetch("https://registry.npmjs.org/"+n.replace("/","%2f")+"/latest",{signal:AbortSignal.timeout(Number(process.argv[2]))}).then(r=>r.ok?r.json():Promise.reject(r.status)).then(j=>process.stdout.write(String(j.version||""))).catch(()=>process.exit(1))';
889
+
890
+ /** @returns {Promise<object>} the forge half of SNAPSHOT.shipLane (remote). */
891
+ function startShipLaneRemote(ship) {
892
+ const { forge, local, publicRepo, npmName } = ship;
893
+ if (!forge) return Promise.resolve({ available: false, reason: "no-remote", repo: null });
894
+ if (forge.provider !== "github") {
895
+ return Promise.resolve({ available: false, reason: "provider-unsupported", repo: forge.slug });
896
+ }
897
+ const cached = readCachedShipLaneRemote(process.env[SHIP_LANE_CACHE_ENV], Date.now(), {
898
+ repo: forge.slug,
899
+ tag: local.latestTag,
900
+ });
901
+ if (cached) return Promise.resolve(cached);
902
+ if (!withinSnapshotBudget(SHIP_LANE_GH_TIMEOUT_MS + 400)) {
903
+ return Promise.resolve({ available: false, reason: "budget", repo: forge.slug });
904
+ }
905
+ const fetchedAt = new Date().toISOString();
906
+ const gh = execFileSettled(
907
+ "gh",
908
+ shipLaneGhArgs({ owner: forge.owner, name: forge.name, tag: local.latestTag, publicRepo }),
909
+ SHIP_LANE_GH_TIMEOUT_MS,
910
+ );
911
+ const npm = npmName
912
+ ? execFileSettled(
913
+ process.execPath,
914
+ ["-e", NPM_LATEST_SCRIPT, npmName, String(SHIP_LANE_NPM_TIMEOUT_MS)],
915
+ SHIP_LANE_NPM_TIMEOUT_MS + 1000,
916
+ )
917
+ : Promise.resolve(null);
918
+ return Promise.all([gh, npm]).then(([ghRes, npmRes]) => {
919
+ let parsed = null;
920
+ try {
921
+ parsed = JSON.parse(ghRes.stdout);
922
+ } catch {
923
+ parsed = null;
924
+ }
925
+ // gh exits non-zero when GraphQL returns errors next to partial data (an
926
+ // unreadable public repo): keep the data when the origin half is there.
927
+ const remote = trimShipLaneGraphql(parsed, {
928
+ repo: forge.slug,
929
+ tag: local.latestTag,
930
+ publicRepo,
931
+ fetchedAt,
932
+ });
933
+ if (!remote) {
934
+ return {
935
+ available: false,
936
+ reason: classifyGhFailure(ghRes.err, ghRes.stderr),
937
+ fetchedAt,
938
+ repo: forge.slug,
939
+ tag: local.latestTag,
940
+ };
941
+ }
942
+ if (npmName) {
943
+ const v = npmRes && !npmRes.err ? npmRes.stdout.trim() : "";
944
+ remote.npm = { name: npmName, version: /^\d+\.\d+\.\d+[\w.+-]*$/.test(v) ? v : null };
945
+ }
946
+ return remote;
947
+ });
948
+ }
949
+
739
950
  // SNAPSHOT.devops is assigned near the end of the snapshot build (after the
740
951
  // transcripts/reports/ps collectors below), not here — gh run list is a
741
952
  // network call that must not run ahead of and starve the local-only
@@ -1092,10 +1303,17 @@ function collectAgentPrompts() {
1092
1303
  * lives in `isReportTriaged`. A missing or unreadable `.cursor/memory/`
1093
1304
  * directory yields an empty list, never an error state.
1094
1305
  */
1306
+ /** Review outcomes for the outcome ledger (filled by collectExternalReports). */
1307
+ const reviewOutcomes = [];
1308
+ /** False when the report scan was skipped or failed (no plan rewards then). */
1309
+ let reviewOutcomesCollected = false;
1095
1310
  function collectExternalReports() {
1096
1311
  if (!withinSnapshotBudget(600)) return [];
1097
1312
  const memoryDir = join(ROOT, ".cursor", "memory");
1098
- if (!existsSync(memoryDir)) return [];
1313
+ if (!existsSync(memoryDir)) {
1314
+ reviewOutcomesCollected = true; // no reports at all: nothing open
1315
+ return [];
1316
+ }
1099
1317
 
1100
1318
  const reports = [];
1101
1319
  try {
@@ -1131,10 +1349,18 @@ function collectExternalReports() {
1131
1349
  });
1132
1350
  if (!report) continue;
1133
1351
  reports.push(report);
1352
+ reviewOutcomes.push({
1353
+ file: report.file,
1354
+ reviewedPlanFile: report.reviewedPlanFile,
1355
+ hasOpenReviewGaps: report.hasOpenReviewGaps,
1356
+ fullReviewHead: fullReviewHeadSha(content),
1357
+ modifiedAt: report.modifiedAt,
1358
+ });
1134
1359
  }
1135
1360
  } catch {
1136
1361
  return [];
1137
1362
  }
1363
+ reviewOutcomesCollected = true;
1138
1364
  return reports;
1139
1365
  }
1140
1366
 
@@ -1372,6 +1598,7 @@ function readPreviousInventory() {
1372
1598
  }
1373
1599
  }
1374
1600
 
1601
+ let finalTimingLedger = null;
1375
1602
  {
1376
1603
  const missionControl = buildMissionControlView({
1377
1604
  plans: SNAPSHOT.plans,
@@ -1397,6 +1624,7 @@ function readPreviousInventory() {
1397
1624
  gateExitTickets: SNAPSHOT.gateExit?.tickets || [],
1398
1625
  });
1399
1626
  persistMissionTimingLedger(missionControl.timingLedger);
1627
+ finalTimingLedger = missionControl.timingLedger;
1400
1628
  persistFlightLogLedger(missionControl.flightLogLedger);
1401
1629
  // Do not expose the writable ledger blobs on the public snapshot wire.
1402
1630
  const {
@@ -1415,9 +1643,157 @@ SNAPSHOT._gitRecentLog = undefined;
1415
1643
  // a network call (gh run list) unlike every other collector in this file, so
1416
1644
  // it must not run ahead of and eat into the shared SNAPSHOT_BUDGET_MS budget
1417
1645
  // that the local-only collectors also need.
1646
+ // The ship lane's forge half starts first and runs while gh run list blocks.
1647
+ let shipLaneLocal = null;
1648
+ let shipLaneRemote;
1649
+ try {
1650
+ shipLaneLocal = collectShipLaneLocal();
1651
+ shipLaneRemote = startShipLaneRemote(shipLaneLocal);
1652
+ } catch {
1653
+ shipLaneRemote = Promise.resolve({ available: false, reason: "call-failed", repo: null });
1654
+ }
1418
1655
  SNAPSHOT.devops = {
1419
1656
  pipeline: collectPipelineRuns(),
1420
1657
  deploy: collectDeploySignal(),
1421
1658
  };
1659
+ {
1660
+ const remote = await shipLaneRemote;
1661
+ const local = shipLaneLocal?.local ?? {
1662
+ latestTag: null,
1663
+ version: null,
1664
+ mainRef: null,
1665
+ stagingAheadOfMain: null,
1666
+ mainInStaging: null,
1667
+ tagOnMain: null,
1668
+ };
1669
+ let rows = [];
1670
+ try {
1671
+ rows = buildShipLaneRows({
1672
+ lane: shipLaneLocal?.lane ?? "consumer",
1673
+ repo: shipLaneLocal?.forge?.slug ?? null,
1674
+ publicRepo: shipLaneLocal?.publicRepo ?? null,
1675
+ local,
1676
+ remote,
1677
+ });
1678
+ } catch {
1679
+ rows = [];
1680
+ }
1681
+ SNAPSHOT.shipLane = {
1682
+ lane: shipLaneLocal?.lane ?? null,
1683
+ repo: shipLaneLocal?.forge?.slug ?? null,
1684
+ publicRepo: shipLaneLocal?.publicRepo ?? null,
1685
+ local,
1686
+ remote,
1687
+ note: remote.available ? null : shipLaneReasonNote(remote.reason),
1688
+ rows,
1689
+ };
1690
+ }
1691
+
1692
+ // 7. Outcome ledger (ADR 2026-10-23 colony-game-canon-outcome-ledger-art-policy).
1693
+ // Last, after shipLane: it folds what the collectors above already read (plans,
1694
+ // mission timing, run logs, review reports, CI rows, the Release Latest) plus
1695
+ // local v* tags, archived plans, test-results.json and the optional factory
1696
+ // history ledger. No network call of its own; write-on-change only.
1697
+ const MAX_ARCHIVED_PLAN_READS = 200;
1698
+ const MAX_LEDGER_TAGS = 500;
1699
+ function collectLedgerTags() {
1700
+ try {
1701
+ // Newest first, so the cap drops the oldest tags, never a new release.
1702
+ const out = execFileSync(
1703
+ "git",
1704
+ [
1705
+ "for-each-ref",
1706
+ "--sort=-creatordate",
1707
+ "--format=%(refname:short)|%(creatordate:iso-strict)",
1708
+ `--count=${MAX_LEDGER_TAGS}`,
1709
+ "refs/tags/v*",
1710
+ ],
1711
+ { cwd: ROOT, encoding: "utf-8", timeout: 5000, stdio: ["ignore", "pipe", "ignore"] },
1712
+ );
1713
+ return out
1714
+ .split("\n")
1715
+ .filter(Boolean)
1716
+ .map((line) => {
1717
+ const [name, date] = line.split("|");
1718
+ return { name: (name || "").trim(), date: (date || "").trim() || null };
1719
+ });
1720
+ } catch {
1721
+ return [];
1722
+ }
1723
+ }
1724
+ function collectArchivedPlanTodos() {
1725
+ const rows = [];
1726
+ for (const file of archivedPlanFiles.slice(0, MAX_ARCHIVED_PLAN_READS)) {
1727
+ try {
1728
+ const path = join(plansArchiveDir, file);
1729
+ if (statSync(path).size > 512 * 1024) continue;
1730
+ rows.push({ file, todos: parsePlanTodos(readFileSync(path, "utf-8")) });
1731
+ } catch {
1732
+ // unreadable archived plan: skipped
1733
+ }
1734
+ }
1735
+ return rows;
1736
+ }
1737
+ /** Factory-only evidence (optional): parsed only when its size+mtime changed. */
1738
+ function readHistoryLedger(prevStamp) {
1739
+ const path = join(ROOT, "docs", "evidence", "history-ledger.json");
1740
+ try {
1741
+ if (!existsSync(path)) return { stamp: null, data: null };
1742
+ const st = statSync(path);
1743
+ const stamp = `${st.size}-${Math.trunc(st.mtimeMs)}`;
1744
+ if (stamp === prevStamp || st.size > 32 * 1024 * 1024) return { stamp, data: null };
1745
+ return { stamp, data: JSON.parse(readFileSync(path, "utf-8")) };
1746
+ } catch {
1747
+ return { stamp: null, data: null };
1748
+ }
1749
+ }
1750
+ const ledgerPlans = () => SNAPSHOT.plans.map((p) => ({ file: p.file, todos: p.todos.items }));
1751
+ if (!withinSnapshotBudget(400)) {
1752
+ // No fold this time: show what is already earned rather than zeros.
1753
+ try {
1754
+ const persisted = readOutcomeLedgerFile(ROOT);
1755
+ SNAPSHOT.outcomeLedger = {
1756
+ ...summarizeOutcomeLedger(persisted.ledger, {
1757
+ tests: testCollectorStatus(ROOT, readTestResults(ROOT)),
1758
+ }),
1759
+ available: false,
1760
+ reason: "budget",
1761
+ };
1762
+ } catch {
1763
+ SNAPSHOT.outcomeLedger = emptyOutcomeLedgerSummary("budget");
1764
+ }
1765
+ } else {
1766
+ try {
1767
+ const testResults = readTestResults(ROOT);
1768
+ const { ledger: prevLedger, foldable } = readOutcomeLedgerFile(ROOT);
1769
+ if (!foldable) throw new Error("outcome ledger unreadable or another version: left as is");
1770
+ const history = readHistoryLedger(prevLedger.sources.historyLedger ?? null);
1771
+ const allPlans = [...ledgerPlans(), ...collectArchivedPlanTodos()];
1772
+ const events = extractOutcomeEvents({
1773
+ plans: allPlans,
1774
+ timing: finalTimingLedger,
1775
+ reviews: reviewOutcomes,
1776
+ reviewsCollected: reviewOutcomesCollected,
1777
+ tags: collectLedgerTags(),
1778
+ ciRuns: SNAPSHOT.devops?.pipeline?.runs || [],
1779
+ originRelease: SNAPSHOT.shipLane?.remote?.originRelease ?? null,
1780
+ testResults,
1781
+ historyLedger: history.data,
1782
+ historyRepo: SNAPSHOT.shipLane?.repo ?? null,
1783
+ });
1784
+ const { ledger } = foldOutcomeLedger(
1785
+ prevLedger,
1786
+ events,
1787
+ history.data ? { historyLedger: history.stamp } : {},
1788
+ );
1789
+ persistOutcomeLedger(ROOT, ledger);
1790
+ SNAPSHOT.outcomeLedger = summarizeOutcomeLedger(ledger, {
1791
+ flow: deriveFlowSignal(finalTimingLedger, SNAPSHOT.runLogs, allPlans),
1792
+ tests: testCollectorStatus(ROOT, testResults),
1793
+ });
1794
+ } catch {
1795
+ SNAPSHOT.outcomeLedger = emptyOutcomeLedgerSummary("unreadable");
1796
+ }
1797
+ }
1422
1798
 
1423
1799
  process.stdout.write(JSON.stringify(SNAPSHOT, null, 2));