@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
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/checks/bin/check-doc-coverage.ts
4
4
  import { execFileSync as execFileSync4 } from "node:child_process";
5
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
5
+ import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
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.`);
@@ -3739,9 +4094,9 @@ function emitCheckError(error) {
3739
4094
 
3740
4095
  // src/lib/config.ts
3741
4096
  import { execFileSync as execFileSync3 } from "node:child_process";
3742
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4097
+ import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
3743
4098
  import { homedir } from "node:os";
3744
- import { dirname, join as join2 } from "node:path";
4099
+ import { dirname, join as join2, resolve } from "node:path";
3745
4100
  import { z } from "zod";
3746
4101
 
3747
4102
  // src/lib/agent-vendors.ts
@@ -3849,6 +4204,20 @@ var ManagedManifestSchema = z.object({
3849
4204
  labels: z.array(z.string()),
3850
4205
  agents: z.array(z.enum(AGENT_VENDORS)).optional()
3851
4206
  });
4207
+ var ProjectEntrySchema = z.object({
4208
+ name: z.string().min(1),
4209
+ description: z.string().min(1).optional(),
4210
+ path: z.string().min(1).optional()
4211
+ });
4212
+ function parseTokensCollectDeclaration(value) {
4213
+ const m = value.trim().match(/^(\S+)\s+(\S+)$/);
4214
+ if (!m)
4215
+ return null;
4216
+ const [, interpreter, script] = m;
4217
+ if (!isSafeRepoRelPath(script))
4218
+ return null;
4219
+ return { interpreter, script };
4220
+ }
3852
4221
  var VinayaConfigSchema = z.object({
3853
4222
  rings: z.object({
3854
4223
  ring1_forgeWriteInterception: z.boolean(),
@@ -3861,13 +4230,19 @@ var VinayaConfigSchema = z.object({
3861
4230
  principals: z.array(z.string()).min(1).optional(),
3862
4231
  releaseActor: z.string().min(1).optional(),
3863
4232
  ci: z.object({ setup: z.string().min(1) }).optional(),
4233
+ tokens: z.object({
4234
+ collect: z.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
4235
+ message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
4236
+ })
4237
+ }).optional(),
3864
4238
  blastRadius: z.object({ extraDomains: z.array(z.string()).optional() }).optional(),
3865
4239
  proseGates: z.object({
3866
4240
  doctrineRoot: z.string().min(1).optional(),
3867
4241
  readerFacingPrefix: z.string().min(1).optional(),
3868
4242
  readerFacingSuffix: z.string().min(1).optional(),
3869
4243
  legacySlugDir: z.string().min(1).optional()
3870
- }).optional()
4244
+ }).optional(),
4245
+ projects: z.array(ProjectEntrySchema).optional()
3871
4246
  });
3872
4247
  var GLOBAL_VINAYA_HOME = join2(homedir(), ".vinaya");
3873
4248
  var GLOBAL_CONFIG_PATH = join2(GLOBAL_VINAYA_HOME, "config.json");
@@ -3906,6 +4281,9 @@ function globalRolesIgnoredWarning(path) {
3906
4281
  function globalReleaseActorIgnoredWarning(path) {
3907
4282
  return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
3908
4283
  }
4284
+ function globalTokensCollectIgnoredWarning(path) {
4285
+ return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
4286
+ }
3909
4287
  function stripGlobalOnlyKeys(config, path) {
3910
4288
  if (path !== GLOBAL_CONFIG_PATH)
3911
4289
  return config;
@@ -3926,6 +4304,10 @@ function stripGlobalOnlyKeys(config, path) {
3926
4304
  console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
3927
4305
  result = { ...result, releaseActor: undefined };
3928
4306
  }
4307
+ if (result.tokens) {
4308
+ console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
4309
+ result = { ...result, tokens: undefined };
4310
+ }
3929
4311
  return result;
3930
4312
  }
3931
4313
  function resolvePrincipalAllowlist(config) {
@@ -4005,12 +4387,13 @@ function loadConfig() {
4005
4387
  if (!path)
4006
4388
  return null;
4007
4389
  try {
4008
- const raw = JSON.parse(readFileSync(path, "utf-8"));
4390
+ const raw = JSON.parse(readFileSync2(path, "utf-8"));
4009
4391
  return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
4010
4392
  } catch {
4011
4393
  return null;
4012
4394
  }
4013
4395
  }
4396
+ var TOKENS_COLLECT_TRUST_PATH = join2(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
4014
4397
 
4015
4398
  // src/checks/bin/check-doc-coverage.ts
4016
4399
  var CHECK_NAME = "doc-coverage";
@@ -4030,7 +4413,7 @@ function resolvePrBody() {
4030
4413
  return process.env.PR_BODY;
4031
4414
  if (process.env.PR_BODY_FILE) {
4032
4415
  try {
4033
- return readFileSync2(process.env.PR_BODY_FILE, "utf8");
4416
+ return readFileSync3(process.env.PR_BODY_FILE, "utf8");
4034
4417
  } catch {
4035
4418
  return "";
4036
4419
  }
@@ -4088,7 +4471,7 @@ function main() {
4088
4471
  if (changed.length === 0) {
4089
4472
  process.exit(0);
4090
4473
  }
4091
- const content = existsSync2(DOC_OWNERS_PATH) ? readFileSync2(DOC_OWNERS_PATH, "utf8") : null;
4474
+ const content = existsSync2(DOC_OWNERS_PATH) ? readFileSync3(DOC_OWNERS_PATH, "utf8") : null;
4092
4475
  const result = evaluateC5(changed, content, resolvePrBody(), existsSync2, waiverActive(), (p) => fileDiffAgainst(ref, p));
4093
4476
  if (result.errors.length > 0) {
4094
4477
  for (const message of result.errors) {