@attalabs/vinaya 0.39.0 → 0.41.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 (186) hide show
  1. package/README.md +9 -9
  2. package/aeg-root/contracts/developer-reviewer.md +2 -2
  3. package/aeg-root/contracts/planner-developer.md +5 -5
  4. package/aeg-root/enforcement.md +22 -22
  5. package/aeg-root/process.md +4 -4
  6. package/aeg-root/roles/archivist.md +1 -1
  7. package/aeg-root/roles/developer/reference.md +7 -1
  8. package/aeg-root/roles/developer.md +1 -1
  9. package/aeg-root/roles/planner/reference.md +18 -5
  10. package/aeg-root/roles/principal.md +1 -1
  11. package/aeg-root/roles/reviewer.md +3 -3
  12. package/aeg-root/roles/security.md +4 -4
  13. package/aeg-root/roles/tranche-archivist.md +2 -2
  14. package/aeg-root/skills/aeg/SKILL.md +1 -1
  15. package/aeg-root/state-machine.md +10 -15
  16. package/aeg-root/templates/brief-template.md +5 -2
  17. package/aeg-root/templates/decision-record-template.md +38 -0
  18. package/aeg-root/templates/issue-rationale-template.md +1 -1
  19. package/aeg-root/tranche-model.md +1 -1
  20. package/dist/checks/bin/check-body-bare-digits.js +1974 -354
  21. package/dist/checks/bin/check-branch-topology.js +1296 -243
  22. package/dist/checks/bin/check-brief-shape.js +2038 -460
  23. package/dist/checks/bin/check-changeset-coverage.js +2411 -564
  24. package/dist/checks/bin/check-ci-shard-coverage.js +12391 -15
  25. package/dist/checks/bin/check-closes-n.js +1296 -243
  26. package/dist/checks/bin/check-coherence.js +1914 -1155
  27. package/dist/checks/bin/check-dead-branch-push.js +1242 -230
  28. package/dist/checks/bin/check-dispatch-readiness.js +2222 -460
  29. package/dist/checks/bin/check-doc-claims.js +2233 -260
  30. package/dist/checks/bin/check-doc-coverage-push.js +2436 -550
  31. package/dist/checks/bin/check-doc-coverage.js +2434 -552
  32. package/dist/checks/bin/check-doctrine-no-procedures.js +1776 -353
  33. package/dist/checks/bin/check-doctrine-portability.js +2408 -561
  34. package/dist/checks/bin/check-evidence-fresh.js +2370 -508
  35. package/dist/checks/bin/check-exec-bits.js +2407 -560
  36. package/dist/checks/bin/check-first-push-dispatch.js +1984 -380
  37. package/dist/checks/bin/check-issue-assignment.js +712 -170
  38. package/dist/checks/bin/check-issue-milestone-attach.js +1233 -230
  39. package/dist/checks/bin/check-issue-objectives-numbering.js +1769 -346
  40. package/dist/checks/bin/check-issue-parts-coverage.js +1233 -230
  41. package/dist/checks/bin/check-issue-surface-globs.js +1926 -378
  42. package/dist/checks/bin/check-issue-title-grammar.js +1233 -230
  43. package/dist/checks/bin/check-issue-tranche-label.js +702 -170
  44. package/dist/checks/bin/check-main-branch-refusal.js +1245 -232
  45. package/dist/checks/bin/check-no-disk-state.js +1233 -230
  46. package/dist/checks/bin/check-pr-premise-reassert.js +1769 -346
  47. package/dist/checks/bin/check-pr-report-density.js +1233 -230
  48. package/dist/checks/bin/check-principal-test-plan-wait.js +2489 -259
  49. package/dist/checks/bin/check-quoted-command.js +2391 -544
  50. package/dist/checks/bin/check-reader-resolvable-prose.js +2437 -564
  51. package/dist/checks/bin/check-registry-gates.js +1380 -296
  52. package/dist/checks/bin/check-retired-vocabulary.js +2416 -550
  53. package/dist/checks/bin/check-review-gate.js +2073 -371
  54. package/dist/checks/bin/check-single-plan-pr.js +1297 -235
  55. package/dist/checks/bin/check-surface-scope.js +1531 -252
  56. package/dist/checks/bin/check-test-plan.js +2487 -258
  57. package/dist/checks/bin/check-token-collection-wired.js +1233 -230
  58. package/dist/checks/bin/check-workspace-escape.js +2408 -561
  59. package/dist/checks/bin/verify-coherence.js +597 -97
  60. package/dist/checks/bin/verify-dispatch.js +632 -152
  61. package/dist/checks/bin/verify-docs.js +642 -132
  62. package/dist/index.js +25948 -16630
  63. package/dist/lib/pre-push-cache-test-run.js +1813 -297
  64. package/dist/lib/pre-push-changed-files.js +65 -19
  65. package/dist/lib/pre-push-mode.js +466 -0
  66. package/dist/lib/pre-push-progress-dir.js +4205 -0
  67. package/dist/lib/pre-push-record-tests.js +446 -0
  68. package/dist/lib/pre-push-select-tests.js +2353 -632
  69. package/dist/lib/push-progress-observer.js +4213 -0
  70. package/package.json +22 -5
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +17 -3
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +73 -30
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +3 -3
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +2 -2
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +88 -5
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +34 -2
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +26 -4
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +7 -1
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +29 -3
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +35 -18
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +1 -1
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +70 -45
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -1
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/entry-point.ts +27 -0
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +3 -5
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +96 -9
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +24 -54
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +809 -106
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/live-record.ts +179 -0
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +8 -2
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +1 -0
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +2 -0
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema-digest.ts +225 -0
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +7 -1
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +23 -1
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +6 -4
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/principals-config.ts +44 -0
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/prose-rules.ts +532 -0
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/protected-paths.ts +31 -0
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +157 -80
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +8 -12
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +53 -93
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +46 -17
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +85 -1
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +32 -13
  107. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +46 -0
  108. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +2 -4
  109. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +63 -8
  110. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +24 -0
  111. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +0 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  114. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +2 -2
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  156. 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
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0sxadt2._.js +13 -0
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +57 -0
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1ug9syi._.js → [root-of-the-server]__1d4eth3._.js} +1 -1
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +3 -3
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +2 -2
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +3 -3
  171. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  172. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  173. 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
  174. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  175. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  176. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  177. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  178. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{33rszkngkuoko.js → 0x7u6si-ai179.js} +1 -1
  179. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{06_55xbp7rcbi.js → 2fu7mfsj4oima.js} +1 -1
  180. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2brkwv169ygep.js → 34b4ruddunn3q.js} +1 -1
  181. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  182. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +0 -57
  183. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +0 -13
  184. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_buildManifest.js +0 -0
  185. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_clientMiddlewareManifest.js +0 -0
  186. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_ssgManifest.js +0 -0
@@ -44,11 +44,13 @@ export type ProseFinding = {
44
44
  line: number
45
45
  message: string
46
46
  blocking: boolean
47
+ /** The id of the rule that matched. */
48
+ rule: string
47
49
  }
48
50
 
49
51
  /**
50
- * Path prefixes under which a tranche-slug citation in product code is a
51
- * blocking finding — copied verbatim (aeg-root dropped) from the scope list
52
+ * The default of `proseGates.productPaths`: path prefixes under which a
53
+ * tranche-slug citation in product code is a blocking finding — copied verbatim (aeg-root dropped) from the scope list
52
54
  * `retired-vocabulary.test.ts`'s `PATTERN_SCOPE[TRANCHE_SLUG_VN_PATTERN]` used
53
55
  * to grep directly; that suite no longer greps these paths itself
54
56
  * (`prose-product-scope.test.ts` pins this list against drift instead).
@@ -66,8 +68,8 @@ function isUnderOrEqual(path: string, prefix: string): boolean {
66
68
  return path === prefix || path.startsWith(`${prefix}/`)
67
69
  }
68
70
 
69
- function isProductScopeFile(path: string): boolean {
70
- return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix))
71
+ function isProductScopeFile(path: string, productPaths: readonly string[]): boolean {
72
+ return productPaths.some((prefix) => isUnderOrEqual(path, normalizeRepoPath(prefix)))
71
73
  }
72
74
 
73
75
  /**
@@ -112,11 +114,7 @@ export const DEFAULT_SPEC_PATHS: readonly string[] = ['SPEC.md', 'CONTEXT.md', '
112
114
  * spelling.
113
115
  */
114
116
  export function normalizeSpecPath(entry: string): string {
115
- let out = entry.replace(/\\/g, '/')
116
- while (out.startsWith('./')) out = out.slice(2)
117
- out = out.replace(/\/{2,}/g, '/')
118
- while (out.endsWith('/')) out = out.slice(0, -1)
119
- return out
117
+ return normalizeRepoPath(entry)
120
118
  }
121
119
 
122
120
  /**
@@ -169,13 +167,17 @@ function isClaudeMdFile(path: string): boolean {
169
167
  * root context document and decision records read. A caller adding
170
168
  * configured paths passes the defaults alongside them; this parameter is the
171
169
  * whole set, never a delta.
170
+ *
171
+ * `productPaths` is the product class's file set — `PRODUCT_SLUG_SCOPE`
172
+ * unless `proseGates.productPaths` replaces it.
172
173
  */
173
174
  export function classifyProseFile(
174
175
  path: string,
175
176
  readerFacingPrefix: string,
176
177
  readerFacingSuffix: string,
177
178
  shipsPrefix: string = SHIPS_PREFIX,
178
- specPaths: readonly string[] = DEFAULT_SPEC_PATHS
179
+ specPaths: readonly string[] = DEFAULT_SPEC_PATHS,
180
+ productPaths: readonly string[] = PRODUCT_SLUG_SCOPE
179
181
  ): ProseFileClass | null {
180
182
  if (path.startsWith(shipsPrefix)) {
181
183
  return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? 'internal' : 'ships'
@@ -185,7 +187,7 @@ export function classifyProseFile(
185
187
  }
186
188
  if (isClaudeMdFile(path)) return 'internal'
187
189
  if (isSpecFile(path, specPaths)) return 'spec'
188
- if (isProductScopeFile(path)) return 'product'
190
+ if (isProductScopeFile(path, productPaths)) return 'product'
189
191
  return null
190
192
  }
191
193
 
@@ -242,10 +244,27 @@ function lineAt(content: string, index: number): number {
242
244
  }
243
245
 
244
246
  /** `#NNN`-shaped — a PR/Issue number cited bare, resolvable only inside this repo's own tracker. */
245
- export const FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g
247
+ import {
248
+ DEFAULT_PROSE_RULE_SET,
249
+ normalizeRepoPath,
250
+ type ProseRuleSet,
251
+ type ResolvedProseRule,
252
+ ruleReads,
253
+ rulesForGroup,
254
+ rulesInScope
255
+ } from './prose-rules'
256
+
257
+ const readerRules = rulesForGroup('reader-resolvable')
258
+ const readerPattern = (id: string, scope = 'prose'): RegExp => {
259
+ const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope]
260
+ if (!(pattern instanceof RegExp)) throw new Error(`default prose rule ${id} has no ${scope} pattern`)
261
+ return pattern
262
+ }
263
+
264
+ export const FORGE_NUMBER_PATTERN = readerPattern('forge-number')
246
265
 
247
266
  /** `example-tranche-vN`-shaped — an internal tranche slug ending `-vN`. */
248
- export const TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g
267
+ export const TRANCHE_SLUG_VN_PATTERN = readerPattern('tranche-slug')
249
268
 
250
269
  /**
251
270
  * `task 4`/`tasks 12`/`task #4`-shaped — a task's number out of a plan, which
@@ -263,7 +282,7 @@ export const TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g
263
282
  * citation itself — the caller reports group 2, so the boundary character
264
283
  * never leaks into a finding's message.
265
284
  */
266
- export const TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi
285
+ export const TASK_NUMBER_PATTERN = readerPattern('task-number')
267
286
 
268
287
  /**
269
288
  * Builds the legacy-slug pattern from the real archived-tranche filenames
@@ -308,6 +327,55 @@ export function specGrandfatherPaths(specGrandfather: SpecGrandfather): string[]
308
327
  return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather)
309
328
  }
310
329
 
330
+ /**
331
+ * Options every sweep below accepts as its last parameter. `rules` is the
332
+ * resolved rule set (`resolveProseRules`) — the shipped defaults unless the
333
+ * repository configured `proseGates.rules`; `productPaths` replaces
334
+ * `PRODUCT_SLUG_SCOPE` as the product class's file set.
335
+ */
336
+ export type ProseSweepOptions = {
337
+ rules?: ProseRuleSet
338
+ productPaths?: readonly string[]
339
+ }
340
+
341
+ /** The file classes the reference sweep reads, each the scope of the same name. */
342
+ const REFERENCE_CLASSES: ReadonlySet<ProseFileClass> = new Set(['ships', 'reader-facing', 'product', 'spec'])
343
+
344
+ /** The reference rules for one file class, in run order: every pattern rule whose scopes name the class, plus the built-in legacy-slug rule. */
345
+ function referenceRulesFor(set: ProseRuleSet, cls: ProseFileClass): readonly ResolvedProseRule[] {
346
+ return rulesInScope(set, cls).filter((rule) => rule.group === 'reader-resolvable' && rule.id !== 'coined-term')
347
+ }
348
+
349
+ /**
350
+ * Every match of `pattern` in `text`, with the cited text and its offset. A
351
+ * configured pattern that matches the empty string advances past it and
352
+ * reports nothing, so a careless rule can never loop forever.
353
+ */
354
+ function citations(pattern: RegExp, text: string, group?: number): { cited: string; index: number }[] {
355
+ const out: { cited: string; index: number }[] = []
356
+ const re = pattern.global ? pattern : new RegExp(pattern.source, `${pattern.flags}g`)
357
+ re.lastIndex = 0
358
+ let match: RegExpExecArray | null = re.exec(text)
359
+ while (match !== null) {
360
+ if (match[0] === '') {
361
+ re.lastIndex++
362
+ } else {
363
+ const cited = group !== undefined ? (match[group] ?? match[0]) : match[0]
364
+ // The cited text's own offset, not the whole match's — see the line
365
+ // computation in `checkUnresolvableReferences`.
366
+ out.push({ cited, index: match.index + match[0].indexOf(cited) })
367
+ }
368
+ match = re.exec(text)
369
+ }
370
+ re.lastIndex = 0
371
+ return out
372
+ }
373
+
374
+ /** A custom rule's finding text: its own id, the matched text, and its message. */
375
+ function customMessage(rule: ResolvedProseRule, cited: string): string {
376
+ return `${rule.id}: ${rule.message} ("${cited}")`
377
+ }
378
+
311
379
  export function checkUnresolvableReferences(
312
380
  files: readonly ProseSourceFile[],
313
381
  readerFacingPrefix: string,
@@ -315,43 +383,37 @@ export function checkUnresolvableReferences(
315
383
  legacySlugs: readonly string[] = [],
316
384
  shipsPrefix: string = SHIPS_PREFIX,
317
385
  specGrandfather: SpecGrandfather = [],
318
- specPaths: readonly string[] = DEFAULT_SPEC_PATHS
386
+ specPaths: readonly string[] = DEFAULT_SPEC_PATHS,
387
+ options: ProseSweepOptions = {}
319
388
  ): ProseFinding[] {
389
+ const set = options.rules ?? DEFAULT_PROSE_RULE_SET
390
+ const productPaths = options.productPaths ?? PRODUCT_SLUG_SCOPE
320
391
  const findings: ProseFinding[] = []
321
392
  const legacyPattern = legacySlugPattern(legacySlugs)
322
393
  const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? (specGrandfather as readonly string[]) : [])
323
394
  const limits = new Map<string, number>(
324
395
  Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather as Readonly<Record<string, number>>)
325
396
  )
326
- // `group` names the capture holding the actual cited text — the plain
327
- // patterns have none (report the whole match), the boundary-checked
328
- // legacy-slug pattern reports its group 2 so the boundary chars around it
329
- // never leak into the finding's message.
330
- const patterns: { pattern: RegExp; what: string; group?: number }[] = [
331
- { pattern: FORGE_NUMBER_PATTERN, what: 'a forge number' },
332
- { pattern: TRANCHE_SLUG_VN_PATTERN, what: 'an internal tranche slug' },
333
- ...(legacyPattern ? [{ pattern: legacyPattern, what: 'an internal tranche slug', group: 2 }] : [])
334
- ]
335
397
 
336
- const productPatterns: { pattern: RegExp; what: string; group?: number }[] = [
337
- { pattern: TRANCHE_SLUG_VN_PATTERN, what: 'an internal tranche slug in product code' }
338
- ]
339
-
340
- // A spec carries the doctrine-page patterns AND the task-number one: a
341
- // durable document that copies a plan's task numbers goes stale the moment
342
- // the plan is renumbered, which is the failure this class was widened for.
343
- // The doctrine pages themselves are deliberately left out of it — their own
398
+ // Which rules run in which class is the rule set's `scopes`: by default a
399
+ // doctrine page and a reader-facing page carry the forge-number,
400
+ // tranche-slug and legacy-slug rules; product code carries the
401
+ // tranche-slug rule alone; a spec carries all of those plus the
402
+ // task-number rule, since a durable document that copies a plan's task
403
+ // numbers goes stale the moment the plan is renumbered. The doctrine pages
404
+ // are deliberately left out of the task-number rule — their own
344
405
  // report-only sweep names a much larger standing backlog, and a rule that
345
406
  // blocks belongs where it can be satisfied file by file.
346
- const specPatterns: { pattern: RegExp; what: string; group?: number }[] = [
347
- ...patterns,
348
- { pattern: TASK_NUMBER_PATTERN, what: 'a task number', group: 2 }
349
- ]
350
-
351
407
  for (const file of files) {
352
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths)
353
- if (!cls || cls === 'internal') continue
354
- if (cls !== 'product' && cls !== 'spec' && !SWEPT_CLASSES.has(cls)) continue
408
+ const cls = classifyProseFile(
409
+ file.path,
410
+ readerFacingPrefix,
411
+ readerFacingSuffix,
412
+ shipsPrefix,
413
+ specPaths,
414
+ productPaths
415
+ )
416
+ if (!cls || !REFERENCE_CLASSES.has(cls)) continue
355
417
  // A spec explicitly listed by path is grandfathered stock (already
356
418
  // failing when this sweep was extended to specs) and is skipped
357
419
  // entirely, not merely down-graded: the list shrinks as each spec's
@@ -362,35 +424,31 @@ export function checkUnresolvableReferences(
362
424
  // source. A path listed with a number is not skipped: its findings are
363
425
  // counted below and reported only once they exceed that number.
364
426
  if (cls === 'spec' && grandfatheredWhole.has(file.path)) continue
365
- const blocking = cls === 'product' || cls === 'spec'
366
427
  const scrubbed =
367
428
  cls === 'product' ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content)
368
- // A spec is checked with the SAME rules a doctrine page is — the full
369
- // reference pattern set, never the narrower product-code list — plus the
370
- // task-number rule that applies to this class alone.
371
- const patternsToRun = cls === 'product' ? productPatterns : cls === 'spec' ? specPatterns : patterns
372
429
  const fileFindings: ProseFinding[] = []
373
- for (const { pattern, what, group } of patternsToRun) {
374
- pattern.lastIndex = 0
375
- let match: RegExpExecArray | null = pattern.exec(scrubbed)
376
- while (match !== null) {
377
- const cited = group !== undefined ? (match[group] ?? match[0]) : match[0]
430
+ for (const rule of referenceRulesFor(set, cls)) {
431
+ if (!ruleReads(set, rule, file.path)) continue
432
+ const pattern = !rule.custom && rule.id === 'legacy-batch-name' ? legacyPattern : rule.patternFor(cls)
433
+ if (!pattern) continue
434
+ const blocking = rule.severity[cls] === 'error'
435
+ // A product-code finding names its class in its own message.
436
+ const what = cls === 'product' ? `${rule.message} in product code` : rule.message
437
+ for (const { cited, index } of citations(pattern, scrubbed, rule.custom ? undefined : rule.reportGroup)) {
378
438
  // The line is the CITED text's own line, not the whole match's. A
379
439
  // boundary-checked pattern consumes the character before the
380
440
  // citation, and where that character is the newline ending the
381
441
  // previous line — a citation that opens a line — the match begins on
382
442
  // the previous line and a finding sent the reader there instead.
383
- // `indexOf` is exact for both shapes in use: the leading boundary is
384
- // one character that can never itself start the cited text, and an
385
- // empty boundary (start of file) resolves to offset zero.
386
- const citedIndex = match.index + match[0].indexOf(cited)
387
443
  fileFindings.push({
388
444
  file: file.path,
389
- line: lineAt(scrubbed, citedIndex),
390
- message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
391
- blocking
445
+ line: lineAt(scrubbed, index),
446
+ message: rule.custom
447
+ ? customMessage(rule, cited)
448
+ : `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
449
+ blocking,
450
+ rule: rule.id
392
451
  })
393
- match = pattern.exec(scrubbed)
394
452
  }
395
453
  }
396
454
  const limit = cls === 'spec' ? limits.get(file.path) : undefined
@@ -461,13 +519,27 @@ export function checkUndefinedVocabulary(
461
519
  glossaryTerms: readonly string[],
462
520
  readerFacingPrefix: string,
463
521
  readerFacingSuffix: string,
464
- shipsPrefix: string = SHIPS_PREFIX
522
+ shipsPrefix: string = SHIPS_PREFIX,
523
+ options: ProseSweepOptions = {}
465
524
  ): ProseFinding[] {
466
525
  const findings: ProseFinding[] = []
526
+ const set = options.rules ?? DEFAULT_PROSE_RULE_SET
527
+ // The built-in coined-term rule: switched off, it is absent from the set;
528
+ // narrowed, it reads only the classes its scopes still name.
529
+ const rule = set.rules.find((r) => !r.custom && r.id === 'coined-term')
530
+ if (!rule) return findings
467
531
 
468
532
  for (const file of files) {
469
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
470
- if (!cls || !SWEPT_CLASSES.has(cls)) continue
533
+ const cls = classifyProseFile(
534
+ file.path,
535
+ readerFacingPrefix,
536
+ readerFacingSuffix,
537
+ shipsPrefix,
538
+ DEFAULT_SPEC_PATHS,
539
+ options.productPaths
540
+ )
541
+ if (!cls || !SWEPT_CLASSES.has(cls) || !rule.scopes.includes(cls)) continue
542
+ if (!ruleReads(set, rule, file.path)) continue
471
543
  const scrubbed = stripNonProse(file.path, file.content)
472
544
 
473
545
  for (const term of glossaryTerms) {
@@ -478,7 +550,8 @@ export function checkUndefinedVocabulary(
478
550
  file: file.path,
479
551
  line,
480
552
  message: `uses coined term "${term}" without defining it inline or linking the glossary`,
481
- blocking: false
553
+ blocking: rule.severity[cls] === 'error',
554
+ rule: rule.id
482
555
  })
483
556
  }
484
557
  }
@@ -493,10 +566,10 @@ export function checkUndefinedVocabulary(
493
566
  * (`x-vN`) is still exactly the kind of internal citation a reader outside
494
567
  * this repo cannot resolve.
495
568
  */
496
- export const SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g
569
+ export const SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern('source-comment-tranche-slug', 'comment')
497
570
 
498
571
  /** `#NNN`-shaped, source-comment class — no upper digit-count bound (unlike `FORGE_NUMBER_PATTERN`'s `{2,4}`), since a forge's issue/PR numbering has no fixed ceiling. */
499
- export const SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g
572
+ export const SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern('source-comment-forge-number', 'comment')
500
573
 
501
574
  /**
502
575
  * The inverse of `stripNonProse`'s `.ts`/`.tsx` half: keeps ONLY the text
@@ -627,30 +700,32 @@ export function extractComments(path: string, content: string): string {
627
700
  */
628
701
  export function checkSourceComments(
629
702
  files: readonly ProseSourceFile[],
630
- allowlist: readonly string[] = []
703
+ allowlist: readonly string[] = [],
704
+ options: ProseSweepOptions = {}
631
705
  ): ProseFinding[] {
632
706
  const findings: ProseFinding[] = []
633
707
  const allowed = new Set(allowlist)
634
- const patterns: { pattern: RegExp; what: string }[] = [
635
- { pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: 'a tranche-slug citation' },
636
- { pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: 'a forge-number citation' }
637
- ]
708
+ const set = options.rules ?? DEFAULT_PROSE_RULE_SET
709
+ const rules = rulesInScope(set, 'source-comment').filter((rule) => rule.group === 'reader-resolvable')
638
710
 
639
711
  for (const file of files) {
640
712
  if (!file.path.endsWith('.ts')) continue
641
713
  if (allowed.has(file.path)) continue
642
714
  const comments = extractComments(file.path, file.content)
643
- for (const { pattern, what } of patterns) {
644
- pattern.lastIndex = 0
645
- let match: RegExpExecArray | null = pattern.exec(comments)
646
- while (match !== null) {
715
+ for (const rule of rules) {
716
+ if (!ruleReads(set, rule, file.path)) continue
717
+ const pattern = rule.patternFor('source-comment')
718
+ if (!pattern) continue
719
+ for (const { cited, index } of citations(pattern, comments)) {
647
720
  findings.push({
648
721
  file: file.path,
649
- line: lineAt(comments, match.index),
650
- message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
651
- blocking: false
722
+ line: lineAt(comments, index),
723
+ message: rule.custom
724
+ ? customMessage(rule, cited)
725
+ : `comment cites ${rule.message} ("${cited}") a reader outside this repo's tracker cannot resolve`,
726
+ blocking: rule.severity['source-comment'] === 'error',
727
+ rule: rule.id
652
728
  })
653
- match = pattern.exec(comments)
654
729
  }
655
730
  }
656
731
  }
@@ -666,7 +741,8 @@ export function checkReaderResolvableProse(
666
741
  legacySlugs: readonly string[] = [],
667
742
  shipsPrefix: string = SHIPS_PREFIX,
668
743
  specGrandfather: SpecGrandfather = [],
669
- specPaths: readonly string[] = DEFAULT_SPEC_PATHS
744
+ specPaths: readonly string[] = DEFAULT_SPEC_PATHS,
745
+ options: ProseSweepOptions = {}
670
746
  ): ProseFinding[] {
671
747
  return [
672
748
  ...checkUnresolvableReferences(
@@ -676,9 +752,10 @@ export function checkReaderResolvableProse(
676
752
  legacySlugs,
677
753
  shipsPrefix,
678
754
  specGrandfather,
679
- specPaths
755
+ specPaths,
756
+ options
680
757
  ),
681
- ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
758
+ ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix, options)
682
759
  ]
683
760
  }
684
761
 
@@ -144,16 +144,14 @@ const NON_GATE_BIN_NAMES: readonly string[] = NON_GATE_BINS
144
144
  * maintained rather than folded into `GATE_AUDIENCE`, because each would
145
145
  * break an existing invariant that map enforces:
146
146
  *
147
- * - `check-dead-branch-push.ts` / `check-issue-assignment.ts`: their aeg-core
148
- * twins (`check-push-target.ts`, `assign-task-issue.ts`) are genuinely NOT
149
- * the same mechanism, only a closely related one an existing row's own
150
- * prose already cross-references — `check-push-target.ts` is a lower-level
151
- * helper `dead-branch-push`'s row already names as `implementation` (a
152
- * single-purpose forge query, not a second copy of the check), and
153
- * `assign-task-issue.ts` WRITES the assignment `issue-assignment` only
154
- * verifies. `GATE_AUDIENCE`/`NON_GATE_BINS` correctly keep both classified
155
- * by what they actually do; forcing a `shippedAs` claim onto either to
156
- * satisfy G2 would misdescribe them.
147
+ * - `check-dead-branch-push.ts`: its aeg-core twin (`check-push-target.ts`)
148
+ * is genuinely NOT the same mechanism, only a closely related one an
149
+ * existing row's own prose already cross-references —
150
+ * `check-push-target.ts` is a lower-level helper `dead-branch-push`'s row
151
+ * already names as `implementation` (a single-purpose forge query, not a
152
+ * second copy of the check). `GATE_AUDIENCE` correctly keeps it classified
153
+ * by what it actually does; forcing a `shippedAs` claim onto it to satisfy
154
+ * G2 would misdescribe it.
157
155
  * - `check-closes-n.ts`: its twin, `verify-coherence.ts`, already ships as
158
156
  * `coherence` (ring 0) via `GATE_AUDIENCE` — but `closes-n` is ring 1
159
157
  * (`CLI_CHECK_RING`), and `ShippedGate` has exactly one `ring` per bin
@@ -169,8 +167,6 @@ const NON_GATE_BIN_NAMES: readonly string[] = NON_GATE_BINS
169
167
  const TWIN_CANDIDATE_EXCEPTIONS: Readonly<Record<string, string>> = {
170
168
  'apps/cli/src/checks/bin/check-dead-branch-push.ts':
171
169
  'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
172
- 'apps/cli/src/checks/bin/check-issue-assignment.ts':
173
- 'Ring 0 "A task branch\'s first push (Issue self-assignment)" (implementation: assign-task-issue.ts)',
174
170
  'apps/cli/src/checks/bin/check-closes-n.ts': 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
175
171
  }
176
172
 
@@ -37,93 +37,41 @@ export type VocabFinding = {
37
37
  line: number
38
38
  pattern: string
39
39
  message: string
40
+ /** The id of the rule that matched. */
41
+ rule: string
42
+ /** Whether the rule's severity for the `repository` scope is `error`. */
43
+ blocking: boolean
40
44
  }
41
45
 
46
+ import {
47
+ DEFAULT_PROSE_RULE_SET,
48
+ PLAN_ON_DISK_PATTERNS,
49
+ type ProseRuleSet,
50
+ RETIRED_GLOBAL_EXEMPTIONS,
51
+ RETIRED_PATTERN_EXEMPTIONS,
52
+ ruleReads,
53
+ rulesForGroup,
54
+ rulesOfGroup,
55
+ TRANCHE_MODEL_FILE
56
+ } from './prose-rules'
57
+
58
+ const retiredRules = rulesForGroup('retired-vocabulary')
59
+
60
+ export { PLAN_ON_DISK_PATTERNS, TRANCHE_MODEL_FILE }
61
+
42
62
  /** The retired mechanisms this scan bans as claims of current-ness — see the module header for what is deliberately NOT here. */
43
- export const RETIRED_PATTERNS: readonly string[] = [
44
- // the deleted decision-id format
45
- String.raw`\bD-[0-9]{3}\b`,
46
- 'D-(###|NNN|nnn|xxx)',
47
- // the retired record as a live, writable, required artifact, every
48
- // inflection but never "decision logic"
49
- 'decision (entry|logged)',
50
- 'decision-log entry',
51
- 'decision log entry',
52
- 'decision log(s|ged|ging)?([^a-z]|$)',
53
- 'decision-log',
54
- 'decision entr',
55
- 'decisions? (are |is )?logged',
56
- 'log entries',
57
- String.raw`decisions\.md`,
58
- 'decisions-legacy',
59
- 'CONTRADICTION',
60
- 'assumes Tier 3',
61
- // the lock
62
- 'Lock: ?YES',
63
- 'Lock: ?NO',
64
- 'lock approvals?',
65
- 'approves locks',
66
- 'Conforms to lock',
67
- 'Challenges lock',
68
- // checks deleted with the machinery
69
- 'checkDecisionNumbersFresh',
70
- // the role that no longer exists
71
- String.raw`roles/team-leader\.md`,
72
- // the wreckage a citation strip leaves when it deletes the contents of a
73
- // parenthetical and not the punctuation around it — the shape is banned,
74
- // not one instance of it. `()` is deliberately absent: it is an ordinary
75
- // function call, and banning it would make any TypeScript source unusable.
76
- String.raw`\(,`,
77
- String.raw`,\)`,
78
- String.raw`\(\.\)`
79
- ]
63
+ export const RETIRED_PATTERNS: readonly string[] = retiredRules.map((rule) => rule.patterns.repository as string)
80
64
 
81
65
  /** Paths where a retired-vocabulary mention is legitimate: frozen archives and historical records. Substring match, same as the vitest suite's own `EXEMPT`. */
82
- export const RETIRED_EXEMPT_SUBSTRINGS: readonly string[] = [
83
- 'docs/decisions-legacy.md',
84
- 'apps/herald-ai/docs/',
85
- 'apps/vada-ai/docs/',
86
- 'aeg-root/tranches/completed/',
87
- 'packages/aeg-core/src/docs/published-prose',
88
- 'packages/aeg-core/src/retired-vocabulary.test.ts',
89
- 'packages/aeg-core/src/retired-vocabulary.ts',
90
- '/fixtures/',
91
- '/node_modules/',
92
- '/.next/',
93
- '/.turbo/'
94
- ]
66
+ export const RETIRED_EXEMPT_SUBSTRINGS: readonly string[] = RETIRED_GLOBAL_EXEMPTIONS
95
67
 
96
- /**
97
- * Per-pattern exemptions on top of `RETIRED_EXEMPT_SUBSTRINGS`, for the
98
- * handful of patterns with a real, load-bearing false-positive shape (a
99
- * live doc that legitimately discusses the retired concept by name, or a
100
- * same-shaped live feature). Copied verbatim from `retired-vocabulary.test.ts`'s
101
- * `PATTERN_EXEMPT` — including entries for `apps/herald-ai`/`apps/vada-ai`
102
- * paths this repo does not carry, since a nonexistent path costs nothing to
103
- * keep and this module's whole point is not re-deriving the list.
104
- */
105
- export const PATTERN_EXEMPT: Readonly<Record<string, readonly string[]>> = {
106
- [String.raw`\bD-[0-9]{3}\b`]: ['./CLAUDE.md'],
107
- [String.raw`decisions\.md`]: [
108
- 'docs-index.md',
109
- 'apps/vada-ai/specs/legacy/README.md',
110
- 'apps/vada-ai/specs/vada-product-spec.md',
111
- 'apps/vada-ai/web/CLAUDE.md',
112
- 'apps/vada-ai/CLAUDE.md'
113
- ],
114
- 'decisions-legacy': [
115
- 'packages/aeg-core/src/file-classify.ts',
116
- 'packages/aeg-core/src/file-classify.test.ts',
117
- 'packages/aeg-core/src/pr-tier.test.ts',
118
- 'docs-index.md',
119
- '.claude/skills/database/SKILL.md',
120
- '.claude/skills/vada-architecture/SKILL.md',
121
- 'apps/vada-ai/specs/vada-byok-principles.md',
122
- 'apps/vada-ai/web/CLAUDE.md',
123
- 'apps/vada-ai/CLAUDE.md'
124
- ],
125
- CONTRADICTION: ['apps/vada-ai/specs/vada-reviewers-spec.md']
126
- }
68
+ /** Per-pattern exemptions on top of `RETIRED_EXEMPT_SUBSTRINGS`; the data lives in the shared rule module. */
69
+ export const PATTERN_EXEMPT: Readonly<Record<string, readonly string[]>> = RETIRED_PATTERN_EXEMPTIONS
70
+
71
+ /** Each retired default's pattern text as shipped, by id — what a finding quotes and `PATTERN_EXEMPT` is keyed by. */
72
+ const DEFAULT_PATTERN_OF: ReadonlyMap<string, string> = new Map(
73
+ retiredRules.map((rule) => [rule.id, rule.patterns.repository as string])
74
+ )
127
75
 
128
76
  function lineNumbers(content: string, pattern: RegExp): number[] {
129
77
  const out: number[] = []
@@ -135,26 +83,38 @@ function lineNumbers(content: string, pattern: RegExp): number[] {
135
83
  }
136
84
 
137
85
  /**
138
- * Sweeps `files` for `RETIRED_PATTERNS`, skipping any file whose path
139
- * contains a `RETIRED_EXEMPT_SUBSTRINGS` entry, or that pattern's own
140
- * `PATTERN_EXEMPT` entry. Matching is per-line, case-sensitive — the same
141
- * semantics `grep -E` (with no `-i`) gives the vitest suite this was
142
- * extracted from.
86
+ * Sweeps `files` for the retired group of `rules` — `RETIRED_PATTERNS` when
87
+ * nothing is configured. A default skips any file whose path contains one
88
+ * of its `RETIRED_EXEMPT_SUBSTRINGS` entries, or that pattern's own
89
+ * `PATTERN_EXEMPT` entry; every rule also skips the paths
90
+ * `proseGates.rules` exempts. Matching is per-line — case-sensitive for a
91
+ * default, the same semantics `grep -E` (with no `-i`) gives the vitest
92
+ * suite this was extracted from; a custom rule carries its own flags.
143
93
  */
144
- export function scanRetiredVocabulary(files: readonly VocabSourceFile[]): VocabFinding[] {
94
+ export function scanRetiredVocabulary(
95
+ files: readonly VocabSourceFile[],
96
+ rules: ProseRuleSet = DEFAULT_PROSE_RULE_SET
97
+ ): VocabFinding[] {
145
98
  const findings: VocabFinding[] = []
99
+ const retired = rulesOfGroup(rules, 'retired-vocabulary')
146
100
  for (const file of files) {
147
- if (RETIRED_EXEMPT_SUBSTRINGS.some((e) => file.path.includes(e))) continue
148
- for (const pattern of RETIRED_PATTERNS) {
149
- const patternExempt = PATTERN_EXEMPT[pattern] ?? []
150
- if (patternExempt.some((e) => file.path.includes(e))) continue
151
- const re = new RegExp(pattern)
101
+ for (const rule of retired) {
102
+ if (rule.substringExempt.some((e) => file.path.includes(e))) continue
103
+ if (!ruleReads(rules, rule, file.path)) continue
104
+ const re = rule.patternFor('repository')
105
+ if (!re) continue
106
+ const pattern = rule.custom ? re.source : (DEFAULT_PATTERN_OF.get(rule.id) ?? re.source)
107
+ if (!rule.custom && (PATTERN_EXEMPT[pattern] ?? []).some((e) => file.path.includes(e))) continue
152
108
  for (const line of lineNumbers(file.content, re)) {
153
109
  findings.push({
154
110
  file: file.path,
155
111
  line,
156
112
  pattern,
157
- message: `claims a retired AEG mechanism is still live (matches /${pattern}/)`
113
+ message: rule.custom
114
+ ? `${rule.id}: ${rule.message} (matches /${pattern}/)`
115
+ : `claims a retired AEG mechanism is still live (matches /${pattern}/)`,
116
+ rule: rule.id,
117
+ blocking: rule.severity.repository === 'error'
158
118
  })
159
119
  }
160
120
  }