@attalabs/vinaya 0.34.0 → 0.35.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 (125) hide show
  1. package/LICENSE +104 -201
  2. package/README.md +1 -1
  3. package/aeg-root/roles/planner/reference.md +1 -1
  4. package/dist/checks/bin/check-body-bare-digits.js +5 -2
  5. package/dist/checks/bin/check-branch-topology.js +13 -0
  6. package/dist/checks/bin/check-brief-shape.js +5 -2
  7. package/dist/checks/bin/check-changeset-coverage.js +38 -5
  8. package/dist/checks/bin/check-closes-n.js +13 -0
  9. package/dist/checks/bin/check-coherence.js +16 -2
  10. package/dist/checks/bin/check-dead-branch-push.js +2 -0
  11. package/dist/checks/bin/check-dispatch-readiness.js +16 -2
  12. package/dist/checks/bin/check-doc-coverage-push.js +38 -5
  13. package/dist/checks/bin/check-doc-coverage.js +38 -5
  14. package/dist/checks/bin/check-doctrine-no-procedures.js +5 -2
  15. package/dist/checks/bin/check-doctrine-portability.js +38 -5
  16. package/dist/checks/bin/check-evidence-fresh.js +38 -5
  17. package/dist/checks/bin/check-exec-bits.js +38 -5
  18. package/dist/checks/bin/check-first-push-dispatch.js +16 -2
  19. package/dist/checks/bin/check-issue-assignment.js +13 -0
  20. package/dist/checks/bin/check-issue-milestone-attach.js +2 -0
  21. package/dist/checks/bin/check-issue-objectives-numbering.js +5 -2
  22. package/dist/checks/bin/check-issue-parts-coverage.js +2 -0
  23. package/dist/checks/bin/check-issue-surface-globs.js +16 -2
  24. package/dist/checks/bin/check-issue-title-grammar.js +2 -0
  25. package/dist/checks/bin/check-issue-tranche-label.js +2 -0
  26. package/dist/checks/bin/check-main-branch-refusal.js +2 -0
  27. package/dist/checks/bin/check-no-disk-state.js +2 -0
  28. package/dist/checks/bin/check-pr-premise-reassert.js +5 -2
  29. package/dist/checks/bin/check-pr-report-density.js +2 -0
  30. package/dist/checks/bin/check-principal-test-plan-wait.js +2 -0
  31. package/dist/checks/bin/check-quoted-command.js +38 -5
  32. package/dist/checks/bin/check-reader-resolvable-prose.js +38 -5
  33. package/dist/checks/bin/check-registry-gates.js +2 -0
  34. package/dist/checks/bin/check-retired-vocabulary.js +38 -5
  35. package/dist/checks/bin/check-review-gate.js +5 -2
  36. package/dist/checks/bin/check-single-plan-pr.js +2 -0
  37. package/dist/checks/bin/check-surface-scope.js +13 -0
  38. package/dist/checks/bin/check-test-plan.js +2 -0
  39. package/dist/checks/bin/check-token-collection-wired.js +2 -0
  40. package/dist/checks/bin/check-token-report.js +2 -0
  41. package/dist/checks/bin/check-workspace-escape.js +38 -5
  42. package/dist/index.js +308 -113
  43. package/dist/lib/pre-push-cache-test-run.js +36 -5
  44. package/dist/lib/pre-push-select-tests.js +3 -2
  45. package/package.json +2 -2
  46. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +153 -37
  47. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +87 -24
  48. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +9 -2
  49. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +7 -0
  50. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +28 -2
  51. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-cutovers.ts +49 -0
  52. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +12 -2
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +138 -54
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +26 -3
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives-cutover-config.ts +31 -0
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +15 -6
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +122 -23
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +38 -3
  59. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  60. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  61. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  62. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  63. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  64. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  65. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  66. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  70. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +1 -1
  98. 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
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__07uhu5z._.js → [root-of-the-server]__0zc_0gx._.js} +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +2 -2
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  113. 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
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  118. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2174nz5he_oc4.js → 3goaig_rysc6p.js} +1 -1
  119. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0q9p7c6vn-x2w.js → 3ip5z3cf43bgo.js} +4 -4
  120. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xnma0-359j17.js → 3u9emqjwpd0t9.js} +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  122. /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/aeg-core}/bin/verify-coherence.ts +0 -0
  123. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{HmoeqXdX1E4drt7GReFOO → ca66rAHI_w9D7S7ceXDvR}/_buildManifest.js +0 -0
  124. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{HmoeqXdX1E4drt7GReFOO → ca66rAHI_w9D7S7ceXDvR}/_clientMiddlewareManifest.js +0 -0
  125. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{HmoeqXdX1E4drt7GReFOO → ca66rAHI_w9D7S7ceXDvR}/_ssgManifest.js +0 -0
@@ -233,7 +233,14 @@ function buildRoundRecord(
233
233
  confidence: Confidence | null,
234
234
  outcome: RoundOutcome
235
235
  ): RoundRecord {
236
+ // Every column this round MEASURED, seeded at zero before a single finding
237
+ // is counted — so a round the loop assessed and found nothing in is a
238
+ // recorded zero, not an absent count. The published table needs the two told
239
+ // apart (`countCells`, `render-summary.ts`): a round rebuilt from the pull
240
+ // request's markers after a restart has no counts at all, and must report
241
+ // nothing rather than a zero a reader would take for a clean round.
236
242
  const countsBySeverity: Record<string, number> = {}
243
+ for (const key of SEVERITY_COLUMNS) countsBySeverity[key] = 0
237
244
  for (const v of verdicts) {
238
245
  for (const f of v.findings) {
239
246
  const key = f.severity.toLowerCase()
@@ -13,6 +13,12 @@ import { SEVERITY_COLUMNS, type Confidence, type Journal, type RoundRecord } fro
13
13
  * reads the same literals the renderer wrote. They are DIFFERENT facts: the
14
14
  * loop never asked this round for a confidence at all (round 1 never is), or
15
15
  * it asked and the developer stated nothing readable.
16
+ *
17
+ * `CONFIDENCE_NOT_ASKED_CELL`'s glyph is also the count columns' own
18
+ * "nothing to report" cell (`countCells` below) — one glyph for one meaning
19
+ * across the table, rather than a second literal saying the same thing. Only
20
+ * the confidence column is read back out of a posted table, so the shared
21
+ * glyph never makes a count cell parseable as a confidence.
16
22
  */
17
23
  export const CONFIDENCE_NOT_ASKED_CELL = '—'
18
24
  export const CONFIDENCE_ABSENT_CELL = 'absent'
@@ -26,9 +32,29 @@ function confidenceCell(confidence: Confidence | null): string {
26
32
  return `${confidence.value}%`
27
33
  }
28
34
 
35
+ /**
36
+ * One round's count cells — numbers when the loop recorded this round's
37
+ * findings, the not-reported glyph when it never recorded them at all.
38
+ *
39
+ * A round the loop ASSESSED records every severity column, zeros included
40
+ * (`buildRoundRecord`, `assess-round.ts`), so a record carrying none of them
41
+ * is one whose counts have no source: a round rebuilt from the pull request's
42
+ * own round markers after a restart, which name a round's number and head and
43
+ * carry no finding breakdown at all (`journal-reconstruction.ts`). Writing `0`
44
+ * for those cells told a reader the round was clean — four rounds of a real
45
+ * task's published table read as zero findings when the truth was that nobody
46
+ * knew. The distinction is whether the counts were recorded, never whether
47
+ * they are zero: a round the loop assessed and found nothing in still reads
48
+ * `0`, because that zero is a measurement.
49
+ */
50
+ function countCells(record: RoundRecord): string[] {
51
+ const recorded = SEVERITY_COLUMNS.some((key) => record.countsBySeverity[key] !== undefined)
52
+ if (!recorded) return SEVERITY_COLUMNS.map(() => CONFIDENCE_NOT_ASKED_CELL)
53
+ return SEVERITY_COLUMNS.map((key) => String(record.countsBySeverity[key] ?? 0))
54
+ }
55
+
29
56
  function row(record: RoundRecord): string {
30
- const counts = SEVERITY_COLUMNS.map((key) => String(record.countsBySeverity[key] ?? 0))
31
- return `| ${record.round} | ${counts.join(' | ')} | ${confidenceCell(record.confidence)} | ${record.outcome} |`
57
+ return `| ${record.round} | ${countCells(record).join(' | ')} | ${confidenceCell(record.confidence)} | ${record.outcome} |`
32
58
  }
33
59
 
34
60
  export function renderSummary(journal: Journal): string {
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The five gate cutovers as data — one Issue/PR number per gate below which
3
+ * that gate is grandfathered (an Issue/PR older than the cutover passes
4
+ * unconditionally). Pure — no `fs`, no `fetch`, no config read: the caller
5
+ * resolves the effective cutovers once (`resolveGateCutovers`,
6
+ * `apps/cli/src/lib/config.ts`, reading `vinaya.config.json`'s optional
7
+ * `gateCutovers` key) and passes them into the pure validators, exactly the
8
+ * seam `ReviewPolicy`/`resolveReviewPolicy` already use for the review
9
+ * thresholds.
10
+ *
11
+ * Each field is `number | null`, and **`null` means NO CUTOVER** — the gate
12
+ * applies to every Issue/PR, from number 1. That is the whole point of moving
13
+ * these numbers out of hardcoded constants and into an optional config key: a
14
+ * repository that declares no `gateCutovers` resolves every field to `null`
15
+ * here (`NO_GATE_CUTOVERS`), so its Issue 1 is held to the same gates a
16
+ * high-numbered Issue is (O1). A repository whose Issues predate a gate — this
17
+ * one — sets the numbers in its own `vinaya.config.json` so its older Issues
18
+ * and pull requests are judged exactly as before (O2). See
19
+ * `packages/sources/src/config-reference.ts`'s `gateCutovers` entry (O3).
20
+ *
21
+ * The built-in constants that were these numbers (`OBJECTIVES_SINCE_ISSUE`
22
+ * etc., still exported from `issue-validation.ts`/`brief-validation.ts`) remain
23
+ * as the DEFAULT parameter value of each pure validator, so a caller that does
24
+ * not resolve config (a test, an authoring path with no repo config in hand)
25
+ * keeps this repository's historical behaviour. Every ENFORCEMENT path resolves
26
+ * config and passes the value explicitly, and an absent key resolves to `null`
27
+ * there — never to the constant — which is what makes O1 hold.
28
+ */
29
+ export type GateCutovers = {
30
+ /** `## Objectives` Issue gate (`checkIssueObjectives`). */
31
+ objectivesSinceIssue: number | null
32
+ /** `## Surface`/`## Parts`/`## Test plan`/`## Stop conditions` Issue gate (`checkIssueBriefSections`). */
33
+ briefSectionsSinceIssue: number | null
34
+ /** `## Documentation` Issue gate, folded into `checkIssueBriefSections`. */
35
+ documentationSinceIssue: number | null
36
+ /** The four brief-shape rules' PR rollout (`partitionBriefErrorsByRollout`). */
37
+ briefRulesSincePr: number | null
38
+ /** The `[agent]`-checkbox refusal's PR rollout (`checkNoAgentBoxes` via the same partition). */
39
+ agentBoxesRefusedSincePr: number | null
40
+ }
41
+
42
+ /** No cutover on any gate — every gate applies from Issue/PR 1. The resolved value for a repository that declares no `gateCutovers` key (O1). */
43
+ export const NO_GATE_CUTOVERS: GateCutovers = {
44
+ objectivesSinceIssue: null,
45
+ briefSectionsSinceIssue: null,
46
+ documentationSinceIssue: null,
47
+ briefRulesSincePr: null,
48
+ agentBoxesRefusedSincePr: null
49
+ }
@@ -161,6 +161,7 @@ export {
161
161
  resolveNewestFrozenBrief
162
162
  } from './brief-validation'
163
163
  export type {
164
+ BriefRolloutCutovers,
164
165
  BriefSectionResult,
165
166
  BriefSectionsOptions,
166
167
  FencedBlock,
@@ -252,6 +253,7 @@ export {
252
253
  checkConflictCompleteness,
253
254
  checkDocsWithinSurface,
254
255
  checkDocumentationCitesObjective,
256
+ checkEdgeIdsWholeNumbers,
255
257
  checkIssueBriefSections,
256
258
  checkIssueObjectives,
257
259
  checkIssueRationale,
@@ -350,11 +352,14 @@ export {
350
352
  checkUndefinedVocabulary,
351
353
  checkUnresolvableReferences,
352
354
  classifyProseFile,
355
+ DEFAULT_SPEC_PATHS,
353
356
  extractComments,
354
357
  legacySlugPattern,
358
+ normalizeSpecPath,
355
359
  parseGlossaryTerms,
356
360
  PRODUCT_SLUG_SCOPE,
357
- stripNonProse
361
+ stripNonProse,
362
+ TASK_NUMBER_PATTERN
358
363
  } from './reader-resolvable-prose'
359
364
  export type { ProseFileClass, ProseFinding, ProseSourceFile } from './reader-resolvable-prose'
360
365
  export {
@@ -427,6 +432,8 @@ export {
427
432
  TASK_TOOL_NAMES,
428
433
  taskToolByName,
429
434
  taskToolError,
435
+ isTaskNextAction,
436
+ TASK_NEXT_ACTIONS,
430
437
  taskStartRequestIdentity,
431
438
  TaskStartResultSchema,
432
439
  EscalationEvidenceSchema,
@@ -464,6 +471,7 @@ export {
464
471
  export type {
465
472
  Freshness,
466
473
  OperatorGrantedTool,
474
+ TaskNextAction,
467
475
  PageRequest,
468
476
  RequestedAuthority,
469
477
  TaskCancelInput,
@@ -548,7 +556,9 @@ export type {
548
556
  export { findWorkspaceEscapes } from './workspace-escape'
549
557
  export type { WorkspaceEscapeFinding, WorkspaceEscapeReason, WorkspaceEscapeSourceFile } from './workspace-escape'
550
558
  export { extractBoundaryFilePaths, extractSourceRevision, parseRationaleFields, renderBrief } from './brief-render'
551
- export type { BriefFacts, RationaleFieldKey, RenderResult, SurfaceFileFact } from './brief-render'
559
+ export type { BriefFacts, LocalGateCommands, RationaleFieldKey, RenderResult, SurfaceFileFact } from './brief-render'
560
+ export { NO_GATE_CUTOVERS } from './gate-cutovers'
561
+ export type { GateCutovers } from './gate-cutovers'
552
562
  export {
553
563
  hasObjectivesHeading,
554
564
  isIssueNotFoundError,
@@ -17,6 +17,7 @@
17
17
  */
18
18
 
19
19
  import {
20
+ findLetteredEdgeIds,
20
21
  hasLabel,
21
22
  LABELS,
22
23
  projectFieldFromBody,
@@ -102,22 +103,60 @@ export function checkIssueRationale(body: string): IssueSectionResult {
102
103
  }
103
104
 
104
105
  /**
105
- * The Issue number from which `## Objectives` becomes mandatory (a real
106
- * incident: a merged PR left two brief Parts
107
- * undelivered and nothing named what the work had to do in a form a machine
108
- * could compare). Every task
109
- * Issue at or above this cutover number already carries the section by hand. Same shape as
110
- * `BRIEF_RULES_SINCE_PR` (`brief-validation.ts`) — a cutover by Issue number,
111
- * never a retroactive requirement on the pre-gate stock.
106
+ * **A `Depends-on`/`Conflicts-with` edge names a whole-number task id.** A
107
+ * lettered id (`7a`, `2b`) clears no gate downstream — `vinaya task run` and
108
+ * `task dispatch` refuse any non-numeric id — so a plan naming one in an edge
109
+ * builds a dependency the Operator can never start, the exact split that let a
110
+ * new adopter's `2a`/`2b` plan pass every gate and then stall. The edge grammar
111
+ * (`parse-rationale-deps.ts`'s `ID_TOKEN`/`SLUG_QUALIFIED_ID`) no longer accepts
112
+ * a lettered id; this NAMES the offending token at authoring time rather than
113
+ * silently dropping it. `findLetteredEdgeIds` reads the same declared-edge spans
114
+ * `parseRationaleDeps` does, so this can never disagree with what the parser
115
+ * treats as an edge. One error line per lettered id.
116
+ */
117
+ export function checkEdgeIdsWholeNumbers(body: string): IssueSectionResult {
118
+ const lettered = findLetteredEdgeIds(body)
119
+ if (lettered.length === 0) return { status: 'pass', errors: [] }
120
+ return {
121
+ status: 'fail',
122
+ errors: lettered.map(
123
+ (id) =>
124
+ `issue-validation edge id: \`${id}\` in a \`Depends-on\`/\`Conflicts-with\` edge is not a whole number — task ids are whole numbers (\`1\`, \`2\`), never lettered (\`2a\`). \`vinaya task run\` and \`task dispatch\` refuse a non-numeric id, so a plan naming one names a task that cannot be started.`
125
+ )
126
+ }
127
+ }
128
+
129
+ /**
130
+ * This repository's own historical Objectives cutover (a real incident: a
131
+ * merged PR left two brief Parts undelivered and nothing named what the work
132
+ * had to do in a form a machine could compare). Every task Issue at or above
133
+ * this number already carries the section by hand.
134
+ *
135
+ * **This is now the DEFAULT parameter value of `checkIssueObjectives`, not the
136
+ * value the gate reads.** The cutover is an optional `vinaya.config.json` key
137
+ * (`gateCutovers.objectivesSinceIssue`, resolved by `resolveGateCutovers` in
138
+ * `apps/cli/src/lib/config.ts`) passed into this gate as `sinceIssue`; an
139
+ * absent key resolves to `null` (NO cutover — the gate applies from Issue 1,
140
+ * O1), never to this constant. This repository restates this number as its own
141
+ * `gateCutovers.objectivesSinceIssue` so its behaviour is unchanged (O2). The
142
+ * constant stays exported as the parameter default so a caller that does not
143
+ * resolve config (a test, an authoring path) keeps this repo's behaviour. Same
144
+ * shape as `BRIEF_RULES_SINCE_PR` (`brief-validation.ts`).
112
145
  */
113
146
  export const OBJECTIVES_SINCE_ISSUE = 404
114
147
 
115
148
  /**
116
- * **The Objectives gate.** A task Issue numbered at or above
117
- * `OBJECTIVES_SINCE_ISSUE` must carry a well-formed `## Objectives` section
118
- * (`objectives.ts`'s `objectivesOf`) — one numbered, observable-outcome
119
- * sentence per line, contiguous from `O1`. Below the cutover, an Issue passes
120
- * unconditionally — the stock of older Issues stays green.
149
+ * **The Objectives gate.** A task Issue numbered at or above `sinceIssue` must
150
+ * carry a well-formed `## Objectives` section (`objectives.ts`'s
151
+ * `objectivesOf`) — one numbered, observable-outcome sentence per line,
152
+ * contiguous from `O1`. Below the cutover, an Issue passes unconditionally.
153
+ *
154
+ * `sinceIssue` is the resolved cutover: a number (grandfather Issues below it),
155
+ * or `null` for NO cutover — the gate then applies to every Issue, from 1 (a
156
+ * repository that declares no `gateCutovers`, O1). It defaults to
157
+ * `OBJECTIVES_SINCE_ISSUE` (this repo's historical value) only for a caller
158
+ * that does not resolve config; every enforcement path passes the resolved
159
+ * value, which is `null` when the key is absent.
121
160
  *
122
161
  * `issueNumber === null` (not yet known — an Issue being created has no
123
162
  * number until the write completes) is NOT exempted: fail-closed, the same
@@ -126,8 +165,12 @@ export const OBJECTIVES_SINCE_ISSUE = 404
126
165
  * far past the cutover, so this never blocks a legitimate create; what it
127
166
  * refuses is guessing an unknown number is old enough to skip.
128
167
  */
129
- export function checkIssueObjectives(body: string, issueNumber: number | null): IssueSectionResult {
130
- if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE) return { status: 'pass', errors: [] }
168
+ export function checkIssueObjectives(
169
+ body: string,
170
+ issueNumber: number | null,
171
+ sinceIssue: number | null = OBJECTIVES_SINCE_ISSUE
172
+ ): IssueSectionResult {
173
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue) return { status: 'pass', errors: [] }
131
174
  const result = objectivesOf(body)
132
175
  if (result.ok) return { status: 'pass', errors: [] }
133
176
  return { status: 'fail', errors: result.errors.map((e) => `issue-validation objectives: ${e}`) }
@@ -676,41 +719,59 @@ export function checkDocumentationCitesObjective(body: string): IssueSectionResu
676
719
  }
677
720
 
678
721
  /**
679
- * The Issue number from which the four judgment sections above become
680
- * mandatory — this Issue's own number, the first Issue this tranche cut.
681
- * Same cutover-by-Issue-number shape as `OBJECTIVES_SINCE_ISSUE`; a task
682
- * Issue below this number legitimately carries none of the four.
722
+ * This repository's own historical brief-sections cutover — the first Issue
723
+ * this tranche cut, from which the four judgment sections became mandatory.
724
+ * Now the DEFAULT parameter value of `checkIssueBriefSections`, not the value
725
+ * the gate reads: the cutover is `vinaya.config.json`'s optional
726
+ * `gateCutovers.briefSectionsSinceIssue` (absent → `null` → gate from Issue 1,
727
+ * O1), restated as this repo's own value (O2). Same shape as
728
+ * `OBJECTIVES_SINCE_ISSUE`.
683
729
  */
684
730
  export const BRIEF_SECTIONS_SINCE_ISSUE = 426
685
731
 
686
732
  /**
687
- * The Issue number from which `## Documentation` becomes mandatory alongside
688
- * the four sections above — deliberately one past this requirement's own
689
- * Issue (the highest Issue number in existence when it was authored),
690
- * so no open or historical Issue is invalidated by the new requirement and
691
- * `issue edit` on one never starts refusing a body it could not have carried
692
- * the section in. Never grandfathered further back than that: unlike
693
- * `BRIEF_SECTIONS_SINCE_ISSUE`'s 426, there is no stock of Issues that
694
- * already carry a literal `## Documentation` heading by hand to preserve.
733
+ * This repository's own historical `## Documentation` cutover — one past that
734
+ * requirement's own Issue (the highest Issue number in existence when it was
735
+ * authored), so no open or historical Issue was invalidated by the new
736
+ * requirement. Now the DEFAULT parameter value of `checkIssueBriefSections`'s
737
+ * `sinceDocumentation`, not the value the gate reads: the cutover is
738
+ * `vinaya.config.json`'s optional `gateCutovers.documentationSinceIssue`
739
+ * (absent → `null` → gate from Issue 1, O1), restated as this repo's own value
740
+ * (O2). Never grandfathered further back than this: unlike
741
+ * `BRIEF_SECTIONS_SINCE_ISSUE`'s 426, there is no stock of Issues that already
742
+ * carry a literal `## Documentation` heading by hand to preserve.
695
743
  */
696
744
  export const DOCUMENTATION_SINCE_ISSUE = 626
697
745
 
698
746
  /**
699
747
  * **The brief-sections gate.** A task Issue numbered at or above
700
- * `BRIEF_SECTIONS_SINCE_ISSUE` must carry all four of `## Surface`,
701
- * `## Parts`, `## Test plan`, `## Stop conditions`, each well-formed per its
702
- * own parser above. Below the cutover, an Issue passes unconditionally.
703
- * `issueNumber === null` is NOT exempted — fail-closed, the same posture
704
- * `checkIssueObjectives` takes for an Issue with no number yet.
748
+ * `sinceBriefSections` must carry all four of `## Surface`, `## Parts`,
749
+ * `## Test plan`, `## Stop conditions`, each well-formed per its own parser
750
+ * above. Below the cutover, an Issue passes unconditionally.
751
+ *
752
+ * `sinceBriefSections`/`sinceDocumentation` are the resolved cutovers: a number
753
+ * (grandfather Issues below it), or `null` for NO cutover — the gate then
754
+ * applies to every Issue, from 1 (a repository that declares no `gateCutovers`,
755
+ * O1). They default to this repo's historical constants only for a caller that
756
+ * does not resolve config; every enforcement path passes the resolved values,
757
+ * which are `null` when the key is absent. `issueNumber === null` is NOT
758
+ * exempted — fail-closed, the same posture `checkIssueObjectives` takes.
705
759
  *
706
760
  * A fifth section, `## Documentation`, is folded into this same gate rather
707
- * than a new builtin (O1) — it is graded on its own, later
708
- * cutover (`DOCUMENTATION_SINCE_ISSUE`), since no pre-existing Issue ever
709
- * carried it and requiring it retroactively on an `issue edit` would refuse a
710
- * body no author had reason to write that way.
761
+ * than a new builtin — it is graded on its own, later cutover
762
+ * (`sinceDocumentation`), since no pre-existing Issue ever carried it and
763
+ * requiring it retroactively on an `issue edit` would refuse a body no author
764
+ * had reason to write that way.
711
765
  */
712
- export function checkIssueBriefSections(body: string, issueNumber: number | null): IssueSectionResult {
713
- if (issueNumber !== null && issueNumber < BRIEF_SECTIONS_SINCE_ISSUE) return { status: 'pass', errors: [] }
766
+ export function checkIssueBriefSections(
767
+ body: string,
768
+ issueNumber: number | null,
769
+ sinceBriefSections: number | null = BRIEF_SECTIONS_SINCE_ISSUE,
770
+ sinceDocumentation: number | null = DOCUMENTATION_SINCE_ISSUE
771
+ ): IssueSectionResult {
772
+ if (sinceBriefSections !== null && issueNumber !== null && issueNumber < sinceBriefSections) {
773
+ return { status: 'pass', errors: [] }
774
+ }
714
775
 
715
776
  const errors: string[] = []
716
777
  const surface = parseIssueSurface(body)
@@ -722,7 +783,7 @@ export function checkIssueBriefSections(body: string, issueNumber: number | null
722
783
  const stopConditions = parseIssueStopConditions(body)
723
784
  if (!stopConditions.ok) errors.push(...stopConditions.errors.map((e) => `issue-validation Stop conditions: ${e}`))
724
785
 
725
- if (issueNumber === null || issueNumber >= DOCUMENTATION_SINCE_ISSUE) {
786
+ if (sinceDocumentation === null || issueNumber === null || issueNumber >= sinceDocumentation) {
726
787
  const documentation = parseIssueDocumentation(body)
727
788
  if (!documentation.ok) errors.push(...documentation.errors.map((e) => `issue-validation Documentation: ${e}`))
728
789
  else errors.push(...checkDocumentationCitesObjective(body).errors)
@@ -1266,11 +1327,15 @@ const BLAST_RADIUS_ACK_RE = /(?:\*\*)?blast-radius-ack(?:\*\*)?\s*[:—–-]/i
1266
1327
  * touch `packages/ui`") — a negation the text scan below cannot tell apart
1267
1328
  * from a real touch-claim, and a heuristic in a blocking gate is wrong in
1268
1329
  * both directions. `## Surface`'s `in:` glob list is parsed structure with
1269
- * no negation to misread: at or above `BRIEF_SECTIONS_SINCE_ISSUE`, where
1330
+ * no negation to misread: at or above the brief-sections cutover, where
1270
1331
  * every task Issue carries one, a shared domain is "named" iff a declared
1271
1332
  * `in:` glob covers it (`globCoversPath`) — never by scanning prose for the
1272
1333
  * domain's name. Below the cutover, an Issue legitimately carries no
1273
- * `## Surface` at all, so the original prose scan is unchanged.
1334
+ * `## Surface` at all, so the original prose scan is unchanged. The cutover is
1335
+ * the resolved `sinceBriefSections` (`gateCutovers.briefSectionsSinceIssue`,
1336
+ * an absent key → `null` → NO cutover, so `## Surface` decides from Issue 1,
1337
+ * O1); it defaults to `BRIEF_SECTIONS_SINCE_ISSUE` only for a caller that does
1338
+ * not resolve config.
1274
1339
  * `issueNumber` follows the same fail-closed posture as
1275
1340
  * `checkIssueObjectives`/`checkIssueBriefSections`: `null` (not yet known,
1276
1341
  * e.g. `issue create`) is NOT treated as "at or above the cutover" — it
@@ -1282,10 +1347,11 @@ export function checkBlastRadiusScope(
1282
1347
  _labels: string[],
1283
1348
  sharedPackages: string[],
1284
1349
  projectPaths: ProjectPath[],
1285
- issueNumber: number | null = null
1350
+ issueNumber: number | null = null,
1351
+ sinceBriefSections: number | null = BRIEF_SECTIONS_SINCE_ISSUE
1286
1352
  ): IssueSectionResult {
1287
1353
  if (sharedPackages.length === 0) return { status: 'pass', errors: [] }
1288
- const decideFromSurface = issueNumber !== null && issueNumber >= BRIEF_SECTIONS_SINCE_ISSUE
1354
+ const decideFromSurface = issueNumber !== null && (sinceBriefSections === null || issueNumber >= sinceBriefSections)
1289
1355
  let named: string[]
1290
1356
  if (decideFromSurface) {
1291
1357
  const surface = parseIssueSurface(body)
@@ -1476,15 +1542,24 @@ export function checkRationaleNamesDocs(body: string): IssueSectionResult {
1476
1542
  * simply does not enclose is now accepted; a pointer the surface explicitly
1477
1543
  * excludes still is not.
1478
1544
  *
1479
- * At or above `BRIEF_SECTIONS_SINCE_ISSUE` only — below it an Issue
1545
+ * At or above the brief-sections cutover only — below it an Issue
1480
1546
  * legitimately carries no `## Surface` to compare against, same cutover
1481
- * every other Surface-aware check in this module uses. Passes trivially
1482
- * when the Surface itself doesn't parse (`checkIssueBriefSections` already
1483
- * reports that malformation) or the docs field carries the `no-doc-surface`
1484
- * sentinel (nothing to compare).
1547
+ * every other Surface-aware check in this module uses. The cutover is the
1548
+ * resolved `sinceBriefSections` (`gateCutovers.briefSectionsSinceIssue`, an
1549
+ * absent key → `null` → NO cutover, so this gate applies from Issue 1 wherever
1550
+ * `## Surface` is itself required from Issue 1, O1); it defaults to
1551
+ * `BRIEF_SECTIONS_SINCE_ISSUE` only for a caller that does not resolve config.
1552
+ * Passes trivially when the Surface itself doesn't parse
1553
+ * (`checkIssueBriefSections` already reports that malformation) or the docs
1554
+ * field carries the `no-doc-surface` sentinel (nothing to compare).
1485
1555
  */
1486
- export function checkDocsWithinSurface(body: string, issueNumber: number | null): IssueSectionResult {
1487
- if (issueNumber !== null && issueNumber < BRIEF_SECTIONS_SINCE_ISSUE) return { status: 'pass', errors: [] }
1556
+ export function checkDocsWithinSurface(
1557
+ body: string,
1558
+ issueNumber: number | null,
1559
+ sinceBriefSections: number | null = BRIEF_SECTIONS_SINCE_ISSUE
1560
+ ): IssueSectionResult {
1561
+ if (sinceBriefSections !== null && issueNumber !== null && issueNumber < sinceBriefSections)
1562
+ return { status: 'pass', errors: [] }
1488
1563
  const surface = parseIssueSurface(body)
1489
1564
  if (!surface.ok) return { status: 'pass', errors: [] }
1490
1565
 
@@ -1559,11 +1634,20 @@ function nearestInGlob(path: string, inGlobs: string[]): string {
1559
1634
  * decision undid; Boundary is where "what this task touches" is actually
1560
1635
  * declared.
1561
1636
  *
1562
- * At or above `BRIEF_SECTIONS_SINCE_ISSUE` only — below it an Issue
1563
- * legitimately carries no `## Surface` to compare against.
1637
+ * At or above the brief-sections cutover only — below it an Issue
1638
+ * legitimately carries no `## Surface` to compare against. The cutover is the
1639
+ * resolved `sinceBriefSections` (`gateCutovers.briefSectionsSinceIssue`, an
1640
+ * absent key → `null` → NO cutover, so this gate applies from Issue 1 wherever
1641
+ * `## Surface` is itself required from Issue 1, O1); it defaults to
1642
+ * `BRIEF_SECTIONS_SINCE_ISSUE` only for a caller that does not resolve config.
1564
1643
  */
1565
- export function checkRationaleSurfaceCoverage(body: string, issueNumber: number | null): IssueSectionResult {
1566
- if (issueNumber !== null && issueNumber < BRIEF_SECTIONS_SINCE_ISSUE) return { status: 'pass', errors: [] }
1644
+ export function checkRationaleSurfaceCoverage(
1645
+ body: string,
1646
+ issueNumber: number | null,
1647
+ sinceBriefSections: number | null = BRIEF_SECTIONS_SINCE_ISSUE
1648
+ ): IssueSectionResult {
1649
+ if (sinceBriefSections !== null && issueNumber !== null && issueNumber < sinceBriefSections)
1650
+ return { status: 'pass', errors: [] }
1567
1651
  const surface = parseIssueSurface(body)
1568
1652
  if (!surface.ok) return { status: 'pass', errors: [] }
1569
1653
 
@@ -1579,7 +1663,7 @@ export function checkRationaleSurfaceCoverage(body: string, issueNumber: number
1579
1663
  if (surface.value.out.some((g) => globCoversPath(g, path))) continue
1580
1664
  const nearest = nearestInGlob(path, surface.value.in)
1581
1665
  errors.push(
1582
- `issue-validation Boundary: \`${path}\` is named in the Boundary rationale, but no \`## Surface\` \`in:\` glob covers it — nearest is \`${nearest}\`. Widen the Surface's \`in:\` list to cover it, or correct the path if it was mistyped.`
1666
+ `issue-validation Boundary: \`${path}\` is named in the Boundary rationale, but no \`## Surface\` \`in:\` glob covers it — nearest is \`${nearest}\`. Widen an \`in:\` directory glob to cover it (\`## Surface\` lists directories, never a file path), or correct the path if it was mistyped.`
1583
1667
  )
1584
1668
  }
1585
1669
  return { status: errors.length > 0 ? 'fail' : 'pass', errors }
@@ -20,9 +20,23 @@ function attemptFromEnv(value: string | undefined): number | null {
20
20
  return Number.isInteger(n) ? n : null
21
21
  }
22
22
 
23
- /** Only a value the caller actually asserts becomes `parent_attributed`/`self_reported` — `buildHeader` never upgrades trust on its own (see `schema.ts`'s `ProvenanceSchema` doc). */
24
- function provenanceFor(input: Pick<HeaderInput, 'provenance' | 'env'>): Provenance {
23
+ /**
24
+ * Only a value the caller actually asserts becomes
25
+ * `parent_attributed`/`self_reported` — `buildHeader` never upgrades trust
26
+ * on its own (see `schema.ts`'s `ProvenanceSchema` doc). A `branchIssue`
27
+ * deliberately does NOT count as an environment correlation: nothing about a
28
+ * checked-out branch is one. An event whose `subject.issue` came from the
29
+ * branch therefore reads `'unavailable'` EVEN WHEN the environment named a
30
+ * role, because this one field describes the whole subject and there is no
31
+ * way to say "the role was env-correlated, the issue was guessed" — reading
32
+ * `'env_correlated'` beside a branch-guessed number would present a guess as
33
+ * a correlation, and a process with `VINAYA_ROLE` set and `VINAYA_TASK`
34
+ * absent or unparseable is exactly that shape. Under-claiming about the role
35
+ * is the safe direction; over-claiming about the issue is not.
36
+ */
37
+ function provenanceFor(input: Pick<HeaderInput, 'provenance' | 'env' | 'branchIssue'>): Provenance {
25
38
  if (input.provenance) return input.provenance
39
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null) return 'unavailable'
26
40
  if (input.env.role || input.env.task) return 'env_correlated'
27
41
  return 'unavailable'
28
42
  }
@@ -51,6 +65,15 @@ export type HeaderInput = {
51
65
  host: Host
52
66
  hostname: string
53
67
  env: { role?: string; task?: string; round?: string; run?: string; attempt?: string; parent?: string }
68
+ /**
69
+ * The Issue the caller's own checked-out branch names, for a process that
70
+ * carries no `VINAYA_TASK` — `subject.issue`'s fallback, never its
71
+ * override: an event that names its task in the environment keeps that
72
+ * number. `null`/absent when the branch names no task or its Issue could
73
+ * not be resolved, which stays `issue: null` rather than a guess. Read
74
+ * by the caller (the sink, from `git`/`gh`); this module stays pure.
75
+ */
76
+ branchIssue?: number | null
54
77
  subject?: Partial<Subject>
55
78
  /** Stable per-event identity (O1) — generated by the caller (the sink), once per `log()` call, never here (this module stays free of non-deterministic output). */
56
79
  eventId: string
@@ -82,7 +105,7 @@ export function buildHeader(input: HeaderInput): Header {
82
105
  const role: Subject['role'] = isRole(input.env.role) ? input.env.role : 'unattributed'
83
106
  const round = roundFromEnv(input.env.round)
84
107
  const subject: Subject = {
85
- issue: issueFromTask(input.env.task),
108
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
86
109
  role,
87
110
  ...(round !== undefined ? { round } : {}),
88
111
  ...(input.subject ?? {})
@@ -0,0 +1,31 @@
1
+ import { readFileSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+
4
+ /**
5
+ * `vinaya.config.json`'s `gateCutovers.objectivesSinceIssue` — the Objectives
6
+ * gate's cutover, read as plain JSON because aeg-core cannot depend on
7
+ * `apps/cli`'s zod resolver (`resolveGateCutovers`). Kept impure and OUT of
8
+ * `gate-cutovers.ts` (which is deliberately pure — the caller resolves config
9
+ * and passes the value in); the two aeg-core authoring bins (`open-issue.ts`,
10
+ * `verify-brief.ts`) ARE such callers and share this one reader rather than
11
+ * each declaring their own (the symbol-collision gate refuses a name that
12
+ * resolves to two source files).
13
+ *
14
+ * `null` for an absent key OR a malformed/missing config: NO cutover, so the
15
+ * Objectives gate applies to every task Issue, from Issue 1 (a repository that
16
+ * declares no `gateCutovers`, O1). This repository restates its historical
17
+ * value in its own config (O2), so this returns `404` here and the gate is
18
+ * unchanged. `repoRoot` defaults to the current working directory; a caller
19
+ * that has not `chdir`'d to the repo root passes it explicitly.
20
+ */
21
+ export function readConfigObjectivesSinceIssue(repoRoot = '.'): number | null {
22
+ try {
23
+ const raw = JSON.parse(readFileSync(join(repoRoot, 'vinaya.config.json'), 'utf8')) as {
24
+ gateCutovers?: { objectivesSinceIssue?: unknown }
25
+ }
26
+ const value = raw.gateCutovers?.objectivesSinceIssue
27
+ return typeof value === 'number' && Number.isInteger(value) && value >= 0 ? value : null
28
+ } catch {
29
+ return null
30
+ }
31
+ }
@@ -270,18 +270,27 @@ export function isIssueNotFoundError(err: unknown): boolean {
270
270
  * substitutes its own fetcher for the `'issue'` case rather than this
271
271
  * function reading anything itself.
272
272
  *
273
- * `cutoverIssue` is `OBJECTIVES_SINCE_ISSUE` (`issue-validation.ts`) — passed
274
- * in, not imported, because `issue-validation.ts` already imports FROM this
275
- * module (`objectivesOf`); importing the constant back would be circular.
273
+ * `cutoverIssue` is the resolved Objectives cutover (`gateCutovers.objectivesSinceIssue`,
274
+ * resolved by `resolveGateCutovers`, `apps/cli/src/lib/config.ts`) — passed in,
275
+ * not imported, because `issue-validation.ts` already imports FROM this module
276
+ * (`objectivesOf`); importing the constant back would be circular. A number
277
+ * grandfathers Issues below it; `null` means NO cutover — objectives grading
278
+ * applies to every Issue, from 1 (a repository that declares no `gateCutovers`,
279
+ * O1).
276
280
  */
277
281
  export type ObjectivesSource = { kind: 'issue'; issue: number } | { kind: 'body' } | { kind: 'none' }
278
282
 
279
- export function resolveObjectivesSource(prBody: string, issue: number | null, cutoverIssue: number): ObjectivesSource {
283
+ export function resolveObjectivesSource(
284
+ prBody: string,
285
+ issue: number | null,
286
+ cutoverIssue: number | null
287
+ ): ObjectivesSource {
280
288
  // Checked first and unconditionally: a pre-cutover Issue is `'none'`
281
289
  // regardless of what the PR body itself carries — a pre-cutover PR must
282
290
  // keep passing unchanged, never picking up a body-level objectives list
283
- // the Issue-linked case was never subject to.
284
- if (issue !== null && issue < cutoverIssue) return { kind: 'none' }
291
+ // the Issue-linked case was never subject to. A `null` cutover means no
292
+ // grandfathering, so this branch never fires and every Issue is graded.
293
+ if (issue !== null && cutoverIssue !== null && issue < cutoverIssue) return { kind: 'none' }
285
294
  if (issue !== null) return { kind: 'issue', issue }
286
295
  if (hasObjectivesHeading(prBody)) return { kind: 'body' }
287
296
  return { kind: 'none' }