@attalabs/vinaya 0.19.3 → 0.20.1

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 (112) hide show
  1. package/README.md +7 -0
  2. package/aeg-root/contracts/archivist-tranche-archivist.md +2 -2
  3. package/aeg-root/contracts/tranche-archivist-planner.md +8 -8
  4. package/aeg-root/enforcement.md +6 -4
  5. package/aeg-root/process.md +5 -5
  6. package/aeg-root/roles/archivist.md +9 -10
  7. package/aeg-root/roles/brief-author.md +1 -1
  8. package/aeg-root/roles/developer.md +1 -1
  9. package/aeg-root/roles/planner.md +1 -1
  10. package/aeg-root/roles/principal.md +1 -1
  11. package/aeg-root/roles/tranche-archivist.md +3 -16
  12. package/aeg-root/skills/aeg/SKILL.md +30 -1
  13. package/aeg-root/skills/aeg-roles/SKILL.md +1 -1
  14. package/aeg-root/skills/brief-authoring/SKILL.md +2 -2
  15. package/aeg-root/state-machine.md +8 -6
  16. package/aeg-root/task-model.md +1 -1
  17. package/aeg-root/templates/pr-report-template.md +4 -0
  18. package/dist/checks/bin/check-body-bare-digits.js +192 -27
  19. package/dist/checks/bin/check-branch-topology.js +518 -11
  20. package/dist/checks/bin/check-brief-shape.js +104 -11
  21. package/dist/checks/bin/check-closes-n.js +518 -11
  22. package/dist/checks/bin/check-coherence.js +526 -12
  23. package/dist/checks/bin/check-dead-branch-push.js +104 -11
  24. package/dist/checks/bin/check-dispatch-readiness.js +621 -14
  25. package/dist/checks/bin/check-doc-coverage-push.js +170 -20
  26. package/dist/checks/bin/check-doc-coverage.js +170 -20
  27. package/dist/checks/bin/check-doctrine-portability.js +112 -12
  28. package/dist/checks/bin/check-evidence-fresh.js +213 -20
  29. package/dist/checks/bin/check-first-push-dispatch.js +526 -12
  30. package/dist/checks/bin/check-issue-assignment.js +518 -11
  31. package/dist/checks/bin/check-main-branch-refusal.js +3724 -0
  32. package/dist/checks/bin/check-no-disk-state.js +104 -11
  33. package/dist/checks/bin/check-reader-resolvable-prose.js +186 -17
  34. package/dist/checks/bin/check-registry-gates.js +185 -16
  35. package/dist/checks/bin/check-retired-vocabulary.js +185 -16
  36. package/dist/checks/bin/check-review-gate.js +112 -12
  37. package/dist/checks/bin/check-single-plan-pr.js +104 -11
  38. package/dist/checks/bin/check-test-plan.js +104 -11
  39. package/dist/checks/bin/check-workspace-escape.js +104 -11
  40. package/dist/index.js +664 -56
  41. package/package.json +1 -1
  42. package/studio-standalone/_node_modules/@attalabs/aeg-core/bin/verify-coherence.ts +1089 -0
  43. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  44. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  45. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  46. package/studio-standalone/apps/vinaya-studio/web/.next/required-server-files.json +5 -0
  47. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  48. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  49. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  50. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  51. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  52. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  53. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  54. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  55. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  56. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  57. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
  58. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  59. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  60. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  61. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  62. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  63. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  64. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  65. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  66. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  70. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +2 -2
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__0pvgf28._.js → [externals]__1agj1ww._.js} +2 -2
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +1 -1
  85. 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
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0053k9k._.js +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0112h-k._.js +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0o771t1._.js +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0puovz5._.js +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__03jepya._.js → [root-of-the-server]__16cuydh._.js} +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1hs0dcu._.js +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_03x_w6q._.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gvm3og._.js +1 -1
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0lwxg63._.js +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1n0cnq-._.js +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_1vo08dj._.js +2 -2
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +3 -3
  102. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3noqvds-2bvrd.js → 0ea8-8nopz29h.js} +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0la0hhmjprdxm.css +1 -0
  104. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1lk7h-0buf4ab.js +1 -0
  105. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3gehliafvmjo9.js → 2twnwe77d4n-m.js} +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
  107. package/aeg-root/coordination.md +0 -292
  108. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2iysedx-n06xc.js +0 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/42wxpzjhw7oy4.css +0 -1
  110. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{5Lv83SnT--7YJDjSbxona → b2VfZK2AItZwlghK_pUN0}/_buildManifest.js +0 -0
  111. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{5Lv83SnT--7YJDjSbxona → b2VfZK2AItZwlghK_pUN0}/_clientMiddlewareManifest.js +0 -0
  112. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{5Lv83SnT--7YJDjSbxona → b2VfZK2AItZwlghK_pUN0}/_ssgManifest.js +0 -0
@@ -2,20 +2,22 @@
2
2
 
3
3
  // src/checks/bin/check-dispatch-readiness.ts
4
4
  import { execFile as execFile4, execFileSync as execFileSync4 } from "node:child_process";
5
+ import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync } from "node:fs";
6
+ import { sep as sep2 } from "node:path";
5
7
  import { promisify as promisify4 } from "node:util";
6
8
  // ../../packages/aeg-core/src/gate-audience.ts
7
9
  var GATE_AUDIENCE = {
8
- "check-branch-topology": { shippedAs: "branch-topology" },
9
- "check-first-push-dispatch": { shippedAs: "first-push-dispatch" },
10
- "check-no-disk-state": { shippedAs: "no-disk-state" },
11
- "verify-brief": { shippedAs: "brief-shape" },
12
- "verify-coherence": { shippedAs: "coherence" },
13
- "verify-dispatch": { shippedAs: "dispatch-readiness" },
14
- "verify-docs": { shippedAs: ["doc-coverage", "doc-coverage-push"] },
15
- "verify-registry": { shippedAs: "registry-gates" },
16
- "verify-review-gate": { shippedAs: "review-gate" },
17
- "verify-single-plan-pr": { shippedAs: "single-plan-pr" },
18
- "verify-test-plan": { shippedAs: "test-plan" },
10
+ "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
11
+ "check-first-push-dispatch": { shippedAs: "first-push-dispatch", ring: 0 },
12
+ "check-no-disk-state": { shippedAs: "no-disk-state", ring: 0 },
13
+ "verify-brief": { shippedAs: "brief-shape", ring: 0 },
14
+ "verify-coherence": { shippedAs: "coherence", ring: 0 },
15
+ "verify-dispatch": { shippedAs: "dispatch-readiness", ring: 0 },
16
+ "verify-docs": { shippedAs: ["doc-coverage", "doc-coverage-push"], ring: 0 },
17
+ "verify-registry": { shippedAs: "registry-gates", ring: 0 },
18
+ "verify-review-gate": { shippedAs: "review-gate", ring: 1 },
19
+ "verify-single-plan-pr": { shippedAs: "single-plan-pr", ring: 0 },
20
+ "verify-test-plan": { shippedAs: "test-plan", ring: 1 },
19
21
  "check-direct-main-push": {
20
22
  internal: "Reaches adopters through `vinaya audit --only=direct-push`, not the check registry: it is a ring-2 sweep over merge history keyed on `GITHUB_SHA`, run by the generated archivist job on push to the default branch. It has no diff to key on, so there is nothing for `vinaya check` to run it against."
21
23
  },
@@ -327,6 +329,13 @@ var LABELS = [
327
329
  form: "literal",
328
330
  carries: "Execution is halted pending an external unblock; wins over every other derived status."
329
331
  },
332
+ {
333
+ key: "backlog",
334
+ id: "vinaya/backlog",
335
+ category: "state",
336
+ form: "literal",
337
+ carries: "The Issue is deliberately unplanned — belongs to no tranche and is excluded from dispatch, until a Planner promotes it."
338
+ },
330
339
  {
331
340
  key: "tier-0",
332
341
  id: "vinaya/tier:0",
@@ -1985,7 +1994,59 @@ function overrideActive(opts) {
1985
1994
  return false;
1986
1995
  }
1987
1996
  // ../../packages/aeg-core/src/premise-check.ts
1997
+ import { createHash } from "node:crypto";
1988
1998
  var ASSERTION_KINDS = new Set(["contains", "absent", "sha256"]);
1999
+ function isPremiseHeader(line) {
2000
+ const stripped = line.replace(/[*#]/g, "").trim();
2001
+ return /^premise\s*:?$/i.test(stripped);
2002
+ }
2003
+ var PREMISE_LINE = /^[-*]\s*(\S+)\s+(contains|absent|sha256)\s*:\s*(.+)$/i;
2004
+ function parsePremiseBlock(prBody) {
2005
+ const searchIn = anchoredRegion(prBody, "PREMISE") ?? prBody;
2006
+ const lines = searchIn.split(/\r?\n/);
2007
+ const assertions = [];
2008
+ let inBlock = false;
2009
+ for (const raw of lines) {
2010
+ const line = raw.trim();
2011
+ if (!inBlock) {
2012
+ if (isPremiseHeader(line))
2013
+ inBlock = true;
2014
+ continue;
2015
+ }
2016
+ if (line === "")
2017
+ break;
2018
+ const m = line.match(PREMISE_LINE);
2019
+ if (!m)
2020
+ break;
2021
+ const [, path, kindRaw, value] = m;
2022
+ const kind = kindRaw.toLowerCase();
2023
+ if (!ASSERTION_KINDS.has(kind))
2024
+ continue;
2025
+ assertions.push({ kind, path, value: value.trim() });
2026
+ }
2027
+ return assertions;
2028
+ }
2029
+ function checkPremises(assertions, fileReader) {
2030
+ const failures = [];
2031
+ for (const a of assertions) {
2032
+ const content = fileReader(a.path);
2033
+ if (content === null) {
2034
+ failures.push(`premise-check: ${a.path} does not exist on disk (premise asserted \`${a.kind}: ${a.value}\`) — the surface moved since this brief was authored; re-dig before proceeding.`);
2035
+ continue;
2036
+ }
2037
+ if (a.kind === "contains" && !content.includes(a.value)) {
2038
+ failures.push(`premise-check: ${a.path} no longer contains "${a.value}" — the premise this brief pinned has moved; re-dig before proceeding.`);
2039
+ } else if (a.kind === "absent" && content.includes(a.value)) {
2040
+ failures.push(`premise-check: ${a.path} now contains "${a.value}", but the brief pinned it absent — the premise has moved; re-dig before proceeding.`);
2041
+ } else if (a.kind === "sha256") {
2042
+ const actual = createHash("sha256").update(content).digest("hex");
2043
+ if (actual !== a.value.toLowerCase()) {
2044
+ failures.push(`premise-check: ${a.path} sha256 mismatch (brief pinned ${a.value}, file is now ${actual}) — the file changed since this brief was authored; re-dig before proceeding.`);
2045
+ }
2046
+ }
2047
+ }
2048
+ return { pass: failures.length === 0, failures };
2049
+ }
1989
2050
 
1990
2051
  // ../../packages/aeg-core/src/test-plan-section.ts
1991
2052
  var HEADING_FORM_RE = /^#{1,4}[ \t]*(?:\d+[a-z]?\.[ \t]*)?\*{0,2}Test Plan\*{0,2}[ \t]*$/im;
@@ -2789,6 +2850,7 @@ function checkG1(rows, existsFn) {
2789
2850
  }
2790
2851
  return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
2791
2852
  }
2853
+ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
2792
2854
  function checkG2(rows, candidateFiles) {
2793
2855
  const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
2794
2856
  const findings = [];
@@ -2800,6 +2862,16 @@ function checkG2(rows, candidateFiles) {
2800
2862
  });
2801
2863
  }
2802
2864
  }
2865
+ for (const row of rows) {
2866
+ const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
2867
+ if (carriesPlaceholder) {
2868
+ findings.push({
2869
+ row: row.action,
2870
+ path: row.implementation,
2871
+ reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
2872
+ });
2873
+ }
2874
+ }
2803
2875
  return { check: "G2", status: findings.length > 0 ? "info" : "pass", findings };
2804
2876
  }
2805
2877
  function checkG3(ring0Rows, crossingFiles) {
@@ -3319,6 +3391,29 @@ function isNewDiskStateFile(path, status) {
3319
3391
  return false;
3320
3392
  return ANY_DEPTH_TRANCHES_MD.test(path) || TOKENS_FILE.test(path);
3321
3393
  }
3394
+ // ../../packages/aeg-core/src/main-branch-refusal.ts
3395
+ function checkMainBranchRefusal(facts) {
3396
+ const { currentSymbolicBranch, defaultBranch } = facts;
3397
+ if (currentSymbolicBranch === null)
3398
+ return null;
3399
+ if (defaultBranch === null) {
3400
+ return {
3401
+ reason: "default-branch-undetermined",
3402
+ severity: "warning",
3403
+ currentBranch: currentSymbolicBranch,
3404
+ defaultBranch: null
3405
+ };
3406
+ }
3407
+ if (currentSymbolicBranch === defaultBranch) {
3408
+ return {
3409
+ reason: "on-default-branch",
3410
+ severity: "error",
3411
+ currentBranch: currentSymbolicBranch,
3412
+ defaultBranch
3413
+ };
3414
+ }
3415
+ return null;
3416
+ }
3322
3417
  // ../../packages/aeg-core/src/branch-topology-gate.ts
3323
3418
  function taskBranchTopologyFields(branch) {
3324
3419
  if (!/^task\/.*\/.*$/.test(branch))
@@ -3572,6 +3667,420 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
3572
3667
  }
3573
3668
  return findings;
3574
3669
  }
3670
+ // ../../packages/sources/src/commands.ts
3671
+ var COMMANDS = [
3672
+ {
3673
+ name: "help",
3674
+ description: "Show this help text",
3675
+ status: "shipped"
3676
+ },
3677
+ {
3678
+ name: "version",
3679
+ description: "Print the CLI version",
3680
+ flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }],
3681
+ status: "shipped"
3682
+ },
3683
+ {
3684
+ name: "init",
3685
+ description: "Install Vinaya's git hooks, CI workflow, and starter config (diff-and-confirm, non-destructive)",
3686
+ flags: [
3687
+ { flag: "--dry-run", description: "Print the full diff without installing anything" },
3688
+ { flag: "--yes", description: "Skip the confirmation prompt" }
3689
+ ],
3690
+ details: [
3691
+ "It detects your repo, prints the complete diff of every intended change, and waits for your confirmation before installing anything. `--dry-run` prints that same diff and installs nothing. Nothing ever runs automatically on package install.",
3692
+ "It installs one CI workflow that runs `vinaya check --all --diff-only`, alongside your existing workflows — refusing to overwrite rather than touching foreign content already at that path. Git hook stubs invoke the `vinaya` binary directly; if a hook already exists, it appends a delimited managed block, shown verbatim in the diff first, rather than overwriting it.",
3693
+ "`vinaya.config.json` is seeded with a starter ruleset extracted from Vinaya's own battle-tested gates, not invented defaults. Issue and PR templates carrying the brief schema are added alongside your own; tier and `needs:*-input` labels are created only if they don't already exist — your existing labels are never modified.",
3694
+ "Two empty folders — `vinaya/checks/` and `vinaya/roles/` — are scaffolded alongside the config, each held open by a placeholder file (git does not track empty directories). `vinaya new noop-check` and `vinaya new role` write their real output into these folders later; both placeholders are recorded in the ownership manifest, so `eject` removes them exactly like everything else `init` created.",
3695
+ "The generated workflows reach the `vinaya` binary through `npx @attalabs/vinaya`, with no build step — unless your repo vendors the CLI itself (a workspace member declaring the name `@attalabs/vinaya`), in which case `npx` would resolve to that unbuilt local member instead of the registry. `init` detects that at generation time and writes workflows that build and run your own copy by path instead, so your CI exercises the code in the pull request. `upgrade` and `doctor` make the same determination, so regenerating is stable.",
3696
+ "The recommended branch-protection command is printed for you to run yourself — it is never applied, and your PATH is never touched. `eject` removes exactly the managed block it owns, or a whole file only if `init` created it."
3697
+ ],
3698
+ status: "shipped"
3699
+ },
3700
+ {
3701
+ name: "init product",
3702
+ description: "Register a project in .vinaya/projects.md in an already-initialized repo",
3703
+ flags: [
3704
+ {
3705
+ flag: "--path <path>",
3706
+ description: "The project's home folder — declared, not derived. Defaults to the repo root."
3707
+ }
3708
+ ],
3709
+ details: [
3710
+ "Writes (or appends to) `.vinaya/projects.md` — the registry Vinaya Studio's tranche board resolves a project's board link against. Idempotent: re-running with the same name updates nothing.",
3711
+ "Reaches no forge and needs no GitHub remote or credentials: the registry row is a pure local file write, and it is deliberately NOT recorded in the ownership manifest, so `eject` does not reverse adopter-declared data.",
3712
+ "Creates no label. Project is a field, not a label: a task Issue declares its project in the body's `**Project:**` field, and a `project:*` label is ignored wherever one still exists."
3713
+ ],
3714
+ status: "shipped"
3715
+ },
3716
+ {
3717
+ name: "check",
3718
+ description: "Run one check, or every registered check",
3719
+ flags: [
3720
+ { flag: "--all", description: "Run every registered check instead of one named check" },
3721
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" },
3722
+ { flag: "--diff-only", description: "Scope diff-declared checks to changed files" },
3723
+ {
3724
+ flag: "--local",
3725
+ description: "Skip every requiresOpenPr check (closes-n, test-plan) — set by the generated hooks, never by CI"
3726
+ },
3727
+ { flag: "--parallel[=n]", description: "Concurrency cap (default: cpu-derived)" },
3728
+ {
3729
+ flag: "--plan",
3730
+ description: "Print the resolved check registry and the resolved `roles` registry (default/overridden/additive) without running anything"
3731
+ }
3732
+ ],
3733
+ details: [
3734
+ "Each spawned check's child process sees only a fixed baseline (`PATH`, `LANG`, `HOME`, `HTTPS_PROXY`, `HTTP_PROXY`, `NO_PROXY`, `TMPDIR`) plus whatever its `CheckSpec['env']` declaration explicitly forwards — never the full parent environment. A required (`true`) or unsatisfied `anyOf` declaration missing from the caller's environment synthesizes a `CheckError` before the check ever spawns. Declare `env` (a core check's own registration, or `vinaya.config.json`'s `checks.<name>.env` for a custom one) for any check that reads `process.env`/`Bun.env`/`Deno.env` directly — `vinaya doctor` carries the permanent diagnostic for one that doesn't.",
3735
+ "The resolved registry IS what runs. A `checks` key that exactly matches a core check id REPLACES that core check (the core one does not run); any other key must be namespaced `<yourname>/<id>`. Anything the resolver cannot classify — a malformed entry, a bare un-namespaced key matching no core id, a duplicate id — makes `vinaya check` refuse the ENTIRE run: exit 1, nothing executes, never a partial ruleset and never a core-only fallback. `vinaya doctor` carries the permanent diagnostic for each rejected entry, so a refused config is still diagnosable.",
3736
+ "`--plan` composes with `--json`. It requires zero env vars and never prints an env value — only how each one resolves (passthrough, optional, literal, or anyOf). A `FAIL_CLOSED` entry always renders inline rather than being dropped, and exits non-zero. `--plan` and execution read the same resolution, so what the plan prints is what runs.",
3737
+ "`--local` exists because a `requiresOpenPr` check (the core `closes-n`/`test-plan`, or a custom check declaring the same field) can only evaluate for real once a pull request exists — the generated `pre-commit`/`pre-push` hooks pass it so the first commit on a fresh task branch is never asked to satisfy a PR-body field before a PR can possibly exist. CI's `vinaya-checks.yml` omits it, so these checks always run for real once a PR is open.",
3738
+ "`--plan`'s `roles` half resolves `vinaya.config.json`'s `roles` block against bundled doctrine — same override/additive shape as `checks`, with its own RENDERS AS column (the registry key and the role's own `role_id` differ for an additive entry) and a GATING column (`core` vs. `inert` — an additive role carries no core `ACTIONS` wiring). `roles.available` is `false` only when no bundled doctrine can be found next to this CLI install."
3739
+ ],
3740
+ status: "shipped"
3741
+ },
3742
+ {
3743
+ name: "commit-msg",
3744
+ description: "The generated `commit-msg` hook's invocation target — validates a commit message's first line",
3745
+ details: [
3746
+ "Not meant to be run by hand day-to-day: the managed `commit-msg` hook calls `vinaya commit-msg <message-file> [source]` with the two arguments git itself passes a commit-msg hook (githooks(5)) — the message file path and, when known, the commit's source keyword.",
3747
+ "Validates the message file's first line against the same `Type(scope): Description` vocabulary `check`'s `forge-title`-shaped gates enforce on PR/Issue titles (`@attalabs/aeg-core`'s `COMMIT_TYPES` — the commitlint type set plus `Plan`). Exits 0 with no output on a conforming message; a `source` of `merge` is skipped outright, since a merge commit's message is written by git, not the person committing."
3748
+ ],
3749
+ status: "shipped"
3750
+ },
3751
+ {
3752
+ name: "new check",
3753
+ description: "Scaffold a custom check into ./scripts/vinaya-checks/",
3754
+ details: [
3755
+ "Takes the REGISTRATION KEY, not a bare name: `vinaya new check <yourname>/<id>` writes `./scripts/vinaya-checks/<id>.ts` and prints the namespaced `checks` entry to paste. It refuses a bare, un-namespaced name — `vinaya check` refuses its entire run over a key it cannot resolve, so scaffolding one would brick every check invocation in the repo — and refuses a core check id, since registering one REPLACES that core gate and a scaffolded stub is never what an adopter means by that."
3756
+ ],
3757
+ status: "shipped"
3758
+ },
3759
+ {
3760
+ name: "new noop-check",
3761
+ description: "Scaffold an explicit no-op into vinaya/checks/ that silences a core check",
3762
+ details: [
3763
+ "Takes a CORE check id — the opposite of what `new check` accepts, which refuses one. `vinaya new noop-check <core-check-id>` writes `vinaya/checks/<id>.ts`, an explicit, contract-satisfying no-op (always exits `0`, emits no findings, carries a comment marking the silencing as intentional) and prints the `checks` entry that REPLACES the named core check with it. This is the only sanctioned way to silence a core check."
3764
+ ],
3765
+ status: "shipped"
3766
+ },
3767
+ {
3768
+ name: "new role",
3769
+ description: "Scaffold an additive role contract into vinaya/roles/",
3770
+ details: [
3771
+ 'Takes the REGISTRATION KEY: `vinaya new role <yourname>/<id>` writes `vinaya/roles/<id>.md` — a structurally-valid role contract stub (the six frontmatter keys plus `title`/`order`, and a non-empty "## The short version" section) whose own `role_id` is set to `<id>` — and prints the `roles` entry to paste. It refuses a bare, un-namespaced key: that shape resolves as an OVERRIDE of a core role, a complete replacement of that role\'s contract and a real governance decision this scaffolder does not make for you.'
3772
+ ],
3773
+ status: "shipped"
3774
+ },
3775
+ {
3776
+ name: "pr create",
3777
+ description: "Open a pull request after full brief-schema validation",
3778
+ flags: [
3779
+ { flag: "--title", description: "PR title (validated against the forge-title grammar)" },
3780
+ { flag: "--body-file", description: "Path to the PR body (stream-safe; the same bytes are validated and sent)" },
3781
+ { flag: "--label", description: "Label(s) to apply (repeatable, comma-separated)" },
3782
+ { flag: "--validate-only", description: "Run every gate and report PASS without opening the PR" },
3783
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
3784
+ ],
3785
+ details: [
3786
+ "Runs the config-defined brief-schema gate (`briefSchema.pr` in `vinaya.config.json`) LOCALLY before any `gh` write — prevention, not detection. On any failure it refuses with the versioned CheckError contract (one JSON line per finding on stderr, exit 1) whose `agent_recovery_prompt` names the exact corrective command.",
3787
+ "Which sections bind depends on the branch, matching the `brief-shape` check that runs the same grammar in CI. On a `task/<tranche>/<n>` branch every configured section binds, `closesN` included. On any other branch a body that is not brief-shaped is exempt entirely — an ordinary one-line dependency bump is not made to grow a brief — while a brief-shaped body is still graded on every other section, since a standalone fix brief is a brief; only `closesN` is dropped, because such a branch has no task Issue to close. The title grammar sits outside all of this and binds on every branch.",
3788
+ "A branch counts as resolvable only when HEAD is a symbolic ref that also resolves to a commit. Neither git query answers that alone: `rev-parse --abbrev-ref HEAD` reports the literal string `HEAD` on a detached HEAD, and `symbolic-ref` reports the not-yet-created branch name when HEAD is unborn. Reading either as an ordinary branch would take the relaxed path, so both states — plus running outside a repo — resolve to nothing and the gate is fail-closed: every configured section is enforced."
3789
+ ],
3790
+ status: "shipped"
3791
+ },
3792
+ {
3793
+ name: "pr edit",
3794
+ description: "Edit an existing pull request (<n>) after full brief-schema validation",
3795
+ flags: [
3796
+ { flag: "--title", description: "New PR title (validated against the forge-title grammar)" },
3797
+ { flag: "--body-file", description: "Path to the new PR body (stream-safe; same bytes validated and sent)" },
3798
+ { flag: "--validate-only", description: "Run every gate and report PASS without editing the PR" },
3799
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
3800
+ ],
3801
+ details: [
3802
+ "The target PR's real head branch and changed files are fetched from the forge to build the validation context — a failed fetch is a hard refusal, never a fall-back to the local checkout.",
3803
+ "That fetched head branch is what selects the section set, by the same branch grammar `pr create` uses — a property of the target PR, never of whatever the local checkout happens to have checked out."
3804
+ ],
3805
+ status: "shipped"
3806
+ },
3807
+ {
3808
+ name: "pr report",
3809
+ description: "Emit the AEG:EVIDENCE block — a PR body's factual claims, from commands, never typed",
3810
+ flags: [
3811
+ {
3812
+ flag: "--write",
3813
+ description: "Path to the PR body file; replaces the content between the AEG:EVIDENCE anchors in place"
3814
+ }
3815
+ ],
3816
+ details: [
3817
+ "Two groups: Group A (recomputable) is the head sha and a width-invariant `git diff --numstat` against the merge-base with `BASE_SHA` (else `origin/main`, then `main`) — `check-evidence-fresh` recomputes and byte-compares this exactly. Group B (attested) is the result of `vinaya check --all --diff-only`, this CLI's own portable gate suite — `check-evidence-fresh` can only check it for staleness (the block's recorded head still matches the PR's real head), never re-run it.",
3818
+ "With no `--write`, prints the block to stdout instead of writing a file. Exits non-zero whenever the gate run failed, whether or not `--write` was given — the block records a failing result rather than hiding one, and a non-zero exit stops a scripted `--write && open-pr` from carrying a failing suite onto the forge."
3819
+ ],
3820
+ status: "shipped"
3821
+ },
3822
+ {
3823
+ name: "issue create",
3824
+ description: "Open an issue after full brief-schema validation",
3825
+ flags: [
3826
+ { flag: "--title", description: "Issue title (validated on task Issues)" },
3827
+ { flag: "--body-file", description: "Path to the Issue body (stream-safe; same bytes validated and sent)" },
3828
+ { flag: "--label", description: "Label(s) to apply; a `vinaya/tranche:*` label marks a task Issue" },
3829
+ { flag: "--validate-only", description: "Run every gate and report PASS without opening the Issue" },
3830
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
3831
+ ],
3832
+ details: [
3833
+ "A task Issue (any `vinaya/tranche:*` label) must carry the full Planner rationale (`briefSchema.issue`); non-task Issues pass through unvalidated."
3834
+ ],
3835
+ status: "shipped"
3836
+ },
3837
+ {
3838
+ name: "issue edit",
3839
+ description: "Edit an existing issue (<n>) after full brief-schema validation",
3840
+ flags: [
3841
+ { flag: "--title", description: "New Issue title (validated on task Issues)" },
3842
+ { flag: "--body-file", description: "Path to the new Issue body (stream-safe; same bytes validated and sent)" },
3843
+ { flag: "--validate-only", description: "Run every gate and report PASS without editing the Issue" },
3844
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
3845
+ ],
3846
+ details: [
3847
+ "The target Issue's actual labels are fetched from the forge and unioned with argv to decide task-Issue applicability — a failed fetch is a hard refusal."
3848
+ ],
3849
+ status: "shipped"
3850
+ },
3851
+ {
3852
+ name: "milestone create",
3853
+ description: "Create a GitHub Milestone from a validated body",
3854
+ flags: [
3855
+ { flag: "--title", description: "Milestone title — free text, never parsed for a version" },
3856
+ {
3857
+ flag: "--body-file",
3858
+ description: "Path to the Milestone description (stream-safe; same bytes validated and sent)"
3859
+ },
3860
+ { flag: "--validate-only", description: "Run every gate and report PASS without creating the Milestone" },
3861
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
3862
+ ],
3863
+ details: [
3864
+ "Refuses before any `gh` call when the goal is absent, an optional `Release:` field is present but not a version, or an optional `### Tranche intents` section (`- <slug>: <intent text>`) doesn't parse. `Release:` is the sole authority for the milestone's version — the title is never parsed for one."
3865
+ ],
3866
+ status: "shipped"
3867
+ },
3868
+ {
3869
+ name: "milestone adopt",
3870
+ description: "Move one or more existing tranches into a target Milestone",
3871
+ flags: [
3872
+ { flag: "--target", description: "The Milestone every named slug is adopted into" },
3873
+ { flag: "--slug", description: "A tranche slug to adopt — repeatable for a multi-slug move" },
3874
+ { flag: "--validate-only", description: "Run every gate and report PASS without writing anything" },
3875
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
3876
+ ],
3877
+ details: [
3878
+ "Reattaches every Issue carrying each named `vinaya/tranche:<slug>` label to `--target`, then closes (never deletes) each slug's old tranche-Milestone. Every fact for every named slug is gathered and checked in ONE call before any write, so a single unsafe slug — an unknown slug, a slug whose label carries no Issues, a target that does not exist or is closed, or a slug already adopted into a different Milestone — refuses the whole invocation, not just its own slug."
3879
+ ],
3880
+ status: "shipped"
3881
+ },
3882
+ {
3883
+ name: "milestone edit",
3884
+ description: "Edit an existing Milestone (<n>) after full brief-schema validation",
3885
+ flags: [
3886
+ {
3887
+ flag: "--body-file",
3888
+ description: "Path to the new Milestone description (stream-safe; same bytes validated and sent)"
3889
+ },
3890
+ { flag: "--validate-only", description: "Run every gate and report PASS without editing the Milestone" },
3891
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
3892
+ ],
3893
+ details: [
3894
+ "Same `checkMilestoneShape` refusal `create` runs, before any `gh` call — the gated replacement for a raw `gh api PATCH` against a Milestone. Only the description changes; the title is untouched."
3895
+ ],
3896
+ status: "shipped"
3897
+ },
3898
+ {
3899
+ name: "review post",
3900
+ description: "Render, post, and self-verify a code-reviewer or security-review verdict comment on a PR",
3901
+ flags: [
3902
+ { flag: "--role", description: "`code-reviewer` or `security` — selects which role template is rendered" },
3903
+ {
3904
+ flag: "--pr",
3905
+ description: "Target PR number — its real head is resolved via `gh pr view`, never caller-supplied"
3906
+ },
3907
+ {
3908
+ flag: "--verdict",
3909
+ description: "code-reviewer: `APPROVE` | `REQUEST_CHANGES`. security: `PASS` | `FAIL`"
3910
+ },
3911
+ {
3912
+ flag: "--findings-file",
3913
+ description: "One finding per line: `SEVERITY|file:line|description` (`|`-delimited). Omit for zero findings."
3914
+ },
3915
+ { flag: "--brief-conformance", description: "code-reviewer only: the BRIEF CONFORMANCE line" },
3916
+ { flag: "--spec-conformance", description: "code-reviewer only: the SPEC CONFORMANCE line" },
3917
+ { flag: "--scope", description: "code-reviewer only: the SCOPE line" },
3918
+ { flag: "--tests", description: "code-reviewer only: the TESTS line" },
3919
+ { flag: "--docs", description: "code-reviewer only: the DOCS line" },
3920
+ { flag: "--config-scan", description: "security only: the CONFIG SCAN line" },
3921
+ { flag: "--secrets", description: "security only: the SECRETS line" },
3922
+ {
3923
+ flag: "--secrets-evidence-file",
3924
+ description: 'security only: required whenever `--secrets` claims "none found" — the pasted scanner output backing that claim'
3925
+ },
3926
+ { flag: "--task-id", description: "the closing `Tokens:` line's task id" },
3927
+ { flag: "--model", description: "the closing `Tokens:` line's model name" },
3928
+ { flag: "--tokens-in", description: "a non-negative integer, or `-` if unknown" },
3929
+ { flag: "--tokens-out", description: "a non-negative integer, or `-` if unknown" },
3930
+ { flag: "--cost", description: "free text, or `-` if unknown" },
3931
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
3932
+ ],
3933
+ details: [
3934
+ "Every structural line (`VERDICT:`, `Judged head:`) is rendered from this command's own validated enum/sha inputs — never from a caller-supplied string — so a Reviewer's free-typed prose can no longer produce a shape the merge gate's line-anchored regex fails to see.",
3935
+ "Refuses a contradictory verdict before posting anything: a BLOCKER finding with `--verdict APPROVE`, or a CRITICAL/HIGH finding with `--verdict PASS`, is rejected outright, mirroring each role doc's own consistency rule.",
3936
+ "After posting, re-fetches the PR's comments and runs them through the exact `extractCodeReviewVerdict`/`extractSecurityReviewVerdict` functions `checkReviewGate` calls — the same functions, not a second implementation — and exits non-zero naming precisely what failed to re-parse if the post does not come back clean and bound to the resolved head. There is no `--skip-verify` escape."
3937
+ ],
3938
+ status: "shipped"
3939
+ },
3940
+ {
3941
+ name: "doctor",
3942
+ description: "Diagnose hook, workflow, and config health — report only, never mutates",
3943
+ flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }],
3944
+ details: [
3945
+ 'Carries the same env-declaration diagnostic `vinaya check` warns with — permanently, at `info` severity, not just ahead of the spawn-default flip — plus a `warn`-severity lint over suspicious `env` literal forms (a stray `"true"`/`"false"` string, or a high-entropy literal that reads like a leaked secret committed to config).',
3946
+ "Also carries the two permanent `checks`-classification diagnostics: a config key that REPLACES a core check (`warn`), and a bare un-namespaced key that is REJECTED (`error`, naming the rename requirement). These are the reason a config `vinaya check` now refuses outright is still diagnosable — the refusal runs nothing, so `doctor` is the surface that explains why."
3947
+ ],
3948
+ status: "shipped"
3949
+ },
3950
+ {
3951
+ name: "tokens",
3952
+ description: "Print a role's `Tokens: …` report line — the portable front door over the collection adapter",
3953
+ flags: [
3954
+ { flag: "--phase", description: 'e.g. `"<task-id>: develop"` — required' },
3955
+ { flag: "--role", description: "e.g. `Developer` — required" },
3956
+ { flag: "--model", description: "Overrides the model id the adapter derived, if given" },
3957
+ {
3958
+ flag: "--transcript",
3959
+ description: "Read this transcript directly. Supported primary route — use it whenever you know which transcript " + "is yours, and always in a repo with no track-transcript.sh hook. Omitted resolves via the Stop-hook " + "pointer file, if this repo installs that hook."
3960
+ },
3961
+ {
3962
+ flag: "--in / --out",
3963
+ description: "Manual entry: the exact token figures, for a host whose usage arrives by some other means than a " + "Claude Code transcript. Both required together; skips transcript resolution entirely."
3964
+ }
3965
+ ],
3966
+ details: [
3967
+ "Resolves the Claude Code collection adapter (`resolveMeteringCapability`, `summarizeTranscript`, `formatTokensLine`) from the INSTALLED `@attalabs/aeg-core` package, never by a repo-relative path — the fix for `packages/aeg-core/bin/report-tokens.ts` not existing in an adopter repo with no local `packages/`.",
3968
+ "Refuses — never emits a `0/0/—` line — when no transcript resolves, a resolved transcript can't be read, or it summarizes to zero usage records (empty, unparseable, or not yet flushed to disk). Capability is probed by actually attempting resolution, never declared from the host being Claude Code."
3969
+ ],
3970
+ status: "shipped"
3971
+ },
3972
+ {
3973
+ name: "doctrine",
3974
+ description: "Print the absolute path of the bundled doctrine's front door (aeg-root/skills/aeg/SKILL.md) on this machine",
3975
+ flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1) — `{ root, entry }`" }],
3976
+ details: [
3977
+ "The committed root `VINAYA.md` pointer names the `@attalabs/vinaya` package, never a filesystem path — where the package sits is a property of each machine, not of the repo, and the pointer is committed for every clone. This command is the read-time resolution step the pointer hands the reader: it resolves the installed package's own bundled `aeg-root/` wherever the CLI physically sits and prints the front door's absolute path, so `cat \"$(vinaya doctrine)\"` opens the doctrine on any machine at any version.",
3978
+ "In a repo that vendors the CLI, the bundled copy is a gitignored pack-time artifact, so the command falls back to the monorepo root's own `aeg-root/` — the same directory `bundle-doctrine` copies from. Exits 1 with a corrective message when neither location holds a doctrine."
3979
+ ],
3980
+ status: "shipped"
3981
+ },
3982
+ {
3983
+ name: "upgrade",
3984
+ description: "Regenerate hooks, workflow, and config to the current contract version (diff-and-confirm)",
3985
+ flags: [
3986
+ { flag: "--dry-run", description: "Print the full diff without regenerating anything" },
3987
+ { flag: "--yes", description: "Skip the confirmation prompt" }
3988
+ ],
3989
+ status: "shipped"
3990
+ },
3991
+ {
3992
+ name: "archive",
3993
+ description: "Run the post-merge Archivist directly: provenance + Issue close-out for a merged task PR",
3994
+ flags: [{ flag: "--merge-sha", description: "The merge commit to resolve (defaults to the current HEAD)" }],
3995
+ details: [
3996
+ "Resolves the merge commit's associated PR via `gh`, and — if it's a task PR without a provenance comment yet — posts the provenance block and closes the linked Issue. Idempotent: re-running against an already-archived PR is a no-op.",
3997
+ "The same logic the generated `vinaya-archivist.yml` workflow's `post-merge` job runs on every push to `main` — callable directly for a one-off run or local verification.",
3998
+ "All progress output writes through `process.stdout.write`/`process.stderr.write` (never bare `console.*`), so piping this command into a log file or a CI step captures every line in order."
3999
+ ],
4000
+ status: "shipped"
4001
+ },
4002
+ {
4003
+ name: "archive tranche",
4004
+ description: "Close a tranche — the tranche-level bookend to `init product`, closing the Milestone via the CLI",
4005
+ flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
4006
+ details: [
4007
+ "Refuses if any task Issue attached to the named tranche is still open, naming each one — closing a tranche with unresolved work is never silently allowed.",
4008
+ "Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes the GitHub Milestone."
4009
+ ],
4010
+ status: "shipped"
4011
+ },
4012
+ {
4013
+ name: "audit",
4014
+ description: "Run the ring-2 dead-branch-push and direct-main-push detection checks directly",
4015
+ flags: [
4016
+ { flag: "--only", description: "Scope to one check: 'dead-branches' or 'direct-push'" },
4017
+ { flag: "--sha", description: "The commit to check for direct-main-push (defaults to the current HEAD)" },
4018
+ { flag: "--json", description: "Enveloped JSON output" }
4019
+ ],
4020
+ details: [
4021
+ "Dead-branch-push is never-red — a notification channel that flags (label + PR comment) any `task/*` branch whose tip commit lands after its own PR already resolved. Direct-main-push is a real pass/fail — it polls the merge-association API for up to ~100s before deciding, then opens an incident Issue and exits 1 if a commit on `main` genuinely has no associated merged PR.",
4022
+ "The same logic the generated `vinaya-archivist.yml` workflow's `daily-drift` and `direct-main-push-detection` jobs run on schedule / on every push to `main` — callable directly for a one-off run or local verification.",
4023
+ "All progress output writes through `process.stdout.write`/`process.stderr.write` (never bare `console.*`), so piping this command into a log file or a CI step captures every line in order."
4024
+ ],
4025
+ status: "shipped"
4026
+ },
4027
+ {
4028
+ name: "eject",
4029
+ description: "Remove every Vinaya-installed artifact, restoring the repo to stock",
4030
+ flags: [
4031
+ { flag: "--dry-run", description: "Print the full removal diff without removing anything" },
4032
+ { flag: "--yes", description: "Skip the confirmation prompt" }
4033
+ ],
4034
+ status: "shipped"
4035
+ },
4036
+ {
4037
+ name: "demo break",
4038
+ description: "Run a guided refusal-then-fix demo on an isolated, discardable branch",
4039
+ flags: [{ flag: "--keep", description: "Skip cleanup and leave the demo branch checked out to inspect" }],
4040
+ details: [
4041
+ "Creates a collision-safe `vinaya/demo-break-<id>` branch off the current one, stages a deliberately incomplete draft brief, and attempts a real `git commit` — the repo's actually-installed pre-commit hook refuses it with its real output, not a scripted string. Applies the minimal fix, commits again, then switches back and deletes the demo branch.",
4042
+ "Safe to run twice: refuses on a dirty working tree, refuses from a detached HEAD, and recovers automatically from a prior crashed run before starting a fresh one — never leaves the original branch touched or a stray demo branch behind."
4043
+ ],
4044
+ status: "shipped"
4045
+ },
4046
+ {
4047
+ name: "waiver",
4048
+ description: "Apply the actor-verified 'vinaya/waiver:docs' or 'vinaya/waiver:review' label after prompting for a reason",
4049
+ flags: [
4050
+ { flag: "--reason", description: "The waiver rationale, posted as a PR comment (prompted for if omitted)" },
4051
+ { flag: "--print-only", description: "Print the exact `gh` commands instead of running them" }
4052
+ ],
4053
+ details: [
4054
+ "Applies the label via `gh pr edit --add-label`, under the invoking human's own authenticated `gh` identity — this command never fabricates an actor. A waiver is never an agent-emittable string: not a PR body field, not a commit trailer, not a comment — the label plus its own labeling-timeline actor is the only mechanism ring 1 honors.",
4055
+ "`--print-only` prints the exact `gh pr edit`/`gh pr comment` commands and runs nothing — for a human who wants to run them itself, or a CI/non-interactive context where an agent session should never be the one applying its own waiver."
4056
+ ],
4057
+ status: "shipped"
4058
+ },
4059
+ {
4060
+ name: "studio",
4061
+ description: "Launch Vinaya Studio — runs the Studio dev app when its source (apps/vinaya-studio/web) is in a checkout above the current directory; a published install launches its bundled standalone server instead",
4062
+ flags: [
4063
+ {
4064
+ flag: "--port <n>",
4065
+ description: "Bind this exact port. Without the flag the default is unchanged — 3008, falling back to 3108 when it is taken. With it there is no fallback: a taken port is refused, so you always know which server answered. Accepts `--port 3208` and `--port=3208`. Applies to a published install; in a workspace checkout Studio's own dev script owns the port and the flag is refused."
4066
+ }
4067
+ ],
4068
+ details: [
4069
+ "Resolution happens in this order: a workspace checkout carrying `apps/vinaya-studio/web` (Studio's source, which lives in the attalabs monorepo — not this repository) runs the dev app directly; a published install's `studio-standalone/` bundle (fetched from attalabs' release artifact at publish time, see `scripts/bundle-studio.ts`) runs that bundled server; anything else — a publish that shipped without the bundle — gets an explicit refusal and exit 1 rather than a silent no-op.",
4070
+ "Every published `@attalabs/vinaya` build ships the `studio-standalone/` bundle: `prepack` fetches attalabs’ latest CI-built standalone Studio artifact and assembles it into the tarball before publish."
4071
+ ],
4072
+ status: "shipped"
4073
+ },
4074
+ {
4075
+ name: "quickstart",
4076
+ description: "Guided wizard: init, doc-owners, project, commit, demo break, doctor, push — one command",
4077
+ details: [
4078
+ "Calls `init`'s own diff-and-confirm flow unchanged (pausing on Enter before the diff prints, so its own step header isn't scrolled off by a long diff), then Y/n-prompts through the workarounds a guest used to run by hand: binding `.vinaya/doc-owners` pairs (bad input offers a retry instead of silently skipping, and a pointer that doesn't exist on disk is refused outright — both loop across as many pairs as the guest wants, not just one), registering tracked projects (`init product`, same retry/loop shape), committing the install, running `demo break` as proof the gates actually work (default yes — the one step this wizard makes hardest to skip), running `doctor`, and pushing. Each declined prompt skips only that step; the install commit itself is never prompt-gated — it just no-ops when there is genuinely nothing to commit.",
4079
+ "Never reimplements or edits `init`/`init product`/`demo break`/`doctor` — it only calls their existing, unmodified entry points in sequence."
4080
+ ],
4081
+ status: "shipped"
4082
+ }
4083
+ ];
3575
4084
  // ../../packages/sources/src/forge-adapter.ts
3576
4085
  function createForgeSource(config) {
3577
4086
  return {
@@ -3686,8 +4195,15 @@ function isSafeRepoRelPath(p) {
3686
4195
  var SafeRepoRelPath = z2.string().refine(isSafeRepoRelPath, {
3687
4196
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
3688
4197
  });
4198
+ var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
4199
+ function isCanonicalHookBlockPath(p) {
4200
+ return CANONICAL_HOOK_BLOCK_PREFIXES.some((prefix) => p.startsWith(prefix) && p.length > prefix.length);
4201
+ }
4202
+ var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
4203
+ message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
4204
+ });
3689
4205
  var ManagedBlockRecordSchema = z2.object({
3690
- path: SafeRepoRelPath,
4206
+ path: ManagedHookBlockPath,
3691
4207
  marker: z2.string(),
3692
4208
  comment: z2.enum(["hash", "html"])
3693
4209
  });
@@ -3861,6 +4377,16 @@ function loadConfig() {
3861
4377
  }
3862
4378
  }
3863
4379
 
4380
+ // src/lib/ops.ts
4381
+ import { dirname as dirname2, isAbsolute, join as join2, resolve, sep } from "node:path";
4382
+ function containedAbs(repoRoot, relPath) {
4383
+ const root = resolve(repoRoot);
4384
+ const target = resolve(root, relPath);
4385
+ if (target === root)
4386
+ return null;
4387
+ return target === root || target.startsWith(root + sep) ? target : null;
4388
+ }
4389
+
3864
4390
  // src/checks/edge-resolve.ts
3865
4391
  import { execFileSync as execFileSync3 } from "node:child_process";
3866
4392
  var DIRECT_ISSUE_REF = /#(\d+)/;
@@ -3924,6 +4450,53 @@ function resolveEdge(id, taskById, factsByTaskId, repo) {
3924
4450
  return { issue: null, merged: false, open: false, issueState: null, stateReason: null, closedByActor: null };
3925
4451
  }
3926
4452
 
4453
+ // src/checks/premise-reassert-logic.ts
4454
+ function reassertPremiseFile(checkName, premiseFilePath, body, fileReader) {
4455
+ if (body === null) {
4456
+ return {
4457
+ pass: false,
4458
+ errors: [
4459
+ {
4460
+ schema: CHECK_SCHEMA_VERSION,
4461
+ check: checkName,
4462
+ severity: "error",
4463
+ message: `dispatch-gate premise: PREMISE_FILE "${premiseFilePath}" does not exist or is unreadable.`,
4464
+ agent_recovery_prompt: "Confirm the path passed via PREMISE_FILE is correct and readable, then re-run `vinaya check dispatch-readiness`."
4465
+ }
4466
+ ]
4467
+ };
4468
+ }
4469
+ const assertions = parsePremiseBlock(body);
4470
+ if (assertions.length === 0) {
4471
+ return {
4472
+ pass: false,
4473
+ errors: [
4474
+ {
4475
+ schema: CHECK_SCHEMA_VERSION,
4476
+ check: checkName,
4477
+ severity: "error",
4478
+ message: `dispatch-gate premise: PREMISE_FILE "${premiseFilePath}" carries no \`Premise:\` assertions — a premise file with no pins is a mistake, not a pass.`,
4479
+ agent_recovery_prompt: "Add a `Premise:` block with at least one `contains`/`absent`/`sha256` pin to the brief file, then re-run `vinaya check dispatch-readiness`."
4480
+ }
4481
+ ]
4482
+ };
4483
+ }
4484
+ const result = checkPremises(assertions, fileReader);
4485
+ if (!result.pass) {
4486
+ return {
4487
+ pass: false,
4488
+ errors: result.failures.map((failure) => ({
4489
+ schema: CHECK_SCHEMA_VERSION,
4490
+ check: checkName,
4491
+ severity: "error",
4492
+ message: `dispatch-gate premise: ${failure}`,
4493
+ agent_recovery_prompt: "The surface moved since this brief was authored — re-dig the affected pin, correct the brief, and re-run `vinaya check dispatch-readiness` before continuing."
4494
+ }))
4495
+ };
4496
+ }
4497
+ return { pass: true, errors: [] };
4498
+ }
4499
+
3927
4500
  // src/checks/bin/check-dispatch-readiness.ts
3928
4501
  var CHECK_NAME = "dispatch-readiness";
3929
4502
  var execFileAsync4 = promisify4(execFile4);
@@ -3976,6 +4549,37 @@ function fail(message, prompt) {
3976
4549
  });
3977
4550
  process.exit(1);
3978
4551
  }
4552
+ function checkPremiseReassertion() {
4553
+ const premiseFile = process.env.PREMISE_FILE;
4554
+ if (!premiseFile)
4555
+ return true;
4556
+ const body = existsSync2(premiseFile) ? readFileSync2(premiseFile, "utf8") : null;
4557
+ const result = reassertPremiseFile(CHECK_NAME, premiseFile, body, (p) => {
4558
+ const real = containedRealPath(process.cwd(), p);
4559
+ if (real === null)
4560
+ return null;
4561
+ try {
4562
+ return readFileSync2(real, "utf8");
4563
+ } catch {
4564
+ return null;
4565
+ }
4566
+ });
4567
+ for (const error of result.errors)
4568
+ emitCheckError(error);
4569
+ return result.pass;
4570
+ }
4571
+ function containedRealPath(root, p) {
4572
+ const abs = containedAbs(root, p);
4573
+ if (abs === null)
4574
+ return null;
4575
+ try {
4576
+ const real = realpathSync(abs);
4577
+ const realRoot = realpathSync(root);
4578
+ return real === realRoot || real.startsWith(realRoot + sep2) ? real : null;
4579
+ } catch {
4580
+ return null;
4581
+ }
4582
+ }
3979
4583
  async function main() {
3980
4584
  const branch = currentBranch();
3981
4585
  const m = branch.match(/^task\/([^/]+)\/(.+)$/);
@@ -4043,6 +4647,7 @@ async function main() {
4043
4647
  principalAllowlist: resolvePrincipalAllowlist(loadTrustAnchorConfig())
4044
4648
  };
4045
4649
  const result = checkDispatchReadiness(input);
4650
+ let ready = true;
4046
4651
  if (!result.ready) {
4047
4652
  for (const blocker of result.blockers) {
4048
4653
  emitCheckError({
@@ -4053,9 +4658,11 @@ async function main() {
4053
4658
  agent_recovery_prompt: recoveryPromptFor(blocker)
4054
4659
  });
4055
4660
  }
4056
- process.exit(1);
4661
+ ready = false;
4057
4662
  }
4058
- process.exit(0);
4663
+ if (!checkPremiseReassertion())
4664
+ ready = false;
4665
+ process.exit(ready ? 0 : 1);
4059
4666
  }
4060
4667
  function recoveryPromptFor(blocker) {
4061
4668
  if (blocker.startsWith("dispatch-gate issue-existence:")) {