@attalabs/vinaya 0.39.0 → 0.40.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 (151) hide show
  1. package/README.md +9 -9
  2. package/aeg-root/contracts/planner-developer.md +1 -1
  3. package/aeg-root/enforcement.md +22 -22
  4. package/aeg-root/process.md +1 -1
  5. package/aeg-root/roles/archivist.md +1 -1
  6. package/aeg-root/roles/developer/reference.md +4 -1
  7. package/aeg-root/roles/developer.md +1 -1
  8. package/aeg-root/roles/planner/reference.md +18 -5
  9. package/aeg-root/roles/principal.md +1 -1
  10. package/aeg-root/roles/reviewer.md +3 -3
  11. package/aeg-root/roles/security.md +4 -4
  12. package/aeg-root/roles/tranche-archivist.md +2 -2
  13. package/aeg-root/skills/aeg/SKILL.md +1 -1
  14. package/aeg-root/state-machine.md +8 -13
  15. package/aeg-root/templates/brief-template.md +4 -1
  16. package/aeg-root/templates/decision-record-template.md +38 -0
  17. package/aeg-root/templates/issue-rationale-template.md +1 -1
  18. package/aeg-root/tranche-model.md +1 -1
  19. package/dist/checks/bin/check-body-bare-digits.js +1867 -347
  20. package/dist/checks/bin/check-branch-topology.js +1181 -237
  21. package/dist/checks/bin/check-brief-shape.js +1911 -433
  22. package/dist/checks/bin/check-changeset-coverage.js +2144 -517
  23. package/dist/checks/bin/check-ci-shard-coverage.js +12133 -11
  24. package/dist/checks/bin/check-closes-n.js +1181 -237
  25. package/dist/checks/bin/check-coherence.js +1785 -1126
  26. package/dist/checks/bin/check-dead-branch-push.js +1154 -225
  27. package/dist/checks/bin/check-dispatch-readiness.js +2068 -436
  28. package/dist/checks/bin/check-doc-claims.js +2104 -231
  29. package/dist/checks/bin/check-doc-coverage-push.js +2181 -515
  30. package/dist/checks/bin/check-doc-coverage.js +2181 -519
  31. package/dist/checks/bin/check-doctrine-no-procedures.js +1668 -345
  32. package/dist/checks/bin/check-doctrine-portability.js +2143 -516
  33. package/dist/checks/bin/check-evidence-fresh.js +2080 -465
  34. package/dist/checks/bin/check-exec-bits.js +2130 -503
  35. package/dist/checks/bin/check-first-push-dispatch.js +1845 -371
  36. package/dist/checks/bin/check-issue-assignment.js +712 -170
  37. package/dist/checks/bin/check-issue-milestone-attach.js +1145 -225
  38. package/dist/checks/bin/check-issue-objectives-numbering.js +1661 -338
  39. package/dist/checks/bin/check-issue-parts-coverage.js +1145 -225
  40. package/dist/checks/bin/check-issue-surface-globs.js +1787 -369
  41. package/dist/checks/bin/check-issue-title-grammar.js +1145 -225
  42. package/dist/checks/bin/check-issue-tranche-label.js +702 -170
  43. package/dist/checks/bin/check-main-branch-refusal.js +1157 -227
  44. package/dist/checks/bin/check-no-disk-state.js +1145 -225
  45. package/dist/checks/bin/check-pr-premise-reassert.js +1661 -338
  46. package/dist/checks/bin/check-pr-report-density.js +1145 -225
  47. package/dist/checks/bin/check-principal-test-plan-wait.js +2379 -249
  48. package/dist/checks/bin/check-quoted-command.js +2128 -501
  49. package/dist/checks/bin/check-reader-resolvable-prose.js +2170 -517
  50. package/dist/checks/bin/check-registry-gates.js +1228 -272
  51. package/dist/checks/bin/check-retired-vocabulary.js +2153 -507
  52. package/dist/checks/bin/check-review-gate.js +1932 -350
  53. package/dist/checks/bin/check-single-plan-pr.js +1208 -229
  54. package/dist/checks/bin/check-surface-scope.js +1414 -244
  55. package/dist/checks/bin/check-test-plan.js +2381 -252
  56. package/dist/checks/bin/check-token-collection-wired.js +1145 -225
  57. package/dist/checks/bin/check-workspace-escape.js +2141 -514
  58. package/dist/checks/bin/verify-coherence.js +493 -86
  59. package/dist/checks/bin/verify-dispatch.js +512 -132
  60. package/dist/checks/bin/verify-docs.js +549 -124
  61. package/dist/index.js +22702 -17900
  62. package/dist/lib/pre-push-cache-test-run.js +1026 -233
  63. package/dist/lib/pre-push-select-tests.js +922 -173
  64. package/package.json +12 -1
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +13 -2
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +55 -26
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +12 -1
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +22 -1
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -1
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/entry-point.ts +27 -0
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +2 -1
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +19 -2
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +593 -55
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +1 -0
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +6 -4
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +19 -2
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +32 -13
  78. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  80. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +2 -2
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  122. 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
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0sxadt2._.js +13 -0
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +57 -0
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1ug9syi._.js → [root-of-the-server]__1wzfiav._.js} +1 -1
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  138. 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
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  143. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{06_55xbp7rcbi.js → 1p3vr9qts86_b.js} +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2brkwv169ygep.js → 21tunzmxjvm2a.js} +1 -1
  145. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{33rszkngkuoko.js → 38kom-9c-oi65.js} +1 -1
  146. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +0 -57
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +0 -13
  149. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_buildManifest.js +0 -0
  150. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_clientMiddlewareManifest.js +0 -0
  151. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_ssgManifest.js +0 -0
@@ -1774,7 +1774,8 @@ var ANCHOR_FIELDS = [
1774
1774
  "PREMISE",
1775
1775
  "TEST-PLAN",
1776
1776
  "EVIDENCE",
1777
- "BEYOND-SURFACE"
1777
+ "BEYOND-SURFACE",
1778
+ "LIVE"
1778
1779
  ];
1779
1780
  function anchoredRegionBounds(body, field) {
1780
1781
  const masked = maskCode(body);
@@ -1994,6 +1995,14 @@ var RULING_ORDINAL_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Ruling ordinal:\s*(\d+)(
1994
1995
  var BRIEF_HASH_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Brief hash:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
1995
1996
  var POLICY_DIGEST_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Policy digest:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
1996
1997
  var BASE_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged base:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
1998
+ var MANIFEST_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Manifest version:\s*(\d+)\s*$/im;
1999
+ var PAUSE_BOUND_RULING_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Pause-bound ruling:\s*(?:(\S+)\|(\S+)\|([0-9a-f]{64})|\(none\))\s*$/im;
2000
+ function extractPauseBoundRuling(comment) {
2001
+ const m = comment.match(PAUSE_BOUND_RULING_PATTERN);
2002
+ if (!m)
2003
+ return;
2004
+ return m[1] ? { rulingId: m[1], pauseId: m[2], contentDigest: m[3] } : null;
2005
+ }
1997
2006
  function firstFiveLines(comment) {
1998
2007
  return comment.split(`
1999
2008
  `).slice(0, 5).join(`
@@ -2087,6 +2096,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
2087
2096
  danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
2088
2097
  };
2089
2098
  }
2099
+ const versionMatch = latest.match(MANIFEST_VERSION_PATTERN);
2100
+ const pauseBoundRuling = extractPauseBoundRuling(latest);
2090
2101
  return {
2091
2102
  value: m[1].toUpperCase().replace(/[_-]/g, " "),
2092
2103
  headSha: extractHeadSha(latest),
@@ -2095,6 +2106,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
2095
2106
  briefHash: extractBriefHash(latest),
2096
2107
  policyDigest: extractPolicyDigest(latest),
2097
2108
  baseSha: extractBaseSha(latest),
2109
+ ...versionMatch ? { manifestVersion: Number.parseInt(versionMatch[1], 10) } : {},
2110
+ ...pauseBoundRuling === undefined ? {} : { pauseBoundRuling },
2098
2111
  findingSeverities: extractFindingSeverities(latest),
2099
2112
  danglingNote: null
2100
2113
  };
@@ -2105,6 +2118,16 @@ function extractCodeReviewVerdict(comments) {
2105
2118
  function extractSecurityReviewVerdict(comments) {
2106
2119
  return extractVerdict(comments, /^[ \t]*(?:\*{1,3}|_{1,3})?VERDICT:\s*(PASS|FAIL)(?![A-Za-z0-9])/im, "security-review");
2107
2120
  }
2121
+
2122
+ // ../../packages/aeg-core/src/review-status.ts
2123
+ var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-(\d+)\s*-->/i;
2124
+ function parseDeveloperRoundMarker(body) {
2125
+ const m = body.match(DEVELOPER_ROUND_MARKER);
2126
+ if (!m)
2127
+ return null;
2128
+ const n = Number(m[1]);
2129
+ return Number.isFinite(n) ? n : null;
2130
+ }
2108
2131
  // ../../packages/aeg-core/src/report-tokens.ts
2109
2132
  var DASH_LOOKALIKES = {
2110
2133
  "-": "‑",
@@ -2800,14 +2823,14 @@ function checkTestPlan(prBody) {
2800
2823
  const region = located.found ? located.section : prBody;
2801
2824
  if (TEST_PLAN_UNIT_TESTS_ONLY_RE.test(region))
2802
2825
  return { status: "pass", errors: [] };
2803
- if (/\*\*\[(?:agent|principal)\]\*\*/.test(region))
2826
+ if (/\*\*\[(?:agent|principal|live)\]\*\*/.test(region))
2804
2827
  return { status: "pass", errors: [] };
2805
2828
  if (located.found && extractFencedBlocks(region).length > 0)
2806
2829
  return { status: "pass", errors: [] };
2807
2830
  return {
2808
2831
  status: "fail",
2809
2832
  errors: [
2810
- "brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`-tagged checklist item."
2833
+ "brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`/`**[live]**`-tagged item."
2811
2834
  ]
2812
2835
  };
2813
2836
  }
@@ -3429,6 +3452,375 @@ function checkPrReportDensity(prBody) {
3429
3452
  const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
3430
3453
  return { errors: results.flatMap((r) => r.errors) };
3431
3454
  }
3455
+ // ../../packages/aeg-core/src/prose-rules.ts
3456
+ var RETIRED_GLOBAL_EXEMPTIONS = [
3457
+ "docs/decisions-legacy.md",
3458
+ "apps/herald-ai/docs/",
3459
+ "apps/vada-ai/docs/",
3460
+ "aeg-root/tranches/completed/",
3461
+ "packages/aeg-core/src/docs/published-prose",
3462
+ "packages/aeg-core/src/retired-vocabulary.test.ts",
3463
+ "packages/aeg-core/src/retired-vocabulary.ts",
3464
+ "/fixtures/",
3465
+ "/node_modules/",
3466
+ "/.next/",
3467
+ "/.turbo/"
3468
+ ];
3469
+ var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
3470
+ var TRANCHE_MODEL_FILE = "/tranche-model.md";
3471
+ var RETIRED_PATTERN_EXEMPTIONS = {
3472
+ [String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
3473
+ [String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
3474
+ "docs-index.md",
3475
+ "apps/vada-ai/specs/legacy/README.md",
3476
+ "apps/vada-ai/specs/vada-product-spec.md",
3477
+ "apps/vada-ai/web/CLAUDE.md",
3478
+ "apps/vada-ai/CLAUDE.md"
3479
+ ],
3480
+ "decisions-legacy": [
3481
+ "packages/aeg-core/src/file-classify.ts",
3482
+ "packages/aeg-core/src/file-classify.test.ts",
3483
+ "packages/aeg-core/src/pr-tier.test.ts",
3484
+ "docs-index.md",
3485
+ ".claude/skills/database/SKILL.md",
3486
+ ".claude/skills/vada-architecture/SKILL.md",
3487
+ "apps/vada-ai/specs/vada-byok-principles.md",
3488
+ "apps/vada-ai/web/CLAUDE.md",
3489
+ "apps/vada-ai/CLAUDE.md"
3490
+ ],
3491
+ CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
3492
+ ...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
3493
+ };
3494
+ var retiredPatterns = [
3495
+ String.raw`\bD-[0-9]{3}\b`,
3496
+ "D-(###|NNN|nnn|xxx)",
3497
+ "decision (entry|logged)",
3498
+ "decision-log entry",
3499
+ "decision log entry",
3500
+ "decision log(s|ged|ging)?([^a-z]|$)",
3501
+ "decision-log",
3502
+ "decision entr",
3503
+ "decisions? (are |is )?logged",
3504
+ "log entries",
3505
+ String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
3506
+ "decisions-legacy",
3507
+ "CONTRADICTION",
3508
+ "assumes Tier 3",
3509
+ "Lock: ?YES",
3510
+ "Lock: ?NO",
3511
+ "lock approvals?",
3512
+ "approves locks",
3513
+ "Conforms to lock",
3514
+ "Challenges lock",
3515
+ "checkDecisionNumbersFresh",
3516
+ String.raw`roles/team-leader\.md`,
3517
+ String.raw`\(,`,
3518
+ String.raw`,\)`,
3519
+ String.raw`\(\.\)`,
3520
+ ...PLAN_ON_DISK_PATTERNS
3521
+ ];
3522
+ var published = [
3523
+ ["decision-id", "a decision id", /\bD-\d{3,}\b/],
3524
+ ["section-ref", "a section reference", /§/],
3525
+ ["forge-number", "a forge number", /#\d+/],
3526
+ ["retired-name", "the retired public name", /\bAEG\b/],
3527
+ ["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
3528
+ [
3529
+ "label-vocabulary",
3530
+ "forge label vocabulary",
3531
+ /(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
3532
+ ],
3533
+ ["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
3534
+ ["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
3535
+ [
3536
+ "internal-path",
3537
+ "a repo-internal file",
3538
+ /(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
3539
+ ]
3540
+ ];
3541
+ var DEFAULT_PROSE_RULES = [
3542
+ {
3543
+ id: "forge-number",
3544
+ group: "reader-resolvable",
3545
+ scopes: ["ships", "reader-facing", "spec"],
3546
+ patterns: { prose: /#[0-9]{2,4}/g },
3547
+ flags: ["global"],
3548
+ message: "a forge number",
3549
+ severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
3550
+ exemptions: []
3551
+ },
3552
+ {
3553
+ id: "tranche-slug",
3554
+ group: "reader-resolvable",
3555
+ scopes: ["ships", "reader-facing", "product", "spec"],
3556
+ patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
3557
+ flags: ["global"],
3558
+ message: "an internal tranche slug",
3559
+ severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
3560
+ exemptions: []
3561
+ },
3562
+ {
3563
+ id: "task-number",
3564
+ group: "reader-resolvable",
3565
+ scopes: ["spec"],
3566
+ patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
3567
+ flags: ["global", "ignore-case"],
3568
+ message: "a task number",
3569
+ severity: { spec: "error" },
3570
+ exemptions: []
3571
+ },
3572
+ {
3573
+ id: "source-comment-tranche-slug",
3574
+ group: "reader-resolvable",
3575
+ scopes: ["source-comment"],
3576
+ patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
3577
+ flags: ["global"],
3578
+ message: "a tranche-slug citation",
3579
+ severity: { "source-comment": "warning" },
3580
+ exemptions: []
3581
+ },
3582
+ {
3583
+ id: "source-comment-forge-number",
3584
+ group: "reader-resolvable",
3585
+ scopes: ["source-comment"],
3586
+ patterns: { comment: /#[0-9]{2,}/g },
3587
+ flags: ["global"],
3588
+ message: "a forge-number citation",
3589
+ severity: { "source-comment": "warning" },
3590
+ exemptions: []
3591
+ },
3592
+ {
3593
+ id: "legacy-batch-name",
3594
+ group: "reader-resolvable",
3595
+ scopes: ["ships", "reader-facing", "spec"],
3596
+ patterns: {},
3597
+ flags: ["built-in"],
3598
+ message: "an internal tranche slug",
3599
+ severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
3600
+ exemptions: [],
3601
+ builtIn: true
3602
+ },
3603
+ {
3604
+ id: "coined-term",
3605
+ group: "reader-resolvable",
3606
+ scopes: ["ships", "reader-facing"],
3607
+ patterns: {},
3608
+ flags: ["built-in"],
3609
+ message: "uses coined term without defining it inline or linking the glossary",
3610
+ severity: { ships: "warning", "reader-facing": "warning" },
3611
+ exemptions: [],
3612
+ builtIn: true
3613
+ },
3614
+ ...retiredPatterns.map((pattern, index) => ({
3615
+ id: `retired-vocabulary-${index + 1}`,
3616
+ group: "retired-vocabulary",
3617
+ scopes: ["repository"],
3618
+ patterns: { repository: pattern },
3619
+ flags: [],
3620
+ message: "retired vocabulary",
3621
+ severity: { repository: "error" },
3622
+ exemptions: RETIRED_GLOBAL_EXEMPTIONS,
3623
+ patternExemptions: RETIRED_PATTERN_EXEMPTIONS
3624
+ })),
3625
+ ...published.map(([id, message, pattern]) => ({
3626
+ id,
3627
+ group: "published-prose",
3628
+ scopes: ["published"],
3629
+ patterns: { published: pattern },
3630
+ flags: [],
3631
+ message,
3632
+ severity: { published: "error" },
3633
+ exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
3634
+ }))
3635
+ ];
3636
+ var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
3637
+ var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
3638
+ var RETIRED_SCOPES = ["repository"];
3639
+ var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
3640
+ function groupOfScope(scope) {
3641
+ if (RESOLVABLE_SCOPES.includes(scope))
3642
+ return "reader-resolvable";
3643
+ if (RETIRED_SCOPES.includes(scope))
3644
+ return "retired-vocabulary";
3645
+ return;
3646
+ }
3647
+ var CONFIGURED_PROSE_FLAGS = ["i", "u"];
3648
+ var CONFIGURED_PATTERN_MAX_LENGTH = 200;
3649
+ var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
3650
+ function allowedScopesFor(rule) {
3651
+ if (rule.builtIn)
3652
+ return rule.scopes;
3653
+ return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
3654
+ }
3655
+ function normalizeRepoPath(entry) {
3656
+ let out = entry.replace(/\\/g, "/");
3657
+ while (out.startsWith("./"))
3658
+ out = out.slice(2);
3659
+ out = out.replace(/\/{2,}/g, "/");
3660
+ while (out.endsWith("/"))
3661
+ out = out.slice(0, -1);
3662
+ return out;
3663
+ }
3664
+ function isConfiguredExempt(path, exempt, repoRoot) {
3665
+ if (exempt.length === 0)
3666
+ return false;
3667
+ const root = repoRoot === undefined ? undefined : normalizeRepoPath(repoRoot);
3668
+ let rel = normalizeRepoPath(path);
3669
+ if (root && rel.startsWith(`${root}/`))
3670
+ rel = rel.slice(root.length + 1);
3671
+ return exempt.some((entry) => {
3672
+ const e = normalizeRepoPath(entry);
3673
+ return rel === e || rel.startsWith(`${e}/`);
3674
+ });
3675
+ }
3676
+ function ruleReads(set, rule, path) {
3677
+ return !isConfiguredExempt(path, set.exempt, set.repoRoot) && !isConfiguredExempt(path, rule.exempt, set.repoRoot);
3678
+ }
3679
+ var RESOLVABLE_RUN_ORDER = [
3680
+ "forge-number",
3681
+ "tranche-slug",
3682
+ "legacy-batch-name",
3683
+ "task-number",
3684
+ "source-comment-tranche-slug",
3685
+ "source-comment-forge-number",
3686
+ "coined-term"
3687
+ ];
3688
+ var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
3689
+ function scopeDefaultSeverity(scope, sourceCommentSeverity) {
3690
+ if (scope === "source-comment")
3691
+ return sourceCommentSeverity ?? "warning";
3692
+ if (scope === "repository")
3693
+ return "error";
3694
+ return "warning";
3695
+ }
3696
+ function applySeverity(scopes, base, setting) {
3697
+ const out = {};
3698
+ for (const scope of scopes) {
3699
+ const configured = typeof setting === "string" ? setting : setting?.[scope];
3700
+ const value = configured ?? base[scope];
3701
+ if (value !== undefined)
3702
+ out[scope] = value;
3703
+ }
3704
+ return out;
3705
+ }
3706
+ function defaultPatternFor(rule) {
3707
+ const cache = new Map;
3708
+ return (scope) => {
3709
+ if (cache.has(scope))
3710
+ return cache.get(scope) ?? null;
3711
+ const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
3712
+ const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
3713
+ cache.set(scope, compiled);
3714
+ return compiled;
3715
+ };
3716
+ }
3717
+ function customPatternFor(rule, global) {
3718
+ const cache = new Map;
3719
+ return (scope) => {
3720
+ if (cache.has(scope))
3721
+ return cache.get(scope) ?? null;
3722
+ const source = rule.patterns?.[scope] ?? rule.pattern;
3723
+ const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
3724
+ cache.set(scope, compiled);
3725
+ return compiled;
3726
+ };
3727
+ }
3728
+ function resolveProseRules(config = undefined, options = {}) {
3729
+ const rules = [];
3730
+ const defaults = config?.defaults ?? {};
3731
+ for (const rule of CONFIGURABLE_DEFAULT_RULES) {
3732
+ const override = defaults[rule.id];
3733
+ if (override === "off")
3734
+ continue;
3735
+ const group = rule.group;
3736
+ const scopes = override?.scopes ?? rule.scopes;
3737
+ const base = {};
3738
+ for (const scope of scopes) {
3739
+ base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
3740
+ }
3741
+ rules.push({
3742
+ id: rule.id,
3743
+ group,
3744
+ custom: false,
3745
+ builtIn: rule.builtIn === true,
3746
+ scopes,
3747
+ message: rule.message,
3748
+ severity: applySeverity(scopes, base, override?.severity),
3749
+ exempt: override?.exempt ?? [],
3750
+ substringExempt: rule.exemptions,
3751
+ reportGroup: REPORT_GROUPS[rule.id],
3752
+ patternFor: defaultPatternFor(rule)
3753
+ });
3754
+ }
3755
+ for (const rule of config?.custom ?? []) {
3756
+ const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
3757
+ const base = {};
3758
+ for (const scope of rule.scopes)
3759
+ base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
3760
+ rules.push({
3761
+ id: rule.id,
3762
+ group,
3763
+ custom: true,
3764
+ builtIn: false,
3765
+ scopes: rule.scopes,
3766
+ message: rule.means,
3767
+ severity: applySeverity(rule.scopes, base, rule.severity),
3768
+ exempt: rule.exempt ?? [],
3769
+ substringExempt: [],
3770
+ patternFor: customPatternFor(rule, group === "reader-resolvable")
3771
+ });
3772
+ }
3773
+ if (options.decisionRecordsPath !== undefined)
3774
+ rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
3775
+ const order = (rule) => {
3776
+ const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
3777
+ return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
3778
+ };
3779
+ const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
3780
+ const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
3781
+ return {
3782
+ rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
3783
+ exempt: config?.exempt ?? [],
3784
+ repoRoot: options.repoRoot
3785
+ };
3786
+ }
3787
+ function rulesOfGroup(set, group) {
3788
+ return set.rules.filter((rule) => rule.group === group);
3789
+ }
3790
+ function rulesInScope(set, scope) {
3791
+ return set.rules.filter((rule) => rule.scopes.includes(scope));
3792
+ }
3793
+ var DEFAULT_PROSE_RULE_SET = resolveProseRules();
3794
+ var DECISION_RECORD_CITATION_ID = "decision-record-citation";
3795
+ var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
3796
+ var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
3797
+ function escapeRegExp(text) {
3798
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3799
+ }
3800
+ function decisionRecordCitationPattern(decisionRecordsPath) {
3801
+ const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
3802
+ return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
3803
+ }
3804
+ function decisionRecordCitationRule(decisionRecordsPath) {
3805
+ const folder = normalizeRepoPath(decisionRecordsPath);
3806
+ const pattern = decisionRecordCitationPattern(folder);
3807
+ const severity = {};
3808
+ for (const scope of DECISION_RECORD_CITATION_SCOPES)
3809
+ severity[scope] = "error";
3810
+ return {
3811
+ id: DECISION_RECORD_CITATION_ID,
3812
+ group: "reader-resolvable",
3813
+ custom: false,
3814
+ builtIn: false,
3815
+ scopes: DECISION_RECORD_CITATION_SCOPES,
3816
+ message: DECISION_RECORD_CITATION_MESSAGE,
3817
+ severity,
3818
+ exempt: [folder],
3819
+ substringExempt: [],
3820
+ patternFor: () => pattern
3821
+ };
3822
+ }
3823
+
3432
3824
  // ../../packages/aeg-core/src/reader-resolvable-prose.ts
3433
3825
  var PRODUCT_SLUG_SCOPE = [
3434
3826
  "apps/cli/src",
@@ -3440,8 +3832,8 @@ var PRODUCT_SLUG_SCOPE = [
3440
3832
  function isUnderOrEqual(path, prefix) {
3441
3833
  return path === prefix || path.startsWith(`${prefix}/`);
3442
3834
  }
3443
- function isProductScopeFile(path) {
3444
- return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
3835
+ function isProductScopeFile(path, productPaths) {
3836
+ return productPaths.some((prefix) => isUnderOrEqual(path, normalizeRepoPath(prefix)));
3445
3837
  }
3446
3838
  var SHIPS_PREFIX = "aeg-root/";
3447
3839
  function shipsArchivePrefix(shipsPrefix) {
@@ -3449,13 +3841,7 @@ function shipsArchivePrefix(shipsPrefix) {
3449
3841
  }
3450
3842
  var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
3451
3843
  function normalizeSpecPath(entry) {
3452
- let out = entry.replace(/\\/g, "/");
3453
- while (out.startsWith("./"))
3454
- out = out.slice(2);
3455
- out = out.replace(/\/{2,}/g, "/");
3456
- while (out.endsWith("/"))
3457
- out = out.slice(0, -1);
3458
- return out;
3844
+ return normalizeRepoPath(entry);
3459
3845
  }
3460
3846
  function isSpecFile2(path, specPaths) {
3461
3847
  if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
@@ -3467,7 +3853,7 @@ function isSpecFile2(path, specPaths) {
3467
3853
  function isClaudeMdFile(path) {
3468
3854
  return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
3469
3855
  }
3470
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
3856
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS, productPaths = PRODUCT_SLUG_SCOPE) {
3471
3857
  if (path.startsWith(shipsPrefix)) {
3472
3858
  return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
3473
3859
  }
@@ -3478,7 +3864,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
3478
3864
  return "internal";
3479
3865
  if (isSpecFile2(path, specPaths))
3480
3866
  return "spec";
3481
- if (isProductScopeFile(path))
3867
+ if (isProductScopeFile(path, productPaths))
3482
3868
  return "product";
3483
3869
  return null;
3484
3870
  }
@@ -3503,9 +3889,16 @@ function lineAt(content, index) {
3503
3889
  }
3504
3890
  return line;
3505
3891
  }
3506
- var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
3507
- var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
3508
- var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
3892
+ var readerRules = rulesForGroup("reader-resolvable");
3893
+ var readerPattern = (id, scope = "prose") => {
3894
+ const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
3895
+ if (!(pattern instanceof RegExp))
3896
+ throw new Error(`default prose rule ${id} has no ${scope} pattern`);
3897
+ return pattern;
3898
+ };
3899
+ var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
3900
+ var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
3901
+ var TASK_NUMBER_PATTERN = readerPattern("task-number");
3509
3902
  function legacySlugPattern(legacySlugs) {
3510
3903
  if (legacySlugs.length === 0)
3511
3904
  return null;
@@ -3515,48 +3908,61 @@ function legacySlugPattern(legacySlugs) {
3515
3908
  function specGrandfatherPaths(specGrandfather) {
3516
3909
  return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
3517
3910
  }
3518
- function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3911
+ var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
3912
+ function referenceRulesFor(set, cls) {
3913
+ return rulesInScope(set, cls).filter((rule) => rule.group === "reader-resolvable" && rule.id !== "coined-term");
3914
+ }
3915
+ function citations(pattern, text, group) {
3916
+ const out = [];
3917
+ const re = pattern.global ? pattern : new RegExp(pattern.source, `${pattern.flags}g`);
3918
+ re.lastIndex = 0;
3919
+ let match = re.exec(text);
3920
+ while (match !== null) {
3921
+ if (match[0] === "") {
3922
+ re.lastIndex++;
3923
+ } else {
3924
+ const cited = group !== undefined ? match[group] ?? match[0] : match[0];
3925
+ out.push({ cited, index: match.index + match[0].indexOf(cited) });
3926
+ }
3927
+ match = re.exec(text);
3928
+ }
3929
+ re.lastIndex = 0;
3930
+ return out;
3931
+ }
3932
+ function customMessage(rule, cited) {
3933
+ return `${rule.id}: ${rule.message} ("${cited}")`;
3934
+ }
3935
+ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
3936
+ const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
3937
+ const productPaths = options.productPaths ?? PRODUCT_SLUG_SCOPE;
3519
3938
  const findings = [];
3520
3939
  const legacyPattern = legacySlugPattern(legacySlugs);
3521
3940
  const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
3522
3941
  const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
3523
- const patterns = [
3524
- { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
3525
- { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
3526
- ...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
3527
- ];
3528
- const productPatterns = [
3529
- { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
3530
- ];
3531
- const specPatterns = [
3532
- ...patterns,
3533
- { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
3534
- ];
3535
3942
  for (const file of files) {
3536
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
3537
- if (!cls || cls === "internal")
3538
- continue;
3539
- if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
3943
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths, productPaths);
3944
+ if (!cls || !REFERENCE_CLASSES.has(cls))
3540
3945
  continue;
3541
3946
  if (cls === "spec" && grandfatheredWhole.has(file.path))
3542
3947
  continue;
3543
- const blocking = cls === "product" || cls === "spec";
3544
3948
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
3545
- const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
3546
3949
  const fileFindings = [];
3547
- for (const { pattern, what, group } of patternsToRun) {
3548
- pattern.lastIndex = 0;
3549
- let match = pattern.exec(scrubbed);
3550
- while (match !== null) {
3551
- const cited = group !== undefined ? match[group] ?? match[0] : match[0];
3552
- const citedIndex = match.index + match[0].indexOf(cited);
3950
+ for (const rule of referenceRulesFor(set, cls)) {
3951
+ if (!ruleReads(set, rule, file.path))
3952
+ continue;
3953
+ const pattern = !rule.custom && rule.id === "legacy-batch-name" ? legacyPattern : rule.patternFor(cls);
3954
+ if (!pattern)
3955
+ continue;
3956
+ const blocking = rule.severity[cls] === "error";
3957
+ const what = cls === "product" ? `${rule.message} in product code` : rule.message;
3958
+ for (const { cited, index } of citations(pattern, scrubbed, rule.custom ? undefined : rule.reportGroup)) {
3553
3959
  fileFindings.push({
3554
3960
  file: file.path,
3555
- line: lineAt(scrubbed, citedIndex),
3556
- message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
3557
- blocking
3961
+ line: lineAt(scrubbed, index),
3962
+ message: rule.custom ? customMessage(rule, cited) : `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
3963
+ blocking,
3964
+ rule: rule.id
3558
3965
  });
3559
- match = pattern.exec(scrubbed);
3560
3966
  }
3561
3967
  }
3562
3968
  const limit = cls === "spec" ? limits.get(file.path) : undefined;
@@ -3597,11 +4003,17 @@ function definesOrLinksGlossary(content, term) {
3597
4003
  return true;
3598
4004
  return /docs\/glossary|glossary\.md/i.test(content);
3599
4005
  }
3600
- function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4006
+ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, options = {}) {
3601
4007
  const findings = [];
4008
+ const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
4009
+ const rule = set.rules.find((r) => !r.custom && r.id === "coined-term");
4010
+ if (!rule)
4011
+ return findings;
3602
4012
  for (const file of files) {
3603
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3604
- if (!cls || !SWEPT_CLASSES.has(cls))
4013
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, DEFAULT_SPEC_PATHS, options.productPaths);
4014
+ if (!cls || !SWEPT_CLASSES.has(cls) || !rule.scopes.includes(cls))
4015
+ continue;
4016
+ if (!ruleReads(set, rule, file.path))
3605
4017
  continue;
3606
4018
  const scrubbed = stripNonProse(file.path, file.content);
3607
4019
  for (const term of glossaryTerms) {
@@ -3614,14 +4026,15 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
3614
4026
  file: file.path,
3615
4027
  line,
3616
4028
  message: `uses coined term "${term}" without defining it inline or linking the glossary`,
3617
- blocking: false
4029
+ blocking: rule.severity[cls] === "error",
4030
+ rule: rule.id
3618
4031
  });
3619
4032
  }
3620
4033
  }
3621
4034
  return findings;
3622
4035
  }
3623
- var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g;
3624
- var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g;
4036
+ var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
4037
+ var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
3625
4038
  function extractComments(path, content) {
3626
4039
  if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
3627
4040
  return content.replace(/[^\n]/g, "");
@@ -3718,39 +4131,40 @@ function extractComments(path, content) {
3718
4131
  }
3719
4132
  return out;
3720
4133
  }
3721
- function checkSourceComments(files, allowlist = []) {
4134
+ function checkSourceComments(files, allowlist = [], options = {}) {
3722
4135
  const findings = [];
3723
4136
  const allowed = new Set(allowlist);
3724
- const patterns = [
3725
- { pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
3726
- { pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
3727
- ];
4137
+ const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
4138
+ const rules = rulesInScope(set, "source-comment").filter((rule) => rule.group === "reader-resolvable");
3728
4139
  for (const file of files) {
3729
4140
  if (!file.path.endsWith(".ts"))
3730
4141
  continue;
3731
4142
  if (allowed.has(file.path))
3732
4143
  continue;
3733
4144
  const comments = extractComments(file.path, file.content);
3734
- for (const { pattern, what } of patterns) {
3735
- pattern.lastIndex = 0;
3736
- let match = pattern.exec(comments);
3737
- while (match !== null) {
4145
+ for (const rule of rules) {
4146
+ if (!ruleReads(set, rule, file.path))
4147
+ continue;
4148
+ const pattern = rule.patternFor("source-comment");
4149
+ if (!pattern)
4150
+ continue;
4151
+ for (const { cited, index } of citations(pattern, comments)) {
3738
4152
  findings.push({
3739
4153
  file: file.path,
3740
- line: lineAt(comments, match.index),
3741
- message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
3742
- blocking: false
4154
+ line: lineAt(comments, index),
4155
+ message: rule.custom ? customMessage(rule, cited) : `comment cites ${rule.message} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4156
+ blocking: rule.severity["source-comment"] === "error",
4157
+ rule: rule.id
3743
4158
  });
3744
- match = pattern.exec(comments);
3745
4159
  }
3746
4160
  }
3747
4161
  }
3748
4162
  return findings;
3749
4163
  }
3750
- function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4164
+ function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
3751
4165
  return [
3752
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
3753
- ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4166
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths, options),
4167
+ ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix, options)
3754
4168
  ];
3755
4169
  }
3756
4170
  function parseGlossaryTerms(glossaryContent) {
@@ -4072,13 +4486,20 @@ function globCoversPath(glob, path) {
4072
4486
  return !p.includes("/");
4073
4487
  return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
4074
4488
  }
4489
+ function surfaceEntryResolves(entry, resolvesToFile, pinnedFiles) {
4490
+ if (resolvesToFile(entry))
4491
+ return true;
4492
+ const directory = entry.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
4493
+ return pinnedFiles.some((path) => path.startsWith(`${directory}/`));
4494
+ }
4075
4495
  function checkSurfaceGlobsResolve(body, resolvesToFile) {
4076
4496
  const surface = parseIssueSurface(body);
4077
4497
  if (!surface.ok)
4078
4498
  return { status: "pass", errors: [] };
4499
+ const pinnedFiles = boundaryPinnedFiles(body);
4079
4500
  const errors = [];
4080
4501
  for (const glob of surface.value.in) {
4081
- if (!resolvesToFile(glob)) {
4502
+ if (!surfaceEntryResolves(glob, resolvesToFile, pinnedFiles)) {
4082
4503
  errors.push(`issue-validation Surface: \`${glob}\` in \`## Surface\`'s \`in:\` list matches no tracked file — a Surface that cannot resolve cannot render a brief's file list.`);
4083
4504
  }
4084
4505
  }
@@ -4163,6 +4584,19 @@ function checkPartsCiteDefinedObjectives(body) {
4163
4584
  }
4164
4585
  return { status: errors.length > 0 ? "fail" : "pass", errors };
4165
4586
  }
4587
+ var ISSUE_LIVE_LINE_RE = /^-\s*\*{2}\[live\]\*{2}(.*)$/gim;
4588
+ function liveCommand(text) {
4589
+ const trimmed = text.trim();
4590
+ const span = /^(`+)(.+)\1$/.exec(trimmed);
4591
+ return span ? span[2].trim() : trimmed;
4592
+ }
4593
+ function liveItemsIn(region) {
4594
+ return [...region.matchAll(ISSUE_LIVE_LINE_RE)].map((m) => liveCommand(m[1] ?? "")).filter(Boolean);
4595
+ }
4596
+ function parseLiveTestPlanItems(body) {
4597
+ const located = locateTestPlanSection(body);
4598
+ return located.found ? liveItemsIn(located.section) : [];
4599
+ }
4166
4600
  function isTaskIssueLabelSet(labels) {
4167
4601
  return hasLabel("tranche", labels);
4168
4602
  }
@@ -4184,6 +4618,7 @@ function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTi
4184
4618
  };
4185
4619
  }
4186
4620
  var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
4621
+ var PATH_TEXT = (body) => stripCode(body, { inlineSpans: "keep" });
4187
4622
  function isControlCodePoint(codePoint) {
4188
4623
  return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
4189
4624
  }
@@ -4244,8 +4679,14 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
4244
4679
  }
4245
4680
  return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
4246
4681
  }
4682
+ function rationaleFieldText(text, labelPattern) {
4683
+ const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})[^\\n]*\\n?([\\s\\S]*?)(?=\\n\\s*(?:\\*\\*[A-Z]|#{1,4}\\s)|(?![\\s\\S]))`, "im");
4684
+ const m = re.exec(text);
4685
+ return m ? m[0] : "";
4686
+ }
4247
4687
  var DOC_PATH_RE = /(?:(?:aeg-root|apps|packages|specs|docs|tools|\.claude|\.github)\/[\w./@-]*\.(?:md|mdx)|\.claude\/(?:skills|rules)\/[\w./-]+|\b(?:docs-index|decisions|projects|state-machine|enforcement|process|README|CLAUDE)\.md\b|\b[\w-]+-(?:spec|decisions|backlog)\.md\b)/i;
4248
4688
  var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
4689
+ var RATIONALE_PATH_RE_GLOBAL = /`([\w.@-]+(?:\/[\w.@-]+)+)`/g;
4249
4690
  function normalizeEdgeId(s) {
4250
4691
  const qualified = splitSlugQualifiedEdge(s);
4251
4692
  return (qualified ? qualified.bareId : s).replace(/^#/, "").trim();
@@ -4253,6 +4694,15 @@ function normalizeEdgeId(s) {
4253
4694
  function edgesNameEachOther(a, b) {
4254
4695
  return a.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(b.ref)) || b.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(a.ref));
4255
4696
  }
4697
+ var BOUNDARY_OUT_RE = /\bOut\s*:\s*([\s\S]*)$/im;
4698
+ function boundaryOutText(body) {
4699
+ const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
4700
+ const m = BOUNDARY_OUT_RE.exec(boundary);
4701
+ return m ? m[1] : "";
4702
+ }
4703
+ function namedPathsIn(text) {
4704
+ return [...new Set([...text.matchAll(RATIONALE_PATH_RE_GLOBAL)].map((m) => m[1]))].filter((p) => !/^https?:\/\//i.test(p));
4705
+ }
4256
4706
  var FILE_EXTENSIONS = new Set([
4257
4707
  "ts",
4258
4708
  "tsx",
@@ -4274,6 +4724,11 @@ var FILE_EXTENSIONS = new Set([
4274
4724
  "html",
4275
4725
  "css"
4276
4726
  ]);
4727
+ function boundaryPinnedFiles(body) {
4728
+ const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
4729
+ const excluded = new Set(namedPathsIn(boundaryOutText(body)));
4730
+ return namedPathsIn(boundary).filter((p) => looksLikeFilePath(p) && !excluded.has(p));
4731
+ }
4277
4732
  var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
4278
4733
  var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
4279
4734
 
@@ -4647,6 +5102,58 @@ function extractIssue(body) {
4647
5102
  }
4648
5103
  // ../../packages/aeg-core/src/review-input-manifest.ts
4649
5104
  import { createHash as createHash4 } from "node:crypto";
5105
+
5106
+ // ../../packages/aeg-core/src/ruling-ordinal.ts
5107
+ var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
5108
+ function newestPrincipalRulingOrdinal(comments, allowlist) {
5109
+ let best = 0;
5110
+ for (const c of comments) {
5111
+ if (!isPrincipal(c.author, allowlist))
5112
+ continue;
5113
+ const firstLine = (c.body.split(`
5114
+ `)[0] ?? "").trim();
5115
+ const m = RULING_MARKER_ORDINAL.exec(firstLine);
5116
+ if (!m)
5117
+ continue;
5118
+ const k = Number.parseInt(m[1], 10);
5119
+ if (k > best)
5120
+ best = k;
5121
+ }
5122
+ return best;
5123
+ }
5124
+ function parseRulingIdentity(rulingId) {
5125
+ const m = /^(issue-)?(\d+)-(\d+)$/.exec(rulingId);
5126
+ if (!m)
5127
+ return null;
5128
+ const ref = Number.parseInt(m[2], 10);
5129
+ const ordinal = Number.parseInt(m[3], 10);
5130
+ if (ref <= 0 || ordinal <= 0)
5131
+ return null;
5132
+ return { target: m[1] ? "issue" : "pr", ref, ordinal };
5133
+ }
5134
+ function principalRulingTextById(comments, allowlist, rulingId) {
5135
+ const identity = parseRulingIdentity(rulingId);
5136
+ if (identity === null)
5137
+ return null;
5138
+ const matches = comments.filter((c) => {
5139
+ if (!isPrincipal(c.author, allowlist))
5140
+ return false;
5141
+ const m = RULING_MARKER_ORDINAL.exec((c.body.split(`
5142
+ `)[0] ?? "").trim());
5143
+ return m !== null && Number.parseInt(m[1], 10) === identity.ordinal;
5144
+ });
5145
+ if (matches.length !== 1)
5146
+ return null;
5147
+ const body = matches[0].body;
5148
+ const idx = body.indexOf(`
5149
+ `);
5150
+ return idx === -1 ? "" : body.slice(idx + 1).trim();
5151
+ }
5152
+
5153
+ // ../../packages/aeg-core/src/review-input-manifest.ts
5154
+ function pauseBoundRulingDigest(rulingText) {
5155
+ return createHash4("sha256").update(rulingText).digest("hex");
5156
+ }
4650
5157
  function briefHash(brief) {
4651
5158
  return createHash4("sha256").update(`${brief}
4652
5159
  `).digest("hex");
@@ -4707,14 +5214,19 @@ function compareManifest(echoed, current, patchIdOf) {
4707
5214
  const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
4708
5215
  const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
4709
5216
  const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
5217
+ const legacyCurrent = current.manifestVersion === undefined;
5218
+ const manifestVersion = legacyCurrent ? echoed.manifestVersion === undefined || echoed.manifestVersion === null : echoed.manifestVersion === current.manifestVersion;
5219
+ const pauseBoundRuling = legacyCurrent ? true : Object.hasOwn(echoed, "pauseBoundRuling") && JSON.stringify(echoed.pauseBoundRuling) === JSON.stringify(current.pauseBoundRuling);
4710
5220
  const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
4711
5221
  return {
4712
- bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
5222
+ bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && pauseBoundRuling && manifestVersion && policyDigestBound,
4713
5223
  head,
4714
5224
  base,
4715
5225
  briefHash: briefHashBound,
4716
5226
  objectivesVersion,
4717
5227
  rulingOrdinal,
5228
+ pauseBoundRuling,
5229
+ manifestVersion,
4718
5230
  policyDigest: policyDigestBound
4719
5231
  };
4720
5232
  }
@@ -4769,27 +5281,33 @@ function checkReviewGate(input) {
4769
5281
  const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
4770
5282
  const securityClean = securityTextClean && securityPolicyClean;
4771
5283
  const currentManifest = {
5284
+ ...input.manifestVersion === undefined ? {} : { manifestVersion: input.manifestVersion },
4772
5285
  headSha: input.headSha,
4773
5286
  baseSha: input.baseSha ?? null,
4774
5287
  briefHash: input.briefHash ?? null,
4775
5288
  objectivesVersion: input.objectivesVersion,
4776
5289
  rulingOrdinal: input.rulingOrdinal,
5290
+ pauseBoundRuling: input.pauseBoundRuling ?? null,
4777
5291
  policyDigest: policyDigest(policy)
4778
5292
  };
4779
5293
  const codeReviewEchoed = {
5294
+ manifestVersion: codeReview.manifestVersion,
4780
5295
  headSha: codeReview.headSha,
4781
5296
  baseSha: codeReview.baseSha,
4782
5297
  briefHash: codeReview.briefHash,
4783
5298
  objectivesVersion: codeReview.objectivesVersion,
4784
5299
  rulingOrdinal: codeReview.rulingOrdinal,
5300
+ pauseBoundRuling: codeReview.pauseBoundRuling,
4785
5301
  policyDigest: codeReview.policyDigest
4786
5302
  };
4787
5303
  const securityEchoed = {
5304
+ manifestVersion: security.manifestVersion,
4788
5305
  headSha: security.headSha,
4789
5306
  baseSha: security.baseSha,
4790
5307
  briefHash: security.briefHash,
4791
5308
  objectivesVersion: security.objectivesVersion,
4792
5309
  rulingOrdinal: security.rulingOrdinal,
5310
+ pauseBoundRuling: security.pauseBoundRuling,
4793
5311
  policyDigest: security.policyDigest
4794
5312
  };
4795
5313
  const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
@@ -4828,6 +5346,10 @@ function checkReviewGate(input) {
4828
5346
  problems.push(`the newest code-review verdict was cast against brief hash ${codeReview.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
4829
5347
  } else if (!codeReviewBinding.policyDigest) {
4830
5348
  problems.push(`the newest code-review verdict was cast against review policy digest ${codeReview.policyDigest ?? "none"}, this repository's current policy digest is ${currentManifest.policyDigest}`);
5349
+ } else if (!codeReviewBinding.manifestVersion) {
5350
+ problems.push(`the newest code-review verdict echoes manifest version ${codeReview.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
5351
+ } else if (!codeReviewBinding.pauseBoundRuling) {
5352
+ problems.push(`the newest code-review verdict echoes pauseBoundRuling ${renderBinding(codeReview.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
4831
5353
  }
4832
5354
  if (!securityTextClean) {
4833
5355
  problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
@@ -4845,6 +5367,10 @@ function checkReviewGate(input) {
4845
5367
  problems.push(`the newest security-review verdict was cast against brief hash ${security.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
4846
5368
  } else if (!securityBinding.policyDigest) {
4847
5369
  problems.push(`the newest security-review verdict was cast against review policy digest ${security.policyDigest ?? "none"}, this repository's current policy digest is ${currentManifest.policyDigest}`);
5370
+ } else if (!securityBinding.manifestVersion) {
5371
+ problems.push(`the newest security-review verdict echoes manifest version ${security.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
5372
+ } else if (!securityBinding.pauseBoundRuling) {
5373
+ problems.push(`the newest security-review verdict echoes pauseBoundRuling ${renderBinding(security.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
4848
5374
  }
4849
5375
  const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
4850
5376
  return {
@@ -4853,29 +5379,16 @@ function checkReviewGate(input) {
4853
5379
  waived: false
4854
5380
  };
4855
5381
  }
5382
+ function renderBinding(binding) {
5383
+ if (binding === undefined)
5384
+ return "(absent)";
5385
+ return binding === null ? "(none)" : `${binding.rulingId}|${binding.pauseId}|${binding.contentDigest}`;
5386
+ }
4856
5387
  var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
4857
5388
  var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
4858
5389
  function isChangesetsReleasePr(branch, author, expectedAuthor) {
4859
5390
  return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
4860
5391
  }
4861
- // ../../packages/aeg-core/src/ruling-ordinal.ts
4862
- var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
4863
- function newestPrincipalRulingOrdinal(comments, allowlist) {
4864
- let best = 0;
4865
- for (const c of comments) {
4866
- if (!isPrincipal(c.author, allowlist))
4867
- continue;
4868
- const firstLine = (c.body.split(`
4869
- `)[0] ?? "").trim();
4870
- const m = RULING_MARKER_ORDINAL.exec(firstLine);
4871
- if (!m)
4872
- continue;
4873
- const k = Number.parseInt(m[1], 10);
4874
- if (k > best)
4875
- best = k;
4876
- }
4877
- return best;
4878
- }
4879
5392
  // ../../packages/aeg-core/src/markdown-table.ts
4880
5393
  function splitRow(line) {
4881
5394
  const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
@@ -5251,72 +5764,10 @@ function compareToBaseline(current, baseline) {
5251
5764
  };
5252
5765
  }
5253
5766
  // ../../packages/aeg-core/src/retired-vocabulary.ts
5254
- var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
5255
- var RETIRED_PATTERNS = [
5256
- String.raw`\bD-[0-9]{3}\b`,
5257
- "D-(###|NNN|nnn|xxx)",
5258
- "decision (entry|logged)",
5259
- "decision-log entry",
5260
- "decision log entry",
5261
- "decision log(s|ged|ging)?([^a-z]|$)",
5262
- "decision-log",
5263
- "decision entr",
5264
- "decisions? (are |is )?logged",
5265
- "log entries",
5266
- String.raw`decisions\.md`,
5267
- "decisions-legacy",
5268
- "CONTRADICTION",
5269
- "assumes Tier 3",
5270
- "Lock: ?YES",
5271
- "Lock: ?NO",
5272
- "lock approvals?",
5273
- "approves locks",
5274
- "Conforms to lock",
5275
- "Challenges lock",
5276
- "checkDecisionNumbersFresh",
5277
- String.raw`roles/team-leader\.md`,
5278
- String.raw`\(,`,
5279
- String.raw`,\)`,
5280
- String.raw`\(\.\)`,
5281
- ...PLAN_ON_DISK_PATTERNS
5282
- ];
5283
- var TRANCHE_MODEL_FILE = "/tranche-model.md";
5284
- var RETIRED_EXEMPT_SUBSTRINGS = [
5285
- "docs/decisions-legacy.md",
5286
- "apps/herald-ai/docs/",
5287
- "apps/vada-ai/docs/",
5288
- "aeg-root/tranches/completed/",
5289
- "packages/aeg-core/src/docs/published-prose",
5290
- "packages/aeg-core/src/retired-vocabulary.test.ts",
5291
- "packages/aeg-core/src/retired-vocabulary.ts",
5292
- "/fixtures/",
5293
- "/node_modules/",
5294
- "/.next/",
5295
- "/.turbo/"
5296
- ];
5297
- var PATTERN_EXEMPT = {
5298
- [String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
5299
- [String.raw`decisions\.md`]: [
5300
- "docs-index.md",
5301
- "apps/vada-ai/specs/legacy/README.md",
5302
- "apps/vada-ai/specs/vada-product-spec.md",
5303
- "apps/vada-ai/web/CLAUDE.md",
5304
- "apps/vada-ai/CLAUDE.md"
5305
- ],
5306
- "decisions-legacy": [
5307
- "packages/aeg-core/src/file-classify.ts",
5308
- "packages/aeg-core/src/file-classify.test.ts",
5309
- "packages/aeg-core/src/pr-tier.test.ts",
5310
- "docs-index.md",
5311
- ".claude/skills/database/SKILL.md",
5312
- ".claude/skills/vada-architecture/SKILL.md",
5313
- "apps/vada-ai/specs/vada-byok-principles.md",
5314
- "apps/vada-ai/web/CLAUDE.md",
5315
- "apps/vada-ai/CLAUDE.md"
5316
- ],
5317
- CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
5318
- ...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
5319
- };
5767
+ var retiredRules = rulesForGroup("retired-vocabulary");
5768
+ var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
5769
+ var PATTERN_EXEMPT = RETIRED_PATTERN_EXEMPTIONS;
5770
+ var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
5320
5771
  function lineNumbers(content, pattern) {
5321
5772
  const out = [];
5322
5773
  const lines = content.split(`
@@ -5327,22 +5778,29 @@ function lineNumbers(content, pattern) {
5327
5778
  }
5328
5779
  return out;
5329
5780
  }
5330
- function scanRetiredVocabulary(files) {
5781
+ function scanRetiredVocabulary(files, rules = DEFAULT_PROSE_RULE_SET) {
5331
5782
  const findings = [];
5783
+ const retired = rulesOfGroup(rules, "retired-vocabulary");
5332
5784
  for (const file of files) {
5333
- if (RETIRED_EXEMPT_SUBSTRINGS.some((e) => file.path.includes(e)))
5334
- continue;
5335
- for (const pattern of RETIRED_PATTERNS) {
5336
- const patternExempt = PATTERN_EXEMPT[pattern] ?? [];
5337
- if (patternExempt.some((e) => file.path.includes(e)))
5785
+ for (const rule of retired) {
5786
+ if (rule.substringExempt.some((e) => file.path.includes(e)))
5787
+ continue;
5788
+ if (!ruleReads(rules, rule, file.path))
5789
+ continue;
5790
+ const re = rule.patternFor("repository");
5791
+ if (!re)
5792
+ continue;
5793
+ const pattern = rule.custom ? re.source : DEFAULT_PATTERN_OF.get(rule.id) ?? re.source;
5794
+ if (!rule.custom && (PATTERN_EXEMPT[pattern] ?? []).some((e) => file.path.includes(e)))
5338
5795
  continue;
5339
- const re = new RegExp(pattern);
5340
5796
  for (const line of lineNumbers(file.content, re)) {
5341
5797
  findings.push({
5342
5798
  file: file.path,
5343
5799
  line,
5344
5800
  pattern,
5345
- message: `claims a retired AEG mechanism is still live (matches /${pattern}/)`
5801
+ message: rule.custom ? `${rule.id}: ${rule.message} (matches /${pattern}/)` : `claims a retired AEG mechanism is still live (matches /${pattern}/)`,
5802
+ rule: rule.id,
5803
+ blocking: rule.severity.repository === "error"
5346
5804
  });
5347
5805
  }
5348
5806
  }
@@ -5764,8 +6222,61 @@ function decideIssueAssignment(input) {
5764
6222
  reason: `First push of \`${branch}\` — assigning Issue #${issue} to @${login} (the authenticated pusher).`
5765
6223
  };
5766
6224
  }
6225
+ // ../../packages/aeg-core/src/live-record.ts
6226
+ var RECORD_LINE_RE = /^-\s*\[([ xX])\]\s*\*\*\[live\]\*\*\s+(`+) ?(.+?) ?\2(?!`)\s+—\s+(passed|failed|unverified)\s+at\s+`([^`]+)`/;
6227
+ function liveMarkers(body) {
6228
+ const masked = maskCode(body);
6229
+ return [...masked.matchAll(/<!--\s*AEG:LIVE:(?:START|END)\s*-->/g)].map((m) => ({
6230
+ start: m.index,
6231
+ end: m.index + m[0].length
6232
+ }));
6233
+ }
6234
+ var AMBIGUOUS_RECORD_LINE = {
6235
+ line: "- [ ] **[live]** the pull request body carries more than one `AEG:LIVE` marker pair, so the driver's record cannot be told apart",
6236
+ ticked: false,
6237
+ command: "",
6238
+ outcome: "failed",
6239
+ head: ""
6240
+ };
6241
+ function readLiveRecord(body) {
6242
+ const markers = liveMarkers(body).length;
6243
+ if (markers === 0)
6244
+ return [];
6245
+ if (markers !== 2)
6246
+ return [AMBIGUOUS_RECORD_LINE];
6247
+ const region = anchoredRegion(body, "LIVE");
6248
+ if (region === null)
6249
+ return [];
6250
+ const lines = [];
6251
+ for (const raw of region.split(`
6252
+ `)) {
6253
+ const line = raw.trim();
6254
+ const m = RECORD_LINE_RE.exec(line);
6255
+ if (!m)
6256
+ continue;
6257
+ lines.push({
6258
+ line,
6259
+ ticked: m[1].toLowerCase() === "x",
6260
+ command: m[3],
6261
+ outcome: m[4],
6262
+ head: m[5]
6263
+ });
6264
+ }
6265
+ return lines;
6266
+ }
5767
6267
  // ../../packages/aeg-core/src/test-plan-gate.ts
5768
- function evaluateTestPlanGate(body, branch) {
6268
+ function gradedLiveLines(record, live) {
6269
+ if (live === undefined)
6270
+ return record.map((entry) => entry.line);
6271
+ const commands = new Set(live.liveCommands);
6272
+ const others = record.filter((entry) => !commands.has(entry.command)).map((entry) => entry.line);
6273
+ const graded = live.liveCommands.map((command) => {
6274
+ const atHead = record.filter((entry) => entry.command === command && entry.head === live.head);
6275
+ return (atHead.find((entry) => entry.ticked) ?? atHead[0])?.line ?? `- [ ] **[live]** \`${command}\` — no passed run recorded at \`${live.head || "an unknown head"}\``;
6276
+ });
6277
+ return [...others, ...graded];
6278
+ }
6279
+ function evaluateTestPlanGate(body, branch, live) {
5769
6280
  if (!body) {
5770
6281
  return {
5771
6282
  verdict: "pass",
@@ -5776,7 +6287,9 @@ function evaluateTestPlanGate(body, branch) {
5776
6287
  };
5777
6288
  }
5778
6289
  const located = locateTestPlanSection(body);
5779
- if (!located.found) {
6290
+ const liveLines = gradedLiveLines(readLiveRecord(body), live);
6291
+ const liveUnticked = liveLines.some((line) => /^[-*]\s+\[\s\]/.test(line));
6292
+ if (!located.found && !liveUnticked) {
5780
6293
  if (parseTaskBranchIdentity(branch) !== null) {
5781
6294
  return {
5782
6295
  verdict: "fail",
@@ -5796,15 +6309,18 @@ function evaluateTestPlanGate(body, branch) {
5796
6309
  ]
5797
6310
  };
5798
6311
  }
5799
- const section = located.section;
5800
- if (/unit-tests-only/i.test(section)) {
6312
+ const section = located.found ? located.section : "";
6313
+ if (/unit-tests-only/i.test(section) && !liveUnticked) {
5801
6314
  return {
5802
6315
  verdict: "pass",
5803
6316
  messages: ["Test Plan: unit-tests-only — pure-logic brief, CI unit-tests are the proof.", "PASS."]
5804
6317
  };
5805
6318
  }
5806
- const checkboxLines = section.split(`
5807
- `).map((line) => line.trimStart()).filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line));
6319
+ const checkboxLines = [
6320
+ ...section.split(`
6321
+ `).map((line) => line.trimStart()).filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line)),
6322
+ ...liveLines
6323
+ ];
5808
6324
  if (checkboxLines.length === 0) {
5809
6325
  return {
5810
6326
  verdict: "pass",
@@ -5821,7 +6337,9 @@ function evaluateTestPlanGate(body, branch) {
5821
6337
  messages.push("", "FAIL — the following [principal] Test Plan items are unticked:");
5822
6338
  for (const line of unchecked)
5823
6339
  messages.push(` ${line}`);
5824
- messages.push("", "Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.", "The Principal runs the item in a real signed-in browser and ticks the box.", "Note: editing the PR body does not retrigger most workflows. If your PR body changes do not surface here, push an empty commit to re-run.");
6340
+ messages.push("", "Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.", "The Principal runs the item in a real signed-in browser and ticks the box.", ...liveUnticked ? [
6341
+ "An unticked [live] line is a live run that failed or that the review loop could not verify on its host: a later head re-runs it, or the Principal runs it and ticks the box."
6342
+ ] : [], "Note: editing the PR body does not retrigger most workflows. If your PR body changes do not surface here, push an empty commit to re-run.");
5825
6343
  return { verdict: "fail", messages };
5826
6344
  }
5827
6345
  messages.push("All [principal] Test Plan items ticked — runtime verification complete.", "PASS.");
@@ -6010,9 +6528,11 @@ var LineageSchema = z3.object({
6010
6528
  parent: z3.string().nullable()
6011
6529
  }).strict();
6012
6530
  var InputVersionsSchema = z3.object({
6531
+ manifest_version: z3.literal(2).nullable().optional(),
6013
6532
  objectives_version: z3.string().nullable(),
6014
6533
  brief_hash: z3.string().nullable(),
6015
6534
  ruling_ordinal: z3.number().int().nullable(),
6535
+ pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
6016
6536
  policy_digest: z3.string().nullable()
6017
6537
  }).strict();
6018
6538
  var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
@@ -6560,9 +7080,11 @@ function buildHeader(input) {
6560
7080
  parent: lineageFieldFromEnv(input.env.parent)
6561
7081
  },
6562
7082
  input_versions: {
7083
+ manifest_version: input.inputVersions?.manifestVersion ?? null,
6563
7084
  objectives_version: input.inputVersions?.objectivesVersion ?? null,
6564
7085
  brief_hash: input.inputVersions?.briefHash ?? null,
6565
7086
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
7087
+ pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
6566
7088
  policy_digest: input.inputVersions?.policyDigest ?? null
6567
7089
  },
6568
7090
  provenance: provenanceFor(input),
@@ -6758,6 +7280,12 @@ var ManifestRecordSchema = z4.object({
6758
7280
  briefHash: z4.string().min(1).nullable(),
6759
7281
  objectivesVersion: z4.string().min(1).nullable(),
6760
7282
  rulingOrdinal: epochNumber,
7283
+ manifestVersion: z4.literal(2).optional(),
7284
+ pauseBoundRuling: z4.object({
7285
+ rulingId: z4.string().min(1),
7286
+ pauseId: z4.string().min(1),
7287
+ contentDigest: z4.string().min(1)
7288
+ }).strict().nullable().optional(),
6761
7289
  policyDigest: z4.string().min(1),
6762
7290
  recordedAt: isoTimestamp
6763
7291
  }).strict();
@@ -6779,7 +7307,11 @@ var LoopStateRecordSchema = z4.object({
6779
7307
  deliveredFindings: roundHeadIdentity.nullable(),
6780
7308
  repeatMemory: z4.object({
6781
7309
  blockingFindings: z4.array(z4.string()),
6782
- lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
7310
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
7311
+ }).strict().optional(),
7312
+ developerHandoff: z4.object({
7313
+ findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
7314
+ failingChecks: z4.array(z4.string().min(1))
6783
7315
  }).strict().optional(),
6784
7316
  publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
6785
7317
  taskStartedAt: isoTimestamp.optional(),
@@ -6950,6 +7482,16 @@ var COMMANDS = [
6950
7482
  ],
6951
7483
  status: "shipped"
6952
7484
  },
7485
+ {
7486
+ name: "new adr",
7487
+ needs: [],
7488
+ description: "Write the next numbered decision record into the folder decisionRecords.path names",
7489
+ details: [
7490
+ "`vinaya new adr <title>` writes `<decisionRecords.path>/NNNN-<kebab-title>.md` from the shipped decision-record template (`vinaya doctrine --template decision-record`), with status Proposed and today's date, and adds a row for it to the folder's `README.md` index page, creating that page on the first record. Numbers start at `0001` and are one past the highest number any file in the folder or any row of the index carries, so a number is never reused, even after its file is removed.",
7491
+ "Refuses, naming the key, while `decisionRecords.path` is unset: decision records are opt-in. The same key switches on the `decision-record-citation` writing rule — see `decisionRecords.path` in the configuration reference."
7492
+ ],
7493
+ status: "shipped"
7494
+ },
6953
7495
  {
6954
7496
  name: "brief render",
6955
7497
  needs: ["forge", "default-branch"],