@attalabs/vinaya 0.20.1 → 0.22.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 (152) hide show
  1. package/README.md +76 -1
  2. package/aeg-root/enforcement.md +15 -7
  3. package/aeg-root/milestone-model.md +3 -1
  4. package/aeg-root/roles/architect.md +2 -2
  5. package/aeg-root/roles/archivist.md +2 -2
  6. package/aeg-root/roles/developer.md +3 -2
  7. package/aeg-root/roles/planner.md +2 -2
  8. package/aeg-root/roles/principal.md +1 -0
  9. package/aeg-root/roles/tranche-archivist.md +2 -2
  10. package/aeg-root/templates/issue-rationale-template.md +4 -4
  11. package/aeg-root/templates/pr-report-template.md +2 -0
  12. package/aeg-root/tranche-model.md +4 -4
  13. package/dist/checks/bin/check-body-bare-digits.js +392 -10
  14. package/dist/checks/bin/check-branch-topology.js +382 -2
  15. package/dist/checks/bin/check-brief-shape.js +357 -2
  16. package/dist/checks/bin/check-changeset-coverage.js +4262 -0
  17. package/dist/checks/bin/check-closes-n.js +382 -2
  18. package/dist/checks/bin/check-coherence.js +416 -8
  19. package/dist/checks/bin/check-dead-branch-push.js +357 -2
  20. package/dist/checks/bin/check-dispatch-readiness.js +492 -25
  21. package/dist/checks/bin/check-doc-coverage-push.js +392 -9
  22. package/dist/checks/bin/check-doc-coverage.js +392 -9
  23. package/dist/checks/bin/check-doctrine-portability.js +391 -8
  24. package/dist/checks/bin/check-evidence-fresh.js +357 -2
  25. package/dist/checks/bin/check-first-push-dispatch.js +481 -17
  26. package/dist/checks/bin/check-issue-assignment.js +382 -2
  27. package/dist/checks/bin/check-main-branch-refusal.js +357 -2
  28. package/dist/checks/bin/check-no-disk-state.js +357 -2
  29. package/dist/checks/bin/check-quoted-command.js +4514 -0
  30. package/dist/checks/bin/check-reader-resolvable-prose.js +430 -21
  31. package/dist/checks/bin/check-registry-gates.js +410 -7
  32. package/dist/checks/bin/check-retired-vocabulary.js +422 -13
  33. package/dist/checks/bin/check-review-gate.js +389 -6
  34. package/dist/checks/bin/check-single-plan-pr.js +357 -2
  35. package/dist/checks/bin/check-test-plan.js +357 -2
  36. package/dist/checks/bin/check-token-collection-wired.js +4081 -0
  37. package/dist/checks/bin/check-token-report.js +4096 -0
  38. package/dist/checks/bin/check-workspace-escape.js +359 -4
  39. package/dist/index.js +1607 -641
  40. package/package.json +1 -1
  41. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  42. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  43. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  44. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  45. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  46. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  47. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  48. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  49. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  50. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  51. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  52. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js +2 -2
  53. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  54. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  55. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  56. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  57. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js +2 -2
  58. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  59. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  60. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  61. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +2 -2
  62. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  63. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  64. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  65. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +3 -3
  66. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +3 -3
  70. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +2 -2
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +3 -3
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +3 -3
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +3 -3
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +2 -2
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +1 -1
  89. 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
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0053k9k._.js +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0112h-k._.js +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__02c71kv._.js +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__040smoa._.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__16cuydh._.js → [root-of-the-server]__069-_41._.js} +1 -1
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0cxtq46._.js +25 -18
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0o771t1._.js +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0puovz5._.js +1 -1
  98. 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
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__18kqy4q._.js +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1hs0dcu._.js +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1widio3._.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1yoa8tx._.js +3 -0
  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/_0o54suy._.js +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0wxycau._.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0x999pb._.js +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-6rzip._.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1fqw88f._.js +2 -2
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_0zys35s._.js → _1mqrlbl._.js} +2 -2
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_1c9b9j-._.js → _1mrtj0f._.js} +2 -2
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1n0cnq-._.js +1 -1
  116. 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
  117. 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
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_1vo08dj._.js +2 -2
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_animate_components_index_ts_186fje1._.js +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_brutal_components_index_ts_0n_lcc4._.js +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_retro_components_index_ts_0wvpm_z._.js +1 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_retro_components_index_ts_1_cfi48._.js +1 -1
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +3 -3
  127. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/00pi8vhg8w6gi.js +1 -0
  128. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/03q0q9n6-xah8.js +1 -0
  129. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vc2u252q5q6o.js +1 -0
  130. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/13g16cu00g570.js +1 -0
  131. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1lk7h-0buf4ab.js → 1hufpuody6vjv.js} +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1sfxfunirkcr6.js +1 -0
  133. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{29-foak16tjfu.js → 206ajg8f1a-_h.js} +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0ea8-8nopz29h.js → 267o-tsrnuwnv.js} +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0msr2a1i-x-br.js → 279qq4twinc97.js} +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{112g08xpx3kro.js → 2ka8dg687auhj.js} +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0up5x3jg-cwov.js → 2rn89uwtf2lwc.js} +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2twnwe77d4n-m.js → 37hnluhzj9bei.js} +4 -4
  139. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3qc67qhcvbg0o.css +1 -0
  140. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{30ojnsx3p4lp4.js → 3zugx9esh2x51.js} +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1rku4gz._.js +0 -3
  143. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0_jnwbarv-cqk.js +0 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0la0hhmjprdxm.css +0 -1
  145. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/25j-y57ng11hl.js +0 -1
  146. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/30lyvn0yzwdiz.js +0 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/35u8inxa732is.js +0 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3r5efmleneaco.js +0 -1
  149. /package/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  150. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{b2VfZK2AItZwlghK_pUN0 → Fmyc42qzLwFcWWHLLNy-G}/_buildManifest.js +0 -0
  151. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{b2VfZK2AItZwlghK_pUN0 → Fmyc42qzLwFcWWHLLNy-G}/_clientMiddlewareManifest.js +0 -0
  152. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{b2VfZK2AItZwlghK_pUN0 → Fmyc42qzLwFcWWHLLNy-G}/_ssgManifest.js +0 -0
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/checks/bin/check-reader-resolvable-prose.ts
4
- import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync3, statSync } from "node:fs";
5
- import { join as join5, resolve } from "node:path";
4
+ import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync4, statSync } from "node:fs";
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
8
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -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 === "–";
@@ -1786,6 +1792,257 @@ var DERIVED_STATUSES = [
1786
1792
  "incoherent"
1787
1793
  ];
1788
1794
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1795
+ // ../../packages/aeg-core/src/parse-ledger.ts
1796
+ function rowFromCells(cells) {
1797
+ if (cells.length < 7)
1798
+ return null;
1799
+ const phase = (cells[0] ?? "").trim();
1800
+ if (!phase)
1801
+ return null;
1802
+ return {
1803
+ phase,
1804
+ role: (cells[1] ?? "").trim(),
1805
+ agentModel: (cells[2] ?? "").trim(),
1806
+ tokensIn: parseIntCell(cells[3] ?? ""),
1807
+ tokensOut: parseIntCell(cells[4] ?? ""),
1808
+ cost: parseCostCell(cells[5] ?? ""),
1809
+ date: (cells[6] ?? "").trim()
1810
+ };
1811
+ }
1812
+ function parseIntCell(cell) {
1813
+ const trimmed = cell.replace(/`/g, "").trim();
1814
+ if (!trimmed || isEmDashOrDash(trimmed))
1815
+ return null;
1816
+ const normalized = trimmed.replace(/[,_\s]/g, "");
1817
+ if (!/^-?\d+$/.test(normalized))
1818
+ return null;
1819
+ return Number(normalized);
1820
+ }
1821
+ function parseCostCell(cell) {
1822
+ const trimmed = cell.replace(/`/g, "").trim();
1823
+ if (!trimmed || isEmDashOrDash(trimmed))
1824
+ return null;
1825
+ const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1826
+ if (!/^-?\d+(\.\d+)?$/.test(normalized))
1827
+ return null;
1828
+ return Number(normalized);
1829
+ }
1830
+ function isEmDashOrDash(s) {
1831
+ const t = s.trim();
1832
+ return t === "—" || t === "-" || t === "–";
1833
+ }
1834
+ // ../../packages/aeg-core/src/parse-token-report.ts
1835
+ var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1836
+ var INLINE_FIELD_LIST = /Phase:\s*([^|]+?)\s*\|\s*Role:\s*([^|]+?)\s*\|\s*Agent\/Model:\s*([^|]+?)\s*\|\s*Tokens in:\s*([^|]+?)\s*\|\s*Tokens out:\s*([^|]+?)\s*\|\s*Cost:\s*([^|]+?)\s*\|\s*Date:\s*(.+?)\s*$/im;
1837
+ function parseTokenReportEntries(body) {
1838
+ const lines = body.split(/\r?\n/);
1839
+ const headingIdxs = [];
1840
+ lines.forEach((line, i) => {
1841
+ if (TOKEN_REPORT_HEADING.test(line))
1842
+ headingIdxs.push(i);
1843
+ });
1844
+ const out = [];
1845
+ for (let h = 0;h < headingIdxs.length; h++) {
1846
+ const start = headingIdxs[h] + 1;
1847
+ const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1848
+ const section = lines.slice(start, end).join(`
1849
+ `);
1850
+ const tableRows = parseTableSection(section);
1851
+ if (tableRows.length > 0) {
1852
+ out.push(...tableRows);
1853
+ continue;
1854
+ }
1855
+ const inlineRow = parseInlineFieldList(section);
1856
+ if (inlineRow)
1857
+ out.push(inlineRow);
1858
+ }
1859
+ return out;
1860
+ }
1861
+ function parseTableSection(section) {
1862
+ const lines = section.split(/\r?\n/);
1863
+ let i = 0;
1864
+ for (;i < lines.length; i++) {
1865
+ if ((lines[i] ?? "").trim().startsWith("|"))
1866
+ break;
1867
+ }
1868
+ if (i + 1 >= lines.length)
1869
+ return [];
1870
+ i += 2;
1871
+ const out = [];
1872
+ for (;i < lines.length; i++) {
1873
+ const trimmed = (lines[i] ?? "").trim();
1874
+ if (!trimmed.startsWith("|"))
1875
+ break;
1876
+ const row = rowFromCells(splitTableRow(trimmed));
1877
+ if (row)
1878
+ out.push(row);
1879
+ }
1880
+ return out;
1881
+ }
1882
+ function parseInlineFieldList(section) {
1883
+ const m = section.match(INLINE_FIELD_LIST);
1884
+ if (!m)
1885
+ return null;
1886
+ return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
1887
+ }
1888
+ // ../../packages/aeg-core/src/report-tokens.ts
1889
+ var DASH_LOOKALIKES = {
1890
+ "-": "‑",
1891
+ "–": "‒",
1892
+ "—": "―"
1893
+ };
1894
+ var DASH_CHARS = new Set(Object.keys(DASH_LOOKALIKES));
1895
+ // ../../packages/aeg-core/src/claude-code-transcript.ts
1896
+ import { createHash } from "node:crypto";
1897
+ function summarizeTranscript(jsonl) {
1898
+ const seen = new Set;
1899
+ const components = {
1900
+ inputTokens: 0,
1901
+ outputTokens: 0,
1902
+ cacheCreationInputTokens: 0,
1903
+ cacheReadInputTokens: 0
1904
+ };
1905
+ let model = null;
1906
+ let messageCount = 0;
1907
+ for (const rawLine of jsonl.split(/\r?\n/)) {
1908
+ const line = rawLine.trim();
1909
+ if (!line)
1910
+ continue;
1911
+ let entry2;
1912
+ try {
1913
+ entry2 = JSON.parse(line);
1914
+ } catch {
1915
+ continue;
1916
+ }
1917
+ if (!entry2 || typeof entry2 !== "object")
1918
+ continue;
1919
+ const obj = entry2;
1920
+ if (obj.type !== "assistant")
1921
+ continue;
1922
+ const message = obj.message;
1923
+ const id = message?.id;
1924
+ const usage = message?.usage;
1925
+ if (typeof id !== "string" || !id || !usage || seen.has(id))
1926
+ continue;
1927
+ seen.add(id);
1928
+ messageCount++;
1929
+ components.inputTokens += numberOr(usage.input_tokens, 0);
1930
+ components.outputTokens += numberOr(usage.output_tokens, 0);
1931
+ components.cacheCreationInputTokens += numberOr(usage.cache_creation_input_tokens, 0);
1932
+ components.cacheReadInputTokens += numberOr(usage.cache_read_input_tokens, 0);
1933
+ const messageModel = message?.model;
1934
+ if (typeof messageModel === "string" && messageModel)
1935
+ model = messageModel;
1936
+ }
1937
+ return { components, model, messageCount };
1938
+ }
1939
+ function numberOr(value, fallback) {
1940
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
1941
+ }
1942
+ function sanitizeKey(value) {
1943
+ return value.replace(/[^A-Za-z0-9]+/g, "-");
1944
+ }
1945
+ function collisionResistantKey(value) {
1946
+ const digest = createHash("sha256").update(value).digest("hex");
1947
+ return `${sanitizeKey(value)}-${digest}`;
1948
+ }
1949
+ function transcriptPointerPath(projectDir, tmpDir) {
1950
+ return `${tmpDir}/claude-transcript-${collisionResistantKey(projectDir)}.txt`;
1951
+ }
1952
+ function legacyTranscriptPointerPath(projectDir, tmpDir) {
1953
+ return `${tmpDir}/claude-transcript-${sanitizeKey(projectDir)}.txt`;
1954
+ }
1955
+ function resolvePointer(explicitTranscriptPath, deps) {
1956
+ if (explicitTranscriptPath)
1957
+ return { path: explicitTranscriptPath, corroborated: true };
1958
+ const projectDir = deps.env.CLAUDE_PROJECT_DIR ?? deps.cwd;
1959
+ const tmpDir = deps.env.TMPDIR ?? "/tmp";
1960
+ const primaryPointerPath = transcriptPointerPath(projectDir, tmpDir);
1961
+ const legacyPointerPath = legacyTranscriptPointerPath(projectDir, tmpDir);
1962
+ const currentSessionId = deps.env.CLAUDE_CODE_SESSION_ID;
1963
+ const pointerPath = deps.exists(primaryPointerPath) ? primaryPointerPath : deps.exists(legacyPointerPath) ? legacyPointerPath : undefined;
1964
+ if (!pointerPath) {
1965
+ return {
1966
+ pointerExisted: false,
1967
+ corroborated: false,
1968
+ error: `No transcript pointer at ${primaryPointerPath} (nor its pre-migration name ${legacyPointerPath}) ` + "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."
1969
+ };
1970
+ }
1971
+ let contents;
1972
+ try {
1973
+ contents = deps.readFile(pointerPath).replace(/\r?\n+$/, "");
1974
+ } catch (err) {
1975
+ return {
1976
+ pointerExisted: true,
1977
+ oursByLocation: true,
1978
+ 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."
1979
+ };
1980
+ }
1981
+ const [pointerSessionId, transcriptPath] = contents.split("\t");
1982
+ if (!transcriptPath) {
1983
+ return {
1984
+ pointerExisted: true,
1985
+ oursByLocation: true,
1986
+ 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."
1987
+ };
1988
+ }
1989
+ if (currentSessionId && pointerSessionId && currentSessionId !== pointerSessionId) {
1990
+ return {
1991
+ pointerExisted: true,
1992
+ corroborated: false,
1993
+ 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."
1994
+ };
1995
+ }
1996
+ return { path: transcriptPath, corroborated: Boolean(currentSessionId && pointerSessionId) };
1997
+ }
1998
+ function resolveMeteringCapability(deps, explicitTranscriptPath) {
1999
+ const resolved = resolvePointer(explicitTranscriptPath, deps);
2000
+ if ("error" in resolved) {
2001
+ const ours = resolved.pointerExisted && (resolved.corroborated || resolved.oursByLocation);
2002
+ if (ours)
2003
+ return { capable: false, reason: "pointer-unusable", detail: resolved.error };
2004
+ return {
2005
+ capable: false,
2006
+ reason: "no-transcript-resolved",
2007
+ 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
2008
+ };
2009
+ }
2010
+ const downstream = (r, detail) => resolved.corroborated ? { reason: r, detail } : {
2011
+ reason: "no-transcript-resolved",
2012
+ 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})`
2013
+ };
2014
+ if (!deps.exists(resolved.path)) {
2015
+ return {
2016
+ capable: false,
2017
+ ...downstream("transcript-unreadable", `Resolved transcript path ${resolved.path} is not readable as a regular file owned by this user.`)
2018
+ };
2019
+ }
2020
+ let jsonl;
2021
+ try {
2022
+ jsonl = deps.readFile(resolved.path);
2023
+ } catch (err) {
2024
+ return {
2025
+ capable: false,
2026
+ ...downstream("transcript-unreadable", `Transcript at ${resolved.path} could not be read: ${err.message}`)
2027
+ };
2028
+ }
2029
+ const summary = summarizeTranscript(jsonl);
2030
+ if (summary.messageCount === 0) {
2031
+ return {
2032
+ capable: false,
2033
+ ...downstream("transcript-empty", `Transcript at ${resolved.path} yielded zero assistant messages with usage data — ` + "it's empty, unparseable, or not yet flushed to disk.")
2034
+ };
2035
+ }
2036
+ return { capable: true, transcriptPath: resolved.path, summary };
2037
+ }
2038
+ function isTokenCollectionWiringBroken(capability) {
2039
+ if (capability.capable)
2040
+ return false;
2041
+ return capability.reason !== "no-transcript-resolved";
2042
+ }
2043
+ // ../../packages/aeg-core/src/metering-io-guard.ts
2044
+ import { closeSync, constants as fsConstants, fstatSync, openSync, readFileSync } from "node:fs";
2045
+ var GUARD_OPEN_FLAGS = fsConstants.O_RDONLY | fsConstants.O_NONBLOCK | fsConstants.O_NOFOLLOW;
1789
2046
  // ../../packages/aeg-core/src/file-classify.ts
1790
2047
  function isCodeFile(p) {
1791
2048
  if (p.endsWith(".md"))
@@ -1992,7 +2249,7 @@ function overrideActive(opts) {
1992
2249
  return false;
1993
2250
  }
1994
2251
  // ../../packages/aeg-core/src/premise-check.ts
1995
- import { createHash } from "node:crypto";
2252
+ import { createHash as createHash2 } from "node:crypto";
1996
2253
  var ASSERTION_KINDS = new Set(["contains", "absent", "sha256"]);
1997
2254
  function isPremiseHeader(line) {
1998
2255
  const stripped = line.replace(/[*#]/g, "").trim();
@@ -2037,7 +2294,7 @@ function checkPremises(assertions, fileReader) {
2037
2294
  } else if (a.kind === "absent" && content.includes(a.value)) {
2038
2295
  failures.push(`premise-check: ${a.path} now contains "${a.value}", but the brief pinned it absent — the premise has moved; re-dig before proceeding.`);
2039
2296
  } else if (a.kind === "sha256") {
2040
- const actual = createHash("sha256").update(content).digest("hex");
2297
+ const actual = createHash2("sha256").update(content).digest("hex");
2041
2298
  if (actual !== a.value.toLowerCase()) {
2042
2299
  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.`);
2043
2300
  }
@@ -3217,6 +3474,100 @@ function parseGlossaryTerms(glossaryContent) {
3217
3474
  }
3218
3475
  return terms;
3219
3476
  }
3477
+ // ../../packages/aeg-core/src/quoted-command.ts
3478
+ var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3479
+ var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3480
+ var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
3481
+ var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
3482
+ function isValidCitedFilePath(path) {
3483
+ if (path.length === 0)
3484
+ return false;
3485
+ if (path.startsWith("/") || path.startsWith("\\"))
3486
+ return false;
3487
+ if (/^[A-Za-z]:[\\/]/.test(path))
3488
+ return false;
3489
+ return !path.split(/[\\/]+/).includes("..");
3490
+ }
3491
+ function quotedCommandLineAt(content, index) {
3492
+ let line = 1;
3493
+ for (let i = 0;i < index; i++) {
3494
+ if (content.charCodeAt(i) === 10)
3495
+ line++;
3496
+ }
3497
+ return line;
3498
+ }
3499
+ function extractQuotedText(raw) {
3500
+ const trimmed = raw.trim();
3501
+ const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
3502
+ if (fenced)
3503
+ return (fenced[1] ?? "").trim();
3504
+ const inline = /^`([^`]+)`$/.exec(trimmed);
3505
+ if (inline)
3506
+ return (inline[1] ?? "").trim();
3507
+ return trimmed;
3508
+ }
3509
+ function findQuotesInFile(path, content) {
3510
+ const masked = maskCode(content);
3511
+ const quotes = [];
3512
+ START_PATTERN.lastIndex = 0;
3513
+ let start = START_PATTERN.exec(masked);
3514
+ while (start !== null) {
3515
+ const citedFile = start[1];
3516
+ const innerStart = start.index + start[0].length;
3517
+ const end = END_PATTERN.exec(masked.slice(innerStart));
3518
+ if (end === null) {
3519
+ START_PATTERN.lastIndex = innerStart;
3520
+ start = START_PATTERN.exec(masked);
3521
+ continue;
3522
+ }
3523
+ const innerEnd = innerStart + end.index;
3524
+ if (isValidCitedFilePath(citedFile)) {
3525
+ const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
3526
+ if (quotedText.length > 0) {
3527
+ quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
3528
+ }
3529
+ }
3530
+ START_PATTERN.lastIndex = innerEnd + end[0].length;
3531
+ start = START_PATTERN.exec(masked);
3532
+ }
3533
+ return quotes;
3534
+ }
3535
+ function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
3536
+ const quotes = [];
3537
+ for (const file of files) {
3538
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3539
+ if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
3540
+ continue;
3541
+ quotes.push(...findQuotesInFile(file.path, file.content));
3542
+ }
3543
+ return quotes;
3544
+ }
3545
+ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3546
+ const findings = [];
3547
+ for (const quote of citedQuotes) {
3548
+ const content = citedFileContents.get(quote.citedFile);
3549
+ if (content === undefined) {
3550
+ findings.push({
3551
+ file: quote.file,
3552
+ line: quote.line,
3553
+ citedFile: quote.citedFile,
3554
+ quotedText: quote.quotedText,
3555
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
3556
+ });
3557
+ continue;
3558
+ }
3559
+ if (!content.includes(quote.quotedText)) {
3560
+ findings.push({
3561
+ file: quote.file,
3562
+ line: quote.line,
3563
+ citedFile: quote.citedFile,
3564
+ quotedText: quote.quotedText,
3565
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
3566
+ });
3567
+ }
3568
+ }
3569
+ return findings;
3570
+ }
3220
3571
  // ../../packages/aeg-core/src/retired-vocabulary.ts
3221
3572
  var RETIRED_PATTERNS = [
3222
3573
  String.raw`\bD-[0-9]{3}\b`,
@@ -3330,6 +3681,10 @@ function checkDispatchReadiness(input) {
3330
3681
  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.`);
3331
3682
  }
3332
3683
  for (const dep of input.dependsOn) {
3684
+ if (dep.resolved === false) {
3685
+ 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.`);
3686
+ continue;
3687
+ }
3333
3688
  if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
3334
3689
  const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
3335
3690
  blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
@@ -3666,7 +4021,7 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
3666
4021
  return findings;
3667
4022
  }
3668
4023
  // src/commands/doctrine.ts
3669
- import { existsSync as existsSync2, readdirSync, readFileSync } from "node:fs";
4024
+ import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "node:fs";
3670
4025
  import { dirname as dirname2, join as join2, sep } from "node:path";
3671
4026
  import matter2 from "gray-matter";
3672
4027
 
@@ -3694,17 +4049,20 @@ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url)) {
3694
4049
  if (!pkg.split(sep).includes("node_modules"))
3695
4050
  candidates.push(join2(dirname2(dirname2(pkg)), "aeg-root"));
3696
4051
  for (const root of candidates) {
3697
- if (existsSync2(join2(root, ...ENTRY_SEGMENTS)))
4052
+ if (hasDoctrineEntry(root))
3698
4053
  return root;
3699
4054
  }
3700
4055
  return null;
3701
4056
  }
4057
+ function hasDoctrineEntry(root) {
4058
+ return existsSync2(join2(root, ...ENTRY_SEGMENTS));
4059
+ }
3702
4060
 
3703
4061
  // src/lib/config.ts
3704
4062
  import { execFileSync as execFileSync2 } from "node:child_process";
3705
- import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
4063
+ import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
3706
4064
  import { homedir } from "node:os";
3707
- import { dirname as dirname3, join as join3 } from "node:path";
4065
+ import { dirname as dirname3, join as join3, resolve } from "node:path";
3708
4066
  import { z } from "zod";
3709
4067
 
3710
4068
  // src/lib/agent-vendors.ts
@@ -3812,6 +4170,20 @@ var ManagedManifestSchema = z.object({
3812
4170
  labels: z.array(z.string()),
3813
4171
  agents: z.array(z.enum(AGENT_VENDORS)).optional()
3814
4172
  });
4173
+ var ProjectEntrySchema = z.object({
4174
+ name: z.string().min(1),
4175
+ description: z.string().min(1).optional(),
4176
+ path: z.string().min(1).optional()
4177
+ });
4178
+ function parseTokensCollectDeclaration(value) {
4179
+ const m = value.trim().match(/^(\S+)\s+(\S+)$/);
4180
+ if (!m)
4181
+ return null;
4182
+ const [, interpreter, script] = m;
4183
+ if (!isSafeRepoRelPath(script))
4184
+ return null;
4185
+ return { interpreter, script };
4186
+ }
3815
4187
  var VinayaConfigSchema = z.object({
3816
4188
  rings: z.object({
3817
4189
  ring1_forgeWriteInterception: z.boolean(),
@@ -3824,13 +4196,19 @@ var VinayaConfigSchema = z.object({
3824
4196
  principals: z.array(z.string()).min(1).optional(),
3825
4197
  releaseActor: z.string().min(1).optional(),
3826
4198
  ci: z.object({ setup: z.string().min(1) }).optional(),
4199
+ tokens: z.object({
4200
+ collect: z.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
4201
+ message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
4202
+ })
4203
+ }).optional(),
3827
4204
  blastRadius: z.object({ extraDomains: z.array(z.string()).optional() }).optional(),
3828
4205
  proseGates: z.object({
3829
4206
  doctrineRoot: z.string().min(1).optional(),
3830
4207
  readerFacingPrefix: z.string().min(1).optional(),
3831
4208
  readerFacingSuffix: z.string().min(1).optional(),
3832
4209
  legacySlugDir: z.string().min(1).optional()
3833
- }).optional()
4210
+ }).optional(),
4211
+ projects: z.array(ProjectEntrySchema).optional()
3834
4212
  });
3835
4213
  var GLOBAL_VINAYA_HOME = join3(homedir(), ".vinaya");
3836
4214
  var GLOBAL_CONFIG_PATH = join3(GLOBAL_VINAYA_HOME, "config.json");
@@ -3869,6 +4247,9 @@ function globalRolesIgnoredWarning(path) {
3869
4247
  function globalReleaseActorIgnoredWarning(path) {
3870
4248
  return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
3871
4249
  }
4250
+ function globalTokensCollectIgnoredWarning(path) {
4251
+ return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
4252
+ }
3872
4253
  function stripGlobalOnlyKeys(config, path) {
3873
4254
  if (path !== GLOBAL_CONFIG_PATH)
3874
4255
  return config;
@@ -3889,6 +4270,10 @@ function stripGlobalOnlyKeys(config, path) {
3889
4270
  console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
3890
4271
  result = { ...result, releaseActor: undefined };
3891
4272
  }
4273
+ if (result.tokens) {
4274
+ console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
4275
+ result = { ...result, tokens: undefined };
4276
+ }
3892
4277
  return result;
3893
4278
  }
3894
4279
  function resolvePrincipalAllowlist(config) {
@@ -3968,12 +4353,13 @@ function loadConfig() {
3968
4353
  if (!path)
3969
4354
  return null;
3970
4355
  try {
3971
- const raw = JSON.parse(readFileSync2(path, "utf-8"));
4356
+ const raw = JSON.parse(readFileSync3(path, "utf-8"));
3972
4357
  return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
3973
4358
  } catch {
3974
4359
  return null;
3975
4360
  }
3976
4361
  }
4362
+ var TOKENS_COLLECT_TRUST_PATH = join3(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
3977
4363
 
3978
4364
  // src/checks/contract.ts
3979
4365
  var CHECK_SCHEMA_VERSION = 1;
@@ -4050,11 +4436,22 @@ function resolveChangedFiles(base = process.env.BASE_SHA || "origin/main") {
4050
4436
  // src/checks/bin/check-reader-resolvable-prose.ts
4051
4437
  var CHECK_NAME = "reader-resolvable-prose";
4052
4438
  var proseGates = loadConfig()?.proseGates;
4053
- var DOCTRINE_ROOT = proseGates?.doctrineRoot ?? resolveDoctrineRoot() ?? "aeg-root";
4439
+ function resolveCheckDoctrineRoot() {
4440
+ if (proseGates?.doctrineRoot !== undefined)
4441
+ return proseGates.doctrineRoot;
4442
+ const root = repoRoot();
4443
+ if (root !== null) {
4444
+ const candidate = join5(root, "aeg-root");
4445
+ if (hasDoctrineEntry(candidate))
4446
+ return candidate;
4447
+ }
4448
+ return resolveDoctrineRoot();
4449
+ }
4450
+ var DOCTRINE_ROOT = resolveCheckDoctrineRoot();
4054
4451
  var READER_FACING_PREFIX = proseGates?.readerFacingPrefix ?? null;
4055
4452
  var READER_FACING_SUFFIX = proseGates?.readerFacingSuffix ?? null;
4056
4453
  var READER_FACING_ACTIVE = READER_FACING_PREFIX !== null && READER_FACING_SUFFIX !== null;
4057
- var LEGACY_SLUG_DIR = proseGates?.legacySlugDir ?? `${DOCTRINE_ROOT}/tranches/completed`;
4454
+ var LEGACY_SLUG_DIR = proseGates?.legacySlugDir ?? (DOCTRINE_ROOT === null ? null : `${DOCTRINE_ROOT}/tranches/completed`);
4058
4455
  function collect(dir, out = []) {
4059
4456
  let entries;
4060
4457
  try {
@@ -4081,35 +4478,47 @@ function collect(dir, out = []) {
4081
4478
  return out;
4082
4479
  }
4083
4480
  function readAll(paths) {
4084
- return paths.map((p) => ({ path: p, content: readFileSync3(p, "utf8") }));
4481
+ return paths.map((p) => ({ path: p, content: readFileSync4(p, "utf8") }));
4085
4482
  }
4086
- function legacySlugs() {
4087
- if (!existsSync4(LEGACY_SLUG_DIR))
4483
+ function legacySlugs(legacySlugDir) {
4484
+ if (!existsSync4(legacySlugDir))
4088
4485
  return { slugs: [], dormant: true };
4089
4486
  try {
4090
- const slugs = readdirSync2(LEGACY_SLUG_DIR).filter((f) => f.endsWith(".md") && !f.endsWith(".tokens.md")).map((f) => f.slice(0, -3)).filter((slug) => !/-v[0-9]+$/.test(slug));
4487
+ const slugs = readdirSync2(legacySlugDir).filter((f) => f.endsWith(".md") && !f.endsWith(".tokens.md")).map((f) => f.slice(0, -3)).filter((slug) => !/-v[0-9]+$/.test(slug));
4091
4488
  return { slugs, dormant: false };
4092
4489
  } catch (err) {
4093
- console.log(`${CHECK_NAME}: could not read ${LEGACY_SLUG_DIR} (${err instanceof Error ? err.message : String(err)}) — legacy-slug class treated as dormant.`);
4490
+ console.log(`${CHECK_NAME}: could not read ${legacySlugDir} (${err instanceof Error ? err.message : String(err)}) — legacy-slug class treated as dormant.`);
4094
4491
  return { slugs: [], dormant: true };
4095
4492
  }
4096
4493
  }
4097
4494
  function main() {
4495
+ if (DOCTRINE_ROOT === null) {
4496
+ console.log(`${CHECK_NAME}: doctrine root unresolvable — sweep did not run.`);
4497
+ emitCheckError({
4498
+ schema: CHECK_SCHEMA_VERSION,
4499
+ check: CHECK_NAME,
4500
+ severity: "error",
4501
+ message: "doctrine root unresolvable: no aeg-root found at the repo root under check, and no bundled copy found " + "relative to this package's own install.",
4502
+ agent_recovery_prompt: "Set proseGates.doctrineRoot in vinaya.config.json to the doctrine tree this repo actually uses, or " + "confirm aeg-root/ exists at the repo root (or that this package's own bundled aeg-root/ is present)."
4503
+ });
4504
+ process.exit(2);
4505
+ }
4098
4506
  const shipsPrefix = `${DOCTRINE_ROOT}/`;
4099
4507
  const shipsPaths = collect(DOCTRINE_ROOT).filter((p) => p.endsWith(".md"));
4100
4508
  const readerFacingPaths = READER_FACING_ACTIVE && READER_FACING_SUFFIX !== null ? collect(READER_FACING_PREFIX).filter((p) => p.endsWith(READER_FACING_SUFFIX)) : [];
4101
4509
  const files = readAll([...shipsPaths, ...readerFacingPaths]);
4102
4510
  const glossaryPath = join5(DOCTRINE_ROOT, "glossary.md");
4103
- const glossaryTerms = existsSync4(glossaryPath) ? parseGlossaryTerms(readFileSync3(glossaryPath, "utf8")) : [];
4104
- const { slugs, dormant: legacySlugsDormant } = legacySlugs();
4511
+ const glossaryTerms = existsSync4(glossaryPath) ? parseGlossaryTerms(readFileSync4(glossaryPath, "utf8")) : [];
4512
+ const legacySlugDir = LEGACY_SLUG_DIR ?? `${DOCTRINE_ROOT}/tranches/completed`;
4513
+ const { slugs, dormant: legacySlugsDormant } = legacySlugs(legacySlugDir);
4105
4514
  const readerFacingPrefix = READER_FACING_ACTIVE && READER_FACING_PREFIX !== null ? `${READER_FACING_PREFIX}/` : "/no-reader-facing-surface";
4106
4515
  const readerFacingSuffix = READER_FACING_ACTIVE && READER_FACING_SUFFIX !== null ? READER_FACING_SUFFIX : "/page.tsx";
4107
4516
  const findings = checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, slugs, shipsPrefix);
4108
4517
  const changedFilesList = resolveChangedFiles();
4109
4518
  const changed = changedFilesList === null ? null : new Set(changedFilesList);
4110
4519
  const pathBase = repoRoot() ?? process.cwd();
4111
- const reportable = changed === null ? findings : findings.filter((f) => changed.has(resolve(pathBase, f.file)));
4112
- 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`);
4520
+ const reportable = changed === null ? findings : findings.filter((f) => changed.has(resolve2(pathBase, f.file)));
4521
+ 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 — ${legacySlugDir} is absent` : `ran (${slugs.length} slug(s))`}; ` + `${findings.length} finding(s) swept, ${reportable.length} in this diff`);
4113
4522
  for (const finding of reportable) {
4114
4523
  emitCheckError({
4115
4524
  schema: CHECK_SCHEMA_VERSION,