rungate 0.8.22 → 0.8.23

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/gates/.gate-salt CHANGED
@@ -1 +1 @@
1
- 7ed090dd68860ba3c71316283fe5935c3fc35fb98b04f2d15f1905c9dd39cac5
1
+ e387efb0e00e0aa4e64f43d5fed7be9d6279267723195e1531aff90000f927f7
@@ -299,6 +299,16 @@ export const CLI_COMMANDS: Record<string, CliCommand> = {
299
299
  "rungate unaccounted-work [--project-root <dir>] [--repo <owner/name>] [--issues-fixture <file.json>] [--json] " +
300
300
  "(exit 1 when work is unaccounted, 2 when a source could not be read)",
301
301
  },
302
+ // #2248: the command #2233 (fix-commits on push to main) and #2234
303
+ // (gate-refusals at the end of a ship run) call, per #1126's decision that
304
+ // each intake source runs on its own trigger.
305
+ intake: {
306
+ script: "scripts/intake.ts",
307
+ summary: "Run each intake source and print its reading — MEASURED with a count, or UNMEASURED naming why",
308
+ usage:
309
+ "rungate intake [--project-root <dir>] [--source <id>] [--json] " +
310
+ "(advisory: an unreadable source prints UNMEASURED and exits 0; exit 2 on a bad argument)",
311
+ },
302
312
  // Reads a `gh pr view`-shaped payload on stdin, which the dispatcher passes
303
313
  // through (`stdio: "inherit"`), or `--fixture` offline.
304
314
  "audit-closing-references": {
@@ -509,6 +509,68 @@ export function stageLadderViolations(raw: unknown): string[] {
509
509
  });
510
510
  });
511
511
 
512
+ out.push(...duplicateVerifyViolations(raw));
513
+ return out;
514
+ }
515
+
516
+ /**
517
+ * Two items proved by one command — #2236.
518
+ *
519
+ * They can never disagree, so the second is never checked as its own claim:
520
+ * whatever makes the first true makes the second true, which is the
521
+ * done-condition restated that AGENTS.md rule 10 forbids. On #2221, E4's first
522
+ * proof was B4's `criteria-field` reading copied byte for byte, and only
523
+ * review caught it.
524
+ *
525
+ * Across the WHOLE ladder, not within a stage, because that is where it
526
+ * happened. Compared after trimming, so a copied command with a stray newline
527
+ * is still the same command. A null verify is an item nobody has written a
528
+ * proof for yet, and two of those duplicate nothing.
529
+ *
530
+ * Retro improvements are in the same population (review of #2243): an
531
+ * improvement's verify proves a mechanism is in place, which is a claim of
532
+ * the same kind, and the live plan carried #1849's improvement in two retros
533
+ * with one command until #2245. An improvement is named by its stage and its
534
+ * 1-based position, `"C retro improvement 2"`, because it has no id.
535
+ */
536
+ function duplicateVerifyViolations(raw: unknown[]): string[] {
537
+ const proofs: { id: string; verify: unknown }[] = [];
538
+ for (const s of raw) {
539
+ const stage = s as { id?: unknown; items?: unknown; retro?: unknown } | null;
540
+ if (stage === null || typeof stage !== "object") continue;
541
+ if (Array.isArray(stage.items)) {
542
+ for (const it of stage.items) {
543
+ const item = it as { id?: unknown; verify?: unknown } | null;
544
+ if (item !== null && typeof item === "object") proofs.push({ id: String(item.id), verify: item.verify });
545
+ }
546
+ }
547
+ const improvements = (stage.retro as { improvements?: unknown } | null)?.improvements;
548
+ if (Array.isArray(improvements)) {
549
+ improvements.forEach((imp, k) => {
550
+ const i = imp as { verify?: unknown } | null;
551
+ if (i !== null && typeof i === "object") {
552
+ proofs.push({ id: `${String(stage.id)} retro improvement ${k + 1}`, verify: i.verify });
553
+ }
554
+ });
555
+ }
556
+ }
557
+ const first = new Map<string, string>();
558
+ const out: string[] = [];
559
+ for (const { id, verify } of proofs) {
560
+ if (typeof verify !== "string") continue;
561
+ const cmd = verify.trim();
562
+ if (cmd === "") continue;
563
+ const earlier = first.get(cmd);
564
+ if (earlier === undefined) {
565
+ first.set(cmd, id);
566
+ continue;
567
+ }
568
+ out.push(
569
+ `"${earlier}" and "${id}" carry the same verify command, so they can never disagree and ` +
570
+ `"${id}" is never checked as its own claim — a done-condition restated (AGENTS.md rule 10). ` +
571
+ `Give "${id}" a command that reads what only it claims.`,
572
+ );
573
+ }
512
574
  return out;
513
575
  }
514
576
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rungate",
3
- "version": "0.8.22",
3
+ "version": "0.8.23",
4
4
  "type": "module",
5
5
  "description": "Ship harness — conformity tests, scaffold, and agent briefs for AI-first development",
6
6
  "repository": {
@@ -37,6 +37,7 @@
37
37
  "scripts/board-ready.ts",
38
38
  "scripts/board-id.ts",
39
39
  "scripts/unaccounted-work.ts",
40
+ "scripts/intake.ts",
40
41
  "scripts/board-intake-move.ts",
41
42
  "scripts/audit-closing-references.ts",
42
43
  "scripts/create-spec.ts",
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * `rungate intake` — run the registered intake sources and print each one's
4
+ * reading (#2248).
5
+ *
6
+ * Before this, nothing outside `lib/intake-sources.ts` called
7
+ * `mineObservedFailures`, so no command ran intake at all. Jason decided on
8
+ * #1126 (2026-11-15) that each source runs on its own trigger: `fix-commits`
9
+ * in CI on push to main with full history (#2233), `gate-refusals` at the end
10
+ * of a ship run (#2234). Both call this.
11
+ *
12
+ * ADVISORY. A source that cannot be read here prints UNMEASURED with the
13
+ * producer's own reason and the command still exits 0: a shallow clone or an
14
+ * absent run store says nothing about the change that triggered the run, so
15
+ * it must never turn that run red. UNMEASURED is printed, never a silent
16
+ * zero, and the partial count of an unmeasured reading is never printed as
17
+ * the reading (`AggregateIntakeReading` withholds `candidates` there for the
18
+ * same reason). A bad argument is the only refusal.
19
+ */
20
+ import { resolve } from "path";
21
+ import {
22
+ INTAKE_SOURCES,
23
+ defaultIntakeContext,
24
+ mineObservedFailures,
25
+ type IntakeContext,
26
+ } from "../lib/intake-sources";
27
+
28
+ /** A bad argument. The only non-zero exit: every reading exits 0. */
29
+ export const EXIT_REFUSED = 2;
30
+
31
+ const USAGE =
32
+ "rungate intake [--project-root <dir>] [--source <id>] [--json] " +
33
+ `(sources: ${INTAKE_SOURCES.map(s => s.id).join(", ")}; advisory — an unreadable source prints UNMEASURED and exits 0)`;
34
+
35
+ /**
36
+ * `deps.workStore` overrides the run store, so a test reads a fixture rather
37
+ * than this machine's `~/.rungate`. Absent, `defaultIntakeContext` decides,
38
+ * which reads `RUNGATE_WORK_DIR` through `lib/paths.ts`.
39
+ */
40
+ export function main(argv: readonly string[], deps: { workStore?: string } = {}): number {
41
+ let rootArg: string | undefined;
42
+ let source: string | undefined;
43
+ let json = false;
44
+ for (let i = 0; i < argv.length; i++) {
45
+ const a = argv[i];
46
+ if (a === "--json") {
47
+ json = true;
48
+ } else if (a === "--project-root" || a === "--source") {
49
+ const next = argv[i + 1];
50
+ if (next === undefined || next.startsWith("--")) {
51
+ console.error(`intake: ${a} needs a value after it. Nothing was read.\n${USAGE}`);
52
+ return EXIT_REFUSED;
53
+ }
54
+ if (a === "--project-root") rootArg = next;
55
+ else source = next;
56
+ i++;
57
+ } else {
58
+ console.error(`intake: unknown argument ${JSON.stringify(a)}. Nothing was read.\n${USAGE}`);
59
+ return EXIT_REFUSED;
60
+ }
61
+ }
62
+
63
+ const sources = source === undefined ? INTAKE_SOURCES : INTAKE_SOURCES.filter(s => s.id === source);
64
+ if (sources.length === 0) {
65
+ console.error(
66
+ `intake: no source is named ${JSON.stringify(source)}. The registered sources are ` +
67
+ `${INTAKE_SOURCES.map(s => s.id).join(", ")}. Nothing was read.`,
68
+ );
69
+ return EXIT_REFUSED;
70
+ }
71
+
72
+ const root = resolve(rootArg ?? process.cwd());
73
+ const base = defaultIntakeContext(root);
74
+ const ctx: IntakeContext = deps.workStore === undefined ? base : { ...base, workStore: deps.workStore };
75
+ const reading = mineObservedFailures(ctx, sources);
76
+
77
+ if (json) {
78
+ console.log(JSON.stringify(reading, null, 2));
79
+ return 0;
80
+ }
81
+
82
+ for (const s of sources) {
83
+ const r = reading.bySource[s.id];
84
+ if (r.reading === "MEASURED") {
85
+ console.log(
86
+ `${s.id}: MEASURED — ${r.candidates.length} candidate(s) from ${r.commitsScanned} unit(s) of history read`,
87
+ );
88
+ } else {
89
+ console.log(`${s.id}: UNMEASURED — ${r.unmeasuredReasons.join("; ")}`);
90
+ }
91
+ }
92
+ console.log(
93
+ reading.reading === "MEASURED"
94
+ ? `intake: MEASURED — ${reading.candidates.length} candidate(s) across ${sources.length} source(s)`
95
+ : `intake: UNMEASURED — ${reading.unmeasuredReasons.length} reason(s) above; ` +
96
+ `${reading.partialCandidates.length} candidate(s) came from the sources that could be read, and are not a reading`,
97
+ );
98
+ return 0;
99
+ }
100
+
101
+ if (import.meta.main) process.exitCode = main(process.argv.slice(2));