@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.
- package/aeg-root/contracts/developer-reviewer.md +2 -2
- package/aeg-root/contracts/planner-developer.md +4 -4
- package/aeg-root/process.md +3 -3
- package/aeg-root/roles/developer/reference.md +3 -0
- package/aeg-root/state-machine.md +2 -2
- package/aeg-root/templates/brief-template.md +1 -1
- package/dist/checks/bin/check-body-bare-digits.js +165 -65
- package/dist/checks/bin/check-branch-topology.js +169 -60
- package/dist/checks/bin/check-brief-shape.js +165 -65
- package/dist/checks/bin/check-changeset-coverage.js +342 -122
- package/dist/checks/bin/check-ci-shard-coverage.js +384 -130
- package/dist/checks/bin/check-closes-n.js +169 -60
- package/dist/checks/bin/check-coherence.js +165 -65
- package/dist/checks/bin/check-dead-branch-push.js +142 -59
- package/dist/checks/bin/check-dispatch-readiness.js +211 -81
- package/dist/checks/bin/check-doc-claims.js +165 -65
- package/dist/checks/bin/check-doc-coverage-push.js +342 -122
- package/dist/checks/bin/check-doc-coverage.js +344 -124
- package/dist/checks/bin/check-doctrine-no-procedures.js +165 -65
- package/dist/checks/bin/check-doctrine-portability.js +342 -122
- package/dist/checks/bin/check-evidence-fresh.js +376 -129
- package/dist/checks/bin/check-exec-bits.js +342 -122
- package/dist/checks/bin/check-first-push-dispatch.js +208 -78
- package/dist/checks/bin/check-issue-milestone-attach.js +142 -59
- package/dist/checks/bin/check-issue-objectives-numbering.js +165 -65
- package/dist/checks/bin/check-issue-parts-coverage.js +142 -59
- package/dist/checks/bin/check-issue-surface-globs.js +218 -88
- package/dist/checks/bin/check-issue-title-grammar.js +142 -59
- package/dist/checks/bin/check-main-branch-refusal.js +142 -59
- package/dist/checks/bin/check-no-disk-state.js +142 -59
- package/dist/checks/bin/check-pr-premise-reassert.js +165 -65
- package/dist/checks/bin/check-pr-report-density.js +142 -59
- package/dist/checks/bin/check-principal-test-plan-wait.js +165 -65
- package/dist/checks/bin/check-quoted-command.js +338 -118
- package/dist/checks/bin/check-reader-resolvable-prose.js +338 -118
- package/dist/checks/bin/check-registry-gates.js +206 -78
- package/dist/checks/bin/check-retired-vocabulary.js +338 -118
- package/dist/checks/bin/check-review-gate.js +203 -83
- package/dist/checks/bin/check-single-plan-pr.js +142 -59
- package/dist/checks/bin/check-surface-scope.js +169 -60
- package/dist/checks/bin/check-test-plan.js +165 -65
- package/dist/checks/bin/check-token-collection-wired.js +142 -59
- package/dist/checks/bin/check-workspace-escape.js +340 -120
- package/dist/checks/bin/verify-coherence.js +153 -60
- package/dist/checks/bin/verify-dispatch.js +169 -69
- package/dist/checks/bin/verify-docs.js +142 -57
- package/dist/index.js +16280 -11764
- package/dist/lib/pre-push-cache-test-run.js +791 -68
- package/dist/lib/pre-push-changed-files.js +65 -19
- package/dist/lib/pre-push-mode.js +466 -0
- package/dist/lib/pre-push-progress-dir.js +4205 -0
- package/dist/lib/pre-push-record-tests.js +446 -0
- package/dist/lib/pre-push-select-tests.js +1426 -454
- package/dist/lib/push-progress-observer.js +4213 -0
- package/package.json +11 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +18 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +3 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +88 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +34 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +26 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +7 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +17 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +13 -17
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +70 -45
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +1 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +77 -7
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +24 -54
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +221 -56
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/live-record.ts +179 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +8 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema-digest.ts +225 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +7 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +23 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/principals-config.ts +44 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/prose-rules.ts +532 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/protected-paths.ts +31 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +157 -80
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +8 -12
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +52 -109
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +46 -17
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +85 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +46 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +2 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +63 -8
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +24 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
- 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
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +1 -1
- 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
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
- 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
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{38kom-9c-oi65.js → 0x7u6si-ai179.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1p3vr9qts86_b.js → 2fu7mfsj4oima.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{21tunzmxjvm2a.js → 34b4ruddunn3q.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
export type ProseRuleSeverity = 'error' | 'warning'
|
|
2
|
+
|
|
3
|
+
export type DefaultProseRule = {
|
|
4
|
+
id: string
|
|
5
|
+
group: 'reader-resolvable' | 'retired-vocabulary' | 'published-prose'
|
|
6
|
+
scopes: readonly string[]
|
|
7
|
+
patterns: Readonly<Record<string, RegExp | string>>
|
|
8
|
+
flags: readonly string[]
|
|
9
|
+
message: string
|
|
10
|
+
severity: Readonly<Record<string, ProseRuleSeverity>>
|
|
11
|
+
exemptions: readonly string[]
|
|
12
|
+
patternExemptions?: Readonly<Record<string, readonly string[]>>
|
|
13
|
+
builtIn?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const RETIRED_GLOBAL_EXEMPTIONS = [
|
|
17
|
+
'docs/decisions-legacy.md',
|
|
18
|
+
'apps/herald-ai/docs/',
|
|
19
|
+
'apps/vada-ai/docs/',
|
|
20
|
+
'aeg-root/tranches/completed/',
|
|
21
|
+
'packages/aeg-core/src/docs/published-prose',
|
|
22
|
+
'packages/aeg-core/src/retired-vocabulary.test.ts',
|
|
23
|
+
'packages/aeg-core/src/retired-vocabulary.ts',
|
|
24
|
+
'/fixtures/',
|
|
25
|
+
'/node_modules/',
|
|
26
|
+
'/.next/',
|
|
27
|
+
'/.turbo/'
|
|
28
|
+
] as const
|
|
29
|
+
|
|
30
|
+
export const PLAN_ON_DISK_PATTERNS: readonly string[] = ['[Tt]opology files?', 'aeg-root/tranches/', 'aeg-project/']
|
|
31
|
+
|
|
32
|
+
export const TRANCHE_MODEL_FILE = '/tranche-model.md'
|
|
33
|
+
|
|
34
|
+
export const RETIRED_PATTERN_EXEMPTIONS: Readonly<Record<string, readonly string[]>> = {
|
|
35
|
+
[String.raw`\bD-[0-9]{3}\b`]: ['./CLAUDE.md'],
|
|
36
|
+
[String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
|
|
37
|
+
'docs-index.md',
|
|
38
|
+
'apps/vada-ai/specs/legacy/README.md',
|
|
39
|
+
'apps/vada-ai/specs/vada-product-spec.md',
|
|
40
|
+
'apps/vada-ai/web/CLAUDE.md',
|
|
41
|
+
'apps/vada-ai/CLAUDE.md'
|
|
42
|
+
],
|
|
43
|
+
'decisions-legacy': [
|
|
44
|
+
'packages/aeg-core/src/file-classify.ts',
|
|
45
|
+
'packages/aeg-core/src/file-classify.test.ts',
|
|
46
|
+
'packages/aeg-core/src/pr-tier.test.ts',
|
|
47
|
+
'docs-index.md',
|
|
48
|
+
'.claude/skills/database/SKILL.md',
|
|
49
|
+
'.claude/skills/vada-architecture/SKILL.md',
|
|
50
|
+
'apps/vada-ai/specs/vada-byok-principles.md',
|
|
51
|
+
'apps/vada-ai/web/CLAUDE.md',
|
|
52
|
+
'apps/vada-ai/CLAUDE.md'
|
|
53
|
+
],
|
|
54
|
+
CONTRADICTION: ['apps/vada-ai/specs/vada-reviewers-spec.md'],
|
|
55
|
+
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const retiredPatterns = [
|
|
59
|
+
String.raw`\bD-[0-9]{3}\b`,
|
|
60
|
+
'D-(###|NNN|nnn|xxx)',
|
|
61
|
+
'decision (entry|logged)',
|
|
62
|
+
'decision-log entry',
|
|
63
|
+
'decision log entry',
|
|
64
|
+
'decision log(s|ged|ging)?([^a-z]|$)',
|
|
65
|
+
'decision-log',
|
|
66
|
+
'decision entr',
|
|
67
|
+
'decisions? (are |is )?logged',
|
|
68
|
+
'log entries',
|
|
69
|
+
String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
|
|
70
|
+
'decisions-legacy',
|
|
71
|
+
'CONTRADICTION',
|
|
72
|
+
'assumes Tier 3',
|
|
73
|
+
'Lock: ?YES',
|
|
74
|
+
'Lock: ?NO',
|
|
75
|
+
'lock approvals?',
|
|
76
|
+
'approves locks',
|
|
77
|
+
'Conforms to lock',
|
|
78
|
+
'Challenges lock',
|
|
79
|
+
'checkDecisionNumbersFresh',
|
|
80
|
+
String.raw`roles/team-leader\.md`,
|
|
81
|
+
String.raw`\(,`,
|
|
82
|
+
String.raw`,\)`,
|
|
83
|
+
String.raw`\(\.\)`,
|
|
84
|
+
...PLAN_ON_DISK_PATTERNS
|
|
85
|
+
] as const
|
|
86
|
+
|
|
87
|
+
const published = [
|
|
88
|
+
['decision-id', 'a decision id', /\bD-\d{3,}\b/],
|
|
89
|
+
['section-ref', 'a section reference', /§/],
|
|
90
|
+
['forge-number', 'a forge number', /#\d+/],
|
|
91
|
+
['retired-name', 'the retired public name', /\bAEG\b/],
|
|
92
|
+
['tranche-slug', 'a tranche slug', /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
|
|
93
|
+
[
|
|
94
|
+
'label-vocabulary',
|
|
95
|
+
'forge label vocabulary',
|
|
96
|
+
/(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
|
|
97
|
+
],
|
|
98
|
+
['internal-path', 'a repo-internal path', /\b(?:packages|apps|aeg-root|tools|scripts)\//],
|
|
99
|
+
['internal-path', 'a repo-internal path', /\.(?:claude|husky|github)\//],
|
|
100
|
+
[
|
|
101
|
+
'internal-path',
|
|
102
|
+
'a repo-internal file',
|
|
103
|
+
/(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
|
|
104
|
+
]
|
|
105
|
+
] as const
|
|
106
|
+
|
|
107
|
+
export const DEFAULT_PROSE_RULES: readonly DefaultProseRule[] = [
|
|
108
|
+
{
|
|
109
|
+
id: 'forge-number',
|
|
110
|
+
group: 'reader-resolvable',
|
|
111
|
+
scopes: ['ships', 'reader-facing', 'spec'],
|
|
112
|
+
patterns: { prose: /#[0-9]{2,4}/g },
|
|
113
|
+
flags: ['global'],
|
|
114
|
+
message: 'a forge number',
|
|
115
|
+
severity: { ships: 'warning', 'reader-facing': 'warning', spec: 'error' },
|
|
116
|
+
exemptions: []
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'tranche-slug',
|
|
120
|
+
group: 'reader-resolvable',
|
|
121
|
+
scopes: ['ships', 'reader-facing', 'product', 'spec'],
|
|
122
|
+
patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
|
|
123
|
+
flags: ['global'],
|
|
124
|
+
message: 'an internal tranche slug',
|
|
125
|
+
severity: { ships: 'warning', 'reader-facing': 'warning', product: 'error', spec: 'error' },
|
|
126
|
+
exemptions: []
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'task-number',
|
|
130
|
+
group: 'reader-resolvable',
|
|
131
|
+
scopes: ['spec'],
|
|
132
|
+
patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
|
|
133
|
+
flags: ['global', 'ignore-case'],
|
|
134
|
+
message: 'a task number',
|
|
135
|
+
severity: { spec: 'error' },
|
|
136
|
+
exemptions: []
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: 'source-comment-tranche-slug',
|
|
140
|
+
group: 'reader-resolvable',
|
|
141
|
+
scopes: ['source-comment'],
|
|
142
|
+
patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
|
|
143
|
+
flags: ['global'],
|
|
144
|
+
message: 'a tranche-slug citation',
|
|
145
|
+
severity: { 'source-comment': 'warning' },
|
|
146
|
+
exemptions: []
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: 'source-comment-forge-number',
|
|
150
|
+
group: 'reader-resolvable',
|
|
151
|
+
scopes: ['source-comment'],
|
|
152
|
+
patterns: { comment: /#[0-9]{2,}/g },
|
|
153
|
+
flags: ['global'],
|
|
154
|
+
message: 'a forge-number citation',
|
|
155
|
+
severity: { 'source-comment': 'warning' },
|
|
156
|
+
exemptions: []
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: 'legacy-batch-name',
|
|
160
|
+
group: 'reader-resolvable',
|
|
161
|
+
scopes: ['ships', 'reader-facing', 'spec'],
|
|
162
|
+
patterns: {},
|
|
163
|
+
flags: ['built-in'],
|
|
164
|
+
message: 'an internal tranche slug',
|
|
165
|
+
severity: { ships: 'warning', 'reader-facing': 'warning', spec: 'error' },
|
|
166
|
+
exemptions: [],
|
|
167
|
+
builtIn: true
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: 'coined-term',
|
|
171
|
+
group: 'reader-resolvable',
|
|
172
|
+
scopes: ['ships', 'reader-facing'],
|
|
173
|
+
patterns: {},
|
|
174
|
+
flags: ['built-in'],
|
|
175
|
+
message: 'uses coined term without defining it inline or linking the glossary',
|
|
176
|
+
severity: { ships: 'warning', 'reader-facing': 'warning' },
|
|
177
|
+
exemptions: [],
|
|
178
|
+
builtIn: true
|
|
179
|
+
},
|
|
180
|
+
...retiredPatterns.map((pattern, index) => ({
|
|
181
|
+
id: `retired-vocabulary-${index + 1}`,
|
|
182
|
+
group: 'retired-vocabulary' as const,
|
|
183
|
+
scopes: ['repository'],
|
|
184
|
+
patterns: { repository: pattern },
|
|
185
|
+
flags: [],
|
|
186
|
+
message: 'retired vocabulary',
|
|
187
|
+
severity: { repository: 'error' as const },
|
|
188
|
+
exemptions: RETIRED_GLOBAL_EXEMPTIONS,
|
|
189
|
+
patternExemptions: RETIRED_PATTERN_EXEMPTIONS
|
|
190
|
+
})),
|
|
191
|
+
...published.map(([id, message, pattern]) => ({
|
|
192
|
+
id,
|
|
193
|
+
group: 'published-prose' as const,
|
|
194
|
+
scopes: ['published'],
|
|
195
|
+
patterns: { published: pattern },
|
|
196
|
+
flags: [],
|
|
197
|
+
message,
|
|
198
|
+
severity: { published: 'error' as const },
|
|
199
|
+
exemptions: ['.worktrees/task/<tranche>/<n>', 'task/<tranche>/<n>', '.worktrees/']
|
|
200
|
+
}))
|
|
201
|
+
]
|
|
202
|
+
|
|
203
|
+
export const rulesForGroup = (group: DefaultProseRule['group']): readonly DefaultProseRule[] =>
|
|
204
|
+
DEFAULT_PROSE_RULES.filter((rule) => rule.group === group)
|
|
205
|
+
|
|
206
|
+
export const proseSeverity = (id: string, scope: string): ProseRuleSeverity | undefined =>
|
|
207
|
+
DEFAULT_PROSE_RULES.find((rule) => rule.id === id)?.severity[scope]
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The scopes a repository's own configuration may name, and the check that
|
|
211
|
+
* reads each one. `reader-resolvable-prose` runs every rule whose scopes fall
|
|
212
|
+
* in the first set; `retired-vocabulary` runs every rule whose scopes fall in
|
|
213
|
+
* the second. `published` is absent on purpose: the published pass belongs
|
|
214
|
+
* to the documentation gate, and `proseGates.published.allow` is its only
|
|
215
|
+
* setting.
|
|
216
|
+
*/
|
|
217
|
+
export const RESOLVABLE_SCOPES = ['ships', 'reader-facing', 'product', 'spec', 'source-comment'] as const
|
|
218
|
+
export const RETIRED_SCOPES = ['repository'] as const
|
|
219
|
+
export const CONFIGURABLE_PROSE_SCOPES: readonly string[] = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES]
|
|
220
|
+
|
|
221
|
+
/** The two rule groups a configured rule can join — one per prose check. */
|
|
222
|
+
export type ProseCheckGroup = 'reader-resolvable' | 'retired-vocabulary'
|
|
223
|
+
|
|
224
|
+
/** The group whose check reads `scope`, or `undefined` for a scope no configured rule may name. */
|
|
225
|
+
export function groupOfScope(scope: string): ProseCheckGroup | undefined {
|
|
226
|
+
if ((RESOLVABLE_SCOPES as readonly string[]).includes(scope)) return 'reader-resolvable'
|
|
227
|
+
if ((RETIRED_SCOPES as readonly string[]).includes(scope)) return 'retired-vocabulary'
|
|
228
|
+
return undefined
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** The regular-expression flags a configured rule may carry. */
|
|
232
|
+
export const CONFIGURED_PROSE_FLAGS: readonly string[] = ['i', 'u']
|
|
233
|
+
|
|
234
|
+
/** The longest pattern a repository may configure. The shipped defaults are not held to it. */
|
|
235
|
+
export const CONFIGURED_PATTERN_MAX_LENGTH = 200
|
|
236
|
+
|
|
237
|
+
/** The defaults `proseGates.rules.defaults` may address: every rule one of the two prose checks runs. */
|
|
238
|
+
export const CONFIGURABLE_DEFAULT_RULES: readonly DefaultProseRule[] = DEFAULT_PROSE_RULES.filter(
|
|
239
|
+
(rule): rule is DefaultProseRule & { group: ProseCheckGroup } => rule.group !== 'published-prose'
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* The scopes a default rule may be moved to. A built-in rule computes its
|
|
244
|
+
* own matches for the scopes it ships with, so it may only narrow them; a
|
|
245
|
+
* pattern rule may take any scope its own check reads.
|
|
246
|
+
*/
|
|
247
|
+
export function allowedScopesFor(rule: DefaultProseRule): readonly string[] {
|
|
248
|
+
if (rule.builtIn) return rule.scopes
|
|
249
|
+
return rule.group === 'retired-vocabulary' ? RETIRED_SCOPES : RESOLVABLE_SCOPES
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export type ProseRuleSeveritySetting = ProseRuleSeverity | Readonly<Record<string, ProseRuleSeverity>>
|
|
253
|
+
|
|
254
|
+
/** `proseGates.rules.defaults.<id>` — switch a default off, or retune its scopes, severity or exemptions. Its pattern and message are never configurable. */
|
|
255
|
+
export type ProseRuleOverride =
|
|
256
|
+
| 'off'
|
|
257
|
+
| {
|
|
258
|
+
scopes?: readonly string[]
|
|
259
|
+
severity?: ProseRuleSeveritySetting
|
|
260
|
+
exempt?: readonly string[]
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** `proseGates.rules.custom[]` — a rule a repository writes for itself. */
|
|
264
|
+
export type CustomProseRule = {
|
|
265
|
+
id: string
|
|
266
|
+
pattern?: string
|
|
267
|
+
patterns?: Readonly<Record<string, string>>
|
|
268
|
+
flags?: string
|
|
269
|
+
means: string
|
|
270
|
+
scopes: readonly string[]
|
|
271
|
+
severity?: ProseRuleSeveritySetting
|
|
272
|
+
exempt?: readonly string[]
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** `proseGates.rules`. */
|
|
276
|
+
export type ProseRulesConfig = {
|
|
277
|
+
exempt?: readonly string[]
|
|
278
|
+
defaults?: Readonly<Record<string, ProseRuleOverride>>
|
|
279
|
+
custom?: readonly CustomProseRule[]
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** One rule as a check runs it: a default with its configuration applied, or a custom rule. */
|
|
283
|
+
export type ResolvedProseRule = {
|
|
284
|
+
id: string
|
|
285
|
+
group: ProseCheckGroup
|
|
286
|
+
custom: boolean
|
|
287
|
+
builtIn: boolean
|
|
288
|
+
scopes: readonly string[]
|
|
289
|
+
/** The default's message, or the custom rule's `means`. */
|
|
290
|
+
message: string
|
|
291
|
+
severity: Readonly<Record<string, ProseRuleSeverity>>
|
|
292
|
+
/** Configured path exemptions: repository-relative files or folders this rule does not read. */
|
|
293
|
+
exempt: readonly string[]
|
|
294
|
+
/** The default's own substring exemptions (the retired group's archives and history), unchanged. */
|
|
295
|
+
substringExempt: readonly string[]
|
|
296
|
+
/** The capture holding the cited text, when the pattern carries boundary characters around it. */
|
|
297
|
+
reportGroup?: number
|
|
298
|
+
/** The pattern for one scope, or `null` when the rule has none there. */
|
|
299
|
+
patternFor: (scope: string) => RegExp | null
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export type ProseRuleSet = {
|
|
303
|
+
rules: readonly ResolvedProseRule[]
|
|
304
|
+
/** `proseGates.rules.exempt` — paths no rule reads. */
|
|
305
|
+
exempt: readonly string[]
|
|
306
|
+
/** Absolute repository root, stripped from an absolute file path before an exemption is compared. */
|
|
307
|
+
repoRoot?: string
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** One repository path in a single spelling: forward slashes, no leading `./`, no doubled or trailing slash. */
|
|
311
|
+
export function normalizeRepoPath(entry: string): string {
|
|
312
|
+
let out = entry.replace(/\\/g, '/')
|
|
313
|
+
while (out.startsWith('./')) out = out.slice(2)
|
|
314
|
+
out = out.replace(/\/{2,}/g, '/')
|
|
315
|
+
while (out.endsWith('/')) out = out.slice(0, -1)
|
|
316
|
+
return out
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** Whether a configured exemption list covers `path` — the path itself, or anything under a listed folder. */
|
|
320
|
+
export function isConfiguredExempt(path: string, exempt: readonly string[], repoRoot?: string): boolean {
|
|
321
|
+
if (exempt.length === 0) return false
|
|
322
|
+
const root = repoRoot === undefined ? undefined : normalizeRepoPath(repoRoot)
|
|
323
|
+
let rel = normalizeRepoPath(path)
|
|
324
|
+
if (root && rel.startsWith(`${root}/`)) rel = rel.slice(root.length + 1)
|
|
325
|
+
return exempt.some((entry) => {
|
|
326
|
+
const e = normalizeRepoPath(entry)
|
|
327
|
+
return rel === e || rel.startsWith(`${e}/`)
|
|
328
|
+
})
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** Whether `rule` reads `path` at all under `set`'s exemptions. */
|
|
332
|
+
export function ruleReads(set: ProseRuleSet, rule: ResolvedProseRule, path: string): boolean {
|
|
333
|
+
return !isConfiguredExempt(path, set.exempt, set.repoRoot) && !isConfiguredExempt(path, rule.exempt, set.repoRoot)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** The order the reader-resolvable rules have always run in, so an unconfigured run reports findings in the same order. */
|
|
337
|
+
const RESOLVABLE_RUN_ORDER = [
|
|
338
|
+
'forge-number',
|
|
339
|
+
'tranche-slug',
|
|
340
|
+
'legacy-batch-name',
|
|
341
|
+
'task-number',
|
|
342
|
+
'source-comment-tranche-slug',
|
|
343
|
+
'source-comment-forge-number',
|
|
344
|
+
'coined-term'
|
|
345
|
+
]
|
|
346
|
+
|
|
347
|
+
const REPORT_GROUPS: Readonly<Record<string, number>> = { 'task-number': 2, 'legacy-batch-name': 2 }
|
|
348
|
+
|
|
349
|
+
/** A scope's severity when nothing names one: the source-comment scope follows `proseGates.sourceComments.severity`, the retired check blocks, every other scope warns. */
|
|
350
|
+
function scopeDefaultSeverity(scope: string, sourceCommentSeverity: ProseRuleSeverity | undefined): ProseRuleSeverity {
|
|
351
|
+
if (scope === 'source-comment') return sourceCommentSeverity ?? 'warning'
|
|
352
|
+
if (scope === 'repository') return 'error'
|
|
353
|
+
return 'warning'
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function applySeverity(
|
|
357
|
+
scopes: readonly string[],
|
|
358
|
+
base: Readonly<Record<string, ProseRuleSeverity>>,
|
|
359
|
+
setting: ProseRuleSeveritySetting | undefined
|
|
360
|
+
): Record<string, ProseRuleSeverity> {
|
|
361
|
+
const out: Record<string, ProseRuleSeverity> = {}
|
|
362
|
+
for (const scope of scopes) {
|
|
363
|
+
const configured = typeof setting === 'string' ? setting : setting?.[scope]
|
|
364
|
+
const value = configured ?? base[scope]
|
|
365
|
+
if (value !== undefined) out[scope] = value
|
|
366
|
+
}
|
|
367
|
+
return out
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function defaultPatternFor(rule: DefaultProseRule): (scope: string) => RegExp | null {
|
|
371
|
+
const cache = new Map<string, RegExp | null>()
|
|
372
|
+
return (scope) => {
|
|
373
|
+
if (cache.has(scope)) return cache.get(scope) ?? null
|
|
374
|
+
const own =
|
|
375
|
+
rule.patterns[scope] ??
|
|
376
|
+
(scope === 'source-comment' ? rule.patterns.comment : rule.patterns.prose) ??
|
|
377
|
+
Object.values(rule.patterns)[0]
|
|
378
|
+
const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own)
|
|
379
|
+
cache.set(scope, compiled)
|
|
380
|
+
return compiled
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function customPatternFor(rule: CustomProseRule, global: boolean): (scope: string) => RegExp | null {
|
|
385
|
+
const cache = new Map<string, RegExp | null>()
|
|
386
|
+
return (scope) => {
|
|
387
|
+
if (cache.has(scope)) return cache.get(scope) ?? null
|
|
388
|
+
const source = rule.patterns?.[scope] ?? rule.pattern
|
|
389
|
+
const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ''}${global ? 'g' : ''}`)
|
|
390
|
+
cache.set(scope, compiled)
|
|
391
|
+
return compiled
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* The rule set the two prose checks run: every default the two checks own,
|
|
397
|
+
* with `config.defaults` applied (an `"off"` default is dropped), followed by
|
|
398
|
+
* `config.custom` in the order written. With no configuration this is the
|
|
399
|
+
* defaults exactly as shipped, so an unconfigured run reports what it always
|
|
400
|
+
* did. `options.decisionRecordsPath` — `decisionRecords.path` — adds the
|
|
401
|
+
* decision-record citation rule after the custom rules; absent, the rule is
|
|
402
|
+
* not in the set at all. Validation is the configuration loader's job; this
|
|
403
|
+
* function trusts its input.
|
|
404
|
+
*/
|
|
405
|
+
export function resolveProseRules(
|
|
406
|
+
config: ProseRulesConfig | undefined = undefined,
|
|
407
|
+
options: { sourceCommentSeverity?: ProseRuleSeverity; repoRoot?: string; decisionRecordsPath?: string } = {}
|
|
408
|
+
): ProseRuleSet {
|
|
409
|
+
const rules: ResolvedProseRule[] = []
|
|
410
|
+
const defaults = config?.defaults ?? {}
|
|
411
|
+
for (const rule of CONFIGURABLE_DEFAULT_RULES) {
|
|
412
|
+
const override = defaults[rule.id]
|
|
413
|
+
if (override === 'off') continue
|
|
414
|
+
const group = rule.group as ProseCheckGroup
|
|
415
|
+
const scopes = override?.scopes ?? rule.scopes
|
|
416
|
+
const base: Record<string, ProseRuleSeverity> = {}
|
|
417
|
+
for (const scope of scopes) {
|
|
418
|
+
base[scope] =
|
|
419
|
+
scope === 'source-comment'
|
|
420
|
+
? (options.sourceCommentSeverity ?? rule.severity[scope] ?? 'warning')
|
|
421
|
+
: (rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity))
|
|
422
|
+
}
|
|
423
|
+
rules.push({
|
|
424
|
+
id: rule.id,
|
|
425
|
+
group,
|
|
426
|
+
custom: false,
|
|
427
|
+
builtIn: rule.builtIn === true,
|
|
428
|
+
scopes,
|
|
429
|
+
message: rule.message,
|
|
430
|
+
severity: applySeverity(scopes, base, override?.severity),
|
|
431
|
+
exempt: override?.exempt ?? [],
|
|
432
|
+
substringExempt: rule.exemptions,
|
|
433
|
+
reportGroup: REPORT_GROUPS[rule.id],
|
|
434
|
+
patternFor: defaultPatternFor(rule)
|
|
435
|
+
})
|
|
436
|
+
}
|
|
437
|
+
for (const rule of config?.custom ?? []) {
|
|
438
|
+
const group = groupOfScope(rule.scopes[0] ?? '') ?? 'reader-resolvable'
|
|
439
|
+
const base: Record<string, ProseRuleSeverity> = {}
|
|
440
|
+
for (const scope of rule.scopes) base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity)
|
|
441
|
+
rules.push({
|
|
442
|
+
id: rule.id,
|
|
443
|
+
group,
|
|
444
|
+
custom: true,
|
|
445
|
+
builtIn: false,
|
|
446
|
+
scopes: rule.scopes,
|
|
447
|
+
message: rule.means,
|
|
448
|
+
severity: applySeverity(rule.scopes, base, rule.severity),
|
|
449
|
+
exempt: rule.exempt ?? [],
|
|
450
|
+
substringExempt: [],
|
|
451
|
+
patternFor: customPatternFor(rule, group === 'reader-resolvable')
|
|
452
|
+
})
|
|
453
|
+
}
|
|
454
|
+
if (options.decisionRecordsPath !== undefined) rules.push(decisionRecordCitationRule(options.decisionRecordsPath))
|
|
455
|
+
const order = (rule: ResolvedProseRule): number => {
|
|
456
|
+
const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id)
|
|
457
|
+
return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at
|
|
458
|
+
}
|
|
459
|
+
const resolvable = rules.filter((rule) => rule.group === 'reader-resolvable')
|
|
460
|
+
const sorted = resolvable
|
|
461
|
+
.map((rule, index) => ({ rule, index }))
|
|
462
|
+
.sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index)
|
|
463
|
+
.map(({ rule }) => rule)
|
|
464
|
+
return {
|
|
465
|
+
rules: [...sorted, ...rules.filter((rule) => rule.group === 'retired-vocabulary')],
|
|
466
|
+
exempt: config?.exempt ?? [],
|
|
467
|
+
repoRoot: options.repoRoot
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** The rules one check runs, in run order. */
|
|
472
|
+
export function rulesOfGroup(set: ProseRuleSet, group: ProseCheckGroup): readonly ResolvedProseRule[] {
|
|
473
|
+
return set.rules.filter((rule) => rule.group === group)
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/** The rules one check runs in one scope, in run order. */
|
|
477
|
+
export function rulesInScope(set: ProseRuleSet, scope: string): readonly ResolvedProseRule[] {
|
|
478
|
+
return set.rules.filter((rule) => rule.scopes.includes(scope))
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/** The rule set with nothing configured — what both checks run by default. */
|
|
482
|
+
export const DEFAULT_PROSE_RULE_SET: ProseRuleSet = resolveProseRules()
|
|
483
|
+
|
|
484
|
+
/** The id of the rule `decisionRecords.path` switches on. */
|
|
485
|
+
export const DECISION_RECORD_CITATION_ID = 'decision-record-citation'
|
|
486
|
+
|
|
487
|
+
/** Where the decision-record citation rule reads: the doctrine pages, the specs, product code and source comments — and the published pass, which runs it separately. */
|
|
488
|
+
export const DECISION_RECORD_CITATION_SCOPES: readonly string[] = ['ships', 'product', 'spec', 'source-comment']
|
|
489
|
+
|
|
490
|
+
/** The message a decision-record citation finding prints. */
|
|
491
|
+
export const DECISION_RECORD_CITATION_MESSAGE = 'a decision-record number'
|
|
492
|
+
|
|
493
|
+
function escapeRegExp(text: string): string {
|
|
494
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* The decision-record citation pattern for the folder `decisionRecordsPath`:
|
|
499
|
+
* `ADR` followed by a number (`ADR-7`, `ADR 0007`, `ADR7`), or a path to a
|
|
500
|
+
* numbered file in that folder (`docs/adr/0007-retire-locks.md`). A record's
|
|
501
|
+
* number means nothing to a reader without the folder in front of them, so
|
|
502
|
+
* text outside the folder states the decision instead of citing it.
|
|
503
|
+
*/
|
|
504
|
+
export function decisionRecordCitationPattern(decisionRecordsPath: string): RegExp {
|
|
505
|
+
const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath))
|
|
506
|
+
return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, 'g')
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* The decision-record citation rule, resolved for one folder. It exists only
|
|
511
|
+
* while `decisionRecords.path` is set — `resolveProseRules` adds it when its
|
|
512
|
+
* `decisionRecordsPath` option is given and never otherwise — and it never
|
|
513
|
+
* reads the folder itself, so a record may name the record it supersedes.
|
|
514
|
+
*/
|
|
515
|
+
export function decisionRecordCitationRule(decisionRecordsPath: string): ResolvedProseRule {
|
|
516
|
+
const folder = normalizeRepoPath(decisionRecordsPath)
|
|
517
|
+
const pattern = decisionRecordCitationPattern(folder)
|
|
518
|
+
const severity: Record<string, ProseRuleSeverity> = {}
|
|
519
|
+
for (const scope of DECISION_RECORD_CITATION_SCOPES) severity[scope] = 'error'
|
|
520
|
+
return {
|
|
521
|
+
id: DECISION_RECORD_CITATION_ID,
|
|
522
|
+
group: 'reader-resolvable',
|
|
523
|
+
custom: false,
|
|
524
|
+
builtIn: false,
|
|
525
|
+
scopes: DECISION_RECORD_CITATION_SCOPES,
|
|
526
|
+
message: DECISION_RECORD_CITATION_MESSAGE,
|
|
527
|
+
severity,
|
|
528
|
+
exempt: [folder],
|
|
529
|
+
substringExempt: [],
|
|
530
|
+
patternFor: () => pattern
|
|
531
|
+
}
|
|
532
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { posix as posixPath } from 'node:path'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The administrative policy paths a task may write only when the `in:` globs
|
|
5
|
+
* of its Issue's Surface cover them. The broker's push refusal and the
|
|
6
|
+
* `surface-scope` check both read this one list.
|
|
7
|
+
*/
|
|
8
|
+
export const PROTECTED_ADMIN_PATHS = ['vinaya.config.json', '.vinaya/doc-owners', '.github/', 'aeg-root/'] as const
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the path as if rooted at a virtual `/` — via `posixPath.resolve`,
|
|
12
|
+
* never `posixPath.normalize` — so `foo/../.github/workflows/ci.yml`,
|
|
13
|
+
* `./.github/x`, an absolute `/aeg-root/x`, and a path that OPENS with an
|
|
14
|
+
* unresolved `..` (`../.github/x`, `../../aeg-root/x`) all normalize to the
|
|
15
|
+
* same string a plain `.github/x` or `aeg-root/x` would. `resolve` against a
|
|
16
|
+
* root has nowhere to go past that root, so a leading `..` collapses to the
|
|
17
|
+
* root itself instead of surviving in the output — `normalize` alone has no
|
|
18
|
+
* such floor and leaves an unresolvable leading `..` untouched, which is
|
|
19
|
+
* exactly the disguise that got past an earlier version of the broker's
|
|
20
|
+
* check (`../.github/workflows/ci.yml` normalized to itself, never matching
|
|
21
|
+
* the `.github/` prefix). The leading `/` that `resolve` adds is stripped after.
|
|
22
|
+
*/
|
|
23
|
+
export function normalizeTouchedPath(path: string): string {
|
|
24
|
+
return posixPath.resolve('/', path.replace(/\\/g, '/')).replace(/^\/+/, '')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** True when the path, once normalized, is a protected administrative path or sits under one. */
|
|
28
|
+
export function isProtectedAdminPath(path: string): boolean {
|
|
29
|
+
const normalized = normalizeTouchedPath(path)
|
|
30
|
+
return PROTECTED_ADMIN_PATHS.some((prefix) => normalized === prefix || normalized.startsWith(prefix))
|
|
31
|
+
}
|