@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-registry-gates.ts
4
4
  import { execSync, execFileSync as execFileSync2 } from "node:child_process";
5
- import { existsSync as existsSync3, readdirSync, readFileSync, statSync } from "node:fs";
5
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, statSync } from "node:fs";
6
6
  import matter2 from "gray-matter";
7
7
  // ../../packages/aeg-core/src/gate-audience.ts
8
8
  var GATE_AUDIENCE = {
@@ -191,6 +191,12 @@ var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
191
191
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
192
192
  var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
193
193
  var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
194
+ function splitSlugQualifiedEdge(edge) {
195
+ const m = edge.trim().match(SLUG_QUALIFIED_ID);
196
+ if (!m)
197
+ return null;
198
+ return { slug: m[1], bareId: m[2] };
199
+ }
194
200
  function isEmptyMarker(s) {
195
201
  const t = s.trim();
196
202
  return t === "" || t === "—" || t === "-" || t === "–";
@@ -1787,6 +1793,257 @@ var DERIVED_STATUSES = [
1787
1793
  "incoherent"
1788
1794
  ];
1789
1795
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1796
+ // ../../packages/aeg-core/src/parse-ledger.ts
1797
+ function rowFromCells(cells) {
1798
+ if (cells.length < 7)
1799
+ return null;
1800
+ const phase = (cells[0] ?? "").trim();
1801
+ if (!phase)
1802
+ return null;
1803
+ return {
1804
+ phase,
1805
+ role: (cells[1] ?? "").trim(),
1806
+ agentModel: (cells[2] ?? "").trim(),
1807
+ tokensIn: parseIntCell(cells[3] ?? ""),
1808
+ tokensOut: parseIntCell(cells[4] ?? ""),
1809
+ cost: parseCostCell(cells[5] ?? ""),
1810
+ date: (cells[6] ?? "").trim()
1811
+ };
1812
+ }
1813
+ function parseIntCell(cell) {
1814
+ const trimmed = cell.replace(/`/g, "").trim();
1815
+ if (!trimmed || isEmDashOrDash(trimmed))
1816
+ return null;
1817
+ const normalized = trimmed.replace(/[,_\s]/g, "");
1818
+ if (!/^-?\d+$/.test(normalized))
1819
+ return null;
1820
+ return Number(normalized);
1821
+ }
1822
+ function parseCostCell(cell) {
1823
+ const trimmed = cell.replace(/`/g, "").trim();
1824
+ if (!trimmed || isEmDashOrDash(trimmed))
1825
+ return null;
1826
+ const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1827
+ if (!/^-?\d+(\.\d+)?$/.test(normalized))
1828
+ return null;
1829
+ return Number(normalized);
1830
+ }
1831
+ function isEmDashOrDash(s) {
1832
+ const t = s.trim();
1833
+ return t === "—" || t === "-" || t === "–";
1834
+ }
1835
+ // ../../packages/aeg-core/src/parse-token-report.ts
1836
+ var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1837
+ 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;
1838
+ function parseTokenReportEntries(body) {
1839
+ const lines = body.split(/\r?\n/);
1840
+ const headingIdxs = [];
1841
+ lines.forEach((line, i) => {
1842
+ if (TOKEN_REPORT_HEADING.test(line))
1843
+ headingIdxs.push(i);
1844
+ });
1845
+ const out = [];
1846
+ for (let h = 0;h < headingIdxs.length; h++) {
1847
+ const start = headingIdxs[h] + 1;
1848
+ const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1849
+ const section = lines.slice(start, end).join(`
1850
+ `);
1851
+ const tableRows = parseTableSection(section);
1852
+ if (tableRows.length > 0) {
1853
+ out.push(...tableRows);
1854
+ continue;
1855
+ }
1856
+ const inlineRow = parseInlineFieldList(section);
1857
+ if (inlineRow)
1858
+ out.push(inlineRow);
1859
+ }
1860
+ return out;
1861
+ }
1862
+ function parseTableSection(section) {
1863
+ const lines = section.split(/\r?\n/);
1864
+ let i = 0;
1865
+ for (;i < lines.length; i++) {
1866
+ if ((lines[i] ?? "").trim().startsWith("|"))
1867
+ break;
1868
+ }
1869
+ if (i + 1 >= lines.length)
1870
+ return [];
1871
+ i += 2;
1872
+ const out = [];
1873
+ for (;i < lines.length; i++) {
1874
+ const trimmed = (lines[i] ?? "").trim();
1875
+ if (!trimmed.startsWith("|"))
1876
+ break;
1877
+ const row = rowFromCells(splitTableRow(trimmed));
1878
+ if (row)
1879
+ out.push(row);
1880
+ }
1881
+ return out;
1882
+ }
1883
+ function parseInlineFieldList(section) {
1884
+ const m = section.match(INLINE_FIELD_LIST);
1885
+ if (!m)
1886
+ return null;
1887
+ return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
1888
+ }
1889
+ // ../../packages/aeg-core/src/report-tokens.ts
1890
+ var DASH_LOOKALIKES = {
1891
+ "-": "‑",
1892
+ "–": "‒",
1893
+ "—": "―"
1894
+ };
1895
+ var DASH_CHARS = new Set(Object.keys(DASH_LOOKALIKES));
1896
+ // ../../packages/aeg-core/src/claude-code-transcript.ts
1897
+ import { createHash } from "node:crypto";
1898
+ function summarizeTranscript(jsonl) {
1899
+ const seen = new Set;
1900
+ const components = {
1901
+ inputTokens: 0,
1902
+ outputTokens: 0,
1903
+ cacheCreationInputTokens: 0,
1904
+ cacheReadInputTokens: 0
1905
+ };
1906
+ let model = null;
1907
+ let messageCount = 0;
1908
+ for (const rawLine of jsonl.split(/\r?\n/)) {
1909
+ const line = rawLine.trim();
1910
+ if (!line)
1911
+ continue;
1912
+ let entry2;
1913
+ try {
1914
+ entry2 = JSON.parse(line);
1915
+ } catch {
1916
+ continue;
1917
+ }
1918
+ if (!entry2 || typeof entry2 !== "object")
1919
+ continue;
1920
+ const obj = entry2;
1921
+ if (obj.type !== "assistant")
1922
+ continue;
1923
+ const message = obj.message;
1924
+ const id = message?.id;
1925
+ const usage = message?.usage;
1926
+ if (typeof id !== "string" || !id || !usage || seen.has(id))
1927
+ continue;
1928
+ seen.add(id);
1929
+ messageCount++;
1930
+ components.inputTokens += numberOr(usage.input_tokens, 0);
1931
+ components.outputTokens += numberOr(usage.output_tokens, 0);
1932
+ components.cacheCreationInputTokens += numberOr(usage.cache_creation_input_tokens, 0);
1933
+ components.cacheReadInputTokens += numberOr(usage.cache_read_input_tokens, 0);
1934
+ const messageModel = message?.model;
1935
+ if (typeof messageModel === "string" && messageModel)
1936
+ model = messageModel;
1937
+ }
1938
+ return { components, model, messageCount };
1939
+ }
1940
+ function numberOr(value, fallback) {
1941
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
1942
+ }
1943
+ function sanitizeKey(value) {
1944
+ return value.replace(/[^A-Za-z0-9]+/g, "-");
1945
+ }
1946
+ function collisionResistantKey(value) {
1947
+ const digest = createHash("sha256").update(value).digest("hex");
1948
+ return `${sanitizeKey(value)}-${digest}`;
1949
+ }
1950
+ function transcriptPointerPath(projectDir, tmpDir) {
1951
+ return `${tmpDir}/claude-transcript-${collisionResistantKey(projectDir)}.txt`;
1952
+ }
1953
+ function legacyTranscriptPointerPath(projectDir, tmpDir) {
1954
+ return `${tmpDir}/claude-transcript-${sanitizeKey(projectDir)}.txt`;
1955
+ }
1956
+ function resolvePointer(explicitTranscriptPath, deps) {
1957
+ if (explicitTranscriptPath)
1958
+ return { path: explicitTranscriptPath, corroborated: true };
1959
+ const projectDir = deps.env.CLAUDE_PROJECT_DIR ?? deps.cwd;
1960
+ const tmpDir = deps.env.TMPDIR ?? "/tmp";
1961
+ const primaryPointerPath = transcriptPointerPath(projectDir, tmpDir);
1962
+ const legacyPointerPath = legacyTranscriptPointerPath(projectDir, tmpDir);
1963
+ const currentSessionId = deps.env.CLAUDE_CODE_SESSION_ID;
1964
+ const pointerPath = deps.exists(primaryPointerPath) ? primaryPointerPath : deps.exists(legacyPointerPath) ? legacyPointerPath : undefined;
1965
+ if (!pointerPath) {
1966
+ return {
1967
+ pointerExisted: false,
1968
+ corroborated: false,
1969
+ 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."
1970
+ };
1971
+ }
1972
+ let contents;
1973
+ try {
1974
+ contents = deps.readFile(pointerPath).replace(/\r?\n+$/, "");
1975
+ } catch (err) {
1976
+ return {
1977
+ pointerExisted: true,
1978
+ oursByLocation: true,
1979
+ 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."
1980
+ };
1981
+ }
1982
+ const [pointerSessionId, transcriptPath] = contents.split("\t");
1983
+ if (!transcriptPath) {
1984
+ return {
1985
+ pointerExisted: true,
1986
+ oursByLocation: true,
1987
+ 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."
1988
+ };
1989
+ }
1990
+ if (currentSessionId && pointerSessionId && currentSessionId !== pointerSessionId) {
1991
+ return {
1992
+ pointerExisted: true,
1993
+ corroborated: false,
1994
+ 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."
1995
+ };
1996
+ }
1997
+ return { path: transcriptPath, corroborated: Boolean(currentSessionId && pointerSessionId) };
1998
+ }
1999
+ function resolveMeteringCapability(deps, explicitTranscriptPath) {
2000
+ const resolved = resolvePointer(explicitTranscriptPath, deps);
2001
+ if ("error" in resolved) {
2002
+ const ours = resolved.pointerExisted && (resolved.corroborated || resolved.oursByLocation);
2003
+ if (ours)
2004
+ return { capable: false, reason: "pointer-unusable", detail: resolved.error };
2005
+ return {
2006
+ capable: false,
2007
+ reason: "no-transcript-resolved",
2008
+ 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
2009
+ };
2010
+ }
2011
+ const downstream = (r, detail) => resolved.corroborated ? { reason: r, detail } : {
2012
+ reason: "no-transcript-resolved",
2013
+ 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})`
2014
+ };
2015
+ if (!deps.exists(resolved.path)) {
2016
+ return {
2017
+ capable: false,
2018
+ ...downstream("transcript-unreadable", `Resolved transcript path ${resolved.path} is not readable as a regular file owned by this user.`)
2019
+ };
2020
+ }
2021
+ let jsonl;
2022
+ try {
2023
+ jsonl = deps.readFile(resolved.path);
2024
+ } catch (err) {
2025
+ return {
2026
+ capable: false,
2027
+ ...downstream("transcript-unreadable", `Transcript at ${resolved.path} could not be read: ${err.message}`)
2028
+ };
2029
+ }
2030
+ const summary = summarizeTranscript(jsonl);
2031
+ if (summary.messageCount === 0) {
2032
+ return {
2033
+ capable: false,
2034
+ ...downstream("transcript-empty", `Transcript at ${resolved.path} yielded zero assistant messages with usage data — ` + "it's empty, unparseable, or not yet flushed to disk.")
2035
+ };
2036
+ }
2037
+ return { capable: true, transcriptPath: resolved.path, summary };
2038
+ }
2039
+ function isTokenCollectionWiringBroken(capability) {
2040
+ if (capability.capable)
2041
+ return false;
2042
+ return capability.reason !== "no-transcript-resolved";
2043
+ }
2044
+ // ../../packages/aeg-core/src/metering-io-guard.ts
2045
+ import { closeSync, constants as fsConstants, fstatSync, openSync, readFileSync } from "node:fs";
2046
+ var GUARD_OPEN_FLAGS = fsConstants.O_RDONLY | fsConstants.O_NONBLOCK | fsConstants.O_NOFOLLOW;
1790
2047
  // ../../packages/aeg-core/src/file-classify.ts
1791
2048
  function isCodeFile(p) {
1792
2049
  if (p.endsWith(".md"))
@@ -1993,7 +2250,7 @@ function overrideActive(opts) {
1993
2250
  return false;
1994
2251
  }
1995
2252
  // ../../packages/aeg-core/src/premise-check.ts
1996
- import { createHash } from "node:crypto";
2253
+ import { createHash as createHash2 } from "node:crypto";
1997
2254
  var ASSERTION_KINDS = new Set(["contains", "absent", "sha256"]);
1998
2255
  function isPremiseHeader(line) {
1999
2256
  const stripped = line.replace(/[*#]/g, "").trim();
@@ -2038,7 +2295,7 @@ function checkPremises(assertions, fileReader) {
2038
2295
  } else if (a.kind === "absent" && content.includes(a.value)) {
2039
2296
  failures.push(`premise-check: ${a.path} now contains "${a.value}", but the brief pinned it absent — the premise has moved; re-dig before proceeding.`);
2040
2297
  } else if (a.kind === "sha256") {
2041
- const actual = createHash("sha256").update(content).digest("hex");
2298
+ const actual = createHash2("sha256").update(content).digest("hex");
2042
2299
  if (actual !== a.value.toLowerCase()) {
2043
2300
  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.`);
2044
2301
  }
@@ -3218,6 +3475,100 @@ function parseGlossaryTerms(glossaryContent) {
3218
3475
  }
3219
3476
  return terms;
3220
3477
  }
3478
+ // ../../packages/aeg-core/src/quoted-command.ts
3479
+ var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3480
+ var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3481
+ var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
3482
+ var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
3483
+ function isValidCitedFilePath(path) {
3484
+ if (path.length === 0)
3485
+ return false;
3486
+ if (path.startsWith("/") || path.startsWith("\\"))
3487
+ return false;
3488
+ if (/^[A-Za-z]:[\\/]/.test(path))
3489
+ return false;
3490
+ return !path.split(/[\\/]+/).includes("..");
3491
+ }
3492
+ function quotedCommandLineAt(content, index) {
3493
+ let line = 1;
3494
+ for (let i = 0;i < index; i++) {
3495
+ if (content.charCodeAt(i) === 10)
3496
+ line++;
3497
+ }
3498
+ return line;
3499
+ }
3500
+ function extractQuotedText(raw) {
3501
+ const trimmed = raw.trim();
3502
+ const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
3503
+ if (fenced)
3504
+ return (fenced[1] ?? "").trim();
3505
+ const inline = /^`([^`]+)`$/.exec(trimmed);
3506
+ if (inline)
3507
+ return (inline[1] ?? "").trim();
3508
+ return trimmed;
3509
+ }
3510
+ function findQuotesInFile(path, content) {
3511
+ const masked = maskCode(content);
3512
+ const quotes = [];
3513
+ START_PATTERN.lastIndex = 0;
3514
+ let start = START_PATTERN.exec(masked);
3515
+ while (start !== null) {
3516
+ const citedFile = start[1];
3517
+ const innerStart = start.index + start[0].length;
3518
+ const end = END_PATTERN.exec(masked.slice(innerStart));
3519
+ if (end === null) {
3520
+ START_PATTERN.lastIndex = innerStart;
3521
+ start = START_PATTERN.exec(masked);
3522
+ continue;
3523
+ }
3524
+ const innerEnd = innerStart + end.index;
3525
+ if (isValidCitedFilePath(citedFile)) {
3526
+ const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
3527
+ if (quotedText.length > 0) {
3528
+ quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
3529
+ }
3530
+ }
3531
+ START_PATTERN.lastIndex = innerEnd + end[0].length;
3532
+ start = START_PATTERN.exec(masked);
3533
+ }
3534
+ return quotes;
3535
+ }
3536
+ function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
3537
+ const quotes = [];
3538
+ for (const file of files) {
3539
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3540
+ if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
3541
+ continue;
3542
+ quotes.push(...findQuotesInFile(file.path, file.content));
3543
+ }
3544
+ return quotes;
3545
+ }
3546
+ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3547
+ const findings = [];
3548
+ for (const quote of citedQuotes) {
3549
+ const content = citedFileContents.get(quote.citedFile);
3550
+ if (content === undefined) {
3551
+ findings.push({
3552
+ file: quote.file,
3553
+ line: quote.line,
3554
+ citedFile: quote.citedFile,
3555
+ quotedText: quote.quotedText,
3556
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
3557
+ });
3558
+ continue;
3559
+ }
3560
+ if (!content.includes(quote.quotedText)) {
3561
+ findings.push({
3562
+ file: quote.file,
3563
+ line: quote.line,
3564
+ citedFile: quote.citedFile,
3565
+ quotedText: quote.quotedText,
3566
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
3567
+ });
3568
+ }
3569
+ }
3570
+ return findings;
3571
+ }
3221
3572
  // ../../packages/aeg-core/src/retired-vocabulary.ts
3222
3573
  var RETIRED_PATTERNS = [
3223
3574
  String.raw`\bD-[0-9]{3}\b`,
@@ -3331,6 +3682,10 @@ function checkDispatchReadiness(input) {
3331
3682
  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.`);
3332
3683
  }
3333
3684
  for (const dep of input.dependsOn) {
3685
+ if (dep.resolved === false) {
3686
+ 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.`);
3687
+ continue;
3688
+ }
3334
3689
  if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
3335
3690
  const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
3336
3691
  blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
@@ -3829,6 +4184,21 @@ var REGISTRY = [
3829
4184
  },
3830
4185
  1
3831
4186
  ],
4187
+ [
4188
+ {
4189
+ name: "token-report",
4190
+ run: bin("check-token-report"),
4191
+ scope: "diff",
4192
+ timeoutMs: 15000,
4193
+ requiresOpenPr: true,
4194
+ env: {
4195
+ PR_BODY: { optional: true },
4196
+ CLAUDE_PROJECT_DIR: { optional: true },
4197
+ CLAUDE_CODE_SESSION_ID: { optional: true }
4198
+ }
4199
+ },
4200
+ 1
4201
+ ],
3832
4202
  [
3833
4203
  {
3834
4204
  name: "no-disk-state",
@@ -4005,6 +4375,26 @@ var REGISTRY = [
4005
4375
  },
4006
4376
  0
4007
4377
  ],
4378
+ [
4379
+ {
4380
+ name: "changeset-coverage",
4381
+ run: bin("check-changeset-coverage"),
4382
+ scope: "diff",
4383
+ timeoutMs: 15000,
4384
+ env: {}
4385
+ },
4386
+ 0
4387
+ ],
4388
+ [
4389
+ {
4390
+ name: "quoted-command",
4391
+ run: bin("check-quoted-command"),
4392
+ scope: "diff",
4393
+ timeoutMs: 15000,
4394
+ env: {}
4395
+ },
4396
+ 0
4397
+ ],
4008
4398
  [
4009
4399
  {
4010
4400
  name: "main-branch-refusal",
@@ -4014,6 +4404,19 @@ var REGISTRY = [
4014
4404
  env: {}
4015
4405
  },
4016
4406
  0
4407
+ ],
4408
+ [
4409
+ {
4410
+ name: "token-collection-wired",
4411
+ run: bin("check-token-collection-wired"),
4412
+ scope: "full",
4413
+ timeoutMs: 15000,
4414
+ env: {
4415
+ CLAUDE_PROJECT_DIR: { optional: true },
4416
+ CLAUDE_CODE_SESSION_ID: { optional: true }
4417
+ }
4418
+ },
4419
+ 0
4017
4420
  ]
4018
4421
  ];
4019
4422
  function coreCheckRegistry() {
@@ -4054,7 +4457,7 @@ function globCandidateFiles() {
4054
4457
  return out;
4055
4458
  }
4056
4459
  function findCrossingFiles(candidateFiles) {
4057
- return candidateFiles.filter((path) => readFileSync(path, "utf8").split(`
4460
+ return candidateFiles.filter((path) => readFileSync2(path, "utf8").split(`
4058
4461
  `).some((line) => isGithubCrossingLine(line)));
4059
4462
  }
4060
4463
  function readRoles() {
@@ -4062,7 +4465,7 @@ function readRoles() {
4062
4465
  return [];
4063
4466
  return readdirSync(ROLES_DIR).filter((name) => name.endsWith(".md")).map((name) => {
4064
4467
  const rel = `${ROLES_DIR}/${name}`;
4065
- const { data } = matter2(readFileSync(rel, "utf8"));
4468
+ const { data } = matter2(readFileSync2(rel, "utf8"));
4066
4469
  return {
4067
4470
  file: rel,
4068
4471
  role_id: typeof data.role_id === "string" ? data.role_id : "",
@@ -4076,7 +4479,7 @@ function readContracts() {
4076
4479
  return [];
4077
4480
  return readdirSync(CONTRACTS_DIR).filter((name) => name.endsWith(".md")).map((name) => {
4078
4481
  const rel = `${CONTRACTS_DIR}/${name}`;
4079
- const { data } = matter2(readFileSync(rel, "utf8"));
4482
+ const { data } = matter2(readFileSync2(rel, "utf8"));
4080
4483
  return {
4081
4484
  file: rel,
4082
4485
  producer: typeof data.producer === "string" ? data.producer : "",
@@ -4157,7 +4560,7 @@ async function main() {
4157
4560
  });
4158
4561
  process.exit(0);
4159
4562
  }
4160
- const enforcementContent = readFileSync(ENFORCEMENT_PATH, "utf8");
4563
+ const enforcementContent = readFileSync2(ENFORCEMENT_PATH, "utf8");
4161
4564
  const rows = parseEnforcementRegistry(enforcementContent);
4162
4565
  const ring0Rows = rows.filter((r) => r.ring === "ring0");
4163
4566
  const candidateFiles = globCandidateFiles();