@attalabs/vinaya 0.42.2 → 0.43.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 (82) hide show
  1. package/dist/checks/bin/check-evidence-fresh.js +8 -5
  2. package/dist/index.js +20 -17
  3. package/dist/lib/pre-push-cache-test-run.js +3 -1
  4. package/dist/programs/archive.js +3 -1
  5. package/dist/programs/check.js +3 -1
  6. package/dist/programs/commit-msg.js +3 -1
  7. package/dist/programs/dev-review-loop.js +9 -6
  8. package/dist/programs/dispatch.js +3 -1
  9. package/dist/programs/log-emit.js +3 -1
  10. package/dist/programs/log-selftest.js +3 -1
  11. package/dist/programs/log-send.js +3 -1
  12. package/dist/programs/pr-report.js +8 -5
  13. package/dist/programs/pr-snapshot.js +3 -1
  14. package/dist/programs/pr-verify-evidence.js +8 -5
  15. package/dist/programs/pr.js +3 -1
  16. package/dist/programs/review-post.js +3 -1
  17. package/dist/programs/review-status.js +3 -1
  18. package/dist/programs/run-engine.js +110594 -0
  19. package/dist/programs/supervised-command.js +67 -0
  20. package/dist/programs/sync.js +3 -1
  21. package/dist/programs/task-brief.js +5 -3
  22. package/dist/programs/task-sweep.js +3 -1
  23. package/dist/programs/task-tools-serve.js +13 -11
  24. package/dist/programs/tokens.js +3 -1
  25. package/dist/programs/waiver.js +3 -1
  26. package/dist/vinaya-strict/checks/registry.ts +1085 -0
  27. package/dist/vinaya-strict/executing/code-reviewer/README.md +3 -0
  28. package/dist/vinaya-strict/executing/code-reviewer/doctrine.md +185 -0
  29. package/dist/vinaya-strict/executing/code-reviewer/evals/README.md +1 -0
  30. package/dist/vinaya-strict/executing/code-reviewer/evals/code-reviewer-cases.json +280 -0
  31. package/dist/vinaya-strict/executing/code-reviewer/grants.yaml +22 -0
  32. package/dist/vinaya-strict/executing/code-reviewer/output.schema.json +93 -0
  33. package/dist/vinaya-strict/executing/code-reviewer/review-result.ts +347 -0
  34. package/dist/vinaya-strict/executing/dev-review.flow.yaml +103 -0
  35. package/dist/vinaya-strict/executing/developer/README.md +3 -0
  36. package/dist/vinaya-strict/executing/developer/developer-doctrine-shape.test.ts +69 -0
  37. package/dist/vinaya-strict/executing/developer/developer-turn-result.ts +286 -0
  38. package/dist/vinaya-strict/executing/developer/doctrine.md +111 -0
  39. package/dist/vinaya-strict/executing/developer/evals/README.md +1 -0
  40. package/dist/vinaya-strict/executing/developer/evals/developer-capability-cases.json +6275 -0
  41. package/dist/vinaya-strict/executing/developer/evals/developer-capability-held-out.json +11526 -0
  42. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.test.ts +498 -0
  43. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.ts +1407 -0
  44. package/dist/vinaya-strict/executing/developer/grants.yaml +25 -0
  45. package/dist/vinaya-strict/executing/developer/output.schema.json +148 -0
  46. package/dist/vinaya-strict/executing/developer/reference.md +376 -0
  47. package/dist/vinaya-strict/executing/operator/doctrine.md +209 -0
  48. package/dist/vinaya-strict/executing/security-reviewer/README.md +3 -0
  49. package/dist/vinaya-strict/executing/security-reviewer/doctrine.md +171 -0
  50. package/dist/vinaya-strict/executing/security-reviewer/evals/README.md +1 -0
  51. package/dist/vinaya-strict/executing/security-reviewer/evals/security-reviewer-cases.json +141 -0
  52. package/dist/vinaya-strict/executing/security-reviewer/grants.yaml +22 -0
  53. package/dist/vinaya-strict/executing/security-reviewer/output.schema.json +93 -0
  54. package/dist/vinaya-strict/integration/config/vinaya-config-section.ts +1278 -0
  55. package/dist/vinaya-strict/integration/policies/vinaya-policies.ts +52 -0
  56. package/dist/vinaya-strict/integration/process/process-integration.ts +57 -0
  57. package/dist/vinaya-strict/loops/dev-review/v2/dev-review-v2.flow.yaml +136 -0
  58. package/dist/vinaya-strict/process.yaml +43 -0
  59. package/dist/vinaya-strict/retrospecting/archivist/doctrine.md +174 -0
  60. package/dist/vinaya-strict/retrospecting/tranche-archivist/doctrine.md +270 -0
  61. package/dist/vinaya-strict/thinking/architect/doctrine.md +110 -0
  62. package/dist/vinaya-strict/thinking/planner/doctrine.md +105 -0
  63. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.test.ts +128 -0
  64. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.ts +169 -0
  65. package/dist/vinaya-strict/thinking/planner/tools/open-issue.test.ts +701 -0
  66. package/dist/vinaya-strict/thinking/planner/tools/open-issue.ts +1035 -0
  67. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.test.ts +359 -0
  68. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.ts +815 -0
  69. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.test.ts +200 -0
  70. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.ts +458 -0
  71. package/package.json +4 -2
  72. package/studio-standalone/apps/vinaya-studio/.next/BUILD_ID +1 -1
  73. package/studio-standalone/apps/vinaya-studio/.next/build-manifest.json +2 -2
  74. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.html +1 -1
  75. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.rsc +1 -1
  76. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  77. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  78. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  79. package/studio-standalone/apps/vinaya-studio/.next/server/middleware-build-manifest.js +1 -1
  80. package/studio-standalone/apps/vinaya-studio/.next/server/pages/500.html +1 -1
  81. /package/studio-standalone/apps/vinaya-studio/.next/static/{Q_xjhiWztjosXWbMSJ0Yp → x2q88XfwsihlevulRhIvs}/_buildManifest.js +0 -0
  82. /package/studio-standalone/apps/vinaya-studio/.next/static/{Q_xjhiWztjosXWbMSJ0Yp → x2q88XfwsihlevulRhIvs}/_ssgManifest.js +0 -0
@@ -0,0 +1,1085 @@
1
+ import { installCheckRegistry } from '../../../kernel/gates/checks/registry'
2
+ import { existsSync } from 'node:fs'
3
+ import { join, relative, sep } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+ import { cliPackageRoot } from '../../../../apps/cli/src/lib/package-root.js'
6
+ import { DOCTRINE_REPO_PATHS } from '../tools/doctrine/doctrine-map'
7
+ import type { CheckSpec } from '../../../kernel/gates/checks/contract'
8
+
9
+ // `cliPackageRoot()` walks up to the nearest `package.json`
10
+ // rather than a fixed `../..` — the fixed depth was correct only when
11
+ // running unbundled from `src/checks/`; once bundled into a single-file
12
+ // `dist/index.js` (what a real `npm install` ships), the depth from the
13
+ // bundled file to the package root differs, and a fixed walk landed every
14
+ // `BIN_DIR`-derived path one directory short. `BIN_DIR` is still computed
15
+ // once at module scope: the package root a check's bin resolves against
16
+ // never changes at runtime.
17
+ //
18
+ // **The published tarball never contains `src/`** — `package.json`'s
19
+ // `files` allowlist ships only `dist`, `templates`, `README.md`. Every one
20
+ // of these checks was 100% unreachable through a real `npm install`
21
+ // (`check --all` errored "not found on PATH" for all 15 — found live
22
+ // against the real published `@attalabs/vinaya@0.1.1`, not caught by any
23
+ // prior review because verification only ever ran against local source,
24
+ // where `src/checks/bin/*.ts` genuinely exists). `scripts/build.ts` now
25
+ // bundles each `src/checks/bin/*.ts` to its own standalone, self-contained
26
+ // `dist/checks/bin/*.js` (same `Bun.build` shape as the main `dist/index.js`
27
+ // entrypoint) — that bundled output is what actually ships. A bundled entry
28
+ // uses it; a raw source entry uses the `.ts` checks even when a stale `dist`
29
+ // directory is present.
30
+ export function resolveCheckBin(packageDir: string, moduleUrl: string): { dir: string; ext: '.js' | '.ts' } {
31
+ const fromPackage = relative(packageDir, fileURLToPath(moduleUrl))
32
+ const bundled = fromPackage === 'dist' || fromPackage.startsWith(`dist${sep}`)
33
+ return bundled
34
+ ? { dir: join(packageDir, 'dist', 'checks', 'bin'), ext: '.js' }
35
+ : { dir: join(packageDir, '..', '..', 'harness/processes/vinaya-strict/checks/bin'), ext: '.ts' }
36
+ }
37
+
38
+ const CHECK_BIN = resolveCheckBin(cliPackageRoot(), import.meta.url)
39
+ const BIN_DIR = CHECK_BIN.dir
40
+ const BIN_EXT = CHECK_BIN.ext
41
+
42
+ /** `bin('check-brief-shape')` → the real, resolvable path to that check's executable — bundled `.js` when shipped, raw `.ts` in local dev. */
43
+ function bin(name: string): string {
44
+ return join(BIN_DIR, `${name}${BIN_EXT}`)
45
+ }
46
+
47
+ /** The loop's readiness-gate steps: the shipped check bin, and the core package's existing-work verification, which the build bundles beside the checks. */
48
+ export type GateStep = 'check-dispatch-readiness' | 'verify-dispatch'
49
+
50
+ /**
51
+ * The real path of one readiness-gate step, resolved from the package this
52
+ * module lives in — never the current directory, which an adopter's
53
+ * repository does not fill with Vinaya sources. `null` when the step is not
54
+ * on disk (an incomplete install).
55
+ */
56
+ export function resolveGateStep(
57
+ step: GateStep,
58
+ packageDir = cliPackageRoot(),
59
+ moduleUrl = import.meta.url
60
+ ): string | null {
61
+ const { dir, ext } = resolveCheckBin(packageDir, moduleUrl)
62
+ const path =
63
+ step === 'verify-dispatch' && ext === '.ts'
64
+ ? join(packageDir, '..', '..', 'harness/processes/vinaya-strict/checks/standalone/verify-dispatch.ts')
65
+ : join(dir, `${step}${ext}`)
66
+ return existsSync(path) ? path : null
67
+ }
68
+
69
+ /**
70
+ * `ring` — which of `harness/processes/vinaya-strict/doctrine/enforcement.md`'s three ring tables this core
71
+ * check's own row belongs in, when the registry-scaffold writer
72
+ * (`harness/processes/vinaya-strict/checks/registry-scaffold.ts`) needs to auto-insert a stub
73
+ * row for it. Derived mechanically, not by re-reading each check's prose:
74
+ * `0` for every check that runs under the managed local hooks (pre-commit/
75
+ * pre-push's `vinaya check --all --local`) — i.e. everything that is
76
+ * neither `requiresOpenPr` nor `ownWorkflow`, since `--local` skips exactly
77
+ * those two classes (`harness/processes/vinaya-strict/integration/artifacts.ts`'s `preCommitBody`/
78
+ * `prePushBody` comments) and nothing else; `1` for a check that can only
79
+ * ever run once a pull request exists (`requiresOpenPr`) or is reported by
80
+ * its own dedicated workflow instead of `--all` (`ownWorkflow`) — CI/PR-only
81
+ * by construction. No core check is ring-2-only today: every ring-2
82
+ * mechanism in this repo (`archive-task.ts`, `check-direct-main-push.ts`,
83
+ * `dead-branch-audit.ts`, `report-tokens.ts`) is a standalone script, never
84
+ * a `coreCheckRegistry()` entry.
85
+ *
86
+ * Several of these checks are *also* re-run in CI (`vinaya-checks.yml`'s
87
+ * `check --all --diff-only`) even when ring-0 — `enforcement.md` line 114
88
+ * documents this as the normal, accepted shape ("Same checks, same
89
+ * strictness, at ring 0 and ring 1 — the runner is one codebase invoked from
90
+ * both"), not a contradiction: `ring` here names the EARLIEST enforcement
91
+ * point (ring 0 also covers body checks enforced by pre-write validation,
92
+ * even when hooks skip them without a body), not an
93
+ * exhaustive list of every ring a check happens to also run under.
94
+ *
95
+ * Deliberately NOT a field on `CheckSpec` (or on the objects
96
+ * `coreCheckRegistry()` returns): the shared contract and the adopter config
97
+ * schema stay untouched (a core-registry-local decision), and
98
+ * `tests/checks/no-privileged-api.test.ts` already guards that a core
99
+ * `CheckSpec` object carries no field a config-derived one cannot — adding
100
+ * `ring` as a real property on the spec would trip that guard, which is
101
+ * exactly the invariant this task must not break. Paired here as a 2-tuple
102
+ * instead: `REGISTRY`'s element type is `readonly [CheckSpec, 0 | 1 | 2]`, so
103
+ * omitting the ring for a new entry is a tuple-arity type error, not a
104
+ * silent gap — the typechecker forces completeness without the annotation
105
+ * ever reaching the runtime object.
106
+ */
107
+ export type CoreCheckRing = 0 | 1 | 2
108
+
109
+ /**
110
+ * The core Vinaya gates an adopter's repo actually runs, expressed as ordinary
111
+ * `CheckSpec`s — the exact shape a `vinaya.config.json` entry produces. No
112
+ * extra field, no privileged flag: this IS the no-privileged-API proof, not
113
+ * a stylistic choice. See `tests/checks/no-privileged-api.test.ts`.
114
+ *
115
+ * `reader-resolvable-prose`/`retired-vocabulary`: both
116
+ * used to be excluded here because they hardcoded this monorepo's own
117
+ * doctrine layout — a scope-registration decision, not a pathing bug. Both
118
+ * bins now read their doctrine root, reader-facing globs, and legacy-slug
119
+ * corpus from `vinaya.config.json`'s `proseGates` key (`lib/config.ts`),
120
+ * defaulting to this repo's own prior hardcoded shape when unset, so an
121
+ * install that sets nothing behaves exactly as before this task. Both
122
+ * registered report-only (`harness/processes/vinaya-strict/doctrine/enforcement.md`'s G1/G2 precedent) — a
123
+ * `warning` finding, never a failing exit code — so registering them could
124
+ * not newly fail any existing install's CI. `retired-vocabulary` has since
125
+ * turned blocking, once the shipped doctrine tree it sweeps carried zero
126
+ * findings.
127
+ *
128
+ * Each entry is paired with its ring in `REGISTRY` below — see
129
+ * `CoreCheckRing`'s doc comment for how the ring is derived and why it is
130
+ * not a field on the spec itself.
131
+ */
132
+ const REGISTRY: ReadonlyArray<readonly [CheckSpec, CoreCheckRing]> = [
133
+ [
134
+ {
135
+ name: 'brief-shape',
136
+ validates: 'body',
137
+ requiresOpenPr: true,
138
+ run: bin('check-brief-shape'),
139
+ scope: 'diff',
140
+ timeoutMs: 15_000,
141
+ // `process.env.PR_BODY ?? ''` / `process.env.BRANCH ?? ''` — both
142
+ // plain absence-tolerant fall-throughs. Without BRANCH declared here
143
+ // the runner strips it before the child spawns and the non-task/
144
+ // non-brief bypass and requireClosesN gating never fire.
145
+ // `PR_NUMBER` (task 10 round-2 ruling addendum 1) gates
146
+ // BRIEF_RULES_SINCE_PR grandfathering — without it declared here the
147
+ // runner strips it too, and every PR reads as "no PR number", which
148
+ // this check's own logic treats as NOT grandfathered (fail-closed).
149
+ // `GITHUB_TOKEN`/`GH_TOKEN` are what let a
150
+ // task branch's objectives checks `gh issue view` the linked Issue's
151
+ // live `## Objectives` section — without them declared here the
152
+ // runner strips them, and the fetch fails every time regardless of
153
+ // the real token the CI job holds.
154
+ // VINAYA_FORGE_SNAPSHOT_DIR/GITHUB_ACTIONS: in CI this check reads the
155
+ // pull request and its task Issue from the run's forge snapshot
156
+ // (`lib/forge-snapshot.ts`), honoured only when GITHUB_ACTIONS is
157
+ // `true`; undeclared, the runner strips both and every read goes to
158
+ // `gh` again.
159
+ env: {
160
+ PR_BODY: { optional: true },
161
+ BRANCH: { optional: true },
162
+ PR_NUMBER: { optional: true },
163
+ GITHUB_TOKEN: { optional: true },
164
+ GH_TOKEN: { optional: true },
165
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
166
+ GITHUB_ACTIONS: { optional: true }
167
+ }
168
+ },
169
+ 0
170
+ ],
171
+ [
172
+ {
173
+ // Hooks have no body to grade. Pre-write validation still grades the
174
+ // outgoing draft before a pull request exists, as does a named run.
175
+ name: 'pr-report-density',
176
+ validates: 'body',
177
+ requiresOpenPr: true,
178
+ run: bin('check-pr-report-density'),
179
+ scope: 'diff',
180
+ timeoutMs: 15_000,
181
+ env: {
182
+ PR_BODY: { optional: true }
183
+ }
184
+ },
185
+ 0
186
+ ],
187
+ [
188
+ {
189
+ name: 'doc-coverage',
190
+ validates: 'body',
191
+ run: bin('check-doc-coverage'),
192
+ scope: 'diff',
193
+ timeoutMs: 15_000,
194
+ // `resolvePrBody()` falls through to `''` when neither PR_BODY nor
195
+ // PR_BODY_FILE is set — the legitimate ring-0 "no PR exists yet" case.
196
+ // BASE_SHA already defaults via `|| 'origin/main'` in the bin itself.
197
+ // Git sets GIT_INDEX_FILE for both hooks. The generated pre-commit hook
198
+ // additionally supplies VINAYA_COMMIT_HOOK=1, so the bin can add staged
199
+ // files only for that run and retain the committed comparison at push.
200
+ // PR_NUMBER absence takes the bin's own "no PR to evaluate the waiver
201
+ // against yet" bypass (`waiverActive()` returns false) — same shape as
202
+ // `review-gate`'s identical PR_NUMBER declaration below. The bin shells
203
+ // to `gh pr view`/`gh api .../timeline` directly to resolve the
204
+ // `vinaya/waiver:docs` label + its labeling actor, so
205
+ // GITHUB_TOKEN/GH_TOKEN must reach it on a CI runner, where `gh`
206
+ // authenticates only from those env vars. GITHUB_REPOSITORY/
207
+ // GITHUB_TOKEN/GH_TOKEN also feed the Principal read
208
+ // (`resolveTrustedPrincipals`, lib/config.ts) — a `gh api` fetch of
209
+ // `principals` from the DEFAULT BRANCH, never local git. All optional,
210
+ // but there is no built-in Principal to fall back to: once a waiver
211
+ // label is on the pull request, a failed read or a default branch that
212
+ // names no Principal refuses the check, naming the reason or the fix.
213
+ // VINAYA_FORGE_SNAPSHOT_DIR/GITHUB_ACTIONS: the forge snapshot — see
214
+ // `brief-shape` above.
215
+ env: {
216
+ BASE_SHA: { optional: true },
217
+ GIT_INDEX_FILE: { optional: true },
218
+ VINAYA_COMMIT_HOOK: { optional: true },
219
+ PR_BODY: { optional: true },
220
+ PR_BODY_FILE: { optional: true },
221
+ PR_NUMBER: { optional: true },
222
+ GITHUB_REPOSITORY: { optional: true },
223
+ GITHUB_TOKEN: { optional: true },
224
+ GH_TOKEN: { optional: true },
225
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
226
+ GITHUB_ACTIONS: { optional: true }
227
+ }
228
+ },
229
+ 0
230
+ ],
231
+ [
232
+ {
233
+ name: 'coherence',
234
+ run: bin('check-coherence'),
235
+ scope: 'full',
236
+ timeoutMs: 30_000,
237
+ // `resolveToken()`'s three-tier fallback (GITHUB_TOKEN, then GH_TOKEN,
238
+ // then a `gh auth token` subprocess) means neither var is ever
239
+ // hard-required — the subprocess path is the documented reason zero
240
+ // pre-spawn env coverage is the correct outcome here, not a gap.
241
+ // VINAYA_REPO/BRANCH each fall back to `git remote`/`git rev-parse`.
242
+ env: {
243
+ VINAYA_REPO: { optional: true },
244
+ BRANCH: { optional: true },
245
+ GITHUB_TOKEN: { optional: true },
246
+ GH_TOKEN: { optional: true }
247
+ }
248
+ },
249
+ 0
250
+ ],
251
+ [
252
+ {
253
+ // Second caller of `../premise-reassert-logic.ts`'s `reassertPremiseFile`
254
+ // — re-asserts a pull request BODY's `Premise:` pins,
255
+ // where `dispatch-readiness`'s `PREMISE_FILE` above re-asserts a FILE
256
+ // handed to a dispatch. Triggered by the block's presence alone, on
257
+ // any branch: `PR_BODY` is the same absence-tolerant fall-through
258
+ // `brief-shape`/`pr-report-density` above use, so a PR with no
259
+ // `Premise:` block (the overwhelming majority) is silent, and there is
260
+ // no branch condition anywhere in this check.
261
+ name: 'pr-premise-reassert',
262
+ validates: 'body',
263
+ requiresOpenPr: true,
264
+ run: bin('check-pr-premise-reassert'),
265
+ scope: 'diff',
266
+ timeoutMs: 15_000,
267
+ env: {
268
+ PR_BODY: { optional: true }
269
+ }
270
+ },
271
+ 0
272
+ ],
273
+ [
274
+ {
275
+ name: 'dispatch-readiness',
276
+ run: bin('check-dispatch-readiness'),
277
+ scope: 'full',
278
+ timeoutMs: 30_000,
279
+ // Identical `resolveToken()` three-tier fallback to `coherence` above
280
+ // — same reasoning, same declaration. PREMISE_FILE is a
281
+ // local-file path, not a forge credential — optional, absent by
282
+ // default, and the bin's own re-assertion path never reaches the
283
+ // network on its account.
284
+ // VINAYA_FORGE_SNAPSHOT_DIR/GITHUB_ACTIONS: the forge snapshot — see
285
+ // `brief-shape` above.
286
+ env: {
287
+ VINAYA_REPO: { optional: true },
288
+ BRANCH: { optional: true },
289
+ GITHUB_TOKEN: { optional: true },
290
+ GH_TOKEN: { optional: true },
291
+ PREMISE_FILE: { optional: true },
292
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
293
+ GITHUB_ACTIONS: { optional: true }
294
+ }
295
+ },
296
+ 0
297
+ ],
298
+ [
299
+ {
300
+ name: 'closes-n',
301
+ validates: 'body',
302
+ run: bin('check-closes-n'),
303
+ scope: 'diff',
304
+ timeoutMs: 15_000,
305
+ // Pre-merge-only: needs the open PR's real body to find `Closes #N`.
306
+ // See `CheckSpec.requiresOpenPr`'s doc comment for why the local hooks
307
+ // skip this rather than running it against nothing.
308
+ requiresOpenPr: true,
309
+ // `process.env.PR_BODY ?? ''`; BRANCH/VINAYA_REPO both fall back to git
310
+ // (`rev-parse --abbrev-ref HEAD` / `remote get-url origin`). Tokens
311
+ // forwarded because the bin reaches the forge through
312
+ // `createForgeSource` — same as `branch-topology`'s identical
313
+ // declaration above: the runner spawns each check with only a fixed
314
+ // baseline env, so without explicit forwarding this check has no way
315
+ // to auth to GitHub on a CI runner (found live: passed locally under
316
+ // a developer's own `gh auth login`, failed deterministically in CI
317
+ // with "no topology file found" — a misleading message, since the
318
+ // real cause was an unauthenticated forge read, not a missing file).
319
+ env: {
320
+ BRANCH: { optional: true },
321
+ PR_BODY: { optional: true },
322
+ VINAYA_REPO: { optional: true },
323
+ GITHUB_TOKEN: { optional: true },
324
+ GH_TOKEN: { optional: true }
325
+ }
326
+ },
327
+ // requiresOpenPr: cannot run under the local hook (`--local` skips it) —
328
+ // CI/PR-only, see `CoreCheckRing`'s doc comment.
329
+ 1
330
+ ],
331
+ [
332
+ {
333
+ name: 'single-plan-pr',
334
+ run: bin('check-single-plan-pr'),
335
+ scope: 'diff',
336
+ timeoutMs: 15_000,
337
+ // BASE_SHA defaults to `'origin/main'`; PR_NUMBER's absence takes the
338
+ // explicit `? Number(...) : null` branch — both tolerate absence.
339
+ // Tokens forwarded so the bin's `gh pr list` authenticates on CI
340
+ // runners (fail-open to [] without them — silently vacuous there).
341
+ env: {
342
+ BASE_SHA: { optional: true },
343
+ PR_NUMBER: { optional: true },
344
+ GITHUB_TOKEN: { optional: true },
345
+ GH_TOKEN: { optional: true }
346
+ }
347
+ },
348
+ 0
349
+ ],
350
+ [
351
+ {
352
+ name: 'surface-scope',
353
+ run: bin('check-surface-scope'),
354
+ scope: 'diff',
355
+ timeoutMs: 15_000,
356
+ // Reads the pull request body's `VINAYA:BEYOND-SURFACE` record, which
357
+ // exists only once the pull request is open — the local hooks skip it.
358
+ // See `CheckSpec.requiresOpenPr`'s doc comment.
359
+ requiresOpenPr: true,
360
+ // BASE_SHA defaults to `'origin/main'`; BRANCH defaults to
361
+ // `git rev-parse --abbrev-ref HEAD`. VINAYA_REPO/GITHUB_TOKEN/GH_TOKEN
362
+ // feed the live forge read (topology + Issue body) `gh`/
363
+ // `createForgeSource` need on a CI runner. PR_BODY/PR_BODY_FILE carry
364
+ // the pull request body whose beyond-Surface record this check reads;
365
+ // absent, the body records nothing.
366
+ // VINAYA_FORGE_SNAPSHOT_DIR/GITHUB_ACTIONS: the forge snapshot — see
367
+ // `brief-shape` above.
368
+ env: {
369
+ VINAYA_REPO: { optional: true },
370
+ BASE_SHA: { optional: true },
371
+ BRANCH: { optional: true },
372
+ PR_BODY: { optional: true },
373
+ PR_BODY_FILE: { optional: true },
374
+ GITHUB_TOKEN: { optional: true },
375
+ GH_TOKEN: { optional: true },
376
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
377
+ GITHUB_ACTIONS: { optional: true }
378
+ }
379
+ },
380
+ // requiresOpenPr: cannot run under the local hook (`--local` skips it) —
381
+ // CI/PR-only, see `CoreCheckRing`'s doc comment.
382
+ 1
383
+ ],
384
+ [
385
+ {
386
+ name: 'test-plan',
387
+ validates: 'body',
388
+ run: bin('check-test-plan'),
389
+ scope: 'diff',
390
+ timeoutMs: 15_000,
391
+ // Pre-merge-only: a `[principal]` Test Plan item is, by construction
392
+ // (`roles/developer.md`), never tickable by the Developer that makes
393
+ // the first commit — only the Principal can satisfy it, after review.
394
+ // See `CheckSpec.requiresOpenPr`'s doc comment.
395
+ requiresOpenPr: true,
396
+ // See `CheckSpec.principalOwed`'s doc comment: a run whose ONLY
397
+ // red is this check, failing for the
398
+ // `pending: true` (unticked `[principal]` item) reason, reads green to
399
+ // `vinaya check --all`'s own exit code and to the loop's CI reader.
400
+ // The `[agent]`/structural half stays a real, blocking failure.
401
+ principalOwed: true,
402
+ // `process.env.PR_BODY ?? ''` / `process.env.BRANCH ?? ''` — both
403
+ // plain absence-tolerant fall-throughs. On a task branch the bin reads
404
+ // the task Issue's frozen brief for its `[live]` lines (`gh api`), so
405
+ // GITHUB_TOKEN/GH_TOKEN must reach it on a CI runner, where `gh`
406
+ // authenticates only from those, and GITHUB_REPOSITORY addresses the
407
+ // trust-anchor read of `principals` that picks the brief's author.
408
+ // PULL_REQUEST_HEAD_SHA is the pull request's own head — never the
409
+ // merge ref a `pull_request` run checks out — at which each `[live]`
410
+ // line must have passed. Absent, no record entry matches and every
411
+ // `[live]` line reads unpassed. That red is `pending` here, so this
412
+ // check's own line goes red while `--all`'s exit stays green
413
+ // (`principalOwed`); the merge hold is `principal-test-plan-wait`'s,
414
+ // which grades the same inputs. The loop's `run_checks` supplies the
415
+ // pull request's head (`worktreeCheckEnv`).
416
+ // VINAYA_FORGE_SNAPSHOT_DIR/GITHUB_ACTIONS: the forge snapshot — see
417
+ // `brief-shape` above.
418
+ env: {
419
+ PR_BODY: { optional: true },
420
+ BRANCH: { optional: true },
421
+ PULL_REQUEST_HEAD_SHA: { optional: true },
422
+ GITHUB_REPOSITORY: { optional: true },
423
+ GITHUB_TOKEN: { optional: true },
424
+ GH_TOKEN: { optional: true },
425
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
426
+ GITHUB_ACTIONS: { optional: true }
427
+ }
428
+ },
429
+ // requiresOpenPr — see `closes-n` above.
430
+ 1
431
+ ],
432
+ [
433
+ {
434
+ // Owns the merge condition an unticked `[principal]` Test Plan item
435
+ // represents, as its own independent check — the Principal wants
436
+ // every merge condition to be its own check, so that all green means
437
+ // mergeable, rather than depending on a reviewer to notice this
438
+ // reason buried inside `review-gate`'s own possible failures.
439
+ // Reported by its own job in `vinaya-body-checks.yml`, never by
440
+ // `--all` (see `ownWorkflow` below) — its own workflow re-runs on a
441
+ // PR body edit (ticking a box), unlike `review-gate`, which a body
442
+ // edit never retriggers.
443
+ name: 'principal-test-plan-wait',
444
+ validates: 'body',
445
+ run: bin('check-principal-test-plan-wait'),
446
+ scope: 'diff',
447
+ timeoutMs: 15_000,
448
+ // Pre-merge-only: an unticked `[principal]` Test Plan item is never
449
+ // tickable by the Developer's first commit — only the Principal
450
+ // clears it. See `CheckSpec.requiresOpenPr`'s doc comment.
451
+ requiresOpenPr: true,
452
+ // Reported by its own dedicated job in the generated
453
+ // `vinaya-body-checks.yml` — `--all` must never evaluate it a second
454
+ // time, the same reasoning `review-gate`/`body-bare-digits` document
455
+ // on their own entries: a second copy inside `--all` would put this
456
+ // check's red inside another check's name.
457
+ ownWorkflow: true,
458
+ // Deliberately NOT `principalOwed`, unlike `test-plan` above. That flag
459
+ // would make this check's red read green to the mechanical gate and the
460
+ // loop's CI reader — and holding the merge until the box is ticked is
461
+ // this check's entire job. Its one all-`pending` error still never
462
+ // refuses a forge-write: the write path excludes that by reading
463
+ // `CheckError.pending` alone (`isPendingOnlyFailure`,
464
+ // `harness/processes/vinaya-strict/tools/task-contract/forge/forge-write.ts`), so the per-round Evidence splice
465
+ // goes through while the box is still unticked and the Principal's tick
466
+ // then finds a fresh block rather than the template placeholder.
467
+ // The same inputs as `test-plan`'s declaration above, for the same
468
+ // reason: on a task branch the bin reads the frozen brief's `[live]`
469
+ // lines and holds the merge on each with no passed entry at
470
+ // PULL_REQUEST_HEAD_SHA, and a brief it cannot read holds it too.
471
+ // VINAYA_FORGE_SNAPSHOT_DIR/GITHUB_ACTIONS: the forge snapshot — see
472
+ // `brief-shape` above.
473
+ env: {
474
+ PR_BODY: { optional: true },
475
+ BRANCH: { optional: true },
476
+ PULL_REQUEST_HEAD_SHA: { optional: true },
477
+ GITHUB_REPOSITORY: { optional: true },
478
+ GITHUB_TOKEN: { optional: true },
479
+ GH_TOKEN: { optional: true },
480
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
481
+ GITHUB_ACTIONS: { optional: true }
482
+ }
483
+ },
484
+ // requiresOpenPr AND ownWorkflow — CI/PR-only twice over, same as
485
+ // `body-bare-digits` below.
486
+ 1
487
+ ],
488
+ [
489
+ {
490
+ name: 'body-bare-digits',
491
+ validates: 'body',
492
+ run: bin('check-body-bare-digits'),
493
+ scope: 'diff',
494
+ timeoutMs: 15_000,
495
+ // Pre-merge-only: reads the open PR's real body, same reasoning as
496
+ // `closes-n`/`test-plan`/`evidence-fresh` above — nothing to scan
497
+ // before a PR (hence its body) exists.
498
+ requiresOpenPr: true,
499
+ // Reported by the generated `vinaya-body-checks.yml`, a
500
+ // `pull_request_target` job — `check --all` must not evaluate it a
501
+ // second time from `vinaya-checks.yml`'s `pull_request` job: that copy
502
+ // cannot safely resolve the Changesets-release exemption (its
503
+ // PR_NUMBER/BRANCH are PR-editable), same reasoning as `review-gate`'s
504
+ // own `ownWorkflow` entry above.
505
+ ownWorkflow: true,
506
+ // `process.env.PR_BODY ?? ''` — plain absence-tolerant fall-through.
507
+ // PR_NUMBER/GITHUB_TOKEN/GH_TOKEN back the live `gh pr view` fetch the
508
+ // Changesets-release exemption needs (bin's own module comment) —
509
+ // same reasoning as `review-gate`'s entry: on a CI runner `gh`
510
+ // authenticates ONLY from GH_TOKEN/GITHUB_TOKEN, and PR_AUTHOR is
511
+ // deliberately never declared here (registry-env.test.ts's coupling
512
+ // test bans any check bin from reading it from env at all).
513
+ // GITHUB_REPOSITORY addresses the trust-anchor read
514
+ // (`loadTrustAnchorConfig`, lib/config.ts) — a `gh api` fetch of
515
+ // `releaseActor` from the DEFAULT BRANCH, same as `review-gate`'s own
516
+ // entry. Found live in code review: omitted here, the runner
517
+ // strips it before the check ever runs, and the trust-anchor read
518
+ // silently falls to its local-dev fallback path on every CI run.
519
+ // VINAYA_FORGE_SNAPSHOT_DIR/GITHUB_ACTIONS: the forge snapshot — see
520
+ // `brief-shape` above.
521
+ env: {
522
+ PR_BODY: { optional: true },
523
+ PR_NUMBER: { optional: true },
524
+ GITHUB_REPOSITORY: { optional: true },
525
+ GITHUB_TOKEN: { optional: true },
526
+ GH_TOKEN: { optional: true },
527
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
528
+ GITHUB_ACTIONS: { optional: true }
529
+ }
530
+ },
531
+ // requiresOpenPr AND ownWorkflow — CI/PR-only twice over.
532
+ 1
533
+ ],
534
+ [
535
+ {
536
+ name: 'no-disk-state',
537
+ run: bin('check-no-disk-state'),
538
+ scope: 'diff',
539
+ timeoutMs: 15_000,
540
+ // BASE_SHA defaults to `'origin/main'`, with a further `main...HEAD`
541
+ // fallback in the bin itself when that yields no files.
542
+ env: { BASE_SHA: { optional: true } }
543
+ },
544
+ 0
545
+ ],
546
+ [
547
+ {
548
+ name: 'registry-gates',
549
+ run: bin('check-registry-gates'),
550
+ scope: 'full',
551
+ timeoutMs: 30_000,
552
+ // `resolveRepo()`'s only env read; falls back to `git remote get-url
553
+ // origin` when unset. The bin is otherwise dormant (exit 0) when
554
+ // `harness/processes/vinaya-strict/doctrine/enforcement.md` doesn't exist — no other env dependency.
555
+ // Tokens forwarded so its `gh auth status` / `gh issue|pr view`
556
+ // string-form shell-outs authenticate on CI runners (without them
557
+ // `ghReachable()` reports false there and the forge-number
558
+ // resolution degrades, exactly like the execFileSync siblings).
559
+ env: {
560
+ VINAYA_REPO: { optional: true },
561
+ GITHUB_TOKEN: { optional: true },
562
+ GH_TOKEN: { optional: true }
563
+ }
564
+ },
565
+ 0
566
+ ],
567
+ [
568
+ {
569
+ name: 'review-gate',
570
+ run: bin('check-review-gate'),
571
+ scope: 'full',
572
+ timeoutMs: 30_000,
573
+ // Reported by the generated `vinaya-review.yml`, which the verdict
574
+ // workflow re-runs when a verdict comment lands. `check --all` must not
575
+ // evaluate it a second time: nothing re-runs `vinaya-checks.yml`, so
576
+ // that copy freezes at push-time verdicts and stays red after an
577
+ // approval — measured live.
578
+ ownWorkflow: true,
579
+ // PR_NUMBER's absence takes the explicit "no PR to evaluate yet
580
+ // (local dev, pre-push before a PR exists)"
581
+ // bypass documented in the bin's own module comment. The bin shells
582
+ // to `gh` directly (no `resolveToken()`), and on a CI runner `gh`
583
+ // authenticates ONLY from GH_TOKEN/GITHUB_TOKEN — without forwarding
584
+ // them the allowlist strips the workflow-provided token and every
585
+ // `gh pr view` fails. Optional because local runs use `gh`'s own
586
+ // keyring auth with no env var at all. GITHUB_REPOSITORY addresses the
587
+ // Principal read (`resolveTrustedPrincipals`, lib/config.ts) — a `gh
588
+ // api` fetch of `principals` from the DEFAULT BRANCH, which refuses the
589
+ // check when it fails or names no Principal — and the trust-anchor read
590
+ // of the review policy (`loadTrustAnchorConfig`).
591
+ //
592
+ // Deliberately NO `BASE_SHA` here, and no other ref-shaped knob: a
593
+ // `BASE_SHA` declaration was tried and reverted (a security-review
594
+ // finding) because a `pull_request`-triggered workflow runs the
595
+ // PR's own PR-editable YAML, so any ref this check accepts as an
596
+ // override is attacker-steerable and reopens the self-approval hole.
597
+ // GITHUB_REPOSITORY is not the same thing: it names WHICH repo to ask
598
+ // GitHub about, is runner-set in the only context where this is a trust
599
+ // decision, and never selects a commit — see `trustAnchorRepo`.
600
+ // VINAYA_FORGE_SNAPSHOT_DIR/GITHUB_ACTIONS: the forge snapshot — see
601
+ // `brief-shape` above. Not a ref-shaped knob either: it names a
602
+ // directory a default-branch step of the same trusted workflow wrote,
603
+ // and it selects no commit and no trust anchor.
604
+ env: {
605
+ PR_NUMBER: { optional: true },
606
+ GITHUB_REPOSITORY: { optional: true },
607
+ GITHUB_TOKEN: { optional: true },
608
+ GH_TOKEN: { optional: true },
609
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
610
+ GITHUB_ACTIONS: { optional: true }
611
+ }
612
+ },
613
+ // ownWorkflow — see `body-bare-digits` above.
614
+ 1
615
+ ],
616
+ [
617
+ {
618
+ name: 'branch-topology',
619
+ run: bin('check-branch-topology'),
620
+ scope: 'full',
621
+ timeoutMs: 30_000,
622
+ // BRANCH falls back to git; VINAYA_REPO falls back to `git remote`.
623
+ // Tokens forwarded because the bin reaches the forge through
624
+ // `createForgeSource` → the forge-state modules' token resolution (`tools/task-contract/forge/`)
625
+ // (GITHUB_TOKEN, then GH_TOKEN, then a `gh auth token` subprocess)
626
+ // — the subprocess tier fails on CI runners, so without forwarding
627
+ // the check cannot reach the forge there. Same reasoning as
628
+ // `coherence`/`dispatch-readiness` above.
629
+ env: {
630
+ BRANCH: { optional: true },
631
+ VINAYA_REPO: { optional: true },
632
+ GITHUB_TOKEN: { optional: true },
633
+ GH_TOKEN: { optional: true }
634
+ }
635
+ },
636
+ 0
637
+ ],
638
+ [
639
+ {
640
+ name: 'dead-branch-push',
641
+ run: bin('check-dead-branch-push'),
642
+ scope: 'full',
643
+ timeoutMs: 30_000,
644
+ // BRANCH falls back to `git rev-parse --abbrev-ref HEAD`; the bin's
645
+ // own module comment documents fail-open (UNKNOWN → allow) for every
646
+ // other forge-reachability gap, unrelated to env absence. Tokens
647
+ // forwarded so `gh pr list` authenticates on CI runners instead of
648
+ // taking that UNKNOWN branch on every run.
649
+ env: {
650
+ BRANCH: { optional: true },
651
+ GITHUB_TOKEN: { optional: true },
652
+ GH_TOKEN: { optional: true }
653
+ }
654
+ },
655
+ 0
656
+ ],
657
+ [
658
+ {
659
+ name: 'first-push-dispatch',
660
+ run: bin('check-first-push-dispatch'),
661
+ scope: 'full',
662
+ timeoutMs: 30_000,
663
+ // BRANCH/VINAYA_REPO fall back to git; GITHUB_TOKEN/GH_TOKEN read as
664
+ // `process.env.GITHUB_TOKEN || process.env.GH_TOKEN || ''` inside
665
+ // `classifyReadiness` — absence degrades to an empty token, which
666
+ // `fetchOpenIssuesByLabel` tolerates (fail-open, per the bin's own
667
+ // module comment on forge-reachability failures).
668
+ env: {
669
+ BRANCH: { optional: true },
670
+ VINAYA_REPO: { optional: true },
671
+ GITHUB_TOKEN: { optional: true },
672
+ GH_TOKEN: { optional: true }
673
+ }
674
+ },
675
+ 0
676
+ ],
677
+ [
678
+ {
679
+ name: 'doc-coverage-push',
680
+ validates: 'body',
681
+ advisory: true,
682
+ run: bin('check-doc-coverage-push'),
683
+ scope: 'diff',
684
+ timeoutMs: 15_000,
685
+ // Same `resolvePrBody()`/BASE_SHA/PR_LABELS/WAIVER_LABEL_ACTOR
686
+ // absence-tolerance as `doc-coverage` above, plus OVERRIDE_DOCS
687
+ // (`overrideActive()`'s first, env-only check) which is opt-in by
688
+ // design — absence is the default, unremarkable path.
689
+ // GITHUB_REPOSITORY/GITHUB_TOKEN/GH_TOKEN: same trust-anchor read as
690
+ // `doc-coverage` above — see that entry's comment. Changed paths and
691
+ // per-file evidence supplement the committed diff only when both
692
+ // pre-commit hook variables are set; push and CI stay committed-only.
693
+ env: {
694
+ OVERRIDE_DOCS: { optional: true },
695
+ BASE_SHA: { optional: true },
696
+ GIT_INDEX_FILE: { optional: true },
697
+ VINAYA_COMMIT_HOOK: { optional: true },
698
+ PR_BODY: { optional: true },
699
+ PR_BODY_FILE: { optional: true },
700
+ PR_LABELS: { optional: true },
701
+ WAIVER_LABEL_ACTOR: { optional: true },
702
+ GITHUB_REPOSITORY: { optional: true },
703
+ GITHUB_TOKEN: { optional: true },
704
+ GH_TOKEN: { optional: true }
705
+ }
706
+ },
707
+ 0
708
+ ],
709
+ [
710
+ {
711
+ name: 'evidence-fresh',
712
+ validates: 'body',
713
+ run: bin('check-evidence-fresh'),
714
+ scope: 'diff',
715
+ timeoutMs: 15_000,
716
+ // Pre-merge-only: meaningless before a PR exists to resolve a real
717
+ // head against. Same reasoning as `closes-n`/`test-plan` above.
718
+ requiresOpenPr: true,
719
+ // The bin shells to `gh pr view --json headRefOid` to resolve the real
720
+ // PR head (never `HEAD`, which is the merge commit in CI — see the
721
+ // bin's own module comment), so GITHUB_TOKEN/GH_TOKEN must reach it on
722
+ // a CI runner. PR_NUMBER/PR_BODY absence both take documented
723
+ // ring-0/no-PR bypasses in the bin. BASE_SHA overrides the
724
+ // `origin/main`/`main` merge-base resolution — same declaration as
725
+ // `doc-coverage`/`doc-coverage-push`/`no-disk-state`/`single-plan-pr`
726
+ // above (`closes-n` declares no BASE_SHA and resolves no merge-base) —
727
+ // for a repo whose default branch resolves as neither.
728
+ // VINAYA_FORGE_SNAPSHOT_DIR/GITHUB_ACTIONS: the forge snapshot — see
729
+ // `brief-shape` above.
730
+ env: {
731
+ PR_NUMBER: { optional: true },
732
+ PR_BODY: { optional: true },
733
+ BASE_SHA: { optional: true },
734
+ GITHUB_TOKEN: { optional: true },
735
+ GH_TOKEN: { optional: true },
736
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
737
+ GITHUB_ACTIONS: { optional: true }
738
+ }
739
+ },
740
+ // requiresOpenPr — see `closes-n` above.
741
+ 1
742
+ ],
743
+ [
744
+ {
745
+ name: 'reader-resolvable-prose',
746
+ run: bin('check-reader-resolvable-prose'),
747
+ scope: 'full',
748
+ timeoutMs: 30_000,
749
+ // Reads local files plus the shared diff helper. BASE_SHA scopes that
750
+ // helper's diff; the hook variables let it add staged evidence only
751
+ // during pre-commit.
752
+ env: {
753
+ BASE_SHA: { optional: true },
754
+ GIT_INDEX_FILE: { optional: true },
755
+ VINAYA_COMMIT_HOOK: { optional: true }
756
+ },
757
+ // An `include` declaration on a `scope: 'full'` entry
758
+ // is currently pinning/documentation only (`runner.ts`'s `shouldSkip`
759
+ // returns early for any non-`'diff'` scope, before ever consulting
760
+ // `include`) — see this task's own PR body for that known gap and why
761
+ // `runner.ts` is out of this task's surface. Declared anyway so the
762
+ // sweep's real scope is legible here, and so a future `runner.ts`
763
+ // change that extends `--diff-only` skipping to `scope: 'full'` finds
764
+ // this already correct.
765
+ //
766
+ // The four product-code globs below mirror
767
+ // `PRODUCT_SLUG_SCOPE` in `reader-resolvable-prose.ts` — the surface
768
+ // whose tranche-slug citation is now this check's one blocking class.
769
+ include: [...DOCTRINE_REPO_PATHS, 'apps/cli/src/**', '.github/workflows/**', '.vinaya/**', 'apps/cli/README.md']
770
+ },
771
+ 0
772
+ ],
773
+ [
774
+ {
775
+ name: 'retired-vocabulary',
776
+ run: bin('check-retired-vocabulary'),
777
+ scope: 'full',
778
+ timeoutMs: 30_000,
779
+ // Same shared-diff declarations as `reader-resolvable-prose`: BASE_SHA
780
+ // plus the two hook variables.
781
+ env: {
782
+ BASE_SHA: { optional: true },
783
+ GIT_INDEX_FILE: { optional: true },
784
+ VINAYA_COMMIT_HOOK: { optional: true }
785
+ },
786
+ // See `reader-resolvable-prose`'s identical `include` comment above.
787
+ include: [...DOCTRINE_REPO_PATHS]
788
+ },
789
+ 0
790
+ ],
791
+ [
792
+ {
793
+ name: 'doctrine-portability',
794
+ advisory: true,
795
+ run: bin('check-doctrine-portability'),
796
+ scope: 'full',
797
+ timeoutMs: 30_000,
798
+ // Local-only: `git ls-tree`/`git show` and the shared diff helper read
799
+ // the already-fetched local repository, never the network.
800
+ // BASE_SHA overrides the `origin/main` baseline ref, same declaration
801
+ // as `doc-coverage`/`no-disk-state`/`evidence-fresh` above.
802
+ env: {
803
+ BASE_SHA: { optional: true },
804
+ GIT_INDEX_FILE: { optional: true },
805
+ VINAYA_COMMIT_HOOK: { optional: true }
806
+ },
807
+ // See `reader-resolvable-prose`'s identical `include` comment above.
808
+ include: [...DOCTRINE_REPO_PATHS]
809
+ },
810
+ 0
811
+ ],
812
+ [
813
+ {
814
+ name: 'doctrine-no-procedures',
815
+ run: bin('check-doctrine-no-procedures'),
816
+ scope: 'full',
817
+ timeoutMs: 30_000,
818
+ // Local-only: walks `<doctrineRoot>` with `node:fs`, never the
819
+ // network, `gh`, or a PR-scoped fact — no forge call, no PR content.
820
+ env: {},
821
+ // See `reader-resolvable-prose`'s identical `include` comment above.
822
+ include: [...DOCTRINE_REPO_PATHS]
823
+ },
824
+ 0
825
+ ],
826
+ [
827
+ {
828
+ name: 'doc-claims',
829
+ run: bin('check-doc-claims'),
830
+ scope: 'full',
831
+ timeoutMs: 30_000,
832
+ // Local-only: `git ls-files` and tracked-file reads, never the
833
+ // network, `gh`, or a PR-scoped fact — no forge call, no PR content.
834
+ env: {},
835
+ // See `reader-resolvable-prose`'s identical `include` comment above.
836
+ // The corpus the bin sweeps; a binding goes stale when its CITED file
837
+ // changes, which may sit anywhere in the repository. The registry is
838
+ // static and never reads configuration, so this lists the default
839
+ // doctrine root; the bin derives the configured one.
840
+ include: [...DOCTRINE_REPO_PATHS, 'apps/**/*.ts', 'apps/**/*.md', 'packages/**/*.ts', 'packages/**/*.md']
841
+ },
842
+ 0
843
+ ],
844
+ [
845
+ {
846
+ name: 'exec-bits',
847
+ run: bin('check-exec-bits'),
848
+ scope: 'diff',
849
+ timeoutMs: 30_000,
850
+ // Local-only: `git ls-files -s`, a first-line read, and the shared diff
851
+ // helper; BASE_SHA scopes its diff and the hook variables admit staged
852
+ // evidence only at pre-commit.
853
+ env: {
854
+ BASE_SHA: { optional: true },
855
+ GIT_INDEX_FILE: { optional: true },
856
+ VINAYA_COMMIT_HOOK: { optional: true }
857
+ }
858
+ },
859
+ 0
860
+ ],
861
+ [
862
+ {
863
+ // Refuses new CLI tests absent from every shard list. No include glob:
864
+ // pre-commit reads additions and shard lists from the index under both
865
+ // hook markers; push and CI judge committed branch additions against
866
+ // HEAD's shard lists, or all tracked CLI tests if no diff resolves.
867
+ name: 'ci-shard-coverage',
868
+ run: bin('check-ci-shard-coverage'),
869
+ scope: 'diff',
870
+ timeoutMs: 15_000,
871
+ // Local-only: `git diff --cached`/`git show :<path>` plus the shared
872
+ // diff helper, never the network. BASE_SHA scopes that helper's diff;
873
+ // the hook variables admit staged evidence only at pre-commit.
874
+ env: {
875
+ BASE_SHA: { optional: true },
876
+ GIT_INDEX_FILE: { optional: true },
877
+ VINAYA_COMMIT_HOOK: { optional: true }
878
+ }
879
+ },
880
+ 0
881
+ ],
882
+ [
883
+ {
884
+ name: 'workspace-escape',
885
+ advisory: true,
886
+ run: bin('check-workspace-escape'),
887
+ scope: 'full',
888
+ timeoutMs: 30_000,
889
+ // Local-only: walks the working tree and consults the shared diff
890
+ // helper; BASE_SHA scopes its diff and the hook variables admit staged
891
+ // evidence only at pre-commit.
892
+ env: {
893
+ BASE_SHA: { optional: true },
894
+ GIT_INDEX_FILE: { optional: true },
895
+ VINAYA_COMMIT_HOOK: { optional: true }
896
+ },
897
+ // See `reader-resolvable-prose`'s identical `include` comment above —
898
+ // named here per the Issue's own list even though this sweep's real
899
+ // domain is `apps`/`packages`, not the doctrine under `harness/processes/vinaya-strict`; harmless either way
900
+ // while `include` has no runtime effect on a `scope: 'full'` entry.
901
+ include: [...DOCTRINE_REPO_PATHS]
902
+ },
903
+ 0
904
+ ],
905
+ [
906
+ {
907
+ name: 'changeset-coverage',
908
+ run: bin('check-changeset-coverage'),
909
+ scope: 'diff',
910
+ timeoutMs: 15_000,
911
+ // Local-only: `.changeset/config.json`, every fixed-group member's own
912
+ // `package.json`, and the shared diff all come from the already-local
913
+ // working tree and `git`. BASE_SHA scopes the diff; the hook variables
914
+ // admit staged evidence only at pre-commit. Blocking on a finding (see
915
+ // the bin's doc).
916
+ env: {
917
+ BASE_SHA: { optional: true },
918
+ GIT_INDEX_FILE: { optional: true },
919
+ VINAYA_COMMIT_HOOK: { optional: true }
920
+ }
921
+ },
922
+ 0
923
+ ],
924
+ [
925
+ {
926
+ name: 'quoted-command',
927
+ advisory: true,
928
+ run: bin('check-quoted-command'),
929
+ scope: 'full',
930
+ timeoutMs: 15_000,
931
+ // Local-only: sweeps `<doctrineRoot>/**` (and any configured
932
+ // reader-facing pages) for `VINAYA:QUOTES-FILE` markers, then reads each
933
+ // marker's cited file straight off the already-checked-out working
934
+ // tree — no forge call, no PR content. Report-only (severity: warning,
935
+ // exit 0 always — see the bin's own module doc), same rollout
936
+ // precedent as changeset-coverage/reader-resolvable-prose above:
937
+ // registering it must not newly redden any existing install. Full
938
+ // scope: the sweep covers the whole doctrine tree whatever the diff.
939
+ env: {},
940
+ // See `reader-resolvable-prose`'s identical `include` comment above.
941
+ include: [...DOCTRINE_REPO_PATHS]
942
+ },
943
+ 0
944
+ ],
945
+ [
946
+ {
947
+ name: 'main-branch-refusal',
948
+ run: bin('check-main-branch-refusal'),
949
+ scope: 'diff',
950
+ timeoutMs: 15_000,
951
+ // Diff scope with no `include`: the commit hook's `--skip-full` skips
952
+ // only full-scope checks and `--diff-only` never skips a diff-scope
953
+ // check without `include` globs, so a commit on the default branch is
954
+ // refused too. Local-only: the facts (`symbolic-ref --short HEAD`, the
955
+ // remote-tracking refs of origin) read
956
+ // already-local git state — no forge call, no PR content, same `env: {}` shape as
957
+ // `workspace-escape` above. `VINAYA_PUSH_REFS` is the
958
+ // one exception: the generated pre-push hook sets it from git's own
959
+ // pre-push stdin before spawning `check --all --local`, and without
960
+ // it in this allowlist `buildCheckEnv` strips it before the check
961
+ // subprocess ever sees it — every tag-only push then reads as a plain
962
+ // commit-on-main and refuses. Optional: absent on every non-push
963
+ // invocation (a commit, or a bare `check` run), which the check
964
+ // already treats as "not a push in flight."
965
+ env: { VINAYA_PUSH_REFS: { optional: true } }
966
+ },
967
+ 0
968
+ ],
969
+ [
970
+ {
971
+ name: 'token-collection-wired',
972
+ run: bin('check-token-collection-wired'),
973
+ scope: 'full',
974
+ timeoutMs: 15_000,
975
+ // `resolveMeteringCapability` (`kernel/adapters/agents/claude-code/claude-code-transcript.ts`) reads
976
+ // `CLAUDE_PROJECT_DIR`/`CLAUDE_CODE_SESSION_ID` directly — both must be
977
+ // declared or the runner strips them before spawn (the same env-stripping
978
+ // trap `brief-shape`'s `BRANCH` comment above names) and the pointer-file
979
+ // resolution silently falls back to `cwd`/no-staleness-check on every
980
+ // hook run. `TMPDIR` needs no declaration: it's already in the
981
+ // runner's fixed baseline.
982
+ env: {
983
+ CLAUDE_PROJECT_DIR: { optional: true },
984
+ CLAUDE_CODE_SESSION_ID: { optional: true }
985
+ }
986
+ },
987
+ 0
988
+ ],
989
+ // The five write-only rules named apart — `validates: 'issue'`
990
+ // means each applies only to a task Issue's own content, never a pull
991
+ // request. `ownWorkflow: true`: nothing in `.github/workflows` ever
992
+ // invokes these by name, so `--all` (both `vinaya-checks.yml` and
993
+ // `vinaya-body-checks.yml`, both PULL-REQUEST workflows) never selects
994
+ // them either way — declared for the same reason `review-gate`/
995
+ // `body-bare-digits` declare it: a check that is invoked directly, by
996
+ // name, from somewhere other than `--all`. The executables run by name
997
+ // only from the Issue write gate's runner (`runIssueChecks`); the
998
+ // coherence sweep never spawns one, though its R1 rule calls two of their
999
+ // rule functions directly (`checkIssueObjectives`,
1000
+ // `checkPartsCiteDefinedObjectives`).
1001
+ [
1002
+ {
1003
+ name: 'issue-title-grammar',
1004
+ run: bin('check-issue-title-grammar'),
1005
+ validates: 'issue',
1006
+ scope: 'full',
1007
+ ownWorkflow: true,
1008
+ timeoutMs: 15_000,
1009
+ env: { ISSUE_TITLE: { optional: true } }
1010
+ },
1011
+ 1
1012
+ ],
1013
+ [
1014
+ {
1015
+ name: 'issue-objectives-numbering',
1016
+ run: bin('check-issue-objectives-numbering'),
1017
+ validates: 'issue',
1018
+ scope: 'full',
1019
+ ownWorkflow: true,
1020
+ timeoutMs: 15_000,
1021
+ env: { ISSUE_BODY: { optional: true }, ISSUE_NUMBER: { optional: true } }
1022
+ },
1023
+ 1
1024
+ ],
1025
+ [
1026
+ {
1027
+ name: 'issue-parts-coverage',
1028
+ run: bin('check-issue-parts-coverage'),
1029
+ validates: 'issue',
1030
+ scope: 'full',
1031
+ ownWorkflow: true,
1032
+ timeoutMs: 15_000,
1033
+ env: { ISSUE_BODY: { optional: true } }
1034
+ },
1035
+ 1
1036
+ ],
1037
+ [
1038
+ {
1039
+ name: 'issue-surface-globs',
1040
+ run: bin('check-issue-surface-globs'),
1041
+ validates: 'issue',
1042
+ scope: 'full',
1043
+ ownWorkflow: true,
1044
+ timeoutMs: 15_000,
1045
+ env: { ISSUE_BODY: { optional: true } }
1046
+ },
1047
+ 1
1048
+ ],
1049
+ [
1050
+ {
1051
+ name: 'issue-milestone-attach',
1052
+ run: bin('check-issue-milestone-attach'),
1053
+ validates: 'issue',
1054
+ scope: 'full',
1055
+ ownWorkflow: true,
1056
+ timeoutMs: 15_000,
1057
+ env: {
1058
+ ISSUE_LABELS: { optional: true },
1059
+ CURRENT_MILESTONE_TITLE: { optional: true },
1060
+ RESOLVED_MILESTONE_TITLE: { optional: true }
1061
+ }
1062
+ },
1063
+ 1
1064
+ ]
1065
+ ]
1066
+
1067
+ /** The exact `CheckSpec[]` shape `vinaya.config.json` also produces — no
1068
+ * extra field, no privileged flag. See `no-privileged-api.test.ts`. */
1069
+ export function coreCheckRegistry(): CheckSpec[] {
1070
+ return REGISTRY.map(([spec]) => spec)
1071
+ }
1072
+
1073
+ /** `name` -> `ring`, derived from the same `REGISTRY` pairing `coreCheckRegistry()`
1074
+ * reads — never out of sync with it by construction. Consulted by
1075
+ * `harness/processes/vinaya-strict/checks/registry-scaffold.ts` indirectly, through the
1076
+ * process-local mirror in `gate-audience.ts` (that module cannot import this
1077
+ * module — see that file's own doc comment for why); `gate-audience.test.ts`-
1078
+ * style coupling assertions in this package keep the two in sync. */
1079
+ export const CORE_CHECK_RING: Readonly<Record<string, CoreCheckRing>> = Object.fromEntries(
1080
+ REGISTRY.map(([spec, ring]) => [spec.name, ring])
1081
+ )
1082
+
1083
+ export function installVinayaCheckRegistry(): void {
1084
+ installCheckRegistry(coreCheckRegistry())
1085
+ }