@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
@@ -6,13 +6,19 @@
6
6
  */
7
7
 
8
8
  import { SUMMARY_TABLE_HEADER } from './journal-reconstruction'
9
- import { SEVERITY_COLUMNS, type Confidence, type Journal, type RoundRecord } from './types'
9
+ import { SEVERITY_COLUMNS, type Confidence, type Journal, type NotReviewedReason, type RoundRecord } from './types'
10
10
 
11
11
  /**
12
12
  * The two non-numeric cells this table writes, named once so the parser below
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,52 @@ 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. Two kinds carry none: a round rebuilt
42
+ * from the pull request's own round markers after a restart, which name a
43
+ * round's number and head and carry no finding breakdown at all
44
+ * (`journal-reconstruction.ts`); and a round no reviewer ever saw — its gate
45
+ * was red, or a low confidence sent the developer back — which records no
46
+ * counts on purpose (`buildUnreviewedRecord`, `assess-round.ts`) and names why
47
+ * in its outcome cell (`outcomeCell` below). Writing `0` for those cells told a
48
+ * reader the round was clean — four rounds of a real task's published table
49
+ * read as zero findings when the truth was that nobody knew, and an unreviewed
50
+ * round read as a clean review that never ran. The distinction is whether the
51
+ * counts were recorded, never whether they are zero: a round the loop assessed
52
+ * and found nothing in still reads `0`, because that zero is a measurement.
53
+ */
54
+ function countCells(record: RoundRecord): string[] {
55
+ const recorded = SEVERITY_COLUMNS.some((key) => record.countsBySeverity[key] !== undefined)
56
+ if (!recorded) return SEVERITY_COLUMNS.map(() => CONFIDENCE_NOT_ASKED_CELL)
57
+ return SEVERITY_COLUMNS.map((key) => String(record.countsBySeverity[key] ?? 0))
58
+ }
59
+
60
+ /**
61
+ * The outcome cell. A round the loop assessed (or one rebuilt from a marker)
62
+ * prints its own `outcome` verbatim — the vocabulary `render-summary.test.ts`
63
+ * pins (`green`, `changes_requested`, `escalated`, `stopped`). A round no
64
+ * reviewer saw (`notReviewed` set, `buildUnreviewedRecord` in
65
+ * `assess-round.ts`) instead states that no review ran and why, so a reader
66
+ * never takes its `—` counts for a clean round the way the old `0` /
67
+ * `changes_requested` row read.
68
+ */
69
+ const NOT_REVIEWED_REASON_TEXT: Record<NotReviewedReason, string> = {
70
+ checks_red: 'checks red',
71
+ low_confidence: 'low confidence'
72
+ }
73
+
74
+ function outcomeCell(record: RoundRecord): string {
75
+ if (record.notReviewed !== undefined) return `not reviewed — ${NOT_REVIEWED_REASON_TEXT[record.notReviewed]}`
76
+ return record.outcome
77
+ }
78
+
29
79
  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} |`
80
+ return `| ${record.round} | ${countCells(record).join(' | ')} | ${confidenceCell(record.confidence)} | ${outcomeCell(record)} |`
32
81
  }
33
82
 
34
83
  export function renderSummary(journal: Journal): string {
@@ -184,12 +184,40 @@ export type Decision =
184
184
  */
185
185
  export type RoundOutcome = 'green' | 'changes_requested' | 'escalated' | 'stopped'
186
186
 
187
+ /**
188
+ * Why a round ended before any reviewer ran, for the published table's outcome
189
+ * cell. A round no reviewer saw has no findings from any source, so it records
190
+ * no counts at all (an empty `countsBySeverity`, `render-summary.ts`' own `—`)
191
+ * rather than a zero that reads as a clean review — and this names the reason
192
+ * the outcome cell states instead of the log-parity `outcome` a reviewed round
193
+ * carries:
194
+ *
195
+ * - `'checks_red'` — the round's gate observation was not green, so reviewers
196
+ * were never dispatched;
197
+ * - `'low_confidence'` — a below-threshold confidence sent the developer back
198
+ * without dispatching reviewers.
199
+ *
200
+ * `outcome` stays whatever the round would otherwise carry (both reasons are
201
+ * `changes_requested` today), so the `round_ended` log event a reader parses is
202
+ * unaffected — only the summary table's rendering changes.
203
+ */
204
+ export type NotReviewedReason = 'checks_red' | 'low_confidence'
205
+
187
206
  /** One row of the published summary (`renderSummary`, O4) — counts only, no finding prose. */
188
207
  export type RoundRecord = {
189
208
  round: number
190
209
  countsBySeverity: Record<string, number>
191
210
  confidence: Confidence | null
192
211
  outcome: RoundOutcome
212
+ /**
213
+ * Set only for a round no reviewer saw (`buildUnreviewedRecord`,
214
+ * `assess-round.ts`): its counts are absent (empty `countsBySeverity`) and the
215
+ * table's outcome cell names this reason. Absent for every round the loop
216
+ * assessed and for a round rebuilt from a marker — a marker-reconstructed
217
+ * round's counts are likewise unknown, but the round DID reach review, so it
218
+ * keeps its `outcome`, not a not-reviewed reason.
219
+ */
220
+ notReviewed?: NotReviewedReason
193
221
  }
194
222
 
195
223
  export type Journal = { rounds: RoundRecord[] }
@@ -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,
@@ -580,6 +590,7 @@ export type {
580
590
  Journal,
581
591
  LoopConfig,
582
592
  LoopState,
593
+ NotReviewedReason,
583
594
  Observations,
584
595
  PauseReason,
585
596
  PendingRound,
@@ -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}`) }
@@ -258,10 +301,20 @@ export function parseIssueSurface(body: string): ParsedIssueSection<IssueSurface
258
301
  * — shared by O4 (does a `## Surface` `in:` glob touch a shared collision
259
302
  * domain?) and O6 (does a `## Surface` glob contain a doc pointer?). Both
260
303
  * sides are stripped of a trailing `/**`/`/*` and any trailing slash first.
304
+ *
305
+ * **The root glob `*` names the repository-root files.** A bare `*` covers
306
+ * every tracked path with no `/` (`README.md`, `LICENSE`) — and ONLY those.
307
+ * It never admits a nested path, so the common `in: *, out: apps` shape still
308
+ * excludes `apps/...`, and `*` in an `out:` list excludes only root-level
309
+ * files. Without this case a bare `*` covered nothing real — no legal glob
310
+ * admitted a repository-root file, so a Boundary pinning `README.md` could not
311
+ * validate and its brief rendered an empty file list. Only `*` is the
312
+ * root glob; `.` keeps its existing prefix behaviour unchanged.
261
313
  */
262
314
  export function globCoversPath(glob: string, path: string): boolean {
263
315
  const g = glob.replace(/\/\*\*?$/, '').replace(/\/+$/, '')
264
316
  const p = path.replace(/\/+$/, '')
317
+ if (g === '*') return !p.includes('/')
265
318
  return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`)
266
319
  }
267
320
 
@@ -676,41 +729,59 @@ export function checkDocumentationCitesObjective(body: string): IssueSectionResu
676
729
  }
677
730
 
678
731
  /**
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.
732
+ * This repository's own historical brief-sections cutover — the first Issue
733
+ * this tranche cut, from which the four judgment sections became mandatory.
734
+ * Now the DEFAULT parameter value of `checkIssueBriefSections`, not the value
735
+ * the gate reads: the cutover is `vinaya.config.json`'s optional
736
+ * `gateCutovers.briefSectionsSinceIssue` (absent → `null` → gate from Issue 1,
737
+ * O1), restated as this repo's own value (O2). Same shape as
738
+ * `OBJECTIVES_SINCE_ISSUE`.
683
739
  */
684
740
  export const BRIEF_SECTIONS_SINCE_ISSUE = 426
685
741
 
686
742
  /**
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.
743
+ * This repository's own historical `## Documentation` cutover — one past that
744
+ * requirement's own Issue (the highest Issue number in existence when it was
745
+ * authored), so no open or historical Issue was invalidated by the new
746
+ * requirement. Now the DEFAULT parameter value of `checkIssueBriefSections`'s
747
+ * `sinceDocumentation`, not the value the gate reads: the cutover is
748
+ * `vinaya.config.json`'s optional `gateCutovers.documentationSinceIssue`
749
+ * (absent → `null` → gate from Issue 1, O1), restated as this repo's own value
750
+ * (O2). Never grandfathered further back than this: unlike
751
+ * `BRIEF_SECTIONS_SINCE_ISSUE`'s 426, there is no stock of Issues that already
752
+ * carry a literal `## Documentation` heading by hand to preserve.
695
753
  */
696
754
  export const DOCUMENTATION_SINCE_ISSUE = 626
697
755
 
698
756
  /**
699
757
  * **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.
758
+ * `sinceBriefSections` must carry all four of `## Surface`, `## Parts`,
759
+ * `## Test plan`, `## Stop conditions`, each well-formed per its own parser
760
+ * above. Below the cutover, an Issue passes unconditionally.
761
+ *
762
+ * `sinceBriefSections`/`sinceDocumentation` are the resolved cutovers: a number
763
+ * (grandfather Issues below it), or `null` for NO cutover — the gate then
764
+ * applies to every Issue, from 1 (a repository that declares no `gateCutovers`,
765
+ * O1). They default to this repo's historical constants only for a caller that
766
+ * does not resolve config; every enforcement path passes the resolved values,
767
+ * which are `null` when the key is absent. `issueNumber === null` is NOT
768
+ * exempted — fail-closed, the same posture `checkIssueObjectives` takes.
705
769
  *
706
770
  * 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.
771
+ * than a new builtin — it is graded on its own, later cutover
772
+ * (`sinceDocumentation`), since no pre-existing Issue ever carried it and
773
+ * requiring it retroactively on an `issue edit` would refuse a body no author
774
+ * had reason to write that way.
711
775
  */
712
- export function checkIssueBriefSections(body: string, issueNumber: number | null): IssueSectionResult {
713
- if (issueNumber !== null && issueNumber < BRIEF_SECTIONS_SINCE_ISSUE) return { status: 'pass', errors: [] }
776
+ export function checkIssueBriefSections(
777
+ body: string,
778
+ issueNumber: number | null,
779
+ sinceBriefSections: number | null = BRIEF_SECTIONS_SINCE_ISSUE,
780
+ sinceDocumentation: number | null = DOCUMENTATION_SINCE_ISSUE
781
+ ): IssueSectionResult {
782
+ if (sinceBriefSections !== null && issueNumber !== null && issueNumber < sinceBriefSections) {
783
+ return { status: 'pass', errors: [] }
784
+ }
714
785
 
715
786
  const errors: string[] = []
716
787
  const surface = parseIssueSurface(body)
@@ -722,7 +793,7 @@ export function checkIssueBriefSections(body: string, issueNumber: number | null
722
793
  const stopConditions = parseIssueStopConditions(body)
723
794
  if (!stopConditions.ok) errors.push(...stopConditions.errors.map((e) => `issue-validation Stop conditions: ${e}`))
724
795
 
725
- if (issueNumber === null || issueNumber >= DOCUMENTATION_SINCE_ISSUE) {
796
+ if (sinceDocumentation === null || issueNumber === null || issueNumber >= sinceDocumentation) {
726
797
  const documentation = parseIssueDocumentation(body)
727
798
  if (!documentation.ok) errors.push(...documentation.errors.map((e) => `issue-validation Documentation: ${e}`))
728
799
  else errors.push(...checkDocumentationCitesObjective(body).errors)
@@ -1266,11 +1337,15 @@ const BLAST_RADIUS_ACK_RE = /(?:\*\*)?blast-radius-ack(?:\*\*)?\s*[:—–-]/i
1266
1337
  * touch `packages/ui`") — a negation the text scan below cannot tell apart
1267
1338
  * from a real touch-claim, and a heuristic in a blocking gate is wrong in
1268
1339
  * both directions. `## Surface`'s `in:` glob list is parsed structure with
1269
- * no negation to misread: at or above `BRIEF_SECTIONS_SINCE_ISSUE`, where
1340
+ * no negation to misread: at or above the brief-sections cutover, where
1270
1341
  * every task Issue carries one, a shared domain is "named" iff a declared
1271
1342
  * `in:` glob covers it (`globCoversPath`) — never by scanning prose for the
1272
1343
  * domain's name. Below the cutover, an Issue legitimately carries no
1273
- * `## Surface` at all, so the original prose scan is unchanged.
1344
+ * `## Surface` at all, so the original prose scan is unchanged. The cutover is
1345
+ * the resolved `sinceBriefSections` (`gateCutovers.briefSectionsSinceIssue`,
1346
+ * an absent key → `null` → NO cutover, so `## Surface` decides from Issue 1,
1347
+ * O1); it defaults to `BRIEF_SECTIONS_SINCE_ISSUE` only for a caller that does
1348
+ * not resolve config.
1274
1349
  * `issueNumber` follows the same fail-closed posture as
1275
1350
  * `checkIssueObjectives`/`checkIssueBriefSections`: `null` (not yet known,
1276
1351
  * e.g. `issue create`) is NOT treated as "at or above the cutover" — it
@@ -1282,10 +1357,11 @@ export function checkBlastRadiusScope(
1282
1357
  _labels: string[],
1283
1358
  sharedPackages: string[],
1284
1359
  projectPaths: ProjectPath[],
1285
- issueNumber: number | null = null
1360
+ issueNumber: number | null = null,
1361
+ sinceBriefSections: number | null = BRIEF_SECTIONS_SINCE_ISSUE
1286
1362
  ): IssueSectionResult {
1287
1363
  if (sharedPackages.length === 0) return { status: 'pass', errors: [] }
1288
- const decideFromSurface = issueNumber !== null && issueNumber >= BRIEF_SECTIONS_SINCE_ISSUE
1364
+ const decideFromSurface = issueNumber !== null && (sinceBriefSections === null || issueNumber >= sinceBriefSections)
1289
1365
  let named: string[]
1290
1366
  if (decideFromSurface) {
1291
1367
  const surface = parseIssueSurface(body)
@@ -1476,15 +1552,24 @@ export function checkRationaleNamesDocs(body: string): IssueSectionResult {
1476
1552
  * simply does not enclose is now accepted; a pointer the surface explicitly
1477
1553
  * excludes still is not.
1478
1554
  *
1479
- * At or above `BRIEF_SECTIONS_SINCE_ISSUE` only — below it an Issue
1555
+ * At or above the brief-sections cutover only — below it an Issue
1480
1556
  * 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).
1557
+ * every other Surface-aware check in this module uses. The cutover is the
1558
+ * resolved `sinceBriefSections` (`gateCutovers.briefSectionsSinceIssue`, an
1559
+ * absent key → `null` → NO cutover, so this gate applies from Issue 1 wherever
1560
+ * `## Surface` is itself required from Issue 1, O1); it defaults to
1561
+ * `BRIEF_SECTIONS_SINCE_ISSUE` only for a caller that does not resolve config.
1562
+ * Passes trivially when the Surface itself doesn't parse
1563
+ * (`checkIssueBriefSections` already reports that malformation) or the docs
1564
+ * field carries the `no-doc-surface` sentinel (nothing to compare).
1485
1565
  */
1486
- export function checkDocsWithinSurface(body: string, issueNumber: number | null): IssueSectionResult {
1487
- if (issueNumber !== null && issueNumber < BRIEF_SECTIONS_SINCE_ISSUE) return { status: 'pass', errors: [] }
1566
+ export function checkDocsWithinSurface(
1567
+ body: string,
1568
+ issueNumber: number | null,
1569
+ sinceBriefSections: number | null = BRIEF_SECTIONS_SINCE_ISSUE
1570
+ ): IssueSectionResult {
1571
+ if (sinceBriefSections !== null && issueNumber !== null && issueNumber < sinceBriefSections)
1572
+ return { status: 'pass', errors: [] }
1488
1573
  const surface = parseIssueSurface(body)
1489
1574
  if (!surface.ok) return { status: 'pass', errors: [] }
1490
1575
 
@@ -1559,11 +1644,20 @@ function nearestInGlob(path: string, inGlobs: string[]): string {
1559
1644
  * decision undid; Boundary is where "what this task touches" is actually
1560
1645
  * declared.
1561
1646
  *
1562
- * At or above `BRIEF_SECTIONS_SINCE_ISSUE` only — below it an Issue
1563
- * legitimately carries no `## Surface` to compare against.
1647
+ * At or above the brief-sections cutover only — below it an Issue
1648
+ * legitimately carries no `## Surface` to compare against. The cutover is the
1649
+ * resolved `sinceBriefSections` (`gateCutovers.briefSectionsSinceIssue`, an
1650
+ * absent key → `null` → NO cutover, so this gate applies from Issue 1 wherever
1651
+ * `## Surface` is itself required from Issue 1, O1); it defaults to
1652
+ * `BRIEF_SECTIONS_SINCE_ISSUE` only for a caller that does not resolve config.
1564
1653
  */
1565
- export function checkRationaleSurfaceCoverage(body: string, issueNumber: number | null): IssueSectionResult {
1566
- if (issueNumber !== null && issueNumber < BRIEF_SECTIONS_SINCE_ISSUE) return { status: 'pass', errors: [] }
1654
+ export function checkRationaleSurfaceCoverage(
1655
+ body: string,
1656
+ issueNumber: number | null,
1657
+ sinceBriefSections: number | null = BRIEF_SECTIONS_SINCE_ISSUE
1658
+ ): IssueSectionResult {
1659
+ if (sinceBriefSections !== null && issueNumber !== null && issueNumber < sinceBriefSections)
1660
+ return { status: 'pass', errors: [] }
1567
1661
  const surface = parseIssueSurface(body)
1568
1662
  if (!surface.ok) return { status: 'pass', errors: [] }
1569
1663
 
@@ -1579,7 +1673,7 @@ export function checkRationaleSurfaceCoverage(body: string, issueNumber: number
1579
1673
  if (surface.value.out.some((g) => globCoversPath(g, path))) continue
1580
1674
  const nearest = nearestInGlob(path, surface.value.in)
1581
1675
  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.`
1676
+ `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
1677
  )
1584
1678
  }
1585
1679
  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
+ }