@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
@@ -189,6 +189,12 @@ var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
189
189
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
190
190
  var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
191
191
  var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
192
+ function splitSlugQualifiedEdge(edge) {
193
+ const m = edge.trim().match(SLUG_QUALIFIED_ID);
194
+ if (!m)
195
+ return null;
196
+ return { slug: m[1], bareId: m[2] };
197
+ }
192
198
  function isEmptyMarker(s) {
193
199
  const t = s.trim();
194
200
  return t === "" || t === "—" || t === "-" || t === "–";
@@ -1785,6 +1791,257 @@ var DERIVED_STATUSES = [
1785
1791
  "incoherent"
1786
1792
  ];
1787
1793
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1794
+ // ../../packages/aeg-core/src/parse-ledger.ts
1795
+ function rowFromCells(cells) {
1796
+ if (cells.length < 7)
1797
+ return null;
1798
+ const phase = (cells[0] ?? "").trim();
1799
+ if (!phase)
1800
+ return null;
1801
+ return {
1802
+ phase,
1803
+ role: (cells[1] ?? "").trim(),
1804
+ agentModel: (cells[2] ?? "").trim(),
1805
+ tokensIn: parseIntCell(cells[3] ?? ""),
1806
+ tokensOut: parseIntCell(cells[4] ?? ""),
1807
+ cost: parseCostCell(cells[5] ?? ""),
1808
+ date: (cells[6] ?? "").trim()
1809
+ };
1810
+ }
1811
+ function parseIntCell(cell) {
1812
+ const trimmed = cell.replace(/`/g, "").trim();
1813
+ if (!trimmed || isEmDashOrDash(trimmed))
1814
+ return null;
1815
+ const normalized = trimmed.replace(/[,_\s]/g, "");
1816
+ if (!/^-?\d+$/.test(normalized))
1817
+ return null;
1818
+ return Number(normalized);
1819
+ }
1820
+ function parseCostCell(cell) {
1821
+ const trimmed = cell.replace(/`/g, "").trim();
1822
+ if (!trimmed || isEmDashOrDash(trimmed))
1823
+ return null;
1824
+ const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1825
+ if (!/^-?\d+(\.\d+)?$/.test(normalized))
1826
+ return null;
1827
+ return Number(normalized);
1828
+ }
1829
+ function isEmDashOrDash(s) {
1830
+ const t = s.trim();
1831
+ return t === "—" || t === "-" || t === "–";
1832
+ }
1833
+ // ../../packages/aeg-core/src/parse-token-report.ts
1834
+ var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1835
+ 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;
1836
+ function parseTokenReportEntries(body) {
1837
+ const lines = body.split(/\r?\n/);
1838
+ const headingIdxs = [];
1839
+ lines.forEach((line, i) => {
1840
+ if (TOKEN_REPORT_HEADING.test(line))
1841
+ headingIdxs.push(i);
1842
+ });
1843
+ const out = [];
1844
+ for (let h = 0;h < headingIdxs.length; h++) {
1845
+ const start = headingIdxs[h] + 1;
1846
+ const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1847
+ const section = lines.slice(start, end).join(`
1848
+ `);
1849
+ const tableRows = parseTableSection(section);
1850
+ if (tableRows.length > 0) {
1851
+ out.push(...tableRows);
1852
+ continue;
1853
+ }
1854
+ const inlineRow = parseInlineFieldList(section);
1855
+ if (inlineRow)
1856
+ out.push(inlineRow);
1857
+ }
1858
+ return out;
1859
+ }
1860
+ function parseTableSection(section) {
1861
+ const lines = section.split(/\r?\n/);
1862
+ let i = 0;
1863
+ for (;i < lines.length; i++) {
1864
+ if ((lines[i] ?? "").trim().startsWith("|"))
1865
+ break;
1866
+ }
1867
+ if (i + 1 >= lines.length)
1868
+ return [];
1869
+ i += 2;
1870
+ const out = [];
1871
+ for (;i < lines.length; i++) {
1872
+ const trimmed = (lines[i] ?? "").trim();
1873
+ if (!trimmed.startsWith("|"))
1874
+ break;
1875
+ const row = rowFromCells(splitTableRow(trimmed));
1876
+ if (row)
1877
+ out.push(row);
1878
+ }
1879
+ return out;
1880
+ }
1881
+ function parseInlineFieldList(section) {
1882
+ const m = section.match(INLINE_FIELD_LIST);
1883
+ if (!m)
1884
+ return null;
1885
+ return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
1886
+ }
1887
+ // ../../packages/aeg-core/src/report-tokens.ts
1888
+ var DASH_LOOKALIKES = {
1889
+ "-": "‑",
1890
+ "–": "‒",
1891
+ "—": "―"
1892
+ };
1893
+ var DASH_CHARS = new Set(Object.keys(DASH_LOOKALIKES));
1894
+ // ../../packages/aeg-core/src/claude-code-transcript.ts
1895
+ import { createHash } from "node:crypto";
1896
+ function summarizeTranscript(jsonl) {
1897
+ const seen = new Set;
1898
+ const components = {
1899
+ inputTokens: 0,
1900
+ outputTokens: 0,
1901
+ cacheCreationInputTokens: 0,
1902
+ cacheReadInputTokens: 0
1903
+ };
1904
+ let model = null;
1905
+ let messageCount = 0;
1906
+ for (const rawLine of jsonl.split(/\r?\n/)) {
1907
+ const line = rawLine.trim();
1908
+ if (!line)
1909
+ continue;
1910
+ let entry2;
1911
+ try {
1912
+ entry2 = JSON.parse(line);
1913
+ } catch {
1914
+ continue;
1915
+ }
1916
+ if (!entry2 || typeof entry2 !== "object")
1917
+ continue;
1918
+ const obj = entry2;
1919
+ if (obj.type !== "assistant")
1920
+ continue;
1921
+ const message = obj.message;
1922
+ const id = message?.id;
1923
+ const usage = message?.usage;
1924
+ if (typeof id !== "string" || !id || !usage || seen.has(id))
1925
+ continue;
1926
+ seen.add(id);
1927
+ messageCount++;
1928
+ components.inputTokens += numberOr(usage.input_tokens, 0);
1929
+ components.outputTokens += numberOr(usage.output_tokens, 0);
1930
+ components.cacheCreationInputTokens += numberOr(usage.cache_creation_input_tokens, 0);
1931
+ components.cacheReadInputTokens += numberOr(usage.cache_read_input_tokens, 0);
1932
+ const messageModel = message?.model;
1933
+ if (typeof messageModel === "string" && messageModel)
1934
+ model = messageModel;
1935
+ }
1936
+ return { components, model, messageCount };
1937
+ }
1938
+ function numberOr(value, fallback) {
1939
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
1940
+ }
1941
+ function sanitizeKey(value) {
1942
+ return value.replace(/[^A-Za-z0-9]+/g, "-");
1943
+ }
1944
+ function collisionResistantKey(value) {
1945
+ const digest = createHash("sha256").update(value).digest("hex");
1946
+ return `${sanitizeKey(value)}-${digest}`;
1947
+ }
1948
+ function transcriptPointerPath(projectDir, tmpDir) {
1949
+ return `${tmpDir}/claude-transcript-${collisionResistantKey(projectDir)}.txt`;
1950
+ }
1951
+ function legacyTranscriptPointerPath(projectDir, tmpDir) {
1952
+ return `${tmpDir}/claude-transcript-${sanitizeKey(projectDir)}.txt`;
1953
+ }
1954
+ function resolvePointer(explicitTranscriptPath, deps) {
1955
+ if (explicitTranscriptPath)
1956
+ return { path: explicitTranscriptPath, corroborated: true };
1957
+ const projectDir = deps.env.CLAUDE_PROJECT_DIR ?? deps.cwd;
1958
+ const tmpDir = deps.env.TMPDIR ?? "/tmp";
1959
+ const primaryPointerPath = transcriptPointerPath(projectDir, tmpDir);
1960
+ const legacyPointerPath = legacyTranscriptPointerPath(projectDir, tmpDir);
1961
+ const currentSessionId = deps.env.CLAUDE_CODE_SESSION_ID;
1962
+ const pointerPath = deps.exists(primaryPointerPath) ? primaryPointerPath : deps.exists(legacyPointerPath) ? legacyPointerPath : undefined;
1963
+ if (!pointerPath) {
1964
+ return {
1965
+ pointerExisted: false,
1966
+ corroborated: false,
1967
+ 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."
1968
+ };
1969
+ }
1970
+ let contents;
1971
+ try {
1972
+ contents = deps.readFile(pointerPath).replace(/\r?\n+$/, "");
1973
+ } catch (err) {
1974
+ return {
1975
+ pointerExisted: true,
1976
+ oursByLocation: true,
1977
+ 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."
1978
+ };
1979
+ }
1980
+ const [pointerSessionId, transcriptPath] = contents.split("\t");
1981
+ if (!transcriptPath) {
1982
+ return {
1983
+ pointerExisted: true,
1984
+ oursByLocation: true,
1985
+ 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."
1986
+ };
1987
+ }
1988
+ if (currentSessionId && pointerSessionId && currentSessionId !== pointerSessionId) {
1989
+ return {
1990
+ pointerExisted: true,
1991
+ corroborated: false,
1992
+ 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."
1993
+ };
1994
+ }
1995
+ return { path: transcriptPath, corroborated: Boolean(currentSessionId && pointerSessionId) };
1996
+ }
1997
+ function resolveMeteringCapability(deps, explicitTranscriptPath) {
1998
+ const resolved = resolvePointer(explicitTranscriptPath, deps);
1999
+ if ("error" in resolved) {
2000
+ const ours = resolved.pointerExisted && (resolved.corroborated || resolved.oursByLocation);
2001
+ if (ours)
2002
+ return { capable: false, reason: "pointer-unusable", detail: resolved.error };
2003
+ return {
2004
+ capable: false,
2005
+ reason: "no-transcript-resolved",
2006
+ 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
2007
+ };
2008
+ }
2009
+ const downstream = (r, detail) => resolved.corroborated ? { reason: r, detail } : {
2010
+ reason: "no-transcript-resolved",
2011
+ 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})`
2012
+ };
2013
+ if (!deps.exists(resolved.path)) {
2014
+ return {
2015
+ capable: false,
2016
+ ...downstream("transcript-unreadable", `Resolved transcript path ${resolved.path} is not readable as a regular file owned by this user.`)
2017
+ };
2018
+ }
2019
+ let jsonl;
2020
+ try {
2021
+ jsonl = deps.readFile(resolved.path);
2022
+ } catch (err) {
2023
+ return {
2024
+ capable: false,
2025
+ ...downstream("transcript-unreadable", `Transcript at ${resolved.path} could not be read: ${err.message}`)
2026
+ };
2027
+ }
2028
+ const summary = summarizeTranscript(jsonl);
2029
+ if (summary.messageCount === 0) {
2030
+ return {
2031
+ capable: false,
2032
+ ...downstream("transcript-empty", `Transcript at ${resolved.path} yielded zero assistant messages with usage data — ` + "it's empty, unparseable, or not yet flushed to disk.")
2033
+ };
2034
+ }
2035
+ return { capable: true, transcriptPath: resolved.path, summary };
2036
+ }
2037
+ function isTokenCollectionWiringBroken(capability) {
2038
+ if (capability.capable)
2039
+ return false;
2040
+ return capability.reason !== "no-transcript-resolved";
2041
+ }
2042
+ // ../../packages/aeg-core/src/metering-io-guard.ts
2043
+ import { closeSync, constants as fsConstants, fstatSync, openSync, readFileSync } from "node:fs";
2044
+ var GUARD_OPEN_FLAGS = fsConstants.O_RDONLY | fsConstants.O_NONBLOCK | fsConstants.O_NOFOLLOW;
1788
2045
  // ../../packages/aeg-core/src/file-classify.ts
1789
2046
  function isCodeFile(p) {
1790
2047
  if (p.endsWith(".md"))
@@ -1991,7 +2248,7 @@ function overrideActive(opts) {
1991
2248
  return false;
1992
2249
  }
1993
2250
  // ../../packages/aeg-core/src/premise-check.ts
1994
- import { createHash } from "node:crypto";
2251
+ import { createHash as createHash2 } from "node:crypto";
1995
2252
  var ASSERTION_KINDS = new Set(["contains", "absent", "sha256"]);
1996
2253
  function isPremiseHeader(line) {
1997
2254
  const stripped = line.replace(/[*#]/g, "").trim();
@@ -2036,7 +2293,7 @@ function checkPremises(assertions, fileReader) {
2036
2293
  } else if (a.kind === "absent" && content.includes(a.value)) {
2037
2294
  failures.push(`premise-check: ${a.path} now contains "${a.value}", but the brief pinned it absent — the premise has moved; re-dig before proceeding.`);
2038
2295
  } else if (a.kind === "sha256") {
2039
- const actual = createHash("sha256").update(content).digest("hex");
2296
+ const actual = createHash2("sha256").update(content).digest("hex");
2040
2297
  if (actual !== a.value.toLowerCase()) {
2041
2298
  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.`);
2042
2299
  }
@@ -3216,6 +3473,100 @@ function parseGlossaryTerms(glossaryContent) {
3216
3473
  }
3217
3474
  return terms;
3218
3475
  }
3476
+ // ../../packages/aeg-core/src/quoted-command.ts
3477
+ var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3478
+ var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3479
+ var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
3480
+ var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
3481
+ function isValidCitedFilePath(path) {
3482
+ if (path.length === 0)
3483
+ return false;
3484
+ if (path.startsWith("/") || path.startsWith("\\"))
3485
+ return false;
3486
+ if (/^[A-Za-z]:[\\/]/.test(path))
3487
+ return false;
3488
+ return !path.split(/[\\/]+/).includes("..");
3489
+ }
3490
+ function quotedCommandLineAt(content, index) {
3491
+ let line = 1;
3492
+ for (let i = 0;i < index; i++) {
3493
+ if (content.charCodeAt(i) === 10)
3494
+ line++;
3495
+ }
3496
+ return line;
3497
+ }
3498
+ function extractQuotedText(raw) {
3499
+ const trimmed = raw.trim();
3500
+ const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
3501
+ if (fenced)
3502
+ return (fenced[1] ?? "").trim();
3503
+ const inline = /^`([^`]+)`$/.exec(trimmed);
3504
+ if (inline)
3505
+ return (inline[1] ?? "").trim();
3506
+ return trimmed;
3507
+ }
3508
+ function findQuotesInFile(path, content) {
3509
+ const masked = maskCode(content);
3510
+ const quotes = [];
3511
+ START_PATTERN.lastIndex = 0;
3512
+ let start = START_PATTERN.exec(masked);
3513
+ while (start !== null) {
3514
+ const citedFile = start[1];
3515
+ const innerStart = start.index + start[0].length;
3516
+ const end = END_PATTERN.exec(masked.slice(innerStart));
3517
+ if (end === null) {
3518
+ START_PATTERN.lastIndex = innerStart;
3519
+ start = START_PATTERN.exec(masked);
3520
+ continue;
3521
+ }
3522
+ const innerEnd = innerStart + end.index;
3523
+ if (isValidCitedFilePath(citedFile)) {
3524
+ const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
3525
+ if (quotedText.length > 0) {
3526
+ quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
3527
+ }
3528
+ }
3529
+ START_PATTERN.lastIndex = innerEnd + end[0].length;
3530
+ start = START_PATTERN.exec(masked);
3531
+ }
3532
+ return quotes;
3533
+ }
3534
+ function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
3535
+ const quotes = [];
3536
+ for (const file of files) {
3537
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3538
+ if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
3539
+ continue;
3540
+ quotes.push(...findQuotesInFile(file.path, file.content));
3541
+ }
3542
+ return quotes;
3543
+ }
3544
+ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3545
+ const findings = [];
3546
+ for (const quote of citedQuotes) {
3547
+ const content = citedFileContents.get(quote.citedFile);
3548
+ if (content === undefined) {
3549
+ findings.push({
3550
+ file: quote.file,
3551
+ line: quote.line,
3552
+ citedFile: quote.citedFile,
3553
+ quotedText: quote.quotedText,
3554
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
3555
+ });
3556
+ continue;
3557
+ }
3558
+ if (!content.includes(quote.quotedText)) {
3559
+ findings.push({
3560
+ file: quote.file,
3561
+ line: quote.line,
3562
+ citedFile: quote.citedFile,
3563
+ quotedText: quote.quotedText,
3564
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
3565
+ });
3566
+ }
3567
+ }
3568
+ return findings;
3569
+ }
3219
3570
  // ../../packages/aeg-core/src/retired-vocabulary.ts
3220
3571
  var RETIRED_PATTERNS = [
3221
3572
  String.raw`\bD-[0-9]{3}\b`,
@@ -3329,6 +3680,10 @@ function checkDispatchReadiness(input) {
3329
3680
  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.`);
3330
3681
  }
3331
3682
  for (const dep of input.dependsOn) {
3683
+ if (dep.resolved === false) {
3684
+ 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.`);
3685
+ continue;
3686
+ }
3332
3687
  if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
3333
3688
  const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
3334
3689
  blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
@@ -3816,6 +4171,18 @@ var COMMANDS = [
3816
4171
  ],
3817
4172
  status: "shipped"
3818
4173
  },
4174
+ {
4175
+ name: "pr verify-evidence",
4176
+ description: "Prove a pull request's AEG:EVIDENCE region was machine-generated — regenerate it and compare",
4177
+ flags: [],
4178
+ details: [
4179
+ "Deliberately a command, not a check: `evidence-fresh` runs inside `vinaya check --all`, and `pr report` runs `vinaya check --all --diff-only`, so a check that regenerated the block would run the suite containing itself. That recursion is why `evidence-fresh` verifies Group A only and leaves Group B attested.",
4180
+ "Must be run from the repository ROOT of a CLEAN checkout at the pull request's head, and refuses otherwise. The regeneration inherits the working directory and several gates resolve their scan root from it, so a subdirectory silently narrows what the fresh run inspects. On cleanliness: Group B is regenerated by diff-scoped checks, so uncommitted or untracked files change which files are scanned and can produce a MATCH a clean checkout would not. Ignored paths are deliberately NOT inspected — `git diff` never reports one, so they cannot change the scope, and including them would refuse in every real checkout since `node_modules` is ignored and always present. The head is read from the forge and both a mismatch AND an unreadable head refuse — the verdict is bound to a commit, never merely attested. `BASE_SHA` is refused as well, since it steers the regeneration's merge-base.",
4181
+ "Exits 0 on MATCH; 1 on DIFFERS, HIDDEN, or no block; 2 on a refusal (dirty worktree, wrong head, usage error). HIDDEN means the anchor pair sits inside a collapsed `<details>` block, where `body-bare-digits` blanks every digit and nothing can verify what it claims.",
4182
+ "Comparison is a multiset of repo-relative, control-stripped lines: absolute paths (local AND foreign, so a block generated in CI compares against one generated on a laptop) and line order are ignored — a reorder is not a fabrication. Only the AEG:EVIDENCE region is read, since AEG:TOKENS appends by design. A moved merge-base is reported ALONGSIDE the differing lines, never instead of them."
4183
+ ],
4184
+ status: "shipped"
4185
+ },
3819
4186
  {
3820
4187
  name: "issue create",
3821
4188
  description: "Open an issue after full brief-schema validation",
@@ -3892,6 +4259,19 @@ var COMMANDS = [
3892
4259
  ],
3893
4260
  status: "shipped"
3894
4261
  },
4262
+ {
4263
+ name: "milestone close",
4264
+ description: "Close a tranche's Milestone after verifying every labeled Issue is actually attached",
4265
+ flags: [
4266
+ { flag: "--slug", description: "The tranche whose Milestone is being closed" },
4267
+ { flag: "--validate-only", description: "Run every gate and report PASS without closing the Milestone" },
4268
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
4269
+ ],
4270
+ details: [
4271
+ "Resolves the target Milestone the same legacy-or-intent-declared way Issue create auto-attach does, then refuses to close on any mismatch between the label's Issues and the Milestone's natively attached Issues — naming each unattached or foreign Issue and its repair path (`gh issue edit <n> --milestone <title>`, or `vinaya milestone adopt`) — before the PATCH ever reaches the forge."
4272
+ ],
4273
+ status: "shipped"
4274
+ },
3895
4275
  {
3896
4276
  name: "review post",
3897
4277
  description: "Render, post, and self-verify a code-reviewer or security-review verdict comment on a PR",
@@ -4101,9 +4481,9 @@ function emitCheckError(error) {
4101
4481
 
4102
4482
  // src/lib/config.ts
4103
4483
  import { execFileSync as execFileSync2 } from "node:child_process";
4104
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4484
+ import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
4105
4485
  import { homedir } from "node:os";
4106
- import { dirname, join } from "node:path";
4486
+ import { dirname, join, resolve } from "node:path";
4107
4487
  import { z as z2 } from "zod";
4108
4488
 
4109
4489
  // src/lib/agent-vendors.ts
@@ -4211,6 +4591,20 @@ var ManagedManifestSchema = z2.object({
4211
4591
  labels: z2.array(z2.string()),
4212
4592
  agents: z2.array(z2.enum(AGENT_VENDORS)).optional()
4213
4593
  });
4594
+ var ProjectEntrySchema = z2.object({
4595
+ name: z2.string().min(1),
4596
+ description: z2.string().min(1).optional(),
4597
+ path: z2.string().min(1).optional()
4598
+ });
4599
+ function parseTokensCollectDeclaration(value) {
4600
+ const m = value.trim().match(/^(\S+)\s+(\S+)$/);
4601
+ if (!m)
4602
+ return null;
4603
+ const [, interpreter, script] = m;
4604
+ if (!isSafeRepoRelPath(script))
4605
+ return null;
4606
+ return { interpreter, script };
4607
+ }
4214
4608
  var VinayaConfigSchema = z2.object({
4215
4609
  rings: z2.object({
4216
4610
  ring1_forgeWriteInterception: z2.boolean(),
@@ -4223,13 +4617,19 @@ var VinayaConfigSchema = z2.object({
4223
4617
  principals: z2.array(z2.string()).min(1).optional(),
4224
4618
  releaseActor: z2.string().min(1).optional(),
4225
4619
  ci: z2.object({ setup: z2.string().min(1) }).optional(),
4620
+ tokens: z2.object({
4621
+ collect: z2.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
4622
+ message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
4623
+ })
4624
+ }).optional(),
4226
4625
  blastRadius: z2.object({ extraDomains: z2.array(z2.string()).optional() }).optional(),
4227
4626
  proseGates: z2.object({
4228
4627
  doctrineRoot: z2.string().min(1).optional(),
4229
4628
  readerFacingPrefix: z2.string().min(1).optional(),
4230
4629
  readerFacingSuffix: z2.string().min(1).optional(),
4231
4630
  legacySlugDir: z2.string().min(1).optional()
4232
- }).optional()
4631
+ }).optional(),
4632
+ projects: z2.array(ProjectEntrySchema).optional()
4233
4633
  });
4234
4634
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
4235
4635
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -4268,6 +4668,9 @@ function globalRolesIgnoredWarning(path) {
4268
4668
  function globalReleaseActorIgnoredWarning(path) {
4269
4669
  return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
4270
4670
  }
4671
+ function globalTokensCollectIgnoredWarning(path) {
4672
+ return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
4673
+ }
4271
4674
  function stripGlobalOnlyKeys(config, path) {
4272
4675
  if (path !== GLOBAL_CONFIG_PATH)
4273
4676
  return config;
@@ -4288,6 +4691,10 @@ function stripGlobalOnlyKeys(config, path) {
4288
4691
  console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
4289
4692
  result = { ...result, releaseActor: undefined };
4290
4693
  }
4694
+ if (result.tokens) {
4695
+ console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
4696
+ result = { ...result, tokens: undefined };
4697
+ }
4291
4698
  return result;
4292
4699
  }
4293
4700
  function resolvePrincipalAllowlist(config) {
@@ -4367,12 +4774,13 @@ function loadConfig() {
4367
4774
  if (!path)
4368
4775
  return null;
4369
4776
  try {
4370
- const raw = JSON.parse(readFileSync(path, "utf-8"));
4777
+ const raw = JSON.parse(readFileSync2(path, "utf-8"));
4371
4778
  return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
4372
4779
  } catch {
4373
4780
  return null;
4374
4781
  }
4375
4782
  }
4783
+ var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
4376
4784
 
4377
4785
  // src/checks/edge-resolve.ts
4378
4786
  import { execFileSync as execFileSync3 } from "node:child_process";
@@ -4400,9 +4808,32 @@ function fetchIssueState(num, repo) {
4400
4808
  issueCache.set(key, out);
4401
4809
  return out;
4402
4810
  }
4811
+ var defaultResolveSiblingTranche = async (slug, repo) => {
4812
+ let tranche;
4813
+ try {
4814
+ tranche = await deriveTrancheFromForge(repo.owner, repo.repo, slug);
4815
+ } catch {
4816
+ return null;
4817
+ }
4818
+ const taskRefs = tranche.tasks.map((t) => ({ id: t.id, issue: t.issue }));
4819
+ const snapshot = await fetchForgeFacts({ owner: repo.owner, repo: repo.repo, tranche: slug, tasks: taskRefs });
4820
+ return {
4821
+ tasks: new Map(tranche.tasks.map((t) => [t.id, { id: t.id, issue: t.issue }])),
4822
+ facts: snapshot.facts
4823
+ };
4824
+ };
4825
+ var siblingTrancheCache = new Map;
4403
4826
  function edgeFromIssueJson(num, json) {
4404
4827
  if (json === null) {
4405
- return { issue: num, merged: false, open: false, issueState: null, stateReason: null, closedByActor: null };
4828
+ return {
4829
+ issue: num,
4830
+ merged: false,
4831
+ open: false,
4832
+ issueState: null,
4833
+ stateReason: null,
4834
+ closedByActor: null,
4835
+ resolved: true
4836
+ };
4406
4837
  }
4407
4838
  const state = json.state === "CLOSED" ? "closed" : json.state === "OPEN" ? "open" : null;
4408
4839
  const reason = json.stateReason === "COMPLETED" ? "completed" : json.stateReason === "NOT_PLANNED" ? "not_planned" : null;
@@ -4413,10 +4844,11 @@ function edgeFromIssueJson(num, json) {
4413
4844
  open: false,
4414
4845
  issueState: state,
4415
4846
  stateReason: reason,
4416
- closedByActor: null
4847
+ closedByActor: null,
4848
+ resolved: true
4417
4849
  };
4418
4850
  }
4419
- function resolveEdge(id, taskById, factsByTaskId, repo) {
4851
+ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = defaultResolveSiblingTranche) {
4420
4852
  const target = taskById.get(id);
4421
4853
  if (target) {
4422
4854
  const facts = target.issue !== null ? factsByTaskId.get(target.id) : undefined;
@@ -4426,7 +4858,8 @@ function resolveEdge(id, taskById, factsByTaskId, repo) {
4426
4858
  open: facts?.prState === "open",
4427
4859
  issueState: facts?.issueState ?? null,
4428
4860
  stateReason: facts?.stateReason ?? null,
4429
- closedByActor: facts?.closedByActor ?? null
4861
+ closedByActor: facts?.closedByActor ?? null,
4862
+ resolved: true
4430
4863
  };
4431
4864
  }
4432
4865
  const direct = id.match(DIRECT_ISSUE_REF);
@@ -4434,7 +4867,37 @@ function resolveEdge(id, taskById, factsByTaskId, repo) {
4434
4867
  const num = Number(direct[1]);
4435
4868
  return edgeFromIssueJson(num, fetchIssueState(num, repo));
4436
4869
  }
4437
- return { issue: null, merged: false, open: false, issueState: null, stateReason: null, closedByActor: null };
4870
+ const qualified = splitSlugQualifiedEdge(id);
4871
+ if (qualified) {
4872
+ const cacheKey = `${repo.owner}/${repo.repo}:${qualified.slug}`;
4873
+ let sibling = siblingTrancheCache.get(cacheKey);
4874
+ if (sibling === undefined) {
4875
+ sibling = await resolveSibling(qualified.slug, repo);
4876
+ siblingTrancheCache.set(cacheKey, sibling);
4877
+ }
4878
+ const siblingTask = sibling?.tasks.get(qualified.bareId);
4879
+ if (sibling && siblingTask) {
4880
+ const facts = siblingTask.issue !== null ? sibling.facts.get(siblingTask.id) : undefined;
4881
+ return {
4882
+ issue: siblingTask.issue,
4883
+ merged: facts?.prState === "merged",
4884
+ open: facts?.prState === "open",
4885
+ issueState: facts?.issueState ?? null,
4886
+ stateReason: facts?.stateReason ?? null,
4887
+ closedByActor: facts?.closedByActor ?? null,
4888
+ resolved: true
4889
+ };
4890
+ }
4891
+ }
4892
+ return {
4893
+ issue: null,
4894
+ merged: false,
4895
+ open: false,
4896
+ issueState: null,
4897
+ stateReason: null,
4898
+ closedByActor: null,
4899
+ resolved: false
4900
+ };
4438
4901
  }
4439
4902
 
4440
4903
  // src/checks/bin/check-first-push-dispatch.ts
@@ -4500,21 +4963,22 @@ async function classifyReadiness(trancheSlug, taskId) {
4500
4963
  const issueRationalePass = openIssueMatch ? checkIssueRationale(openIssueMatch.body).status !== "fail" : true;
4501
4964
  const taskById = new Map(tranche.tasks.map((t) => [t.id, t]));
4502
4965
  const factsByTaskId = snapshot.facts;
4503
- const dependsOn = task.dependsOn.map((dep) => {
4504
- const r = resolveEdge(dep, taskById, factsByTaskId, repo);
4966
+ const dependsOn = await Promise.all(task.dependsOn.map(async (dep) => {
4967
+ const r = await resolveEdge(dep, taskById, factsByTaskId, repo);
4505
4968
  return {
4506
4969
  id: dep,
4507
4970
  issue: r.issue,
4508
4971
  merged: r.merged,
4972
+ resolved: r.resolved,
4509
4973
  issueState: r.issueState,
4510
4974
  stateReason: r.stateReason,
4511
4975
  closedByActor: r.closedByActor
4512
4976
  };
4513
- });
4514
- const conflictsWith = task.conflictsWith.map((c) => {
4515
- const r = resolveEdge(c, taskById, factsByTaskId, repo);
4977
+ }));
4978
+ const conflictsWith = await Promise.all(task.conflictsWith.map(async (c) => {
4979
+ const r = await resolveEdge(c, taskById, factsByTaskId, repo);
4516
4980
  return { id: c, issue: r.issue, openOrInFlight: r.open };
4517
- });
4981
+ }));
4518
4982
  const input = {
4519
4983
  trancheSlug,
4520
4984
  task,