@attalabs/vinaya 0.19.3 → 0.21.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 (153) hide show
  1. package/README.md +81 -0
  2. package/aeg-root/contracts/archivist-tranche-archivist.md +2 -2
  3. package/aeg-root/contracts/tranche-archivist-planner.md +8 -8
  4. package/aeg-root/enforcement.md +18 -9
  5. package/aeg-root/milestone-model.md +3 -1
  6. package/aeg-root/process.md +5 -5
  7. package/aeg-root/roles/architect.md +2 -2
  8. package/aeg-root/roles/archivist.md +10 -11
  9. package/aeg-root/roles/brief-author.md +1 -1
  10. package/aeg-root/roles/developer.md +4 -3
  11. package/aeg-root/roles/planner.md +2 -2
  12. package/aeg-root/roles/principal.md +2 -1
  13. package/aeg-root/roles/tranche-archivist.md +5 -18
  14. package/aeg-root/skills/aeg/SKILL.md +30 -1
  15. package/aeg-root/skills/aeg-roles/SKILL.md +1 -1
  16. package/aeg-root/skills/brief-authoring/SKILL.md +2 -2
  17. package/aeg-root/state-machine.md +8 -6
  18. package/aeg-root/task-model.md +1 -1
  19. package/aeg-root/templates/issue-rationale-template.md +4 -4
  20. package/aeg-root/templates/pr-report-template.md +4 -0
  21. package/aeg-root/tranche-model.md +1 -1
  22. package/dist/checks/bin/check-body-bare-digits.js +473 -32
  23. package/dist/checks/bin/check-branch-topology.js +792 -11
  24. package/dist/checks/bin/check-brief-shape.js +353 -11
  25. package/dist/checks/bin/check-changeset-coverage.js +4156 -0
  26. package/dist/checks/bin/check-closes-n.js +792 -11
  27. package/dist/checks/bin/check-coherence.js +831 -15
  28. package/dist/checks/bin/check-dead-branch-push.js +353 -11
  29. package/dist/checks/bin/check-dispatch-readiness.js +996 -28
  30. package/dist/checks/bin/check-doc-coverage-push.js +449 -22
  31. package/dist/checks/bin/check-doc-coverage.js +449 -22
  32. package/dist/checks/bin/check-doctrine-portability.js +392 -15
  33. package/dist/checks/bin/check-evidence-fresh.js +462 -20
  34. package/dist/checks/bin/check-first-push-dispatch.js +898 -26
  35. package/dist/checks/bin/check-issue-assignment.js +792 -11
  36. package/dist/checks/bin/check-main-branch-refusal.js +3973 -0
  37. package/dist/checks/bin/check-no-disk-state.js +353 -11
  38. package/dist/checks/bin/check-quoted-command.js +4405 -0
  39. package/dist/checks/bin/check-reader-resolvable-prose.js +466 -20
  40. package/dist/checks/bin/check-registry-gates.js +467 -16
  41. package/dist/checks/bin/check-retired-vocabulary.js +465 -19
  42. package/dist/checks/bin/check-review-gate.js +392 -15
  43. package/dist/checks/bin/check-single-plan-pr.js +353 -11
  44. package/dist/checks/bin/check-test-plan.js +353 -11
  45. package/dist/checks/bin/check-token-collection-wired.js +3975 -0
  46. package/dist/checks/bin/check-workspace-escape.js +353 -11
  47. package/dist/index.js +1921 -420
  48. package/package.json +1 -1
  49. package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core/bin/verify-coherence.ts +1089 -0
  50. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  51. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  52. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  53. package/studio-standalone/apps/vinaya-studio/web/.next/required-server-files.json +5 -0
  54. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  55. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  56. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  57. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  58. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  59. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  60. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  61. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  62. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js +2 -2
  63. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  64. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  65. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
  66. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js +2 -2
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  70. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +2 -2
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +3 -3
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +3 -3
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +2 -2
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +3 -3
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +3 -3
  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 +3 -3
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +2 -2
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__0pvgf28._.js → [externals]__1agj1ww._.js} +2 -2
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +1 -1
  101. 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
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0053k9k._.js +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0112h-k._.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__040smoa._.js +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0cxtq46._.js +25 -18
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0o771t1._.js +1 -1
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__03jepya._.js → [root-of-the-server]__0ozbaq0._.js} +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0puovz5._.js +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0ykun-j._.js → [root-of-the-server]__0z6dav-._.js} +3 -3
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__18kqy4q._.js +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1hs0dcu._.js +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1widio3._.js +1 -1
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1yoa8tx._.js +3 -0
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_03x_w6q._.js +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gvm3og._.js +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0lwxg63._.js +1 -1
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0wxycau._.js +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0x999pb._.js +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-6rzip._.js +1 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1fqw88f._.js +2 -2
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_0zys35s._.js → _1mqrlbl._.js} +2 -2
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_1c9b9j-._.js → _1mrtj0f._.js} +2 -2
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1n0cnq-._.js +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{apps_vinaya-studio_web_src_app_studio_18kqbvs._.js → apps_vinaya-studio_web_src_app_studio_06it6s-._.js} +2 -2
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_app_studio_projects_[name]_tranches_[slug]_05ufo8i._.js +1 -1
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_1vo08dj._.js +2 -2
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +3 -3
  133. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0r4i_ks9z02bw.js +1 -0
  134. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3noqvds-2bvrd.js → 1hfhxjy577l5d.js} +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1k916ih3p4nsg.js +1 -0
  136. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{29-foak16tjfu.js → 1t2kft7bxzuxn.js} +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2iysedx-n06xc.js → 1ybrihl5_aocy.js} +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{30ojnsx3p4lp4.js → 1yqs2zgvwa4p1.js} +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0msr2a1i-x-br.js → 25kbt5k-xb2a5.js} +1 -1
  140. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3gehliafvmjo9.js → 2_k6j1o9q5nn4.js} +4 -4
  141. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2hmannd4bjhzy.js +1 -0
  142. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3mqu_uhluy19i.css +1 -0
  143. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  144. package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
  145. package/aeg-root/coordination.md +0 -292
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1rku4gz._.js +0 -3
  147. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/25j-y57ng11hl.js +0 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/30lyvn0yzwdiz.js +0 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/35u8inxa732is.js +0 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/42wxpzjhw7oy4.css +0 -1
  151. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{5Lv83SnT--7YJDjSbxona → crNCHQ9uAgKOYC6DKkZma}/_buildManifest.js +0 -0
  152. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{5Lv83SnT--7YJDjSbxona → crNCHQ9uAgKOYC6DKkZma}/_clientMiddlewareManifest.js +0 -0
  153. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{5Lv83SnT--7YJDjSbxona → crNCHQ9uAgKOYC6DKkZma}/_ssgManifest.js +0 -0
@@ -2,20 +2,20 @@
2
2
 
3
3
  // src/checks/bin/check-reader-resolvable-prose.ts
4
4
  import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync3, statSync } from "node:fs";
5
- import { join as join4 } from "node:path";
5
+ import { join as join5, resolve as resolve2 } from "node:path";
6
6
  // ../../packages/aeg-core/src/gate-audience.ts
7
7
  var GATE_AUDIENCE = {
8
- "check-branch-topology": { shippedAs: "branch-topology" },
9
- "check-first-push-dispatch": { shippedAs: "first-push-dispatch" },
10
- "check-no-disk-state": { shippedAs: "no-disk-state" },
11
- "verify-brief": { shippedAs: "brief-shape" },
12
- "verify-coherence": { shippedAs: "coherence" },
13
- "verify-dispatch": { shippedAs: "dispatch-readiness" },
14
- "verify-docs": { shippedAs: ["doc-coverage", "doc-coverage-push"] },
15
- "verify-registry": { shippedAs: "registry-gates" },
16
- "verify-review-gate": { shippedAs: "review-gate" },
17
- "verify-single-plan-pr": { shippedAs: "single-plan-pr" },
18
- "verify-test-plan": { shippedAs: "test-plan" },
8
+ "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
9
+ "check-first-push-dispatch": { shippedAs: "first-push-dispatch", ring: 0 },
10
+ "check-no-disk-state": { shippedAs: "no-disk-state", ring: 0 },
11
+ "verify-brief": { shippedAs: "brief-shape", ring: 0 },
12
+ "verify-coherence": { shippedAs: "coherence", ring: 0 },
13
+ "verify-dispatch": { shippedAs: "dispatch-readiness", ring: 0 },
14
+ "verify-docs": { shippedAs: ["doc-coverage", "doc-coverage-push"], ring: 0 },
15
+ "verify-registry": { shippedAs: "registry-gates", ring: 0 },
16
+ "verify-review-gate": { shippedAs: "review-gate", ring: 1 },
17
+ "verify-single-plan-pr": { shippedAs: "single-plan-pr", ring: 0 },
18
+ "verify-test-plan": { shippedAs: "test-plan", ring: 1 },
19
19
  "check-direct-main-push": {
20
20
  internal: "Reaches adopters through `vinaya audit --only=direct-push`, not the check registry: it is a ring-2 sweep over merge history keyed on `GITHUB_SHA`, run by the generated archivist job on push to the default branch. It has no diff to key on, so there is nothing for `vinaya check` to run it against."
21
21
  },
@@ -190,6 +190,12 @@ var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
190
190
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
191
191
  var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
192
192
  var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
193
+ function splitSlugQualifiedEdge(edge) {
194
+ const m = edge.trim().match(SLUG_QUALIFIED_ID);
195
+ if (!m)
196
+ return null;
197
+ return { slug: m[1], bareId: m[2] };
198
+ }
193
199
  function isEmptyMarker(s) {
194
200
  const t = s.trim();
195
201
  return t === "" || t === "—" || t === "-" || t === "–";
@@ -327,6 +333,13 @@ var LABELS = [
327
333
  form: "literal",
328
334
  carries: "Execution is halted pending an external unblock; wins over every other derived status."
329
335
  },
336
+ {
337
+ key: "backlog",
338
+ id: "vinaya/backlog",
339
+ category: "state",
340
+ form: "literal",
341
+ carries: "The Issue is deliberately unplanned — belongs to no tranche and is excluded from dispatch, until a Planner promotes it."
342
+ },
330
343
  {
331
344
  key: "tier-0",
332
345
  id: "vinaya/tier:0",
@@ -1779,6 +1792,151 @@ var DERIVED_STATUSES = [
1779
1792
  "incoherent"
1780
1793
  ];
1781
1794
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1795
+ // ../../packages/aeg-core/src/report-tokens.ts
1796
+ var DASH_LOOKALIKES = {
1797
+ "-": "‑",
1798
+ "–": "‒",
1799
+ "—": "―"
1800
+ };
1801
+ var DASH_CHARS = new Set(Object.keys(DASH_LOOKALIKES));
1802
+ // ../../packages/aeg-core/src/claude-code-transcript.ts
1803
+ function summarizeTranscript(jsonl) {
1804
+ const seen = new Set;
1805
+ const components = {
1806
+ inputTokens: 0,
1807
+ outputTokens: 0,
1808
+ cacheCreationInputTokens: 0,
1809
+ cacheReadInputTokens: 0
1810
+ };
1811
+ let model = null;
1812
+ let messageCount = 0;
1813
+ for (const rawLine of jsonl.split(/\r?\n/)) {
1814
+ const line = rawLine.trim();
1815
+ if (!line)
1816
+ continue;
1817
+ let entry2;
1818
+ try {
1819
+ entry2 = JSON.parse(line);
1820
+ } catch {
1821
+ continue;
1822
+ }
1823
+ if (!entry2 || typeof entry2 !== "object")
1824
+ continue;
1825
+ const obj = entry2;
1826
+ if (obj.type !== "assistant")
1827
+ continue;
1828
+ const message = obj.message;
1829
+ const id = message?.id;
1830
+ const usage = message?.usage;
1831
+ if (typeof id !== "string" || !id || !usage || seen.has(id))
1832
+ continue;
1833
+ seen.add(id);
1834
+ messageCount++;
1835
+ components.inputTokens += numberOr(usage.input_tokens, 0);
1836
+ components.outputTokens += numberOr(usage.output_tokens, 0);
1837
+ components.cacheCreationInputTokens += numberOr(usage.cache_creation_input_tokens, 0);
1838
+ components.cacheReadInputTokens += numberOr(usage.cache_read_input_tokens, 0);
1839
+ const messageModel = message?.model;
1840
+ if (typeof messageModel === "string" && messageModel)
1841
+ model = messageModel;
1842
+ }
1843
+ return { components, model, messageCount };
1844
+ }
1845
+ function numberOr(value, fallback) {
1846
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
1847
+ }
1848
+ function sanitizeKey(value) {
1849
+ return value.replace(/[^A-Za-z0-9]+/g, "-");
1850
+ }
1851
+ function transcriptPointerPath(projectDir, tmpDir) {
1852
+ return `${tmpDir}/claude-transcript-${sanitizeKey(projectDir)}.txt`;
1853
+ }
1854
+ function resolvePointer(explicitTranscriptPath, deps) {
1855
+ if (explicitTranscriptPath)
1856
+ return { path: explicitTranscriptPath, corroborated: true };
1857
+ const projectDir = deps.env.CLAUDE_PROJECT_DIR ?? deps.cwd;
1858
+ const tmpDir = deps.env.TMPDIR ?? "/tmp";
1859
+ const pointerPath = transcriptPointerPath(projectDir, tmpDir);
1860
+ const currentSessionId = deps.env.CLAUDE_CODE_SESSION_ID;
1861
+ if (!deps.exists(pointerPath)) {
1862
+ return {
1863
+ pointerExisted: false,
1864
+ corroborated: false,
1865
+ error: `No transcript pointer at ${pointerPath} and no --transcript given. ` + "Either this repo installs no track-transcript.sh Stop hook (lacking one is not a defect — " + "name the transcript directly instead), or no session has completed a turn yet."
1866
+ };
1867
+ }
1868
+ let contents;
1869
+ try {
1870
+ contents = deps.readFile(pointerPath).replace(/\r?\n+$/, "");
1871
+ } catch (err) {
1872
+ return {
1873
+ pointerExisted: true,
1874
+ oursByLocation: true,
1875
+ error: `Transcript pointer at ${pointerPath} could not be read: ${err.message}. ` + "Remove that file to clear this — the Stop hook rewrites it on the next turn."
1876
+ };
1877
+ }
1878
+ const [pointerSessionId, transcriptPath] = contents.split("\t");
1879
+ if (!transcriptPath) {
1880
+ return {
1881
+ pointerExisted: true,
1882
+ oursByLocation: true,
1883
+ error: `Transcript pointer file ${pointerPath} is malformed: "${contents.slice(0, 120)}${contents.length > 120 ? "…" : ""}". ` + "Remove that file to clear this — the Stop hook rewrites it on the next turn."
1884
+ };
1885
+ }
1886
+ if (currentSessionId && pointerSessionId && currentSessionId !== pointerSessionId) {
1887
+ return {
1888
+ pointerExisted: true,
1889
+ corroborated: false,
1890
+ error: `Transcript pointer at ${pointerPath} is stale: written for session ${pointerSessionId}, ` + `but this session is ${currentSessionId}. Name your own transcript with --transcript instead of ` + "reporting another session's figures as yours."
1891
+ };
1892
+ }
1893
+ return { path: transcriptPath, corroborated: Boolean(currentSessionId && pointerSessionId) };
1894
+ }
1895
+ function resolveMeteringCapability(deps, explicitTranscriptPath) {
1896
+ const resolved = resolvePointer(explicitTranscriptPath, deps);
1897
+ if ("error" in resolved) {
1898
+ const ours = resolved.pointerExisted && (resolved.corroborated || resolved.oursByLocation);
1899
+ if (ours)
1900
+ return { capable: false, reason: "pointer-unusable", detail: resolved.error };
1901
+ return {
1902
+ capable: false,
1903
+ reason: "no-transcript-resolved",
1904
+ detail: resolved.pointerExisted ? `A transcript pointer exists but belongs to another session, so this session has no wiring of its own to use. (Underlying condition, for diagnosis only: ${resolved.error})` : resolved.error
1905
+ };
1906
+ }
1907
+ const downstream = (r, detail) => resolved.corroborated ? { reason: r, detail } : {
1908
+ reason: "no-transcript-resolved",
1909
+ detail: `A transcript pointer was found but could not be shown to belong to this session, so it is not treated as this session's wiring. (Underlying condition, for diagnosis only: ${detail})`
1910
+ };
1911
+ if (!deps.exists(resolved.path)) {
1912
+ return {
1913
+ capable: false,
1914
+ ...downstream("transcript-unreadable", `Resolved transcript path ${resolved.path} is not readable as a regular file owned by this user.`)
1915
+ };
1916
+ }
1917
+ let jsonl;
1918
+ try {
1919
+ jsonl = deps.readFile(resolved.path);
1920
+ } catch (err) {
1921
+ return {
1922
+ capable: false,
1923
+ ...downstream("transcript-unreadable", `Transcript at ${resolved.path} could not be read: ${err.message}`)
1924
+ };
1925
+ }
1926
+ const summary = summarizeTranscript(jsonl);
1927
+ if (summary.messageCount === 0) {
1928
+ return {
1929
+ capable: false,
1930
+ ...downstream("transcript-empty", `Transcript at ${resolved.path} yielded zero assistant messages with usage data — ` + "it's empty, unparseable, or not yet flushed to disk.")
1931
+ };
1932
+ }
1933
+ return { capable: true, transcriptPath: resolved.path, summary };
1934
+ }
1935
+ function isTokenCollectionWiringBroken(capability) {
1936
+ if (capability.capable)
1937
+ return false;
1938
+ return capability.reason !== "no-transcript-resolved";
1939
+ }
1782
1940
  // ../../packages/aeg-core/src/file-classify.ts
1783
1941
  function isCodeFile(p) {
1784
1942
  if (p.endsWith(".md"))
@@ -1985,7 +2143,59 @@ function overrideActive(opts) {
1985
2143
  return false;
1986
2144
  }
1987
2145
  // ../../packages/aeg-core/src/premise-check.ts
2146
+ import { createHash } from "node:crypto";
1988
2147
  var ASSERTION_KINDS = new Set(["contains", "absent", "sha256"]);
2148
+ function isPremiseHeader(line) {
2149
+ const stripped = line.replace(/[*#]/g, "").trim();
2150
+ return /^premise\s*:?$/i.test(stripped);
2151
+ }
2152
+ var PREMISE_LINE = /^[-*]\s*(\S+)\s+(contains|absent|sha256)\s*:\s*(.+)$/i;
2153
+ function parsePremiseBlock(prBody) {
2154
+ const searchIn = anchoredRegion(prBody, "PREMISE") ?? prBody;
2155
+ const lines = searchIn.split(/\r?\n/);
2156
+ const assertions = [];
2157
+ let inBlock = false;
2158
+ for (const raw of lines) {
2159
+ const line = raw.trim();
2160
+ if (!inBlock) {
2161
+ if (isPremiseHeader(line))
2162
+ inBlock = true;
2163
+ continue;
2164
+ }
2165
+ if (line === "")
2166
+ break;
2167
+ const m = line.match(PREMISE_LINE);
2168
+ if (!m)
2169
+ break;
2170
+ const [, path, kindRaw, value] = m;
2171
+ const kind = kindRaw.toLowerCase();
2172
+ if (!ASSERTION_KINDS.has(kind))
2173
+ continue;
2174
+ assertions.push({ kind, path, value: value.trim() });
2175
+ }
2176
+ return assertions;
2177
+ }
2178
+ function checkPremises(assertions, fileReader) {
2179
+ const failures = [];
2180
+ for (const a of assertions) {
2181
+ const content = fileReader(a.path);
2182
+ if (content === null) {
2183
+ failures.push(`premise-check: ${a.path} does not exist on disk (premise asserted \`${a.kind}: ${a.value}\`) — the surface moved since this brief was authored; re-dig before proceeding.`);
2184
+ continue;
2185
+ }
2186
+ if (a.kind === "contains" && !content.includes(a.value)) {
2187
+ failures.push(`premise-check: ${a.path} no longer contains "${a.value}" — the premise this brief pinned has moved; re-dig before proceeding.`);
2188
+ } else if (a.kind === "absent" && content.includes(a.value)) {
2189
+ failures.push(`premise-check: ${a.path} now contains "${a.value}", but the brief pinned it absent — the premise has moved; re-dig before proceeding.`);
2190
+ } else if (a.kind === "sha256") {
2191
+ const actual = createHash("sha256").update(content).digest("hex");
2192
+ if (actual !== a.value.toLowerCase()) {
2193
+ 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.`);
2194
+ }
2195
+ }
2196
+ }
2197
+ return { pass: failures.length === 0, failures };
2198
+ }
1989
2199
 
1990
2200
  // ../../packages/aeg-core/src/test-plan-section.ts
1991
2201
  var HEADING_FORM_RE = /^#{1,4}[ \t]*(?:\d+[a-z]?\.[ \t]*)?\*{0,2}Test Plan\*{0,2}[ \t]*$/im;
@@ -2789,6 +2999,7 @@ function checkG1(rows, existsFn) {
2789
2999
  }
2790
3000
  return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
2791
3001
  }
3002
+ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
2792
3003
  function checkG2(rows, candidateFiles) {
2793
3004
  const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
2794
3005
  const findings = [];
@@ -2800,6 +3011,16 @@ function checkG2(rows, candidateFiles) {
2800
3011
  });
2801
3012
  }
2802
3013
  }
3014
+ for (const row of rows) {
3015
+ const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
3016
+ if (carriesPlaceholder) {
3017
+ findings.push({
3018
+ row: row.action,
3019
+ path: row.implementation,
3020
+ reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
3021
+ });
3022
+ }
3023
+ }
2803
3024
  return { check: "G2", status: findings.length > 0 ? "info" : "pass", findings };
2804
3025
  }
2805
3026
  function checkG3(ring0Rows, crossingFiles) {
@@ -3147,6 +3368,100 @@ function parseGlossaryTerms(glossaryContent) {
3147
3368
  }
3148
3369
  return terms;
3149
3370
  }
3371
+ // ../../packages/aeg-core/src/quoted-command.ts
3372
+ var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3373
+ var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3374
+ var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
3375
+ var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
3376
+ function isValidCitedFilePath(path) {
3377
+ if (path.length === 0)
3378
+ return false;
3379
+ if (path.startsWith("/") || path.startsWith("\\"))
3380
+ return false;
3381
+ if (/^[A-Za-z]:[\\/]/.test(path))
3382
+ return false;
3383
+ return !path.split(/[\\/]+/).includes("..");
3384
+ }
3385
+ function quotedCommandLineAt(content, index) {
3386
+ let line = 1;
3387
+ for (let i = 0;i < index; i++) {
3388
+ if (content.charCodeAt(i) === 10)
3389
+ line++;
3390
+ }
3391
+ return line;
3392
+ }
3393
+ function extractQuotedText(raw) {
3394
+ const trimmed = raw.trim();
3395
+ const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
3396
+ if (fenced)
3397
+ return (fenced[1] ?? "").trim();
3398
+ const inline = /^`([^`]+)`$/.exec(trimmed);
3399
+ if (inline)
3400
+ return (inline[1] ?? "").trim();
3401
+ return trimmed;
3402
+ }
3403
+ function findQuotesInFile(path, content) {
3404
+ const masked = maskCode(content);
3405
+ const quotes = [];
3406
+ START_PATTERN.lastIndex = 0;
3407
+ let start = START_PATTERN.exec(masked);
3408
+ while (start !== null) {
3409
+ const citedFile = start[1];
3410
+ const innerStart = start.index + start[0].length;
3411
+ const end = END_PATTERN.exec(masked.slice(innerStart));
3412
+ if (end === null) {
3413
+ START_PATTERN.lastIndex = innerStart;
3414
+ start = START_PATTERN.exec(masked);
3415
+ continue;
3416
+ }
3417
+ const innerEnd = innerStart + end.index;
3418
+ if (isValidCitedFilePath(citedFile)) {
3419
+ const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
3420
+ if (quotedText.length > 0) {
3421
+ quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
3422
+ }
3423
+ }
3424
+ START_PATTERN.lastIndex = innerEnd + end[0].length;
3425
+ start = START_PATTERN.exec(masked);
3426
+ }
3427
+ return quotes;
3428
+ }
3429
+ function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
3430
+ const quotes = [];
3431
+ for (const file of files) {
3432
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3433
+ if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
3434
+ continue;
3435
+ quotes.push(...findQuotesInFile(file.path, file.content));
3436
+ }
3437
+ return quotes;
3438
+ }
3439
+ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3440
+ const findings = [];
3441
+ for (const quote of citedQuotes) {
3442
+ const content = citedFileContents.get(quote.citedFile);
3443
+ if (content === undefined) {
3444
+ findings.push({
3445
+ file: quote.file,
3446
+ line: quote.line,
3447
+ citedFile: quote.citedFile,
3448
+ quotedText: quote.quotedText,
3449
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
3450
+ });
3451
+ continue;
3452
+ }
3453
+ if (!content.includes(quote.quotedText)) {
3454
+ findings.push({
3455
+ file: quote.file,
3456
+ line: quote.line,
3457
+ citedFile: quote.citedFile,
3458
+ quotedText: quote.quotedText,
3459
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
3460
+ });
3461
+ }
3462
+ }
3463
+ return findings;
3464
+ }
3150
3465
  // ../../packages/aeg-core/src/retired-vocabulary.ts
3151
3466
  var RETIRED_PATTERNS = [
3152
3467
  String.raw`\bD-[0-9]{3}\b`,
@@ -3260,6 +3575,10 @@ function checkDispatchReadiness(input) {
3260
3575
  blockers.push(`dispatch-gate rationale: Issue #${input.issue.number} for ${taskLabel} fails the rationale gate (checkIssueRationale) — the Planner must complete the eight-field rationale before this task is dispatchable.`);
3261
3576
  }
3262
3577
  for (const dep of input.dependsOn) {
3578
+ if (dep.resolved === false) {
3579
+ blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on "${dep.id}", which is UNRESOLVABLE — the resolver could not find a matching tranche/task/Issue for this edge (not a claim about merge status). Not dispatchable until the edge is corrected.`);
3580
+ continue;
3581
+ }
3263
3582
  if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
3264
3583
  const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
3265
3584
  blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
@@ -3319,6 +3638,29 @@ function isNewDiskStateFile(path, status) {
3319
3638
  return false;
3320
3639
  return ANY_DEPTH_TRANCHES_MD.test(path) || TOKENS_FILE.test(path);
3321
3640
  }
3641
+ // ../../packages/aeg-core/src/main-branch-refusal.ts
3642
+ function checkMainBranchRefusal(facts) {
3643
+ const { currentSymbolicBranch, defaultBranch } = facts;
3644
+ if (currentSymbolicBranch === null)
3645
+ return null;
3646
+ if (defaultBranch === null) {
3647
+ return {
3648
+ reason: "default-branch-undetermined",
3649
+ severity: "warning",
3650
+ currentBranch: currentSymbolicBranch,
3651
+ defaultBranch: null
3652
+ };
3653
+ }
3654
+ if (currentSymbolicBranch === defaultBranch) {
3655
+ return {
3656
+ reason: "on-default-branch",
3657
+ severity: "error",
3658
+ currentBranch: currentSymbolicBranch,
3659
+ defaultBranch
3660
+ };
3661
+ }
3662
+ return null;
3663
+ }
3322
3664
  // ../../packages/aeg-core/src/branch-topology-gate.ts
3323
3665
  function taskBranchTopologyFields(branch) {
3324
3666
  if (!/^task\/.*\/.*$/.test(branch))
@@ -3609,9 +3951,9 @@ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url)) {
3609
3951
 
3610
3952
  // src/lib/config.ts
3611
3953
  import { execFileSync as execFileSync2 } from "node:child_process";
3612
- import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
3954
+ import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
3613
3955
  import { homedir } from "node:os";
3614
- import { dirname as dirname3, join as join3 } from "node:path";
3956
+ import { dirname as dirname3, join as join3, resolve } from "node:path";
3615
3957
  import { z } from "zod";
3616
3958
 
3617
3959
  // src/lib/agent-vendors.ts
@@ -3700,8 +4042,15 @@ function isSafeRepoRelPath(p) {
3700
4042
  var SafeRepoRelPath = z.string().refine(isSafeRepoRelPath, {
3701
4043
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
3702
4044
  });
4045
+ var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
4046
+ function isCanonicalHookBlockPath(p) {
4047
+ return CANONICAL_HOOK_BLOCK_PREFIXES.some((prefix) => p.startsWith(prefix) && p.length > prefix.length);
4048
+ }
4049
+ var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
4050
+ message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
4051
+ });
3703
4052
  var ManagedBlockRecordSchema = z.object({
3704
- path: SafeRepoRelPath,
4053
+ path: ManagedHookBlockPath,
3705
4054
  marker: z.string(),
3706
4055
  comment: z.enum(["hash", "html"])
3707
4056
  });
@@ -3712,6 +4061,20 @@ var ManagedManifestSchema = z.object({
3712
4061
  labels: z.array(z.string()),
3713
4062
  agents: z.array(z.enum(AGENT_VENDORS)).optional()
3714
4063
  });
4064
+ var ProjectEntrySchema = z.object({
4065
+ name: z.string().min(1),
4066
+ description: z.string().min(1).optional(),
4067
+ path: z.string().min(1).optional()
4068
+ });
4069
+ function parseTokensCollectDeclaration(value) {
4070
+ const m = value.trim().match(/^(\S+)\s+(\S+)$/);
4071
+ if (!m)
4072
+ return null;
4073
+ const [, interpreter, script] = m;
4074
+ if (!isSafeRepoRelPath(script))
4075
+ return null;
4076
+ return { interpreter, script };
4077
+ }
3715
4078
  var VinayaConfigSchema = z.object({
3716
4079
  rings: z.object({
3717
4080
  ring1_forgeWriteInterception: z.boolean(),
@@ -3724,13 +4087,19 @@ var VinayaConfigSchema = z.object({
3724
4087
  principals: z.array(z.string()).min(1).optional(),
3725
4088
  releaseActor: z.string().min(1).optional(),
3726
4089
  ci: z.object({ setup: z.string().min(1) }).optional(),
4090
+ tokens: z.object({
4091
+ collect: z.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
4092
+ message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
4093
+ })
4094
+ }).optional(),
3727
4095
  blastRadius: z.object({ extraDomains: z.array(z.string()).optional() }).optional(),
3728
4096
  proseGates: z.object({
3729
4097
  doctrineRoot: z.string().min(1).optional(),
3730
4098
  readerFacingPrefix: z.string().min(1).optional(),
3731
4099
  readerFacingSuffix: z.string().min(1).optional(),
3732
4100
  legacySlugDir: z.string().min(1).optional()
3733
- }).optional()
4101
+ }).optional(),
4102
+ projects: z.array(ProjectEntrySchema).optional()
3734
4103
  });
3735
4104
  var GLOBAL_VINAYA_HOME = join3(homedir(), ".vinaya");
3736
4105
  var GLOBAL_CONFIG_PATH = join3(GLOBAL_VINAYA_HOME, "config.json");
@@ -3769,6 +4138,9 @@ function globalRolesIgnoredWarning(path) {
3769
4138
  function globalReleaseActorIgnoredWarning(path) {
3770
4139
  return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
3771
4140
  }
4141
+ function globalTokensCollectIgnoredWarning(path) {
4142
+ return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
4143
+ }
3772
4144
  function stripGlobalOnlyKeys(config, path) {
3773
4145
  if (path !== GLOBAL_CONFIG_PATH)
3774
4146
  return config;
@@ -3789,6 +4161,10 @@ function stripGlobalOnlyKeys(config, path) {
3789
4161
  console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
3790
4162
  result = { ...result, releaseActor: undefined };
3791
4163
  }
4164
+ if (result.tokens) {
4165
+ console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
4166
+ result = { ...result, tokens: undefined };
4167
+ }
3792
4168
  return result;
3793
4169
  }
3794
4170
  function resolvePrincipalAllowlist(config) {
@@ -3874,6 +4250,7 @@ function loadConfig() {
3874
4250
  return null;
3875
4251
  }
3876
4252
  }
4253
+ var TOKENS_COLLECT_TRUST_PATH = join3(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
3877
4254
 
3878
4255
  // src/checks/contract.ts
3879
4256
  var CHECK_SCHEMA_VERSION = 1;
@@ -3882,6 +4259,71 @@ function emitCheckError(error) {
3882
4259
  `);
3883
4260
  }
3884
4261
 
4262
+ // src/lib/diff-evidence.ts
4263
+ import { execFileSync as execFileSync3 } from "node:child_process";
4264
+ import { join as join4 } from "node:path";
4265
+ function fileDiffAgainst(ref, path) {
4266
+ let out;
4267
+ try {
4268
+ out = execFileSync3("git", ["diff", `${ref}...HEAD`, "--", path], {
4269
+ encoding: "utf8",
4270
+ stdio: ["ignore", "pipe", "pipe"]
4271
+ }).trim();
4272
+ } catch {
4273
+ return null;
4274
+ }
4275
+ return out === "" ? null : out;
4276
+ }
4277
+ function revParse(ref) {
4278
+ try {
4279
+ return execFileSync3("git", ["rev-parse", "--verify", ref], {
4280
+ encoding: "utf8",
4281
+ stdio: ["ignore", "pipe", "pipe"]
4282
+ }).trim();
4283
+ } catch {
4284
+ return null;
4285
+ }
4286
+ }
4287
+ function repoRoot() {
4288
+ try {
4289
+ return execFileSync3("git", ["rev-parse", "--show-toplevel"], {
4290
+ encoding: "utf8",
4291
+ stdio: ["ignore", "pipe", "pipe"]
4292
+ }).trim();
4293
+ } catch {
4294
+ return null;
4295
+ }
4296
+ }
4297
+ function changedFiles(base) {
4298
+ let out;
4299
+ try {
4300
+ out = execFileSync3("git", ["diff", "--name-only", `${base}...HEAD`], {
4301
+ encoding: "utf8",
4302
+ stdio: ["ignore", "pipe", "pipe"]
4303
+ }).trim();
4304
+ } catch {
4305
+ return null;
4306
+ }
4307
+ return out === "" ? [] : out.split(`
4308
+ `).map((s) => s.trim()).filter(Boolean);
4309
+ }
4310
+ function resolveChangedFiles(base = process.env.BASE_SHA || "origin/main") {
4311
+ const root = repoRoot();
4312
+ if (root === null)
4313
+ return null;
4314
+ const head = revParse("HEAD");
4315
+ for (const ref of [base, "main"]) {
4316
+ const resolved = revParse(ref);
4317
+ if (resolved === null || resolved === head)
4318
+ continue;
4319
+ const relPaths = changedFiles(ref);
4320
+ if (relPaths === null)
4321
+ continue;
4322
+ return relPaths.map((p) => join4(root, p));
4323
+ }
4324
+ return null;
4325
+ }
4326
+
3885
4327
  // src/checks/bin/check-reader-resolvable-prose.ts
3886
4328
  var CHECK_NAME = "reader-resolvable-prose";
3887
4329
  var proseGates = loadConfig()?.proseGates;
@@ -3898,7 +4340,7 @@ function collect(dir, out = []) {
3898
4340
  return out;
3899
4341
  }
3900
4342
  for (const name of entries) {
3901
- const full = join4(dir, name);
4343
+ const full = join5(dir, name);
3902
4344
  let isDir;
3903
4345
  try {
3904
4346
  isDir = statSync(full).isDirectory();
@@ -3934,14 +4376,18 @@ function main() {
3934
4376
  const shipsPaths = collect(DOCTRINE_ROOT).filter((p) => p.endsWith(".md"));
3935
4377
  const readerFacingPaths = READER_FACING_ACTIVE && READER_FACING_SUFFIX !== null ? collect(READER_FACING_PREFIX).filter((p) => p.endsWith(READER_FACING_SUFFIX)) : [];
3936
4378
  const files = readAll([...shipsPaths, ...readerFacingPaths]);
3937
- const glossaryPath = join4(DOCTRINE_ROOT, "glossary.md");
4379
+ const glossaryPath = join5(DOCTRINE_ROOT, "glossary.md");
3938
4380
  const glossaryTerms = existsSync4(glossaryPath) ? parseGlossaryTerms(readFileSync3(glossaryPath, "utf8")) : [];
3939
4381
  const { slugs, dormant: legacySlugsDormant } = legacySlugs();
3940
4382
  const readerFacingPrefix = READER_FACING_ACTIVE && READER_FACING_PREFIX !== null ? `${READER_FACING_PREFIX}/` : "/no-reader-facing-surface";
3941
4383
  const readerFacingSuffix = READER_FACING_ACTIVE && READER_FACING_SUFFIX !== null ? READER_FACING_SUFFIX : "/page.tsx";
3942
4384
  const findings = checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, slugs, shipsPrefix);
3943
- console.log(`${CHECK_NAME}: doctrine root "${DOCTRINE_ROOT}"; reader-facing class ${READER_FACING_ACTIVE ? "ran" : "dormant — proseGates.readerFacingPrefix/readerFacingSuffix not both set"}; ` + `legacy-slug class ${legacySlugsDormant ? `dormant — ${LEGACY_SLUG_DIR} is absent` : `ran (${slugs.length} slug(s))`}; ` + `${findings.length} finding(s)`);
3944
- for (const finding of findings) {
4385
+ const changedFilesList = resolveChangedFiles();
4386
+ const changed = changedFilesList === null ? null : new Set(changedFilesList);
4387
+ const pathBase = repoRoot() ?? process.cwd();
4388
+ const reportable = changed === null ? findings : findings.filter((f) => changed.has(resolve2(pathBase, f.file)));
4389
+ console.log(`${CHECK_NAME}: doctrine root "${DOCTRINE_ROOT}"; reader-facing class ${READER_FACING_ACTIVE ? "ran" : "dormant — proseGates.readerFacingPrefix/readerFacingSuffix not both set"}; ` + `legacy-slug class ${legacySlugsDormant ? `dormant — ${LEGACY_SLUG_DIR} is absent` : `ran (${slugs.length} slug(s))`}; ` + `${findings.length} finding(s) swept, ${reportable.length} in this diff`);
4390
+ for (const finding of reportable) {
3945
4391
  emitCheckError({
3946
4392
  schema: CHECK_SCHEMA_VERSION,
3947
4393
  check: CHECK_NAME,