@attalabs/vinaya 0.44.1 → 0.47.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 (143) hide show
  1. package/README.md +6 -4
  2. package/dist/checks/bin/check-body-bare-digits.js +233 -195
  3. package/dist/checks/bin/check-branch-topology.js +70 -23
  4. package/dist/checks/bin/check-brief-shape.js +233 -195
  5. package/dist/checks/bin/check-changeset-coverage.js +94 -16
  6. package/dist/checks/bin/check-ci-shard-coverage.js +3 -0
  7. package/dist/checks/bin/check-closes-n.js +128 -34
  8. package/dist/checks/bin/check-coherence.js +336 -245
  9. package/dist/checks/bin/check-dispatch-readiness.js +3623 -463
  10. package/dist/checks/bin/check-doc-claims.js +233 -195
  11. package/dist/checks/bin/check-doc-coverage-push.js +243 -196
  12. package/dist/checks/bin/check-doc-coverage.js +243 -196
  13. package/dist/checks/bin/check-doctrine-no-procedures.js +233 -195
  14. package/dist/checks/bin/check-doctrine-portability.js +233 -195
  15. package/dist/checks/bin/check-evidence-fresh.js +9983 -1995
  16. package/dist/checks/bin/check-exec-bits.js +3 -0
  17. package/dist/checks/bin/check-first-push-dispatch.js +301 -224
  18. package/dist/checks/bin/check-issue-milestone-attach.js +65 -10
  19. package/dist/checks/bin/check-issue-objectives-numbering.js +233 -195
  20. package/dist/checks/bin/check-issue-parts-coverage.js +65 -10
  21. package/dist/checks/bin/check-issue-surface-globs.js +1032 -236
  22. package/dist/checks/bin/check-issue-title-grammar.js +5 -1
  23. package/dist/checks/bin/check-no-disk-state.js +5 -1
  24. package/dist/checks/bin/check-pr-premise-reassert.js +10 -1
  25. package/dist/checks/bin/check-pr-report-density.js +5 -1
  26. package/dist/checks/bin/check-principal-test-plan-wait.js +253 -201
  27. package/dist/checks/bin/check-quoted-command.js +233 -195
  28. package/dist/checks/bin/check-reader-resolvable-prose.js +233 -195
  29. package/dist/checks/bin/check-registry-gates.js +131 -34
  30. package/dist/checks/bin/check-retired-vocabulary.js +233 -195
  31. package/dist/checks/bin/check-review-gate.js +233 -195
  32. package/dist/checks/bin/check-single-plan-pr.js +5 -1
  33. package/dist/checks/bin/check-surface-scope.js +107 -32
  34. package/dist/checks/bin/check-test-plan.js +253 -201
  35. package/dist/checks/bin/check-token-collection-wired.js +3 -0
  36. package/dist/checks/bin/check-workspace-escape.js +3 -0
  37. package/dist/checks/bin/verify-coherence.js +237 -148
  38. package/dist/checks/bin/verify-dispatch.js +870 -66
  39. package/dist/checks/bin/verify-docs.js +13 -6
  40. package/dist/harness.js +57 -10
  41. package/dist/index.js +16617 -7187
  42. package/dist/lib/pre-push-cache-test-run.js +4487 -2170
  43. package/dist/lib/pre-push-changed-files.js +251 -12
  44. package/dist/lib/pre-push-mode.js +69 -19
  45. package/dist/lib/pre-push-progress-dir.js +10265 -2853
  46. package/dist/lib/pre-push-record-tests.js +67 -19
  47. package/dist/lib/pre-push-select-tests.js +520 -222
  48. package/dist/lib/push-progress-observer.js +9176 -1757
  49. package/dist/process.js +2 -0
  50. package/dist/programs/archive.js +8948 -1547
  51. package/dist/programs/audit.js +9176 -1772
  52. package/dist/programs/check.js +9248 -1845
  53. package/dist/programs/commit-msg.js +8984 -1583
  54. package/dist/programs/dev-review-loop.js +15612 -7634
  55. package/dist/programs/dispatch.js +9977 -2726
  56. package/dist/programs/log-emit.js +9011 -1660
  57. package/dist/programs/log-selftest.js +8908 -1507
  58. package/dist/programs/log-send.js +9081 -1594
  59. package/dist/programs/pr-report.js +9476 -1820
  60. package/dist/programs/pr-snapshot.js +8916 -1515
  61. package/dist/programs/pr-verify-evidence.js +9481 -1825
  62. package/dist/programs/pr.js +11709 -4033
  63. package/dist/programs/review-post.js +11140 -3496
  64. package/dist/programs/review-status.js +8996 -1533
  65. package/dist/programs/run-engine.js +22031 -18759
  66. package/dist/programs/sync.js +9030 -1629
  67. package/dist/programs/task-brief.js +10185 -1821
  68. package/dist/programs/task-sweep.js +9266 -1621
  69. package/dist/programs/task-tools-serve.js +77118 -16678
  70. package/dist/programs/tokens.js +8966 -1565
  71. package/dist/programs/waiver.js +8983 -1582
  72. package/dist/types/harness/kernel/dev-process-socket/loader/load-process.d.ts +1 -1
  73. package/dist/types/harness/processes/vinaya-strict/tools/legacy-markers.d.ts +8 -0
  74. package/dist/types/harness/processes/vinaya-strict/tools/task-contract/brief-validation.d.ts +3 -3
  75. package/dist/types/harness/processes/vinaya-strict/tools/task-contract/objectives.d.ts +5 -6
  76. package/dist/vinaya-strict/checks/registry.ts +2 -2
  77. package/dist/vinaya-strict/executing/developer/developer-doctrine-shape.test.ts +8 -0
  78. package/dist/vinaya-strict/executing/developer/developer-turn-result.ts +1 -1
  79. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.test.ts +2 -2
  80. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.ts +30 -20
  81. package/dist/vinaya-strict/executing/developer/reference.md +5 -3
  82. package/dist/vinaya-strict/integration/config/vinaya-config-section.ts +29 -7
  83. package/dist/vinaya-strict/integration/policies/vinaya-policies.ts +4 -4
  84. package/dist/vinaya-strict/integration/process/process-integration.ts +5 -1
  85. package/dist/vinaya-strict/process.yaml +6 -1
  86. package/dist/vinaya-strict/thinking/plan-reviewer/doctrine.md +68 -0
  87. package/dist/vinaya-strict/thinking/plan-reviewer/grants.yaml +19 -0
  88. package/dist/vinaya-strict/thinking/plan-reviewer/output.schema.json +388 -0
  89. package/dist/vinaya-strict/thinking/planner/doctrine.md +4 -1
  90. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.test.ts +10 -2
  91. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.ts +5 -1
  92. package/dist/vinaya-strict/thinking/planner/tools/open-issue.test.ts +198 -34
  93. package/dist/vinaya-strict/thinking/planner/tools/open-issue.ts +120 -193
  94. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.test.ts +629 -15
  95. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.ts +726 -62
  96. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.test.ts +505 -5
  97. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.ts +636 -21
  98. package/package.json +3 -2
  99. package/studio-standalone/apps/vinaya-studio/.next/BUILD_ID +1 -1
  100. package/studio-standalone/apps/vinaya-studio/.next/build-manifest.json +2 -2
  101. package/studio-standalone/apps/vinaya-studio/.next/prerender-manifest.json +3 -3
  102. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  103. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.html +1 -1
  104. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.rsc +1 -1
  105. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  106. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  107. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  108. package/studio-standalone/apps/vinaya-studio/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  109. package/studio-standalone/apps/vinaya-studio/.next/server/app/milestones/page_client-reference-manifest.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/.next/server/app/page_client-reference-manifest.js +1 -1
  111. package/studio-standalone/apps/vinaya-studio/.next/server/app/tasks/page_client-reference-manifest.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/.next/server/chunks/209.js +2 -2
  113. package/studio-standalone/apps/vinaya-studio/.next/server/chunks/951.js +1 -1
  114. package/studio-standalone/apps/vinaya-studio/.next/server/middleware-build-manifest.js +1 -1
  115. package/studio-standalone/apps/vinaya-studio/.next/server/pages/500.html +1 -1
  116. package/studio-standalone/apps/vinaya-studio/.next/server/preview-props.json +3 -3
  117. package/studio-standalone/apps/vinaya-studio/.next/server/server-reference-manifest.json +1 -1
  118. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/151-c365f0ef8268ad13.js +1 -0
  119. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/19-aa314f13784dcc58.js +4 -0
  120. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/{layout-dfa2186095e797bd.js → layout-f038e8deecb2bf5f.js} +1 -1
  121. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/milestones/{page-2fffb49104860a15.js → page-12314f4deb06a414.js} +1 -1
  122. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/{page-6ae258f663623b2a.js → page-7a06aa3cdd046fa8.js} +1 -1
  123. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/tasks/{page-2fffb49104860a15.js → page-12314f4deb06a414.js} +1 -1
  124. package/studio-standalone/apps/vinaya-studio/.next/static/css/8eb5ed5b65b9692e.css +1 -0
  125. package/studio-standalone/apps/vinaya-studio/log-follow.mjs +708 -93
  126. package/studio-standalone/apps/vinaya-studio/log-sync-folder-source.mjs +699 -84
  127. package/studio-standalone/apps/vinaya-studio/studio-server.mjs +4692 -3116
  128. package/vinaya-strict/artifacts/templates/brief-template.md +4 -0
  129. package/vinaya-strict/artifacts/templates/issue-rationale-template.md +7 -3
  130. package/vinaya-strict/artifacts/templates/pr-report-template.md +1 -1
  131. package/vinaya-strict/doctrine/contracts/planner-developer.md +2 -1
  132. package/vinaya-strict/doctrine/enforcement.md +4 -4
  133. package/vinaya-strict/doctrine/roles/principal.md +1 -1
  134. package/vinaya-strict/doctrine/state-machine.md +7 -2
  135. package/vinaya-strict/executing/developer/reference.md +5 -3
  136. package/vinaya-strict/thinking/plan-reviewer/doctrine.md +68 -0
  137. package/vinaya-strict/thinking/planner/doctrine.md +4 -1
  138. package/vinaya-strict/thinking/planner/reference.md +29 -8
  139. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/151-23bea4cac9687151.js +0 -1
  140. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/853-1d5548ff3a55a75f.js +0 -4
  141. package/studio-standalone/apps/vinaya-studio/.next/static/css/fb16828fc3128d4c.css +0 -1
  142. /package/studio-standalone/apps/vinaya-studio/.next/static/{3URbt6IPajL5OOhijN1-x → bJrgAp9Kl4JsCUYkeAYez}/_buildManifest.js +0 -0
  143. /package/studio-standalone/apps/vinaya-studio/.next/static/{3URbt6IPajL5OOhijN1-x → bJrgAp9Kl4JsCUYkeAYez}/_ssgManifest.js +0 -0
@@ -5,38 +5,30 @@
5
5
  * this repo. No hook intercepts a raw `gh issue create` /
6
6
  * `gh issue edit`; ring-1 CI re-validation is the backstop for one.
7
7
  *
8
- * Gate: a task Issue (any `vinaya/tranche:<slug>` label) must carry the full
9
- * eight-field Planner's rationale in its body (`checkIssueRationale`,
10
- * planner-brief contract) — refused locally otherwise, before anything
11
- * reaches the forge. Non-task Issues (no tranche label) pass through
12
- * unvalidated: the rationale contract does not apply to them.
8
+ * Gate: a task Issue (any `vinaya/tranche:<slug>` label, or a labelless body
9
+ * that is task-shaped) is graded by `validateTaskIssueOutcome` — the one
10
+ * validation the Planner tools call for `task_issue_create` and
11
+ * `task_issue_edit`, so a rule added there reaches this script with no edit
12
+ * here, and a draft this script passes is a draft the tools pass. It returns
13
+ * every finding at once; this script prints each with its check name and
14
+ * refuses when any is blocking, on `--validate-only`, on `create`, on `edit`
15
+ * and on `amend-deps`'s amended body. Non-task Issues pass through
16
+ * unvalidated.
13
17
  *
14
- * Content gate: past presence, several checks grade what those fields
15
- * SAY (and what the Issue carries) against the surface the task touches, and
16
- * refuse — `checkBlastRadiusScope`
17
- * (a shared collision domain — live-derived `packages/*` workspace members,
18
- * built-in cross-cutting defaults, plus `vinaya.config.json`
19
- * `blastRadius.extraDomains`, see `readSharedPackages` below — that no
20
- * declared project owns, without a second project or a `blast-radius-ack:`
21
- * line),
22
- * `checkProjectsRegistered` (every declared `**Project:**` name resolves
23
- * against `.vinaya/projects.md`),
24
- * `checkNoBriefContent` (brief-shaped sections belong in the brief, not here),
25
- * `checkRationaleNamesDocs` (name a doc/skill path, or the `no-doc-surface`
26
- * sentinel — the only read-obligation signal a forge write leaves, since no
27
- * other check observes what the Planner read before this forge write),
28
- * `checkIssueType` (exactly one `vinaya/type:*` label — `labels.ts`'s `type`
29
- * category, the commit-type vocabulary applied to the Issue instead of the
30
- * commit). **CREATE-only**, unlike its four siblings above: the label is
31
- * required going forward from this axis's own merge, never retroactively —
32
- * running it on `edit` too would refuse an unrelated edit to any
33
- * pre-existing Issue for lacking a label nothing ever asked it to carry, a
34
- * forced backfill through the only sanctioned edit path. See the `isEdit`
35
- * branch below.
36
- * `checkConflictCompleteness` warns on an undeclared collision-domain overlap
37
- * and never blocks. The five block-on-fail checks apply to task Issues only,
38
- * same as the rationale gate; `checkIssueType` additionally applies to
39
- * `create` only.
18
+ * The task-type label stays CREATE-only, inside that validation: running it on
19
+ * `edit` would refuse an unrelated edit to any pre-existing Issue for lacking
20
+ * a label nothing ever asked it to carry.
21
+ *
22
+ * Script-only, kept here: the tranche label length check (the forge's own
23
+ * 50-character cap, caught before `gh` returns an opaque 422), the leftover
24
+ * print, and the collision-domain warning (`checkConflictCompleteness`),
25
+ * printed after the gate's findings, which warns on an undeclared overlap and
26
+ * never blocks.
27
+ *
28
+ * The validation runs the registered Issue checks through the check runner,
29
+ * which records each run, so the entry installs the Log sink factory, the
30
+ * configuration provider and the check registry before it runs anything, the
31
+ * way every other entry point does.
40
32
  *
41
33
  * Label detection is per-path: on `create`, labels come from this command's
42
34
  * own argv (`--label` flags are naturally present there). On `edit`, argv is
@@ -56,43 +48,35 @@ import { execFileSync } from 'node:child_process'
56
48
  import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
57
49
  import { tmpdir } from 'node:os'
58
50
  import { join } from 'node:path'
51
+ import { installProcess } from '@harness/kernel/dev-process-socket/contract/install-process.js'
52
+ import { recordCliOperationAtExit } from '@harness/kernel/log/client/cli-operation-log.js'
53
+ import { vinayaProcessIntegration } from '@harness/workflow/integration/process/process-integration.js'
59
54
  import { amendRationaleDeps } from './amend-rationale-deps'
60
55
  import {
61
56
  findMilestoneAttachTargetForSlug,
62
57
  hasExplicitMilestoneFlag,
63
58
  type MilestoneAttachTarget
64
- } from '../../../tools/task-contract/forge/fetch-milestone'
65
- import { findTrancheSlug, trancheLabel, trancheSlugLengthError } from '../../../tools/task-contract/forge/labels'
66
- import { parseRationaleDeps } from '../../../tools/task-contract/forge/parse-rationale-deps'
59
+ } from '@harness/workflow/tools/task-contract/forge/fetch-milestone'
60
+ import {
61
+ findTrancheSlug,
62
+ trancheLabel,
63
+ trancheSlugLengthError
64
+ } from '@harness/workflow/tools/task-contract/forge/labels'
65
+ import { parseRationaleDeps } from '@harness/workflow/tools/task-contract/forge/parse-rationale-deps'
67
66
  import {
68
67
  deriveBuiltinCrossCuttingDefaults,
69
68
  deriveWorkspacePackageDomains,
70
69
  parsePnpmWorkspaceYaml
71
- } from '../../../tools/task-contract/blast-radius-domains'
72
- import { checkForgeTitle } from '../../../tools/task-contract/brief-validation'
70
+ } from '@harness/workflow/tools/task-contract/blast-radius-domains'
71
+ import { validateTaskIssueOutcome } from '@harness/workflow/tools/task-contract/forge/forge-write'
73
72
  import {
74
- checkBlastRadiusScope,
75
73
  checkConflictCompleteness,
76
- checkIssueObjectives,
77
- checkIssueRationale,
78
- checkIssueType,
79
- checkNoBriefContent,
80
- checkNoForeignTaskOwnership,
81
- checkProseAllowsBeyondSurfaceEdit,
82
- checkObjectivesRespectBoundary,
83
- checkPartsCiteDefinedObjectives,
84
- checkPartsCoverageAndSequence,
85
- checkProjectsRegistered,
86
- checkRationaleNamesDocs,
87
- checkSurfaceGlobsResolve,
88
74
  isTaskIssueBodyShaped,
89
75
  isTaskIssueLabelSet,
90
- type ProjectPath,
91
76
  type TaskIssueFacts
92
- } from '../../../tools/task-contract/issue-validation'
93
- import { classifyLeftover } from '../../../tools/task-contract/bin/leftover-detection'
94
- import { readConfigObjectivesSinceIssue } from '../../../tools/task-contract/objectives-cutover-config'
95
- import { parseRegistry } from '../../../tools/task-contract/parse-registry'
77
+ } from '@harness/workflow/tools/task-contract/issue-validation'
78
+ import { classifyLeftover } from '@harness/workflow/tools/task-contract/bin/leftover-detection'
79
+ import type { CheckError } from '@harness/kernel/gates/checks/contract'
96
80
 
97
81
  const REPO_ROOT = join(import.meta.dirname, '../../../../../..')
98
82
 
@@ -102,18 +86,6 @@ function parseIssueNumberFromRef(ref: string): number | null {
102
86
  return m ? Number.parseInt(m[1] as string, 10) : null
103
87
  }
104
88
 
105
- /** `git ls-files -- <glob>` non-empty — mirrors `apps/cli/src/lib/brief-assembly.ts`'s `expandGlob`, used the same way (`checkSurfaceGlobsResolve`'s `resolvesToFile` predicate). */
106
- function globResolvesToFile(glob: string): boolean {
107
- try {
108
- return (
109
- execFileSync('git', ['ls-files', '--', glob], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()
110
- .length > 0
111
- )
112
- } catch {
113
- return false
114
- }
115
- }
116
-
117
89
  function fail(msg: string): never {
118
90
  console.error(`\n[open-issue] REFUSED — ${msg}`)
119
91
  console.error('[open-issue] Nothing was sent to the forge. Fix the body and retry.')
@@ -249,6 +221,15 @@ function fetchForgeLabels(issueRef: string): string[] {
249
221
  }
250
222
  }
251
223
 
224
+ /** Why a hand create of a tranche task is refused. */
225
+ const PUBLISH_ONLY_REASON =
226
+ 'a tranche task is published only through the `plan_publish` tool, from the approved plan draft; this script does not create an Issue that carries a `vinaya/tranche:*` label (edit and --validate-only are unchanged).'
227
+
228
+ /** The reason a create is refused (a tranche-labelled one; an edit never is), or `null` when it may go on. */
229
+ export function createRefusalReason(labels: string[], isEdit: boolean): string | null {
230
+ return !isEdit && trancheSlugFromLabels(labels) !== null ? PUBLISH_ONLY_REASON : null
231
+ }
232
+
252
233
  /** First `vinaya/tranche:<slug>` label's slug, or `null` when the set carries none. */
253
234
  function trancheSlugFromLabels(labels: string[]): string | null {
254
235
  return findTrancheSlug(labels)
@@ -487,6 +468,35 @@ export function validateAmendFlags(flags: AmendDepsFlags): string | null {
487
468
  return null
488
469
  }
489
470
 
471
+ export type IssueValidate = typeof validateTaskIssueOutcome
472
+
473
+ /** One finding as this script prints it: severity mark, check name, message. */
474
+ export function formatFinding(e: CheckError): string {
475
+ return ` ${e.severity === 'warning' ? '!' : '✗'} [${e.check}] ${e.message}`
476
+ }
477
+
478
+ /**
479
+ * The one decision every write path of this script takes: the validation the
480
+ * Planner tools call, given the same arguments `createIssue`/`editIssue` give
481
+ * it (`issueRef` is `null` on a create, which has no number until the write
482
+ * completes). Returns every finding and whether any blocks; prints nothing.
483
+ */
484
+ export async function runIssueGate(
485
+ input: { body: string | null; title: string | null; labels: string[]; issueRef: string | null; ghArgs: string[] },
486
+ validate: IssueValidate = validateTaskIssueOutcome
487
+ ): Promise<{ errors: CheckError[]; blocking: boolean; renderSkipped: string | null }> {
488
+ const { body, title, labels, issueRef, ghArgs } = input
489
+ const isEdit = issueRef !== null
490
+ return validate(
491
+ body,
492
+ title,
493
+ labels,
494
+ isEdit ? 'open-issue edit' : 'open-issue',
495
+ isEdit ? parseIssueNumberFromRef(issueRef) : null,
496
+ isEdit ? { kind: 'edit', issueRef, ghArgs } : { kind: 'create', ghArgs }
497
+ )
498
+ }
499
+
490
500
  /** IO seams for {@link runAmendDeps}, injected so the orchestrator is testable without a real `gh`. */
491
501
  export type AmendDepsDeps = {
492
502
  fetchLabels: (issue: string) => string[]
@@ -495,6 +505,8 @@ export type AmendDepsDeps = {
495
505
  today: () => string
496
506
  log: (msg: string) => void
497
507
  fail: (msg: string) => never
508
+ /** The validation the Planner tools call; replaceable only so a test can observe the call. */
509
+ validate?: IssueValidate
498
510
  }
499
511
 
500
512
  /**
@@ -504,7 +516,7 @@ export type AmendDepsDeps = {
504
516
  * "test against real data, not assumptions" trap (Issue #481) enforced on
505
517
  * every invocation forever.
506
518
  */
507
- export function runAmendDeps(flags: AmendDepsFlags, deps: AmendDepsDeps): void {
519
+ export async function runAmendDeps(flags: AmendDepsFlags, deps: AmendDepsDeps): Promise<void> {
508
520
  const err = validateAmendFlags(flags)
509
521
  if (err) deps.fail(err)
510
522
  const issue = flags.issue as string
@@ -545,12 +557,15 @@ export function runAmendDeps(flags: AmendDepsFlags, deps: AmendDepsDeps): void {
545
557
  )
546
558
  }
547
559
 
548
- // Rationale gate — the amended body must still carry the full rationale.
549
- const rationale = checkIssueRationale(newBody)
550
- if (rationale.status === 'fail') {
551
- deps.fail(
552
- `amend-deps: the amended body no longer passes the rationale gate (${rationale.errors.join(' | ')}). Nothing written.`
553
- )
560
+ // The amended body goes through the validation the Planner tools call; a
561
+ // blocking finding refuses, and nothing is written.
562
+ const gate = await runIssueGate(
563
+ { body: newBody, title: null, labels, issueRef: issue, ghArgs: [] },
564
+ deps.validate ?? validateTaskIssueOutcome
565
+ )
566
+ for (const e of gate.errors) deps.log(formatFinding(e))
567
+ if (gate.blocking) {
568
+ deps.fail('amend-deps: the amended body fails the Issue checks above. Nothing written.')
554
569
  }
555
570
 
556
571
  if (flags.dryRun) {
@@ -654,15 +669,6 @@ export function readSharedPackages(repoRoot: string = REPO_ROOT): string[] {
654
669
  return [...new Set([...derived, ...defaults, ...configExtra])]
655
670
  }
656
671
 
657
- /** Registry rows (`projects.md`) — the authority for which project owns which path. Absent ⇒ nothing is owned. */
658
- function readProjectPaths(): ProjectPath[] {
659
- try {
660
- return parseRegistry(readFileSync(join(REPO_ROOT, '.vinaya/projects.md'), 'utf8'))
661
- } catch {
662
- return []
663
- }
664
- }
665
-
666
672
  /**
667
673
  * The tranche's other open task Issues, for check C. Best-effort by design:
668
674
  * C is warn-only, so a forge hiccup must degrade to "no warning", never to a
@@ -776,8 +782,7 @@ function ensureTrancheLabelExists(slug: string): void {
776
782
  /**
777
783
  * Whether the task-Issue content gate (rationale, blast-radius, project
778
784
  * registry, brief content, docs-read, Parts/Objectives/Surface, task-type)
779
- * applies at all. True on a `vinaya/tranche:*` label, same as before this
780
- * task, OR — O2/O3 (task 21, `#541`, round 2 review SECURITY HIGH) — a
785
+ * applies at all. True on a `vinaya/tranche:*` label, OR on a
781
786
  * labelless body that is still task-shaped: a legitimate backlog Issue,
782
787
  * never a Planner mistake to wave through unvalidated. Pulled out as its own
783
788
  * pure predicate (mirroring `apps/cli/src/lib/forge-write.ts`'s identical
@@ -789,32 +794,13 @@ export function appliesTaskIssueGate(labels: string[], body: string | null): boo
789
794
  return isTaskIssueLabelSet(labels) || (body !== null && isTaskIssueBodyShaped(body))
790
795
  }
791
796
 
792
- /**
793
- * The blast-radius rule for one write, given the Issue ref an `edit` names
794
- * (`null` on `create`). An edit passes the Issue's own number, so an Issue
795
- * numbered below the brief-sections cutover keeps the prose scan; a create has
796
- * no number yet and is judged from `## Surface`, exactly as `apps/cli`'s
797
- * `validateIssueContent` judges it. Pulled out so that number reaching the
798
- * rule is unit-testable without a real `gh` call.
799
- */
800
- export function blastRadiusErrorsForWrite(
801
- body: string,
802
- labels: string[],
803
- sharedPackages: string[],
804
- projectPaths: ProjectPath[],
805
- issueRef: string | null
806
- ): string[] {
807
- const issueNumber = issueRef === null ? null : parseIssueNumberFromRef(issueRef)
808
- return checkBlastRadiusScope(body, labels, sharedPackages, projectPaths, issueNumber).errors
809
- }
810
-
811
- export function main(): void {
797
+ export async function main(): Promise<void> {
812
798
  const argv = process.argv.slice(2)
813
799
  const validateOnly = argv.includes('--validate-only')
814
800
  const args = argv.filter((a) => a !== '--validate-only')
815
801
 
816
802
  if (args[0] === 'amend-deps') {
817
- runAmendDeps(parseAmendArgs(args.slice(1)), {
803
+ await runAmendDeps(parseAmendArgs(args.slice(1)), {
818
804
  fetchLabels: fetchForgeLabels,
819
805
  fetchBody: fetchForgeBody,
820
806
  editBody: ghEditBody,
@@ -842,7 +828,7 @@ export function main(): void {
842
828
  labels = [...new Set([...forgeLabels, ...labels])]
843
829
  }
844
830
 
845
- // O2/O3 (task 21, `#541`, round 2 review SECURITY HIGH): a labelless
831
+ // A labelless
846
832
  // backlog Issue is task-shaped content too — gating this whole content
847
833
  // gate on the label alone let a labelless body through with NONE of
848
834
  // `checkIssueRationale`/`checkBlastRadiusScope`/`checkProjectsRegistered`/
@@ -878,104 +864,36 @@ export function main(): void {
878
864
  }
879
865
  }
880
866
 
881
- const title = extractTitle(bodyArgs)
882
- if (title !== null) {
883
- const t = checkForgeTitle(title)
884
- if (t.status === 'fail') fail(t.errors[0] as string)
885
- }
886
- if (body === null) {
867
+ console.log('[open-issue] task Issue — running the validation the Planner tools run…')
868
+ const gate = await runIssueGate({
869
+ body,
870
+ title: extractTitle(bodyArgs),
871
+ labels,
872
+ issueRef: isEdit ? (ghArgs[0] as string) : null,
873
+ ghArgs: bodyArgs
874
+ })
875
+ for (const e of gate.errors) console.error(formatFinding(e))
876
+ if (gate.blocking) {
887
877
  fail(
888
- 'a task Issue (vinaya/tranche:* label) requires a `--body-file <path>` so the rationale gate can validate it.'
878
+ `the Issue body fails ${gate.errors.filter((e) => e.severity !== 'warning').length} Issue check(s) (named above).`
889
879
  )
890
880
  }
891
- console.log('[open-issue] task Issue (tranche label) — validating the Planner rationale…')
892
- const { status, errors } = checkIssueRationale(body)
893
- if (status === 'fail') {
894
- console.error(`\n[open-issue] FAILED — ${errors.length} rationale field(s) missing:\n`)
895
- for (const e of errors) console.error(` ✗ ${e}`)
896
- fail('the Issue body does not carry the full eight-field Planner rationale (planner-brief contract).')
881
+ if (gate.renderSkipped !== null) {
882
+ console.warn(`[open-issue] the brief render did not run (${gate.renderSkipped}) — this is not a full pass.`)
897
883
  }
898
- console.log('[open-issue] rationale gate PASS.')
884
+ console.log('[open-issue] Issue checks PASS.')
899
885
 
900
- // ---- content gate: A/B/D block, C warns --------------------------------
901
- // The rationale gate above proves the eight fields EXIST. These prove what
902
- // they say is consistent with the surface the task touches — the three
903
- // failure classes that passed the presence gate on #621/#622/#626.
886
+ // Warn-only, script-only. Never blocks: an Issue declares no precise file
887
+ // surface, so an overlapping collision domain is a hint, not a fact.
904
888
  const sharedPackages = readSharedPackages()
905
889
  if (sharedPackages.length === 0) {
906
890
  console.warn(
907
- '[open-issue] no collision domains derived, defaulted, or declared (no `packages/*` workspace, no cross-cutting default present, no `vinaya.config.json` blastRadius.extraDomains) — blast-radius check (A) is dormant.'
891
+ '[open-issue] no collision domains derived, defaulted, or declared (no `packages/*` workspace, no cross-cutting default present, no `vinaya.config.json` blastRadius.extraDomains) — the conflict-completeness warning is dormant.'
908
892
  )
909
893
  }
910
- const projectPaths = readProjectPaths()
911
- if (projectPaths.length === 0) {
912
- console.warn('[open-issue] no `.vinaya/projects.md` registry — the project-registry check is dormant.')
913
- }
914
- // checkIssueType is CREATE-ONLY, deliberately. "Forward-only, no
915
- // backfill" (task 10's §10 answer) means the label is required on a
916
- // task Issue from the moment it is CUT, not re-required every time it
917
- // is later edited — `open-issue.ts` is the only sanctioned edit path
918
- // for ANY Issue body, so running this check on `edit` too would refuse
919
- // an unrelated edit (a typo fix, a dependency update) to any Issue that
920
- // predates this axis, which is a de facto forced backfill through the
921
- // back door. A task Issue created after this merges gets the label at
922
- // creation and keeps it — nothing removes it — so skipping re-checks on
923
- // edit costs nothing for the forward case and exempts every pre-merge
924
- // Issue exactly as promised.
925
- const typeErrors = isEdit ? [] : checkIssueType(body, labels).errors
926
- // Three of the five write-only rules named apart:
927
- // objectives numbering, Parts coverage, Surface glob resolution.
928
- // `issueNumber` mirrors `apps/cli`'s own fail-closed-on-null posture
929
- // (`checkIssueObjectives`'s own doc comment): `create` has no number
930
- // until the write completes, and every Issue this repo can newly mint is
931
- // already far past the Objectives cutover, so this never blocks a
932
- // legitimate create. `checkPartsCiteDefinedObjectives`/
933
- // `checkSurfaceGlobsResolve` are dormant when the Issue carries no
934
- // `## Parts`/`## Surface` section at all. Title grammar is already
935
- // enforced above. Milestone attach's validating half is NOT wired here:
936
- // this script never re-attaches a Milestone on `edit` (its own
937
- // `resolveMilestoneToAttach` design), and its `create` attach happens as
938
- // part of this SAME write, so no moment here has an attach to verify.
939
- const issueNumber = isEdit ? parseIssueNumberFromRef(ghArgs[0] as string) : null
940
- const contentErrors = [
941
- ...blastRadiusErrorsForWrite(body, labels, sharedPackages, projectPaths, isEdit ? (ghArgs[0] as string) : null),
942
- ...checkProjectsRegistered(
943
- body,
944
- labels,
945
- projectPaths.map((p) => p.name)
946
- ).errors,
947
- ...checkNoBriefContent(body).errors,
948
- ...checkRationaleNamesDocs(body).errors,
949
- ...checkIssueObjectives(body, issueNumber, readConfigObjectivesSinceIssue(REPO_ROOT)).errors,
950
- ...checkPartsCiteDefinedObjectives(body).errors,
951
- ...checkSurfaceGlobsResolve(body, globResolvesToFile).errors,
952
- // The three Boundary/ownership/Parts-coverage predicates, wired here
953
- // identically to `apps/cli`'s own `validateIssueContent` so this
954
- // repo's own dogfooded Issue-write path (this script) and the
955
- // packaged CLI's `issue create`/`edit` can never disagree about
956
- // whether an Issue's Objectives/Boundary/Parts agree.
957
- ...checkObjectivesRespectBoundary(body).errors,
958
- ...checkNoForeignTaskOwnership(body).errors,
959
- ...checkProseAllowsBeyondSurfaceEdit(body).errors,
960
- ...checkPartsCoverageAndSequence(body).errors,
961
- ...typeErrors
962
- ]
963
- if (contentErrors.length > 0) {
964
- console.error(`\n[open-issue] FAILED — ${contentErrors.length} content check(s):\n`)
965
- for (const e of contentErrors) console.error(` ✗ ${e}`)
966
- fail('the Issue body fails the blast-radius / project-registry / brief-content / docs-read / task-type checks.')
967
- }
968
- console.log(
969
- `[open-issue] content gate PASS (blast radius, project registry, brief content, docs read${isEdit ? '' : ', task type'}).`
970
- )
971
- if (isEdit) {
972
- console.log('[open-issue] edit — task-type check skipped (create-only; forward-only enforcement, no backfill).')
973
- }
974
894
 
975
- // C — warn-only. Never blocks: an Issue declares no precise file surface,
976
- // so an overlapping collision domain is a hint, not a fact.
977
895
  const slug = trancheSlugFromLabels(labels)
978
- if (slug) {
896
+ if (slug && body !== null) {
979
897
  const selfRef = isEdit ? (ghArgs[0] as string) : null
980
898
  const conflictWarnings = checkConflictCompleteness(
981
899
  {
@@ -997,6 +915,11 @@ export function main(): void {
997
915
  process.exit(0)
998
916
  }
999
917
 
918
+ // A tranche task is published only by `plan_publish`, from the approved
919
+ // draft; this script writes no Issue that carries a tranche label.
920
+ const refusal = createRefusalReason(labels, isEdit)
921
+ if (refusal !== null) fail(refusal)
922
+
1000
923
  // Give the target tranche label a real chance to exist BEFORE `gh issue
1001
924
  // create`/`edit` ships — otherwise a brand-new tranche's first Issue fails
1002
925
  // outright at `gh` with `not found`, far from its actual cause.
@@ -1031,5 +954,9 @@ export function main(): void {
1031
954
 
1032
955
  if (import.meta.main) {
1033
956
  process.chdir(REPO_ROOT)
1034
- main()
957
+ installProcess(vinayaProcessIntegration, ['log', 'config', 'checks'])
958
+ recordCliOperationAtExit(['open-issue', ...process.argv.slice(2)], {
959
+ on: (event, handler) => process.on(event, handler)
960
+ })
961
+ await main()
1035
962
  }