@attalabs/vinaya 0.37.0 → 0.38.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 (174) hide show
  1. package/aeg-root/enforcement.md +5 -4
  2. package/aeg-root/roles/developer/reference.md +24 -22
  3. package/aeg-root/roles/developer.md +4 -4
  4. package/aeg-root/roles/planner/reference.md +11 -0
  5. package/aeg-root/roles/reviewer.md +5 -3
  6. package/aeg-root/roles/security.md +3 -2
  7. package/aeg-root/state-machine.md +1 -1
  8. package/aeg-root/templates/brief-template.md +4 -4
  9. package/aeg-root/tranche-model.md +6 -0
  10. package/dist/checks/bin/check-body-bare-digits.js +139 -12
  11. package/dist/checks/bin/check-branch-topology.js +171 -13
  12. package/dist/checks/bin/check-brief-shape.js +139 -12
  13. package/dist/checks/bin/check-changeset-coverage.js +177 -17
  14. package/dist/checks/bin/check-closes-n.js +171 -13
  15. package/dist/checks/bin/check-coherence.js +171 -13
  16. package/dist/checks/bin/check-dead-branch-push.js +139 -12
  17. package/dist/checks/bin/check-dispatch-readiness.js +195 -23
  18. package/dist/checks/bin/check-doc-coverage-push.js +173 -13
  19. package/dist/checks/bin/check-doc-coverage.js +180 -13
  20. package/dist/checks/bin/check-doctrine-no-procedures.js +139 -12
  21. package/dist/checks/bin/check-doctrine-portability.js +173 -13
  22. package/dist/checks/bin/check-evidence-fresh.js +173 -13
  23. package/dist/checks/bin/check-exec-bits.js +173 -13
  24. package/dist/checks/bin/check-first-push-dispatch.js +171 -13
  25. package/dist/checks/bin/check-issue-assignment.js +171 -13
  26. package/dist/checks/bin/check-issue-milestone-attach.js +139 -12
  27. package/dist/checks/bin/check-issue-objectives-numbering.js +139 -12
  28. package/dist/checks/bin/check-issue-parts-coverage.js +139 -12
  29. package/dist/checks/bin/check-issue-surface-globs.js +171 -13
  30. package/dist/checks/bin/check-issue-title-grammar.js +139 -12
  31. package/dist/checks/bin/check-issue-tranche-label.js +139 -12
  32. package/dist/checks/bin/check-main-branch-refusal.js +139 -12
  33. package/dist/checks/bin/check-no-disk-state.js +139 -12
  34. package/dist/checks/bin/check-pr-premise-reassert.js +139 -12
  35. package/dist/checks/bin/check-pr-report-density.js +139 -12
  36. package/dist/checks/bin/check-principal-test-plan-wait.js +139 -12
  37. package/dist/checks/bin/check-quoted-command.js +173 -13
  38. package/dist/checks/bin/check-reader-resolvable-prose.js +173 -13
  39. package/dist/checks/bin/check-registry-gates.js +406 -68
  40. package/dist/checks/bin/check-retired-vocabulary.js +173 -13
  41. package/dist/checks/bin/check-review-gate.js +139 -12
  42. package/dist/checks/bin/check-single-plan-pr.js +139 -12
  43. package/dist/checks/bin/check-surface-scope.js +171 -13
  44. package/dist/checks/bin/check-test-plan.js +139 -12
  45. package/dist/checks/bin/check-token-collection-wired.js +139 -12
  46. package/dist/checks/bin/check-workspace-escape.js +173 -13
  47. package/dist/checks/bin/verify-dispatch.js +3849 -0
  48. package/dist/index.js +7348 -2095
  49. package/dist/lib/pre-push-cache-test-run.js +42 -2
  50. package/dist/lib/pre-push-changed-files.js +16 -11
  51. package/dist/lib/pre-push-select-tests.js +177 -21
  52. package/package.json +1 -1
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +7 -6
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +33 -15
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +51 -12
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +1 -0
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +31 -0
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +31 -2
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +214 -24
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +11 -3
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +5 -4
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +13 -13
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +46 -145
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +63 -14
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +3 -1
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +30 -0
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -2
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +0 -1
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +56 -7
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +7 -7
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +24 -6
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/custom.ts +157 -0
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +44 -6
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/executions.ts +493 -0
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/fact-sheets.ts +111 -0
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/generator.ts +155 -0
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/index.ts +12 -0
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +128 -0
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/catches.ts +63 -0
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/checks.ts +146 -0
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/common.ts +137 -0
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/completion.ts +137 -0
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/convergence.ts +420 -0
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/determinism.ts +65 -0
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/index.ts +69 -0
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/judgment.ts +132 -0
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/labels.ts +21 -0
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/time.ts +167 -0
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/usage.ts +139 -0
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +219 -15
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +7 -7
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/cache-contract.ts +207 -0
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/contracts.ts +105 -0
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/engine.ts +308 -0
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/index.ts +34 -0
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/measured.ts +20 -0
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/memory-cache.ts +78 -0
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/normalize.ts +156 -0
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/row.ts +103 -0
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +34 -6
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +70 -6
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +19 -14
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +38 -3
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +5 -2
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +46 -0
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +15 -28
  107. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  109. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  145. 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
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +1 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0h9yhwx._.js +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__14ui9sz._.js → [root-of-the-server]__0jdjsxe._.js} +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  166. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1-acpmtfmrc35.js +1 -0
  167. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3qtt1v3ya-ofe.js → 2f2y8xxok8zph.js} +1 -1
  168. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3l56x8wjdzvaw.js → 2xevgia1h8g0y.js} +4 -4
  169. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  170. package/dist/checks/bin/check-token-report.js +0 -6526
  171. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vtfb0g813gki.js +0 -1
  172. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_buildManifest.js +0 -0
  173. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_clientMiddlewareManifest.js +0 -0
  174. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_ssgManifest.js +0 -0
@@ -2,8 +2,8 @@
2
2
 
3
3
  // src/checks/bin/check-registry-gates.ts
4
4
  import { execSync, execFileSync as execFileSync2 } from "node:child_process";
5
- import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, statSync } from "node:fs";
6
- import { join as join3 } from "node:path";
5
+ import { existsSync as existsSync3, readdirSync as readdirSync3, readFileSync as readFileSync5 } from "node:fs";
6
+ import { join as join5 } from "node:path";
7
7
  import matter2 from "gray-matter";
8
8
  // ../../packages/aeg-core/src/gate-audience.ts
9
9
  var GATE_AUDIENCE = {
@@ -630,6 +630,33 @@ function tasksFromIssues(issues) {
630
630
  }
631
631
  return tasks.sort((a, b) => compareTaskIds(a.id, b.id));
632
632
  }
633
+ function resolveDuplicateTasks(tasks, isOpen) {
634
+ const byId = new Map;
635
+ for (const t of tasks)
636
+ byId.set(t.id, [...byId.get(t.id) ?? [], t]);
637
+ const resolved = [];
638
+ const conflicts = [];
639
+ for (const [id, group] of byId) {
640
+ const first = group[0];
641
+ if (!first)
642
+ continue;
643
+ if (group.length === 1) {
644
+ resolved.push(first);
645
+ continue;
646
+ }
647
+ const number = (t) => t.issue ?? 0;
648
+ const open = group.filter((t) => t.issue !== null && isOpen(t.issue)).sort((a, b) => number(a) - number(b));
649
+ if (open.length > 1) {
650
+ conflicts.push({ id, issues: open.map(number) });
651
+ resolved.push(open[0]);
652
+ } else if (open.length === 1) {
653
+ resolved.push(open[0]);
654
+ } else {
655
+ resolved.push([...group].sort((a, b) => number(b) - number(a))[0]);
656
+ }
657
+ }
658
+ return { tasks: resolved.sort((a, b) => compareTaskIds(a.id, b.id)), conflicts };
659
+ }
633
660
  async function fetchTrancheIssuesAsync(owner, repo, slug) {
634
661
  return ghIssueListByAnyLabelAsync(owner, repo, [trancheLabel(slug)]);
635
662
  }
@@ -1437,7 +1464,7 @@ function mapReviewDecision(decision) {
1437
1464
  function buildBranchName(tranche, taskId) {
1438
1465
  return `task/${tranche}/${taskId}`;
1439
1466
  }
1440
- async function fetchForgeFacts(input) {
1467
+ async function fetchForgeFactsByIssue(input) {
1441
1468
  const token = await resolveGithubToken(input.token);
1442
1469
  if (!token) {
1443
1470
  return {
@@ -1447,7 +1474,13 @@ async function fetchForgeFacts(input) {
1447
1474
  reason: "No GitHub token available (set GITHUB_TOKEN/GH_TOKEN or `gh auth login`)."
1448
1475
  };
1449
1476
  }
1450
- const queriedTasks = input.tasks.filter((t) => t.issue !== null);
1477
+ const seen = new Set;
1478
+ const queriedTasks = input.tasks.filter((t) => {
1479
+ if (t.issue === null || seen.has(t.issue))
1480
+ return false;
1481
+ seen.add(t.issue);
1482
+ return true;
1483
+ });
1451
1484
  if (queriedTasks.length === 0) {
1452
1485
  return { facts: new Map, prRefs: new Map, unavailable: false };
1453
1486
  }
@@ -1475,21 +1508,52 @@ async function fetchForgeFacts(input) {
1475
1508
  };
1476
1509
  }
1477
1510
  for (const task of queriedTasks) {
1478
- const alias = aliasFor(task.id);
1479
- const raw = extractRawFromResponse(response.repository, alias);
1511
+ const raw = extractRawFromResponse(response.repository, aliasFor(task.issue));
1480
1512
  const mapped = mapForgeFacts(raw);
1481
1513
  if (mapped)
1482
- facts.set(task.id, mapped);
1514
+ facts.set(task.issue, mapped);
1483
1515
  const pr = raw.pullRequest;
1484
1516
  if (pr && typeof pr.number === "number" && typeof pr.url === "string") {
1485
- prRefs.set(task.id, { number: pr.number, url: pr.url, state: pr.state });
1517
+ prRefs.set(task.issue, { number: pr.number, url: pr.url, state: pr.state });
1486
1518
  }
1487
1519
  }
1488
1520
  return { facts, prRefs, unavailable: false };
1489
1521
  }
1522
+ async function fetchForgeFacts(input) {
1523
+ const byIssue = await fetchForgeFactsByIssue(input);
1524
+ if (byIssue.unavailable) {
1525
+ return { facts: new Map, prRefs: new Map, unavailable: true, reason: byIssue.reason };
1526
+ }
1527
+ const facts = new Map;
1528
+ const prRefs = new Map;
1529
+ const winner = new Map;
1530
+ for (const task of input.tasks) {
1531
+ if (task.issue === null)
1532
+ continue;
1533
+ const current = winner.get(task.id);
1534
+ if (current === undefined || outranks(byIssue.facts, task.issue, current))
1535
+ winner.set(task.id, task.issue);
1536
+ }
1537
+ for (const [taskId, issue] of winner) {
1538
+ const f = byIssue.facts.get(issue);
1539
+ if (f)
1540
+ facts.set(taskId, f);
1541
+ const pr = byIssue.prRefs.get(issue);
1542
+ if (pr)
1543
+ prRefs.set(taskId, pr);
1544
+ }
1545
+ return { facts, prRefs, unavailable: false };
1546
+ }
1547
+ function outranks(facts, candidate, current) {
1548
+ const candidateOpen = facts.get(candidate)?.issueState === "open";
1549
+ const currentOpen = facts.get(current)?.issueState === "open";
1550
+ if (candidateOpen !== currentOpen)
1551
+ return candidateOpen;
1552
+ return candidate > current;
1553
+ }
1490
1554
  function buildBatchQuery(tranche, tasks) {
1491
1555
  const perTask = tasks.map((task) => {
1492
- const a = aliasFor(task.id);
1556
+ const a = aliasFor(task.issue);
1493
1557
  const branch = buildBranchName(tranche, task.id);
1494
1558
  return `
1495
1559
  ${a}_issue: issue(number: ${task.issue}) {
@@ -1531,9 +1595,8 @@ function buildBatchQuery(tranche, tasks) {
1531
1595
  }
1532
1596
  }`;
1533
1597
  }
1534
- function aliasFor(taskId) {
1535
- const sanitized = taskId.replace(/[^a-zA-Z0-9_]/g, "_");
1536
- return `t_${sanitized}`;
1598
+ function aliasFor(issue) {
1599
+ return `i_${issue}`;
1537
1600
  }
1538
1601
  function extractRawFromResponse(repository, alias) {
1539
1602
  const issue = repository[`${alias}_issue`];
@@ -2364,6 +2427,9 @@ var ROLE_FILE_LOCATION = /(^|\/)aeg-root\/roles\//i;
2364
2427
  function isProseLocation(location) {
2365
2428
  if (ROLE_FILE_LOCATION.test(location))
2366
2429
  return true;
2430
+ return isBodyOrCommentLocation(location);
2431
+ }
2432
+ function isBodyOrCommentLocation(location) {
2367
2433
  if (FILE_SHAPED_LOCATION.test(location))
2368
2434
  return false;
2369
2435
  return PROSE_LOCATION_PATTERNS.some((pattern) => pattern.test(location));
@@ -2390,7 +2456,7 @@ function classifyFinding(finding, scale, threshold, context = {}) {
2390
2456
  const wouldBlock = blockingSeverities(scale, threshold).includes(effectiveSeverity);
2391
2457
  if (!wouldBlock)
2392
2458
  return { outcome: "non_blocking", deferralReason: null };
2393
- const hasLocation = location !== undefined && location.length > 0;
2459
+ const hasLocation = location !== undefined && location.length > 0 && !isBodyOrCommentLocation(location);
2394
2460
  if (hasLocation && context.inSurface && !context.inSurface(location)) {
2395
2461
  return { outcome: "deferred", deferralReason: "outside-surface" };
2396
2462
  }
@@ -4060,6 +4126,8 @@ var FILE_EXTENSIONS = new Set([
4060
4126
  "html",
4061
4127
  "css"
4062
4128
  ]);
4129
+ var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
4130
+ var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
4063
4131
 
4064
4132
  // ../../packages/aeg-core/src/task-branch-identity.ts
4065
4133
  var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
@@ -4937,6 +5005,55 @@ function checkG6(rows, registeredCheckNames) {
4937
5005
  }
4938
5006
  return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
4939
5007
  }
5008
+ function reachesProducer(file, producers, imports) {
5009
+ const seen = new Set([file]);
5010
+ const queue = [file];
5011
+ for (let next = queue.pop();next !== undefined; next = queue.pop()) {
5012
+ if (producers.has(next))
5013
+ return true;
5014
+ for (const dep of imports.get(next) ?? []) {
5015
+ if (!seen.has(dep)) {
5016
+ seen.add(dep);
5017
+ queue.push(dep);
5018
+ }
5019
+ }
5020
+ }
5021
+ return false;
5022
+ }
5023
+ function checkG7(input) {
5024
+ if (!input.enforcementMapPresent)
5025
+ return { check: "G7", status: "info", findings: [] };
5026
+ const subjects = new Set([...input.crossingFiles, ...input.blockingFiles]);
5027
+ const findings = [];
5028
+ for (const path of subjects) {
5029
+ if (path in input.exemptions)
5030
+ continue;
5031
+ if (!reachesProducer(path, input.producers, input.imports)) {
5032
+ findings.push({
5033
+ path,
5034
+ reason: `"${path}" ${input.crossingFiles.includes(path) ? "makes a GitHub-writing call" : "implements a blocking gate"} but neither is a log producer nor imports one, and it is not exempted with a reason`
5035
+ });
5036
+ }
5037
+ }
5038
+ for (const [path, reason] of Object.entries(input.exemptions)) {
5039
+ if (reason.trim() === "") {
5040
+ findings.push({ path, reason: `exemption for "${path}" states no reason` });
5041
+ } else if (!input.existsFn(path)) {
5042
+ findings.push({ path, reason: `exemption names "${path}", which no longer exists` });
5043
+ } else if (!subjects.has(path)) {
5044
+ findings.push({
5045
+ path,
5046
+ reason: `exemption names "${path}", which is neither a GitHub-writing file nor a blocking gate's implementation`
5047
+ });
5048
+ } else if (reachesProducer(path, input.producers, input.imports)) {
5049
+ findings.push({
5050
+ path,
5051
+ reason: `exemption names "${path}", which does reach a log producer — remove the exemption`
5052
+ });
5053
+ }
5054
+ }
5055
+ return { check: "G7", status: findings.length > 0 ? "fail" : "pass", findings };
5056
+ }
4940
5057
  // ../../packages/aeg-core/src/dead-branch-push-guard.ts
4941
5058
  function checkDeadBranchPush(input) {
4942
5059
  const { branch, prState, prNumber } = input;
@@ -5116,6 +5233,11 @@ function checkDispatchReadiness(input) {
5116
5233
  push("depends-on-unresolvable", `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.`);
5117
5234
  continue;
5118
5235
  }
5236
+ if (dep.readFailed === true) {
5237
+ const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
5238
+ push("depends-on-read-failed", `dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, but the forge could not be read for that dependency — not a claim about its merge status. Retry the check.`);
5239
+ continue;
5240
+ }
5119
5241
  if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
5120
5242
  const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
5121
5243
  push("depends-on-not-merged", `dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
@@ -5698,6 +5820,7 @@ var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
5698
5820
 
5699
5821
  // ../../packages/aeg-core/src/log/schema.ts
5700
5822
  var CONFIDENCE_REASON_MAX_LENGTH = 280;
5823
+ var REVIEW_FINDING_DESCRIPTION_MAX_LENGTH = 1000;
5701
5824
  var ROLE_VALUES = [
5702
5825
  "planner",
5703
5826
  "developer",
@@ -5791,6 +5914,9 @@ var envelopeTail = {
5791
5914
  var ReviewFindingSchema = z3.object({
5792
5915
  id: z3.string(),
5793
5916
  severity: z3.string(),
5917
+ location: z3.string().optional(),
5918
+ deferral_reason: z3.enum(["outside-surface", "unchanged-line"]).optional(),
5919
+ description: z3.string().max(REVIEW_FINDING_DESCRIPTION_MAX_LENGTH).optional(),
5794
5920
  state: z3.string().optional(),
5795
5921
  severity_scale: z3.string().optional(),
5796
5922
  policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
@@ -5846,7 +5972,8 @@ var DispatchEventSchema = z3.discriminatedUnion("event", [
5846
5972
  z3.object({
5847
5973
  ...dispatchShared,
5848
5974
  event: z3.literal("dispatch_failed"),
5849
- reason: z3.enum(["timeout", "crash", "refused", "unattributed_write"]),
5975
+ reason: z3.enum(["timeout", "crash", "refused", "unattributed_write", "usage_limit"]),
5976
+ usage_limit: z3.object({ agent: z3.string().min(1), reset_at: z3.string().nullable() }).strict().optional(),
5850
5977
  usage: dispatchUsageField
5851
5978
  }).strict()
5852
5979
  ]);
@@ -6561,6 +6688,235 @@ function initHookPaths() {
6561
6688
  return HOOK_DIRS.flatMap((dir) => INIT_HOOK_NAMES.map((name) => `${dir}/${name}`));
6562
6689
  }
6563
6690
 
6691
+ // src/lib/github-crossing-files.ts
6692
+ import { existsSync, readdirSync, readFileSync as readFileSync2, statSync } from "node:fs";
6693
+ function isGithubCrossingLine(line) {
6694
+ const createMatch = /\bgh\s+(pr|issue)\s+create\b/.test(line);
6695
+ const editWithBodyOrTitle = /\bgh\s+(pr|issue)\s+edit\b/.test(line) && /--body\b|--body-file\b|--title\b|(?:^|\s)-b(?:\s|$)|(?:^|\s)-F(?:\s|$)|(?:^|\s)-t(?:\s|$)/.test(line);
6696
+ const apiPost = /\bgh\s+api\b/.test(line) && /-X\s*POST\b|--method\s*POST\b|(?:^|\s)-f(?:\s|$)|(?:^|\s)-F(?:\s|$)/.test(line) && /(\/pulls|\/issues)(["'\s]|$)/.test(line);
6697
+ const apiPatch = /\bgh\s+api\b/.test(line) && /-X\s*PATCH\b|--method\s*PATCH\b/.test(line) && /(\/pulls|\/issues)\/[0-9]+(["'\s]|$)/.test(line);
6698
+ const curlWrite = /\b(curl|wget)\b/.test(line) && /api\.github\.com/.test(line) && /(\/pulls|\/issues)/.test(line) && /-X\s*(POST|PATCH|PUT)\b|--method\s*(POST|PATCH|PUT)\b|--data\b|(?:^|\s)-d(?:\s|$)|--json\b|--post-data\b/.test(line);
6699
+ return createMatch || editWithBodyOrTitle || apiPost || apiPatch || curlWrite;
6700
+ }
6701
+ function globCandidateFiles() {
6702
+ const out = [];
6703
+ if (existsSync(".husky")) {
6704
+ for (const name of readdirSync(".husky")) {
6705
+ if (name === "_")
6706
+ continue;
6707
+ const rel = `.husky/${name}`;
6708
+ if (statSync(rel).isFile())
6709
+ out.push(rel);
6710
+ }
6711
+ }
6712
+ if (existsSync(".claude/hooks")) {
6713
+ for (const name of readdirSync(".claude/hooks")) {
6714
+ if (name.endsWith(".sh"))
6715
+ out.push(`.claude/hooks/${name}`);
6716
+ }
6717
+ }
6718
+ return out;
6719
+ }
6720
+ function findCrossingFiles(candidateFiles) {
6721
+ return candidateFiles.filter((path) => readFileSync2(path, "utf8").split(`
6722
+ `).some((line) => isGithubCrossingLine(line)));
6723
+ }
6724
+
6725
+ // src/lib/log-producer-graph.ts
6726
+ import { readFileSync as readFileSync4 } from "node:fs";
6727
+ import { join as join2, relative } from "node:path";
6728
+
6729
+ // src/lib/test-selector.ts
6730
+ import { readdirSync as readdirSync2, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
6731
+ import { dirname, extname, isAbsolute, join, resolve } from "node:path";
6732
+
6733
+ // src/lib/repo-scanner-tests.ts
6734
+ var TREE_READERS = new Set([
6735
+ "readdirSync",
6736
+ "readdir",
6737
+ "opendirSync",
6738
+ "opendir",
6739
+ "globSync",
6740
+ "globIterateSync",
6741
+ "readdirp"
6742
+ ]);
6743
+ var SPAWN_CALLS = new Set(["execFileSync", "execSync", "spawnSync", "spawn", "exec", "execFile"]);
6744
+ var PROCESS_CALLS = new Set([...SPAWN_CALLS, "fork"]);
6745
+
6746
+ // src/lib/test-selector.ts
6747
+ var SOURCE_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
6748
+ var SKIP_DIRS = new Set(["node_modules", "dist", ".git", "build", "coverage"]);
6749
+ var OUTPUT_TO_SOURCE_EXTENSIONS = new Map([
6750
+ [".js", [".ts", ".tsx"]],
6751
+ [".jsx", [".tsx"]],
6752
+ [".mjs", [".mts"]],
6753
+ [".cjs", [".cts"]]
6754
+ ]);
6755
+ var FROM_CLAUSE_RE = /^\s*(import|export)\b\s*([^'"]*?)\bfrom\s*(['"])([^'"]+)\3/gm;
6756
+ var QUOTED_LIST_CLAUSE_RE = /^\s*(import|export)\b\s*((?:type\s+)?(?:[A-Za-z_$][\w$]*\s*,\s*)?\{[^{}]*\})\s*from\s*(['"])([^'"]+)\3/gm;
6757
+ var SIDE_EFFECT_IMPORT_RE = /^\s*import\s*(['"])([^'"]+)\1/gm;
6758
+ var DYNAMIC_IMPORT_RE = /\bimport\s*\(\s*(['"])([^'"]+)\1\s*\)/g;
6759
+ var IMPORT_EQUALS_REQUIRE_RE = /^\s*(?:export\s+)?import\s+[A-Za-z_$][\w$]*\s*=\s*require\s*\(\s*(['"])([^'"]+)\1\s*\)/gm;
6760
+ var COMMENT_RE = /\/\*[\s\S]*?\*\/|\/\/[^\n]*/g;
6761
+ function parseNamedList(inside) {
6762
+ const names = [];
6763
+ let clean = true;
6764
+ const entries = inside.replace(COMMENT_RE, "").split(",").map((s) => s.trim()).filter((s) => s.length > 0);
6765
+ if (entries.length === 0)
6766
+ clean = false;
6767
+ for (const raw of entries) {
6768
+ const entry = raw.replace(/^type\s+/, "");
6769
+ const origin = entry.split(/\s+as\s+/)[0].trim();
6770
+ if (/^[A-Za-z_$][\w$]*$/.test(origin))
6771
+ names.push(origin);
6772
+ else
6773
+ clean = false;
6774
+ }
6775
+ return { names, clean };
6776
+ }
6777
+ function classifyFromClause(clause, specifier) {
6778
+ const c = clause.trim().replace(/^type\s+/, "");
6779
+ if (c.startsWith("*")) {
6780
+ return /^\*\s+as\s+/.test(c) ? { kind: "namespace", specifier } : { kind: "star", specifier };
6781
+ }
6782
+ if (c.startsWith("{")) {
6783
+ const { names, clean } = parseNamedList(c.slice(1, c.lastIndexOf("}")));
6784
+ return { kind: "named", specifier, names, clean };
6785
+ }
6786
+ return { kind: "default", specifier };
6787
+ }
6788
+ function collectRecords(source, includeExportFrom) {
6789
+ const records = [];
6790
+ FROM_CLAUSE_RE.lastIndex = 0;
6791
+ for (let m = FROM_CLAUSE_RE.exec(source);m !== null; m = FROM_CLAUSE_RE.exec(source)) {
6792
+ if (!includeExportFrom && m[1] !== "import")
6793
+ continue;
6794
+ records.push(classifyFromClause(m[2], m[4]));
6795
+ }
6796
+ QUOTED_LIST_CLAUSE_RE.lastIndex = 0;
6797
+ for (let m = QUOTED_LIST_CLAUSE_RE.exec(source);m !== null; m = QUOTED_LIST_CLAUSE_RE.exec(source)) {
6798
+ if (!/['"]/.test(m[2]))
6799
+ continue;
6800
+ if (!includeExportFrom && m[1] !== "import")
6801
+ continue;
6802
+ records.push(classifyFromClause(m[2], m[4]));
6803
+ }
6804
+ SIDE_EFFECT_IMPORT_RE.lastIndex = 0;
6805
+ for (let m = SIDE_EFFECT_IMPORT_RE.exec(source);m !== null; m = SIDE_EFFECT_IMPORT_RE.exec(source)) {
6806
+ records.push({ kind: "side-effect", specifier: m[2] });
6807
+ }
6808
+ DYNAMIC_IMPORT_RE.lastIndex = 0;
6809
+ for (let m = DYNAMIC_IMPORT_RE.exec(source);m !== null; m = DYNAMIC_IMPORT_RE.exec(source)) {
6810
+ records.push({ kind: "dynamic", specifier: m[2] });
6811
+ }
6812
+ IMPORT_EQUALS_REQUIRE_RE.lastIndex = 0;
6813
+ for (let m = IMPORT_EQUALS_REQUIRE_RE.exec(source);m !== null; m = IMPORT_EQUALS_REQUIRE_RE.exec(source)) {
6814
+ records.push({ kind: "namespace", specifier: m[2] });
6815
+ }
6816
+ return records;
6817
+ }
6818
+ function extractImportRecords(source) {
6819
+ return collectRecords(source, true);
6820
+ }
6821
+ function walkFiles(root) {
6822
+ const out = [];
6823
+ let entries;
6824
+ try {
6825
+ entries = readdirSync2(root);
6826
+ } catch {
6827
+ return out;
6828
+ }
6829
+ for (const entry of entries) {
6830
+ if (SKIP_DIRS.has(entry))
6831
+ continue;
6832
+ const abs = join(root, entry);
6833
+ let s;
6834
+ try {
6835
+ s = statSync2(abs);
6836
+ } catch {
6837
+ continue;
6838
+ }
6839
+ if (s.isDirectory()) {
6840
+ out.push(...walkFiles(abs));
6841
+ } else {
6842
+ out.push(abs);
6843
+ }
6844
+ }
6845
+ return out;
6846
+ }
6847
+ function resolveFileCandidate(base, knownFiles) {
6848
+ if (knownFiles.has(base))
6849
+ return base;
6850
+ const written = extname(base);
6851
+ for (const ext of OUTPUT_TO_SOURCE_EXTENSIONS.get(written) ?? []) {
6852
+ const source = base.slice(0, -written.length) + ext;
6853
+ if (knownFiles.has(source))
6854
+ return source;
6855
+ }
6856
+ for (const ext of SOURCE_EXTENSIONS) {
6857
+ if (knownFiles.has(base + ext))
6858
+ return base + ext;
6859
+ }
6860
+ for (const ext of SOURCE_EXTENSIONS) {
6861
+ const indexed = join(base, `index${ext}`);
6862
+ if (knownFiles.has(indexed))
6863
+ return indexed;
6864
+ }
6865
+ return null;
6866
+ }
6867
+ function resolveRelativeImport(fromFile, specifier, knownFiles) {
6868
+ if (!specifier.startsWith("."))
6869
+ return null;
6870
+ return resolveFileCandidate(resolve(dirname(fromFile), specifier), knownFiles);
6871
+ }
6872
+ var TYPE_ONLY_CONDITIONS = new Set(["types", "typings"]);
6873
+
6874
+ // src/lib/log-producer-graph.ts
6875
+ var CLI_SOURCE_DIR = "apps/cli/src";
6876
+ var LOG_SINK_PATH = "apps/cli/src/lib/log-sink.ts";
6877
+ var LOG_SINK_PRODUCER_NAMES = ["log", "logSync"];
6878
+ var NOT_REACHED_BY_IMPORT_CHECK_BIN = "a check bin: it runs only as a child of `vinaya check`, whose runner records one gate event per attempt, so no import of the sink is needed";
6879
+ var NOT_REACHED_STANDALONE_SCRIPT = "a standalone script outside the CLI package: the import resolution cannot follow it and no CLI source imports it; invoked directly, it records nothing of its own";
6880
+ var G7_EXEMPTIONS = {
6881
+ "apps/cli/src/checks/bin/check-review-gate.ts": NOT_REACHED_BY_IMPORT_CHECK_BIN,
6882
+ "apps/cli/src/checks/bin/check-main-branch-refusal.ts": NOT_REACHED_BY_IMPORT_CHECK_BIN,
6883
+ "apps/cli/src/checks/bin/check-token-collection-wired.ts": NOT_REACHED_BY_IMPORT_CHECK_BIN,
6884
+ "apps/cli/src/checks/resolver.ts": "the pure step that decides which checks `vinaya check` runs; the runner it feeds records each run and the invocation records its own operation at exit",
6885
+ "packages/aeg-core/bin/open-pr.ts": NOT_REACHED_STANDALONE_SCRIPT,
6886
+ "packages/aeg-core/bin/open-issue.ts": NOT_REACHED_STANDALONE_SCRIPT,
6887
+ "packages/aeg-core/bin/verify-dispatch.ts": NOT_REACHED_STANDALONE_SCRIPT,
6888
+ "packages/aeg-core/bin/verify-task.ts": NOT_REACHED_STANDALONE_SCRIPT,
6889
+ "packages/aeg-core/bin/check-branch-topology.ts": NOT_REACHED_STANDALONE_SCRIPT,
6890
+ "packages/aeg-core/bin/check-push-target.ts": NOT_REACHED_STANDALONE_SCRIPT,
6891
+ "packages/aeg-core/bin/check-first-push-dispatch.ts": NOT_REACHED_STANDALONE_SCRIPT,
6892
+ "packages/aeg-core/bin/assign-task-issue.ts": NOT_REACHED_STANDALONE_SCRIPT,
6893
+ "packages/aeg-core/src/brief-validation.ts": "a pure library outside the CLI package: it makes no call of its own, and the import resolution does not follow a workspace package"
6894
+ };
6895
+ function blockingGateFiles(ring0Rows, existsFn) {
6896
+ return [...new Set(ring0Rows.map((r) => r.implementation).filter((p) => p.endsWith(".ts") && existsFn(p)))];
6897
+ }
6898
+ function gatherLogProducerGraph(root) {
6899
+ const files = walkFiles(join2(root, CLI_SOURCE_DIR)).filter((f) => f.endsWith(".ts") && !f.endsWith(".test.ts"));
6900
+ const known = new Set(files);
6901
+ const sink = join2(root, LOG_SINK_PATH);
6902
+ const producers = new Set([LOG_SINK_PATH]);
6903
+ const imports = new Map;
6904
+ for (const file of files) {
6905
+ const deps = [];
6906
+ for (const record of extractImportRecords(readFileSync4(file, "utf8"))) {
6907
+ const target = resolveRelativeImport(file, record.specifier, known);
6908
+ if (target === null)
6909
+ continue;
6910
+ deps.push(relative(root, target));
6911
+ if (target === sink && record.kind === "named" && record.names.some((n) => LOG_SINK_PRODUCER_NAMES.includes(n))) {
6912
+ producers.add(relative(root, file));
6913
+ }
6914
+ }
6915
+ imports.set(relative(root, file), deps);
6916
+ }
6917
+ return { producers, imports };
6918
+ }
6919
+
6564
6920
  // src/checks/contract.ts
6565
6921
  var CHECK_SCHEMA_VERSION = 1;
6566
6922
  function emitCheckError(error) {
@@ -6569,19 +6925,19 @@ function emitCheckError(error) {
6569
6925
  }
6570
6926
 
6571
6927
  // src/checks/registry.ts
6572
- import { join as join2, relative, sep } from "node:path";
6928
+ import { join as join4, relative as relative2, sep } from "node:path";
6573
6929
  import { fileURLToPath as fileURLToPath2 } from "node:url";
6574
6930
 
6575
6931
  // src/lib/package-root.ts
6576
- import { existsSync } from "node:fs";
6577
- import { dirname, join } from "node:path";
6932
+ import { existsSync as existsSync2 } from "node:fs";
6933
+ import { dirname as dirname2, join as join3 } from "node:path";
6578
6934
  import { fileURLToPath } from "node:url";
6579
6935
  function packageRoot(moduleUrl) {
6580
- let dir = dirname(fileURLToPath(moduleUrl));
6581
- while (!existsSync(join(dir, "package.json"))) {
6582
- if (existsSync(join(dir, ".git")))
6936
+ let dir = dirname2(fileURLToPath(moduleUrl));
6937
+ while (!existsSync2(join3(dir, "package.json"))) {
6938
+ if (existsSync2(join3(dir, ".git")))
6583
6939
  break;
6584
- const parent = dirname(dir);
6940
+ const parent = dirname2(dir);
6585
6941
  if (parent === dir)
6586
6942
  break;
6587
6943
  dir = parent;
@@ -6591,15 +6947,15 @@ function packageRoot(moduleUrl) {
6591
6947
 
6592
6948
  // src/checks/registry.ts
6593
6949
  function resolveCheckBin(packageDir, moduleUrl) {
6594
- const fromPackage = relative(packageDir, fileURLToPath2(moduleUrl));
6950
+ const fromPackage = relative2(packageDir, fileURLToPath2(moduleUrl));
6595
6951
  const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep}`);
6596
- return bundled ? { dir: join2(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join2(packageDir, "src", "checks", "bin"), ext: ".ts" };
6952
+ return bundled ? { dir: join4(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join4(packageDir, "src", "checks", "bin"), ext: ".ts" };
6597
6953
  }
6598
6954
  var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
6599
6955
  var BIN_DIR = CHECK_BIN.dir;
6600
6956
  var BIN_EXT = CHECK_BIN.ext;
6601
6957
  function bin(name) {
6602
- return join2(BIN_DIR, `${name}${BIN_EXT}`);
6958
+ return join4(BIN_DIR, `${name}${BIN_EXT}`);
6603
6959
  }
6604
6960
  var REGISTRY = [
6605
6961
  [
@@ -6641,6 +6997,8 @@ var REGISTRY = [
6641
6997
  timeoutMs: 15000,
6642
6998
  env: {
6643
6999
  BASE_SHA: { optional: true },
7000
+ GIT_INDEX_FILE: { optional: true },
7001
+ VINAYA_COMMIT_HOOK: { optional: true },
6644
7002
  PR_BODY: { optional: true },
6645
7003
  PR_BODY_FILE: { optional: true },
6646
7004
  PR_NUMBER: { optional: true },
@@ -7146,45 +7504,14 @@ var ENFORCEMENT_PATH = "aeg-root/enforcement.md";
7146
7504
  var ROLES_DIR = "aeg-root/roles";
7147
7505
  var CONTRACTS_DIR = "aeg-root/contracts";
7148
7506
  var DOCTRINE_DIR = "aeg-root";
7149
- function isGithubCrossingLine(line) {
7150
- const createMatch = /\bgh\s+(pr|issue)\s+create\b/.test(line);
7151
- const editWithBodyOrTitle = /\bgh\s+(pr|issue)\s+edit\b/.test(line) && /--body\b|--body-file\b|--title\b|(?:^|\s)-b(?:\s|$)|(?:^|\s)-F(?:\s|$)|(?:^|\s)-t(?:\s|$)/.test(line);
7152
- const apiPost = /\bgh\s+api\b/.test(line) && /-X\s*POST\b|--method\s*POST\b|(?:^|\s)-f(?:\s|$)|(?:^|\s)-F(?:\s|$)/.test(line) && /(\/pulls|\/issues)(["'\s]|$)/.test(line);
7153
- const apiPatch = /\bgh\s+api\b/.test(line) && /-X\s*PATCH\b|--method\s*PATCH\b/.test(line) && /(\/pulls|\/issues)\/[0-9]+(["'\s]|$)/.test(line);
7154
- const curlWrite = /\b(curl|wget)\b/.test(line) && /api\.github\.com/.test(line) && /(\/pulls|\/issues)/.test(line) && /-X\s*(POST|PATCH|PUT)\b|--method\s*(POST|PATCH|PUT)\b|--data\b|(?:^|\s)-d(?:\s|$)|--json\b|--post-data\b/.test(line);
7155
- return createMatch || editWithBodyOrTitle || apiPost || apiPatch || curlWrite;
7156
- }
7157
- function globCandidateFiles() {
7158
- const out = [];
7159
- if (existsSync2(".husky")) {
7160
- for (const name of readdirSync(".husky")) {
7161
- if (name === "_")
7162
- continue;
7163
- const rel = `.husky/${name}`;
7164
- if (statSync(rel).isFile())
7165
- out.push(rel);
7166
- }
7167
- }
7168
- if (existsSync2(".claude/hooks")) {
7169
- for (const name of readdirSync(".claude/hooks")) {
7170
- if (name.endsWith(".sh"))
7171
- out.push(`.claude/hooks/${name}`);
7172
- }
7173
- }
7174
- return out;
7175
- }
7176
- function findCrossingFiles(candidateFiles) {
7177
- return candidateFiles.filter((path) => readFileSync2(path, "utf8").split(`
7178
- `).some((line) => isGithubCrossingLine(line)));
7179
- }
7180
7507
  function readHookScanFiles(dir) {
7181
7508
  const out = [];
7182
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
7183
- const rel = join3(dir, entry.name);
7509
+ for (const entry of readdirSync3(dir, { withFileTypes: true })) {
7510
+ const rel = join5(dir, entry.name);
7184
7511
  if (entry.isDirectory())
7185
7512
  out.push(...readHookScanFiles(rel));
7186
7513
  else if (entry.name.endsWith(".md"))
7187
- out.push({ path: rel, content: readFileSync2(rel, "utf8") });
7514
+ out.push({ path: rel, content: readFileSync5(rel, "utf8") });
7188
7515
  }
7189
7516
  return out;
7190
7517
  }
@@ -7194,11 +7521,11 @@ function shippedHookPaths() {
7194
7521
  return new Set([...tracked, ...initHookPaths()]);
7195
7522
  }
7196
7523
  function readRoles() {
7197
- if (!existsSync2(ROLES_DIR))
7524
+ if (!existsSync3(ROLES_DIR))
7198
7525
  return [];
7199
- return readdirSync(ROLES_DIR).filter((name) => name.endsWith(".md")).map((name) => {
7526
+ return readdirSync3(ROLES_DIR).filter((name) => name.endsWith(".md")).map((name) => {
7200
7527
  const rel = `${ROLES_DIR}/${name}`;
7201
- const { data } = matter2(readFileSync2(rel, "utf8"));
7528
+ const { data } = matter2(readFileSync5(rel, "utf8"));
7202
7529
  return {
7203
7530
  file: rel,
7204
7531
  role_id: typeof data.role_id === "string" ? data.role_id : "",
@@ -7208,11 +7535,11 @@ function readRoles() {
7208
7535
  });
7209
7536
  }
7210
7537
  function readContracts() {
7211
- if (!existsSync2(CONTRACTS_DIR))
7538
+ if (!existsSync3(CONTRACTS_DIR))
7212
7539
  return [];
7213
- return readdirSync(CONTRACTS_DIR).filter((name) => name.endsWith(".md")).map((name) => {
7540
+ return readdirSync3(CONTRACTS_DIR).filter((name) => name.endsWith(".md")).map((name) => {
7214
7541
  const rel = `${CONTRACTS_DIR}/${name}`;
7215
- const { data } = matter2(readFileSync2(rel, "utf8"));
7542
+ const { data } = matter2(readFileSync5(rel, "utf8"));
7216
7543
  return {
7217
7544
  file: rel,
7218
7545
  producer: typeof data.producer === "string" ? data.producer : "",
@@ -7283,7 +7610,7 @@ function emitResult(result, blocking) {
7283
7610
  }
7284
7611
  }
7285
7612
  async function main() {
7286
- if (!existsSync2(ENFORCEMENT_PATH)) {
7613
+ if (!existsSync3(ENFORCEMENT_PATH)) {
7287
7614
  emitCheckError({
7288
7615
  schema: CHECK_SCHEMA_VERSION,
7289
7616
  check: `${CHECK_NAME}.dormant`,
@@ -7293,7 +7620,7 @@ async function main() {
7293
7620
  });
7294
7621
  process.exit(0);
7295
7622
  }
7296
- const enforcementContent = readFileSync2(ENFORCEMENT_PATH, "utf8");
7623
+ const enforcementContent = readFileSync5(ENFORCEMENT_PATH, "utf8");
7297
7624
  const rows = parseEnforcementRegistry(enforcementContent);
7298
7625
  const ring0Rows = rows.filter((r) => r.ring === "ring0");
7299
7626
  const candidateFiles = globCandidateFiles();
@@ -7311,18 +7638,29 @@ async function main() {
7311
7638
  }
7312
7639
  ]
7313
7640
  };
7314
- const g1 = checkG1(rows, existsSync2, { docs: readHookScanFiles(DOCTRINE_DIR), shipped: shippedHookPaths() });
7641
+ const g1 = checkG1(rows, existsSync3, { docs: readHookScanFiles(DOCTRINE_DIR), shipped: shippedHookPaths() });
7315
7642
  const g2 = checkG2(rows, candidateFiles);
7316
7643
  const g3 = checkG3(ring0Rows, crossingFiles);
7317
7644
  const g5 = checkG5(roles, contracts);
7318
7645
  const g6 = checkG6(rows, new Set(coreCheckRegistry().map((s) => s.name)));
7646
+ const { producers, imports } = gatherLogProducerGraph(process.cwd());
7647
+ const g7 = checkG7({
7648
+ enforcementMapPresent: true,
7649
+ crossingFiles,
7650
+ blockingFiles: blockingGateFiles(ring0Rows, existsSync3),
7651
+ producers,
7652
+ imports,
7653
+ exemptions: G7_EXEMPTIONS,
7654
+ existsFn: existsSync3
7655
+ });
7319
7656
  emitResult(g1, true);
7320
7657
  emitResult(g2, true);
7321
7658
  emitResult(g3, true);
7322
7659
  emitResult(g4Result, true);
7323
7660
  emitResult(g5, true);
7324
7661
  emitResult(g6, true);
7325
- const blockingFailed = [g1, g2, g3, g4Result, g5, g6].some((r) => r.status === "fail");
7662
+ emitResult(g7, true);
7663
+ const blockingFailed = [g1, g2, g3, g4Result, g5, g6, g7].some((r) => r.status === "fail");
7326
7664
  process.exit(blockingFailed ? 1 : 0);
7327
7665
  }
7328
7666
  main();