@attalabs/vinaya 0.34.0 → 0.36.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 (131) hide show
  1. package/LICENSE +104 -201
  2. package/README.md +1 -1
  3. package/aeg-root/roles/planner/reference.md +21 -6
  4. package/aeg-root/roles/planner.md +2 -0
  5. package/aeg-root/roles/reviewer.md +3 -1
  6. package/aeg-root/templates/brief-template.md +4 -0
  7. package/dist/checks/bin/check-body-bare-digits.js +1450 -1350
  8. package/dist/checks/bin/check-branch-topology.js +1432 -1342
  9. package/dist/checks/bin/check-brief-shape.js +1451 -1351
  10. package/dist/checks/bin/check-changeset-coverage.js +1502 -1360
  11. package/dist/checks/bin/check-closes-n.js +1432 -1342
  12. package/dist/checks/bin/check-coherence.js +1472 -1351
  13. package/dist/checks/bin/check-dead-branch-push.js +1408 -1339
  14. package/dist/checks/bin/check-dispatch-readiness.js +1475 -1354
  15. package/dist/checks/bin/check-doc-coverage-push.js +1502 -1360
  16. package/dist/checks/bin/check-doc-coverage.js +1504 -1362
  17. package/dist/checks/bin/check-doctrine-no-procedures.js +1449 -1349
  18. package/dist/checks/bin/check-doctrine-portability.js +1502 -1360
  19. package/dist/checks/bin/check-evidence-fresh.js +1508 -1366
  20. package/dist/checks/bin/check-exec-bits.js +1502 -1360
  21. package/dist/checks/bin/check-first-push-dispatch.js +1476 -1355
  22. package/dist/checks/bin/check-issue-assignment.js +1432 -1342
  23. package/dist/checks/bin/check-issue-milestone-attach.js +1408 -1339
  24. package/dist/checks/bin/check-issue-objectives-numbering.js +1449 -1349
  25. package/dist/checks/bin/check-issue-parts-coverage.js +1408 -1339
  26. package/dist/checks/bin/check-issue-surface-globs.js +1475 -1354
  27. package/dist/checks/bin/check-issue-title-grammar.js +1408 -1339
  28. package/dist/checks/bin/check-issue-tranche-label.js +1408 -1339
  29. package/dist/checks/bin/check-main-branch-refusal.js +1410 -1341
  30. package/dist/checks/bin/check-no-disk-state.js +1410 -1341
  31. package/dist/checks/bin/check-pr-premise-reassert.js +1449 -1349
  32. package/dist/checks/bin/check-pr-report-density.js +1410 -1341
  33. package/dist/checks/bin/check-principal-test-plan-wait.js +1410 -1341
  34. package/dist/checks/bin/check-quoted-command.js +1500 -1358
  35. package/dist/checks/bin/check-reader-resolvable-prose.js +1500 -1358
  36. package/dist/checks/bin/check-registry-gates.js +1410 -1341
  37. package/dist/checks/bin/check-retired-vocabulary.js +1500 -1358
  38. package/dist/checks/bin/check-review-gate.js +1463 -1363
  39. package/dist/checks/bin/check-single-plan-pr.js +1408 -1339
  40. package/dist/checks/bin/check-surface-scope.js +1432 -1342
  41. package/dist/checks/bin/check-test-plan.js +1408 -1339
  42. package/dist/checks/bin/check-token-collection-wired.js +1410 -1341
  43. package/dist/checks/bin/check-token-report.js +1410 -1341
  44. package/dist/checks/bin/check-workspace-escape.js +1501 -1359
  45. package/dist/index.js +4261 -1917
  46. package/dist/lib/pre-push-cache-test-run.js +130 -19
  47. package/dist/lib/pre-push-select-tests.js +86 -17
  48. package/package.json +2 -2
  49. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +153 -37
  50. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +87 -24
  51. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +9 -2
  52. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +31 -2
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +1 -0
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +52 -3
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +28 -0
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-cutovers.ts +49 -0
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +13 -2
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +148 -54
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +26 -3
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives-cutover-config.ts +31 -0
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +15 -6
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +122 -23
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +38 -3
  64. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  65. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  66. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  70. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +1 -1
  103. 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
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__07uhu5z._.js → [root-of-the-server]__1wy7w66._.js} +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +2 -2
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  118. 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
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  123. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/00z3-ljjd1gj9.js +1 -0
  124. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2174nz5he_oc4.js → 2o9l0b7eqbr57.js} +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0q9p7c6vn-x2w.js → 3lqjwjrcvq481.js} +4 -4
  126. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  127. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3xnma0-359j17.js +0 -1
  128. /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  129. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{HmoeqXdX1E4drt7GReFOO → z1fTSBP6ZlUjObzFIp-qq}/_buildManifest.js +0 -0
  130. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{HmoeqXdX1E4drt7GReFOO → z1fTSBP6ZlUjObzFIp-qq}/_clientMiddlewareManifest.js +0 -0
  131. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{HmoeqXdX1E4drt7GReFOO → z1fTSBP6ZlUjObzFIp-qq}/_ssgManifest.js +0 -0
@@ -21,15 +21,13 @@
21
21
 
22
22
  import { packagesNamedIn } from './brief-validation'
23
23
  import { deriveSection7 } from './derive-section7'
24
+ import type { GateCutovers } from './gate-cutovers'
24
25
  import {
25
- BRIEF_SECTIONS_SINCE_ISSUE,
26
- DOCUMENTATION_SINCE_ISSUE,
27
26
  globCoversPath,
28
27
  type IssueDocumentation,
29
28
  type IssuePart,
30
29
  type IssueSurface,
31
- type IssueTestPlan,
32
- OBJECTIVES_SINCE_ISSUE
30
+ type IssueTestPlan
33
31
  } from './issue-validation'
34
32
  import { type Objective, renderObjectives } from './objectives'
35
33
  import { applyTierFloor, deriveTierFromDiff, readTierFromPrBody } from './pr-tier'
@@ -252,6 +250,16 @@ export type BriefFacts = {
252
250
  * legitimate explicit opt-out and is rendered, never treated as absent.
253
251
  */
254
252
  documentation: IssueDocumentation
253
+ /**
254
+ * The resolved gate cutovers (`resolveGateCutovers`, `apps/cli/src/lib/config.ts`).
255
+ * The renderer's missing-fact refusal for a missing `## Objectives`/
256
+ * `## Documentation` section grandfathers exactly the same class the Issue
257
+ * gate itself does — an Issue below the cutover legitimately has no such
258
+ * section — so the two never disagree. A `null` field means NO cutover: the
259
+ * section is expected on every Issue, from 1 (a repository that declares no
260
+ * `gateCutovers`, O1).
261
+ */
262
+ cutovers: GateCutovers
255
263
  dispatchReady: boolean
256
264
  dispatchBlockers: string[]
257
265
  surfaceFiles: SurfaceFileFact[]
@@ -271,6 +279,43 @@ export type BriefFacts = {
271
279
  * for the review loop's reviewer-prompt facts.
272
280
  */
273
281
  sourceRevision: string
282
+ /**
283
+ * How the repository this brief is rendered for invokes the Vinaya CLI —
284
+ * `npx --yes @attalabs/vinaya@<version>` for a repository that installs it
285
+ * from the registry, `bun <dir>/src/index.ts` for one that vendors it.
286
+ * Every command this renderer tells the Developer to run is written through
287
+ * it, so no brief ever names a path that exists only in the authoring
288
+ * repository.
289
+ *
290
+ * Passed in as a fact, never detected here: this module reads no
291
+ * environment and no filesystem, and the decision already has one owner —
292
+ * `apps/cli`'s `briefCliInvocation`, over the same vendored-CLI detection
293
+ * the generated hooks and workflows use. Empty refuses the render, the same
294
+ * as `sourceRevision`: a brief whose commands nobody can run is worse than
295
+ * no brief.
296
+ */
297
+ cliInvocation: string
298
+ /**
299
+ * Commands the rendered-for repository ships itself that run an unabridged
300
+ * version of a CLI check this brief names — the CLI's own check being the
301
+ * portable form every reader has, and these being the fuller derivation the
302
+ * authoring repository additionally carries (`dispatch-readiness`'s shipped
303
+ * predicate reports prior-tranche-archival empty; `doc-coverage` evaluates
304
+ * C5 alone, not C1/C3). Each is the program alone, with no arguments — this
305
+ * renderer holds the task's own facts and appends them.
306
+ *
307
+ * `null` for a repository that has only the CLI's own checks, which is every
308
+ * adopter — the brief then names the CLI check and nothing else.
309
+ */
310
+ localGateCommands: LocalGateCommands
311
+ }
312
+
313
+ /** See `BriefFacts.localGateCommands`. */
314
+ export type LocalGateCommands = {
315
+ /** e.g. `bun packages/aeg-core/bin/verify-dispatch.ts`, or `null`. */
316
+ dispatchReadiness: string | null
317
+ /** e.g. `bun packages/aeg-core/bin/verify-docs.ts`, or `null`. */
318
+ docCoverage: string | null
274
319
  }
275
320
 
276
321
  export type RenderResult = { ok: true; brief: string } | { ok: false; missing: string[] }
@@ -311,14 +356,37 @@ function isTestFile(path: string): boolean {
311
356
  return /\.test\.[jt]sx?$/i.test(path)
312
357
  }
313
358
 
359
+ /**
360
+ * A command the template (or this module) writes as a bare `vinaya <args>`,
361
+ * rewritten to the way the rendered-for repository actually invokes the CLI.
362
+ *
363
+ * Scoped to an inline code span's own opening backtick, deliberately: the word
364
+ * `vinaya` also occurs in ordinary prose the Planner wrote (`.vinaya/`, "the
365
+ * Vinaya Log", a Boundary quoting a command by name), and none of that is a
366
+ * command this brief is telling anyone to run.
367
+ */
368
+ function withCliInvocation(text: string, invocation: string): string {
369
+ // The replacement is a REPLACER FUNCTION, never a string: in a string
370
+ // replacement `$&`, `` $` ``, `$'` and `$<name>` are substitution patterns,
371
+ // so an invocation carrying any of them would be expanded rather than
372
+ // copied. `cliInvocation` is an unconstrained `string` on the exported
373
+ // `BriefFacts` — the guards that keep it clean today (`self-host.ts`'s
374
+ // `SAFE_PATH`, `ownVersion`'s semver) live in another package, and this
375
+ // module must not depend on them holding.
376
+ return text.replaceAll('`vinaya ', () => `\`${invocation} `)
377
+ }
378
+
314
379
  function renderHeader(facts: BriefFacts, template: string): string {
315
380
  const introMatch = template.match(/^You are the AEG Developer\.[^\n]*$/m)
381
+ // Left as the template's own bare `vinaya`: `renderBrief` runs
382
+ // `withCliInvocation` over this whole section once every section is composed,
383
+ // so rewriting here too would be a second application point to keep in sync.
316
384
  const intro = introMatch
317
385
  ? (introMatch[0] as string)
318
386
  .replace(/\s*\[[^\]]*\]/g, '')
319
387
  .replace(/\bBoth mandatory\.$/, 'Mandatory.')
320
388
  .trim()
321
- : 'You are the AEG Developer. Read `aeg-root/roles/developer.md` first. Mandatory.'
389
+ : 'You are the AEG Developer. Run `vinaya doctrine --role developer --print` and read its output first. Mandatory.'
322
390
 
323
391
  const reason = facts.rationale.suggestedAgentClass ?? ''
324
392
  // The declared tier is a floor, not a default: raised to the mechanical
@@ -354,8 +422,8 @@ function renderSection2(facts: BriefFacts): string {
354
422
  const branch = developerBranchForFacts(facts)
355
423
  const identityLine =
356
424
  facts.trancheSlug !== null
357
- ? `- **Tranche:** \`${facts.trancheSlug}\`, task ${facts.taskId}, Issue #${facts.issue}. Branch \`${branch}\`. \`Depends-on: ${depends}\`, \`Conflicts-with: ${conflicts}\`. Confirm \`READY TO DISPATCH\` at your own Step 0.`
358
- : `- **Backlog Issue:** #${facts.issue}, no tranche. Branch \`${branch}\`. \`Depends-on: ${depends}\`, \`Conflicts-with: ${conflicts}\`. Confirm \`READY TO DISPATCH\` at your own Step 0.`
425
+ ? `- **Tranche:** \`${facts.trancheSlug}\`, task ${facts.taskId}, Issue #${facts.issue}. Branch \`${branch}\`. \`Depends-on: ${depends}\`, \`Conflicts-with: ${conflicts}\`. Confirm dispatch readiness at your own Step 0, with the command §5 names.`
426
+ : `- **Backlog Issue:** #${facts.issue}, no tranche. Branch \`${branch}\`. \`Depends-on: ${depends}\`, \`Conflicts-with: ${conflicts}\`. Confirm dispatch readiness at your own Step 0, with the command §5 names.`
359
427
  const lines = [
360
428
  '## 2. Context — read before doing anything',
361
429
  '',
@@ -554,10 +622,20 @@ function renderSection4(facts: BriefFacts): string {
554
622
 
555
623
  function renderSection5(facts: BriefFacts): string {
556
624
  const branch = developerBranchForFacts(facts)
625
+ // The portable form first — `dispatch-readiness` is a shipped check every
626
+ // reader of this brief can run. The authoring repository's own fuller
627
+ // derivation follows only when `facts` says that repository has one, and
628
+ // takes the task arguments from this render rather than from a placeholder.
629
+ const unabridgedTarget =
630
+ facts.trancheSlug !== null ? `${facts.trancheSlug} ${facts.taskId}` : `--issue ${facts.issue}`
631
+ const unabridged =
632
+ facts.localGateCommands.dispatchReadiness !== null
633
+ ? ` This repository also ships the unabridged derivation — \`${facts.localGateCommands.dispatchReadiness} ${unabridgedTarget}\` → \`READY TO DISPATCH\`.`
634
+ : ''
557
635
  const verifyLine =
558
- facts.trancheSlug !== null
559
- ? '2. `bun packages/aeg-core/bin/verify-dispatch.ts <tranche> <n>` → `READY TO DISPATCH` (re-derived at render time: it was).'
560
- : `2. \`bun packages/aeg-core/bin/verify-dispatch.ts --issue ${facts.issue}\` → \`READY TO DISPATCH\` (re-derived at render time: it was).`
636
+ `2. \`${facts.cliInvocation} check dispatch-readiness\` → pass (re-derived at render time: it was ready).` +
637
+ ' Known gap: its prior-tranche-archival predicate always reports empty — confirm that predicate yourself.' +
638
+ unabridged
561
639
  const lines = [
562
640
  '## 5. Pre-flight checks',
563
641
  '',
@@ -664,7 +742,20 @@ function renderSection7(section7Pointers: string[]): string {
664
742
  return lines.join('\n')
665
743
  }
666
744
 
667
- function renderSection8(): string {
745
+ /**
746
+ * The pre-open documentation gate, as one command the reader can run — cited
747
+ * by both §8 and §12, so it is written once. `check doc-coverage` is the
748
+ * portable form; the authoring repository's fuller `--pr` derivation is
749
+ * appended only when `facts` says that repository ships one.
750
+ */
751
+ function docGateCommand(facts: BriefFacts): string {
752
+ const portable = `\`PR_BODY="$(cat <body-file>)" ${facts.cliInvocation} check doc-coverage\` green`
753
+ return facts.localGateCommands.docCoverage !== null
754
+ ? `${portable} (this repository also ships \`PR_BODY="$(cat <body-file>)" ${facts.localGateCommands.docCoverage} --pr\`, which additionally evaluates the spec-status and code-requires-docs contracts)`
755
+ : portable
756
+ }
757
+
758
+ function renderSection8(facts: BriefFacts): string {
668
759
  return [
669
760
  '## 8. Verification before claiming done',
670
761
  '',
@@ -673,10 +764,10 @@ function renderSection8(): string {
673
764
  // never a command a check or `pr report` executes — `evidence-fresh`
674
765
  // re-running it under the twenty-six sibling checks CI had just built
675
766
  // deleted their own `dist` out from under them.
676
- '- The pre-push hook already ran the affected suite on your one push and refused it on failure — do not additionally run it yourself; `vinaya pr report --write`/`--push` separately re-runs it with `--force` to attest the command and its output in the Evidence block.',
767
+ `- The pre-push hook already ran the affected suite on your one push and refused it on failure — do not additionally run it yourself; \`${facts.cliInvocation} pr report --write\`/\`--push\` separately re-runs it with \`--force\` to attest the command and its output in the Evidence block.`,
677
768
  "- The full `bun run test` suite is CI's to run, on the one push — never run it locally.",
678
769
  '- Every blast-radius consumer named in §4, re-verified by name.',
679
- '- `roles/developer.md`\'s tier checklist genuinely satisfied, and `PR_BODY="$(cat <body-file>)" bun packages/aeg-core/bin/verify-docs.ts --pr` green.'
770
+ `- The tier checklist in \`${facts.cliInvocation} doctrine --role developer --print\` genuinely satisfied, and ${docGateCommand(facts)}.`
680
771
  ].join('\n')
681
772
  }
682
773
 
@@ -767,11 +858,9 @@ function renderSection12(facts: BriefFacts): string {
767
858
  '## 12. Deliverable',
768
859
  '',
769
860
  `- PR title (exact): \`${prTitle}\``,
770
- '- Open the PR only via `bun apps/cli/src/index.ts pr create --body-file <path> --title "<title above>"`.',
771
- "- PR body = the Developer's PR report (start from `aeg-root/templates/pr-report-template.md`), with this entire brief pasted as the reference copy inside a collapsed `<details>` block, and `Closes #" +
772
- facts.issue +
773
- '` at the top of the header block.',
774
- '- Pre-open gate: tier checklist satisfied, and `PR_BODY="$(cat <body-file>)" bun packages/aeg-core/bin/verify-docs.ts --pr` green.',
861
+ `- Open the PR only via \`${facts.cliInvocation} pr create --body-file <path> --title "<title above>"\`.`,
862
+ `- PR body = the Developer's PR report (print it with \`${facts.cliInvocation} doctrine --template pr-report --print\`), with this entire brief pasted as the reference copy inside a collapsed \`<details>\` block, and \`Closes #${facts.issue}\` at the top of the header block.`,
863
+ `- Pre-open gate: tier checklist satisfied, and ${docGateCommand(facts)}.`,
775
864
  '- Include `git diff main --stat` and a token report (if unavailable, state so).',
776
865
  '- Then STOP. Review and Verification are separate invocations.'
777
866
  ].join('\n')
@@ -788,6 +877,11 @@ function renderSection12(facts: BriefFacts): string {
788
877
  * is absent: never a default, per this rule that a brief states no
789
878
  * fact it did not actually derive.
790
879
  */
880
+ /** Whether an Issue is at or above a resolved cutover — `true` for a `null` cutover (no grandfathering: every Issue is at or above "no cutover", O1). */
881
+ function atOrAboveCutover(issue: number, cutover: number | null): boolean {
882
+ return cutover === null || issue >= cutover
883
+ }
884
+
791
885
  export function renderBrief(facts: BriefFacts, template: string): RenderResult {
792
886
  const missing: string[] = []
793
887
 
@@ -797,11 +891,17 @@ export function renderBrief(facts: BriefFacts, template: string): RenderResult {
797
891
  'Revision (no source revision resolved — the caller must refuse before render, never render with an empty one)'
798
892
  )
799
893
  }
894
+ if (!facts.cliInvocation) {
895
+ missing.push(
896
+ 'CLI invocation (the caller must state how this repository invokes the CLI — every command this brief names is written through it)'
897
+ )
898
+ }
800
899
  // Grandfathered the same as the Issue gate itself (`checkIssueObjectives`):
801
- // an Issue below `OBJECTIVES_SINCE_ISSUE` legitimately has no `## Objectives`
802
- // section, and the renderer must not newly refuse a class of Issue every
803
- // other consumer in this task already exempts.
804
- if (facts.objectives.length === 0 && facts.issue >= OBJECTIVES_SINCE_ISSUE) {
900
+ // an Issue below the resolved Objectives cutover legitimately has no
901
+ // `## Objectives` section, and the renderer must not newly refuse a class of
902
+ // Issue every other consumer in this task already exempts. A `null` cutover
903
+ // means no grandfathering — every Issue is expected to carry the section (O1).
904
+ if (facts.objectives.length === 0 && atOrAboveCutover(facts.issue, facts.cutovers.objectivesSinceIssue)) {
805
905
  missing.push('Objectives (Issue has no `## Objectives` section)')
806
906
  }
807
907
  // Same grandfather posture as Objectives, not the four judgment sections
@@ -812,7 +912,7 @@ export function renderBrief(facts: BriefFacts, template: string): RenderResult {
812
912
  if (
813
913
  facts.documentation.kind === 'sources' &&
814
914
  facts.documentation.sources.length === 0 &&
815
- facts.issue >= DOCUMENTATION_SINCE_ISSUE
915
+ atOrAboveCutover(facts.issue, facts.cutovers.documentationSinceIssue)
816
916
  ) {
817
917
  missing.push('Documentation (Issue has no `## Documentation` section)')
818
918
  }
@@ -824,7 +924,10 @@ export function renderBrief(facts: BriefFacts, template: string): RenderResult {
824
924
  // ISSUE CREATION gate starts requiring the section, not whether a brief
825
925
  // can be rendered without one. The message names the cutover so a
826
926
  // pre-cutover Issue reads this as "add the section", not as a gate bug.
827
- const cutoverNote = `the Issue predates the \`## Surface\`/\`## Parts\`/\`## Test plan\`/\`## Stop conditions\` gate cutover at #${BRIEF_SECTIONS_SINCE_ISSUE}, but a brief still needs it to render`
927
+ const cutoverNote =
928
+ facts.cutovers.briefSectionsSinceIssue !== null
929
+ ? `the Issue predates the \`## Surface\`/\`## Parts\`/\`## Test plan\`/\`## Stop conditions\` gate cutover at #${facts.cutovers.briefSectionsSinceIssue}, but a brief still needs it to render`
930
+ : 'a brief still needs the `## Surface`/`## Parts`/`## Test plan`/`## Stop conditions` section to render'
828
931
  if (facts.surface.in.length === 0) {
829
932
  missing.push(`Surface (Issue has no \`## Surface\` section with a non-empty \`in:\` list — ${cutoverNote})`)
830
933
  }
@@ -882,34 +985,47 @@ export function renderBrief(facts: BriefFacts, template: string): RenderResult {
882
985
  )
883
986
  : []
884
987
 
988
+ // `withCliInvocation` over every section the renderer composes, not only the
989
+ // ones whose commands it writes itself: a Planner's own prose (a Traps line,
990
+ // a Boundary, a Test plan entry) names `vinaya` commands too, and those were
991
+ // copied into an adopter's brief unrewritten — the same defect on the
992
+ // caller-supplied side, found by review.
993
+ //
994
+ // `## Objectives` is the one section held out, and the reason is a gate:
995
+ // `checkObjectivesCopy` refuses a brief whose Objectives do not match the
996
+ // Issue's word for word. An objective naming a command keeps the Issue's own
997
+ // spelling; §6's Parts cite it by id, so nothing there depends on the
998
+ // command form.
999
+ const withCli = (section: string): string => withCliInvocation(section, facts.cliInvocation)
1000
+
885
1001
  const brief = [
886
- renderHeader(scopedFacts, template),
1002
+ withCli(renderHeader(scopedFacts, template)),
887
1003
  '',
888
1004
  ...(facts.objectives.length > 0 ? [renderObjectives(facts.objectives), ''] : []),
889
1005
  ...(facts.documentation.kind === 'none' || facts.documentation.sources.length > 0
890
- ? [renderDocumentation(facts.documentation), '']
1006
+ ? [withCli(renderDocumentation(facts.documentation)), '']
891
1007
  : []),
892
- renderSection2(facts),
1008
+ withCli(renderSection2(facts)),
893
1009
  '',
894
- renderSection3(facts),
1010
+ withCli(renderSection3(facts)),
895
1011
  '',
896
- renderSection4(scopedFacts),
1012
+ withCli(renderSection4(scopedFacts)),
897
1013
  '',
898
- renderSection5(facts),
1014
+ withCli(renderSection5(facts)),
899
1015
  '',
900
- renderSection6(scopedFacts),
1016
+ withCli(renderSection6(scopedFacts)),
901
1017
  '',
902
- renderSection7(section7Pointers),
1018
+ withCli(renderSection7(section7Pointers)),
903
1019
  '',
904
- renderSection8(),
1020
+ withCli(renderSection8(facts)),
905
1021
  '',
906
- renderSection9(facts),
1022
+ withCli(renderSection9(facts)),
907
1023
  '',
908
- renderSection10(facts),
1024
+ withCli(renderSection10(facts)),
909
1025
  '',
910
- renderSection11(template, facts),
1026
+ withCli(renderSection11(template, facts)),
911
1027
  '',
912
- renderSection12(facts)
1028
+ withCli(renderSection12(facts))
913
1029
  ].join('\n')
914
1030
 
915
1031
  return { ok: true, brief }
@@ -391,8 +391,22 @@ export const COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join('|')})(\\([a-
391
391
  * (husky/commitlint parity, applied at the wrapper).
392
392
  */
393
393
  export function checkForgeTitle(title: string): BriefSectionResult {
394
- const taskStyle = /^\[[a-z0-9._-]+\] \S+ — \S/
394
+ const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/
395
395
  if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title)) return { status: 'pass', errors: [] }
396
+ // A title that is task-shaped except for a non-numeric id (`[slug] 7a — …`)
397
+ // gets the specific rule, not the generic "matches neither grammar": task ids
398
+ // are whole numbers, the same shape `vinaya task run`/`task dispatch` and the
399
+ // edge grammar (`parse-rationale-deps.ts`) accept — a lettered id names a task
400
+ // nothing downstream can start.
401
+ const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title)
402
+ if (letteredTaskId) {
403
+ return {
404
+ status: 'fail',
405
+ errors: [
406
+ `brief-validation title: "${title}" names task id \`${letteredTaskId[1]}\` — task ids are whole numbers (\`1\`, \`2\`), never lettered (\`2a\`). \`vinaya task run\` and \`task dispatch\` refuse a non-numeric id, so a plan titled this way names a task that cannot be started.`
407
+ ]
408
+ }
409
+ }
396
410
  return {
397
411
  status: 'fail',
398
412
  errors: [
@@ -518,6 +532,12 @@ export const COMMAND_WORDS = ['export', 'bun', 'gh', 'git', 'grep', 'sed', 'cat'
518
532
  * pre-dispatch) has no PR number and applies all four unconditionally —
519
533
  * grandfathering is a CI-only rollout concern, not a grammar relaxation
520
534
  * (round-2 ruling addendum 1).
535
+ *
536
+ * Now this repository's own historical value, exported as the DEFAULT for
537
+ * `partitionBriefErrorsByRollout`'s `cutovers`, not the value the gate reads:
538
+ * the cutover is `vinaya.config.json`'s optional `gateCutovers.briefRulesSincePr`
539
+ * (absent → `null` → no grandfathering, block from PR 1, O1), restated as this
540
+ * repo's own value (O2).
521
541
  */
522
542
  export const BRIEF_RULES_SINCE_PR = 394
523
543
 
@@ -532,6 +552,12 @@ export const BRIEF_RULES_SINCE_PR = 394
532
552
  * (authoring time, pre-dispatch) has no PR number and applies the rule
533
553
  * unconditionally, same grandfathering-is-CI-only posture as
534
554
  * `BRIEF_RULES_SINCE_PR`.
555
+ *
556
+ * Now this repository's own historical value, exported as a DEFAULT for
557
+ * `partitionBriefErrorsByRollout`'s `cutovers`, not the value the gate reads:
558
+ * the cutover is `vinaya.config.json`'s optional
559
+ * `gateCutovers.agentBoxesRefusedSincePr` (absent → `null` → no grandfathering,
560
+ * block from PR 1, O1), restated as this repo's own value (O2).
535
561
  */
536
562
  export const AGENT_BOXES_REFUSED_SINCE_PR = 396
537
563
 
@@ -555,36 +581,68 @@ export function checkNoAgentBoxes(prBody: string): BriefSectionResult {
555
581
  }
556
582
  }
557
583
 
584
+ /** Which rollout rule an error message belongs to (by its distinct prefix), or `null` for an always-blocking message no rollout covers. */
585
+ type BriefRolloutRule = 'briefRules' | 'agentBoxes'
586
+
587
+ function rolloutRuleFor(message: string): BriefRolloutRule | null {
588
+ if (
589
+ message.startsWith('brief-validation unpinned code claim:') ||
590
+ message.startsWith('brief-validation commands carry output:') ||
591
+ message.startsWith('brief-validation consumer tests:') ||
592
+ message.startsWith('brief-validation defeat cases:')
593
+ ) {
594
+ return 'briefRules'
595
+ }
596
+ if (message.startsWith('brief-validation no agent boxes:')) return 'agentBoxes'
597
+ return null
598
+ }
599
+
558
600
  /**
559
601
  * True for an error message produced by one of the five grandfatherable
560
602
  * rules below (the original four, plus `checkNoAgentBoxes`) — classified by
561
603
  * each rule's own distinct message prefix, since `checkBriefSections`
562
- * aggregates every sub-check's errors into one flat `string[]` and this is
563
- * the only reader that ever needs to tell them apart from the rest.
604
+ * aggregates every sub-check's errors into one flat `string[]`. A pure
605
+ * classification of the message, independent of any actual cutover value.
564
606
  */
565
607
  export function isGrandfatherableBriefRuleError(message: string): boolean {
566
- return rolloutThresholdFor(message) !== null
608
+ return rolloutRuleFor(message) !== null
567
609
  }
568
610
 
569
611
  /**
570
- * The rollout constant a given error message is grandfathered against, or
571
- * `null` for a message this rollout scheme does not cover (always blocking,
572
- * on every PR). Two thresholds exist today (`BRIEF_RULES_SINCE_PR`,
573
- * `AGENT_BOXES_REFUSED_SINCE_PR`) — a message is matched to whichever rule
574
- * produced it, never a single global cutover, so a later third threshold
575
- * can be added here without touching either existing one's grandfather
576
- * window.
612
+ * The two PR rollout cutovers, `null` meaning NO cutover for that rule (its
613
+ * findings block on every PR, from PR 1 — a repository that declares no
614
+ * `gateCutovers`, O1). Resolved from `vinaya.config.json`'s optional
615
+ * `gateCutovers` key by `resolveGateCutovers` (`apps/cli/src/lib/config.ts`)
616
+ * and passed into `partitionBriefErrorsByRollout`; this module reads no config.
577
617
  */
578
- function rolloutThresholdFor(message: string): number | null {
579
- if (
580
- message.startsWith('brief-validation unpinned code claim:') ||
581
- message.startsWith('brief-validation commands carry output:') ||
582
- message.startsWith('brief-validation consumer tests:') ||
583
- message.startsWith('brief-validation defeat cases:')
584
- ) {
585
- return BRIEF_RULES_SINCE_PR
586
- }
587
- if (message.startsWith('brief-validation no agent boxes:')) return AGENT_BOXES_REFUSED_SINCE_PR
618
+ export type BriefRolloutCutovers = {
619
+ briefRulesSincePr: number | null
620
+ agentBoxesRefusedSincePr: number | null
621
+ }
622
+
623
+ /**
624
+ * This repository's own historical rollout cutovers — the DEFAULT for a caller
625
+ * that does not resolve config (a test). Every enforcement path
626
+ * (`check-brief-shape.ts`) passes the resolved values, which are `null` when
627
+ * the key is absent.
628
+ */
629
+ const DEFAULT_BRIEF_ROLLOUT_CUTOVERS: BriefRolloutCutovers = {
630
+ briefRulesSincePr: BRIEF_RULES_SINCE_PR,
631
+ agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
632
+ }
633
+
634
+ /**
635
+ * The rollout cutover a given error message is grandfathered against, or
636
+ * `null` — either because the message belongs to no rollout rule (always
637
+ * blocking), or because that rule's own cutover is `null` (no cutover
638
+ * configured, so nothing below it is grandfathered). A message is matched to
639
+ * whichever rule produced it, never a single global cutover, so a later third
640
+ * threshold can be added without touching either existing one's window.
641
+ */
642
+ function rolloutThresholdFor(message: string, cutovers: BriefRolloutCutovers): number | null {
643
+ const rule = rolloutRuleFor(message)
644
+ if (rule === 'briefRules') return cutovers.briefRulesSincePr
645
+ if (rule === 'agentBoxes') return cutovers.agentBoxesRefusedSincePr
588
646
  return null
589
647
  }
590
648
 
@@ -592,7 +650,11 @@ function rolloutThresholdFor(message: string): number | null {
592
650
  * Splits `checkBriefSections`'s flat error list into `blocking` (fails the
593
651
  * check) and `info` (printed, never a failure) — the CI shim
594
652
  * (`check-brief-shape.ts`) is the only caller, but the split is a pure
595
- * function of `(errors, prNumber)` so it is unit-testable directly.
653
+ * function of `(errors, prNumber, cutovers)` so it is unit-testable directly.
654
+ *
655
+ * `cutovers` is the resolved rollout cutovers; a `null` field means that
656
+ * rule's findings are never grandfathered (block from PR 1, O1). Defaults to
657
+ * this repo's historical constants for a caller that does not resolve config.
596
658
  *
597
659
  * `prNumber === null` (no `PR_NUMBER`, or an unparseable one) is NOT
598
660
  * grandfathered — only a real, parsed number below a message's own
@@ -602,12 +664,13 @@ function rolloutThresholdFor(message: string): number | null {
602
664
  */
603
665
  export function partitionBriefErrorsByRollout(
604
666
  errors: string[],
605
- prNumber: number | null
667
+ prNumber: number | null,
668
+ cutovers: BriefRolloutCutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS
606
669
  ): { blocking: string[]; info: string[] } {
607
670
  const blocking: string[] = []
608
671
  const info: string[] = []
609
672
  for (const e of errors) {
610
- const threshold = rolloutThresholdFor(e)
673
+ const threshold = rolloutThresholdFor(e, cutovers)
611
674
  const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold
612
675
  ;(grandfathered ? info : blocking).push(e)
613
676
  }
@@ -511,11 +511,18 @@ export type { ForgeIssue }
511
511
  * (aeg-core is pure). Defaults to `[]`, which leaves the registry half
512
512
  * dormant — so a caller that has no registry to hand keeps R1's prior
513
513
  * behaviour exactly.
514
+ * `objectivesSinceIssue`: the resolved Objectives cutover
515
+ * (`gateCutovers.objectivesSinceIssue`, resolved by the caller from
516
+ * `vinaya.config.json` — aeg-core is pure), threaded into `checkIssueObjectives`.
517
+ * `null` means NO cutover (grade every open Issue from 1, O1); `undefined`
518
+ * (an omitting caller, e.g. a test) falls through to `checkIssueObjectives`'s
519
+ * own default (this repo's historical cutover).
514
520
  */
515
521
  export function checkR1(
516
522
  issuesBySlug: Map<string, ForgeIssue[]>,
517
523
  grandfatheredIssues: ReadonlySet<number>,
518
- registeredNames: string[] = []
524
+ registeredNames: string[] = [],
525
+ objectivesSinceIssue?: number | null
519
526
  ): CheckResult {
520
527
  const failures: CheckFailure[] = []
521
528
  for (const [slug, issues] of issuesBySlug) {
@@ -524,7 +531,7 @@ export function checkR1(
524
531
  const errors = [
525
532
  ...checkIssueRationale(issue.body).errors,
526
533
  ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
527
- ...checkIssueObjectives(issue.body, issue.number).errors,
534
+ ...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
528
535
  // task 17, O2 — Parts coverage joins the sweep here: same
529
536
  // dormant-when-absent posture as the other two, zero new inputs.
530
537
  ...checkPartsCiteDefinedObjectives(issue.body).errors
@@ -50,6 +50,7 @@ import {
50
50
  type Decision,
51
51
  type DevReviewLoopEventInput,
52
52
  type LoopState,
53
+ type NotReviewedReason,
53
54
  type Observations,
54
55
  type PendingRound,
55
56
  type RoundOutcome,
@@ -233,7 +234,14 @@ function buildRoundRecord(
233
234
  confidence: Confidence | null,
234
235
  outcome: RoundOutcome
235
236
  ): RoundRecord {
237
+ // Every column this round MEASURED, seeded at zero before a single finding
238
+ // is counted — so a round the loop assessed and found nothing in is a
239
+ // recorded zero, not an absent count. The published table needs the two told
240
+ // apart (`countCells`, `render-summary.ts`): a round rebuilt from the pull
241
+ // request's markers after a restart has no counts at all, and must report
242
+ // nothing rather than a zero a reader would take for a clean round.
236
243
  const countsBySeverity: Record<string, number> = {}
244
+ for (const key of SEVERITY_COLUMNS) countsBySeverity[key] = 0
237
245
  for (const v of verdicts) {
238
246
  for (const f of v.findings) {
239
247
  const key = f.severity.toLowerCase()
@@ -244,6 +252,27 @@ function buildRoundRecord(
244
252
  return { round, countsBySeverity, confidence, outcome }
245
253
  }
246
254
 
255
+ /**
256
+ * A round that ended before any reviewer ran — its gate was not green, or a
257
+ * below-threshold confidence sent the developer back — has no findings from any
258
+ * source. Unlike `buildRoundRecord`, it records NO counts (an empty
259
+ * `countsBySeverity`, the shape a marker-reconstructed round also carries), so
260
+ * the published table reports `—` for every severity column through the
261
+ * renderer's existing "counts have no source" path, never a `0` a reader would
262
+ * take for a clean review (`countCells`, `render-summary.ts`). `outcome` is left
263
+ * exactly as this round would otherwise carry — the `round_ended` log event is
264
+ * unchanged — and `notReviewed` names why no reviewer saw it for the table's
265
+ * outcome cell.
266
+ */
267
+ function buildUnreviewedRecord(
268
+ round: number,
269
+ confidence: Confidence | null,
270
+ outcome: RoundOutcome,
271
+ reason: NotReviewedReason
272
+ ): RoundRecord {
273
+ return { round, countsBySeverity: {}, confidence, outcome, notReviewed: reason }
274
+ }
275
+
247
276
  /** Folds one round's diff stats into the running totals `journal_finalized` reports — never recomputed from `rounds`. */
248
277
  function withRoundStats(state: LoopState, stats: RoundStats): Pick<LoopState, 'totalWallMs' | 'totalFilesChanged'> {
249
278
  return {
@@ -310,7 +339,7 @@ function assessGate(
310
339
 
311
340
  if (!obs.green) {
312
341
  events.push(roundEndedEvent(state, obs.round, obs.stats, 'changes_requested'))
313
- const record = buildRoundRecord(obs.round, [], null, 'changes_requested')
342
+ const record = buildUnreviewedRecord(obs.round, null, 'changes_requested', 'checks_red')
314
343
  const newState: LoopState = {
315
344
  ...state,
316
345
  rounds: [...state.rounds, record],
@@ -376,7 +405,7 @@ function assessGate(
376
405
  return { decision: { type: 'pause', reason: 'confidence' }, state: preFinalize, events }
377
406
  }
378
407
  events.push(roundEndedEvent(state, obs.round, obs.stats, 'changes_requested'))
379
- const record = buildRoundRecord(obs.round, [], confidence, 'changes_requested')
408
+ const record = buildUnreviewedRecord(obs.round, confidence, 'changes_requested', 'low_confidence')
380
409
  const newState: LoopState = {
381
410
  ...state,
382
411
  rounds: [...state.rounds, record],
@@ -20,6 +20,7 @@ export type {
20
20
  Journal,
21
21
  LoopConfig,
22
22
  LoopState,
23
+ NotReviewedReason,
23
24
  Observations,
24
25
  PauseReason,
25
26
  PendingRound,