@attalabs/vinaya 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +74 -0
  2. package/aeg-root/enforcement.md +13 -6
  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 +1 -1
  6. package/aeg-root/roles/developer.md +3 -2
  7. package/aeg-root/roles/planner.md +1 -1
  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/tranche-model.md +1 -1
  12. package/dist/checks/bin/check-body-bare-digits.js +281 -5
  13. package/dist/checks/bin/check-branch-topology.js +274 -0
  14. package/dist/checks/bin/check-brief-shape.js +249 -0
  15. package/dist/checks/bin/check-changeset-coverage.js +4156 -0
  16. package/dist/checks/bin/check-closes-n.js +274 -0
  17. package/dist/checks/bin/check-coherence.js +305 -3
  18. package/dist/checks/bin/check-dead-branch-push.js +249 -0
  19. package/dist/checks/bin/check-dispatch-readiness.js +381 -20
  20. package/dist/checks/bin/check-doc-coverage-push.js +280 -3
  21. package/dist/checks/bin/check-doc-coverage.js +280 -3
  22. package/dist/checks/bin/check-doctrine-portability.js +280 -3
  23. package/dist/checks/bin/check-evidence-fresh.js +249 -0
  24. package/dist/checks/bin/check-first-push-dispatch.js +372 -14
  25. package/dist/checks/bin/check-issue-assignment.js +274 -0
  26. package/dist/checks/bin/check-main-branch-refusal.js +249 -0
  27. package/dist/checks/bin/check-no-disk-state.js +249 -0
  28. package/dist/checks/bin/check-quoted-command.js +4405 -0
  29. package/dist/checks/bin/check-reader-resolvable-prose.js +282 -5
  30. package/dist/checks/bin/check-registry-gates.js +282 -0
  31. package/dist/checks/bin/check-retired-vocabulary.js +282 -5
  32. package/dist/checks/bin/check-review-gate.js +280 -3
  33. package/dist/checks/bin/check-single-plan-pr.js +249 -0
  34. package/dist/checks/bin/check-test-plan.js +249 -0
  35. package/dist/checks/bin/check-token-collection-wired.js +3975 -0
  36. package/dist/checks/bin/check-workspace-escape.js +249 -0
  37. package/dist/index.js +1523 -630
  38. package/package.json +1 -1
  39. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  40. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  41. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  42. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  43. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  44. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  45. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  46. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  47. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  48. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  49. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  50. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js +2 -2
  51. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  52. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  53. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  54. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  55. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js +2 -2
  56. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  57. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  58. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  59. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +2 -2
  60. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  61. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  62. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  63. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +3 -3
  64. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  65. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  66. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +3 -3
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  70. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +2 -2
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +3 -3
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +3 -3
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +3 -3
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +2 -2
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +1 -1
  87. 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
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0053k9k._.js +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0112h-k._.js +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__040smoa._.js +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0cxtq46._.js +25 -18
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0o771t1._.js +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__16cuydh._.js → [root-of-the-server]__0ozbaq0._.js} +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0puovz5._.js +1 -1
  95. 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
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__18kqy4q._.js +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1hs0dcu._.js +1 -1
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1widio3._.js +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1yoa8tx._.js +3 -0
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_03x_w6q._.js +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gvm3og._.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0lwxg63._.js +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0wxycau._.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0x999pb._.js +1 -1
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-6rzip._.js +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1fqw88f._.js +2 -2
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_0zys35s._.js → _1mqrlbl._.js} +2 -2
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_1c9b9j-._.js → _1mrtj0f._.js} +2 -2
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1n0cnq-._.js +1 -1
  112. 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
  113. 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
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_1vo08dj._.js +2 -2
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +3 -3
  119. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0r4i_ks9z02bw.js +1 -0
  120. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0ea8-8nopz29h.js → 1hfhxjy577l5d.js} +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1k916ih3p4nsg.js +1 -0
  122. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{29-foak16tjfu.js → 1t2kft7bxzuxn.js} +1 -1
  123. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1ybrihl5_aocy.js +1 -0
  124. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{30ojnsx3p4lp4.js → 1yqs2zgvwa4p1.js} +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0msr2a1i-x-br.js → 25kbt5k-xb2a5.js} +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2twnwe77d4n-m.js → 2_k6j1o9q5nn4.js} +4 -4
  127. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2hmannd4bjhzy.js +1 -0
  128. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3mqu_uhluy19i.css +1 -0
  129. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1rku4gz._.js +0 -3
  131. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0la0hhmjprdxm.css +0 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1lk7h-0buf4ab.js +0 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/25j-y57ng11hl.js +0 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/30lyvn0yzwdiz.js +0 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/35u8inxa732is.js +0 -1
  136. /package/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  137. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{b2VfZK2AItZwlghK_pUN0 → crNCHQ9uAgKOYC6DKkZma}/_buildManifest.js +0 -0
  138. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{b2VfZK2AItZwlghK_pUN0 → crNCHQ9uAgKOYC6DKkZma}/_clientMiddlewareManifest.js +0 -0
  139. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{b2VfZK2AItZwlghK_pUN0 → crNCHQ9uAgKOYC6DKkZma}/_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,151 @@ var DERIVED_STATUSES = [
1785
1791
  "incoherent"
1786
1792
  ];
1787
1793
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1794
+ // ../../packages/aeg-core/src/report-tokens.ts
1795
+ var DASH_LOOKALIKES = {
1796
+ "-": "‑",
1797
+ "–": "‒",
1798
+ "—": "―"
1799
+ };
1800
+ var DASH_CHARS = new Set(Object.keys(DASH_LOOKALIKES));
1801
+ // ../../packages/aeg-core/src/claude-code-transcript.ts
1802
+ function summarizeTranscript(jsonl) {
1803
+ const seen = new Set;
1804
+ const components = {
1805
+ inputTokens: 0,
1806
+ outputTokens: 0,
1807
+ cacheCreationInputTokens: 0,
1808
+ cacheReadInputTokens: 0
1809
+ };
1810
+ let model = null;
1811
+ let messageCount = 0;
1812
+ for (const rawLine of jsonl.split(/\r?\n/)) {
1813
+ const line = rawLine.trim();
1814
+ if (!line)
1815
+ continue;
1816
+ let entry2;
1817
+ try {
1818
+ entry2 = JSON.parse(line);
1819
+ } catch {
1820
+ continue;
1821
+ }
1822
+ if (!entry2 || typeof entry2 !== "object")
1823
+ continue;
1824
+ const obj = entry2;
1825
+ if (obj.type !== "assistant")
1826
+ continue;
1827
+ const message = obj.message;
1828
+ const id = message?.id;
1829
+ const usage = message?.usage;
1830
+ if (typeof id !== "string" || !id || !usage || seen.has(id))
1831
+ continue;
1832
+ seen.add(id);
1833
+ messageCount++;
1834
+ components.inputTokens += numberOr(usage.input_tokens, 0);
1835
+ components.outputTokens += numberOr(usage.output_tokens, 0);
1836
+ components.cacheCreationInputTokens += numberOr(usage.cache_creation_input_tokens, 0);
1837
+ components.cacheReadInputTokens += numberOr(usage.cache_read_input_tokens, 0);
1838
+ const messageModel = message?.model;
1839
+ if (typeof messageModel === "string" && messageModel)
1840
+ model = messageModel;
1841
+ }
1842
+ return { components, model, messageCount };
1843
+ }
1844
+ function numberOr(value, fallback) {
1845
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
1846
+ }
1847
+ function sanitizeKey(value) {
1848
+ return value.replace(/[^A-Za-z0-9]+/g, "-");
1849
+ }
1850
+ function transcriptPointerPath(projectDir, tmpDir) {
1851
+ return `${tmpDir}/claude-transcript-${sanitizeKey(projectDir)}.txt`;
1852
+ }
1853
+ function resolvePointer(explicitTranscriptPath, deps) {
1854
+ if (explicitTranscriptPath)
1855
+ return { path: explicitTranscriptPath, corroborated: true };
1856
+ const projectDir = deps.env.CLAUDE_PROJECT_DIR ?? deps.cwd;
1857
+ const tmpDir = deps.env.TMPDIR ?? "/tmp";
1858
+ const pointerPath = transcriptPointerPath(projectDir, tmpDir);
1859
+ const currentSessionId = deps.env.CLAUDE_CODE_SESSION_ID;
1860
+ if (!deps.exists(pointerPath)) {
1861
+ return {
1862
+ pointerExisted: false,
1863
+ corroborated: false,
1864
+ error: `No transcript pointer at ${pointerPath} and no --transcript given. ` + "Either this repo installs no track-transcript.sh Stop hook (lacking one is not a defect — " + "name the transcript directly instead), or no session has completed a turn yet."
1865
+ };
1866
+ }
1867
+ let contents;
1868
+ try {
1869
+ contents = deps.readFile(pointerPath).replace(/\r?\n+$/, "");
1870
+ } catch (err) {
1871
+ return {
1872
+ pointerExisted: true,
1873
+ oursByLocation: true,
1874
+ 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."
1875
+ };
1876
+ }
1877
+ const [pointerSessionId, transcriptPath] = contents.split("\t");
1878
+ if (!transcriptPath) {
1879
+ return {
1880
+ pointerExisted: true,
1881
+ oursByLocation: true,
1882
+ 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."
1883
+ };
1884
+ }
1885
+ if (currentSessionId && pointerSessionId && currentSessionId !== pointerSessionId) {
1886
+ return {
1887
+ pointerExisted: true,
1888
+ corroborated: false,
1889
+ 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."
1890
+ };
1891
+ }
1892
+ return { path: transcriptPath, corroborated: Boolean(currentSessionId && pointerSessionId) };
1893
+ }
1894
+ function resolveMeteringCapability(deps, explicitTranscriptPath) {
1895
+ const resolved = resolvePointer(explicitTranscriptPath, deps);
1896
+ if ("error" in resolved) {
1897
+ const ours = resolved.pointerExisted && (resolved.corroborated || resolved.oursByLocation);
1898
+ if (ours)
1899
+ return { capable: false, reason: "pointer-unusable", detail: resolved.error };
1900
+ return {
1901
+ capable: false,
1902
+ reason: "no-transcript-resolved",
1903
+ 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
1904
+ };
1905
+ }
1906
+ const downstream = (r, detail) => resolved.corroborated ? { reason: r, detail } : {
1907
+ reason: "no-transcript-resolved",
1908
+ 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})`
1909
+ };
1910
+ if (!deps.exists(resolved.path)) {
1911
+ return {
1912
+ capable: false,
1913
+ ...downstream("transcript-unreadable", `Resolved transcript path ${resolved.path} is not readable as a regular file owned by this user.`)
1914
+ };
1915
+ }
1916
+ let jsonl;
1917
+ try {
1918
+ jsonl = deps.readFile(resolved.path);
1919
+ } catch (err) {
1920
+ return {
1921
+ capable: false,
1922
+ ...downstream("transcript-unreadable", `Transcript at ${resolved.path} could not be read: ${err.message}`)
1923
+ };
1924
+ }
1925
+ const summary = summarizeTranscript(jsonl);
1926
+ if (summary.messageCount === 0) {
1927
+ return {
1928
+ capable: false,
1929
+ ...downstream("transcript-empty", `Transcript at ${resolved.path} yielded zero assistant messages with usage data — ` + "it's empty, unparseable, or not yet flushed to disk.")
1930
+ };
1931
+ }
1932
+ return { capable: true, transcriptPath: resolved.path, summary };
1933
+ }
1934
+ function isTokenCollectionWiringBroken(capability) {
1935
+ if (capability.capable)
1936
+ return false;
1937
+ return capability.reason !== "no-transcript-resolved";
1938
+ }
1788
1939
  // ../../packages/aeg-core/src/file-classify.ts
1789
1940
  function isCodeFile(p) {
1790
1941
  if (p.endsWith(".md"))
@@ -3216,6 +3367,100 @@ function parseGlossaryTerms(glossaryContent) {
3216
3367
  }
3217
3368
  return terms;
3218
3369
  }
3370
+ // ../../packages/aeg-core/src/quoted-command.ts
3371
+ var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3372
+ var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3373
+ var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
3374
+ var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
3375
+ function isValidCitedFilePath(path) {
3376
+ if (path.length === 0)
3377
+ return false;
3378
+ if (path.startsWith("/") || path.startsWith("\\"))
3379
+ return false;
3380
+ if (/^[A-Za-z]:[\\/]/.test(path))
3381
+ return false;
3382
+ return !path.split(/[\\/]+/).includes("..");
3383
+ }
3384
+ function quotedCommandLineAt(content, index) {
3385
+ let line = 1;
3386
+ for (let i = 0;i < index; i++) {
3387
+ if (content.charCodeAt(i) === 10)
3388
+ line++;
3389
+ }
3390
+ return line;
3391
+ }
3392
+ function extractQuotedText(raw) {
3393
+ const trimmed = raw.trim();
3394
+ const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
3395
+ if (fenced)
3396
+ return (fenced[1] ?? "").trim();
3397
+ const inline = /^`([^`]+)`$/.exec(trimmed);
3398
+ if (inline)
3399
+ return (inline[1] ?? "").trim();
3400
+ return trimmed;
3401
+ }
3402
+ function findQuotesInFile(path, content) {
3403
+ const masked = maskCode(content);
3404
+ const quotes = [];
3405
+ START_PATTERN.lastIndex = 0;
3406
+ let start = START_PATTERN.exec(masked);
3407
+ while (start !== null) {
3408
+ const citedFile = start[1];
3409
+ const innerStart = start.index + start[0].length;
3410
+ const end = END_PATTERN.exec(masked.slice(innerStart));
3411
+ if (end === null) {
3412
+ START_PATTERN.lastIndex = innerStart;
3413
+ start = START_PATTERN.exec(masked);
3414
+ continue;
3415
+ }
3416
+ const innerEnd = innerStart + end.index;
3417
+ if (isValidCitedFilePath(citedFile)) {
3418
+ const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
3419
+ if (quotedText.length > 0) {
3420
+ quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
3421
+ }
3422
+ }
3423
+ START_PATTERN.lastIndex = innerEnd + end[0].length;
3424
+ start = START_PATTERN.exec(masked);
3425
+ }
3426
+ return quotes;
3427
+ }
3428
+ function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
3429
+ const quotes = [];
3430
+ for (const file of files) {
3431
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3432
+ if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
3433
+ continue;
3434
+ quotes.push(...findQuotesInFile(file.path, file.content));
3435
+ }
3436
+ return quotes;
3437
+ }
3438
+ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3439
+ const findings = [];
3440
+ for (const quote of citedQuotes) {
3441
+ const content = citedFileContents.get(quote.citedFile);
3442
+ if (content === undefined) {
3443
+ findings.push({
3444
+ file: quote.file,
3445
+ line: quote.line,
3446
+ citedFile: quote.citedFile,
3447
+ quotedText: quote.quotedText,
3448
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
3449
+ });
3450
+ continue;
3451
+ }
3452
+ if (!content.includes(quote.quotedText)) {
3453
+ findings.push({
3454
+ file: quote.file,
3455
+ line: quote.line,
3456
+ citedFile: quote.citedFile,
3457
+ quotedText: quote.quotedText,
3458
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
3459
+ });
3460
+ }
3461
+ }
3462
+ return findings;
3463
+ }
3219
3464
  // ../../packages/aeg-core/src/retired-vocabulary.ts
3220
3465
  var RETIRED_PATTERNS = [
3221
3466
  String.raw`\bD-[0-9]{3}\b`,
@@ -3329,6 +3574,10 @@ function checkDispatchReadiness(input) {
3329
3574
  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
3575
  }
3331
3576
  for (const dep of input.dependsOn) {
3577
+ if (dep.resolved === false) {
3578
+ 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.`);
3579
+ continue;
3580
+ }
3332
3581
  if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
3333
3582
  const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
3334
3583
  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 +4065,18 @@ var COMMANDS = [
3816
4065
  ],
3817
4066
  status: "shipped"
3818
4067
  },
4068
+ {
4069
+ name: "pr verify-evidence",
4070
+ description: "Prove a pull request's AEG:EVIDENCE region was machine-generated — regenerate it and compare",
4071
+ flags: [],
4072
+ details: [
4073
+ "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.",
4074
+ "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.",
4075
+ "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.",
4076
+ "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."
4077
+ ],
4078
+ status: "shipped"
4079
+ },
3819
4080
  {
3820
4081
  name: "issue create",
3821
4082
  description: "Open an issue after full brief-schema validation",
@@ -3892,6 +4153,19 @@ var COMMANDS = [
3892
4153
  ],
3893
4154
  status: "shipped"
3894
4155
  },
4156
+ {
4157
+ name: "milestone close",
4158
+ description: "Close a tranche's Milestone after verifying every labeled Issue is actually attached",
4159
+ flags: [
4160
+ { flag: "--slug", description: "The tranche whose Milestone is being closed" },
4161
+ { flag: "--validate-only", description: "Run every gate and report PASS without closing the Milestone" },
4162
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
4163
+ ],
4164
+ details: [
4165
+ "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."
4166
+ ],
4167
+ status: "shipped"
4168
+ },
3895
4169
  {
3896
4170
  name: "review post",
3897
4171
  description: "Render, post, and self-verify a code-reviewer or security-review verdict comment on a PR",
@@ -4101,9 +4375,9 @@ function emitCheckError(error) {
4101
4375
 
4102
4376
  // src/lib/config.ts
4103
4377
  import { execFileSync as execFileSync2 } from "node:child_process";
4104
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4378
+ import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
4105
4379
  import { homedir } from "node:os";
4106
- import { dirname, join } from "node:path";
4380
+ import { dirname, join, resolve } from "node:path";
4107
4381
  import { z as z2 } from "zod";
4108
4382
 
4109
4383
  // src/lib/agent-vendors.ts
@@ -4211,6 +4485,20 @@ var ManagedManifestSchema = z2.object({
4211
4485
  labels: z2.array(z2.string()),
4212
4486
  agents: z2.array(z2.enum(AGENT_VENDORS)).optional()
4213
4487
  });
4488
+ var ProjectEntrySchema = z2.object({
4489
+ name: z2.string().min(1),
4490
+ description: z2.string().min(1).optional(),
4491
+ path: z2.string().min(1).optional()
4492
+ });
4493
+ function parseTokensCollectDeclaration(value) {
4494
+ const m = value.trim().match(/^(\S+)\s+(\S+)$/);
4495
+ if (!m)
4496
+ return null;
4497
+ const [, interpreter, script] = m;
4498
+ if (!isSafeRepoRelPath(script))
4499
+ return null;
4500
+ return { interpreter, script };
4501
+ }
4214
4502
  var VinayaConfigSchema = z2.object({
4215
4503
  rings: z2.object({
4216
4504
  ring1_forgeWriteInterception: z2.boolean(),
@@ -4223,13 +4511,19 @@ var VinayaConfigSchema = z2.object({
4223
4511
  principals: z2.array(z2.string()).min(1).optional(),
4224
4512
  releaseActor: z2.string().min(1).optional(),
4225
4513
  ci: z2.object({ setup: z2.string().min(1) }).optional(),
4514
+ tokens: z2.object({
4515
+ collect: z2.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
4516
+ message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
4517
+ })
4518
+ }).optional(),
4226
4519
  blastRadius: z2.object({ extraDomains: z2.array(z2.string()).optional() }).optional(),
4227
4520
  proseGates: z2.object({
4228
4521
  doctrineRoot: z2.string().min(1).optional(),
4229
4522
  readerFacingPrefix: z2.string().min(1).optional(),
4230
4523
  readerFacingSuffix: z2.string().min(1).optional(),
4231
4524
  legacySlugDir: z2.string().min(1).optional()
4232
- }).optional()
4525
+ }).optional(),
4526
+ projects: z2.array(ProjectEntrySchema).optional()
4233
4527
  });
4234
4528
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
4235
4529
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -4268,6 +4562,9 @@ function globalRolesIgnoredWarning(path) {
4268
4562
  function globalReleaseActorIgnoredWarning(path) {
4269
4563
  return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
4270
4564
  }
4565
+ function globalTokensCollectIgnoredWarning(path) {
4566
+ return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
4567
+ }
4271
4568
  function stripGlobalOnlyKeys(config, path) {
4272
4569
  if (path !== GLOBAL_CONFIG_PATH)
4273
4570
  return config;
@@ -4288,6 +4585,10 @@ function stripGlobalOnlyKeys(config, path) {
4288
4585
  console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
4289
4586
  result = { ...result, releaseActor: undefined };
4290
4587
  }
4588
+ if (result.tokens) {
4589
+ console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
4590
+ result = { ...result, tokens: undefined };
4591
+ }
4291
4592
  return result;
4292
4593
  }
4293
4594
  function resolvePrincipalAllowlist(config) {
@@ -4373,6 +4674,7 @@ function loadConfig() {
4373
4674
  return null;
4374
4675
  }
4375
4676
  }
4677
+ var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
4376
4678
 
4377
4679
  // src/checks/edge-resolve.ts
4378
4680
  import { execFileSync as execFileSync3 } from "node:child_process";
@@ -4400,9 +4702,32 @@ function fetchIssueState(num, repo) {
4400
4702
  issueCache.set(key, out);
4401
4703
  return out;
4402
4704
  }
4705
+ var defaultResolveSiblingTranche = async (slug, repo) => {
4706
+ let tranche;
4707
+ try {
4708
+ tranche = await deriveTrancheFromForge(repo.owner, repo.repo, slug);
4709
+ } catch {
4710
+ return null;
4711
+ }
4712
+ const taskRefs = tranche.tasks.map((t) => ({ id: t.id, issue: t.issue }));
4713
+ const snapshot = await fetchForgeFacts({ owner: repo.owner, repo: repo.repo, tranche: slug, tasks: taskRefs });
4714
+ return {
4715
+ tasks: new Map(tranche.tasks.map((t) => [t.id, { id: t.id, issue: t.issue }])),
4716
+ facts: snapshot.facts
4717
+ };
4718
+ };
4719
+ var siblingTrancheCache = new Map;
4403
4720
  function edgeFromIssueJson(num, json) {
4404
4721
  if (json === null) {
4405
- return { issue: num, merged: false, open: false, issueState: null, stateReason: null, closedByActor: null };
4722
+ return {
4723
+ issue: num,
4724
+ merged: false,
4725
+ open: false,
4726
+ issueState: null,
4727
+ stateReason: null,
4728
+ closedByActor: null,
4729
+ resolved: true
4730
+ };
4406
4731
  }
4407
4732
  const state = json.state === "CLOSED" ? "closed" : json.state === "OPEN" ? "open" : null;
4408
4733
  const reason = json.stateReason === "COMPLETED" ? "completed" : json.stateReason === "NOT_PLANNED" ? "not_planned" : null;
@@ -4413,10 +4738,11 @@ function edgeFromIssueJson(num, json) {
4413
4738
  open: false,
4414
4739
  issueState: state,
4415
4740
  stateReason: reason,
4416
- closedByActor: null
4741
+ closedByActor: null,
4742
+ resolved: true
4417
4743
  };
4418
4744
  }
4419
- function resolveEdge(id, taskById, factsByTaskId, repo) {
4745
+ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = defaultResolveSiblingTranche) {
4420
4746
  const target = taskById.get(id);
4421
4747
  if (target) {
4422
4748
  const facts = target.issue !== null ? factsByTaskId.get(target.id) : undefined;
@@ -4426,7 +4752,8 @@ function resolveEdge(id, taskById, factsByTaskId, repo) {
4426
4752
  open: facts?.prState === "open",
4427
4753
  issueState: facts?.issueState ?? null,
4428
4754
  stateReason: facts?.stateReason ?? null,
4429
- closedByActor: facts?.closedByActor ?? null
4755
+ closedByActor: facts?.closedByActor ?? null,
4756
+ resolved: true
4430
4757
  };
4431
4758
  }
4432
4759
  const direct = id.match(DIRECT_ISSUE_REF);
@@ -4434,7 +4761,37 @@ function resolveEdge(id, taskById, factsByTaskId, repo) {
4434
4761
  const num = Number(direct[1]);
4435
4762
  return edgeFromIssueJson(num, fetchIssueState(num, repo));
4436
4763
  }
4437
- return { issue: null, merged: false, open: false, issueState: null, stateReason: null, closedByActor: null };
4764
+ const qualified = splitSlugQualifiedEdge(id);
4765
+ if (qualified) {
4766
+ const cacheKey = `${repo.owner}/${repo.repo}:${qualified.slug}`;
4767
+ let sibling = siblingTrancheCache.get(cacheKey);
4768
+ if (sibling === undefined) {
4769
+ sibling = await resolveSibling(qualified.slug, repo);
4770
+ siblingTrancheCache.set(cacheKey, sibling);
4771
+ }
4772
+ const siblingTask = sibling?.tasks.get(qualified.bareId);
4773
+ if (sibling && siblingTask) {
4774
+ const facts = siblingTask.issue !== null ? sibling.facts.get(siblingTask.id) : undefined;
4775
+ return {
4776
+ issue: siblingTask.issue,
4777
+ merged: facts?.prState === "merged",
4778
+ open: facts?.prState === "open",
4779
+ issueState: facts?.issueState ?? null,
4780
+ stateReason: facts?.stateReason ?? null,
4781
+ closedByActor: facts?.closedByActor ?? null,
4782
+ resolved: true
4783
+ };
4784
+ }
4785
+ }
4786
+ return {
4787
+ issue: null,
4788
+ merged: false,
4789
+ open: false,
4790
+ issueState: null,
4791
+ stateReason: null,
4792
+ closedByActor: null,
4793
+ resolved: false
4794
+ };
4438
4795
  }
4439
4796
 
4440
4797
  // src/checks/bin/check-first-push-dispatch.ts
@@ -4500,21 +4857,22 @@ async function classifyReadiness(trancheSlug, taskId) {
4500
4857
  const issueRationalePass = openIssueMatch ? checkIssueRationale(openIssueMatch.body).status !== "fail" : true;
4501
4858
  const taskById = new Map(tranche.tasks.map((t) => [t.id, t]));
4502
4859
  const factsByTaskId = snapshot.facts;
4503
- const dependsOn = task.dependsOn.map((dep) => {
4504
- const r = resolveEdge(dep, taskById, factsByTaskId, repo);
4860
+ const dependsOn = await Promise.all(task.dependsOn.map(async (dep) => {
4861
+ const r = await resolveEdge(dep, taskById, factsByTaskId, repo);
4505
4862
  return {
4506
4863
  id: dep,
4507
4864
  issue: r.issue,
4508
4865
  merged: r.merged,
4866
+ resolved: r.resolved,
4509
4867
  issueState: r.issueState,
4510
4868
  stateReason: r.stateReason,
4511
4869
  closedByActor: r.closedByActor
4512
4870
  };
4513
- });
4514
- const conflictsWith = task.conflictsWith.map((c) => {
4515
- const r = resolveEdge(c, taskById, factsByTaskId, repo);
4871
+ }));
4872
+ const conflictsWith = await Promise.all(task.conflictsWith.map(async (c) => {
4873
+ const r = await resolveEdge(c, taskById, factsByTaskId, repo);
4516
4874
  return { id: c, issue: r.issue, openOrInFlight: r.open };
4517
- });
4875
+ }));
4518
4876
  const input = {
4519
4877
  trancheSlug,
4520
4878
  task,