@attalabs/vinaya 0.39.0 → 0.40.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 (151) hide show
  1. package/README.md +9 -9
  2. package/aeg-root/contracts/planner-developer.md +1 -1
  3. package/aeg-root/enforcement.md +22 -22
  4. package/aeg-root/process.md +1 -1
  5. package/aeg-root/roles/archivist.md +1 -1
  6. package/aeg-root/roles/developer/reference.md +4 -1
  7. package/aeg-root/roles/developer.md +1 -1
  8. package/aeg-root/roles/planner/reference.md +18 -5
  9. package/aeg-root/roles/principal.md +1 -1
  10. package/aeg-root/roles/reviewer.md +3 -3
  11. package/aeg-root/roles/security.md +4 -4
  12. package/aeg-root/roles/tranche-archivist.md +2 -2
  13. package/aeg-root/skills/aeg/SKILL.md +1 -1
  14. package/aeg-root/state-machine.md +8 -13
  15. package/aeg-root/templates/brief-template.md +4 -1
  16. package/aeg-root/templates/decision-record-template.md +38 -0
  17. package/aeg-root/templates/issue-rationale-template.md +1 -1
  18. package/aeg-root/tranche-model.md +1 -1
  19. package/dist/checks/bin/check-body-bare-digits.js +1867 -347
  20. package/dist/checks/bin/check-branch-topology.js +1181 -237
  21. package/dist/checks/bin/check-brief-shape.js +1911 -433
  22. package/dist/checks/bin/check-changeset-coverage.js +2144 -517
  23. package/dist/checks/bin/check-ci-shard-coverage.js +12133 -11
  24. package/dist/checks/bin/check-closes-n.js +1181 -237
  25. package/dist/checks/bin/check-coherence.js +1785 -1126
  26. package/dist/checks/bin/check-dead-branch-push.js +1154 -225
  27. package/dist/checks/bin/check-dispatch-readiness.js +2068 -436
  28. package/dist/checks/bin/check-doc-claims.js +2104 -231
  29. package/dist/checks/bin/check-doc-coverage-push.js +2181 -515
  30. package/dist/checks/bin/check-doc-coverage.js +2181 -519
  31. package/dist/checks/bin/check-doctrine-no-procedures.js +1668 -345
  32. package/dist/checks/bin/check-doctrine-portability.js +2143 -516
  33. package/dist/checks/bin/check-evidence-fresh.js +2080 -465
  34. package/dist/checks/bin/check-exec-bits.js +2130 -503
  35. package/dist/checks/bin/check-first-push-dispatch.js +1845 -371
  36. package/dist/checks/bin/check-issue-assignment.js +712 -170
  37. package/dist/checks/bin/check-issue-milestone-attach.js +1145 -225
  38. package/dist/checks/bin/check-issue-objectives-numbering.js +1661 -338
  39. package/dist/checks/bin/check-issue-parts-coverage.js +1145 -225
  40. package/dist/checks/bin/check-issue-surface-globs.js +1787 -369
  41. package/dist/checks/bin/check-issue-title-grammar.js +1145 -225
  42. package/dist/checks/bin/check-issue-tranche-label.js +702 -170
  43. package/dist/checks/bin/check-main-branch-refusal.js +1157 -227
  44. package/dist/checks/bin/check-no-disk-state.js +1145 -225
  45. package/dist/checks/bin/check-pr-premise-reassert.js +1661 -338
  46. package/dist/checks/bin/check-pr-report-density.js +1145 -225
  47. package/dist/checks/bin/check-principal-test-plan-wait.js +2379 -249
  48. package/dist/checks/bin/check-quoted-command.js +2128 -501
  49. package/dist/checks/bin/check-reader-resolvable-prose.js +2170 -517
  50. package/dist/checks/bin/check-registry-gates.js +1228 -272
  51. package/dist/checks/bin/check-retired-vocabulary.js +2153 -507
  52. package/dist/checks/bin/check-review-gate.js +1932 -350
  53. package/dist/checks/bin/check-single-plan-pr.js +1208 -229
  54. package/dist/checks/bin/check-surface-scope.js +1414 -244
  55. package/dist/checks/bin/check-test-plan.js +2381 -252
  56. package/dist/checks/bin/check-token-collection-wired.js +1145 -225
  57. package/dist/checks/bin/check-workspace-escape.js +2141 -514
  58. package/dist/checks/bin/verify-coherence.js +493 -86
  59. package/dist/checks/bin/verify-dispatch.js +512 -132
  60. package/dist/checks/bin/verify-docs.js +549 -124
  61. package/dist/index.js +22702 -17900
  62. package/dist/lib/pre-push-cache-test-run.js +1026 -233
  63. package/dist/lib/pre-push-select-tests.js +922 -173
  64. package/package.json +12 -1
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +13 -2
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +55 -26
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +12 -1
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +22 -1
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -1
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/entry-point.ts +27 -0
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +2 -1
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +19 -2
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +593 -55
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +1 -0
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +6 -4
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +19 -2
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +32 -13
  78. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  80. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +2 -2
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  122. 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
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0sxadt2._.js +13 -0
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +57 -0
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1ug9syi._.js → [root-of-the-server]__1wzfiav._.js} +1 -1
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  143. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{06_55xbp7rcbi.js → 1p3vr9qts86_b.js} +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2brkwv169ygep.js → 21tunzmxjvm2a.js} +1 -1
  145. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{33rszkngkuoko.js → 38kom-9c-oi65.js} +1 -1
  146. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +0 -57
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +0 -13
  149. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_buildManifest.js +0 -0
  150. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_clientMiddlewareManifest.js +0 -0
  151. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_ssgManifest.js +0 -0
@@ -126,7 +126,7 @@ import { promisify as promisify4 } from "node:util";
126
126
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
127
127
  import { homedir } from "node:os";
128
128
  import { dirname as dirname2, isAbsolute, join as join2, resolve as resolve2 } from "node:path";
129
- import { z as z5 } from "zod";
129
+ import { z as z6 } from "zod";
130
130
  // ../../packages/aeg-forge-state/src/gh.ts
131
131
  import { execFile, execFileSync } from "node:child_process";
132
132
  import { promisify } from "node:util";
@@ -571,8 +571,372 @@ var NON_PATH_TOP_SEGMENTS = new Set(["origin", "refs", "HEAD", "vinaya", "fix"])
571
571
 
572
572
  // ../../packages/aeg-core/src/doctrine-no-procedures.ts
573
573
  var SHELL_LANGS = new Set(["", "sh", "bash", "shell", "console"]);
574
+ // ../../packages/aeg-core/src/prose-rules.ts
575
+ var RETIRED_GLOBAL_EXEMPTIONS = [
576
+ "docs/decisions-legacy.md",
577
+ "apps/herald-ai/docs/",
578
+ "apps/vada-ai/docs/",
579
+ "aeg-root/tranches/completed/",
580
+ "packages/aeg-core/src/docs/published-prose",
581
+ "packages/aeg-core/src/retired-vocabulary.test.ts",
582
+ "packages/aeg-core/src/retired-vocabulary.ts",
583
+ "/fixtures/",
584
+ "/node_modules/",
585
+ "/.next/",
586
+ "/.turbo/"
587
+ ];
588
+ var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
589
+ var TRANCHE_MODEL_FILE = "/tranche-model.md";
590
+ var RETIRED_PATTERN_EXEMPTIONS = {
591
+ [String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
592
+ [String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
593
+ "docs-index.md",
594
+ "apps/vada-ai/specs/legacy/README.md",
595
+ "apps/vada-ai/specs/vada-product-spec.md",
596
+ "apps/vada-ai/web/CLAUDE.md",
597
+ "apps/vada-ai/CLAUDE.md"
598
+ ],
599
+ "decisions-legacy": [
600
+ "packages/aeg-core/src/file-classify.ts",
601
+ "packages/aeg-core/src/file-classify.test.ts",
602
+ "packages/aeg-core/src/pr-tier.test.ts",
603
+ "docs-index.md",
604
+ ".claude/skills/database/SKILL.md",
605
+ ".claude/skills/vada-architecture/SKILL.md",
606
+ "apps/vada-ai/specs/vada-byok-principles.md",
607
+ "apps/vada-ai/web/CLAUDE.md",
608
+ "apps/vada-ai/CLAUDE.md"
609
+ ],
610
+ CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
611
+ ...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
612
+ };
613
+ var retiredPatterns = [
614
+ String.raw`\bD-[0-9]{3}\b`,
615
+ "D-(###|NNN|nnn|xxx)",
616
+ "decision (entry|logged)",
617
+ "decision-log entry",
618
+ "decision log entry",
619
+ "decision log(s|ged|ging)?([^a-z]|$)",
620
+ "decision-log",
621
+ "decision entr",
622
+ "decisions? (are |is )?logged",
623
+ "log entries",
624
+ String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
625
+ "decisions-legacy",
626
+ "CONTRADICTION",
627
+ "assumes Tier 3",
628
+ "Lock: ?YES",
629
+ "Lock: ?NO",
630
+ "lock approvals?",
631
+ "approves locks",
632
+ "Conforms to lock",
633
+ "Challenges lock",
634
+ "checkDecisionNumbersFresh",
635
+ String.raw`roles/team-leader\.md`,
636
+ String.raw`\(,`,
637
+ String.raw`,\)`,
638
+ String.raw`\(\.\)`,
639
+ ...PLAN_ON_DISK_PATTERNS
640
+ ];
641
+ var published = [
642
+ ["decision-id", "a decision id", /\bD-\d{3,}\b/],
643
+ ["section-ref", "a section reference", /§/],
644
+ ["forge-number", "a forge number", /#\d+/],
645
+ ["retired-name", "the retired public name", /\bAEG\b/],
646
+ ["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
647
+ [
648
+ "label-vocabulary",
649
+ "forge label vocabulary",
650
+ /(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
651
+ ],
652
+ ["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
653
+ ["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
654
+ [
655
+ "internal-path",
656
+ "a repo-internal file",
657
+ /(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
658
+ ]
659
+ ];
660
+ var DEFAULT_PROSE_RULES = [
661
+ {
662
+ id: "forge-number",
663
+ group: "reader-resolvable",
664
+ scopes: ["ships", "reader-facing", "spec"],
665
+ patterns: { prose: /#[0-9]{2,4}/g },
666
+ flags: ["global"],
667
+ message: "a forge number",
668
+ severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
669
+ exemptions: []
670
+ },
671
+ {
672
+ id: "tranche-slug",
673
+ group: "reader-resolvable",
674
+ scopes: ["ships", "reader-facing", "product", "spec"],
675
+ patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
676
+ flags: ["global"],
677
+ message: "an internal tranche slug",
678
+ severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
679
+ exemptions: []
680
+ },
681
+ {
682
+ id: "task-number",
683
+ group: "reader-resolvable",
684
+ scopes: ["spec"],
685
+ patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
686
+ flags: ["global", "ignore-case"],
687
+ message: "a task number",
688
+ severity: { spec: "error" },
689
+ exemptions: []
690
+ },
691
+ {
692
+ id: "source-comment-tranche-slug",
693
+ group: "reader-resolvable",
694
+ scopes: ["source-comment"],
695
+ patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
696
+ flags: ["global"],
697
+ message: "a tranche-slug citation",
698
+ severity: { "source-comment": "warning" },
699
+ exemptions: []
700
+ },
701
+ {
702
+ id: "source-comment-forge-number",
703
+ group: "reader-resolvable",
704
+ scopes: ["source-comment"],
705
+ patterns: { comment: /#[0-9]{2,}/g },
706
+ flags: ["global"],
707
+ message: "a forge-number citation",
708
+ severity: { "source-comment": "warning" },
709
+ exemptions: []
710
+ },
711
+ {
712
+ id: "legacy-batch-name",
713
+ group: "reader-resolvable",
714
+ scopes: ["ships", "reader-facing", "spec"],
715
+ patterns: {},
716
+ flags: ["built-in"],
717
+ message: "an internal tranche slug",
718
+ severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
719
+ exemptions: [],
720
+ builtIn: true
721
+ },
722
+ {
723
+ id: "coined-term",
724
+ group: "reader-resolvable",
725
+ scopes: ["ships", "reader-facing"],
726
+ patterns: {},
727
+ flags: ["built-in"],
728
+ message: "uses coined term without defining it inline or linking the glossary",
729
+ severity: { ships: "warning", "reader-facing": "warning" },
730
+ exemptions: [],
731
+ builtIn: true
732
+ },
733
+ ...retiredPatterns.map((pattern, index) => ({
734
+ id: `retired-vocabulary-${index + 1}`,
735
+ group: "retired-vocabulary",
736
+ scopes: ["repository"],
737
+ patterns: { repository: pattern },
738
+ flags: [],
739
+ message: "retired vocabulary",
740
+ severity: { repository: "error" },
741
+ exemptions: RETIRED_GLOBAL_EXEMPTIONS,
742
+ patternExemptions: RETIRED_PATTERN_EXEMPTIONS
743
+ })),
744
+ ...published.map(([id, message, pattern]) => ({
745
+ id,
746
+ group: "published-prose",
747
+ scopes: ["published"],
748
+ patterns: { published: pattern },
749
+ flags: [],
750
+ message,
751
+ severity: { published: "error" },
752
+ exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
753
+ }))
754
+ ];
755
+ var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
756
+ var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
757
+ var RETIRED_SCOPES = ["repository"];
758
+ var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
759
+ function groupOfScope(scope) {
760
+ if (RESOLVABLE_SCOPES.includes(scope))
761
+ return "reader-resolvable";
762
+ if (RETIRED_SCOPES.includes(scope))
763
+ return "retired-vocabulary";
764
+ return;
765
+ }
766
+ var CONFIGURED_PROSE_FLAGS = ["i", "u"];
767
+ var CONFIGURED_PATTERN_MAX_LENGTH = 200;
768
+ var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
769
+ function allowedScopesFor(rule) {
770
+ if (rule.builtIn)
771
+ return rule.scopes;
772
+ return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
773
+ }
774
+ function normalizeRepoPath(entry) {
775
+ let out = entry.replace(/\\/g, "/");
776
+ while (out.startsWith("./"))
777
+ out = out.slice(2);
778
+ out = out.replace(/\/{2,}/g, "/");
779
+ while (out.endsWith("/"))
780
+ out = out.slice(0, -1);
781
+ return out;
782
+ }
783
+ var RESOLVABLE_RUN_ORDER = [
784
+ "forge-number",
785
+ "tranche-slug",
786
+ "legacy-batch-name",
787
+ "task-number",
788
+ "source-comment-tranche-slug",
789
+ "source-comment-forge-number",
790
+ "coined-term"
791
+ ];
792
+ var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
793
+ function scopeDefaultSeverity(scope, sourceCommentSeverity) {
794
+ if (scope === "source-comment")
795
+ return sourceCommentSeverity ?? "warning";
796
+ if (scope === "repository")
797
+ return "error";
798
+ return "warning";
799
+ }
800
+ function applySeverity(scopes, base, setting) {
801
+ const out = {};
802
+ for (const scope of scopes) {
803
+ const configured = typeof setting === "string" ? setting : setting?.[scope];
804
+ const value = configured ?? base[scope];
805
+ if (value !== undefined)
806
+ out[scope] = value;
807
+ }
808
+ return out;
809
+ }
810
+ function defaultPatternFor(rule) {
811
+ const cache = new Map;
812
+ return (scope) => {
813
+ if (cache.has(scope))
814
+ return cache.get(scope) ?? null;
815
+ const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
816
+ const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
817
+ cache.set(scope, compiled);
818
+ return compiled;
819
+ };
820
+ }
821
+ function customPatternFor(rule, global) {
822
+ const cache = new Map;
823
+ return (scope) => {
824
+ if (cache.has(scope))
825
+ return cache.get(scope) ?? null;
826
+ const source = rule.patterns?.[scope] ?? rule.pattern;
827
+ const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
828
+ cache.set(scope, compiled);
829
+ return compiled;
830
+ };
831
+ }
832
+ function resolveProseRules(config = undefined, options = {}) {
833
+ const rules = [];
834
+ const defaults = config?.defaults ?? {};
835
+ for (const rule of CONFIGURABLE_DEFAULT_RULES) {
836
+ const override = defaults[rule.id];
837
+ if (override === "off")
838
+ continue;
839
+ const group = rule.group;
840
+ const scopes = override?.scopes ?? rule.scopes;
841
+ const base = {};
842
+ for (const scope of scopes) {
843
+ base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
844
+ }
845
+ rules.push({
846
+ id: rule.id,
847
+ group,
848
+ custom: false,
849
+ builtIn: rule.builtIn === true,
850
+ scopes,
851
+ message: rule.message,
852
+ severity: applySeverity(scopes, base, override?.severity),
853
+ exempt: override?.exempt ?? [],
854
+ substringExempt: rule.exemptions,
855
+ reportGroup: REPORT_GROUPS[rule.id],
856
+ patternFor: defaultPatternFor(rule)
857
+ });
858
+ }
859
+ for (const rule of config?.custom ?? []) {
860
+ const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
861
+ const base = {};
862
+ for (const scope of rule.scopes)
863
+ base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
864
+ rules.push({
865
+ id: rule.id,
866
+ group,
867
+ custom: true,
868
+ builtIn: false,
869
+ scopes: rule.scopes,
870
+ message: rule.means,
871
+ severity: applySeverity(rule.scopes, base, rule.severity),
872
+ exempt: rule.exempt ?? [],
873
+ substringExempt: [],
874
+ patternFor: customPatternFor(rule, group === "reader-resolvable")
875
+ });
876
+ }
877
+ if (options.decisionRecordsPath !== undefined)
878
+ rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
879
+ const order = (rule) => {
880
+ const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
881
+ return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
882
+ };
883
+ const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
884
+ const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
885
+ return {
886
+ rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
887
+ exempt: config?.exempt ?? [],
888
+ repoRoot: options.repoRoot
889
+ };
890
+ }
891
+ var DEFAULT_PROSE_RULE_SET = resolveProseRules();
892
+ var DECISION_RECORD_CITATION_ID = "decision-record-citation";
893
+ var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
894
+ var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
895
+ function escapeRegExp(text) {
896
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
897
+ }
898
+ function decisionRecordCitationPattern(decisionRecordsPath) {
899
+ const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
900
+ return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
901
+ }
902
+ function decisionRecordCitationRule(decisionRecordsPath) {
903
+ const folder = normalizeRepoPath(decisionRecordsPath);
904
+ const pattern = decisionRecordCitationPattern(folder);
905
+ const severity = {};
906
+ for (const scope of DECISION_RECORD_CITATION_SCOPES)
907
+ severity[scope] = "error";
908
+ return {
909
+ id: DECISION_RECORD_CITATION_ID,
910
+ group: "reader-resolvable",
911
+ custom: false,
912
+ builtIn: false,
913
+ scopes: DECISION_RECORD_CITATION_SCOPES,
914
+ message: DECISION_RECORD_CITATION_MESSAGE,
915
+ severity,
916
+ exempt: [folder],
917
+ substringExempt: [],
918
+ patternFor: () => pattern
919
+ };
920
+ }
921
+
574
922
  // ../../packages/aeg-core/src/reader-resolvable-prose.ts
923
+ function normalizeSpecPath(entry) {
924
+ return normalizeRepoPath(entry);
925
+ }
575
926
  var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
927
+ var readerRules = rulesForGroup("reader-resolvable");
928
+ var readerPattern = (id, scope = "prose") => {
929
+ const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
930
+ if (!(pattern instanceof RegExp))
931
+ throw new Error(`default prose rule ${id} has no ${scope} pattern`);
932
+ return pattern;
933
+ };
934
+ var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
935
+ var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
936
+ var TASK_NUMBER_PATTERN = readerPattern("task-number");
937
+ var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
938
+ var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
939
+ var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
576
940
 
577
941
  // ../../packages/aeg-core/src/quoted-command.ts
578
942
  var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
@@ -616,59 +980,9 @@ var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
616
980
  // ../../packages/aeg-core/src/diagram-model.ts
617
981
  import matter from "gray-matter";
618
982
  // ../../packages/aeg-core/src/retired-vocabulary.ts
619
- var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
620
- var RETIRED_PATTERNS = [
621
- String.raw`\bD-[0-9]{3}\b`,
622
- "D-(###|NNN|nnn|xxx)",
623
- "decision (entry|logged)",
624
- "decision-log entry",
625
- "decision log entry",
626
- "decision log(s|ged|ging)?([^a-z]|$)",
627
- "decision-log",
628
- "decision entr",
629
- "decisions? (are |is )?logged",
630
- "log entries",
631
- String.raw`decisions\.md`,
632
- "decisions-legacy",
633
- "CONTRADICTION",
634
- "assumes Tier 3",
635
- "Lock: ?YES",
636
- "Lock: ?NO",
637
- "lock approvals?",
638
- "approves locks",
639
- "Conforms to lock",
640
- "Challenges lock",
641
- "checkDecisionNumbersFresh",
642
- String.raw`roles/team-leader\.md`,
643
- String.raw`\(,`,
644
- String.raw`,\)`,
645
- String.raw`\(\.\)`,
646
- ...PLAN_ON_DISK_PATTERNS
647
- ];
648
- var TRANCHE_MODEL_FILE = "/tranche-model.md";
649
- var PATTERN_EXEMPT = {
650
- [String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
651
- [String.raw`decisions\.md`]: [
652
- "docs-index.md",
653
- "apps/vada-ai/specs/legacy/README.md",
654
- "apps/vada-ai/specs/vada-product-spec.md",
655
- "apps/vada-ai/web/CLAUDE.md",
656
- "apps/vada-ai/CLAUDE.md"
657
- ],
658
- "decisions-legacy": [
659
- "packages/aeg-core/src/file-classify.ts",
660
- "packages/aeg-core/src/file-classify.test.ts",
661
- "packages/aeg-core/src/pr-tier.test.ts",
662
- "docs-index.md",
663
- ".claude/skills/database/SKILL.md",
664
- ".claude/skills/vada-architecture/SKILL.md",
665
- "apps/vada-ai/specs/vada-byok-principles.md",
666
- "apps/vada-ai/web/CLAUDE.md",
667
- "apps/vada-ai/CLAUDE.md"
668
- ],
669
- CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
670
- ...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
671
- };
983
+ var retiredRules = rulesForGroup("retired-vocabulary");
984
+ var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
985
+ var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
672
986
  // ../../packages/aeg-core/src/task-tools.ts
673
987
  import { z } from "zod";
674
988
  var TASK_TOOL_ERROR_KINDS = [
@@ -937,9 +1251,11 @@ var LineageSchema = z3.object({
937
1251
  parent: z3.string().nullable()
938
1252
  }).strict();
939
1253
  var InputVersionsSchema = z3.object({
1254
+ manifest_version: z3.literal(2).nullable().optional(),
940
1255
  objectives_version: z3.string().nullable(),
941
1256
  brief_hash: z3.string().nullable(),
942
1257
  ruling_ordinal: z3.number().int().nullable(),
1258
+ pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
943
1259
  policy_digest: z3.string().nullable()
944
1260
  }).strict();
945
1261
  var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
@@ -1487,17 +1803,19 @@ function buildHeader(input) {
1487
1803
  parent: lineageFieldFromEnv(input.env.parent)
1488
1804
  },
1489
1805
  input_versions: {
1806
+ manifest_version: input.inputVersions?.manifestVersion ?? null,
1490
1807
  objectives_version: input.inputVersions?.objectivesVersion ?? null,
1491
1808
  brief_hash: input.inputVersions?.briefHash ?? null,
1492
1809
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
1810
+ pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
1493
1811
  policy_digest: input.inputVersions?.policyDigest ?? null
1494
1812
  },
1495
1813
  provenance: provenanceFor(input),
1496
1814
  work: {
1497
1815
  ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
1498
1816
  repo: input.repo,
1499
- change: null,
1500
- revision: null
1817
+ change: pr === undefined ? null : String(pr),
1818
+ revision: input.revision ?? null
1501
1819
  },
1502
1820
  flow: {
1503
1821
  id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
@@ -1685,6 +2003,12 @@ var ManifestRecordSchema = z4.object({
1685
2003
  briefHash: z4.string().min(1).nullable(),
1686
2004
  objectivesVersion: z4.string().min(1).nullable(),
1687
2005
  rulingOrdinal: epochNumber,
2006
+ manifestVersion: z4.literal(2).optional(),
2007
+ pauseBoundRuling: z4.object({
2008
+ rulingId: z4.string().min(1),
2009
+ pauseId: z4.string().min(1),
2010
+ contentDigest: z4.string().min(1)
2011
+ }).strict().nullable().optional(),
1688
2012
  policyDigest: z4.string().min(1),
1689
2013
  recordedAt: isoTimestamp
1690
2014
  }).strict();
@@ -1706,7 +2030,11 @@ var LoopStateRecordSchema = z4.object({
1706
2030
  deliveredFindings: roundHeadIdentity.nullable(),
1707
2031
  repeatMemory: z4.object({
1708
2032
  blockingFindings: z4.array(z4.string()),
1709
- lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
2033
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
2034
+ }).strict().optional(),
2035
+ developerHandoff: z4.object({
2036
+ findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
2037
+ failingChecks: z4.array(z4.string().min(1))
1710
2038
  }).strict().optional(),
1711
2039
  publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
1712
2040
  taskStartedAt: isoTimestamp.optional(),
@@ -1782,10 +2110,10 @@ import { dirname, join, resolve, sep } from "node:path";
1782
2110
  function isErrnoException(err, code) {
1783
2111
  return typeof err === "object" && err !== null && err.code === code;
1784
2112
  }
1785
- function isTrustedDirStat(stat, ownUid) {
2113
+ function isTrustedDirStat(stat, ownUid, trustedOverflowUid) {
1786
2114
  if (typeof ownUid !== "number")
1787
2115
  return true;
1788
- if (stat.uid !== ownUid && stat.uid !== 0)
2116
+ if (stat.uid !== ownUid && stat.uid !== 0 && stat.uid !== trustedOverflowUid)
1789
2117
  return false;
1790
2118
  const worldWritable = (stat.mode & 2) !== 0;
1791
2119
  const sticky = (stat.mode & 512) !== 0;
@@ -1794,15 +2122,54 @@ function isTrustedDirStat(stat, ownUid) {
1794
2122
  function currentUid() {
1795
2123
  return typeof process.getuid === "function" ? process.getuid() : undefined;
1796
2124
  }
2125
+ function uidMapLeavesRootUnmapped(uidMap) {
2126
+ const lines = uidMap.split(`
2127
+ `).map((line) => line.trim()).filter((line) => line.length > 0);
2128
+ if (lines.length === 0)
2129
+ return false;
2130
+ for (const line of lines) {
2131
+ const fields = line.split(/\s+/);
2132
+ if (fields.length !== 3 || !fields.every((field) => /^\d+$/.test(field)))
2133
+ return false;
2134
+ const inside = Number(fields[0]);
2135
+ const count = Number(fields[2]);
2136
+ if (inside === 0 && count > 0)
2137
+ return false;
2138
+ }
2139
+ return true;
2140
+ }
2141
+ function readTrustedOverflowUid(readFile) {
2142
+ try {
2143
+ if (!uidMapLeavesRootUnmapped(readFile("/proc/self/uid_map")))
2144
+ return;
2145
+ const overflow = readFile("/proc/sys/kernel/overflowuid").trim();
2146
+ return /^\d+$/.test(overflow) ? Number(overflow) : undefined;
2147
+ } catch {
2148
+ return;
2149
+ }
2150
+ }
2151
+ var cachedTrustedOverflowUid;
2152
+ function processTrustedOverflowUid() {
2153
+ cachedTrustedOverflowUid ??= { value: readTrustedOverflowUid((path) => readFileSync2(path, "utf8")) };
2154
+ return cachedTrustedOverflowUid.value;
2155
+ }
2156
+ function isAtOrBelowTrustedRoot(index, rootSegmentCount) {
2157
+ return index >= rootSegmentCount - 1;
2158
+ }
2159
+ function segmentTrustedOverflowUid(index, rootSegmentCount, trustedOverflowUid) {
2160
+ return isAtOrBelowTrustedRoot(index, rootSegmentCount) ? undefined : trustedOverflowUid;
2161
+ }
1797
2162
  function mkdirNoSymlinks(dir, mode, trustedRoot) {
1798
2163
  const absolute = resolve(dir);
1799
2164
  const rootSegments = resolve(trustedRoot).split(sep).filter((s) => s.length > 0);
1800
2165
  const segments = absolute.split(sep).filter((s) => s.length > 0);
1801
2166
  const ownUid = currentUid();
2167
+ const trustedOverflowUid = typeof ownUid === "number" ? processTrustedOverflowUid() : undefined;
1802
2168
  let current = absolute.startsWith(sep) ? sep : "";
1803
2169
  segments.forEach((segment, index) => {
1804
2170
  current = current === "" || current === sep ? `${current}${segment}` : `${current}${sep}${segment}`;
1805
- const atOrBelowTrustedRoot = index >= rootSegments.length - 1;
2171
+ const atOrBelowTrustedRoot = isAtOrBelowTrustedRoot(index, rootSegments.length);
2172
+ const overflowUid = segmentTrustedOverflowUid(index, rootSegments.length, trustedOverflowUid);
1806
2173
  try {
1807
2174
  mkdirSync(current, { mode });
1808
2175
  } catch (err) {
@@ -1823,7 +2190,7 @@ function mkdirNoSymlinks(dir, mode, trustedRoot) {
1823
2190
  if (!real.isDirectory()) {
1824
2191
  throw new Error(`control-store: refusing to create a run directory through ${current} — it is a symlink that does not resolve to a real directory`);
1825
2192
  }
1826
- if (!isTrustedDirStat(real, ownUid)) {
2193
+ if (!isTrustedDirStat(real, ownUid, overflowUid)) {
1827
2194
  throw new Error(`control-store: refusing to create a run directory through ${current} — its symlink target is owned by uid ${real.uid} with mode ${(real.mode & 4095).toString(8)}, neither this process's own user nor a safe shared mode`);
1828
2195
  }
1829
2196
  return;
@@ -1831,33 +2198,324 @@ function mkdirNoSymlinks(dir, mode, trustedRoot) {
1831
2198
  if (!stat.isDirectory()) {
1832
2199
  throw new Error(`control-store: refusing to create a run directory through ${current} — it already exists and is not a real directory (a symlink or a file)`);
1833
2200
  }
1834
- if (!isTrustedDirStat(stat, ownUid)) {
2201
+ if (!isTrustedDirStat(stat, ownUid, overflowUid)) {
1835
2202
  throw new Error(`control-store: refusing to create a run directory through ${current} — it already exists, owned by uid ${stat.uid} with mode ${(stat.mode & 4095).toString(8)}, neither this process's own user nor a safe shared mode`);
1836
2203
  }
1837
2204
  });
1838
2205
  }
1839
2206
  var CONTROL_AREA_DIRNAME = "control";
2207
+ // src/checks/contract.ts
2208
+ var CHECK_SCHEMA_VERSION = 1;
2209
+ function emitCheckError(error) {
2210
+ process.stderr.write(`${JSON.stringify(error)}
2211
+ `);
2212
+ }
2213
+
1840
2214
  // src/lib/agent-vendors.ts
1841
2215
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
1842
2216
 
2217
+ // src/lib/prose-rules-config.ts
2218
+ import safeRegex from "safe-regex2";
2219
+ import { z as z5 } from "zod";
2220
+ var SEVERITIES = ["error", "warning"];
2221
+ var OVERRIDE_KEYS = ["scopes", "severity", "exempt"];
2222
+ var FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
2223
+ var CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
2224
+ var DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
2225
+ function isPlainObject(value) {
2226
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2227
+ }
2228
+ function outsideRepositoryReason(entry) {
2229
+ if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
2230
+ return "must be a repository-relative path, not an absolute one";
2231
+ if (entry.split(/[\\/]/).includes(".."))
2232
+ return "must stay inside the repository — no `..` segment";
2233
+ return null;
2234
+ }
2235
+ var RepoRelativePathSchema = z5.string().min(1).superRefine((entry, ctx) => {
2236
+ const reason = outsideRepositoryReason(entry);
2237
+ if (reason)
2238
+ ctx.addIssue({ code: z5.ZodIssueCode.custom, message: reason });
2239
+ });
2240
+ function pathListIssues(value, path, issues) {
2241
+ if (!Array.isArray(value)) {
2242
+ issues.push({ path, message: "must be a list of repository-relative paths" });
2243
+ return;
2244
+ }
2245
+ value.forEach((entry, index) => {
2246
+ if (typeof entry !== "string" || entry.length === 0) {
2247
+ issues.push({ path: [...path, index], message: "must be a non-empty repository-relative path" });
2248
+ return;
2249
+ }
2250
+ const reason = outsideRepositoryReason(entry);
2251
+ if (reason)
2252
+ issues.push({ path: [...path, index], message: reason });
2253
+ });
2254
+ }
2255
+ function scopeListIssues(value, path, allowed, issues) {
2256
+ if (!Array.isArray(value) || value.length === 0) {
2257
+ issues.push({ path, message: "must name at least one scope" });
2258
+ return null;
2259
+ }
2260
+ const scopes = [];
2261
+ value.forEach((scope, index) => {
2262
+ if (typeof scope !== "string" || !CONFIGURABLE_PROSE_SCOPES.includes(scope)) {
2263
+ issues.push({
2264
+ path: [...path, index],
2265
+ message: scope === "published" ? 'scope "published" is not configurable here — the published pass is configured by proseGates.published.allow' : `unknown scope ${JSON.stringify(scope)} — the scopes are: ${CONFIGURABLE_PROSE_SCOPES.join(", ")}`
2266
+ });
2267
+ return;
2268
+ }
2269
+ if (!allowed.includes(scope)) {
2270
+ issues.push({
2271
+ path: [...path, index],
2272
+ message: `scope "${scope}" is not one this rule can run in — it can run in: ${allowed.join(", ")}`
2273
+ });
2274
+ return;
2275
+ }
2276
+ scopes.push(scope);
2277
+ });
2278
+ return scopes;
2279
+ }
2280
+ function severityIssues(value, path, scopes, issues) {
2281
+ if (typeof value === "string") {
2282
+ if (!SEVERITIES.includes(value)) {
2283
+ issues.push({ path, message: `unknown severity ${JSON.stringify(value)} — use "error" or "warning"` });
2284
+ }
2285
+ return;
2286
+ }
2287
+ if (!isPlainObject(value)) {
2288
+ issues.push({ path, message: 'must be "error", "warning", or a map from scope to one of them' });
2289
+ return;
2290
+ }
2291
+ for (const [scope, severity] of Object.entries(value)) {
2292
+ if (!scopes.includes(scope)) {
2293
+ issues.push({ path: [...path, scope], message: `names scope "${scope}", which this rule's scopes do not cover` });
2294
+ }
2295
+ if (typeof severity !== "string" || !SEVERITIES.includes(severity)) {
2296
+ issues.push({
2297
+ path: [...path, scope],
2298
+ message: `unknown severity ${JSON.stringify(severity)} — use "error" or "warning"`
2299
+ });
2300
+ }
2301
+ }
2302
+ }
2303
+ function patternIssues(source, flags, path, issues) {
2304
+ if (typeof source !== "string" || source.length === 0) {
2305
+ issues.push({ path, message: "must be a non-empty regular expression" });
2306
+ return;
2307
+ }
2308
+ if (source.length > CONFIGURED_PATTERN_MAX_LENGTH) {
2309
+ issues.push({
2310
+ path,
2311
+ message: `is ${source.length} characters, over the ${CONFIGURED_PATTERN_MAX_LENGTH}-character limit for a configured pattern`
2312
+ });
2313
+ return;
2314
+ }
2315
+ try {
2316
+ new RegExp(source, flags);
2317
+ } catch (err) {
2318
+ issues.push({ path, message: `does not compile: ${err.message}` });
2319
+ return;
2320
+ }
2321
+ if (!safeRegex(source, { limit: Number.MAX_SAFE_INTEGER })) {
2322
+ issues.push({
2323
+ path,
2324
+ message: "has star height above one (a repeated group that itself repeats), which can take exponential time — " + "safe-regex2 refuses it. The shipped defaults are not held to this limit, so a pattern copied from one of " + "them can still be refused here; rewrite it without the nested repetition."
2325
+ });
2326
+ }
2327
+ }
2328
+ function flagIssues(value, path, issues) {
2329
+ if (value === undefined)
2330
+ return "";
2331
+ if (typeof value !== "string") {
2332
+ issues.push({ path, message: 'must be a string of flags, e.g. "i"' });
2333
+ return "";
2334
+ }
2335
+ const seen = new Set;
2336
+ for (const flag of value) {
2337
+ if (!CONFIGURED_PROSE_FLAGS.includes(flag)) {
2338
+ issues.push({
2339
+ path,
2340
+ message: `unknown flag ${JSON.stringify(flag)} — only ${CONFIGURED_PROSE_FLAGS.map((f) => `"${f}"`).join(" and ")} are allowed`
2341
+ });
2342
+ return "";
2343
+ }
2344
+ if (seen.has(flag)) {
2345
+ issues.push({ path, message: `repeats the flag "${flag}"` });
2346
+ return "";
2347
+ }
2348
+ seen.add(flag);
2349
+ }
2350
+ return value;
2351
+ }
2352
+ function defaultsIssues(value, issues) {
2353
+ const base = ["defaults"];
2354
+ if (!isPlainObject(value)) {
2355
+ issues.push({ path: base, message: 'must map a default rule id to "off" or an override' });
2356
+ return;
2357
+ }
2358
+ for (const [id, override] of Object.entries(value)) {
2359
+ const path = [...base, id];
2360
+ const rule = CONFIGURABLE_DEFAULT_RULES.find((candidate) => candidate.id === id);
2361
+ if (!rule) {
2362
+ issues.push({
2363
+ path,
2364
+ message: `unknown default rule id "${id}" — \`vinaya check --plan\` lists the rules each prose check runs`
2365
+ });
2366
+ continue;
2367
+ }
2368
+ if (override === "off")
2369
+ continue;
2370
+ if (!isPlainObject(override)) {
2371
+ issues.push({ path, message: 'must be "off" or an object with any of scopes, severity, exempt' });
2372
+ continue;
2373
+ }
2374
+ for (const key of Object.keys(override)) {
2375
+ if (OVERRIDE_KEYS.includes(key))
2376
+ continue;
2377
+ issues.push({
2378
+ path: [...path, key],
2379
+ message: FIXED_DEFAULT_KEYS.includes(key) ? `a default rule's ${key} is fixed — add a custom rule under proseGates.rules.custom instead` : `unknown key "${key}" — a default rule takes only scopes, severity and exempt`
2380
+ });
2381
+ }
2382
+ const scopes = override.scopes === undefined ? [...rule.scopes] : scopeListIssues(override.scopes, [...path, "scopes"], allowedScopesFor(rule), issues);
2383
+ if (override.severity !== undefined && scopes)
2384
+ severityIssues(override.severity, [...path, "severity"], scopes, issues);
2385
+ if (override.exempt !== undefined)
2386
+ pathListIssues(override.exempt, [...path, "exempt"], issues);
2387
+ }
2388
+ }
2389
+ function customIssues(value, issues) {
2390
+ if (!Array.isArray(value)) {
2391
+ issues.push({ path: ["custom"], message: "must be a list of rules" });
2392
+ return;
2393
+ }
2394
+ const ids = new Set;
2395
+ value.forEach((rule, index) => {
2396
+ const path = ["custom", index];
2397
+ if (!isPlainObject(rule)) {
2398
+ issues.push({ path, message: "must be a rule object" });
2399
+ return;
2400
+ }
2401
+ for (const key of Object.keys(rule)) {
2402
+ if (!CUSTOM_KEYS.includes(key)) {
2403
+ issues.push({ path: [...path, key], message: `unknown key "${key}" — a rule takes ${CUSTOM_KEYS.join(", ")}` });
2404
+ }
2405
+ }
2406
+ if (typeof rule.id !== "string" || rule.id.length === 0) {
2407
+ issues.push({ path: [...path, "id"], message: "a custom rule needs an id" });
2408
+ } else if (DEFAULT_IDS.has(rule.id)) {
2409
+ issues.push({
2410
+ path: [...path, "id"],
2411
+ message: `"${rule.id}" is a default rule id — a custom rule needs its own id; retune the default under proseGates.rules.defaults instead`
2412
+ });
2413
+ } else if (ids.has(rule.id)) {
2414
+ issues.push({ path: [...path, "id"], message: `"${rule.id}" is used by an earlier custom rule` });
2415
+ } else {
2416
+ ids.add(rule.id);
2417
+ }
2418
+ if (typeof rule.means !== "string" || rule.means.trim().length === 0) {
2419
+ issues.push({ path: [...path, "means"], message: "a custom rule needs a message (`means`)" });
2420
+ }
2421
+ let scopes = null;
2422
+ if (rule.scopes === undefined) {
2423
+ issues.push({ path: [...path, "scopes"], message: "a custom rule needs at least one scope (`scopes`)" });
2424
+ } else {
2425
+ scopes = scopeListIssues(rule.scopes, [...path, "scopes"], CONFIGURABLE_PROSE_SCOPES, issues);
2426
+ }
2427
+ if (scopes && new Set(scopes.map(groupOfScope)).size > 1) {
2428
+ issues.push({
2429
+ path: [...path, "scopes"],
2430
+ message: 'mixes scopes of both prose checks — "repository" belongs to retired-vocabulary and every other scope to reader-resolvable-prose; write one rule per check'
2431
+ });
2432
+ }
2433
+ const flags = flagIssues(rule.flags, [...path, "flags"], issues);
2434
+ if (rule.pattern === undefined && rule.patterns === undefined) {
2435
+ issues.push({
2436
+ path: [...path, "pattern"],
2437
+ message: "a custom rule needs a `pattern` or a per-scope `patterns` map"
2438
+ });
2439
+ }
2440
+ if (rule.pattern !== undefined)
2441
+ patternIssues(rule.pattern, flags, [...path, "pattern"], issues);
2442
+ if (rule.patterns !== undefined) {
2443
+ if (!isPlainObject(rule.patterns)) {
2444
+ issues.push({ path: [...path, "patterns"], message: "must map a scope to a regular expression" });
2445
+ } else {
2446
+ for (const [scope, source] of Object.entries(rule.patterns)) {
2447
+ if (scopes && !scopes.includes(scope)) {
2448
+ issues.push({
2449
+ path: [...path, "patterns", scope],
2450
+ message: `names scope "${scope}", which this rule's scopes do not cover`
2451
+ });
2452
+ continue;
2453
+ }
2454
+ patternIssues(source, flags, [...path, "patterns", scope], issues);
2455
+ }
2456
+ if (rule.pattern === undefined && scopes) {
2457
+ for (const scope of scopes) {
2458
+ if (!(scope in rule.patterns)) {
2459
+ issues.push({
2460
+ path: [...path, "patterns"],
2461
+ message: `has no pattern for scope "${scope}" — add one, or a \`pattern\` every other scope uses`
2462
+ });
2463
+ }
2464
+ }
2465
+ }
2466
+ }
2467
+ }
2468
+ if (rule.severity !== undefined && scopes)
2469
+ severityIssues(rule.severity, [...path, "severity"], scopes, issues);
2470
+ if (rule.exempt !== undefined)
2471
+ pathListIssues(rule.exempt, [...path, "exempt"], issues);
2472
+ });
2473
+ }
2474
+ function proseRulesIssues(value) {
2475
+ const issues = [];
2476
+ if (!isPlainObject(value))
2477
+ return [{ path: [], message: "must be an object with any of exempt, defaults, custom" }];
2478
+ for (const key of Object.keys(value)) {
2479
+ if (!["exempt", "defaults", "custom"].includes(key)) {
2480
+ issues.push({ path: [key], message: `unknown key "${key}" — proseGates.rules takes exempt, defaults and custom` });
2481
+ }
2482
+ }
2483
+ if (value.exempt !== undefined)
2484
+ pathListIssues(value.exempt, ["exempt"], issues);
2485
+ if (value.defaults !== undefined)
2486
+ defaultsIssues(value.defaults, issues);
2487
+ if (value.custom !== undefined)
2488
+ customIssues(value.custom, issues);
2489
+ return issues;
2490
+ }
2491
+ var ProseRulesSchema = z5.unknown().superRefine((value, ctx) => {
2492
+ for (const issue of proseRulesIssues(value)) {
2493
+ ctx.addIssue({ code: z5.ZodIssueCode.custom, path: issue.path, message: issue.message });
2494
+ }
2495
+ }).transform((value) => value);
2496
+ var PublishedProseSchema = z5.object({
2497
+ allow: z5.array(z5.string().min(1)).optional()
2498
+ }).strict();
2499
+
1843
2500
  // src/lib/config.ts
1844
- var EnvEntrySchema = z5.union([
1845
- z5.literal(true),
1846
- z5.object({ optional: z5.literal(true) }),
1847
- z5.object({ anyOf: z5.array(z5.string()).min(2) }),
1848
- z5.string()
2501
+ var EnvEntrySchema = z6.union([
2502
+ z6.literal(true),
2503
+ z6.object({ optional: z6.literal(true) }),
2504
+ z6.object({ anyOf: z6.array(z6.string()).min(2) }),
2505
+ z6.string()
1849
2506
  ]);
1850
- var CheckEntrySchema = z5.object({
1851
- run: z5.string(),
1852
- scope: z5.enum(["diff", "full"]),
1853
- include: z5.array(z5.string()).optional(),
1854
- args: z5.array(z5.string()).optional(),
1855
- timeoutMs: z5.number().optional(),
1856
- env: z5.record(z5.string(), EnvEntrySchema).optional(),
1857
- requiresOpenPr: z5.boolean().optional(),
1858
- ownWorkflow: z5.boolean().optional(),
1859
- principalOwed: z5.literal(true).optional(),
1860
- validates: z5.enum(["body", "issue"]).optional()
2507
+ var CheckEntrySchema = z6.object({
2508
+ run: z6.string(),
2509
+ scope: z6.enum(["diff", "full"]),
2510
+ include: z6.array(z6.string()).optional(),
2511
+ args: z6.array(z6.string()).optional(),
2512
+ timeoutMs: z6.number().optional(),
2513
+ env: z6.record(z6.string(), EnvEntrySchema).optional(),
2514
+ requiresOpenPr: z6.boolean().optional(),
2515
+ ownWorkflow: z6.boolean().optional(),
2516
+ principalOwed: z6.literal(true).optional(),
2517
+ validates: z6.enum(["body", "issue"]).optional(),
2518
+ advisory: z6.literal(true).optional()
1861
2519
  }).superRefine((entry, ctx) => {
1862
2520
  if (!entry.env)
1863
2521
  return;
@@ -1867,22 +2525,22 @@ var CheckEntrySchema = z5.object({
1867
2525
  const members = value.anyOf;
1868
2526
  if (new Set(members).size !== members.length) {
1869
2527
  ctx.addIssue({
1870
- code: z5.ZodIssueCode.custom,
2528
+ code: z6.ZodIssueCode.custom,
1871
2529
  message: `env.${key}.anyOf has duplicate members`,
1872
2530
  path: ["env", key, "anyOf"]
1873
2531
  });
1874
2532
  }
1875
2533
  if (!members.includes(key)) {
1876
2534
  ctx.addIssue({
1877
- code: z5.ZodIssueCode.custom,
2535
+ code: z6.ZodIssueCode.custom,
1878
2536
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
1879
2537
  path: ["env", key, "anyOf"]
1880
2538
  });
1881
2539
  }
1882
2540
  }
1883
2541
  });
1884
- var RoleEntrySchema = z5.object({
1885
- contract: z5.string().refine((p) => p.includes("/"), {
2542
+ var RoleEntrySchema = z6.object({
2543
+ contract: z6.string().refine((p) => p.includes("/"), {
1886
2544
  message: 'must be a path (contain at least one "/"), not a bare filename'
1887
2545
  })
1888
2546
  });
@@ -1906,17 +2564,17 @@ var BRIEF_BUILTINS = [
1906
2564
  "briefSections",
1907
2565
  "milestoneShape"
1908
2566
  ];
1909
- var BriefSectionSchema = z5.union([
1910
- z5.object({ builtin: z5.enum(BRIEF_BUILTINS) }),
1911
- z5.object({ heading: z5.string().min(1), name: z5.string().optional() }),
1912
- z5.object({ field: z5.string().min(1), name: z5.string().optional() }),
1913
- z5.object({ phrase: z5.string().min(1), name: z5.string().optional() })
2567
+ var BriefSectionSchema = z6.union([
2568
+ z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
2569
+ z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
2570
+ z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
2571
+ z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
1914
2572
  ]);
1915
- var BriefSchemaSchema = z5.object({
1916
- pr: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
1917
- issue: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
1918
- milestone: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
1919
- ack: z5.array(z5.enum(BRIEF_BUILTINS)).optional()
2573
+ var BriefSchemaSchema = z6.object({
2574
+ pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
2575
+ issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
2576
+ milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
2577
+ ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
1920
2578
  });
1921
2579
  function isSafeRepoRelPath(p) {
1922
2580
  if (p.length === 0)
@@ -1925,7 +2583,7 @@ function isSafeRepoRelPath(p) {
1925
2583
  return false;
1926
2584
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
1927
2585
  }
1928
- var SafeRepoRelPath = z5.string().refine(isSafeRepoRelPath, {
2586
+ var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
1929
2587
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
1930
2588
  });
1931
2589
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -1935,22 +2593,22 @@ function isCanonicalHookBlockPath(p) {
1935
2593
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
1936
2594
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
1937
2595
  });
1938
- var ManagedBlockRecordSchema = z5.object({
2596
+ var ManagedBlockRecordSchema = z6.object({
1939
2597
  path: ManagedHookBlockPath,
1940
- marker: z5.string(),
1941
- comment: z5.enum(["hash", "html"])
2598
+ marker: z6.string(),
2599
+ comment: z6.enum(["hash", "html"])
1942
2600
  });
1943
- var ManagedManifestSchema = z5.object({
1944
- version: z5.number().int().positive(),
1945
- files: z5.array(SafeRepoRelPath),
1946
- blocks: z5.array(ManagedBlockRecordSchema),
1947
- labels: z5.array(z5.string()),
1948
- agents: z5.array(z5.enum(AGENT_VENDORS)).optional()
2601
+ var ManagedManifestSchema = z6.object({
2602
+ version: z6.number().int().positive(),
2603
+ files: z6.array(SafeRepoRelPath),
2604
+ blocks: z6.array(ManagedBlockRecordSchema),
2605
+ labels: z6.array(z6.string()),
2606
+ agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
1949
2607
  });
1950
- var ProjectEntrySchema = z5.object({
1951
- name: z5.string().min(1),
1952
- description: z5.string().min(1).optional(),
1953
- path: z5.string().min(1).optional()
2608
+ var ProjectEntrySchema = z6.object({
2609
+ name: z6.string().min(1),
2610
+ description: z6.string().min(1).optional(),
2611
+ path: z6.string().min(1).optional()
1954
2612
  });
1955
2613
  function parseTokensCollectDeclaration(value) {
1956
2614
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -1961,90 +2619,90 @@ function parseTokensCollectDeclaration(value) {
1961
2619
  return null;
1962
2620
  return { interpreter, script };
1963
2621
  }
1964
- var VinayaConfigSchema = z5.object({
1965
- rings: z5.object({
1966
- ring1_forgeWriteInterception: z5.boolean(),
1967
- ring2_asyncAudits: z5.boolean()
2622
+ var VinayaConfigObjectSchema = z6.object({
2623
+ rings: z6.object({
2624
+ ring1_forgeWriteInterception: z6.boolean(),
2625
+ ring2_asyncAudits: z6.boolean()
1968
2626
  }).optional(),
1969
- checks: z5.record(z5.string(), CheckEntrySchema).optional(),
1970
- roles: z5.record(z5.string(), RoleEntrySchema).optional(),
2627
+ checks: z6.record(z6.string(), CheckEntrySchema).optional(),
2628
+ roles: z6.record(z6.string(), RoleEntrySchema).optional(),
1971
2629
  briefSchema: BriefSchemaSchema.optional(),
1972
2630
  managed: ManagedManifestSchema.optional(),
1973
- principals: z5.array(z5.string()).min(1).optional(),
1974
- releaseActor: z5.string().min(1).optional(),
1975
- ci: z5.object({ setup: z5.string().min(1) }).optional(),
1976
- tokens: z5.object({
1977
- collect: z5.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
2631
+ principals: z6.array(z6.string()).min(1).optional(),
2632
+ releaseActor: z6.string().min(1).optional(),
2633
+ ci: z6.object({ setup: z6.string().min(1) }).optional(),
2634
+ tokens: z6.object({
2635
+ collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
1978
2636
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
1979
2637
  })
1980
2638
  }).optional(),
1981
- blastRadius: z5.object({ extraDomains: z5.array(z5.string()).optional() }).optional(),
1982
- proseGates: z5.object({
1983
- doctrineRoot: z5.string().min(1).optional(),
1984
- readerFacingPrefix: z5.string().min(1).optional(),
1985
- readerFacingSuffix: z5.string().min(1).optional(),
1986
- legacySlugDir: z5.string().min(1).optional(),
1987
- sourceComments: z5.object({
1988
- globs: z5.array(z5.string().min(1)).optional(),
1989
- allowlist: z5.array(z5.string().min(1)).optional(),
1990
- severity: z5.enum(["warning", "error"]).optional()
2639
+ blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
2640
+ proseGates: z6.object({
2641
+ doctrineRoot: z6.string().min(1).optional(),
2642
+ readerFacingPrefix: z6.string().min(1).optional(),
2643
+ readerFacingSuffix: z6.string().min(1).optional(),
2644
+ legacySlugDir: z6.string().min(1).optional(),
2645
+ sourceComments: z6.object({
2646
+ globs: z6.array(z6.string().min(1)).optional(),
2647
+ allowlist: z6.array(z6.string().min(1)).optional(),
2648
+ severity: z6.enum(["warning", "error"]).optional()
1991
2649
  }).optional(),
1992
- specGrandfather: z5.union([z5.array(z5.string().min(1)), z5.record(z5.string().min(1), z5.number().int().min(0))]).optional(),
1993
- specPaths: z5.array(z5.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
1994
- message: "must be a repository-relative path, not an absolute one"
1995
- }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
1996
- message: "must stay inside the repository — no `..` segment"
1997
- })).optional()
2650
+ specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
2651
+ specPaths: z6.array(RepoRelativePathSchema).optional(),
2652
+ productPaths: z6.array(RepoRelativePathSchema).optional(),
2653
+ published: PublishedProseSchema.optional(),
2654
+ rules: ProseRulesSchema.optional()
1998
2655
  }).optional(),
1999
- projects: z5.array(ProjectEntrySchema).optional(),
2000
- dispatch: z5.object({
2001
- timeoutMs: z5.number().int().positive().optional(),
2002
- killGraceMs: z5.number().int().positive().optional(),
2003
- agent: z5.enum(["claude", "codex", "gemini"]).optional()
2656
+ projects: z6.array(ProjectEntrySchema).optional(),
2657
+ dispatch: z6.object({
2658
+ timeoutMs: z6.number().int().positive().optional(),
2659
+ reviewerTimeoutMs: z6.number().int().positive().optional(),
2660
+ killGraceMs: z6.number().int().positive().optional(),
2661
+ agent: z6.enum(["claude", "codex"]).optional()
2004
2662
  }).optional(),
2005
- reviewPolicy: z5.object({
2006
- codeReviewThreshold: z5.string().min(1).optional(),
2007
- securityThreshold: z5.string().min(1).optional(),
2008
- maxRounds: z5.number().optional(),
2009
- maxTaskMinutes: z5.number().optional()
2663
+ reviewPolicy: z6.object({
2664
+ codeReviewThreshold: z6.string().min(1).optional(),
2665
+ securityThreshold: z6.string().min(1).optional(),
2666
+ maxRounds: z6.number().optional(),
2667
+ maxTaskMinutes: z6.number().optional()
2010
2668
  }).optional(),
2011
- securityScan: z5.object({
2012
- command: z5.array(z5.string().min(1)).min(1)
2669
+ securityScan: z6.object({
2670
+ command: z6.array(z6.string().min(1)).min(1)
2013
2671
  }).optional(),
2014
- gateCutovers: z5.object({
2015
- objectivesSinceIssue: z5.number().int().nonnegative().optional(),
2016
- briefSectionsSinceIssue: z5.number().int().nonnegative().optional(),
2017
- documentationSinceIssue: z5.number().int().nonnegative().optional(),
2018
- briefRulesSincePr: z5.number().int().nonnegative().optional(),
2019
- agentBoxesRefusedSincePr: z5.number().int().nonnegative().optional()
2672
+ gateCutovers: z6.object({
2673
+ objectivesSinceIssue: z6.number().int().nonnegative().optional(),
2674
+ briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
2675
+ documentationSinceIssue: z6.number().int().nonnegative().optional(),
2676
+ briefRulesSincePr: z6.number().int().nonnegative().optional(),
2677
+ agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
2020
2678
  }).optional(),
2021
- planning: z5.object({
2022
- collisionThreshold: z5.number().int().nonnegative().optional()
2679
+ planning: z6.object({
2680
+ collisionThreshold: z6.number().int().nonnegative().optional()
2023
2681
  }).optional(),
2024
- prePush: z5.object({
2025
- alwaysRun: z5.array(z5.string()).optional()
2682
+ prePush: z6.object({
2683
+ alwaysRun: z6.array(z6.string()).optional()
2026
2684
  }).optional(),
2027
- report: z5.object({
2028
- commandTimeoutMs: z5.number().int().positive().optional()
2685
+ report: z6.object({
2686
+ commandTimeoutMs: z6.number().int().positive().optional()
2029
2687
  }).superRefine((report, ctx) => {
2030
2688
  const commandTimeoutMs = report.commandTimeoutMs;
2031
2689
  if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
2032
2690
  ctx.addIssue({
2033
- code: z5.ZodIssueCode.custom,
2691
+ code: z6.ZodIssueCode.custom,
2034
2692
  path: ["commandTimeoutMs"],
2035
2693
  message: "must be at most 3600000 (1 hour)"
2036
2694
  });
2037
2695
  }
2038
2696
  }).optional(),
2039
- logPublish: z5.unknown().refine((v) => v === undefined, {
2697
+ logPublish: z6.unknown().refine((v) => v === undefined, {
2040
2698
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
2041
2699
  }),
2042
- runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
2043
- logs: z5.object({
2044
- folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
2045
- url: z5.string().url().optional(),
2046
- headers: z5.record(z5.string()).optional(),
2047
- readHeaders: z5.record(z5.string()).optional(),
2700
+ runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
2701
+ logs: z6.object({
2702
+ folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
2703
+ url: z6.string().url().optional(),
2704
+ headers: z6.record(z6.string()).optional(),
2705
+ readHeaders: z6.record(z6.string()).optional(),
2048
2706
  events: CustomEventDeclarationsSchema.optional()
2049
2707
  }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
2050
2708
  message: "logs: set at most one of folder/url"
@@ -2052,8 +2710,33 @@ var VinayaConfigSchema = z5.object({
2052
2710
  message: "logs: headers requires url"
2053
2711
  }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
2054
2712
  message: "logs: readHeaders requires url"
2055
- }).optional()
2713
+ }).optional(),
2714
+ decisionRecords: z6.object({
2715
+ path: RepoRelativePathSchema
2716
+ }).strict().optional()
2717
+ });
2718
+ function decisionRecordsPathIssue(path, doctrineRoot) {
2719
+ const reason = outsideRepositoryReason(path);
2720
+ if (reason)
2721
+ return reason;
2722
+ const folder = normalizeSpecPath(path);
2723
+ if (folder === "" || folder === ".")
2724
+ return "must name a folder, not the repository root";
2725
+ const root = normalizeSpecPath(doctrineRoot ?? "aeg-root");
2726
+ if (folder === root || folder.startsWith(`${root}/`)) {
2727
+ return `must be outside the doctrine tree "${root}" — decision records belong to this repository, not to the doctrine it ships`;
2728
+ }
2729
+ return null;
2730
+ }
2731
+ var VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
2732
+ const path = config.decisionRecords?.path;
2733
+ if (path === undefined || outsideRepositoryReason(path))
2734
+ return;
2735
+ const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
2736
+ if (issue)
2737
+ ctx.addIssue({ code: z6.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
2056
2738
  });
2739
+ var VinayaConfigShape = VinayaConfigObjectSchema.shape;
2057
2740
  var GLOBAL_VINAYA_HOME = join2(homedir(), ".vinaya");
2058
2741
  var GLOBAL_CONFIG_PATH = join2(GLOBAL_VINAYA_HOME, "config.json");
2059
2742
  var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
@@ -2227,13 +2910,14 @@ function readTrustAnchorConfigAtRef(ref) {
2227
2910
  });
2228
2911
  return Buffer.from(raw, "utf-8").toString("base64");
2229
2912
  }
2913
+ var NO_TRUST_ANCHOR_REPO_MESSAGE = "could not resolve repo identity for the trust-anchor read";
2230
2914
  function ghFetchTrustAnchorConfig() {
2231
2915
  const probeRef = resolveCiTrustAnchorProbeRef();
2232
2916
  if (probeRef)
2233
2917
  return readTrustAnchorConfigAtRef(probeRef);
2234
2918
  const repo = trustAnchorRepo();
2235
2919
  if (!repo)
2236
- throw new Error("could not resolve repo identity for the trust-anchor read");
2920
+ throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
2237
2921
  return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
2238
2922
  encoding: "utf-8",
2239
2923
  stdio: ["ignore", "pipe", "pipe"]
@@ -2250,7 +2934,7 @@ async function ghFetchTrustAnchorConfigAsync() {
2250
2934
  }
2251
2935
  const repo = await trustAnchorRepoAsync();
2252
2936
  if (!repo)
2253
- throw new Error("could not resolve repo identity for the trust-anchor read");
2937
+ throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
2254
2938
  const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
2255
2939
  return stdout;
2256
2940
  }
@@ -2315,12 +2999,51 @@ function loadConfig() {
2315
2999
  const path = configPath();
2316
3000
  if (!path)
2317
3001
  return null;
3002
+ let text;
2318
3003
  try {
2319
- const raw = JSON.parse(readFileSync3(path, "utf-8"));
2320
- return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
2321
- } catch {
3004
+ text = readFileSync3(path, "utf-8");
3005
+ } catch (err) {
3006
+ reportInvalidConfigOnce(path, `unreadable: ${err.message}`);
2322
3007
  return null;
2323
3008
  }
3009
+ let raw;
3010
+ try {
3011
+ raw = JSON.parse(text);
3012
+ } catch (err) {
3013
+ reportInvalidConfigOnce(path, `invalid JSON: ${err.message}`);
3014
+ return null;
3015
+ }
3016
+ const parsed = VinayaConfigSchema.safeParse(raw);
3017
+ if (!parsed.success) {
3018
+ reportInvalidConfigOnce(path, schemaIssueDetail(parsed.error));
3019
+ return null;
3020
+ }
3021
+ return stripGlobalOnlyKeys(parsed.data, path);
3022
+ }
3023
+ function schemaIssueDetail(error) {
3024
+ return error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
3025
+ }
3026
+ var emittedInvalidConfigReports = new Set;
3027
+ function reportInvalidConfigOnce(path, detail) {
3028
+ const key = `${path}
3029
+ ${detail}`;
3030
+ if (emittedInvalidConfigReports.has(key))
3031
+ return;
3032
+ emittedInvalidConfigReports.add(key);
3033
+ const message = `${path} is not a valid Vinaya configuration (${detail}) — falling back to built-in defaults.`;
3034
+ const checkName = process.env.VINAYA_CHECK_NAME;
3035
+ if (checkName) {
3036
+ emitCheckError({
3037
+ schema: CHECK_SCHEMA_VERSION,
3038
+ check: checkName,
3039
+ severity: "warning",
3040
+ message,
3041
+ agent_recovery_prompt: `Fix the failing keys in ${path} (${detail}) so the file parses and satisfies the configuration schema, then re-run.`,
3042
+ file: path
3043
+ });
3044
+ return;
3045
+ }
3046
+ console.error(`⚠ ${message}`);
2324
3047
  }
2325
3048
  var TOKENS_COLLECT_TRUST_PATH = join2(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
2326
3049
 
@@ -2648,6 +3371,17 @@ var SCANNER_DECLARATIONS = [
2648
3371
  ],
2649
3372
  trigger: "listed-files"
2650
3373
  },
3374
+ {
3375
+ test: "apps/cli/tests/conformance/adapter-contract.test.ts",
3376
+ roots: [
3377
+ "apps/cli/specs/dev-review-engine-capability-matrix.md",
3378
+ "apps/cli/tests/fixtures/dev-review-engine-capability-matrix.json",
3379
+ "apps/cli/tests/eval/registry/modules.json",
3380
+ "AGENTS.md",
3381
+ "CLAUDE.md"
3382
+ ],
3383
+ trigger: "listed-files"
3384
+ },
2651
3385
  { test: "apps/cli/tests/ci-shards.test.ts", roots: ["apps/cli/"], trigger: "tree-shape" },
2652
3386
  {
2653
3387
  test: "apps/cli/tests/conformance/dev-review-invariant-coverage.test.ts",
@@ -2661,6 +3395,11 @@ var SCANNER_DECLARATIONS = [
2661
3395
  ],
2662
3396
  trigger: "tree-shape"
2663
3397
  },
3398
+ {
3399
+ test: "apps/cli/tests/conformance/packed-runtime-not-shipped.test.ts",
3400
+ roots: ["apps/cli/src/"],
3401
+ trigger: "content"
3402
+ },
2664
3403
  { test: "apps/cli/tests/platform-independence.test.ts", roots: ["apps/cli/tests/"], trigger: "content" },
2665
3404
  { test: "apps/cli/tests/process-fixture-coverage.test.ts", roots: ["apps/cli/tests/"], trigger: "process-start" },
2666
3405
  { test: "apps/cli/scripts/bundle-doctrine.test.ts", roots: ["."], trigger: "content" },
@@ -2727,6 +3466,16 @@ var SCANNER_DECLARATIONS = [
2727
3466
  { test: "apps/cli/tests/run-paths-only.test.ts", roots: ["."], trigger: "content" },
2728
3467
  { test: "apps/cli/tests/surface-index.test.ts", roots: ["apps/cli/src/commands/"], trigger: "content" },
2729
3468
  { test: "apps/cli/tests/surface-spec-exports.test.ts", roots: ["apps/cli/src/commands/"], trigger: "content" },
3469
+ {
3470
+ test: "apps/vinaya-portal/src/lib/docs/private-source-links.test.ts",
3471
+ roots: ["apps/vinaya-portal/src/app/(site)/docs/"],
3472
+ trigger: "content"
3473
+ },
3474
+ {
3475
+ test: "apps/vinaya-portal/src/lib/import-boundary.test.ts",
3476
+ roots: ["apps/vinaya-portal/src/"],
3477
+ trigger: "content"
3478
+ },
2730
3479
  { test: "packages/aeg-core/src/actions.test.ts", roots: ["aeg-root/roles/"], trigger: "content" },
2731
3480
  { test: "packages/aeg-core/src/diagram-model.test.ts", roots: ["."], trigger: "content" },
2732
3481
  {
@@ -3761,7 +4510,7 @@ function reaches(start, edges, changed, maxDepth = Number.POSITIVE_INFINITY) {
3761
4510
  }
3762
4511
 
3763
4512
  // src/lib/pre-push-selection.ts
3764
- function prePushSelection(repoRoot, base = resolveRemoteBase(repoRoot)) {
4513
+ function prePushSelection(repoRoot, base = resolveRemoteBase(repoRoot), depth = "one") {
3765
4514
  const changed = changedFilesSinceRemoteBaseAbsolute(repoRoot, base);
3766
4515
  const addedOrRenamed = addedOrRenamedFilesSinceRemoteBaseAbsolute(repoRoot, base);
3767
4516
  const removed = removedFilesSinceRemoteBaseAbsolute(repoRoot, base);
@@ -3776,7 +4525,7 @@ function prePushSelection(repoRoot, base = resolveRemoteBase(repoRoot)) {
3776
4525
  removed,
3777
4526
  changedRanges,
3778
4527
  affectedNames: names,
3779
- depth: "one"
4528
+ depth
3780
4529
  });
3781
4530
  }
3782
4531