@attalabs/vinaya 0.40.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 (157) hide show
  1. package/aeg-root/contracts/developer-reviewer.md +2 -2
  2. package/aeg-root/contracts/planner-developer.md +4 -4
  3. package/aeg-root/process.md +3 -3
  4. package/aeg-root/roles/developer/reference.md +3 -0
  5. package/aeg-root/state-machine.md +2 -2
  6. package/aeg-root/templates/brief-template.md +1 -1
  7. package/dist/checks/bin/check-body-bare-digits.js +165 -65
  8. package/dist/checks/bin/check-branch-topology.js +169 -60
  9. package/dist/checks/bin/check-brief-shape.js +165 -65
  10. package/dist/checks/bin/check-changeset-coverage.js +342 -122
  11. package/dist/checks/bin/check-ci-shard-coverage.js +384 -130
  12. package/dist/checks/bin/check-closes-n.js +169 -60
  13. package/dist/checks/bin/check-coherence.js +165 -65
  14. package/dist/checks/bin/check-dead-branch-push.js +142 -59
  15. package/dist/checks/bin/check-dispatch-readiness.js +211 -81
  16. package/dist/checks/bin/check-doc-claims.js +165 -65
  17. package/dist/checks/bin/check-doc-coverage-push.js +342 -122
  18. package/dist/checks/bin/check-doc-coverage.js +344 -124
  19. package/dist/checks/bin/check-doctrine-no-procedures.js +165 -65
  20. package/dist/checks/bin/check-doctrine-portability.js +342 -122
  21. package/dist/checks/bin/check-evidence-fresh.js +376 -129
  22. package/dist/checks/bin/check-exec-bits.js +342 -122
  23. package/dist/checks/bin/check-first-push-dispatch.js +208 -78
  24. package/dist/checks/bin/check-issue-milestone-attach.js +142 -59
  25. package/dist/checks/bin/check-issue-objectives-numbering.js +165 -65
  26. package/dist/checks/bin/check-issue-parts-coverage.js +142 -59
  27. package/dist/checks/bin/check-issue-surface-globs.js +218 -88
  28. package/dist/checks/bin/check-issue-title-grammar.js +142 -59
  29. package/dist/checks/bin/check-main-branch-refusal.js +142 -59
  30. package/dist/checks/bin/check-no-disk-state.js +142 -59
  31. package/dist/checks/bin/check-pr-premise-reassert.js +165 -65
  32. package/dist/checks/bin/check-pr-report-density.js +142 -59
  33. package/dist/checks/bin/check-principal-test-plan-wait.js +165 -65
  34. package/dist/checks/bin/check-quoted-command.js +338 -118
  35. package/dist/checks/bin/check-reader-resolvable-prose.js +338 -118
  36. package/dist/checks/bin/check-registry-gates.js +206 -78
  37. package/dist/checks/bin/check-retired-vocabulary.js +338 -118
  38. package/dist/checks/bin/check-review-gate.js +203 -83
  39. package/dist/checks/bin/check-single-plan-pr.js +142 -59
  40. package/dist/checks/bin/check-surface-scope.js +169 -60
  41. package/dist/checks/bin/check-test-plan.js +165 -65
  42. package/dist/checks/bin/check-token-collection-wired.js +142 -59
  43. package/dist/checks/bin/check-workspace-escape.js +340 -120
  44. package/dist/checks/bin/verify-coherence.js +153 -60
  45. package/dist/checks/bin/verify-dispatch.js +169 -69
  46. package/dist/checks/bin/verify-docs.js +142 -57
  47. package/dist/index.js +16280 -11764
  48. package/dist/lib/pre-push-cache-test-run.js +791 -68
  49. package/dist/lib/pre-push-changed-files.js +65 -19
  50. package/dist/lib/pre-push-mode.js +466 -0
  51. package/dist/lib/pre-push-progress-dir.js +4205 -0
  52. package/dist/lib/pre-push-record-tests.js +446 -0
  53. package/dist/lib/pre-push-select-tests.js +1426 -454
  54. package/dist/lib/push-progress-observer.js +4213 -0
  55. package/package.json +11 -5
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -2
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +18 -4
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +3 -3
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +2 -2
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +88 -5
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +34 -2
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +26 -4
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +7 -1
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +17 -2
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +13 -17
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +1 -1
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +70 -45
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +1 -4
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +77 -7
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +24 -54
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +221 -56
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/live-record.ts +179 -0
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +8 -2
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +1 -0
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +1 -0
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema-digest.ts +225 -0
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +7 -1
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +23 -1
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/principals-config.ts +44 -0
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/prose-rules.ts +532 -0
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/protected-paths.ts +31 -0
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +157 -80
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +8 -12
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +52 -109
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +46 -17
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +85 -1
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +46 -0
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +2 -4
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +63 -8
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +24 -0
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +0 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  95. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  130. 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
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1wzfiav._.js → [root-of-the-server]__1d4eth3._.js} +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +3 -3
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +2 -2
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +3 -3
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  146. 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
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  151. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{38kom-9c-oi65.js → 0x7u6si-ai179.js} +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1p3vr9qts86_b.js → 2fu7mfsj4oima.js} +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{21tunzmxjvm2a.js → 34b4ruddunn3q.js} +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  155. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_buildManifest.js +0 -0
  156. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_clientMiddlewareManifest.js +0 -0
  157. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 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,110 +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
 
42
- /**
43
- * The plan-on-disk layout the forge-native cutover retired: a plan is a
44
- * Milestone plus labeled Issues now, so a doctrine page naming the topology
45
- * file, its directory, or the per-project state directory as something a
46
- * reader writes or reads today is describing a mechanism that is gone.
47
- */
48
- export const PLAN_ON_DISK_PATTERNS: readonly string[] = ['[Tt]opology files?', 'aeg-root/tranches/', 'aeg-project/']
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'
49
57
 
50
- /** The retired mechanisms this scan bans as claims of current-ness — see the module header for what is deliberately NOT here. */
51
- export const RETIRED_PATTERNS: readonly string[] = [
52
- // the deleted decision-id format
53
- String.raw`\bD-[0-9]{3}\b`,
54
- 'D-(###|NNN|nnn|xxx)',
55
- // the retired record as a live, writable, required artifact, every
56
- // inflection but never "decision logic"
57
- 'decision (entry|logged)',
58
- 'decision-log entry',
59
- 'decision log entry',
60
- 'decision log(s|ged|ging)?([^a-z]|$)',
61
- 'decision-log',
62
- 'decision entr',
63
- 'decisions? (are |is )?logged',
64
- 'log entries',
65
- String.raw`decisions\.md`,
66
- 'decisions-legacy',
67
- 'CONTRADICTION',
68
- 'assumes Tier 3',
69
- // the lock
70
- 'Lock: ?YES',
71
- 'Lock: ?NO',
72
- 'lock approvals?',
73
- 'approves locks',
74
- 'Conforms to lock',
75
- 'Challenges lock',
76
- // checks deleted with the machinery
77
- 'checkDecisionNumbersFresh',
78
- // the role that no longer exists
79
- String.raw`roles/team-leader\.md`,
80
- // the wreckage a citation strip leaves when it deletes the contents of a
81
- // parenthetical and not the punctuation around it — the shape is banned,
82
- // not one instance of it. `()` is deliberately absent: it is an ordinary
83
- // function call, and banning it would make any TypeScript source unusable.
84
- String.raw`\(,`,
85
- String.raw`,\)`,
86
- String.raw`\(\.\)`,
87
- ...PLAN_ON_DISK_PATTERNS
88
- ]
58
+ const retiredRules = rulesForGroup('retired-vocabulary')
89
59
 
90
- /** The doctrine page that records the plan-on-disk layout's retirement — see `PATTERN_EXEMPT`. */
91
- export const TRANCHE_MODEL_FILE = '/tranche-model.md'
60
+ export { PLAN_ON_DISK_PATTERNS, TRANCHE_MODEL_FILE }
61
+
62
+ /** The retired mechanisms this scan bans as claims of current-ness — see the module header for what is deliberately NOT here. */
63
+ export const RETIRED_PATTERNS: readonly string[] = retiredRules.map((rule) => rule.patterns.repository as string)
92
64
 
93
65
  /** Paths where a retired-vocabulary mention is legitimate: frozen archives and historical records. Substring match, same as the vitest suite's own `EXEMPT`. */
94
- export const RETIRED_EXEMPT_SUBSTRINGS: readonly string[] = [
95
- 'docs/decisions-legacy.md',
96
- 'apps/herald-ai/docs/',
97
- 'apps/vada-ai/docs/',
98
- 'aeg-root/tranches/completed/',
99
- 'packages/aeg-core/src/docs/published-prose',
100
- 'packages/aeg-core/src/retired-vocabulary.test.ts',
101
- 'packages/aeg-core/src/retired-vocabulary.ts',
102
- '/fixtures/',
103
- '/node_modules/',
104
- '/.next/',
105
- '/.turbo/'
106
- ]
66
+ export const RETIRED_EXEMPT_SUBSTRINGS: readonly string[] = RETIRED_GLOBAL_EXEMPTIONS
107
67
 
108
- /**
109
- * Per-pattern exemptions on top of `RETIRED_EXEMPT_SUBSTRINGS`, for the
110
- * handful of patterns with a real, load-bearing false-positive shape (a
111
- * live doc that legitimately discusses the retired concept by name, or a
112
- * same-shaped live feature). Copied verbatim from `retired-vocabulary.test.ts`'s
113
- * `PATTERN_EXEMPT` — including entries for `apps/herald-ai`/`apps/vada-ai`
114
- * paths this repo does not carry, since a nonexistent path costs nothing to
115
- * keep and this module's whole point is not re-deriving the list.
116
- */
117
- export const PATTERN_EXEMPT: Readonly<Record<string, readonly string[]>> = {
118
- [String.raw`\bD-[0-9]{3}\b`]: ['./CLAUDE.md'],
119
- [String.raw`decisions\.md`]: [
120
- 'docs-index.md',
121
- 'apps/vada-ai/specs/legacy/README.md',
122
- 'apps/vada-ai/specs/vada-product-spec.md',
123
- 'apps/vada-ai/web/CLAUDE.md',
124
- 'apps/vada-ai/CLAUDE.md'
125
- ],
126
- 'decisions-legacy': [
127
- 'packages/aeg-core/src/file-classify.ts',
128
- 'packages/aeg-core/src/file-classify.test.ts',
129
- 'packages/aeg-core/src/pr-tier.test.ts',
130
- 'docs-index.md',
131
- '.claude/skills/database/SKILL.md',
132
- '.claude/skills/vada-architecture/SKILL.md',
133
- 'apps/vada-ai/specs/vada-byok-principles.md',
134
- 'apps/vada-ai/web/CLAUDE.md',
135
- 'apps/vada-ai/CLAUDE.md'
136
- ],
137
- CONTRADICTION: ['apps/vada-ai/specs/vada-reviewers-spec.md'],
138
- // The tranche model's own retirement section is the one place whose job is
139
- // to say these existed and what replaced them. Exempted by file, for these
140
- // three patterns only — every other retired class still binds that file,
141
- // and its other sections carry none of the three.
142
- ...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
143
- }
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
+ )
144
75
 
145
76
  function lineNumbers(content: string, pattern: RegExp): number[] {
146
77
  const out: number[] = []
@@ -152,26 +83,38 @@ function lineNumbers(content: string, pattern: RegExp): number[] {
152
83
  }
153
84
 
154
85
  /**
155
- * Sweeps `files` for `RETIRED_PATTERNS`, skipping any file whose path
156
- * contains a `RETIRED_EXEMPT_SUBSTRINGS` entry, or that pattern's own
157
- * `PATTERN_EXEMPT` entry. Matching is per-line, case-sensitive — the same
158
- * semantics `grep -E` (with no `-i`) gives the vitest suite this was
159
- * 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.
160
93
  */
161
- export function scanRetiredVocabulary(files: readonly VocabSourceFile[]): VocabFinding[] {
94
+ export function scanRetiredVocabulary(
95
+ files: readonly VocabSourceFile[],
96
+ rules: ProseRuleSet = DEFAULT_PROSE_RULE_SET
97
+ ): VocabFinding[] {
162
98
  const findings: VocabFinding[] = []
99
+ const retired = rulesOfGroup(rules, 'retired-vocabulary')
163
100
  for (const file of files) {
164
- if (RETIRED_EXEMPT_SUBSTRINGS.some((e) => file.path.includes(e))) continue
165
- for (const pattern of RETIRED_PATTERNS) {
166
- const patternExempt = PATTERN_EXEMPT[pattern] ?? []
167
- if (patternExempt.some((e) => file.path.includes(e))) continue
168
- 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
169
108
  for (const line of lineNumbers(file.content, re)) {
170
109
  findings.push({
171
110
  file: file.path,
172
111
  line,
173
112
  pattern,
174
- 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'
175
118
  })
176
119
  }
177
120
  }