@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
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/checks/bin/check-dispatch-readiness.ts
4
4
  import { execFile as execFile4, execFileSync as execFileSync4 } from "node:child_process";
5
- import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync } from "node:fs";
5
+ import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
6
6
  import { sep as sep2 } from "node:path";
7
7
  import { promisify as promisify4 } from "node:util";
8
8
  // ../../packages/aeg-core/src/gate-audience.ts
@@ -192,6 +192,12 @@ var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
192
192
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
193
193
  var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
194
194
  var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
195
+ function splitSlugQualifiedEdge(edge) {
196
+ const m = edge.trim().match(SLUG_QUALIFIED_ID);
197
+ if (!m)
198
+ return null;
199
+ return { slug: m[1], bareId: m[2] };
200
+ }
195
201
  function isEmptyMarker(s) {
196
202
  const t = s.trim();
197
203
  return t === "" || t === "—" || t === "-" || t === "–";
@@ -1788,6 +1794,151 @@ var DERIVED_STATUSES = [
1788
1794
  "incoherent"
1789
1795
  ];
1790
1796
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1797
+ // ../../packages/aeg-core/src/report-tokens.ts
1798
+ var DASH_LOOKALIKES = {
1799
+ "-": "‑",
1800
+ "–": "‒",
1801
+ "—": "―"
1802
+ };
1803
+ var DASH_CHARS = new Set(Object.keys(DASH_LOOKALIKES));
1804
+ // ../../packages/aeg-core/src/claude-code-transcript.ts
1805
+ function summarizeTranscript(jsonl) {
1806
+ const seen = new Set;
1807
+ const components = {
1808
+ inputTokens: 0,
1809
+ outputTokens: 0,
1810
+ cacheCreationInputTokens: 0,
1811
+ cacheReadInputTokens: 0
1812
+ };
1813
+ let model = null;
1814
+ let messageCount = 0;
1815
+ for (const rawLine of jsonl.split(/\r?\n/)) {
1816
+ const line = rawLine.trim();
1817
+ if (!line)
1818
+ continue;
1819
+ let entry2;
1820
+ try {
1821
+ entry2 = JSON.parse(line);
1822
+ } catch {
1823
+ continue;
1824
+ }
1825
+ if (!entry2 || typeof entry2 !== "object")
1826
+ continue;
1827
+ const obj = entry2;
1828
+ if (obj.type !== "assistant")
1829
+ continue;
1830
+ const message = obj.message;
1831
+ const id = message?.id;
1832
+ const usage = message?.usage;
1833
+ if (typeof id !== "string" || !id || !usage || seen.has(id))
1834
+ continue;
1835
+ seen.add(id);
1836
+ messageCount++;
1837
+ components.inputTokens += numberOr(usage.input_tokens, 0);
1838
+ components.outputTokens += numberOr(usage.output_tokens, 0);
1839
+ components.cacheCreationInputTokens += numberOr(usage.cache_creation_input_tokens, 0);
1840
+ components.cacheReadInputTokens += numberOr(usage.cache_read_input_tokens, 0);
1841
+ const messageModel = message?.model;
1842
+ if (typeof messageModel === "string" && messageModel)
1843
+ model = messageModel;
1844
+ }
1845
+ return { components, model, messageCount };
1846
+ }
1847
+ function numberOr(value, fallback) {
1848
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
1849
+ }
1850
+ function sanitizeKey(value) {
1851
+ return value.replace(/[^A-Za-z0-9]+/g, "-");
1852
+ }
1853
+ function transcriptPointerPath(projectDir, tmpDir) {
1854
+ return `${tmpDir}/claude-transcript-${sanitizeKey(projectDir)}.txt`;
1855
+ }
1856
+ function resolvePointer(explicitTranscriptPath, deps) {
1857
+ if (explicitTranscriptPath)
1858
+ return { path: explicitTranscriptPath, corroborated: true };
1859
+ const projectDir = deps.env.CLAUDE_PROJECT_DIR ?? deps.cwd;
1860
+ const tmpDir = deps.env.TMPDIR ?? "/tmp";
1861
+ const pointerPath = transcriptPointerPath(projectDir, tmpDir);
1862
+ const currentSessionId = deps.env.CLAUDE_CODE_SESSION_ID;
1863
+ if (!deps.exists(pointerPath)) {
1864
+ return {
1865
+ pointerExisted: false,
1866
+ corroborated: false,
1867
+ 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."
1868
+ };
1869
+ }
1870
+ let contents;
1871
+ try {
1872
+ contents = deps.readFile(pointerPath).replace(/\r?\n+$/, "");
1873
+ } catch (err) {
1874
+ return {
1875
+ pointerExisted: true,
1876
+ oursByLocation: true,
1877
+ 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."
1878
+ };
1879
+ }
1880
+ const [pointerSessionId, transcriptPath] = contents.split("\t");
1881
+ if (!transcriptPath) {
1882
+ return {
1883
+ pointerExisted: true,
1884
+ oursByLocation: true,
1885
+ 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."
1886
+ };
1887
+ }
1888
+ if (currentSessionId && pointerSessionId && currentSessionId !== pointerSessionId) {
1889
+ return {
1890
+ pointerExisted: true,
1891
+ corroborated: false,
1892
+ 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."
1893
+ };
1894
+ }
1895
+ return { path: transcriptPath, corroborated: Boolean(currentSessionId && pointerSessionId) };
1896
+ }
1897
+ function resolveMeteringCapability(deps, explicitTranscriptPath) {
1898
+ const resolved = resolvePointer(explicitTranscriptPath, deps);
1899
+ if ("error" in resolved) {
1900
+ const ours = resolved.pointerExisted && (resolved.corroborated || resolved.oursByLocation);
1901
+ if (ours)
1902
+ return { capable: false, reason: "pointer-unusable", detail: resolved.error };
1903
+ return {
1904
+ capable: false,
1905
+ reason: "no-transcript-resolved",
1906
+ 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
1907
+ };
1908
+ }
1909
+ const downstream = (r, detail) => resolved.corroborated ? { reason: r, detail } : {
1910
+ reason: "no-transcript-resolved",
1911
+ 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})`
1912
+ };
1913
+ if (!deps.exists(resolved.path)) {
1914
+ return {
1915
+ capable: false,
1916
+ ...downstream("transcript-unreadable", `Resolved transcript path ${resolved.path} is not readable as a regular file owned by this user.`)
1917
+ };
1918
+ }
1919
+ let jsonl;
1920
+ try {
1921
+ jsonl = deps.readFile(resolved.path);
1922
+ } catch (err) {
1923
+ return {
1924
+ capable: false,
1925
+ ...downstream("transcript-unreadable", `Transcript at ${resolved.path} could not be read: ${err.message}`)
1926
+ };
1927
+ }
1928
+ const summary = summarizeTranscript(jsonl);
1929
+ if (summary.messageCount === 0) {
1930
+ return {
1931
+ capable: false,
1932
+ ...downstream("transcript-empty", `Transcript at ${resolved.path} yielded zero assistant messages with usage data — ` + "it's empty, unparseable, or not yet flushed to disk.")
1933
+ };
1934
+ }
1935
+ return { capable: true, transcriptPath: resolved.path, summary };
1936
+ }
1937
+ function isTokenCollectionWiringBroken(capability) {
1938
+ if (capability.capable)
1939
+ return false;
1940
+ return capability.reason !== "no-transcript-resolved";
1941
+ }
1791
1942
  // ../../packages/aeg-core/src/file-classify.ts
1792
1943
  function isCodeFile(p) {
1793
1944
  if (p.endsWith(".md"))
@@ -3219,6 +3370,100 @@ function parseGlossaryTerms(glossaryContent) {
3219
3370
  }
3220
3371
  return terms;
3221
3372
  }
3373
+ // ../../packages/aeg-core/src/quoted-command.ts
3374
+ var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3375
+ var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3376
+ var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
3377
+ var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
3378
+ function isValidCitedFilePath(path) {
3379
+ if (path.length === 0)
3380
+ return false;
3381
+ if (path.startsWith("/") || path.startsWith("\\"))
3382
+ return false;
3383
+ if (/^[A-Za-z]:[\\/]/.test(path))
3384
+ return false;
3385
+ return !path.split(/[\\/]+/).includes("..");
3386
+ }
3387
+ function quotedCommandLineAt(content, index) {
3388
+ let line = 1;
3389
+ for (let i = 0;i < index; i++) {
3390
+ if (content.charCodeAt(i) === 10)
3391
+ line++;
3392
+ }
3393
+ return line;
3394
+ }
3395
+ function extractQuotedText(raw) {
3396
+ const trimmed = raw.trim();
3397
+ const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
3398
+ if (fenced)
3399
+ return (fenced[1] ?? "").trim();
3400
+ const inline = /^`([^`]+)`$/.exec(trimmed);
3401
+ if (inline)
3402
+ return (inline[1] ?? "").trim();
3403
+ return trimmed;
3404
+ }
3405
+ function findQuotesInFile(path, content) {
3406
+ const masked = maskCode(content);
3407
+ const quotes = [];
3408
+ START_PATTERN.lastIndex = 0;
3409
+ let start = START_PATTERN.exec(masked);
3410
+ while (start !== null) {
3411
+ const citedFile = start[1];
3412
+ const innerStart = start.index + start[0].length;
3413
+ const end = END_PATTERN.exec(masked.slice(innerStart));
3414
+ if (end === null) {
3415
+ START_PATTERN.lastIndex = innerStart;
3416
+ start = START_PATTERN.exec(masked);
3417
+ continue;
3418
+ }
3419
+ const innerEnd = innerStart + end.index;
3420
+ if (isValidCitedFilePath(citedFile)) {
3421
+ const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
3422
+ if (quotedText.length > 0) {
3423
+ quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
3424
+ }
3425
+ }
3426
+ START_PATTERN.lastIndex = innerEnd + end[0].length;
3427
+ start = START_PATTERN.exec(masked);
3428
+ }
3429
+ return quotes;
3430
+ }
3431
+ function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
3432
+ const quotes = [];
3433
+ for (const file of files) {
3434
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3435
+ if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
3436
+ continue;
3437
+ quotes.push(...findQuotesInFile(file.path, file.content));
3438
+ }
3439
+ return quotes;
3440
+ }
3441
+ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3442
+ const findings = [];
3443
+ for (const quote of citedQuotes) {
3444
+ const content = citedFileContents.get(quote.citedFile);
3445
+ if (content === undefined) {
3446
+ findings.push({
3447
+ file: quote.file,
3448
+ line: quote.line,
3449
+ citedFile: quote.citedFile,
3450
+ quotedText: quote.quotedText,
3451
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
3452
+ });
3453
+ continue;
3454
+ }
3455
+ if (!content.includes(quote.quotedText)) {
3456
+ findings.push({
3457
+ file: quote.file,
3458
+ line: quote.line,
3459
+ citedFile: quote.citedFile,
3460
+ quotedText: quote.quotedText,
3461
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
3462
+ });
3463
+ }
3464
+ }
3465
+ return findings;
3466
+ }
3222
3467
  // ../../packages/aeg-core/src/retired-vocabulary.ts
3223
3468
  var RETIRED_PATTERNS = [
3224
3469
  String.raw`\bD-[0-9]{3}\b`,
@@ -3332,6 +3577,10 @@ function checkDispatchReadiness(input) {
3332
3577
  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.`);
3333
3578
  }
3334
3579
  for (const dep of input.dependsOn) {
3580
+ if (dep.resolved === false) {
3581
+ 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.`);
3582
+ continue;
3583
+ }
3335
3584
  if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
3336
3585
  const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
3337
3586
  blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
@@ -3819,6 +4068,18 @@ var COMMANDS = [
3819
4068
  ],
3820
4069
  status: "shipped"
3821
4070
  },
4071
+ {
4072
+ name: "pr verify-evidence",
4073
+ description: "Prove a pull request's AEG:EVIDENCE region was machine-generated — regenerate it and compare",
4074
+ flags: [],
4075
+ details: [
4076
+ "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.",
4077
+ "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.",
4078
+ "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.",
4079
+ "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."
4080
+ ],
4081
+ status: "shipped"
4082
+ },
3822
4083
  {
3823
4084
  name: "issue create",
3824
4085
  description: "Open an issue after full brief-schema validation",
@@ -3895,6 +4156,19 @@ var COMMANDS = [
3895
4156
  ],
3896
4157
  status: "shipped"
3897
4158
  },
4159
+ {
4160
+ name: "milestone close",
4161
+ description: "Close a tranche's Milestone after verifying every labeled Issue is actually attached",
4162
+ flags: [
4163
+ { flag: "--slug", description: "The tranche whose Milestone is being closed" },
4164
+ { flag: "--validate-only", description: "Run every gate and report PASS without closing the Milestone" },
4165
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
4166
+ ],
4167
+ details: [
4168
+ "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."
4169
+ ],
4170
+ status: "shipped"
4171
+ },
3898
4172
  {
3899
4173
  name: "review post",
3900
4174
  description: "Render, post, and self-verify a code-reviewer or security-review verdict comment on a PR",
@@ -4104,9 +4378,9 @@ function emitCheckError(error) {
4104
4378
 
4105
4379
  // src/lib/config.ts
4106
4380
  import { execFileSync as execFileSync2 } from "node:child_process";
4107
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4381
+ import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
4108
4382
  import { homedir } from "node:os";
4109
- import { dirname, join } from "node:path";
4383
+ import { dirname, join, resolve } from "node:path";
4110
4384
  import { z as z2 } from "zod";
4111
4385
 
4112
4386
  // src/lib/agent-vendors.ts
@@ -4214,6 +4488,20 @@ var ManagedManifestSchema = z2.object({
4214
4488
  labels: z2.array(z2.string()),
4215
4489
  agents: z2.array(z2.enum(AGENT_VENDORS)).optional()
4216
4490
  });
4491
+ var ProjectEntrySchema = z2.object({
4492
+ name: z2.string().min(1),
4493
+ description: z2.string().min(1).optional(),
4494
+ path: z2.string().min(1).optional()
4495
+ });
4496
+ function parseTokensCollectDeclaration(value) {
4497
+ const m = value.trim().match(/^(\S+)\s+(\S+)$/);
4498
+ if (!m)
4499
+ return null;
4500
+ const [, interpreter, script] = m;
4501
+ if (!isSafeRepoRelPath(script))
4502
+ return null;
4503
+ return { interpreter, script };
4504
+ }
4217
4505
  var VinayaConfigSchema = z2.object({
4218
4506
  rings: z2.object({
4219
4507
  ring1_forgeWriteInterception: z2.boolean(),
@@ -4226,13 +4514,19 @@ var VinayaConfigSchema = z2.object({
4226
4514
  principals: z2.array(z2.string()).min(1).optional(),
4227
4515
  releaseActor: z2.string().min(1).optional(),
4228
4516
  ci: z2.object({ setup: z2.string().min(1) }).optional(),
4517
+ tokens: z2.object({
4518
+ collect: z2.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
4519
+ message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
4520
+ })
4521
+ }).optional(),
4229
4522
  blastRadius: z2.object({ extraDomains: z2.array(z2.string()).optional() }).optional(),
4230
4523
  proseGates: z2.object({
4231
4524
  doctrineRoot: z2.string().min(1).optional(),
4232
4525
  readerFacingPrefix: z2.string().min(1).optional(),
4233
4526
  readerFacingSuffix: z2.string().min(1).optional(),
4234
4527
  legacySlugDir: z2.string().min(1).optional()
4235
- }).optional()
4528
+ }).optional(),
4529
+ projects: z2.array(ProjectEntrySchema).optional()
4236
4530
  });
4237
4531
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
4238
4532
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -4271,6 +4565,9 @@ function globalRolesIgnoredWarning(path) {
4271
4565
  function globalReleaseActorIgnoredWarning(path) {
4272
4566
  return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
4273
4567
  }
4568
+ function globalTokensCollectIgnoredWarning(path) {
4569
+ return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
4570
+ }
4274
4571
  function stripGlobalOnlyKeys(config, path) {
4275
4572
  if (path !== GLOBAL_CONFIG_PATH)
4276
4573
  return config;
@@ -4291,6 +4588,10 @@ function stripGlobalOnlyKeys(config, path) {
4291
4588
  console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
4292
4589
  result = { ...result, releaseActor: undefined };
4293
4590
  }
4591
+ if (result.tokens) {
4592
+ console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
4593
+ result = { ...result, tokens: undefined };
4594
+ }
4294
4595
  return result;
4295
4596
  }
4296
4597
  function resolvePrincipalAllowlist(config) {
@@ -4376,12 +4677,13 @@ function loadConfig() {
4376
4677
  return null;
4377
4678
  }
4378
4679
  }
4680
+ var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
4379
4681
 
4380
4682
  // src/lib/ops.ts
4381
- import { dirname as dirname2, isAbsolute, join as join2, resolve, sep } from "node:path";
4683
+ import { dirname as dirname2, isAbsolute, join as join2, resolve as resolve2, sep } from "node:path";
4382
4684
  function containedAbs(repoRoot, relPath) {
4383
- const root = resolve(repoRoot);
4384
- const target = resolve(root, relPath);
4685
+ const root = resolve2(repoRoot);
4686
+ const target = resolve2(root, relPath);
4385
4687
  if (target === root)
4386
4688
  return null;
4387
4689
  return target === root || target.startsWith(root + sep) ? target : null;
@@ -4413,9 +4715,32 @@ function fetchIssueState(num, repo) {
4413
4715
  issueCache.set(key, out);
4414
4716
  return out;
4415
4717
  }
4718
+ var defaultResolveSiblingTranche = async (slug, repo) => {
4719
+ let tranche;
4720
+ try {
4721
+ tranche = await deriveTrancheFromForge(repo.owner, repo.repo, slug);
4722
+ } catch {
4723
+ return null;
4724
+ }
4725
+ const taskRefs = tranche.tasks.map((t) => ({ id: t.id, issue: t.issue }));
4726
+ const snapshot = await fetchForgeFacts({ owner: repo.owner, repo: repo.repo, tranche: slug, tasks: taskRefs });
4727
+ return {
4728
+ tasks: new Map(tranche.tasks.map((t) => [t.id, { id: t.id, issue: t.issue }])),
4729
+ facts: snapshot.facts
4730
+ };
4731
+ };
4732
+ var siblingTrancheCache = new Map;
4416
4733
  function edgeFromIssueJson(num, json) {
4417
4734
  if (json === null) {
4418
- return { issue: num, merged: false, open: false, issueState: null, stateReason: null, closedByActor: null };
4735
+ return {
4736
+ issue: num,
4737
+ merged: false,
4738
+ open: false,
4739
+ issueState: null,
4740
+ stateReason: null,
4741
+ closedByActor: null,
4742
+ resolved: true
4743
+ };
4419
4744
  }
4420
4745
  const state = json.state === "CLOSED" ? "closed" : json.state === "OPEN" ? "open" : null;
4421
4746
  const reason = json.stateReason === "COMPLETED" ? "completed" : json.stateReason === "NOT_PLANNED" ? "not_planned" : null;
@@ -4426,10 +4751,11 @@ function edgeFromIssueJson(num, json) {
4426
4751
  open: false,
4427
4752
  issueState: state,
4428
4753
  stateReason: reason,
4429
- closedByActor: null
4754
+ closedByActor: null,
4755
+ resolved: true
4430
4756
  };
4431
4757
  }
4432
- function resolveEdge(id, taskById, factsByTaskId, repo) {
4758
+ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = defaultResolveSiblingTranche) {
4433
4759
  const target = taskById.get(id);
4434
4760
  if (target) {
4435
4761
  const facts = target.issue !== null ? factsByTaskId.get(target.id) : undefined;
@@ -4439,7 +4765,8 @@ function resolveEdge(id, taskById, factsByTaskId, repo) {
4439
4765
  open: facts?.prState === "open",
4440
4766
  issueState: facts?.issueState ?? null,
4441
4767
  stateReason: facts?.stateReason ?? null,
4442
- closedByActor: facts?.closedByActor ?? null
4768
+ closedByActor: facts?.closedByActor ?? null,
4769
+ resolved: true
4443
4770
  };
4444
4771
  }
4445
4772
  const direct = id.match(DIRECT_ISSUE_REF);
@@ -4447,7 +4774,37 @@ function resolveEdge(id, taskById, factsByTaskId, repo) {
4447
4774
  const num = Number(direct[1]);
4448
4775
  return edgeFromIssueJson(num, fetchIssueState(num, repo));
4449
4776
  }
4450
- return { issue: null, merged: false, open: false, issueState: null, stateReason: null, closedByActor: null };
4777
+ const qualified = splitSlugQualifiedEdge(id);
4778
+ if (qualified) {
4779
+ const cacheKey = `${repo.owner}/${repo.repo}:${qualified.slug}`;
4780
+ let sibling = siblingTrancheCache.get(cacheKey);
4781
+ if (sibling === undefined) {
4782
+ sibling = await resolveSibling(qualified.slug, repo);
4783
+ siblingTrancheCache.set(cacheKey, sibling);
4784
+ }
4785
+ const siblingTask = sibling?.tasks.get(qualified.bareId);
4786
+ if (sibling && siblingTask) {
4787
+ const facts = siblingTask.issue !== null ? sibling.facts.get(siblingTask.id) : undefined;
4788
+ return {
4789
+ issue: siblingTask.issue,
4790
+ merged: facts?.prState === "merged",
4791
+ open: facts?.prState === "open",
4792
+ issueState: facts?.issueState ?? null,
4793
+ stateReason: facts?.stateReason ?? null,
4794
+ closedByActor: facts?.closedByActor ?? null,
4795
+ resolved: true
4796
+ };
4797
+ }
4798
+ }
4799
+ return {
4800
+ issue: null,
4801
+ merged: false,
4802
+ open: false,
4803
+ issueState: null,
4804
+ stateReason: null,
4805
+ closedByActor: null,
4806
+ resolved: false
4807
+ };
4451
4808
  }
4452
4809
 
4453
4810
  // src/checks/premise-reassert-logic.ts
@@ -4573,8 +4930,8 @@ function containedRealPath(root, p) {
4573
4930
  if (abs === null)
4574
4931
  return null;
4575
4932
  try {
4576
- const real = realpathSync(abs);
4577
- const realRoot = realpathSync(root);
4933
+ const real = realpathSync2(abs);
4934
+ const realRoot = realpathSync2(root);
4578
4935
  return real === realRoot || real.startsWith(realRoot + sep2) ? real : null;
4579
4936
  } catch {
4580
4937
  return null;
@@ -4619,21 +4976,22 @@ async function main() {
4619
4976
  const issueRationalePass = openIssueMatch ? checkIssueRationale(openIssueMatch.body).status !== "fail" : true;
4620
4977
  const taskById = new Map(tranche.tasks.map((t) => [t.id, t]));
4621
4978
  const factsByTaskId = snapshot.facts;
4622
- const dependsOn = task.dependsOn.map((dep) => {
4623
- const r = resolveEdge(dep, taskById, factsByTaskId, repo);
4979
+ const dependsOn = await Promise.all(task.dependsOn.map(async (dep) => {
4980
+ const r = await resolveEdge(dep, taskById, factsByTaskId, repo);
4624
4981
  return {
4625
4982
  id: dep,
4626
4983
  issue: r.issue,
4627
4984
  merged: r.merged,
4985
+ resolved: r.resolved,
4628
4986
  issueState: r.issueState,
4629
4987
  stateReason: r.stateReason,
4630
4988
  closedByActor: r.closedByActor
4631
4989
  };
4632
- });
4633
- const conflictsWith = task.conflictsWith.map((c) => {
4634
- const r = resolveEdge(c, taskById, factsByTaskId, repo);
4990
+ }));
4991
+ const conflictsWith = await Promise.all(task.conflictsWith.map(async (c) => {
4992
+ const r = await resolveEdge(c, taskById, factsByTaskId, repo);
4635
4993
  return { id: c, issue: r.issue, openOrInFlight: r.open };
4636
- });
4994
+ }));
4637
4995
  const priorTrancheArchival = [];
4638
4996
  const input = {
4639
4997
  trancheSlug,
@@ -4671,6 +5029,9 @@ function recoveryPromptFor(blocker) {
4671
5029
  if (blocker.startsWith("dispatch-gate rationale:")) {
4672
5030
  return "The task's Issue fails the rationale gate. Ask the Planner to complete the eight-field rationale on the Issue body, then re-run `vinaya check dispatch-readiness`.";
4673
5031
  }
5032
+ if (blocker.startsWith("dispatch-gate depends-on:") && blocker.includes("UNRESOLVABLE")) {
5033
+ return "A declared dependency edge could not be resolved to any tranche/task/Issue — check the tranche slug and task id in the edge text, then re-run `vinaya check dispatch-readiness`.";
5034
+ }
4674
5035
  if (blocker.startsWith("dispatch-gate depends-on:")) {
4675
5036
  return "A declared dependency is not merged yet. Do not start this task — wait for the named dependency PR to merge, then re-run `vinaya check dispatch-readiness`.";
4676
5037
  }