@attalabs/vinaya 0.24.1 → 0.26.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 (130) hide show
  1. package/README.md +26 -3
  2. package/aeg-root/contracts/architect-planner.md +5 -5
  3. package/aeg-root/contracts/developer-reviewer.md +10 -7
  4. package/aeg-root/contracts/planner-developer.md +142 -0
  5. package/aeg-root/contracts/reviewer-archivist.md +2 -2
  6. package/aeg-root/contracts/tranche-archivist-planner.md +12 -11
  7. package/aeg-root/enforcement.md +25 -11
  8. package/aeg-root/process.md +53 -75
  9. package/aeg-root/roles/archivist.md +3 -3
  10. package/aeg-root/roles/developer.md +30 -24
  11. package/aeg-root/roles/planner.md +100 -21
  12. package/aeg-root/roles/principal.md +14 -11
  13. package/aeg-root/roles/reviewer.md +33 -17
  14. package/aeg-root/roles/security.md +28 -13
  15. package/aeg-root/roles/tranche-archivist.md +2 -2
  16. package/aeg-root/skills/aeg/SKILL.md +5 -5
  17. package/aeg-root/skills/aeg-roles/SKILL.md +7 -7
  18. package/aeg-root/state-machine.md +36 -35
  19. package/aeg-root/task-model.md +3 -3
  20. package/aeg-root/templates/brief-template.md +22 -6
  21. package/aeg-root/templates/issue-rationale-template.md +35 -2
  22. package/aeg-root/templates/pr-report-template.md +5 -13
  23. package/aeg-root/tranche-model.md +21 -21
  24. package/dist/checks/bin/check-body-bare-digits.js +684 -142
  25. package/dist/checks/bin/check-branch-topology.js +741 -88
  26. package/dist/checks/bin/check-brief-shape.js +708 -83
  27. package/dist/checks/bin/check-changeset-coverage.js +1445 -149
  28. package/dist/checks/bin/check-closes-n.js +741 -88
  29. package/dist/checks/bin/check-coherence.js +808 -149
  30. package/dist/checks/bin/check-dead-branch-push.js +617 -81
  31. package/dist/checks/bin/check-dispatch-readiness.js +811 -152
  32. package/dist/checks/bin/check-doc-coverage-push.js +1445 -149
  33. package/dist/checks/bin/check-doc-coverage.js +1447 -151
  34. package/dist/checks/bin/check-doctrine-no-procedures.js +684 -142
  35. package/dist/checks/bin/check-doctrine-portability.js +1445 -149
  36. package/dist/checks/bin/check-evidence-fresh.js +684 -142
  37. package/dist/checks/bin/check-exec-bits.js +1445 -149
  38. package/dist/checks/bin/check-first-push-dispatch.js +808 -149
  39. package/dist/checks/bin/check-issue-assignment.js +741 -88
  40. package/dist/checks/bin/check-main-branch-refusal.js +618 -82
  41. package/dist/checks/bin/check-no-disk-state.js +617 -81
  42. package/dist/checks/bin/check-pr-premise-reassert.js +5401 -0
  43. package/dist/checks/bin/check-pr-report-density.js +617 -81
  44. package/dist/checks/bin/check-quoted-command.js +1443 -147
  45. package/dist/checks/bin/check-reader-resolvable-prose.js +1481 -153
  46. package/dist/checks/bin/check-registry-gates.js +659 -85
  47. package/dist/checks/bin/check-retired-vocabulary.js +1443 -147
  48. package/dist/checks/bin/check-review-gate.js +758 -145
  49. package/dist/checks/bin/check-single-plan-pr.js +617 -81
  50. package/dist/checks/bin/check-surface-scope.js +5722 -0
  51. package/dist/checks/bin/check-test-plan.js +617 -81
  52. package/dist/checks/bin/check-token-collection-wired.js +617 -81
  53. package/dist/checks/bin/check-token-report.js +629 -88
  54. package/dist/checks/bin/check-workspace-escape.js +1443 -147
  55. package/dist/index.js +8548 -4335
  56. package/package.json +1 -1
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +2 -2
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +26 -1
  59. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  60. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  61. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  62. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  63. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  64. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  65. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  66. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  70. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +2 -2
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0053k9k._.js +1 -1
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0112h-k._.js +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0o771t1._.js +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1pndh3_._.js → [root-of-the-server]__0p8q38b._.js} +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0puovz5._.js +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1hs0dcu._.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_03x_w6q._.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gvm3og._.js +1 -1
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0lwxg63._.js +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0wxycau._.js +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1n0cnq-._.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_1vo08dj._.js +2 -2
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_topbar_index_tsx_1h1gs1y._.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +3 -3
  116. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3m1kgax7j2vgs.js → 0bn8c8v5q429o.js} +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0doqwpd81sjzn.js → 0keji7wvbe1d1.js} +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1maoxbrl3pv5d.css +1 -0
  119. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1uogpj5w2n5ju.js → 3-6a3tinbdb-7.js} +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0zebsmmk1bvnb.js → 3_9xytdmiv1xi.js} +4 -4
  121. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  122. package/aeg-root/contracts/brief-developer.md +0 -141
  123. package/aeg-root/contracts/planner-brief.md +0 -130
  124. package/aeg-root/roles/brief-author.md +0 -114
  125. package/aeg-root/skills/brief-authoring/SKILL.md +0 -509
  126. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3qc67qhcvbg0o.css +0 -1
  127. /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  128. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{QY2GhiI47-765D9DHGy1I → DMofV2-9FrHE7100GfrpI}/_buildManifest.js +0 -0
  129. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{QY2GhiI47-765D9DHGy1I → DMofV2-9FrHE7100GfrpI}/_clientMiddlewareManifest.js +0 -0
  130. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{QY2GhiI47-765D9DHGy1I → DMofV2-9FrHE7100GfrpI}/_ssgManifest.js +0 -0
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
3
3
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
4
 
5
5
  // src/checks/bin/check-doc-coverage-push.ts
6
- import { execFileSync as execFileSync4 } from "node:child_process";
6
+ import { execFileSync as execFileSync5 } from "node:child_process";
7
7
  import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
8
8
  // ../../packages/aeg-core/src/gate-audience.ts
9
9
  var GATE_AUDIENCE = {
@@ -28,6 +28,15 @@ var GATE_AUDIENCE = {
28
28
  internal: "A composite that shells this repo's own `typecheck`/`lint`/`test`/`build` scripts by name. Those names are this monorepo's toolchain (bun + turbo + biome), not an adopter's; the shipped equivalent of its intent is `vinaya check --all`, which is portable by construction."
29
29
  }
30
30
  };
31
+ var NON_GATE_BINS = [
32
+ "archive-task",
33
+ "assign-task-issue",
34
+ "dead-branch-audit",
35
+ "eval-agent-compliance",
36
+ "open-issue",
37
+ "open-pr",
38
+ "report-tokens"
39
+ ];
31
40
  function isShipped(a) {
32
41
  return "shippedAs" in a;
33
42
  }
@@ -388,7 +397,7 @@ var LABELS = [
388
397
  id: "vinaya/needs:brief-correction",
389
398
  category: "needs",
390
399
  form: "literal",
391
- carries: "Waiting on the Brief Author — the brief contradicts the surface it describes."
400
+ carries: "Waiting on the Planner — the brief contradicts the surface it describes."
392
401
  },
393
402
  {
394
403
  key: "waiver-docs",
@@ -1939,13 +1948,18 @@ function parseInlineFieldList(section) {
1939
1948
  }
1940
1949
  // ../../packages/aeg-core/src/verdict-extraction.ts
1941
1950
  var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
1942
- function firstThreeLines(comment) {
1951
+ var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
1952
+ function firstFiveLines(comment) {
1943
1953
  return comment.split(`
1944
- `).slice(0, 3).join(`
1954
+ `).slice(0, 5).join(`
1945
1955
  `);
1946
1956
  }
1947
1957
  function extractHeadSha(comment) {
1948
- const m = firstThreeLines(comment).match(HEAD_SHA_PATTERN);
1958
+ const m = firstFiveLines(comment).match(HEAD_SHA_PATTERN);
1959
+ return m ? m[1].toLowerCase() : null;
1960
+ }
1961
+ function extractObjectivesVersion(comment) {
1962
+ const m = firstFiveLines(comment).match(OBJECTIVES_VERSION_PATTERN);
1949
1963
  return m ? m[1].toLowerCase() : null;
1950
1964
  }
1951
1965
  function extractVerdict(comments, valuePattern, missingLabel) {
@@ -1954,21 +1968,24 @@ function extractVerdict(comments, valuePattern, missingLabel) {
1954
1968
  return {
1955
1969
  value: `no ${missingLabel} pass was run before merge — DANGLING, see below`,
1956
1970
  headSha: null,
1971
+ objectivesVersion: null,
1957
1972
  danglingNote: `no ${missingLabel} verdict comment found on this PR`
1958
1973
  };
1959
1974
  }
1960
1975
  const latest = candidates[candidates.length - 1];
1961
- const m = firstThreeLines(latest).match(valuePattern);
1976
+ const m = firstFiveLines(latest).match(valuePattern);
1962
1977
  if (!m) {
1963
1978
  return {
1964
- value: `the most recent ${missingLabel} comment's VERDICT line is not within its first three lines — DANGLING, see below`,
1979
+ value: `the most recent ${missingLabel} comment's VERDICT line is not within its first five lines — DANGLING, see below`,
1965
1980
  headSha: null,
1966
- danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-three-line read window`
1981
+ objectivesVersion: null,
1982
+ danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
1967
1983
  };
1968
1984
  }
1969
1985
  return {
1970
1986
  value: m[1].toUpperCase().replace(/[_-]/g, " "),
1971
1987
  headSha: extractHeadSha(latest),
1988
+ objectivesVersion: extractObjectivesVersion(latest),
1972
1989
  danglingNote: null
1973
1990
  };
1974
1991
  }
@@ -2325,8 +2342,105 @@ function overrideActive(opts) {
2325
2342
  return true;
2326
2343
  return false;
2327
2344
  }
2328
- // ../../packages/aeg-core/src/premise-check.ts
2345
+ // ../../packages/aeg-core/src/objectives.ts
2329
2346
  import { createHash as createHash2 } from "node:crypto";
2347
+ var HEADING_RE = /^##[ \t]*Objectives[ \t]*$/im;
2348
+ var NEXT_HEADING_RE = /^##[ \t]/m;
2349
+ var OBJECTIVE_LINE_RE = /^O(\d+)\.[ \t]*(.*)$/;
2350
+ function hasBacktickedPath(text) {
2351
+ let i = 0;
2352
+ while (i < text.length) {
2353
+ const start = text.indexOf("`", i);
2354
+ if (start === -1)
2355
+ return false;
2356
+ const end = text.indexOf("`", start + 1);
2357
+ if (end === -1)
2358
+ return false;
2359
+ if (text.slice(start + 1, end).includes("/"))
2360
+ return true;
2361
+ i = end + 1;
2362
+ }
2363
+ return false;
2364
+ }
2365
+ var MIN_WORDS_OUTSIDE_BACKTICKS = 3;
2366
+ function stripObjectiveBackticks(text) {
2367
+ return text.replace(/`[^`\n]*`/g, " ");
2368
+ }
2369
+ function wordCount(text) {
2370
+ return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
2371
+ }
2372
+ function objectivesSectionText(body) {
2373
+ const heading = HEADING_RE.exec(body);
2374
+ if (!heading)
2375
+ return null;
2376
+ const afterHeading = body.slice(heading.index + heading[0].length);
2377
+ const next = NEXT_HEADING_RE.exec(afterHeading);
2378
+ return next ? afterHeading.slice(0, next.index) : afterHeading;
2379
+ }
2380
+ function hasObjectivesHeading(body) {
2381
+ return HEADING_RE.test(body);
2382
+ }
2383
+ function objectivesOf(body) {
2384
+ const section = objectivesSectionText(body);
2385
+ if (section === null) {
2386
+ return { ok: false, errors: ["no `## Objectives` heading found in the body."] };
2387
+ }
2388
+ const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
2389
+ if (lines.length === 0) {
2390
+ return { ok: false, errors: ["the `## Objectives` section has no `O<n>.` lines."] };
2391
+ }
2392
+ const objectives = [];
2393
+ const errors = [];
2394
+ for (const line of lines) {
2395
+ const m = OBJECTIVE_LINE_RE.exec(line);
2396
+ if (!m) {
2397
+ errors.push(`"${line}" is not a well-formed objective line — expected \`O<n>. <sentence>\`, e.g. \`O1. …\`.`);
2398
+ continue;
2399
+ }
2400
+ const n = m[1];
2401
+ const text = m[2].trim();
2402
+ if (text.length === 0) {
2403
+ errors.push(`O${n} has no sentence — every objective is one observable sentence.`);
2404
+ continue;
2405
+ }
2406
+ if (hasBacktickedPath(text) && wordCount(stripObjectiveBackticks(text)) < MIN_WORDS_OUTSIDE_BACKTICKS) {
2407
+ errors.push(`O${n} is little more than a file path — an objective states an observable outcome, never a bare path (the Planner maps it to files).`);
2408
+ continue;
2409
+ }
2410
+ objectives.push({ id: `O${n}`, text });
2411
+ }
2412
+ for (let i = 0;i < objectives.length; i++) {
2413
+ const expected = i + 1;
2414
+ const actual = Number.parseInt(objectives[i].id.slice(1), 10);
2415
+ if (actual !== expected) {
2416
+ errors.push(`numbering is not contiguous from O1 — expected O${expected}, found ${objectives[i].id}.`);
2417
+ break;
2418
+ }
2419
+ }
2420
+ if (errors.length > 0)
2421
+ return { ok: false, errors };
2422
+ return { ok: true, objectives };
2423
+ }
2424
+ function normalizeText(text) {
2425
+ return text.trim().replace(/\s+/g, " ");
2426
+ }
2427
+ function objectivesVersion(objectives) {
2428
+ const normalized = objectives.map((o) => `${o.id} ${normalizeText(o.text)}`).join(`
2429
+ `);
2430
+ return createHash2("sha256").update(normalized).digest("hex");
2431
+ }
2432
+ function isIssueNotFoundError(err) {
2433
+ const stderr = err?.stderr;
2434
+ const haystack = [
2435
+ err?.message ?? "",
2436
+ typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
2437
+ ].join(`
2438
+ `);
2439
+ return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
2440
+ }
2441
+
2442
+ // ../../packages/aeg-core/src/premise-check.ts
2443
+ import { createHash as createHash3 } from "node:crypto";
2330
2444
  var ASSERTION_KINDS = new Set(["contains", "absent", "sha256"]);
2331
2445
  function isPremiseHeader(line) {
2332
2446
  const stripped = line.replace(/[*#]/g, "").trim();
@@ -2397,7 +2511,7 @@ function checkPremises(assertions, fileReader) {
2397
2511
  } else if (a.kind === "absent" && content.includes(a.value)) {
2398
2512
  failures.push(`premise-check: ${a.path} now contains "${a.value}", but the brief pinned it absent — the premise has moved; re-dig before proceeding.`);
2399
2513
  } else if (a.kind === "sha256") {
2400
- const actual = createHash2("sha256").update(content).digest("hex");
2514
+ const actual = createHash3("sha256").update(content).digest("hex");
2401
2515
  if (actual !== a.value.toLowerCase()) {
2402
2516
  failures.push(`premise-check: ${a.path} sha256 mismatch (brief pinned ${a.value}, file is now ${actual}) — the file changed since this brief was authored; re-dig before proceeding.`);
2403
2517
  }
@@ -2502,18 +2616,14 @@ function checkTestPlanExclusivity(prBody) {
2502
2616
  function checkPrincipalPlaceholder(prBody) {
2503
2617
  const region = testPlanRegion(prBody);
2504
2618
  const lineRe = /^-\s*\[[ xX]\]\s*\*{2}\[principal\]\*{2}(.*)$/gim;
2619
+ const errors = [];
2505
2620
  for (const m of region.matchAll(lineRe)) {
2506
2621
  const content = m[1] ?? "";
2507
2622
  if (/^\s*None\b/i.test(content)) {
2508
- return {
2509
- status: "fail",
2510
- errors: [
2511
- 'brief-validation Test Plan shape: a `**[principal]**` checkbox item is a "None" placeholder — if there is no principal-runnable surface, omit the item entirely; an untickable placeholder box blocks the merge gate forever.'
2512
- ]
2513
- };
2623
+ errors.push(`brief-validation Test Plan shape: a \`**[principal]**\` checkbox item is a "None" placeholder ("${content.trim()}") — if there is no principal-runnable surface, omit the item entirely; an untickable placeholder box blocks the merge gate forever.`);
2514
2624
  }
2515
2625
  }
2516
- return { status: "pass", errors: [] };
2626
+ return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
2517
2627
  }
2518
2628
  function checkSurfaceMap(prBody) {
2519
2629
  return headingCheck(prBody, "(?:technical\\s+)?surface map", "Technical surface map");
@@ -2758,8 +2868,55 @@ function checkDefeatCases(prBody) {
2758
2868
  ]
2759
2869
  };
2760
2870
  }
2871
+ var PART_CITATION_RE = /Part\s+\d+\s*\(([^)]*)\)/gi;
2872
+ var OBJECTIVE_REF_RE = /O(\d+)/g;
2873
+ function citedObjectiveIds(section6) {
2874
+ const ids = new Set;
2875
+ for (const m of section6.matchAll(PART_CITATION_RE)) {
2876
+ for (const r of m[1].matchAll(OBJECTIVE_REF_RE))
2877
+ ids.add(Number.parseInt(r[1], 10));
2878
+ }
2879
+ return ids;
2880
+ }
2881
+ function checkObjectivesCopy(prBody, issueObjectives) {
2882
+ const parsed = objectivesOf(prBody);
2883
+ if (!parsed.ok) {
2884
+ return { status: "fail", errors: parsed.errors.map((e) => `brief-validation objectives copy: ${e}`) };
2885
+ }
2886
+ if (objectivesVersion(parsed.objectives) !== objectivesVersion(issueObjectives)) {
2887
+ return {
2888
+ status: "fail",
2889
+ errors: [
2890
+ "brief-validation objectives copy: the brief's `## Objectives` section does not match the Issue's — copy the Issue's `## Objectives` section (aeg-root/roles/developer.md)."
2891
+ ]
2892
+ };
2893
+ }
2894
+ return { status: "pass", errors: [] };
2895
+ }
2896
+ function checkObjectivesCoverage(prBody) {
2897
+ const parsed = objectivesOf(prBody);
2898
+ if (!parsed.ok) {
2899
+ return { status: "fail", errors: parsed.errors.map((e) => `brief-validation objectives coverage: ${e}`) };
2900
+ }
2901
+ const declaredIds = new Set(parsed.objectives.map((o) => Number.parseInt(o.id.slice(1), 10)));
2902
+ const section6 = extractNumberedSection(prBody, 6) ?? "";
2903
+ const cited = citedObjectiveIds(section6);
2904
+ const maxDeclared = Math.max(...declaredIds, 0);
2905
+ const errors = [];
2906
+ for (const id of declaredIds) {
2907
+ if (!cited.has(id)) {
2908
+ errors.push(`brief-validation objectives coverage: O${id} is not cited by any Part in §6 — every objective must be cited by at least one Part.`);
2909
+ }
2910
+ }
2911
+ for (const id of cited) {
2912
+ if (!declaredIds.has(id)) {
2913
+ errors.push(`brief-validation objectives coverage: a Part in §6 cites O${id}, but the Objectives section ends at O${maxDeclared}.`);
2914
+ }
2915
+ }
2916
+ return errors.length === 0 ? { status: "pass", errors: [] } : { status: "fail", errors };
2917
+ }
2761
2918
  function checkBriefSections(prBody, readTier, options = {}) {
2762
- const { requireClosesN = true, consumersOf = () => [] } = options;
2919
+ const { requireClosesN = true, consumersOf = () => [], issueObjectives } = options;
2763
2920
  const results = [
2764
2921
  checkTierField(prBody, readTier),
2765
2922
  checkTestPlan(prBody),
@@ -2777,10 +2934,23 @@ function checkBriefSections(prBody, readTier, options = {}) {
2777
2934
  checkCommandsCarryOutput(prBody),
2778
2935
  checkConsumerTests(prBody, consumersOf),
2779
2936
  checkDefeatCases(prBody),
2937
+ ...issueObjectives !== undefined ? [checkObjectivesCopy(prBody, issueObjectives), checkObjectivesCoverage(prBody)] : [],
2780
2938
  ...requireClosesN ? [checkClosesN(prBody)] : []
2781
2939
  ];
2782
2940
  return { errors: results.flatMap((r) => r.errors) };
2783
2941
  }
2942
+ var AEG_BRIEF_V1_MARKER = "<!-- aeg:brief:v1 -->";
2943
+ function contentAfterTwoLines(body) {
2944
+ const first = body.indexOf(`
2945
+ `);
2946
+ if (first === -1)
2947
+ return "";
2948
+ const second = body.indexOf(`
2949
+ `, first + 1);
2950
+ if (second === -1)
2951
+ return "";
2952
+ return body.slice(second + 1);
2953
+ }
2784
2954
  // ../../packages/aeg-core/src/doctrine-portability.ts
2785
2955
  var DEFAULT_SHIPS_PREFIX = "aeg-root/";
2786
2956
  var STATIC_PORTABLE_PREFIXES = [
@@ -2975,14 +3145,14 @@ function checkSectionDensity(prBody, heading) {
2975
3145
  ]
2976
3146
  };
2977
3147
  }
2978
- function checkSummaryDensity(prBody) {
2979
- return checkSectionDensity(prBody, "Summary");
3148
+ function checkDecisionsDensity(prBody) {
3149
+ return checkSectionDensity(prBody, "Decisions");
2980
3150
  }
2981
3151
  function checkScopeDensity(prBody) {
2982
3152
  return checkSectionDensity(prBody, "Scope");
2983
3153
  }
2984
3154
  function checkPrReportDensity(prBody) {
2985
- const results = [checkSummaryDensity(prBody), checkScopeDensity(prBody)];
3155
+ const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
2986
3156
  return { errors: results.flatMap((r) => r.errors) };
2987
3157
  }
2988
3158
  // ../../packages/aeg-core/src/issue-validation.ts
@@ -3014,6 +3184,75 @@ function checkIssueRationale(body) {
3014
3184
  }
3015
3185
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3016
3186
  }
3187
+ var OBJECTIVES_SINCE_ISSUE = 404;
3188
+ function checkIssueObjectives(body, issueNumber) {
3189
+ if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE)
3190
+ return { status: "pass", errors: [] };
3191
+ const result = objectivesOf(body);
3192
+ if (result.ok)
3193
+ return { status: "pass", errors: [] };
3194
+ return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
3195
+ }
3196
+ function topLevelSectionText(body, headingName) {
3197
+ const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
3198
+ const heading = headingRe.exec(body);
3199
+ if (!heading)
3200
+ return null;
3201
+ const afterHeading = body.slice(heading.index + heading[0].length);
3202
+ const next = /^##[ \t]/m.exec(afterHeading);
3203
+ return next ? afterHeading.slice(0, next.index) : afterHeading;
3204
+ }
3205
+ function looksLikeFilePath(entry2) {
3206
+ const stripped = entry2.replace(/\/\*\*?$/, "");
3207
+ const lastSegment = stripped.split("/").pop() ?? stripped;
3208
+ const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3209
+ return extMatch !== null && extMatch.index > 0;
3210
+ }
3211
+ function splitGlobList(raw) {
3212
+ return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
3213
+ }
3214
+ function parseIssueSurface(body) {
3215
+ const section = topLevelSectionText(body, "Surface");
3216
+ if (section === null)
3217
+ return { ok: false, errors: ["no `## Surface` heading found in the body."] };
3218
+ const inLine = /^in:\s*(.+)$/im.exec(section);
3219
+ const outLine = /^out:\s*(.+)$/im.exec(section);
3220
+ const errors = [];
3221
+ if (!inLine)
3222
+ errors.push("`## Surface` has no `in:` line.");
3223
+ if (!outLine)
3224
+ errors.push("`## Surface` has no `out:` line.");
3225
+ if (errors.length > 0)
3226
+ return { ok: false, errors };
3227
+ const inGlobs = splitGlobList(inLine[1]);
3228
+ const outGlobs = splitGlobList(outLine[1]);
3229
+ for (const g of [...inGlobs, ...outGlobs]) {
3230
+ if (looksLikeFilePath(g)) {
3231
+ errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
3232
+ }
3233
+ }
3234
+ if (inGlobs.length === 0)
3235
+ errors.push("`## Surface`'s `in:` line resolved to zero globs.");
3236
+ if (errors.length > 0)
3237
+ return { ok: false, errors };
3238
+ return { ok: true, value: { in: inGlobs, out: outGlobs } };
3239
+ }
3240
+ function globCoversPath(glob, path) {
3241
+ const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
3242
+ const p = path.replace(/\/+$/, "");
3243
+ return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
3244
+ }
3245
+ function checkSurfaceScope(changedFiles, outGlobs) {
3246
+ if (outGlobs.length === 0)
3247
+ return { ok: true };
3248
+ const violations = [];
3249
+ for (const file of changedFiles) {
3250
+ const glob = outGlobs.find((g) => globCoversPath(g, file));
3251
+ if (glob)
3252
+ violations.push({ file, glob });
3253
+ }
3254
+ return violations.length > 0 ? { ok: false, violations } : { ok: true };
3255
+ }
3017
3256
  function isTaskIssueLabelSet(labels) {
3018
3257
  return hasLabel("tranche", labels);
3019
3258
  }
@@ -3078,6 +3317,8 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
3078
3317
  }
3079
3318
  return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
3080
3319
  }
3320
+ var DOC_PATH_RE = /(?:(?:aeg-root|apps|packages|specs|docs|tools|\.claude|\.github)\/[\w./@-]*\.(?:md|mdx)|\.claude\/(?:skills|rules)\/[\w./-]+|\b(?:docs-index|decisions|projects|state-machine|enforcement|process|README|CLAUDE)\.md\b|\b[\w-]+-(?:spec|decisions|backlog)\.md\b)/i;
3321
+ var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
3081
3322
 
3082
3323
  // ../../packages/aeg-core/src/coherence-checks.ts
3083
3324
  var COHERENCE_ENFORCED_FROM = "2026-07-01";
@@ -3275,7 +3516,8 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3275
3516
  continue;
3276
3517
  const errors = [
3277
3518
  ...checkIssueRationale(issue.body).errors,
3278
- ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors
3519
+ ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
3520
+ ...checkIssueObjectives(issue.body, issue.number).errors
3279
3521
  ];
3280
3522
  if (errors.length === 0)
3281
3523
  continue;
@@ -3390,6 +3632,27 @@ function checkClosesN2(branch, prBody, trancheFiles, taskIssueRefs) {
3390
3632
  }
3391
3633
  return { ok: true, expectedIssue };
3392
3634
  }
3635
+ // ../../packages/aeg-core/src/archive-task.ts
3636
+ function closesRefs(text) {
3637
+ return [...new Set([...text.matchAll(/Closes #(\d+)/gi)].map((m) => Number(m[1])))];
3638
+ }
3639
+ function extractIssue(body) {
3640
+ const stripped = stripCode(body);
3641
+ const bodyNums = closesRefs(stripped);
3642
+ const anchored = anchoredRegion(stripped, "CLOSES");
3643
+ if (anchored !== null) {
3644
+ const anchorNums = closesRefs(anchored);
3645
+ if (anchorNums.length === 0)
3646
+ return { issue: null, extraIssues: bodyNums, outsideHeader: false };
3647
+ const issue2 = anchorNums[0];
3648
+ return { issue: issue2, extraIssues: bodyNums.filter((n) => n !== issue2), outsideHeader: false };
3649
+ }
3650
+ const headerNums = closesRefs(headerRegion(stripped));
3651
+ if (bodyNums.length === 0)
3652
+ return { issue: null, extraIssues: [], outsideHeader: false };
3653
+ const issue = headerNums.length > 0 ? headerNums[0] : bodyNums[0];
3654
+ return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: headerNums.length === 0 };
3655
+ }
3393
3656
  // ../../packages/aeg-core/src/review-gate.ts
3394
3657
  function isBoundToHead(extraction, headSha) {
3395
3658
  if (!extraction.headSha)
@@ -3408,6 +3671,11 @@ function isBoundByPatchIdentity(extraction, headSha, patchIdOf) {
3408
3671
  function isBoundToPatch(extraction, headSha, patchIdOf) {
3409
3672
  return isBoundToHead(extraction, headSha) || isBoundByPatchIdentity(extraction, headSha, patchIdOf);
3410
3673
  }
3674
+ function isBoundToObjectives(extraction, currentVersion) {
3675
+ if (currentVersion === null)
3676
+ return true;
3677
+ return extraction.objectivesVersion === currentVersion;
3678
+ }
3411
3679
  function checkReviewGate(input) {
3412
3680
  const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
3413
3681
  const waived = isWaiverLabelActorVerified({
@@ -3434,7 +3702,9 @@ function checkReviewGate(input) {
3434
3702
  const securityClean = security.value === "PASS";
3435
3703
  const codeReviewBound = isBoundToPatch(codeReview, input.headSha, input.patchIdOf);
3436
3704
  const securityBound = isBoundToPatch(security, input.headSha, input.patchIdOf);
3437
- if (codeReviewClean && codeReviewBound && securityClean && securityBound && mechanicalChecksClean) {
3705
+ const codeReviewObjectivesBound = isBoundToObjectives(codeReview, input.objectivesVersion);
3706
+ const securityObjectivesBound = isBoundToObjectives(security, input.objectivesVersion);
3707
+ if (codeReviewClean && codeReviewBound && codeReviewObjectivesBound && securityClean && securityBound && securityObjectivesBound && mechanicalChecksClean) {
3438
3708
  return {
3439
3709
  verdict: "pass",
3440
3710
  reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}, and every reported mechanical check is green.`,
@@ -3446,11 +3716,15 @@ function checkReviewGate(input) {
3446
3716
  problems.push(`code-reviewer verdict is not a clean APPROVE (found: ${codeReview.value})`);
3447
3717
  } else if (!codeReviewBound) {
3448
3718
  problems.push(`the newest code-review verdict covers ${codeReview.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
3719
+ } else if (!codeReviewObjectivesBound) {
3720
+ problems.push(`the newest code-review verdict was cast against objectives version ${codeReview.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
3449
3721
  }
3450
3722
  if (!securityClean) {
3451
3723
  problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
3452
3724
  } else if (!securityBound) {
3453
3725
  problems.push(`the newest security-review verdict covers ${security.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
3726
+ } else if (!securityObjectivesBound) {
3727
+ problems.push(`the newest security-review verdict was cast against objectives version ${security.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
3454
3728
  }
3455
3729
  if (!mechanicalChecksClean) {
3456
3730
  problems.push(reportedMechanicalChecks.length === 0 ? "no mechanical checks have reported for this head yet" : `mechanical check(s) not green: ${reportedMechanicalChecks.filter((c) => c.bucket !== "pass").map((c) => `${c.name} (${c.bucket})`).join(", ")}`);
@@ -3574,16 +3848,33 @@ function checkG1(rows, existsFn) {
3574
3848
  return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
3575
3849
  }
3576
3850
  var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
3851
+ var NON_GATE_BIN_NAMES = NON_GATE_BINS;
3852
+ var TWIN_CANDIDATE_EXCEPTIONS = {
3853
+ "apps/cli/src/checks/bin/check-dead-branch-push.ts": 'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
3854
+ "apps/cli/src/checks/bin/check-issue-assignment.ts": `Ring 0 "A task branch's first push (Issue self-assignment)" (implementation: assign-task-issue.ts)`,
3855
+ "apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
3856
+ };
3857
+ var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
3577
3858
  function checkG2(rows, candidateFiles) {
3578
3859
  const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
3860
+ const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
3579
3861
  const findings = [];
3580
3862
  for (const path of candidateFiles) {
3581
- if (!implementations.has(path)) {
3582
- findings.push({
3583
- path,
3584
- reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
3585
- });
3586
- }
3863
+ if (implementations.has(path))
3864
+ continue;
3865
+ if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
3866
+ continue;
3867
+ if (NON_GATE_HOOK_SCRIPTS.includes(path))
3868
+ continue;
3869
+ if (path in TWIN_CANDIDATE_EXCEPTIONS)
3870
+ continue;
3871
+ const candidateNames = claimedCheckNames(path);
3872
+ if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
3873
+ continue;
3874
+ findings.push({
3875
+ path,
3876
+ reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
3877
+ });
3587
3878
  }
3588
3879
  for (const row of rows) {
3589
3880
  const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
@@ -3595,7 +3886,7 @@ function checkG2(rows, candidateFiles) {
3595
3886
  });
3596
3887
  }
3597
3888
  }
3598
- return { check: "G2", status: findings.length > 0 ? "info" : "pass", findings };
3889
+ return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
3599
3890
  }
3600
3891
  function checkG3(ring0Rows, crossingFiles) {
3601
3892
  const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
@@ -3686,55 +3977,20 @@ function checkG6(rows, registeredCheckNames) {
3686
3977
  }
3687
3978
  return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
3688
3979
  }
3689
- // ../../packages/aeg-core/src/dead-branch-push-guard.ts
3690
- function checkDeadBranchPush(input) {
3691
- const { branch, prState, prNumber } = input;
3692
- if (prState === "MERGED") {
3693
- return {
3694
- verdict: "refuse",
3695
- reason: `Branch \`${branch}\` already has a MERGED PR (#${prNumber}) — this branch's work is done. Push a new task branch instead of pushing onto an already-resolved one.`
3696
- };
3697
- }
3698
- if (prState === "CLOSED") {
3699
- return {
3700
- verdict: "refuse",
3701
- reason: `Branch \`${branch}\` has a CLOSED PR (#${prNumber}) that was never merged — pushing here would resurrect abandoned/rejected work. Open a new task branch instead.`
3702
- };
3703
- }
3704
- if (prState === "OPEN") {
3705
- return {
3706
- verdict: "allow",
3707
- reason: `Branch \`${branch}\` has an OPEN PR (#${prNumber}) — pushing more commits to it is normal.`
3708
- };
3709
- }
3710
- if (prState === "NONE") {
3711
- return {
3712
- verdict: "allow",
3713
- reason: `Branch \`${branch}\` has no PR yet — a brand-new task branch legitimately has none.`
3714
- };
3715
- }
3716
- return {
3717
- verdict: "allow",
3718
- reason: `Could not determine \`${branch}\`'s PR state (forge unreachable) — failing open rather than blocking the push on a transient issue.`
3719
- };
3980
+ // ../../packages/aeg-core/src/reader-resolvable-prose.ts
3981
+ var PRODUCT_SLUG_SCOPE = [
3982
+ "apps/cli/src",
3983
+ ".github/workflows",
3984
+ ".vinaya",
3985
+ "apps/cli/README.md",
3986
+ "packages/sources/README.md"
3987
+ ];
3988
+ function isUnderOrEqual(path, prefix) {
3989
+ return path === prefix || path.startsWith(`${prefix}/`);
3720
3990
  }
3721
- // ../../packages/aeg-core/src/baseline-capture.ts
3722
- function captureBaseline(counts, capturedAt) {
3723
- return counts.map((c) => ({ tool: c.tool, findingCount: c.findingCount, capturedAt }));
3991
+ function isProductScopeFile(path) {
3992
+ return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
3724
3993
  }
3725
- function compareToBaseline(current, baseline) {
3726
- const perTool = current.map((c) => {
3727
- const baselineEntry = baseline.find((b) => b.tool === c.tool);
3728
- const baselineCount = baselineEntry ? baselineEntry.findingCount : c.findingCount;
3729
- return { tool: c.tool, baseline: baselineCount, current: c.findingCount, delta: c.findingCount - baselineCount };
3730
- });
3731
- return {
3732
- withinBudget: perTool.every((t) => t.delta <= 0),
3733
- delta: perTool.reduce((sum, t) => sum + t.delta, 0),
3734
- perTool
3735
- };
3736
- }
3737
- // ../../packages/aeg-core/src/reader-resolvable-prose.ts
3738
3994
  var SHIPS_PREFIX = "aeg-root/";
3739
3995
  function shipsArchivePrefix(shipsPrefix) {
3740
3996
  return `${shipsPrefix}tranches/completed/`;
@@ -3754,6 +4010,8 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
3754
4010
  }
3755
4011
  if (isSpecFile2(path) || isClaudeMdFile(path))
3756
4012
  return "internal";
4013
+ if (isProductScopeFile(path))
4014
+ return "product";
3757
4015
  return null;
3758
4016
  }
3759
4017
  var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
@@ -3766,6 +4024,9 @@ function stripNonProse(path, content) {
3766
4024
  }
3767
4025
  return content;
3768
4026
  }
4027
+ function stripNonProseForProduct(path, content) {
4028
+ return path.endsWith(".md") ? stripNonProse(path, content) : content;
4029
+ }
3769
4030
  function lineAt(content, index) {
3770
4031
  let line = 1;
3771
4032
  for (let i = 0;i < index; i++) {
@@ -3790,12 +4051,19 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3790
4051
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
3791
4052
  ...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
3792
4053
  ];
4054
+ const productPatterns = [
4055
+ { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4056
+ ];
3793
4057
  for (const file of files) {
3794
4058
  const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3795
- if (!cls || !SWEPT_CLASSES.has(cls))
4059
+ if (!cls || cls === "internal")
3796
4060
  continue;
3797
- const scrubbed = stripNonProse(file.path, file.content);
3798
- for (const { pattern, what, group } of patterns) {
4061
+ if (cls !== "product" && !SWEPT_CLASSES.has(cls))
4062
+ continue;
4063
+ const blocking = cls === "product";
4064
+ const scrubbed = blocking ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4065
+ const patternsToRun = blocking ? productPatterns : patterns;
4066
+ for (const { pattern, what, group } of patternsToRun) {
3799
4067
  pattern.lastIndex = 0;
3800
4068
  let match = pattern.exec(scrubbed);
3801
4069
  while (match !== null) {
@@ -3803,7 +4071,8 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3803
4071
  findings.push({
3804
4072
  file: file.path,
3805
4073
  line: lineAt(scrubbed, match.index),
3806
- message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`
4074
+ message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4075
+ blocking
3807
4076
  });
3808
4077
  match = pattern.exec(scrubbed);
3809
4078
  }
@@ -3853,7 +4122,8 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
3853
4122
  findings.push({
3854
4123
  file: file.path,
3855
4124
  line,
3856
- message: `uses coined term "${term}" without defining it inline or linking the glossary`
4125
+ message: `uses coined term "${term}" without defining it inline or linking the glossary`,
4126
+ blocking: false
3857
4127
  });
3858
4128
  }
3859
4129
  }
@@ -3876,6 +4146,7 @@ function parseGlossaryTerms(glossaryContent) {
3876
4146
  }
3877
4147
  return terms;
3878
4148
  }
4149
+
3879
4150
  // ../../packages/aeg-core/src/quoted-command.ts
3880
4151
  var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3881
4152
  var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
@@ -3970,6 +4241,54 @@ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3970
4241
  }
3971
4242
  return findings;
3972
4243
  }
4244
+ // ../../packages/aeg-core/src/dead-branch-push-guard.ts
4245
+ function checkDeadBranchPush(input) {
4246
+ const { branch, prState, prNumber } = input;
4247
+ if (prState === "MERGED") {
4248
+ return {
4249
+ verdict: "refuse",
4250
+ reason: `Branch \`${branch}\` already has a MERGED PR (#${prNumber}) — this branch's work is done. Push a new task branch instead of pushing onto an already-resolved one.`
4251
+ };
4252
+ }
4253
+ if (prState === "CLOSED") {
4254
+ return {
4255
+ verdict: "refuse",
4256
+ reason: `Branch \`${branch}\` has a CLOSED PR (#${prNumber}) that was never merged — pushing here would resurrect abandoned/rejected work. Open a new task branch instead.`
4257
+ };
4258
+ }
4259
+ if (prState === "OPEN") {
4260
+ return {
4261
+ verdict: "allow",
4262
+ reason: `Branch \`${branch}\` has an OPEN PR (#${prNumber}) — pushing more commits to it is normal.`
4263
+ };
4264
+ }
4265
+ if (prState === "NONE") {
4266
+ return {
4267
+ verdict: "allow",
4268
+ reason: `Branch \`${branch}\` has no PR yet — a brand-new task branch legitimately has none.`
4269
+ };
4270
+ }
4271
+ return {
4272
+ verdict: "allow",
4273
+ reason: `Could not determine \`${branch}\`'s PR state (forge unreachable) — failing open rather than blocking the push on a transient issue.`
4274
+ };
4275
+ }
4276
+ // ../../packages/aeg-core/src/baseline-capture.ts
4277
+ function captureBaseline(counts, capturedAt) {
4278
+ return counts.map((c) => ({ tool: c.tool, findingCount: c.findingCount, capturedAt }));
4279
+ }
4280
+ function compareToBaseline(current, baseline) {
4281
+ const perTool = current.map((c) => {
4282
+ const baselineEntry = baseline.find((b) => b.tool === c.tool);
4283
+ const baselineCount = baselineEntry ? baselineEntry.findingCount : c.findingCount;
4284
+ return { tool: c.tool, baseline: baselineCount, current: c.findingCount, delta: c.findingCount - baselineCount };
4285
+ });
4286
+ return {
4287
+ withinBudget: perTool.every((t) => t.delta <= 0),
4288
+ delta: perTool.reduce((sum, t) => sum + t.delta, 0),
4289
+ perTool
4290
+ };
4291
+ }
3973
4292
  // ../../packages/aeg-core/src/retired-vocabulary.ts
3974
4293
  var RETIRED_PATTERNS = [
3975
4294
  String.raw`\bD-[0-9]{3}\b`,
@@ -4439,8 +4758,225 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
4439
4758
  }
4440
4759
  return findings;
4441
4760
  }
4761
+ // ../../packages/aeg-core/src/log/schema.ts
4762
+ import { z } from "zod";
4763
+ var ROLE_VALUES = [
4764
+ "planner",
4765
+ "developer",
4766
+ "code-reviewer",
4767
+ "security",
4768
+ "principal",
4769
+ "archivist",
4770
+ "architect"
4771
+ ];
4772
+ var RoleSchema = z.enum(ROLE_VALUES);
4773
+ var HOST_VALUES = ["hook", "ci", "cli", "loop"];
4774
+ var HostSchema = z.enum(HOST_VALUES);
4775
+ var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
4776
+ var HeaderMetaSchema = z.object({
4777
+ schema: z.literal(1),
4778
+ ts: z.string(),
4779
+ run_id: z.string().regex(RUN_ID_PATTERN),
4780
+ seq: z.number().int().nonnegative(),
4781
+ repo: z.string().nullable(),
4782
+ vinaya: z.string(),
4783
+ doctrine: z.string(),
4784
+ host: HostSchema,
4785
+ machine: z.string()
4786
+ }).strict();
4787
+ var SubjectSchema = z.object({
4788
+ issue: z.number().int().nullable(),
4789
+ pr: z.number().int().optional(),
4790
+ sha: z.string().optional(),
4791
+ role: z.union([RoleSchema, z.literal("unattributed")]),
4792
+ round: z.number().int().optional(),
4793
+ objectives_version: z.string().optional()
4794
+ }).strict();
4795
+ var HeaderSchema = z.object({
4796
+ meta: HeaderMetaSchema,
4797
+ subject: SubjectSchema
4798
+ }).strict();
4799
+ var envelopeTail = {
4800
+ duration_ms: z.number().nonnegative().optional(),
4801
+ payload: z.object({}).strict()
4802
+ };
4803
+ var DispatchOutcomeSchema = z.discriminatedUnion("type", [
4804
+ z.object({ type: z.literal("pr_opened"), pr: z.number().int(), head: z.string() }).strict(),
4805
+ z.object({
4806
+ type: z.literal("round_pushed"),
4807
+ pr: z.number().int(),
4808
+ head: z.string(),
4809
+ comment_id: z.number().int()
4810
+ }).strict(),
4811
+ z.object({
4812
+ type: z.literal("verdict"),
4813
+ verdict: z.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
4814
+ head: z.string(),
4815
+ comment_id: z.number().int(),
4816
+ objectives: z.array(z.object({ id: z.string(), met: z.boolean() }).strict()),
4817
+ findings: z.array(z.object({ id: z.string(), severity: z.string(), state: z.string().optional() }).strict())
4818
+ }).strict(),
4819
+ z.object({
4820
+ type: z.literal("escalation"),
4821
+ class: z.enum(["authority", "strategy", "product"]),
4822
+ comment_id: z.number().int()
4823
+ }).strict(),
4824
+ z.object({ type: z.literal("brief"), comment_id: z.number().int(), hash: z.string() }).strict(),
4825
+ z.object({ type: z.literal("plan"), issues: z.array(z.number().int()) }).strict(),
4826
+ z.object({ type: z.literal("archive"), provenance_comment_id: z.number().int() }).strict()
4827
+ ]);
4828
+ var dispatchShared = {
4829
+ meta: HeaderMetaSchema,
4830
+ subject: SubjectSchema,
4831
+ kind: z.literal("dispatch"),
4832
+ ...envelopeTail,
4833
+ target_role: RoleSchema,
4834
+ model: z.string(),
4835
+ round: z.number().int().optional(),
4836
+ effect_id: z.string()
4837
+ };
4838
+ var dispatchUsageField = z.object({ input: z.number().nonnegative(), output: z.number().nonnegative() }).strict().nullable();
4839
+ var DispatchEventSchema = z.discriminatedUnion("event", [
4840
+ z.object({ ...dispatchShared, event: z.literal("dispatched"), prompt_hash: z.string() }).strict(),
4841
+ z.object({
4842
+ ...dispatchShared,
4843
+ event: z.literal("outcome_received"),
4844
+ outcome: DispatchOutcomeSchema,
4845
+ usage: dispatchUsageField
4846
+ }).strict(),
4847
+ z.object({
4848
+ ...dispatchShared,
4849
+ event: z.literal("dispatch_failed"),
4850
+ reason: z.enum(["timeout", "crash", "refused", "unattributed_write"]),
4851
+ usage: dispatchUsageField
4852
+ }).strict()
4853
+ ]);
4854
+ var loopShared = {
4855
+ meta: HeaderMetaSchema,
4856
+ subject: SubjectSchema,
4857
+ kind: z.literal("dev_review_loop"),
4858
+ ...envelopeTail,
4859
+ loop_id: z.string()
4860
+ };
4861
+ var DevReviewLoopEventSchema = z.discriminatedUnion("event", [
4862
+ z.object({
4863
+ ...loopShared,
4864
+ event: z.literal("loop_started"),
4865
+ task: z.number().int(),
4866
+ policy: z.object({
4867
+ max_rounds: z.number().int().nonnegative(),
4868
+ reviewers: z.array(RoleSchema),
4869
+ models: z.record(RoleSchema, z.string())
4870
+ }).strict()
4871
+ }).strict(),
4872
+ z.object({ ...loopShared, event: z.literal("round_started"), round: z.number().int(), base_head: z.string() }).strict(),
4873
+ z.object({
4874
+ ...loopShared,
4875
+ event: z.literal("gate_result_read"),
4876
+ round: z.number().int(),
4877
+ head: z.string(),
4878
+ green: z.boolean()
4879
+ }).strict(),
4880
+ z.object({
4881
+ ...loopShared,
4882
+ event: z.literal("verdicts_read"),
4883
+ round: z.number().int(),
4884
+ head: z.string(),
4885
+ all_approve: z.boolean(),
4886
+ blockers: z.number().int().nonnegative()
4887
+ }).strict(),
4888
+ z.object({
4889
+ ...loopShared,
4890
+ event: z.literal("findings_compared"),
4891
+ round: z.number().int(),
4892
+ open: z.array(z.string()),
4893
+ resolved: z.array(z.string()),
4894
+ new: z.array(z.string()),
4895
+ recurring: z.array(z.string())
4896
+ }).strict(),
4897
+ z.object({
4898
+ ...loopShared,
4899
+ event: z.literal("stop_condition_met"),
4900
+ round: z.number().int(),
4901
+ condition: z.enum([
4902
+ "green",
4903
+ "max_rounds",
4904
+ "no_progress",
4905
+ "escalated",
4906
+ "principal_stop",
4907
+ "confidence",
4908
+ "reappearance"
4909
+ ])
4910
+ }).strict(),
4911
+ z.object({
4912
+ ...loopShared,
4913
+ event: z.literal("paused"),
4914
+ round: z.number().int(),
4915
+ reason: z.enum(["escalation", "principal_item", "refreeze_needed"])
4916
+ }).strict(),
4917
+ z.object({
4918
+ ...loopShared,
4919
+ event: z.literal("resumed"),
4920
+ round: z.number().int(),
4921
+ by: z.literal("principal")
4922
+ }).strict(),
4923
+ z.object({
4924
+ ...loopShared,
4925
+ event: z.literal("round_ended"),
4926
+ round: z.number().int(),
4927
+ base_head: z.string(),
4928
+ head: z.string(),
4929
+ files_changed: z.number().int().nonnegative(),
4930
+ insertions: z.number().int().nonnegative(),
4931
+ deletions: z.number().int().nonnegative(),
4932
+ wall_ms: z.number().nonnegative(),
4933
+ outcome: z.enum(["green", "changes_requested", "escalated"])
4934
+ }).strict(),
4935
+ z.object({
4936
+ ...loopShared,
4937
+ event: z.literal("journal_finalized"),
4938
+ rounds: z.number().int().nonnegative(),
4939
+ total_wall_ms: z.number().nonnegative(),
4940
+ time_to_green_ms: z.number().nonnegative().nullable(),
4941
+ files_changed_total: z.number().int().nonnegative(),
4942
+ final_head: z.string(),
4943
+ result: z.enum(["merged_ready", "stopped"])
4944
+ }).strict()
4945
+ ]);
4946
+ var ForgeOpSchema = z.enum([
4947
+ "pr.create",
4948
+ "pr.comment",
4949
+ "pr.body.replace",
4950
+ "pr.refreeze",
4951
+ "issue.create",
4952
+ "issue.edit",
4953
+ "issue.comment",
4954
+ "milestone.create",
4955
+ "milestone.edit",
4956
+ "milestone.close",
4957
+ "label.add",
4958
+ "label.remove"
4959
+ ]);
4960
+ var ForgeWriteTargetSchema = z.object({
4961
+ issue: z.number().int().optional(),
4962
+ pr: z.number().int().optional()
4963
+ }).strict();
4964
+ var forgeWriteShared = {
4965
+ meta: HeaderMetaSchema,
4966
+ subject: SubjectSchema,
4967
+ kind: z.literal("forge_write"),
4968
+ ...envelopeTail,
4969
+ op: ForgeOpSchema,
4970
+ target: ForgeWriteTargetSchema
4971
+ };
4972
+ var ForgeWriteEventSchema = z.discriminatedUnion("event", [
4973
+ z.object({ ...forgeWriteShared, event: z.literal("validated") }).strict(),
4974
+ z.object({ ...forgeWriteShared, event: z.literal("refused"), reason: z.string() }).strict(),
4975
+ z.object({ ...forgeWriteShared, event: z.literal("written"), comment_ids: z.array(z.string()) }).strict()
4976
+ ]);
4977
+ var LogEventSchema = z.union([DispatchEventSchema, DevReviewLoopEventSchema, ForgeWriteEventSchema]);
4442
4978
  // src/lib/diff-evidence.ts
4443
- import { execFileSync as execFileSync3 } from "node:child_process";
4979
+ import { execFileSync as execFileSync4 } from "node:child_process";
4444
4980
  import { join as join2, relative, resolve as resolve2 } from "node:path";
4445
4981
 
4446
4982
  // src/lib/config.ts
@@ -4448,27 +4984,27 @@ import { execFileSync as execFileSync2 } from "node:child_process";
4448
4984
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
4449
4985
  import { homedir } from "node:os";
4450
4986
  import { dirname, join, resolve } from "node:path";
4451
- import { z } from "zod";
4987
+ import { z as z2 } from "zod";
4452
4988
 
4453
4989
  // src/lib/agent-vendors.ts
4454
4990
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
4455
4991
 
4456
4992
  // src/lib/config.ts
4457
- var EnvEntrySchema = z.union([
4458
- z.literal(true),
4459
- z.object({ optional: z.literal(true) }),
4460
- z.object({ anyOf: z.array(z.string()).min(2) }),
4461
- z.string()
4993
+ var EnvEntrySchema = z2.union([
4994
+ z2.literal(true),
4995
+ z2.object({ optional: z2.literal(true) }),
4996
+ z2.object({ anyOf: z2.array(z2.string()).min(2) }),
4997
+ z2.string()
4462
4998
  ]);
4463
- var CheckEntrySchema = z.object({
4464
- run: z.string(),
4465
- scope: z.enum(["diff", "full"]),
4466
- include: z.array(z.string()).optional(),
4467
- args: z.array(z.string()).optional(),
4468
- timeoutMs: z.number().optional(),
4469
- env: z.record(z.string(), EnvEntrySchema).optional(),
4470
- requiresOpenPr: z.boolean().optional(),
4471
- ownWorkflow: z.boolean().optional()
4999
+ var CheckEntrySchema = z2.object({
5000
+ run: z2.string(),
5001
+ scope: z2.enum(["diff", "full"]),
5002
+ include: z2.array(z2.string()).optional(),
5003
+ args: z2.array(z2.string()).optional(),
5004
+ timeoutMs: z2.number().optional(),
5005
+ env: z2.record(z2.string(), EnvEntrySchema).optional(),
5006
+ requiresOpenPr: z2.boolean().optional(),
5007
+ ownWorkflow: z2.boolean().optional()
4472
5008
  }).superRefine((entry2, ctx) => {
4473
5009
  if (!entry2.env)
4474
5010
  return;
@@ -4478,22 +5014,22 @@ var CheckEntrySchema = z.object({
4478
5014
  const members = value.anyOf;
4479
5015
  if (new Set(members).size !== members.length) {
4480
5016
  ctx.addIssue({
4481
- code: z.ZodIssueCode.custom,
5017
+ code: z2.ZodIssueCode.custom,
4482
5018
  message: `env.${key}.anyOf has duplicate members`,
4483
5019
  path: ["env", key, "anyOf"]
4484
5020
  });
4485
5021
  }
4486
5022
  if (!members.includes(key)) {
4487
5023
  ctx.addIssue({
4488
- code: z.ZodIssueCode.custom,
5024
+ code: z2.ZodIssueCode.custom,
4489
5025
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
4490
5026
  path: ["env", key, "anyOf"]
4491
5027
  });
4492
5028
  }
4493
5029
  }
4494
5030
  });
4495
- var RoleEntrySchema = z.object({
4496
- contract: z.string().refine((p) => p.includes("/"), {
5031
+ var RoleEntrySchema = z2.object({
5032
+ contract: z2.string().refine((p) => p.includes("/"), {
4497
5033
  message: 'must be a path (contain at least one "/"), not a bare filename'
4498
5034
  })
4499
5035
  });
@@ -4512,19 +5048,21 @@ var BRIEF_BUILTINS = [
4512
5048
  "closesN",
4513
5049
  "premiseCoverage",
4514
5050
  "issueRationale",
5051
+ "objectives",
5052
+ "briefSections",
4515
5053
  "milestoneShape"
4516
5054
  ];
4517
- var BriefSectionSchema = z.union([
4518
- z.object({ builtin: z.enum(BRIEF_BUILTINS) }),
4519
- z.object({ heading: z.string().min(1), name: z.string().optional() }),
4520
- z.object({ field: z.string().min(1), name: z.string().optional() }),
4521
- z.object({ phrase: z.string().min(1), name: z.string().optional() })
5055
+ var BriefSectionSchema = z2.union([
5056
+ z2.object({ builtin: z2.enum(BRIEF_BUILTINS) }),
5057
+ z2.object({ heading: z2.string().min(1), name: z2.string().optional() }),
5058
+ z2.object({ field: z2.string().min(1), name: z2.string().optional() }),
5059
+ z2.object({ phrase: z2.string().min(1), name: z2.string().optional() })
4522
5060
  ]);
4523
- var BriefSchemaSchema = z.object({
4524
- pr: z.object({ sections: z.array(BriefSectionSchema) }).optional(),
4525
- issue: z.object({ sections: z.array(BriefSectionSchema) }).optional(),
4526
- milestone: z.object({ sections: z.array(BriefSectionSchema) }).optional(),
4527
- ack: z.array(z.enum(BRIEF_BUILTINS)).optional()
5061
+ var BriefSchemaSchema = z2.object({
5062
+ pr: z2.object({ sections: z2.array(BriefSectionSchema) }).optional(),
5063
+ issue: z2.object({ sections: z2.array(BriefSectionSchema) }).optional(),
5064
+ milestone: z2.object({ sections: z2.array(BriefSectionSchema) }).optional(),
5065
+ ack: z2.array(z2.enum(BRIEF_BUILTINS)).optional()
4528
5066
  });
4529
5067
  function isSafeRepoRelPath(p) {
4530
5068
  if (p.length === 0)
@@ -4533,7 +5071,7 @@ function isSafeRepoRelPath(p) {
4533
5071
  return false;
4534
5072
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
4535
5073
  }
4536
- var SafeRepoRelPath = z.string().refine(isSafeRepoRelPath, {
5074
+ var SafeRepoRelPath = z2.string().refine(isSafeRepoRelPath, {
4537
5075
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
4538
5076
  });
4539
5077
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -4543,22 +5081,22 @@ function isCanonicalHookBlockPath(p) {
4543
5081
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
4544
5082
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
4545
5083
  });
4546
- var ManagedBlockRecordSchema = z.object({
5084
+ var ManagedBlockRecordSchema = z2.object({
4547
5085
  path: ManagedHookBlockPath,
4548
- marker: z.string(),
4549
- comment: z.enum(["hash", "html"])
5086
+ marker: z2.string(),
5087
+ comment: z2.enum(["hash", "html"])
4550
5088
  });
4551
- var ManagedManifestSchema = z.object({
4552
- version: z.number().int().positive(),
4553
- files: z.array(SafeRepoRelPath),
4554
- blocks: z.array(ManagedBlockRecordSchema),
4555
- labels: z.array(z.string()),
4556
- agents: z.array(z.enum(AGENT_VENDORS)).optional()
5089
+ var ManagedManifestSchema = z2.object({
5090
+ version: z2.number().int().positive(),
5091
+ files: z2.array(SafeRepoRelPath),
5092
+ blocks: z2.array(ManagedBlockRecordSchema),
5093
+ labels: z2.array(z2.string()),
5094
+ agents: z2.array(z2.enum(AGENT_VENDORS)).optional()
4557
5095
  });
4558
- var ProjectEntrySchema = z.object({
4559
- name: z.string().min(1),
4560
- description: z.string().min(1).optional(),
4561
- path: z.string().min(1).optional()
5096
+ var ProjectEntrySchema = z2.object({
5097
+ name: z2.string().min(1),
5098
+ description: z2.string().min(1).optional(),
5099
+ path: z2.string().min(1).optional()
4562
5100
  });
4563
5101
  function parseTokensCollectDeclaration(value) {
4564
5102
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -4569,31 +5107,35 @@ function parseTokensCollectDeclaration(value) {
4569
5107
  return null;
4570
5108
  return { interpreter, script };
4571
5109
  }
4572
- var VinayaConfigSchema = z.object({
4573
- rings: z.object({
4574
- ring1_forgeWriteInterception: z.boolean(),
4575
- ring2_asyncAudits: z.boolean()
5110
+ var VinayaConfigSchema = z2.object({
5111
+ rings: z2.object({
5112
+ ring1_forgeWriteInterception: z2.boolean(),
5113
+ ring2_asyncAudits: z2.boolean()
4576
5114
  }).optional(),
4577
- checks: z.record(z.string(), CheckEntrySchema).optional(),
4578
- roles: z.record(z.string(), RoleEntrySchema).optional(),
5115
+ checks: z2.record(z2.string(), CheckEntrySchema).optional(),
5116
+ roles: z2.record(z2.string(), RoleEntrySchema).optional(),
4579
5117
  briefSchema: BriefSchemaSchema.optional(),
4580
5118
  managed: ManagedManifestSchema.optional(),
4581
- principals: z.array(z.string()).min(1).optional(),
4582
- releaseActor: z.string().min(1).optional(),
4583
- ci: z.object({ setup: z.string().min(1) }).optional(),
4584
- tokens: z.object({
4585
- collect: z.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
5119
+ principals: z2.array(z2.string()).min(1).optional(),
5120
+ releaseActor: z2.string().min(1).optional(),
5121
+ ci: z2.object({ setup: z2.string().min(1) }).optional(),
5122
+ tokens: z2.object({
5123
+ collect: z2.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
4586
5124
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
4587
5125
  })
4588
5126
  }).optional(),
4589
- blastRadius: z.object({ extraDomains: z.array(z.string()).optional() }).optional(),
4590
- proseGates: z.object({
4591
- doctrineRoot: z.string().min(1).optional(),
4592
- readerFacingPrefix: z.string().min(1).optional(),
4593
- readerFacingSuffix: z.string().min(1).optional(),
4594
- legacySlugDir: z.string().min(1).optional()
5127
+ blastRadius: z2.object({ extraDomains: z2.array(z2.string()).optional() }).optional(),
5128
+ proseGates: z2.object({
5129
+ doctrineRoot: z2.string().min(1).optional(),
5130
+ readerFacingPrefix: z2.string().min(1).optional(),
5131
+ readerFacingSuffix: z2.string().min(1).optional(),
5132
+ legacySlugDir: z2.string().min(1).optional()
4595
5133
  }).optional(),
4596
- projects: z.array(ProjectEntrySchema).optional()
5134
+ projects: z2.array(ProjectEntrySchema).optional(),
5135
+ dispatch: z2.object({
5136
+ timeoutMs: z2.number().int().positive().optional(),
5137
+ agent: z2.enum(["claude", "codex", "gemini"]).optional()
5138
+ }).optional()
4597
5139
  });
4598
5140
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
4599
5141
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -4746,6 +5288,760 @@ function loadConfig() {
4746
5288
  }
4747
5289
  var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
4748
5290
 
5291
+ // ../../packages/sources/src/commands.ts
5292
+ var COMMANDS = [
5293
+ {
5294
+ name: "help",
5295
+ description: "Show this help text",
5296
+ status: "shipped"
5297
+ },
5298
+ {
5299
+ name: "version",
5300
+ description: "Print the CLI version",
5301
+ flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }],
5302
+ status: "shipped"
5303
+ },
5304
+ {
5305
+ name: "init",
5306
+ description: "Install Vinaya's git hooks, CI workflow, and starter config (diff-and-confirm, non-destructive)",
5307
+ flags: [
5308
+ { flag: "--dry-run", description: "Print the full diff without installing anything" },
5309
+ { flag: "--yes", description: "Skip the confirmation prompt" }
5310
+ ],
5311
+ details: [
5312
+ "It detects your repo, prints the complete diff of every intended change, and waits for your confirmation before installing anything. `--dry-run` prints that same diff and installs nothing. Nothing ever runs automatically on package install.",
5313
+ "It installs one CI workflow that runs `vinaya check --all --diff-only`, alongside your existing workflows — refusing to overwrite rather than touching foreign content already at that path. Git hook stubs invoke the `vinaya` binary directly; if a hook already exists, it appends a delimited managed block, shown verbatim in the diff first, rather than overwriting it.",
5314
+ "`vinaya.config.json` is seeded with a starter ruleset extracted from Vinaya's own battle-tested gates, not invented defaults. Issue and PR templates carrying the brief schema are added alongside your own; tier and `needs:*-input` labels are created only if they don't already exist — your existing labels are never modified.",
5315
+ "Two empty folders — `vinaya/checks/` and `vinaya/roles/` — are scaffolded alongside the config, each held open by a placeholder file (git does not track empty directories). `vinaya new noop-check` and `vinaya new role` write their real output into these folders later; both placeholders are recorded in the ownership manifest, so `eject` removes them exactly like everything else `init` created.",
5316
+ "The generated workflows reach the `vinaya` binary through `npx @attalabs/vinaya`, with no build step — unless your repo vendors the CLI itself (a workspace member declaring the name `@attalabs/vinaya`), in which case `npx` would resolve to that unbuilt local member instead of the registry. `init` detects that at generation time and writes workflows that build and run your own copy by path instead, so your CI exercises the code in the pull request. `upgrade` and `doctor` make the same determination, so regenerating is stable.",
5317
+ "The recommended branch-protection command is printed for you to run yourself — it is never applied, and your PATH is never touched. `eject` removes exactly the managed block it owns, or a whole file only if `init` created it."
5318
+ ],
5319
+ status: "shipped"
5320
+ },
5321
+ {
5322
+ name: "init product",
5323
+ description: "Register a project in .vinaya/projects.md in an already-initialized repo",
5324
+ flags: [
5325
+ {
5326
+ flag: "--path <path>",
5327
+ description: "The project's home folder — declared, not derived. Defaults to the repo root."
5328
+ }
5329
+ ],
5330
+ details: [
5331
+ "Writes (or appends to) `.vinaya/projects.md` — the registry Vinaya Studio's tranche board resolves a project's board link against. Idempotent: re-running with the same name updates nothing.",
5332
+ "Reaches no forge and needs no GitHub remote or credentials: the registry row is a pure local file write, and it is deliberately NOT recorded in the ownership manifest, so `eject` does not reverse adopter-declared data.",
5333
+ "Creates no label. Project is a field, not a label: a task Issue declares its project in the body's `**Project:**` field, and a `project:*` label is ignored wherever one still exists."
5334
+ ],
5335
+ status: "shipped"
5336
+ },
5337
+ {
5338
+ name: "check",
5339
+ description: "Run one check, or every registered check",
5340
+ flags: [
5341
+ { flag: "--all", description: "Run every registered check instead of one named check" },
5342
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" },
5343
+ { flag: "--diff-only", description: "Scope diff-declared checks to changed files" },
5344
+ {
5345
+ flag: "--local",
5346
+ description: "Skip every requiresOpenPr check (closes-n, test-plan) — set by the generated hooks, never by CI"
5347
+ },
5348
+ { flag: "--parallel[=n]", description: "Concurrency cap (default: cpu-derived)" },
5349
+ {
5350
+ flag: "--plan",
5351
+ description: "Print the resolved check registry and the resolved `roles` registry (default/overridden/additive) without running anything"
5352
+ }
5353
+ ],
5354
+ details: [
5355
+ "Each spawned check's child process sees only a fixed baseline (`PATH`, `LANG`, `HOME`, `HTTPS_PROXY`, `HTTP_PROXY`, `NO_PROXY`, `TMPDIR`) plus whatever its `CheckSpec['env']` declaration explicitly forwards — never the full parent environment. A required (`true`) or unsatisfied `anyOf` declaration missing from the caller's environment synthesizes a `CheckError` before the check ever spawns. Declare `env` (a core check's own registration, or `vinaya.config.json`'s `checks.<name>.env` for a custom one) for any check that reads `process.env`/`Bun.env`/`Deno.env` directly — `vinaya doctor` carries the permanent diagnostic for one that doesn't.",
5356
+ "The resolved registry IS what runs. A `checks` key that exactly matches a core check id REPLACES that core check (the core one does not run); any other key must be namespaced `<yourname>/<id>`. Anything the resolver cannot classify — a malformed entry, a bare un-namespaced key matching no core id, a duplicate id — makes `vinaya check` refuse the ENTIRE run: exit 1, nothing executes, never a partial ruleset and never a core-only fallback. `vinaya doctor` carries the permanent diagnostic for each rejected entry, so a refused config is still diagnosable.",
5357
+ "`--plan` composes with `--json`. It requires zero env vars and never prints an env value — only how each one resolves (passthrough, optional, literal, or anyOf). A `FAIL_CLOSED` entry always renders inline rather than being dropped, and exits non-zero. `--plan` and execution read the same resolution, so what the plan prints is what runs.",
5358
+ "`--local` exists because a `requiresOpenPr` check (the core `closes-n`/`test-plan`, or a custom check declaring the same field) can only evaluate for real once a pull request exists — the generated `pre-commit`/`pre-push` hooks pass it so the first commit on a fresh task branch is never asked to satisfy a PR-body field before a PR can possibly exist. CI's `vinaya-checks.yml` omits it, so these checks always run for real once a PR is open.",
5359
+ "`--plan`'s `roles` half resolves `vinaya.config.json`'s `roles` block against bundled doctrine — same override/additive shape as `checks`, with its own RENDERS AS column (the registry key and the role's own `role_id` differ for an additive entry) and a GATING column (`core` vs. `inert` — an additive role carries no core `ACTIONS` wiring). `roles.available` is `false` only when no bundled doctrine can be found next to this CLI install."
5360
+ ],
5361
+ status: "shipped"
5362
+ },
5363
+ {
5364
+ name: "commit-msg",
5365
+ description: "The generated `commit-msg` hook's invocation target — validates a commit message's first line",
5366
+ details: [
5367
+ "Not meant to be run by hand day-to-day: the managed `commit-msg` hook calls `vinaya commit-msg <message-file> [source]` with the two arguments git itself passes a commit-msg hook (githooks(5)) — the message file path and, when known, the commit's source keyword.",
5368
+ "Validates the message file's first line against the same `Type(scope): Description` vocabulary `check`'s `forge-title`-shaped gates enforce on PR/Issue titles (`@attalabs/aeg-core`'s `COMMIT_TYPES` — the commitlint type set plus `Plan`). Exits 0 with no output on a conforming message; a `source` of `merge` is skipped outright, since a merge commit's message is written by git, not the person committing."
5369
+ ],
5370
+ status: "shipped"
5371
+ },
5372
+ {
5373
+ name: "new check",
5374
+ description: "Scaffold a custom check into ./scripts/vinaya-checks/",
5375
+ details: [
5376
+ "Takes the REGISTRATION KEY, not a bare name: `vinaya new check <yourname>/<id>` writes `./scripts/vinaya-checks/<id>.ts` and prints the namespaced `checks` entry to paste. It refuses a bare, un-namespaced name — `vinaya check` refuses its entire run over a key it cannot resolve, so scaffolding one would brick every check invocation in the repo — and refuses a core check id, since registering one REPLACES that core gate and a scaffolded stub is never what an adopter means by that."
5377
+ ],
5378
+ status: "shipped"
5379
+ },
5380
+ {
5381
+ name: "new noop-check",
5382
+ description: "Scaffold an explicit no-op into vinaya/checks/ that silences a core check",
5383
+ details: [
5384
+ "Takes a CORE check id — the opposite of what `new check` accepts, which refuses one. `vinaya new noop-check <core-check-id>` writes `vinaya/checks/<id>.ts`, an explicit, contract-satisfying no-op (always exits `0`, emits no findings, carries a comment marking the silencing as intentional) and prints the `checks` entry that REPLACES the named core check with it. This is the only sanctioned way to silence a core check."
5385
+ ],
5386
+ status: "shipped"
5387
+ },
5388
+ {
5389
+ name: "new role",
5390
+ description: "Scaffold an additive role contract into vinaya/roles/",
5391
+ details: [
5392
+ 'Takes the REGISTRATION KEY: `vinaya new role <yourname>/<id>` writes `vinaya/roles/<id>.md` — a structurally-valid role contract stub (the six frontmatter keys plus `title`/`order`, and a non-empty "## The short version" section) whose own `role_id` is set to `<id>` — and prints the `roles` entry to paste. It refuses a bare, un-namespaced key: that shape resolves as an OVERRIDE of a core role, a complete replacement of that role\'s contract and a real governance decision this scaffolder does not make for you.'
5393
+ ],
5394
+ status: "shipped"
5395
+ },
5396
+ {
5397
+ name: "brief render",
5398
+ description: "Emit the twelve-section brief skeleton from the forge and the tree, every derivable section filled",
5399
+ flags: [
5400
+ { flag: "--surfaces <glob1,glob2,...>", description: "Intended surface globs, expanded against tracked files" },
5401
+ { flag: "--out <path>", description: "Write the rendered brief to a file instead of stdout" }
5402
+ ],
5403
+ details: [
5404
+ "Reads the task Issue (`vinaya/tranche:<tranche>`-labeled, id `<n>`) and the tree, and fills every section a program can derive: the header `Project:`/`Tier:`/`Closes #N`, the Step 0 worktree line, the dispatch-gate status as the pre-flight line, §4's file list (with consumer packages and a `sha256` premise pin per file, and Out of surface from the Issue's own `## Surface` `out:` list), §6 from the Issue's `## Parts`, §7 from the `.vinaya/doc-owners` derivation, §9 from the Issue's `## Test plan`, §10 from the Issue's `## Stop conditions` plus the rationale's Stop-and-escalate field, and every remaining section from the Issue's eight-field Planner rationale. Refuses — naming the missing section — when it cannot be derived: no Issue, the dispatch gate not clear, a `--surfaces` glob matching no tracked file, or the Issue missing/malformed `## Surface`/`## Parts`/`## Test plan`/`## Stop conditions` — never a bracketed placeholder.",
5405
+ "Never writes under `aeg-root/` or to the Issue — a brief is pasted to the Developer, never committed. Reads `aeg-root/templates/brief-template.md` at run time for its one fixed sentence and the standing autonomy clause; every other byte is generated from the forge/tree facts."
5406
+ ],
5407
+ status: "shipped"
5408
+ },
5409
+ {
5410
+ name: "task dispatch",
5411
+ description: "Render, pin, and post the brief on the Issue as the frozen original; start the developer",
5412
+ flags: [
5413
+ { flag: "--agent <claude|codex|gemini>", description: "Start the developer through dispatchRole once posted" }
5414
+ ],
5415
+ details: [
5416
+ "Renders the brief from the Issue and the tree (the same assembly `brief render` uses) and posts it once as an Issue comment whose first line is `<!-- aeg:brief:v1 -->` and whose second line is `Brief hash: <sha256>` — the hash covers only the body below those two lines, so any reader recomputes it. Refuses outright, naming the existing comment's URL, when a `v1` comment already exists on the Issue — the brief is frozen by design, never overwritten or silently reissued.",
5417
+ "With `--agent`, starts the Developer through `dispatchRole` when `apps/cli/src/lib/dispatch.ts` exports it; otherwise prints the rendered brief and the manual dispatch instruction and exits `0` — a soft dependency, never a hard block.",
5418
+ "Principal-only, with or without `--agent`: refuses before any render, forge read, or post when the authenticated `gh` identity is not on the Principal allowlist (or cannot be resolved at all) — dispatching is the `todo → in-flight` transition, not a general-purpose comment poster."
5419
+ ],
5420
+ status: "shipped"
5421
+ },
5422
+ {
5423
+ name: "pr create",
5424
+ description: "Open a pull request after full brief-schema validation",
5425
+ flags: [
5426
+ { flag: "--title", description: "PR title (validated against the forge-title grammar)" },
5427
+ { flag: "--body-file", description: "Path to the PR body (stream-safe; the same bytes are validated and sent)" },
5428
+ { flag: "--label", description: "Label(s) to apply (repeatable, comma-separated)" },
5429
+ { flag: "--validate-only", description: "Run every gate and report PASS without opening the PR" },
5430
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5431
+ ],
5432
+ details: [
5433
+ "Runs the config-defined brief-schema gate (`briefSchema.pr` in `vinaya.config.json`) LOCALLY before any `gh` write — prevention, not detection. On any failure it refuses with the versioned CheckError contract (one JSON line per finding on stderr, exit 1) whose `agent_recovery_prompt` names the exact corrective command.",
5434
+ "Which sections bind depends on the branch, matching the `brief-shape` check that runs the same grammar in CI. On a `task/<tranche>/<n>` branch every configured section binds, `closesN` included. On any other branch a body that is not brief-shaped is exempt entirely — an ordinary one-line dependency bump is not made to grow a brief — while a brief-shaped body is still graded on every other section, since a standalone fix brief is a brief; only `closesN` is dropped, because such a branch has no task Issue to close. The title grammar sits outside all of this and binds on every branch.",
5435
+ "A branch counts as resolvable only when HEAD is a symbolic ref that also resolves to a commit. Neither git query answers that alone: `rev-parse --abbrev-ref HEAD` reports the literal string `HEAD` on a detached HEAD, and `symbolic-ref` reports the not-yet-created branch name when HEAD is unborn. Reading either as an ordinary branch would take the relaxed path, so both states — plus running outside a repo — resolve to nothing and the gate is fail-closed: every configured section is enforced."
5436
+ ],
5437
+ status: "shipped"
5438
+ },
5439
+ {
5440
+ name: "pr edit",
5441
+ description: "Edit an existing pull request (<n>) after full brief-schema validation",
5442
+ flags: [
5443
+ { flag: "--title", description: "New PR title (validated against the forge-title grammar)" },
5444
+ { flag: "--body-file", description: "Path to the new PR body (stream-safe; same bytes validated and sent)" },
5445
+ { flag: "--validate-only", description: "Run every gate and report PASS without editing the PR" },
5446
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5447
+ ],
5448
+ details: [
5449
+ "The target PR's real head branch and changed files are fetched from the forge to build the validation context — a failed fetch is a hard refusal, never a fall-back to the local checkout.",
5450
+ "That fetched head branch is what selects the section set, by the same branch grammar `pr create` uses — a property of the target PR, never of whatever the local checkout happens to have checked out."
5451
+ ],
5452
+ status: "shipped"
5453
+ },
5454
+ {
5455
+ name: "pr report",
5456
+ description: "Emit the AEG:EVIDENCE block — a PR body's factual claims, from commands, never typed",
5457
+ flags: [
5458
+ {
5459
+ flag: "--write",
5460
+ description: "Path to the PR body file; replaces the content between the AEG:EVIDENCE anchors in place"
5461
+ },
5462
+ {
5463
+ flag: "--push",
5464
+ description: "PR number; splices the same content into that PR's LIVE body (fetched from the forge) and pushes it via `gh pr edit`, self-verifying nothing outside the AEG:EVIDENCE/AEG:TOKENS regions changed. Mutually exclusive with --write."
5465
+ }
5466
+ ],
5467
+ details: [
5468
+ "Two groups: Group A (recomputable) is the head sha and a width-invariant `git diff --numstat` against the merge-base with `BASE_SHA` (else `origin/main`, then `main`) — `check-evidence-fresh` recomputes and byte-compares this exactly. Group B (attested) is the result of `vinaya check --all --diff-only`, this CLI's own portable gate suite — `check-evidence-fresh` can only check it for staleness (the block's recorded head still matches the PR's real head), never re-run it.",
5469
+ "With no `--write`/`--push`, prints the block to stdout instead of writing a file. Exits non-zero whenever the gate run failed, whether or not `--write`/`--push` was given — the block records a failing result rather than hiding one, and a non-zero exit stops a scripted `--write && open-pr` (or `--push`) from carrying a failing suite onto the forge.",
5470
+ "`--push` refuses before writing anything when the live body carries no real `AEG:EVIDENCE` pair (it never appends one, unlike `--write`), when the anchor resolves differently before and after normalisation, or when `<pr>` isn't a bare number. When the live body has no real `AEG:TOKENS` pair, the token splice is skipped (same reasoning, softer outcome) rather than creating one. After pushing, it re-reads the live body and restores the pre-edit body — exiting non-zero — if anything outside the two anchored regions changed."
5471
+ ],
5472
+ status: "shipped"
5473
+ },
5474
+ {
5475
+ name: "pr rule",
5476
+ description: "Post a Principal ruling on a PR, marked and versioned — never mistaken for a review verdict",
5477
+ flags: [
5478
+ { flag: "--file", description: "Path to the ruling file to post as a PR comment" },
5479
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5480
+ ],
5481
+ details: [
5482
+ "Refuses before posting when the file's first line reads as an escalation (`ESCALATE:`), or when the file carries verdict grammar anywhere `extractCodeReviewVerdict`/`extractSecurityReviewVerdict` would treat as a candidate — a `VERDICT:` line past the extractor's own first-five-line window still counts, since the whole-body candidate test is what disqualifies the file, not merely a clean read.",
5483
+ "Marker numbers (`<!-- aeg:principal:ruling:<pr>-<k> -->`) are counted on the forge at post time from `gh pr view --json comments`, never derived from a local file — two rulings racing to the same number are a known, undocumented-lock case."
5484
+ ],
5485
+ status: "shipped"
5486
+ },
5487
+ {
5488
+ name: "pr verify-evidence",
5489
+ description: "Prove a pull request's AEG:EVIDENCE region was machine-generated — regenerate it and compare",
5490
+ flags: [],
5491
+ details: [
5492
+ "Deliberately a command, not a check: `evidence-fresh` runs inside `vinaya check --all`, and `pr report` runs `vinaya check --all --diff-only`, so a check that regenerated the block would run the suite containing itself. That recursion is why `evidence-fresh` verifies Group A only and leaves Group B attested.",
5493
+ "Must be run from the repository ROOT of a CLEAN checkout at the pull request's head, and refuses otherwise. The regeneration inherits the working directory and several gates resolve their scan root from it, so a subdirectory silently narrows what the fresh run inspects. On cleanliness: Group B is regenerated by diff-scoped checks, so uncommitted or untracked files change which files are scanned and can produce a MATCH a clean checkout would not. Ignored paths are deliberately NOT inspected — `git diff` never reports one, so they cannot change the scope, and including them would refuse in every real checkout since `node_modules` is ignored and always present. The head is read from the forge and both a mismatch AND an unreadable head refuse — the verdict is bound to a commit, never merely attested. `BASE_SHA` is refused as well, since it steers the regeneration's merge-base.",
5494
+ "Exits 0 on MATCH; 1 on DIFFERS, HIDDEN, or no block; 2 on a refusal (dirty worktree, wrong head, usage error). HIDDEN means the anchor pair sits inside a collapsed `<details>` block, where `body-bare-digits` blanks every digit and nothing can verify what it claims.",
5495
+ "Comparison is a multiset of repo-relative, control-stripped lines: absolute paths (local AND foreign, so a block generated in CI compares against one generated on a laptop) and line order are ignored — a reorder is not a fabrication. Only the AEG:EVIDENCE region is read, since AEG:TOKENS appends by design. A moved merge-base is reported ALONGSIDE the differing lines, never instead of them."
5496
+ ],
5497
+ status: "shipped"
5498
+ },
5499
+ {
5500
+ name: "issue create",
5501
+ description: "Open an issue after full brief-schema validation",
5502
+ flags: [
5503
+ { flag: "--title", description: "Issue title (validated on task Issues)" },
5504
+ { flag: "--body-file", description: "Path to the Issue body (stream-safe; same bytes validated and sent)" },
5505
+ { flag: "--label", description: "Label(s) to apply; a `vinaya/tranche:*` label marks a task Issue" },
5506
+ { flag: "--validate-only", description: "Run every gate and report PASS without opening the Issue" },
5507
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5508
+ ],
5509
+ details: [
5510
+ "A task Issue (any `vinaya/tranche:*` label) must carry the full Planner rationale (`briefSchema.issue`); non-task Issues pass through unvalidated."
5511
+ ],
5512
+ status: "shipped"
5513
+ },
5514
+ {
5515
+ name: "issue edit",
5516
+ description: "Edit an existing issue (<n>) after full brief-schema validation",
5517
+ flags: [
5518
+ { flag: "--title", description: "New Issue title (validated on task Issues)" },
5519
+ { flag: "--body-file", description: "Path to the new Issue body (stream-safe; same bytes validated and sent)" },
5520
+ { flag: "--validate-only", description: "Run every gate and report PASS without editing the Issue" },
5521
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5522
+ ],
5523
+ details: [
5524
+ "The target Issue's actual labels are fetched from the forge and unioned with argv to decide task-Issue applicability — a failed fetch is a hard refusal."
5525
+ ],
5526
+ status: "shipped"
5527
+ },
5528
+ {
5529
+ name: "issue objectives edit",
5530
+ description: "Rewrite a task Issue's `## Objectives` section by command — versioned, findable on the forge",
5531
+ flags: [
5532
+ { flag: "--add", description: "Append a new objective as `O<max+1>` with the given sentence" },
5533
+ { flag: "--drop", description: "Remove an objective by id (`O<k>`) — never renumbers the survivors" },
5534
+ {
5535
+ flag: "--replace",
5536
+ description: 'Replace an objective\'s sentence in place, keeping its id (`O<k>` "<sentence>")'
5537
+ },
5538
+ { flag: "--reason", description: "Required, non-empty: why this change is being made" },
5539
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5540
+ ],
5541
+ details: [
5542
+ "Exactly one of `--add`/`--drop`/`--replace` is required. Every edit goes through the same validated `issue edit` write path (`writeValidatedIssueEdit`) as `vinaya issue edit` itself — no second, unvalidated write path.",
5543
+ "A `--drop` that leaves the surviving objectives non-contiguous from `O1` is refused with `objectivesOf`'s own parser message: dropping never renumbers survivors, and task 1's contiguous-from-O1 grammar is the one parser everything else reads, so a live contradiction between the two stops here for a Principal ruling rather than silently renumbering.",
5544
+ "Splices the rendered section back in place (`## Objectives` heading through the next `##` heading, or end of body) — every other byte of the Issue body is untouched. Posts one comment marked `<!-- aeg:objectives:v<k> -->` carrying the previous list, the new list, the reason, and the new `objectivesVersion`; `k` is counted on the forge at post time, never derived from a local file."
5545
+ ],
5546
+ status: "shipped"
5547
+ },
5548
+ {
5549
+ name: "log flush",
5550
+ description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
5551
+ flags: [
5552
+ { flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
5553
+ {
5554
+ flag: "--pr",
5555
+ description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
5556
+ },
5557
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5558
+ ],
5559
+ details: [
5560
+ "Exactly one of `--issue`/`--pr` is required. `--pr` resolves the Issue from the PR body's `Closes #N` line — the same anchor every gate reads — and refuses with a check error naming the missing line when the body carries none.",
5561
+ "Splits the outbox first at `run_id` boundaries (a maximal run of consecutive lines sharing one `run_id`, never a global group-by, so an interleaved outbox never produces a range spanning a gap), then at `FORGE_COMMENT_MAX_CHARS` (65536) within each run. Each comment opens with `<!-- aeg:log:<run_id>:<seq_from>-<seq_to> -->` on its own line, then one fenced `ndjson` block, one outbox line per line, verbatim. A single line too large to fit alone is refused by name, never split across two comments.",
5562
+ "Logs its own `forge_write` line — `validated` before posting, `written` (with every returned comment id) after the last post succeeds, or `refused` (with gh's error) on any failure — through the same `log()` every other family uses, into the same outbox, before truncating. The outbox is truncated only to the lines confirmed posted; a failed chunk's lines, and anything appended to the outbox during the flush (including the flush's own `validated`/`written`/`refused` line), always survive to ride the next flush."
5563
+ ],
5564
+ status: "shipped"
5565
+ },
5566
+ {
5567
+ name: "milestone create",
5568
+ description: "Create a GitHub Milestone from a validated body",
5569
+ flags: [
5570
+ { flag: "--title", description: "Milestone title — free text, never parsed for a version" },
5571
+ {
5572
+ flag: "--body-file",
5573
+ description: "Path to the Milestone description (stream-safe; same bytes validated and sent)"
5574
+ },
5575
+ { flag: "--validate-only", description: "Run every gate and report PASS without creating the Milestone" },
5576
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5577
+ ],
5578
+ details: [
5579
+ "Refuses before any `gh` call when the goal is absent, an optional `Release:` field is present but not a version, or an optional `### Tranche intents` section (`- <slug>: <intent text>`) doesn't parse. `Release:` is the sole authority for the milestone's version — the title is never parsed for one."
5580
+ ],
5581
+ status: "shipped"
5582
+ },
5583
+ {
5584
+ name: "milestone adopt",
5585
+ description: "Move one or more existing tranches into a target Milestone",
5586
+ flags: [
5587
+ { flag: "--target", description: "The Milestone every named slug is adopted into" },
5588
+ { flag: "--slug", description: "A tranche slug to adopt — repeatable for a multi-slug move" },
5589
+ { flag: "--validate-only", description: "Run every gate and report PASS without writing anything" },
5590
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5591
+ ],
5592
+ details: [
5593
+ "Reattaches every Issue carrying each named `vinaya/tranche:<slug>` label to `--target`, then closes (never deletes) each slug's old tranche-Milestone. Every fact for every named slug is gathered and checked in ONE call before any write, so a single unsafe slug — an unknown slug, a slug whose label carries no Issues, a target that does not exist or is closed, or a slug already adopted into a different Milestone — refuses the whole invocation, not just its own slug."
5594
+ ],
5595
+ status: "shipped"
5596
+ },
5597
+ {
5598
+ name: "milestone edit",
5599
+ description: "Edit an existing Milestone (<n>) after full brief-schema validation",
5600
+ flags: [
5601
+ {
5602
+ flag: "--body-file",
5603
+ description: "Path to the new Milestone description (stream-safe; same bytes validated and sent)"
5604
+ },
5605
+ { flag: "--validate-only", description: "Run every gate and report PASS without editing the Milestone" },
5606
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5607
+ ],
5608
+ details: [
5609
+ "Same `checkMilestoneShape` refusal `create` runs, before any `gh` call — the gated replacement for a raw `gh api PATCH` against a Milestone. Only the description changes; the title is untouched."
5610
+ ],
5611
+ status: "shipped"
5612
+ },
5613
+ {
5614
+ name: "milestone close",
5615
+ description: "Close a tranche's Milestone after verifying every labeled Issue is actually attached",
5616
+ flags: [
5617
+ { flag: "--slug", description: "The tranche whose Milestone is being closed" },
5618
+ { flag: "--validate-only", description: "Run every gate and report PASS without closing the Milestone" },
5619
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5620
+ ],
5621
+ details: [
5622
+ "Resolves the target Milestone the same legacy-or-intent-declared way Issue create auto-attach does, then refuses to close on any mismatch between the label's Issues and the Milestone's natively attached Issues — naming each unattached or foreign Issue and its repair path (`gh issue edit <n> --milestone <title>`, or `vinaya milestone adopt`) — before the PATCH ever reaches the forge."
5623
+ ],
5624
+ status: "shipped"
5625
+ },
5626
+ {
5627
+ name: "review status",
5628
+ description: "Print the review loop's own state for a PR, and its branch's distance from the base",
5629
+ details: [
5630
+ "Two lines at most. The first is `CONTINUE`, `PAUSE: <reason>[ <id>]` for `reappearance`, `zero-deaths` or `max-rounds` — or, for `stale`, the actionable fact itself: `push after verdict — re-review required`. The second reads `behind main by <n> — merge first` when the branch is behind its base, or `behind main: unknown — fetch origin/<base> first` when git cannot measure the distance; it is absent only when the branch is measurably not behind.",
5631
+ "Rounds are derived from the PR's own verdict comments — one round per `Judged head:` value, read through the same extractors the merge gate blocks on, and only from comments an allowlisted principal authored. A Developer round comment is recognised by its `<!-- aeg:developer:round-<n> -->` marker, at that fixed position, never by scanning its prose.",
5632
+ "Exit `0` only when the state is `CONTINUE` and the branch is not behind; `1` otherwise, so a script can gate on the exit code without parsing the text."
5633
+ ],
5634
+ status: "shipped"
5635
+ },
5636
+ {
5637
+ name: "review post",
5638
+ description: "Render, post, and self-verify a code-reviewer or security-review verdict comment on a PR",
5639
+ flags: [
5640
+ { flag: "--role", description: "`code-reviewer` or `security` — selects which role template is rendered" },
5641
+ {
5642
+ flag: "--pr",
5643
+ description: "Target PR number — its real head is resolved via `gh pr view`, never caller-supplied"
5644
+ },
5645
+ {
5646
+ flag: "--verdict",
5647
+ description: "Optional — derived from the findings file (code-reviewer: `APPROVE`/`REQUEST_CHANGES`; security: `PASS`/`FAIL`). Refused before posting if it disagrees with the derivation."
5648
+ },
5649
+ {
5650
+ flag: "--escalate",
5651
+ description: "`authority` | `strategy` | `product` — posts an `ESCALATE:` comment instead of a verdict. Refused together with `--verdict` or a blocking finding."
5652
+ },
5653
+ { flag: "--summary", description: "Required with `--escalate` — the escalation body text" },
5654
+ {
5655
+ flag: "--findings-file",
5656
+ description: "One finding per line: `SEVERITY|file:line|description` (`|`-delimited). A re-review names a prior id in the description as `F<n> <class> <state>:`. Omit for zero findings."
5657
+ },
5658
+ {
5659
+ flag: "--objectives-file",
5660
+ description: "One line per objective: `O<n>|MET|<evidence>` or `O<n>|NOT MET|<evidence>` (`|`-delimited; evidence is the rest of the line). Required whenever the closed Issue (or the PR body's own `## Objectives`) has an objectives list to judge; its ids must cover that list exactly, and a re-review must restate every prior objective. Never together with `--escalate`."
5661
+ },
5662
+ { flag: "--brief-conformance", description: "code-reviewer only: the BRIEF CONFORMANCE line" },
5663
+ { flag: "--spec-conformance", description: "code-reviewer only: the SPEC CONFORMANCE line" },
5664
+ { flag: "--scope", description: "code-reviewer only: the SCOPE line" },
5665
+ {
5666
+ flag: "--scope-evidence-file",
5667
+ description: "code-reviewer only: pasted diff-stat output, rendered as a fence directly below the verdict block"
5668
+ },
5669
+ { flag: "--tests", description: "code-reviewer only: the TESTS line" },
5670
+ { flag: "--docs", description: "code-reviewer only: the DOCS line" },
5671
+ { flag: "--config-scan", description: "security only: the CONFIG SCAN line" },
5672
+ { flag: "--secrets", description: "security only: the SECRETS line" },
5673
+ {
5674
+ flag: "--secrets-evidence-file",
5675
+ description: 'security only: required whenever `--secrets` claims "none found" — the pasted scanner output backing that claim'
5676
+ },
5677
+ { flag: "--task-id", description: "the closing `Tokens:` line's task id" },
5678
+ { flag: "--model", description: "the closing `Tokens:` line's model name" },
5679
+ { flag: "--tokens-in", description: "a non-negative integer, or `-` if unknown" },
5680
+ { flag: "--tokens-out", description: "a non-negative integer, or `-` if unknown" },
5681
+ { flag: "--cost", description: "free text, or `-` if unknown" },
5682
+ {
5683
+ flag: "--print-only",
5684
+ description: "Render and self-check the comment, print it, and exit — never calls `gh pr comment`"
5685
+ },
5686
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5687
+ ],
5688
+ details: [
5689
+ "`--print-only` runs the exact same render-then-self-check path as a real post, then returns before `gh pr comment` — closes atta-labs/vinaya#184, where the old command silently posted a verdict anyway after a reviewer guessed this flag existed.",
5690
+ "Every structural line (`VERDICT:`, `Judged head:`) is rendered from this command's own validated enum/sha inputs — never from a caller-supplied string — so a Reviewer's free-typed prose can no longer produce a shape the merge gate's line-anchored regex fails to see.",
5691
+ "The verdict is derived, not typed: a BLOCKER (or CRITICAL/HIGH) finding forces REQUEST_CHANGES/FAIL and its absence forces APPROVE/PASS, before posting anything — an explicit `--verdict` that disagrees is refused naming the derived value. When a same-role verdict comment already exists on the PR, a new findings file must carry every prior id with a state and no non-blocking finding outside the diff since that comment's judged head, or the post is refused.",
5692
+ "Renders an `OBJECTIVES:` block (one `O<n>: MET | NOT MET — <evidence>` line per objective) after `SPEC CONFORMANCE:`/before `CONFIG SCAN:`, and an `Objectives version:` line at line 5 — resolved from the closed Issue's `## Objectives` list, or the PR body's own section when it closes none. A clean verdict (`APPROVE`/`PASS`) is refused alongside any `NOT MET`; an Issue below the objectives cutover renders neither line at all, matching the merge gate's own skip.",
5693
+ "Before the post ever reaches the forge, runs the exact `extractCodeReviewVerdict`/`extractSecurityReviewVerdict` functions `checkReviewGate` calls over its own rendered text and refuses (exit 2) unless exactly the intended verdict extracts and the other role extracts none — an escalation requires both to extract none. Both extractors read only a comment's first five lines; a code-review or security render's caller-supplied fields never open one of those lines, but an escalation's `--summary` can (pre-cutover, it becomes line 5 unprefixed) — this pre-post re-parse, not the render's construction, is what catches that case before it ever reaches the forge.",
5694
+ "After posting, re-fetches the PR's comments and runs them through the same extractors `checkReviewGate` calls — the same functions, not a second implementation — and exits non-zero naming precisely what failed to re-parse if the post does not come back clean, bound to the resolved head and objectives version, and free of the other role's verdict. There is no `--skip-verify` escape."
5695
+ ],
5696
+ status: "shipped"
5697
+ },
5698
+ {
5699
+ name: "doctor",
5700
+ description: "Diagnose hook, workflow, and config health — report only, never mutates",
5701
+ flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }],
5702
+ details: [
5703
+ 'Carries the same env-declaration diagnostic `vinaya check` warns with — permanently, at `info` severity, not just ahead of the spawn-default flip — plus a `warn`-severity lint over suspicious `env` literal forms (a stray `"true"`/`"false"` string, or a high-entropy literal that reads like a leaked secret committed to config).',
5704
+ "Also carries the two permanent `checks`-classification diagnostics: a config key that REPLACES a core check (`warn`), and a bare un-namespaced key that is REJECTED (`error`, naming the rename requirement). These are the reason a config `vinaya check` now refuses outright is still diagnosable — the refusal runs nothing, so `doctor` is the surface that explains why."
5705
+ ],
5706
+ status: "shipped"
5707
+ },
5708
+ {
5709
+ name: "tokens",
5710
+ description: "Print a role's `Tokens: …` report line — the portable front door over the collection adapter",
5711
+ flags: [
5712
+ { flag: "--phase", description: 'e.g. `"<task-id>: develop"` — required' },
5713
+ { flag: "--role", description: "e.g. `Developer` — required" },
5714
+ { flag: "--model", description: "Overrides the model id the adapter derived, if given" },
5715
+ {
5716
+ flag: "--transcript",
5717
+ description: "Read this transcript directly. Supported primary route — use it whenever you know which transcript " + "is yours, and always in a repo with no track-transcript.sh hook. Omitted resolves via the Stop-hook " + "pointer file, if this repo installs that hook."
5718
+ },
5719
+ {
5720
+ flag: "--in / --out",
5721
+ description: "Manual entry: the exact token figures, for a host whose usage arrives by some other means than a " + "Claude Code transcript. Both required together; skips transcript resolution entirely."
5722
+ }
5723
+ ],
5724
+ details: [
5725
+ "Resolves the Claude Code collection adapter (`resolveMeteringCapability`, `summarizeTranscript`, `formatTokensLine`) from the INSTALLED `@attalabs/aeg-core` package, never by a repo-relative path — the fix for `packages/aeg-core/bin/report-tokens.ts` not existing in an adopter repo with no local `packages/`.",
5726
+ "Refuses — never emits a `0/0/—` line — when no transcript resolves, a resolved transcript can't be read, or it summarizes to zero usage records (empty, unparseable, or not yet flushed to disk). Capability is probed by actually attempting resolution, never declared from the host being Claude Code."
5727
+ ],
5728
+ status: "shipped"
5729
+ },
5730
+ {
5731
+ name: "doctrine",
5732
+ description: "Print the absolute path of the bundled doctrine's front door (aeg-root/skills/aeg/SKILL.md) on this machine",
5733
+ flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1) — `{ root, entry }`" }],
5734
+ details: [
5735
+ "The committed root `VINAYA.md` pointer names the `@attalabs/vinaya` package, never a filesystem path — where the package sits is a property of each machine, not of the repo, and the pointer is committed for every clone. This command is the read-time resolution step the pointer hands the reader: it resolves the installed package's own bundled `aeg-root/` wherever the CLI physically sits and prints the front door's absolute path, so `cat \"$(vinaya doctrine)\"` opens the doctrine on any machine at any version.",
5736
+ "In a repo that vendors the CLI, the bundled copy is a gitignored pack-time artifact, so the command falls back to the monorepo root's own `aeg-root/` — the same directory `bundle-doctrine` copies from. Exits 1 with a corrective message when neither location holds a doctrine."
5737
+ ],
5738
+ status: "shipped"
5739
+ },
5740
+ {
5741
+ name: "upgrade",
5742
+ description: "Regenerate hooks, workflow, and config to the current contract version (diff-and-confirm)",
5743
+ flags: [
5744
+ { flag: "--dry-run", description: "Print the full diff without regenerating anything" },
5745
+ { flag: "--yes", description: "Skip the confirmation prompt" }
5746
+ ],
5747
+ details: [
5748
+ "When `claude` is a selected agent vendor, also retrofits the Claude Code `Stop` hook (`.claude/hooks/track-transcript.sh`, `.claude/settings.json`) the same way `init` installs it on a fresh repo — for a repo that ran `init` before this hook existed, closing the gap that left token rows reading `—/—/—` with no operator ever told to re-run `init`. Never overwrites a foreign `.claude/settings.json` (refuse-if-foreign, same as `init`); appends to a foreign Stop-hook script rather than replacing it (managed-block, same discipline as the git hooks)."
5749
+ ],
5750
+ status: "shipped"
5751
+ },
5752
+ {
5753
+ name: "archive",
5754
+ description: "Run the post-merge Archivist directly: provenance + Issue close-out for a merged task PR",
5755
+ flags: [{ flag: "--merge-sha", description: "The merge commit to resolve (defaults to the current HEAD)" }],
5756
+ details: [
5757
+ "Resolves the merge commit's associated PR via `gh`, and — if it's a task PR without a provenance comment yet — posts the provenance block and closes the linked Issue. Idempotent: re-running against an already-archived PR is a no-op.",
5758
+ "The same logic the generated `vinaya-archivist.yml` workflow's `post-merge` job runs on every push to `main` — callable directly for a one-off run or local verification.",
5759
+ "All progress output writes through `process.stdout.write`/`process.stderr.write` (never bare `console.*`), so piping this command into a log file or a CI step captures every line in order."
5760
+ ],
5761
+ status: "shipped"
5762
+ },
5763
+ {
5764
+ name: "archive tranche",
5765
+ description: "Close a tranche — the tranche-level bookend to `init product`, closing the Milestone via the CLI",
5766
+ flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
5767
+ details: [
5768
+ "Refuses if any task Issue attached to the named tranche is still open, naming each one — closing a tranche with unresolved work is never silently allowed.",
5769
+ "Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes the GitHub Milestone."
5770
+ ],
5771
+ status: "shipped"
5772
+ },
5773
+ {
5774
+ name: "audit",
5775
+ description: "Run the ring-2 dead-branch-push and direct-main-push detection checks directly",
5776
+ flags: [
5777
+ { flag: "--only", description: "Scope to one check: 'dead-branches' or 'direct-push'" },
5778
+ { flag: "--sha", description: "The commit to check for direct-main-push (defaults to the current HEAD)" },
5779
+ { flag: "--json", description: "Enveloped JSON output" }
5780
+ ],
5781
+ details: [
5782
+ "Dead-branch-push is never-red — a notification channel that flags (label + PR comment) any `task/*` branch whose tip commit lands after its own PR already resolved. Direct-main-push is a real pass/fail — it polls the merge-association API for up to ~100s before deciding, then opens an incident Issue and exits 1 if a commit on `main` genuinely has no associated merged PR.",
5783
+ "The same logic the generated `vinaya-archivist.yml` workflow's `daily-drift` and `direct-main-push-detection` jobs run on schedule / on every push to `main` — callable directly for a one-off run or local verification.",
5784
+ "All progress output writes through `process.stdout.write`/`process.stderr.write` (never bare `console.*`), so piping this command into a log file or a CI step captures every line in order."
5785
+ ],
5786
+ status: "shipped"
5787
+ },
5788
+ {
5789
+ name: "eject",
5790
+ description: "Remove every Vinaya-installed artifact, restoring the repo to stock",
5791
+ flags: [
5792
+ { flag: "--dry-run", description: "Print the full removal diff without removing anything" },
5793
+ { flag: "--yes", description: "Skip the confirmation prompt" }
5794
+ ],
5795
+ status: "shipped"
5796
+ },
5797
+ {
5798
+ name: "demo break",
5799
+ description: "Run a guided refusal-then-fix demo on an isolated, discardable branch",
5800
+ flags: [{ flag: "--keep", description: "Skip cleanup and leave the demo branch checked out to inspect" }],
5801
+ details: [
5802
+ "Creates a collision-safe `vinaya/demo-break-<id>` branch off the current one, stages a deliberately incomplete draft brief, and attempts a real `git commit` — the repo's actually-installed pre-commit hook refuses it with its real output, not a scripted string. Applies the minimal fix, commits again, then switches back and deletes the demo branch.",
5803
+ "Safe to run twice: refuses on a dirty working tree, refuses from a detached HEAD, and recovers automatically from a prior crashed run before starting a fresh one — never leaves the original branch touched or a stray demo branch behind."
5804
+ ],
5805
+ status: "shipped"
5806
+ },
5807
+ {
5808
+ name: "waiver",
5809
+ description: "Apply the actor-verified 'vinaya/waiver:docs' or 'vinaya/waiver:review' label after prompting for a reason",
5810
+ flags: [
5811
+ { flag: "--reason", description: "The waiver rationale, posted as a PR comment (prompted for if omitted)" },
5812
+ { flag: "--print-only", description: "Print the exact `gh` commands instead of running them" }
5813
+ ],
5814
+ details: [
5815
+ "Applies the label via `gh pr edit --add-label`, under the invoking human's own authenticated `gh` identity — this command never fabricates an actor. A waiver is never an agent-emittable string: not a PR body field, not a commit trailer, not a comment — the label plus its own labeling-timeline actor is the only mechanism ring 1 honors.",
5816
+ "`--print-only` prints the exact `gh pr edit`/`gh pr comment` commands and runs nothing — for a human who wants to run them itself, or a CI/non-interactive context where an agent session should never be the one applying its own waiver."
5817
+ ],
5818
+ status: "shipped"
5819
+ },
5820
+ {
5821
+ name: "studio",
5822
+ description: "Launch Vinaya Studio — runs the Studio dev app when its source (apps/vinaya-studio/web) is in a checkout above the current directory; a published install launches its bundled standalone server instead",
5823
+ flags: [
5824
+ {
5825
+ flag: "--port <n>",
5826
+ description: "Bind this exact port. Without the flag the default is unchanged — 3008, falling back to 3108 when it is taken. With it there is no fallback: a taken port is refused, so you always know which server answered. Accepts `--port 3208` and `--port=3208`. Applies to a published install; in a workspace checkout Studio's own dev script owns the port and the flag is refused."
5827
+ }
5828
+ ],
5829
+ details: [
5830
+ "Resolution happens in this order: a workspace checkout carrying `apps/vinaya-studio/web` (Studio's source, which lives in the attalabs monorepo — not this repository) runs the dev app directly; a published install's `studio-standalone/` bundle (fetched from attalabs' release artifact at publish time, see `scripts/bundle-studio.ts`) runs that bundled server; anything else — a publish that shipped without the bundle — gets an explicit refusal and exit 1 rather than a silent no-op.",
5831
+ "Every published `@attalabs/vinaya` build ships the `studio-standalone/` bundle: `prepack` fetches attalabs’ latest CI-built standalone Studio artifact and assembles it into the tarball before publish."
5832
+ ],
5833
+ status: "shipped"
5834
+ },
5835
+ {
5836
+ name: "quickstart",
5837
+ description: "Guided wizard: init, doc-owners, project, commit, demo break, doctor, push — one command",
5838
+ details: [
5839
+ "Calls `init`'s own diff-and-confirm flow unchanged (pausing on Enter before the diff prints, so its own step header isn't scrolled off by a long diff), then Y/n-prompts through the workarounds a guest used to run by hand: binding `.vinaya/doc-owners` pairs (bad input offers a retry instead of silently skipping, and a pointer that doesn't exist on disk is refused outright — both loop across as many pairs as the guest wants, not just one), registering tracked projects (`init product`, same retry/loop shape), committing the install, running `demo break` as proof the gates actually work (default yes — the one step this wizard makes hardest to skip), running `doctor`, and pushing. Each declined prompt skips only that step; the install commit itself is never prompt-gated — it just no-ops when there is genuinely nothing to commit.",
5840
+ "Never reimplements or edits `init`/`init product`/`demo break`/`doctor` — it only calls their existing, unmodified entry points in sequence."
5841
+ ],
5842
+ status: "shipped"
5843
+ },
5844
+ {
5845
+ name: "release",
5846
+ description: "Run this repo's own publish sequence in one command, refusing to start unless every precondition holds",
5847
+ flags: [
5848
+ {
5849
+ flag: "--dry-run",
5850
+ description: "Run the preconditions only and print the plan; publishes nothing"
5851
+ },
5852
+ {
5853
+ flag: "--allow-any-commit",
5854
+ description: "Skip the check that HEAD's commit is a Version Packages commit"
5855
+ }
5856
+ ],
5857
+ details: [
5858
+ "Refuses unless HEAD is the default branch, the working tree is clean, HEAD equals `origin/<default>` (after `git fetch origin`), HEAD's commit subject starts with `Chore(release): Version packages` (unless `--allow-any-commit`), and `npm whoami` exits `0` — each its own refusal naming the fix.",
5859
+ "Then streams `bun install --frozen-lockfile`, `bun run build`, `bun run changeset:publish`, and `git push origin --tags` — a real push, so the repo's own generated pre-push hook sees it exactly as any other push would. After it, prints `npm view <pkg> version` for every tag now on HEAD, noting registry lag on `@attalabs/vinaya` (observed ~20 minutes) when it still shows the previous version.",
5860
+ 'This is the one procedure named in `apps/cli/specs/self-hosting.md`, "How the published version is produced" — publishing itself stays manual and human-triggered; this command only removes the hand-typed four-step recipe.'
5861
+ ],
5862
+ status: "shipped"
5863
+ },
5864
+ {
5865
+ name: "dispatch",
5866
+ description: "Start a role's headless agent session (claude/codex/gemini) with attribution set on its environment, recording the outcome through the Vinaya Log",
5867
+ flags: [
5868
+ {
5869
+ flag: "--agent",
5870
+ description: "Vendor to start: `claude`, `codex`, or `gemini` (falls back to `dispatch.agent` in config)"
5871
+ },
5872
+ { flag: "--prompt-file", description: "Path to the prompt text sent to the agent (never on argv)" },
5873
+ { flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
5874
+ {
5875
+ flag: "--pr",
5876
+ description: "Flush the outbox to this PR's Issue after the dispatch — mutually exclusive with `--task`"
5877
+ },
5878
+ { flag: "--round", description: "Round number, for a dispatch inside a review loop" },
5879
+ {
5880
+ flag: "--resume <id>",
5881
+ description: "Resume the vendor's own session/thread from a prior dispatch's returned `resumeId`, instead of starting a fresh one"
5882
+ },
5883
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5884
+ ],
5885
+ details: [
5886
+ "Sets `VINAYA_RUN_ID`/`VINAYA_ROLE`/`VINAYA_TASK`/`VINAYA_ROUND` on the child only — never on this process's own environment — and refuses by name, before any spawn attempt, when the named vendor binary is absent from `PATH` or present but not executable.",
5887
+ "Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, or `refused`) through the Vinaya Log's one `dispatch` family writer, `dispatchRole`. A wall-time ceiling (`dispatch.timeoutMs` in config, default one hour) sends `SIGTERM` then, after a grace window, `SIGKILL`.",
5888
+ "When `--task` or `--pr` is given, flushes that outbox via `vinaya log flush` immediately after the child settles — `--task` and `--pr` are mutually exclusive here, matching `log flush`'s own single-target rule. Without either, the dispatch still runs and logs; nothing is flushed, and the lines ride to the next flush.",
5889
+ "A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude/gemini: `session_id`; codex: `thread_id`), parsed from its stdout, `null` on any failure. Passing that value as `--resume <id>` on a later call swaps in that vendor's own resume invocation (`claude -p -r <id> ...`; `codex exec resume <id> ...`; `gemini ... --resume <id> ...`) in place of its first-dispatch args."
5890
+ ],
5891
+ status: "shipped"
5892
+ },
5893
+ {
5894
+ name: "dev-review-loop",
5895
+ description: "Dispatch the developer, run review rounds against the forge, resume the same developer session every round, and hold every verdict until the policy says publish",
5896
+ flags: [
5897
+ { flag: "--task <n>", description: "This task's Issue number — its frozen `aeg:brief:v1` comment is the brief" },
5898
+ {
5899
+ flag: "--agent <claude|codex|gemini>",
5900
+ description: "Vendor for every dispatch this loop makes (falls back to `dispatch.agent` in config)"
5901
+ },
5902
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5903
+ ],
5904
+ details: [
5905
+ "Dispatches the developer through `dispatchRole` with the brief read from the Issue, waits for the PR it opens, then runs `assessRound` (`@attalabs/aeg-core`) — the entire policy — against observations this command reads from the forge: the head via `git ls-remote` only (never `gh pr view headRefOid`, which can lag a push), CI conclusion via the check-runs API (never run locally), and ruling comments matching `<!-- aeg:principal:ruling:<pr>-<k> -->`.",
5906
+ "Nothing is posted to the PR before the policy decides `publish`: each round's reviewer and security verdicts are dispatched fresh (never a resumed session) through `dispatchRole`, rendered through `review post`'s own render functions, and written to a local file under the outbox — never `gh pr comment`/`gh pr review`. Posting the held verdicts is a separate, later task.",
5907
+ "The developer's session is resumed every round via `dispatchRole`'s `resumeId` — never a fresh session — for every vendor; a round whose resume fails for a vendor that resumed successfully the round before stops the loop rather than silently falling back to a fresh developer session.",
5908
+ "Every dispatch and round transition is a log line through the Vinaya Log, flushed to the forge at each round boundary."
5909
+ ],
5910
+ status: "shipped"
5911
+ }
5912
+ ];
5913
+ // ../../packages/sources/src/forge-adapter.ts
5914
+ function createForgeSource(config) {
5915
+ return {
5916
+ async getTranche(slug) {
5917
+ return deriveTrancheFromForge(config.owner, config.repo, slug);
5918
+ }
5919
+ };
5920
+ }
5921
+ // ../../packages/sources/src/select-source.ts
5922
+ import { z as z3 } from "zod";
5923
+ var StateSourceConfigSchema = z3.discriminatedUnion("kind", [
5924
+ z3.object({ kind: z3.literal("forge"), owner: z3.string(), repo: z3.string() }),
5925
+ z3.object({ kind: z3.literal("file"), root: z3.string().optional() })
5926
+ ]);
5927
+ // src/checks/edge-resolve.ts
5928
+ import { execFileSync as execFileSync3 } from "node:child_process";
5929
+ var DIRECT_ISSUE_REF = /#(\d+)/;
5930
+ var issueCache = new Map;
5931
+ function fetchIssueState(num, repo) {
5932
+ const key = `${repo.owner}/${repo.repo}#${num}`;
5933
+ if (issueCache.has(key))
5934
+ return issueCache.get(key) ?? null;
5935
+ let out = null;
5936
+ try {
5937
+ const raw = execFileSync3("gh", [
5938
+ "issue",
5939
+ "view",
5940
+ String(num),
5941
+ "-R",
5942
+ `${repo.owner}/${repo.repo}`,
5943
+ "--json",
5944
+ "state,stateReason,closedByPullRequestsReferences"
5945
+ ], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
5946
+ out = JSON.parse(raw);
5947
+ } catch {
5948
+ out = null;
5949
+ }
5950
+ issueCache.set(key, out);
5951
+ return out;
5952
+ }
5953
+ var defaultResolveSiblingTranche = async (slug, repo) => {
5954
+ let tranche;
5955
+ try {
5956
+ tranche = await deriveTrancheFromForge(repo.owner, repo.repo, slug);
5957
+ } catch {
5958
+ return null;
5959
+ }
5960
+ const taskRefs = tranche.tasks.map((t) => ({ id: t.id, issue: t.issue }));
5961
+ const snapshot = await fetchForgeFacts({ owner: repo.owner, repo: repo.repo, tranche: slug, tasks: taskRefs });
5962
+ return {
5963
+ tasks: new Map(tranche.tasks.map((t) => [t.id, { id: t.id, issue: t.issue }])),
5964
+ facts: snapshot.facts
5965
+ };
5966
+ };
5967
+ var siblingTrancheCache = new Map;
5968
+ function edgeFromIssueJson(num, json) {
5969
+ if (json === null) {
5970
+ return {
5971
+ issue: num,
5972
+ merged: false,
5973
+ open: false,
5974
+ issueState: null,
5975
+ stateReason: null,
5976
+ closedByActor: null,
5977
+ resolved: true
5978
+ };
5979
+ }
5980
+ const state = json.state === "CLOSED" ? "closed" : json.state === "OPEN" ? "open" : null;
5981
+ const reason = json.stateReason === "COMPLETED" ? "completed" : json.stateReason === "NOT_PLANNED" ? "not_planned" : null;
5982
+ const closedByMergedPr = (json.closedByPullRequestsReferences ?? []).length > 0;
5983
+ return {
5984
+ issue: num,
5985
+ merged: state === "closed" && closedByMergedPr,
5986
+ open: false,
5987
+ issueState: state,
5988
+ stateReason: reason,
5989
+ closedByActor: null,
5990
+ resolved: true
5991
+ };
5992
+ }
5993
+ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = defaultResolveSiblingTranche) {
5994
+ const target = taskById.get(id);
5995
+ if (target) {
5996
+ const facts = target.issue !== null ? factsByTaskId.get(target.id) : undefined;
5997
+ return {
5998
+ issue: target.issue,
5999
+ merged: facts?.prState === "merged",
6000
+ open: facts?.prState === "open",
6001
+ issueState: facts?.issueState ?? null,
6002
+ stateReason: facts?.stateReason ?? null,
6003
+ closedByActor: facts?.closedByActor ?? null,
6004
+ resolved: true
6005
+ };
6006
+ }
6007
+ const direct = id.match(DIRECT_ISSUE_REF);
6008
+ if (direct) {
6009
+ const num = Number(direct[1]);
6010
+ return edgeFromIssueJson(num, fetchIssueState(num, repo));
6011
+ }
6012
+ const qualified = splitSlugQualifiedEdge(id);
6013
+ if (qualified) {
6014
+ const cacheKey = `${repo.owner}/${repo.repo}:${qualified.slug}`;
6015
+ let sibling = siblingTrancheCache.get(cacheKey);
6016
+ if (sibling === undefined) {
6017
+ sibling = await resolveSibling(qualified.slug, repo);
6018
+ siblingTrancheCache.set(cacheKey, sibling);
6019
+ }
6020
+ const siblingTask = sibling?.tasks.get(qualified.bareId);
6021
+ if (sibling && siblingTask) {
6022
+ const facts = siblingTask.issue !== null ? sibling.facts.get(siblingTask.id) : undefined;
6023
+ return {
6024
+ issue: siblingTask.issue,
6025
+ merged: facts?.prState === "merged",
6026
+ open: facts?.prState === "open",
6027
+ issueState: facts?.issueState ?? null,
6028
+ stateReason: facts?.stateReason ?? null,
6029
+ closedByActor: facts?.closedByActor ?? null,
6030
+ resolved: true
6031
+ };
6032
+ }
6033
+ }
6034
+ return {
6035
+ issue: null,
6036
+ merged: false,
6037
+ open: false,
6038
+ issueState: null,
6039
+ stateReason: null,
6040
+ closedByActor: null,
6041
+ resolved: false
6042
+ };
6043
+ }
6044
+
4749
6045
  // src/checks/contract.ts
4750
6046
  var CHECK_SCHEMA_VERSION = 1;
4751
6047
  function emitCheckError(error) {
@@ -4784,7 +6080,7 @@ function parseChangedLineRanges(diffOutput) {
4784
6080
  function fileDiffAgainst(ref, path) {
4785
6081
  let out;
4786
6082
  try {
4787
- out = execFileSync3("git", ["diff", `${ref}...HEAD`, "--", path], {
6083
+ out = execFileSync4("git", ["diff", `${ref}...HEAD`, "--", path], {
4788
6084
  encoding: "utf8",
4789
6085
  stdio: ["ignore", "pipe", "pipe"]
4790
6086
  }).trim();
@@ -4795,7 +6091,7 @@ function fileDiffAgainst(ref, path) {
4795
6091
  }
4796
6092
  function revParse(ref) {
4797
6093
  try {
4798
- return execFileSync3("git", ["rev-parse", "--verify", ref], {
6094
+ return execFileSync4("git", ["rev-parse", "--verify", ref], {
4799
6095
  encoding: "utf8",
4800
6096
  stdio: ["ignore", "pipe", "pipe"]
4801
6097
  }).trim();
@@ -4805,7 +6101,7 @@ function revParse(ref) {
4805
6101
  }
4806
6102
  function repoRoot() {
4807
6103
  try {
4808
- return execFileSync3("git", ["rev-parse", "--show-toplevel"], {
6104
+ return execFileSync4("git", ["rev-parse", "--show-toplevel"], {
4809
6105
  encoding: "utf8",
4810
6106
  stdio: ["ignore", "pipe", "pipe"]
4811
6107
  }).trim();
@@ -4816,7 +6112,7 @@ function repoRoot() {
4816
6112
  function changedFiles(base) {
4817
6113
  let out;
4818
6114
  try {
4819
- out = execFileSync3("git", ["diff", "--name-only", `${base}...HEAD`], {
6115
+ out = execFileSync4("git", ["diff", "--name-only", `${base}...HEAD`], {
4820
6116
  encoding: "utf8",
4821
6117
  stdio: ["ignore", "pipe", "pipe"]
4822
6118
  }).trim();
@@ -4876,7 +6172,7 @@ function findingsInThisDiff(findings) {
4876
6172
  var CHECK_NAME = "doc-coverage-push";
4877
6173
  function git(args) {
4878
6174
  try {
4879
- return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
6175
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
4880
6176
  } catch {
4881
6177
  return "";
4882
6178
  }