@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
@@ -467,8 +467,372 @@ var NON_PATH_TOP_SEGMENTS = new Set(["origin", "refs", "HEAD", "vinaya", "fix"])
467
467
 
468
468
  // ../../packages/aeg-core/src/doctrine-no-procedures.ts
469
469
  var SHELL_LANGS = new Set(["", "sh", "bash", "shell", "console"]);
470
+ // ../../packages/aeg-core/src/prose-rules.ts
471
+ var RETIRED_GLOBAL_EXEMPTIONS = [
472
+ "docs/decisions-legacy.md",
473
+ "apps/herald-ai/docs/",
474
+ "apps/vada-ai/docs/",
475
+ "aeg-root/tranches/completed/",
476
+ "packages/aeg-core/src/docs/published-prose",
477
+ "packages/aeg-core/src/retired-vocabulary.test.ts",
478
+ "packages/aeg-core/src/retired-vocabulary.ts",
479
+ "/fixtures/",
480
+ "/node_modules/",
481
+ "/.next/",
482
+ "/.turbo/"
483
+ ];
484
+ var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
485
+ var TRANCHE_MODEL_FILE = "/tranche-model.md";
486
+ var RETIRED_PATTERN_EXEMPTIONS = {
487
+ [String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
488
+ [String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
489
+ "docs-index.md",
490
+ "apps/vada-ai/specs/legacy/README.md",
491
+ "apps/vada-ai/specs/vada-product-spec.md",
492
+ "apps/vada-ai/web/CLAUDE.md",
493
+ "apps/vada-ai/CLAUDE.md"
494
+ ],
495
+ "decisions-legacy": [
496
+ "packages/aeg-core/src/file-classify.ts",
497
+ "packages/aeg-core/src/file-classify.test.ts",
498
+ "packages/aeg-core/src/pr-tier.test.ts",
499
+ "docs-index.md",
500
+ ".claude/skills/database/SKILL.md",
501
+ ".claude/skills/vada-architecture/SKILL.md",
502
+ "apps/vada-ai/specs/vada-byok-principles.md",
503
+ "apps/vada-ai/web/CLAUDE.md",
504
+ "apps/vada-ai/CLAUDE.md"
505
+ ],
506
+ CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
507
+ ...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
508
+ };
509
+ var retiredPatterns = [
510
+ String.raw`\bD-[0-9]{3}\b`,
511
+ "D-(###|NNN|nnn|xxx)",
512
+ "decision (entry|logged)",
513
+ "decision-log entry",
514
+ "decision log entry",
515
+ "decision log(s|ged|ging)?([^a-z]|$)",
516
+ "decision-log",
517
+ "decision entr",
518
+ "decisions? (are |is )?logged",
519
+ "log entries",
520
+ String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
521
+ "decisions-legacy",
522
+ "CONTRADICTION",
523
+ "assumes Tier 3",
524
+ "Lock: ?YES",
525
+ "Lock: ?NO",
526
+ "lock approvals?",
527
+ "approves locks",
528
+ "Conforms to lock",
529
+ "Challenges lock",
530
+ "checkDecisionNumbersFresh",
531
+ String.raw`roles/team-leader\.md`,
532
+ String.raw`\(,`,
533
+ String.raw`,\)`,
534
+ String.raw`\(\.\)`,
535
+ ...PLAN_ON_DISK_PATTERNS
536
+ ];
537
+ var published = [
538
+ ["decision-id", "a decision id", /\bD-\d{3,}\b/],
539
+ ["section-ref", "a section reference", /§/],
540
+ ["forge-number", "a forge number", /#\d+/],
541
+ ["retired-name", "the retired public name", /\bAEG\b/],
542
+ ["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
543
+ [
544
+ "label-vocabulary",
545
+ "forge label vocabulary",
546
+ /(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
547
+ ],
548
+ ["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
549
+ ["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
550
+ [
551
+ "internal-path",
552
+ "a repo-internal file",
553
+ /(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
554
+ ]
555
+ ];
556
+ var DEFAULT_PROSE_RULES = [
557
+ {
558
+ id: "forge-number",
559
+ group: "reader-resolvable",
560
+ scopes: ["ships", "reader-facing", "spec"],
561
+ patterns: { prose: /#[0-9]{2,4}/g },
562
+ flags: ["global"],
563
+ message: "a forge number",
564
+ severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
565
+ exemptions: []
566
+ },
567
+ {
568
+ id: "tranche-slug",
569
+ group: "reader-resolvable",
570
+ scopes: ["ships", "reader-facing", "product", "spec"],
571
+ patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
572
+ flags: ["global"],
573
+ message: "an internal tranche slug",
574
+ severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
575
+ exemptions: []
576
+ },
577
+ {
578
+ id: "task-number",
579
+ group: "reader-resolvable",
580
+ scopes: ["spec"],
581
+ patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
582
+ flags: ["global", "ignore-case"],
583
+ message: "a task number",
584
+ severity: { spec: "error" },
585
+ exemptions: []
586
+ },
587
+ {
588
+ id: "source-comment-tranche-slug",
589
+ group: "reader-resolvable",
590
+ scopes: ["source-comment"],
591
+ patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
592
+ flags: ["global"],
593
+ message: "a tranche-slug citation",
594
+ severity: { "source-comment": "warning" },
595
+ exemptions: []
596
+ },
597
+ {
598
+ id: "source-comment-forge-number",
599
+ group: "reader-resolvable",
600
+ scopes: ["source-comment"],
601
+ patterns: { comment: /#[0-9]{2,}/g },
602
+ flags: ["global"],
603
+ message: "a forge-number citation",
604
+ severity: { "source-comment": "warning" },
605
+ exemptions: []
606
+ },
607
+ {
608
+ id: "legacy-batch-name",
609
+ group: "reader-resolvable",
610
+ scopes: ["ships", "reader-facing", "spec"],
611
+ patterns: {},
612
+ flags: ["built-in"],
613
+ message: "an internal tranche slug",
614
+ severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
615
+ exemptions: [],
616
+ builtIn: true
617
+ },
618
+ {
619
+ id: "coined-term",
620
+ group: "reader-resolvable",
621
+ scopes: ["ships", "reader-facing"],
622
+ patterns: {},
623
+ flags: ["built-in"],
624
+ message: "uses coined term without defining it inline or linking the glossary",
625
+ severity: { ships: "warning", "reader-facing": "warning" },
626
+ exemptions: [],
627
+ builtIn: true
628
+ },
629
+ ...retiredPatterns.map((pattern, index) => ({
630
+ id: `retired-vocabulary-${index + 1}`,
631
+ group: "retired-vocabulary",
632
+ scopes: ["repository"],
633
+ patterns: { repository: pattern },
634
+ flags: [],
635
+ message: "retired vocabulary",
636
+ severity: { repository: "error" },
637
+ exemptions: RETIRED_GLOBAL_EXEMPTIONS,
638
+ patternExemptions: RETIRED_PATTERN_EXEMPTIONS
639
+ })),
640
+ ...published.map(([id, message, pattern]) => ({
641
+ id,
642
+ group: "published-prose",
643
+ scopes: ["published"],
644
+ patterns: { published: pattern },
645
+ flags: [],
646
+ message,
647
+ severity: { published: "error" },
648
+ exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
649
+ }))
650
+ ];
651
+ var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
652
+ var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
653
+ var RETIRED_SCOPES = ["repository"];
654
+ var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
655
+ function groupOfScope(scope) {
656
+ if (RESOLVABLE_SCOPES.includes(scope))
657
+ return "reader-resolvable";
658
+ if (RETIRED_SCOPES.includes(scope))
659
+ return "retired-vocabulary";
660
+ return;
661
+ }
662
+ var CONFIGURED_PROSE_FLAGS = ["i", "u"];
663
+ var CONFIGURED_PATTERN_MAX_LENGTH = 200;
664
+ var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
665
+ function allowedScopesFor(rule) {
666
+ if (rule.builtIn)
667
+ return rule.scopes;
668
+ return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
669
+ }
670
+ function normalizeRepoPath(entry) {
671
+ let out = entry.replace(/\\/g, "/");
672
+ while (out.startsWith("./"))
673
+ out = out.slice(2);
674
+ out = out.replace(/\/{2,}/g, "/");
675
+ while (out.endsWith("/"))
676
+ out = out.slice(0, -1);
677
+ return out;
678
+ }
679
+ var RESOLVABLE_RUN_ORDER = [
680
+ "forge-number",
681
+ "tranche-slug",
682
+ "legacy-batch-name",
683
+ "task-number",
684
+ "source-comment-tranche-slug",
685
+ "source-comment-forge-number",
686
+ "coined-term"
687
+ ];
688
+ var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
689
+ function scopeDefaultSeverity(scope, sourceCommentSeverity) {
690
+ if (scope === "source-comment")
691
+ return sourceCommentSeverity ?? "warning";
692
+ if (scope === "repository")
693
+ return "error";
694
+ return "warning";
695
+ }
696
+ function applySeverity(scopes, base, setting) {
697
+ const out = {};
698
+ for (const scope of scopes) {
699
+ const configured = typeof setting === "string" ? setting : setting?.[scope];
700
+ const value = configured ?? base[scope];
701
+ if (value !== undefined)
702
+ out[scope] = value;
703
+ }
704
+ return out;
705
+ }
706
+ function defaultPatternFor(rule) {
707
+ const cache = new Map;
708
+ return (scope) => {
709
+ if (cache.has(scope))
710
+ return cache.get(scope) ?? null;
711
+ const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
712
+ const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
713
+ cache.set(scope, compiled);
714
+ return compiled;
715
+ };
716
+ }
717
+ function customPatternFor(rule, global) {
718
+ const cache = new Map;
719
+ return (scope) => {
720
+ if (cache.has(scope))
721
+ return cache.get(scope) ?? null;
722
+ const source = rule.patterns?.[scope] ?? rule.pattern;
723
+ const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
724
+ cache.set(scope, compiled);
725
+ return compiled;
726
+ };
727
+ }
728
+ function resolveProseRules(config = undefined, options = {}) {
729
+ const rules = [];
730
+ const defaults = config?.defaults ?? {};
731
+ for (const rule of CONFIGURABLE_DEFAULT_RULES) {
732
+ const override = defaults[rule.id];
733
+ if (override === "off")
734
+ continue;
735
+ const group = rule.group;
736
+ const scopes = override?.scopes ?? rule.scopes;
737
+ const base = {};
738
+ for (const scope of scopes) {
739
+ base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
740
+ }
741
+ rules.push({
742
+ id: rule.id,
743
+ group,
744
+ custom: false,
745
+ builtIn: rule.builtIn === true,
746
+ scopes,
747
+ message: rule.message,
748
+ severity: applySeverity(scopes, base, override?.severity),
749
+ exempt: override?.exempt ?? [],
750
+ substringExempt: rule.exemptions,
751
+ reportGroup: REPORT_GROUPS[rule.id],
752
+ patternFor: defaultPatternFor(rule)
753
+ });
754
+ }
755
+ for (const rule of config?.custom ?? []) {
756
+ const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
757
+ const base = {};
758
+ for (const scope of rule.scopes)
759
+ base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
760
+ rules.push({
761
+ id: rule.id,
762
+ group,
763
+ custom: true,
764
+ builtIn: false,
765
+ scopes: rule.scopes,
766
+ message: rule.means,
767
+ severity: applySeverity(rule.scopes, base, rule.severity),
768
+ exempt: rule.exempt ?? [],
769
+ substringExempt: [],
770
+ patternFor: customPatternFor(rule, group === "reader-resolvable")
771
+ });
772
+ }
773
+ if (options.decisionRecordsPath !== undefined)
774
+ rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
775
+ const order = (rule) => {
776
+ const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
777
+ return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
778
+ };
779
+ const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
780
+ const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
781
+ return {
782
+ rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
783
+ exempt: config?.exempt ?? [],
784
+ repoRoot: options.repoRoot
785
+ };
786
+ }
787
+ var DEFAULT_PROSE_RULE_SET = resolveProseRules();
788
+ var DECISION_RECORD_CITATION_ID = "decision-record-citation";
789
+ var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
790
+ var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
791
+ function escapeRegExp(text) {
792
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
793
+ }
794
+ function decisionRecordCitationPattern(decisionRecordsPath) {
795
+ const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
796
+ return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
797
+ }
798
+ function decisionRecordCitationRule(decisionRecordsPath) {
799
+ const folder = normalizeRepoPath(decisionRecordsPath);
800
+ const pattern = decisionRecordCitationPattern(folder);
801
+ const severity = {};
802
+ for (const scope of DECISION_RECORD_CITATION_SCOPES)
803
+ severity[scope] = "error";
804
+ return {
805
+ id: DECISION_RECORD_CITATION_ID,
806
+ group: "reader-resolvable",
807
+ custom: false,
808
+ builtIn: false,
809
+ scopes: DECISION_RECORD_CITATION_SCOPES,
810
+ message: DECISION_RECORD_CITATION_MESSAGE,
811
+ severity,
812
+ exempt: [folder],
813
+ substringExempt: [],
814
+ patternFor: () => pattern
815
+ };
816
+ }
817
+
470
818
  // ../../packages/aeg-core/src/reader-resolvable-prose.ts
819
+ function normalizeSpecPath(entry) {
820
+ return normalizeRepoPath(entry);
821
+ }
471
822
  var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
823
+ var readerRules = rulesForGroup("reader-resolvable");
824
+ var readerPattern = (id, scope = "prose") => {
825
+ const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
826
+ if (!(pattern instanceof RegExp))
827
+ throw new Error(`default prose rule ${id} has no ${scope} pattern`);
828
+ return pattern;
829
+ };
830
+ var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
831
+ var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
832
+ var TASK_NUMBER_PATTERN = readerPattern("task-number");
833
+ var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
834
+ var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
835
+ var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
472
836
 
473
837
  // ../../packages/aeg-core/src/quoted-command.ts
474
838
  var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
@@ -512,59 +876,9 @@ var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
512
876
  // ../../packages/aeg-core/src/diagram-model.ts
513
877
  import matter from "gray-matter";
514
878
  // ../../packages/aeg-core/src/retired-vocabulary.ts
515
- var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
516
- var RETIRED_PATTERNS = [
517
- String.raw`\bD-[0-9]{3}\b`,
518
- "D-(###|NNN|nnn|xxx)",
519
- "decision (entry|logged)",
520
- "decision-log entry",
521
- "decision log entry",
522
- "decision log(s|ged|ging)?([^a-z]|$)",
523
- "decision-log",
524
- "decision entr",
525
- "decisions? (are |is )?logged",
526
- "log entries",
527
- String.raw`decisions\.md`,
528
- "decisions-legacy",
529
- "CONTRADICTION",
530
- "assumes Tier 3",
531
- "Lock: ?YES",
532
- "Lock: ?NO",
533
- "lock approvals?",
534
- "approves locks",
535
- "Conforms to lock",
536
- "Challenges lock",
537
- "checkDecisionNumbersFresh",
538
- String.raw`roles/team-leader\.md`,
539
- String.raw`\(,`,
540
- String.raw`,\)`,
541
- String.raw`\(\.\)`,
542
- ...PLAN_ON_DISK_PATTERNS
543
- ];
544
- var TRANCHE_MODEL_FILE = "/tranche-model.md";
545
- var PATTERN_EXEMPT = {
546
- [String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
547
- [String.raw`decisions\.md`]: [
548
- "docs-index.md",
549
- "apps/vada-ai/specs/legacy/README.md",
550
- "apps/vada-ai/specs/vada-product-spec.md",
551
- "apps/vada-ai/web/CLAUDE.md",
552
- "apps/vada-ai/CLAUDE.md"
553
- ],
554
- "decisions-legacy": [
555
- "packages/aeg-core/src/file-classify.ts",
556
- "packages/aeg-core/src/file-classify.test.ts",
557
- "packages/aeg-core/src/pr-tier.test.ts",
558
- "docs-index.md",
559
- ".claude/skills/database/SKILL.md",
560
- ".claude/skills/vada-architecture/SKILL.md",
561
- "apps/vada-ai/specs/vada-byok-principles.md",
562
- "apps/vada-ai/web/CLAUDE.md",
563
- "apps/vada-ai/CLAUDE.md"
564
- ],
565
- CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
566
- ...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
567
- };
879
+ var retiredRules = rulesForGroup("retired-vocabulary");
880
+ var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
881
+ var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
568
882
  // ../../packages/aeg-core/src/task-tools.ts
569
883
  import { z } from "zod";
570
884
  var TASK_TOOL_ERROR_KINDS = [
@@ -833,9 +1147,11 @@ var LineageSchema = z3.object({
833
1147
  parent: z3.string().nullable()
834
1148
  }).strict();
835
1149
  var InputVersionsSchema = z3.object({
1150
+ manifest_version: z3.literal(2).nullable().optional(),
836
1151
  objectives_version: z3.string().nullable(),
837
1152
  brief_hash: z3.string().nullable(),
838
1153
  ruling_ordinal: z3.number().int().nullable(),
1154
+ pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
839
1155
  policy_digest: z3.string().nullable()
840
1156
  }).strict();
841
1157
  var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
@@ -1383,17 +1699,19 @@ function buildHeader(input) {
1383
1699
  parent: lineageFieldFromEnv(input.env.parent)
1384
1700
  },
1385
1701
  input_versions: {
1702
+ manifest_version: input.inputVersions?.manifestVersion ?? null,
1386
1703
  objectives_version: input.inputVersions?.objectivesVersion ?? null,
1387
1704
  brief_hash: input.inputVersions?.briefHash ?? null,
1388
1705
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
1706
+ pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
1389
1707
  policy_digest: input.inputVersions?.policyDigest ?? null
1390
1708
  },
1391
1709
  provenance: provenanceFor(input),
1392
1710
  work: {
1393
1711
  ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
1394
1712
  repo: input.repo,
1395
- change: null,
1396
- revision: null
1713
+ change: pr === undefined ? null : String(pr),
1714
+ revision: input.revision ?? null
1397
1715
  },
1398
1716
  flow: {
1399
1717
  id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
@@ -1581,6 +1899,12 @@ var ManifestRecordSchema = z4.object({
1581
1899
  briefHash: z4.string().min(1).nullable(),
1582
1900
  objectivesVersion: z4.string().min(1).nullable(),
1583
1901
  rulingOrdinal: epochNumber,
1902
+ manifestVersion: z4.literal(2).optional(),
1903
+ pauseBoundRuling: z4.object({
1904
+ rulingId: z4.string().min(1),
1905
+ pauseId: z4.string().min(1),
1906
+ contentDigest: z4.string().min(1)
1907
+ }).strict().nullable().optional(),
1584
1908
  policyDigest: z4.string().min(1),
1585
1909
  recordedAt: isoTimestamp
1586
1910
  }).strict();
@@ -1602,7 +1926,11 @@ var LoopStateRecordSchema = z4.object({
1602
1926
  deliveredFindings: roundHeadIdentity.nullable(),
1603
1927
  repeatMemory: z4.object({
1604
1928
  blockingFindings: z4.array(z4.string()),
1605
- lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
1929
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
1930
+ }).strict().optional(),
1931
+ developerHandoff: z4.object({
1932
+ findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
1933
+ failingChecks: z4.array(z4.string().min(1))
1606
1934
  }).strict().optional(),
1607
1935
  publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
1608
1936
  taskStartedAt: isoTimestamp.optional(),
@@ -1678,10 +2006,10 @@ import { dirname, join, resolve, sep } from "node:path";
1678
2006
  function isErrnoException(err, code) {
1679
2007
  return typeof err === "object" && err !== null && err.code === code;
1680
2008
  }
1681
- function isTrustedDirStat(stat, ownUid) {
2009
+ function isTrustedDirStat(stat, ownUid, trustedOverflowUid) {
1682
2010
  if (typeof ownUid !== "number")
1683
2011
  return true;
1684
- if (stat.uid !== ownUid && stat.uid !== 0)
2012
+ if (stat.uid !== ownUid && stat.uid !== 0 && stat.uid !== trustedOverflowUid)
1685
2013
  return false;
1686
2014
  const worldWritable = (stat.mode & 2) !== 0;
1687
2015
  const sticky = (stat.mode & 512) !== 0;
@@ -1690,15 +2018,54 @@ function isTrustedDirStat(stat, ownUid) {
1690
2018
  function currentUid() {
1691
2019
  return typeof process.getuid === "function" ? process.getuid() : undefined;
1692
2020
  }
2021
+ function uidMapLeavesRootUnmapped(uidMap) {
2022
+ const lines = uidMap.split(`
2023
+ `).map((line) => line.trim()).filter((line) => line.length > 0);
2024
+ if (lines.length === 0)
2025
+ return false;
2026
+ for (const line of lines) {
2027
+ const fields = line.split(/\s+/);
2028
+ if (fields.length !== 3 || !fields.every((field) => /^\d+$/.test(field)))
2029
+ return false;
2030
+ const inside = Number(fields[0]);
2031
+ const count = Number(fields[2]);
2032
+ if (inside === 0 && count > 0)
2033
+ return false;
2034
+ }
2035
+ return true;
2036
+ }
2037
+ function readTrustedOverflowUid(readFile) {
2038
+ try {
2039
+ if (!uidMapLeavesRootUnmapped(readFile("/proc/self/uid_map")))
2040
+ return;
2041
+ const overflow = readFile("/proc/sys/kernel/overflowuid").trim();
2042
+ return /^\d+$/.test(overflow) ? Number(overflow) : undefined;
2043
+ } catch {
2044
+ return;
2045
+ }
2046
+ }
2047
+ var cachedTrustedOverflowUid;
2048
+ function processTrustedOverflowUid() {
2049
+ cachedTrustedOverflowUid ??= { value: readTrustedOverflowUid((path) => readFileSync2(path, "utf8")) };
2050
+ return cachedTrustedOverflowUid.value;
2051
+ }
2052
+ function isAtOrBelowTrustedRoot(index, rootSegmentCount) {
2053
+ return index >= rootSegmentCount - 1;
2054
+ }
2055
+ function segmentTrustedOverflowUid(index, rootSegmentCount, trustedOverflowUid) {
2056
+ return isAtOrBelowTrustedRoot(index, rootSegmentCount) ? undefined : trustedOverflowUid;
2057
+ }
1693
2058
  function mkdirNoSymlinks(dir, mode, trustedRoot) {
1694
2059
  const absolute = resolve(dir);
1695
2060
  const rootSegments = resolve(trustedRoot).split(sep).filter((s) => s.length > 0);
1696
2061
  const segments = absolute.split(sep).filter((s) => s.length > 0);
1697
2062
  const ownUid = currentUid();
2063
+ const trustedOverflowUid = typeof ownUid === "number" ? processTrustedOverflowUid() : undefined;
1698
2064
  let current = absolute.startsWith(sep) ? sep : "";
1699
2065
  segments.forEach((segment, index) => {
1700
2066
  current = current === "" || current === sep ? `${current}${segment}` : `${current}${sep}${segment}`;
1701
- const atOrBelowTrustedRoot = index >= rootSegments.length - 1;
2067
+ const atOrBelowTrustedRoot = isAtOrBelowTrustedRoot(index, rootSegments.length);
2068
+ const overflowUid = segmentTrustedOverflowUid(index, rootSegments.length, trustedOverflowUid);
1702
2069
  try {
1703
2070
  mkdirSync(current, { mode });
1704
2071
  } catch (err) {
@@ -1719,7 +2086,7 @@ function mkdirNoSymlinks(dir, mode, trustedRoot) {
1719
2086
  if (!real.isDirectory()) {
1720
2087
  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`);
1721
2088
  }
1722
- if (!isTrustedDirStat(real, ownUid)) {
2089
+ if (!isTrustedDirStat(real, ownUid, overflowUid)) {
1723
2090
  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`);
1724
2091
  }
1725
2092
  return;
@@ -1727,7 +2094,7 @@ function mkdirNoSymlinks(dir, mode, trustedRoot) {
1727
2094
  if (!stat.isDirectory()) {
1728
2095
  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)`);
1729
2096
  }
1730
- if (!isTrustedDirStat(stat, ownUid)) {
2097
+ if (!isTrustedDirStat(stat, ownUid, overflowUid)) {
1731
2098
  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`);
1732
2099
  }
1733
2100
  });
@@ -1771,6 +2138,7 @@ var REGISTRY = [
1771
2138
  {
1772
2139
  name: "brief-shape",
1773
2140
  validates: "body",
2141
+ requiresOpenPr: true,
1774
2142
  run: bin("check-brief-shape"),
1775
2143
  scope: "diff",
1776
2144
  timeoutMs: 15000,
@@ -1779,7 +2147,9 @@ var REGISTRY = [
1779
2147
  BRANCH: { optional: true },
1780
2148
  PR_NUMBER: { optional: true },
1781
2149
  GITHUB_TOKEN: { optional: true },
1782
- GH_TOKEN: { optional: true }
2150
+ GH_TOKEN: { optional: true },
2151
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
2152
+ GITHUB_ACTIONS: { optional: true }
1783
2153
  }
1784
2154
  },
1785
2155
  0
@@ -1788,6 +2158,7 @@ var REGISTRY = [
1788
2158
  {
1789
2159
  name: "pr-report-density",
1790
2160
  validates: "body",
2161
+ requiresOpenPr: true,
1791
2162
  run: bin("check-pr-report-density"),
1792
2163
  scope: "diff",
1793
2164
  timeoutMs: 15000,
@@ -1813,7 +2184,9 @@ var REGISTRY = [
1813
2184
  PR_NUMBER: { optional: true },
1814
2185
  GITHUB_REPOSITORY: { optional: true },
1815
2186
  GITHUB_TOKEN: { optional: true },
1816
- GH_TOKEN: { optional: true }
2187
+ GH_TOKEN: { optional: true },
2188
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
2189
+ GITHUB_ACTIONS: { optional: true }
1817
2190
  }
1818
2191
  },
1819
2192
  0
@@ -1837,6 +2210,7 @@ var REGISTRY = [
1837
2210
  {
1838
2211
  name: "pr-premise-reassert",
1839
2212
  validates: "body",
2213
+ requiresOpenPr: true,
1840
2214
  run: bin("check-pr-premise-reassert"),
1841
2215
  scope: "diff",
1842
2216
  timeoutMs: 15000,
@@ -1857,7 +2231,9 @@ var REGISTRY = [
1857
2231
  BRANCH: { optional: true },
1858
2232
  GITHUB_TOKEN: { optional: true },
1859
2233
  GH_TOKEN: { optional: true },
1860
- PREMISE_FILE: { optional: true }
2234
+ PREMISE_FILE: { optional: true },
2235
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
2236
+ GITHUB_ACTIONS: { optional: true }
1861
2237
  }
1862
2238
  },
1863
2239
  0
@@ -1909,7 +2285,9 @@ var REGISTRY = [
1909
2285
  PR_BODY: { optional: true },
1910
2286
  PR_BODY_FILE: { optional: true },
1911
2287
  GITHUB_TOKEN: { optional: true },
1912
- GH_TOKEN: { optional: true }
2288
+ GH_TOKEN: { optional: true },
2289
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
2290
+ GITHUB_ACTIONS: { optional: true }
1913
2291
  }
1914
2292
  },
1915
2293
  1
@@ -1925,7 +2303,13 @@ var REGISTRY = [
1925
2303
  principalOwed: true,
1926
2304
  env: {
1927
2305
  PR_BODY: { optional: true },
1928
- BRANCH: { optional: true }
2306
+ BRANCH: { optional: true },
2307
+ PULL_REQUEST_HEAD_SHA: { optional: true },
2308
+ GITHUB_REPOSITORY: { optional: true },
2309
+ GITHUB_TOKEN: { optional: true },
2310
+ GH_TOKEN: { optional: true },
2311
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
2312
+ GITHUB_ACTIONS: { optional: true }
1929
2313
  }
1930
2314
  },
1931
2315
  1
@@ -1941,7 +2325,13 @@ var REGISTRY = [
1941
2325
  ownWorkflow: true,
1942
2326
  env: {
1943
2327
  PR_BODY: { optional: true },
1944
- BRANCH: { optional: true }
2328
+ BRANCH: { optional: true },
2329
+ PULL_REQUEST_HEAD_SHA: { optional: true },
2330
+ GITHUB_REPOSITORY: { optional: true },
2331
+ GITHUB_TOKEN: { optional: true },
2332
+ GH_TOKEN: { optional: true },
2333
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
2334
+ GITHUB_ACTIONS: { optional: true }
1945
2335
  }
1946
2336
  },
1947
2337
  1
@@ -1960,7 +2350,9 @@ var REGISTRY = [
1960
2350
  PR_NUMBER: { optional: true },
1961
2351
  GITHUB_REPOSITORY: { optional: true },
1962
2352
  GITHUB_TOKEN: { optional: true },
1963
- GH_TOKEN: { optional: true }
2353
+ GH_TOKEN: { optional: true },
2354
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
2355
+ GITHUB_ACTIONS: { optional: true }
1964
2356
  }
1965
2357
  },
1966
2358
  1
@@ -2000,7 +2392,9 @@ var REGISTRY = [
2000
2392
  PR_NUMBER: { optional: true },
2001
2393
  GITHUB_REPOSITORY: { optional: true },
2002
2394
  GITHUB_TOKEN: { optional: true },
2003
- GH_TOKEN: { optional: true }
2395
+ GH_TOKEN: { optional: true },
2396
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
2397
+ GITHUB_ACTIONS: { optional: true }
2004
2398
  }
2005
2399
  },
2006
2400
  1
@@ -2053,12 +2447,15 @@ var REGISTRY = [
2053
2447
  {
2054
2448
  name: "doc-coverage-push",
2055
2449
  validates: "body",
2450
+ advisory: true,
2056
2451
  run: bin("check-doc-coverage-push"),
2057
2452
  scope: "diff",
2058
2453
  timeoutMs: 15000,
2059
2454
  env: {
2060
2455
  OVERRIDE_DOCS: { optional: true },
2061
2456
  BASE_SHA: { optional: true },
2457
+ GIT_INDEX_FILE: { optional: true },
2458
+ VINAYA_COMMIT_HOOK: { optional: true },
2062
2459
  PR_BODY: { optional: true },
2063
2460
  PR_BODY_FILE: { optional: true },
2064
2461
  PR_LABELS: { optional: true },
@@ -2070,21 +2467,6 @@ var REGISTRY = [
2070
2467
  },
2071
2468
  0
2072
2469
  ],
2073
- [
2074
- {
2075
- name: "issue-assignment",
2076
- run: bin("check-issue-assignment"),
2077
- scope: "full",
2078
- timeoutMs: 30000,
2079
- env: {
2080
- AEG_REPO: { optional: true },
2081
- BRANCH: { optional: true },
2082
- GITHUB_TOKEN: { optional: true },
2083
- GH_TOKEN: { optional: true }
2084
- }
2085
- },
2086
- 0
2087
- ],
2088
2470
  [
2089
2471
  {
2090
2472
  name: "evidence-fresh",
@@ -2098,7 +2480,9 @@ var REGISTRY = [
2098
2480
  PR_BODY: { optional: true },
2099
2481
  BASE_SHA: { optional: true },
2100
2482
  GITHUB_TOKEN: { optional: true },
2101
- GH_TOKEN: { optional: true }
2483
+ GH_TOKEN: { optional: true },
2484
+ VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
2485
+ GITHUB_ACTIONS: { optional: true }
2102
2486
  }
2103
2487
  },
2104
2488
  1
@@ -2109,7 +2493,11 @@ var REGISTRY = [
2109
2493
  run: bin("check-reader-resolvable-prose"),
2110
2494
  scope: "full",
2111
2495
  timeoutMs: 30000,
2112
- env: {},
2496
+ env: {
2497
+ BASE_SHA: { optional: true },
2498
+ GIT_INDEX_FILE: { optional: true },
2499
+ VINAYA_COMMIT_HOOK: { optional: true }
2500
+ },
2113
2501
  include: [
2114
2502
  "aeg-root/**/*.md",
2115
2503
  "apps/cli/src/**",
@@ -2127,7 +2515,11 @@ var REGISTRY = [
2127
2515
  run: bin("check-retired-vocabulary"),
2128
2516
  scope: "full",
2129
2517
  timeoutMs: 30000,
2130
- env: {},
2518
+ env: {
2519
+ BASE_SHA: { optional: true },
2520
+ GIT_INDEX_FILE: { optional: true },
2521
+ VINAYA_COMMIT_HOOK: { optional: true }
2522
+ },
2131
2523
  include: ["aeg-root/**/*.md"]
2132
2524
  },
2133
2525
  0
@@ -2135,10 +2527,15 @@ var REGISTRY = [
2135
2527
  [
2136
2528
  {
2137
2529
  name: "doctrine-portability",
2530
+ advisory: true,
2138
2531
  run: bin("check-doctrine-portability"),
2139
2532
  scope: "full",
2140
2533
  timeoutMs: 30000,
2141
- env: { BASE_SHA: { optional: true } },
2534
+ env: {
2535
+ BASE_SHA: { optional: true },
2536
+ GIT_INDEX_FILE: { optional: true },
2537
+ VINAYA_COMMIT_HOOK: { optional: true }
2538
+ },
2142
2539
  include: ["aeg-root/**/*.md"]
2143
2540
  },
2144
2541
  0
@@ -2171,7 +2568,11 @@ var REGISTRY = [
2171
2568
  run: bin("check-exec-bits"),
2172
2569
  scope: "diff",
2173
2570
  timeoutMs: 30000,
2174
- env: {}
2571
+ env: {
2572
+ BASE_SHA: { optional: true },
2573
+ GIT_INDEX_FILE: { optional: true },
2574
+ VINAYA_COMMIT_HOOK: { optional: true }
2575
+ }
2175
2576
  },
2176
2577
  0
2177
2578
  ],
@@ -2181,17 +2582,26 @@ var REGISTRY = [
2181
2582
  run: bin("check-ci-shard-coverage"),
2182
2583
  scope: "diff",
2183
2584
  timeoutMs: 15000,
2184
- env: {}
2585
+ env: {
2586
+ BASE_SHA: { optional: true },
2587
+ GIT_INDEX_FILE: { optional: true },
2588
+ VINAYA_COMMIT_HOOK: { optional: true }
2589
+ }
2185
2590
  },
2186
2591
  0
2187
2592
  ],
2188
2593
  [
2189
2594
  {
2190
2595
  name: "workspace-escape",
2596
+ advisory: true,
2191
2597
  run: bin("check-workspace-escape"),
2192
2598
  scope: "full",
2193
2599
  timeoutMs: 30000,
2194
- env: {},
2600
+ env: {
2601
+ BASE_SHA: { optional: true },
2602
+ GIT_INDEX_FILE: { optional: true },
2603
+ VINAYA_COMMIT_HOOK: { optional: true }
2604
+ },
2195
2605
  include: ["aeg-root/**/*.md"]
2196
2606
  },
2197
2607
  0
@@ -2202,17 +2612,23 @@ var REGISTRY = [
2202
2612
  run: bin("check-changeset-coverage"),
2203
2613
  scope: "diff",
2204
2614
  timeoutMs: 15000,
2205
- env: {}
2615
+ env: {
2616
+ BASE_SHA: { optional: true },
2617
+ GIT_INDEX_FILE: { optional: true },
2618
+ VINAYA_COMMIT_HOOK: { optional: true }
2619
+ }
2206
2620
  },
2207
2621
  0
2208
2622
  ],
2209
2623
  [
2210
2624
  {
2211
2625
  name: "quoted-command",
2626
+ advisory: true,
2212
2627
  run: bin("check-quoted-command"),
2213
- scope: "diff",
2628
+ scope: "full",
2214
2629
  timeoutMs: 15000,
2215
- env: {}
2630
+ env: {},
2631
+ include: ["aeg-root/**/*.md"]
2216
2632
  },
2217
2633
  0
2218
2634
  ],
@@ -2220,7 +2636,7 @@ var REGISTRY = [
2220
2636
  {
2221
2637
  name: "main-branch-refusal",
2222
2638
  run: bin("check-main-branch-refusal"),
2223
- scope: "full",
2639
+ scope: "diff",
2224
2640
  timeoutMs: 15000,
2225
2641
  env: { VINAYA_PUSH_REFS: { optional: true } }
2226
2642
  },
@@ -2287,18 +2703,6 @@ var REGISTRY = [
2287
2703
  },
2288
2704
  1
2289
2705
  ],
2290
- [
2291
- {
2292
- name: "issue-tranche-label",
2293
- run: bin("check-issue-tranche-label"),
2294
- validates: "issue",
2295
- scope: "full",
2296
- ownWorkflow: true,
2297
- timeoutMs: 15000,
2298
- env: { ISSUE_BODY: { optional: true }, ISSUE_LABELS: { optional: true } }
2299
- },
2300
- 1
2301
- ],
2302
2706
  [
2303
2707
  {
2304
2708
  name: "issue-milestone-attach",
@@ -2348,29 +2752,320 @@ import { promisify as promisify4 } from "node:util";
2348
2752
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
2349
2753
  import { homedir } from "node:os";
2350
2754
  import { dirname as dirname3, isAbsolute, join as join4, resolve as resolve2 } from "node:path";
2351
- import { z as z5 } from "zod";
2755
+ import { z as z6 } from "zod";
2756
+
2757
+ // src/checks/contract.ts
2758
+ var CHECK_SCHEMA_VERSION = 1;
2759
+ function emitCheckError(error) {
2760
+ process.stderr.write(`${JSON.stringify(error)}
2761
+ `);
2762
+ }
2352
2763
 
2353
2764
  // src/lib/agent-vendors.ts
2354
2765
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
2355
2766
 
2767
+ // src/lib/prose-rules-config.ts
2768
+ import safeRegex from "safe-regex2";
2769
+ import { z as z5 } from "zod";
2770
+ var SEVERITIES = ["error", "warning"];
2771
+ var OVERRIDE_KEYS = ["scopes", "severity", "exempt"];
2772
+ var FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
2773
+ var CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
2774
+ var DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
2775
+ function isPlainObject(value) {
2776
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2777
+ }
2778
+ function outsideRepositoryReason(entry) {
2779
+ if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
2780
+ return "must be a repository-relative path, not an absolute one";
2781
+ if (entry.split(/[\\/]/).includes(".."))
2782
+ return "must stay inside the repository — no `..` segment";
2783
+ return null;
2784
+ }
2785
+ var RepoRelativePathSchema = z5.string().min(1).superRefine((entry, ctx) => {
2786
+ const reason = outsideRepositoryReason(entry);
2787
+ if (reason)
2788
+ ctx.addIssue({ code: z5.ZodIssueCode.custom, message: reason });
2789
+ });
2790
+ function pathListIssues(value, path, issues) {
2791
+ if (!Array.isArray(value)) {
2792
+ issues.push({ path, message: "must be a list of repository-relative paths" });
2793
+ return;
2794
+ }
2795
+ value.forEach((entry, index) => {
2796
+ if (typeof entry !== "string" || entry.length === 0) {
2797
+ issues.push({ path: [...path, index], message: "must be a non-empty repository-relative path" });
2798
+ return;
2799
+ }
2800
+ const reason = outsideRepositoryReason(entry);
2801
+ if (reason)
2802
+ issues.push({ path: [...path, index], message: reason });
2803
+ });
2804
+ }
2805
+ function scopeListIssues(value, path, allowed, issues) {
2806
+ if (!Array.isArray(value) || value.length === 0) {
2807
+ issues.push({ path, message: "must name at least one scope" });
2808
+ return null;
2809
+ }
2810
+ const scopes = [];
2811
+ value.forEach((scope, index) => {
2812
+ if (typeof scope !== "string" || !CONFIGURABLE_PROSE_SCOPES.includes(scope)) {
2813
+ issues.push({
2814
+ path: [...path, index],
2815
+ 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(", ")}`
2816
+ });
2817
+ return;
2818
+ }
2819
+ if (!allowed.includes(scope)) {
2820
+ issues.push({
2821
+ path: [...path, index],
2822
+ message: `scope "${scope}" is not one this rule can run in — it can run in: ${allowed.join(", ")}`
2823
+ });
2824
+ return;
2825
+ }
2826
+ scopes.push(scope);
2827
+ });
2828
+ return scopes;
2829
+ }
2830
+ function severityIssues(value, path, scopes, issues) {
2831
+ if (typeof value === "string") {
2832
+ if (!SEVERITIES.includes(value)) {
2833
+ issues.push({ path, message: `unknown severity ${JSON.stringify(value)} — use "error" or "warning"` });
2834
+ }
2835
+ return;
2836
+ }
2837
+ if (!isPlainObject(value)) {
2838
+ issues.push({ path, message: 'must be "error", "warning", or a map from scope to one of them' });
2839
+ return;
2840
+ }
2841
+ for (const [scope, severity] of Object.entries(value)) {
2842
+ if (!scopes.includes(scope)) {
2843
+ issues.push({ path: [...path, scope], message: `names scope "${scope}", which this rule's scopes do not cover` });
2844
+ }
2845
+ if (typeof severity !== "string" || !SEVERITIES.includes(severity)) {
2846
+ issues.push({
2847
+ path: [...path, scope],
2848
+ message: `unknown severity ${JSON.stringify(severity)} — use "error" or "warning"`
2849
+ });
2850
+ }
2851
+ }
2852
+ }
2853
+ function patternIssues(source, flags, path, issues) {
2854
+ if (typeof source !== "string" || source.length === 0) {
2855
+ issues.push({ path, message: "must be a non-empty regular expression" });
2856
+ return;
2857
+ }
2858
+ if (source.length > CONFIGURED_PATTERN_MAX_LENGTH) {
2859
+ issues.push({
2860
+ path,
2861
+ message: `is ${source.length} characters, over the ${CONFIGURED_PATTERN_MAX_LENGTH}-character limit for a configured pattern`
2862
+ });
2863
+ return;
2864
+ }
2865
+ try {
2866
+ new RegExp(source, flags);
2867
+ } catch (err) {
2868
+ issues.push({ path, message: `does not compile: ${err.message}` });
2869
+ return;
2870
+ }
2871
+ if (!safeRegex(source, { limit: Number.MAX_SAFE_INTEGER })) {
2872
+ issues.push({
2873
+ path,
2874
+ 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."
2875
+ });
2876
+ }
2877
+ }
2878
+ function flagIssues(value, path, issues) {
2879
+ if (value === undefined)
2880
+ return "";
2881
+ if (typeof value !== "string") {
2882
+ issues.push({ path, message: 'must be a string of flags, e.g. "i"' });
2883
+ return "";
2884
+ }
2885
+ const seen = new Set;
2886
+ for (const flag of value) {
2887
+ if (!CONFIGURED_PROSE_FLAGS.includes(flag)) {
2888
+ issues.push({
2889
+ path,
2890
+ message: `unknown flag ${JSON.stringify(flag)} — only ${CONFIGURED_PROSE_FLAGS.map((f) => `"${f}"`).join(" and ")} are allowed`
2891
+ });
2892
+ return "";
2893
+ }
2894
+ if (seen.has(flag)) {
2895
+ issues.push({ path, message: `repeats the flag "${flag}"` });
2896
+ return "";
2897
+ }
2898
+ seen.add(flag);
2899
+ }
2900
+ return value;
2901
+ }
2902
+ function defaultsIssues(value, issues) {
2903
+ const base = ["defaults"];
2904
+ if (!isPlainObject(value)) {
2905
+ issues.push({ path: base, message: 'must map a default rule id to "off" or an override' });
2906
+ return;
2907
+ }
2908
+ for (const [id, override] of Object.entries(value)) {
2909
+ const path = [...base, id];
2910
+ const rule = CONFIGURABLE_DEFAULT_RULES.find((candidate) => candidate.id === id);
2911
+ if (!rule) {
2912
+ issues.push({
2913
+ path,
2914
+ message: `unknown default rule id "${id}" — \`vinaya check --plan\` lists the rules each prose check runs`
2915
+ });
2916
+ continue;
2917
+ }
2918
+ if (override === "off")
2919
+ continue;
2920
+ if (!isPlainObject(override)) {
2921
+ issues.push({ path, message: 'must be "off" or an object with any of scopes, severity, exempt' });
2922
+ continue;
2923
+ }
2924
+ for (const key of Object.keys(override)) {
2925
+ if (OVERRIDE_KEYS.includes(key))
2926
+ continue;
2927
+ issues.push({
2928
+ path: [...path, key],
2929
+ 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`
2930
+ });
2931
+ }
2932
+ const scopes = override.scopes === undefined ? [...rule.scopes] : scopeListIssues(override.scopes, [...path, "scopes"], allowedScopesFor(rule), issues);
2933
+ if (override.severity !== undefined && scopes)
2934
+ severityIssues(override.severity, [...path, "severity"], scopes, issues);
2935
+ if (override.exempt !== undefined)
2936
+ pathListIssues(override.exempt, [...path, "exempt"], issues);
2937
+ }
2938
+ }
2939
+ function customIssues(value, issues) {
2940
+ if (!Array.isArray(value)) {
2941
+ issues.push({ path: ["custom"], message: "must be a list of rules" });
2942
+ return;
2943
+ }
2944
+ const ids = new Set;
2945
+ value.forEach((rule, index) => {
2946
+ const path = ["custom", index];
2947
+ if (!isPlainObject(rule)) {
2948
+ issues.push({ path, message: "must be a rule object" });
2949
+ return;
2950
+ }
2951
+ for (const key of Object.keys(rule)) {
2952
+ if (!CUSTOM_KEYS.includes(key)) {
2953
+ issues.push({ path: [...path, key], message: `unknown key "${key}" — a rule takes ${CUSTOM_KEYS.join(", ")}` });
2954
+ }
2955
+ }
2956
+ if (typeof rule.id !== "string" || rule.id.length === 0) {
2957
+ issues.push({ path: [...path, "id"], message: "a custom rule needs an id" });
2958
+ } else if (DEFAULT_IDS.has(rule.id)) {
2959
+ issues.push({
2960
+ path: [...path, "id"],
2961
+ message: `"${rule.id}" is a default rule id — a custom rule needs its own id; retune the default under proseGates.rules.defaults instead`
2962
+ });
2963
+ } else if (ids.has(rule.id)) {
2964
+ issues.push({ path: [...path, "id"], message: `"${rule.id}" is used by an earlier custom rule` });
2965
+ } else {
2966
+ ids.add(rule.id);
2967
+ }
2968
+ if (typeof rule.means !== "string" || rule.means.trim().length === 0) {
2969
+ issues.push({ path: [...path, "means"], message: "a custom rule needs a message (`means`)" });
2970
+ }
2971
+ let scopes = null;
2972
+ if (rule.scopes === undefined) {
2973
+ issues.push({ path: [...path, "scopes"], message: "a custom rule needs at least one scope (`scopes`)" });
2974
+ } else {
2975
+ scopes = scopeListIssues(rule.scopes, [...path, "scopes"], CONFIGURABLE_PROSE_SCOPES, issues);
2976
+ }
2977
+ if (scopes && new Set(scopes.map(groupOfScope)).size > 1) {
2978
+ issues.push({
2979
+ path: [...path, "scopes"],
2980
+ 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'
2981
+ });
2982
+ }
2983
+ const flags = flagIssues(rule.flags, [...path, "flags"], issues);
2984
+ if (rule.pattern === undefined && rule.patterns === undefined) {
2985
+ issues.push({
2986
+ path: [...path, "pattern"],
2987
+ message: "a custom rule needs a `pattern` or a per-scope `patterns` map"
2988
+ });
2989
+ }
2990
+ if (rule.pattern !== undefined)
2991
+ patternIssues(rule.pattern, flags, [...path, "pattern"], issues);
2992
+ if (rule.patterns !== undefined) {
2993
+ if (!isPlainObject(rule.patterns)) {
2994
+ issues.push({ path: [...path, "patterns"], message: "must map a scope to a regular expression" });
2995
+ } else {
2996
+ for (const [scope, source] of Object.entries(rule.patterns)) {
2997
+ if (scopes && !scopes.includes(scope)) {
2998
+ issues.push({
2999
+ path: [...path, "patterns", scope],
3000
+ message: `names scope "${scope}", which this rule's scopes do not cover`
3001
+ });
3002
+ continue;
3003
+ }
3004
+ patternIssues(source, flags, [...path, "patterns", scope], issues);
3005
+ }
3006
+ if (rule.pattern === undefined && scopes) {
3007
+ for (const scope of scopes) {
3008
+ if (!(scope in rule.patterns)) {
3009
+ issues.push({
3010
+ path: [...path, "patterns"],
3011
+ message: `has no pattern for scope "${scope}" — add one, or a \`pattern\` every other scope uses`
3012
+ });
3013
+ }
3014
+ }
3015
+ }
3016
+ }
3017
+ }
3018
+ if (rule.severity !== undefined && scopes)
3019
+ severityIssues(rule.severity, [...path, "severity"], scopes, issues);
3020
+ if (rule.exempt !== undefined)
3021
+ pathListIssues(rule.exempt, [...path, "exempt"], issues);
3022
+ });
3023
+ }
3024
+ function proseRulesIssues(value) {
3025
+ const issues = [];
3026
+ if (!isPlainObject(value))
3027
+ return [{ path: [], message: "must be an object with any of exempt, defaults, custom" }];
3028
+ for (const key of Object.keys(value)) {
3029
+ if (!["exempt", "defaults", "custom"].includes(key)) {
3030
+ issues.push({ path: [key], message: `unknown key "${key}" — proseGates.rules takes exempt, defaults and custom` });
3031
+ }
3032
+ }
3033
+ if (value.exempt !== undefined)
3034
+ pathListIssues(value.exempt, ["exempt"], issues);
3035
+ if (value.defaults !== undefined)
3036
+ defaultsIssues(value.defaults, issues);
3037
+ if (value.custom !== undefined)
3038
+ customIssues(value.custom, issues);
3039
+ return issues;
3040
+ }
3041
+ var ProseRulesSchema = z5.unknown().superRefine((value, ctx) => {
3042
+ for (const issue of proseRulesIssues(value)) {
3043
+ ctx.addIssue({ code: z5.ZodIssueCode.custom, path: issue.path, message: issue.message });
3044
+ }
3045
+ }).transform((value) => value);
3046
+ var PublishedProseSchema = z5.object({
3047
+ allow: z5.array(z5.string().min(1)).optional()
3048
+ }).strict();
3049
+
2356
3050
  // src/lib/config.ts
2357
- var EnvEntrySchema = z5.union([
2358
- z5.literal(true),
2359
- z5.object({ optional: z5.literal(true) }),
2360
- z5.object({ anyOf: z5.array(z5.string()).min(2) }),
2361
- z5.string()
3051
+ var EnvEntrySchema = z6.union([
3052
+ z6.literal(true),
3053
+ z6.object({ optional: z6.literal(true) }),
3054
+ z6.object({ anyOf: z6.array(z6.string()).min(2) }),
3055
+ z6.string()
2362
3056
  ]);
2363
- var CheckEntrySchema = z5.object({
2364
- run: z5.string(),
2365
- scope: z5.enum(["diff", "full"]),
2366
- include: z5.array(z5.string()).optional(),
2367
- args: z5.array(z5.string()).optional(),
2368
- timeoutMs: z5.number().optional(),
2369
- env: z5.record(z5.string(), EnvEntrySchema).optional(),
2370
- requiresOpenPr: z5.boolean().optional(),
2371
- ownWorkflow: z5.boolean().optional(),
2372
- principalOwed: z5.literal(true).optional(),
2373
- validates: z5.enum(["body", "issue"]).optional()
3057
+ var CheckEntrySchema = z6.object({
3058
+ run: z6.string(),
3059
+ scope: z6.enum(["diff", "full"]),
3060
+ include: z6.array(z6.string()).optional(),
3061
+ args: z6.array(z6.string()).optional(),
3062
+ timeoutMs: z6.number().optional(),
3063
+ env: z6.record(z6.string(), EnvEntrySchema).optional(),
3064
+ requiresOpenPr: z6.boolean().optional(),
3065
+ ownWorkflow: z6.boolean().optional(),
3066
+ principalOwed: z6.literal(true).optional(),
3067
+ validates: z6.enum(["body", "issue"]).optional(),
3068
+ advisory: z6.literal(true).optional()
2374
3069
  }).superRefine((entry, ctx) => {
2375
3070
  if (!entry.env)
2376
3071
  return;
@@ -2380,22 +3075,22 @@ var CheckEntrySchema = z5.object({
2380
3075
  const members = value.anyOf;
2381
3076
  if (new Set(members).size !== members.length) {
2382
3077
  ctx.addIssue({
2383
- code: z5.ZodIssueCode.custom,
3078
+ code: z6.ZodIssueCode.custom,
2384
3079
  message: `env.${key}.anyOf has duplicate members`,
2385
3080
  path: ["env", key, "anyOf"]
2386
3081
  });
2387
3082
  }
2388
3083
  if (!members.includes(key)) {
2389
3084
  ctx.addIssue({
2390
- code: z5.ZodIssueCode.custom,
3085
+ code: z6.ZodIssueCode.custom,
2391
3086
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
2392
3087
  path: ["env", key, "anyOf"]
2393
3088
  });
2394
3089
  }
2395
3090
  }
2396
3091
  });
2397
- var RoleEntrySchema = z5.object({
2398
- contract: z5.string().refine((p) => p.includes("/"), {
3092
+ var RoleEntrySchema = z6.object({
3093
+ contract: z6.string().refine((p) => p.includes("/"), {
2399
3094
  message: 'must be a path (contain at least one "/"), not a bare filename'
2400
3095
  })
2401
3096
  });
@@ -2419,17 +3114,17 @@ var BRIEF_BUILTINS = [
2419
3114
  "briefSections",
2420
3115
  "milestoneShape"
2421
3116
  ];
2422
- var BriefSectionSchema = z5.union([
2423
- z5.object({ builtin: z5.enum(BRIEF_BUILTINS) }),
2424
- z5.object({ heading: z5.string().min(1), name: z5.string().optional() }),
2425
- z5.object({ field: z5.string().min(1), name: z5.string().optional() }),
2426
- z5.object({ phrase: z5.string().min(1), name: z5.string().optional() })
3117
+ var BriefSectionSchema = z6.union([
3118
+ z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
3119
+ z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
3120
+ z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
3121
+ z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
2427
3122
  ]);
2428
- var BriefSchemaSchema = z5.object({
2429
- pr: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
2430
- issue: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
2431
- milestone: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
2432
- ack: z5.array(z5.enum(BRIEF_BUILTINS)).optional()
3123
+ var BriefSchemaSchema = z6.object({
3124
+ pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
3125
+ issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
3126
+ milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
3127
+ ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
2433
3128
  });
2434
3129
  function isSafeRepoRelPath(p) {
2435
3130
  if (p.length === 0)
@@ -2438,7 +3133,7 @@ function isSafeRepoRelPath(p) {
2438
3133
  return false;
2439
3134
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
2440
3135
  }
2441
- var SafeRepoRelPath = z5.string().refine(isSafeRepoRelPath, {
3136
+ var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
2442
3137
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
2443
3138
  });
2444
3139
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -2448,22 +3143,22 @@ function isCanonicalHookBlockPath(p) {
2448
3143
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
2449
3144
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
2450
3145
  });
2451
- var ManagedBlockRecordSchema = z5.object({
3146
+ var ManagedBlockRecordSchema = z6.object({
2452
3147
  path: ManagedHookBlockPath,
2453
- marker: z5.string(),
2454
- comment: z5.enum(["hash", "html"])
3148
+ marker: z6.string(),
3149
+ comment: z6.enum(["hash", "html"])
2455
3150
  });
2456
- var ManagedManifestSchema = z5.object({
2457
- version: z5.number().int().positive(),
2458
- files: z5.array(SafeRepoRelPath),
2459
- blocks: z5.array(ManagedBlockRecordSchema),
2460
- labels: z5.array(z5.string()),
2461
- agents: z5.array(z5.enum(AGENT_VENDORS)).optional()
3151
+ var ManagedManifestSchema = z6.object({
3152
+ version: z6.number().int().positive(),
3153
+ files: z6.array(SafeRepoRelPath),
3154
+ blocks: z6.array(ManagedBlockRecordSchema),
3155
+ labels: z6.array(z6.string()),
3156
+ agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
2462
3157
  });
2463
- var ProjectEntrySchema = z5.object({
2464
- name: z5.string().min(1),
2465
- description: z5.string().min(1).optional(),
2466
- path: z5.string().min(1).optional()
3158
+ var ProjectEntrySchema = z6.object({
3159
+ name: z6.string().min(1),
3160
+ description: z6.string().min(1).optional(),
3161
+ path: z6.string().min(1).optional()
2467
3162
  });
2468
3163
  function parseTokensCollectDeclaration(value) {
2469
3164
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -2474,90 +3169,90 @@ function parseTokensCollectDeclaration(value) {
2474
3169
  return null;
2475
3170
  return { interpreter, script };
2476
3171
  }
2477
- var VinayaConfigSchema = z5.object({
2478
- rings: z5.object({
2479
- ring1_forgeWriteInterception: z5.boolean(),
2480
- ring2_asyncAudits: z5.boolean()
3172
+ var VinayaConfigObjectSchema = z6.object({
3173
+ rings: z6.object({
3174
+ ring1_forgeWriteInterception: z6.boolean(),
3175
+ ring2_asyncAudits: z6.boolean()
2481
3176
  }).optional(),
2482
- checks: z5.record(z5.string(), CheckEntrySchema).optional(),
2483
- roles: z5.record(z5.string(), RoleEntrySchema).optional(),
3177
+ checks: z6.record(z6.string(), CheckEntrySchema).optional(),
3178
+ roles: z6.record(z6.string(), RoleEntrySchema).optional(),
2484
3179
  briefSchema: BriefSchemaSchema.optional(),
2485
3180
  managed: ManagedManifestSchema.optional(),
2486
- principals: z5.array(z5.string()).min(1).optional(),
2487
- releaseActor: z5.string().min(1).optional(),
2488
- ci: z5.object({ setup: z5.string().min(1) }).optional(),
2489
- tokens: z5.object({
2490
- collect: z5.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
3181
+ principals: z6.array(z6.string()).min(1).optional(),
3182
+ releaseActor: z6.string().min(1).optional(),
3183
+ ci: z6.object({ setup: z6.string().min(1) }).optional(),
3184
+ tokens: z6.object({
3185
+ collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
2491
3186
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
2492
3187
  })
2493
3188
  }).optional(),
2494
- blastRadius: z5.object({ extraDomains: z5.array(z5.string()).optional() }).optional(),
2495
- proseGates: z5.object({
2496
- doctrineRoot: z5.string().min(1).optional(),
2497
- readerFacingPrefix: z5.string().min(1).optional(),
2498
- readerFacingSuffix: z5.string().min(1).optional(),
2499
- legacySlugDir: z5.string().min(1).optional(),
2500
- sourceComments: z5.object({
2501
- globs: z5.array(z5.string().min(1)).optional(),
2502
- allowlist: z5.array(z5.string().min(1)).optional(),
2503
- severity: z5.enum(["warning", "error"]).optional()
3189
+ blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
3190
+ proseGates: z6.object({
3191
+ doctrineRoot: z6.string().min(1).optional(),
3192
+ readerFacingPrefix: z6.string().min(1).optional(),
3193
+ readerFacingSuffix: z6.string().min(1).optional(),
3194
+ legacySlugDir: z6.string().min(1).optional(),
3195
+ sourceComments: z6.object({
3196
+ globs: z6.array(z6.string().min(1)).optional(),
3197
+ allowlist: z6.array(z6.string().min(1)).optional(),
3198
+ severity: z6.enum(["warning", "error"]).optional()
2504
3199
  }).optional(),
2505
- specGrandfather: z5.union([z5.array(z5.string().min(1)), z5.record(z5.string().min(1), z5.number().int().min(0))]).optional(),
2506
- specPaths: z5.array(z5.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
2507
- message: "must be a repository-relative path, not an absolute one"
2508
- }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
2509
- message: "must stay inside the repository — no `..` segment"
2510
- })).optional()
3200
+ specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
3201
+ specPaths: z6.array(RepoRelativePathSchema).optional(),
3202
+ productPaths: z6.array(RepoRelativePathSchema).optional(),
3203
+ published: PublishedProseSchema.optional(),
3204
+ rules: ProseRulesSchema.optional()
2511
3205
  }).optional(),
2512
- projects: z5.array(ProjectEntrySchema).optional(),
2513
- dispatch: z5.object({
2514
- timeoutMs: z5.number().int().positive().optional(),
2515
- killGraceMs: z5.number().int().positive().optional(),
2516
- agent: z5.enum(["claude", "codex", "gemini"]).optional()
3206
+ projects: z6.array(ProjectEntrySchema).optional(),
3207
+ dispatch: z6.object({
3208
+ timeoutMs: z6.number().int().positive().optional(),
3209
+ reviewerTimeoutMs: z6.number().int().positive().optional(),
3210
+ killGraceMs: z6.number().int().positive().optional(),
3211
+ agent: z6.enum(["claude", "codex"]).optional()
2517
3212
  }).optional(),
2518
- reviewPolicy: z5.object({
2519
- codeReviewThreshold: z5.string().min(1).optional(),
2520
- securityThreshold: z5.string().min(1).optional(),
2521
- maxRounds: z5.number().optional(),
2522
- maxTaskMinutes: z5.number().optional()
3213
+ reviewPolicy: z6.object({
3214
+ codeReviewThreshold: z6.string().min(1).optional(),
3215
+ securityThreshold: z6.string().min(1).optional(),
3216
+ maxRounds: z6.number().optional(),
3217
+ maxTaskMinutes: z6.number().optional()
2523
3218
  }).optional(),
2524
- securityScan: z5.object({
2525
- command: z5.array(z5.string().min(1)).min(1)
3219
+ securityScan: z6.object({
3220
+ command: z6.array(z6.string().min(1)).min(1)
2526
3221
  }).optional(),
2527
- gateCutovers: z5.object({
2528
- objectivesSinceIssue: z5.number().int().nonnegative().optional(),
2529
- briefSectionsSinceIssue: z5.number().int().nonnegative().optional(),
2530
- documentationSinceIssue: z5.number().int().nonnegative().optional(),
2531
- briefRulesSincePr: z5.number().int().nonnegative().optional(),
2532
- agentBoxesRefusedSincePr: z5.number().int().nonnegative().optional()
3222
+ gateCutovers: z6.object({
3223
+ objectivesSinceIssue: z6.number().int().nonnegative().optional(),
3224
+ briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
3225
+ documentationSinceIssue: z6.number().int().nonnegative().optional(),
3226
+ briefRulesSincePr: z6.number().int().nonnegative().optional(),
3227
+ agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
2533
3228
  }).optional(),
2534
- planning: z5.object({
2535
- collisionThreshold: z5.number().int().nonnegative().optional()
3229
+ planning: z6.object({
3230
+ collisionThreshold: z6.number().int().nonnegative().optional()
2536
3231
  }).optional(),
2537
- prePush: z5.object({
2538
- alwaysRun: z5.array(z5.string()).optional()
3232
+ prePush: z6.object({
3233
+ alwaysRun: z6.array(z6.string()).optional()
2539
3234
  }).optional(),
2540
- report: z5.object({
2541
- commandTimeoutMs: z5.number().int().positive().optional()
3235
+ report: z6.object({
3236
+ commandTimeoutMs: z6.number().int().positive().optional()
2542
3237
  }).superRefine((report, ctx) => {
2543
3238
  const commandTimeoutMs = report.commandTimeoutMs;
2544
3239
  if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
2545
3240
  ctx.addIssue({
2546
- code: z5.ZodIssueCode.custom,
3241
+ code: z6.ZodIssueCode.custom,
2547
3242
  path: ["commandTimeoutMs"],
2548
3243
  message: "must be at most 3600000 (1 hour)"
2549
3244
  });
2550
3245
  }
2551
3246
  }).optional(),
2552
- logPublish: z5.unknown().refine((v) => v === undefined, {
3247
+ logPublish: z6.unknown().refine((v) => v === undefined, {
2553
3248
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
2554
3249
  }),
2555
- runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
2556
- logs: z5.object({
2557
- folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
2558
- url: z5.string().url().optional(),
2559
- headers: z5.record(z5.string()).optional(),
2560
- readHeaders: z5.record(z5.string()).optional(),
3250
+ runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
3251
+ logs: z6.object({
3252
+ folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
3253
+ url: z6.string().url().optional(),
3254
+ headers: z6.record(z6.string()).optional(),
3255
+ readHeaders: z6.record(z6.string()).optional(),
2561
3256
  events: CustomEventDeclarationsSchema.optional()
2562
3257
  }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
2563
3258
  message: "logs: set at most one of folder/url"
@@ -2565,8 +3260,33 @@ var VinayaConfigSchema = z5.object({
2565
3260
  message: "logs: headers requires url"
2566
3261
  }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
2567
3262
  message: "logs: readHeaders requires url"
2568
- }).optional()
3263
+ }).optional(),
3264
+ decisionRecords: z6.object({
3265
+ path: RepoRelativePathSchema
3266
+ }).strict().optional()
3267
+ });
3268
+ function decisionRecordsPathIssue(path, doctrineRoot) {
3269
+ const reason = outsideRepositoryReason(path);
3270
+ if (reason)
3271
+ return reason;
3272
+ const folder = normalizeSpecPath(path);
3273
+ if (folder === "" || folder === ".")
3274
+ return "must name a folder, not the repository root";
3275
+ const root = normalizeSpecPath(doctrineRoot ?? "aeg-root");
3276
+ if (folder === root || folder.startsWith(`${root}/`)) {
3277
+ return `must be outside the doctrine tree "${root}" — decision records belong to this repository, not to the doctrine it ships`;
3278
+ }
3279
+ return null;
3280
+ }
3281
+ var VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
3282
+ const path = config.decisionRecords?.path;
3283
+ if (path === undefined || outsideRepositoryReason(path))
3284
+ return;
3285
+ const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
3286
+ if (issue)
3287
+ ctx.addIssue({ code: z6.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
2569
3288
  });
3289
+ var VinayaConfigShape = VinayaConfigObjectSchema.shape;
2570
3290
  var GLOBAL_VINAYA_HOME = join4(homedir(), ".vinaya");
2571
3291
  var GLOBAL_CONFIG_PATH = join4(GLOBAL_VINAYA_HOME, "config.json");
2572
3292
  var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
@@ -2740,13 +3460,14 @@ function readTrustAnchorConfigAtRef(ref) {
2740
3460
  });
2741
3461
  return Buffer.from(raw, "utf-8").toString("base64");
2742
3462
  }
3463
+ var NO_TRUST_ANCHOR_REPO_MESSAGE = "could not resolve repo identity for the trust-anchor read";
2743
3464
  function ghFetchTrustAnchorConfig() {
2744
3465
  const probeRef = resolveCiTrustAnchorProbeRef();
2745
3466
  if (probeRef)
2746
3467
  return readTrustAnchorConfigAtRef(probeRef);
2747
3468
  const repo = trustAnchorRepo();
2748
3469
  if (!repo)
2749
- throw new Error("could not resolve repo identity for the trust-anchor read");
3470
+ throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
2750
3471
  return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
2751
3472
  encoding: "utf-8",
2752
3473
  stdio: ["ignore", "pipe", "pipe"]
@@ -2763,7 +3484,7 @@ async function ghFetchTrustAnchorConfigAsync() {
2763
3484
  }
2764
3485
  const repo = await trustAnchorRepoAsync();
2765
3486
  if (!repo)
2766
- throw new Error("could not resolve repo identity for the trust-anchor read");
3487
+ throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
2767
3488
  const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
2768
3489
  return stdout;
2769
3490
  }
@@ -2828,12 +3549,51 @@ function loadConfig() {
2828
3549
  const path = configPath();
2829
3550
  if (!path)
2830
3551
  return null;
3552
+ let text;
2831
3553
  try {
2832
- const raw = JSON.parse(readFileSync3(path, "utf-8"));
2833
- return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
2834
- } catch {
3554
+ text = readFileSync3(path, "utf-8");
3555
+ } catch (err) {
3556
+ reportInvalidConfigOnce(path, `unreadable: ${err.message}`);
3557
+ return null;
3558
+ }
3559
+ let raw;
3560
+ try {
3561
+ raw = JSON.parse(text);
3562
+ } catch (err) {
3563
+ reportInvalidConfigOnce(path, `invalid JSON: ${err.message}`);
3564
+ return null;
3565
+ }
3566
+ const parsed = VinayaConfigSchema.safeParse(raw);
3567
+ if (!parsed.success) {
3568
+ reportInvalidConfigOnce(path, schemaIssueDetail(parsed.error));
2835
3569
  return null;
2836
3570
  }
3571
+ return stripGlobalOnlyKeys(parsed.data, path);
3572
+ }
3573
+ function schemaIssueDetail(error) {
3574
+ return error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
3575
+ }
3576
+ var emittedInvalidConfigReports = new Set;
3577
+ function reportInvalidConfigOnce(path, detail) {
3578
+ const key = `${path}
3579
+ ${detail}`;
3580
+ if (emittedInvalidConfigReports.has(key))
3581
+ return;
3582
+ emittedInvalidConfigReports.add(key);
3583
+ const message = `${path} is not a valid Vinaya configuration (${detail}) — falling back to built-in defaults.`;
3584
+ const checkName = process.env.VINAYA_CHECK_NAME;
3585
+ if (checkName) {
3586
+ emitCheckError({
3587
+ schema: CHECK_SCHEMA_VERSION,
3588
+ check: checkName,
3589
+ severity: "warning",
3590
+ message,
3591
+ agent_recovery_prompt: `Fix the failing keys in ${path} (${detail}) so the file parses and satisfies the configuration schema, then re-run.`,
3592
+ file: path
3593
+ });
3594
+ return;
3595
+ }
3596
+ console.error(`⚠ ${message}`);
2837
3597
  }
2838
3598
  var TOKENS_COLLECT_TRUST_PATH = join4(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
2839
3599
 
@@ -3984,6 +4744,8 @@ function createLogSink(overrides = {}) {
3984
4744
  branchIssue,
3985
4745
  eventId: randomUUID2(),
3986
4746
  processId,
4747
+ revision: headSha,
4748
+ provenance: deps.provenance,
3987
4749
  inputVersions: deps.inputVersions()
3988
4750
  });
3989
4751
  const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
@@ -4198,6 +4960,16 @@ var COMMANDS = [
4198
4960
  ],
4199
4961
  status: "shipped"
4200
4962
  },
4963
+ {
4964
+ name: "new adr",
4965
+ needs: [],
4966
+ description: "Write the next numbered decision record into the folder decisionRecords.path names",
4967
+ details: [
4968
+ "`vinaya new adr <title>` writes `<decisionRecords.path>/NNNN-<kebab-title>.md` from the shipped decision-record template (`vinaya doctrine --template decision-record`), with status Proposed and today's date, and adds a row for it to the folder's `README.md` index page, creating that page on the first record. Numbers start at `0001` and are one past the highest number any file in the folder or any row of the index carries, so a number is never reused, even after its file is removed.",
4969
+ "Refuses, naming the key, while `decisionRecords.path` is unset: decision records are opt-in. The same key switches on the `decision-record-citation` writing rule — see `decisionRecords.path` in the configuration reference."
4970
+ ],
4971
+ status: "shipped"
4972
+ },
4201
4973
  {
4202
4974
  name: "brief render",
4203
4975
  needs: ["forge", "default-branch"],
@@ -4216,9 +4988,7 @@ var COMMANDS = [
4216
4988
  name: "task dispatch",
4217
4989
  needs: ["forge", "operator-seat"],
4218
4990
  description: "Deprecated — render, pin, and post the brief on the Issue as the frozen original; start the developer",
4219
- flags: [
4220
- { flag: "--agent <claude|codex|gemini>", description: "Start the developer through dispatchRole once posted" }
4221
- ],
4991
+ flags: [{ flag: "--agent <claude|codex>", description: "Start the developer through dispatchRole once posted" }],
4222
4992
  details: [
4223
4993
  "Renders the brief from the Issue and the tree (the same assembly `brief render` uses) and posts it once as an Issue comment whose first line is `<!-- aeg:brief:v1 -->` and whose second line is `Brief hash: <sha256>` — the hash covers only the body below those two lines, so any reader recomputes it. Refuses outright, naming the existing comment's URL, when a `v1` comment already exists on the Issue — the brief is frozen by design, never overwritten or silently reissued.",
4224
4994
  "With `--agent`, starts the Developer through `dispatchRole` when `apps/cli/src/lib/dispatch.ts` exports it; otherwise prints the rendered brief and the manual dispatch instruction and exits `0` — a soft dependency, never a hard block.",
@@ -4243,7 +5013,7 @@ var COMMANDS = [
4243
5013
  description: "One command from a planned Issue to a reviewed pull request — exactly one developer started",
4244
5014
  flags: [
4245
5015
  {
4246
- flag: "--agent <claude|codex|gemini>",
5016
+ flag: "--agent <claude|codex>",
4247
5017
  description: "Vendor for the developer and both reviewers this run dispatches"
4248
5018
  },
4249
5019
  {
@@ -4418,6 +5188,22 @@ var COMMANDS = [
4418
5188
  ],
4419
5189
  status: "shipped"
4420
5190
  },
5191
+ {
5192
+ name: "pr snapshot",
5193
+ needs: ["forge"],
5194
+ description: "CI plumbing: write a run's forge snapshot of the pull request and its task Issue, read over REST",
5195
+ flags: [
5196
+ {
5197
+ flag: "--dir",
5198
+ description: "The snapshot directory; its `raw/` holds the REST pull request and comment pages the read step wrote"
5199
+ }
5200
+ ],
5201
+ details: [
5202
+ "Run by the generated workflows' read step, never by hand. Maps the REST pull request and its comments to the shape `gh pr view --json` prints, resolves the task Issue from the body's `Closes #N`, and reads that Issue and its comments over REST — never GraphQL.",
5203
+ "A check reads the snapshot only when `GITHUB_ACTIONS` is `true` and the step running it sets `VINAYA_FORGE_SNAPSHOT_DIR`; anywhere else every read goes to the forge as before. Exits 1, naming what it could not read and both token budgets, on a failed read; 2 on a usage error."
5204
+ ],
5205
+ status: "shipped"
5206
+ },
4421
5207
  {
4422
5208
  name: "issue create",
4423
5209
  needs: ["forge"],
@@ -4538,14 +5324,14 @@ var COMMANDS = [
4538
5324
  {
4539
5325
  name: "milestone close",
4540
5326
  needs: ["forge"],
4541
- description: "Close a tranche's Milestone after verifying every labeled Issue is actually attached",
5327
+ description: "Close a tranche's Milestone after verifying every labeled Issue is attached and every tranche it declares is complete",
4542
5328
  flags: [
4543
5329
  { flag: "--slug", description: "The tranche whose Milestone is being closed" },
4544
5330
  { flag: "--validate-only", description: "Run every gate and report PASS without closing the Milestone" },
4545
5331
  { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
4546
5332
  ],
4547
5333
  details: [
4548
- "Resolves the target Milestone the same legacy-or-intent-declared way Issue create auto-attach does, then refuses to close on any mismatch between the label's Issues and the Milestone's natively attached Issues — naming each unattached or foreign Issue and its repair path (`gh issue edit <n> --milestone <title>`, or `vinaya milestone adopt`) — before the PATCH ever reaches the forge."
5334
+ "Resolves the target Milestone the same legacy-or-intent-declared way Issue create auto-attach does, then refuses to close on any mismatch between the label's Issues and the Milestone's natively attached Issues — naming each unattached or foreign Issue and its repair path (`gh issue edit <n> --milestone <title>`, or `vinaya milestone adopt`) — before the PATCH ever reaches the forge. It also holds the Milestone open while a tranche its `### Tranche intents` section declares is not complete — naming each unfinished tranche and its lifecycle — or while that section carries no readable tranche line; a Milestone with no such section closes on attachment alone. `--validate-only` refuses with the same reasons."
4549
5335
  ],
4550
5336
  status: "shipped"
4551
5337
  },
@@ -4834,7 +5620,7 @@ var COMMANDS = [
4834
5620
  }
4835
5621
  ],
4836
5622
  details: [
4837
- "Refuses unless HEAD is the default branch, the working tree is clean, HEAD equals `origin/<default>` (after `git fetch origin`), HEAD's commit subject starts with `Chore(release): Version packages` (unless `--allow-any-commit`), and `npm whoami` exits `0` — each its own refusal naming the fix.",
5623
+ "Refuses unless HEAD is the default branch, the working tree is clean, HEAD equals `origin/<default>` (after `git fetch origin`), HEAD's commit subject starts with `Chore(release): Version packages` (unless `--allow-any-commit`), and `npm whoami` exits `0`. Before any plan step, including under `--dry-run`, every package in `.changeset/config.json` fixed groups must have an unpublished working-tree version. Exact-version registry queries refuse with every already-published package and version; workspace read failures and registry errors other than E404 also refuse with their reason. E404 for a missing package or version counts as unpublished.",
4838
5624
  "Then streams `bun install --frozen-lockfile`, `bun run build`, `bun run changeset:publish`, and `git push origin --tags` — a real push, so the repo's own generated pre-push hook sees it exactly as any other push would. After it, prints `npm view <pkg> version` for every tag now on HEAD, noting registry lag on `@attalabs/vinaya` (observed ~20 minutes) when it still shows the previous version.",
4839
5625
  'This is the one procedure named in `apps/cli/specs/self-hosting.md`, "How the published version is produced" — publishing itself stays manual and human-triggered; this command only removes the hand-typed four-step recipe.'
4840
5626
  ],
@@ -4843,11 +5629,11 @@ var COMMANDS = [
4843
5629
  {
4844
5630
  name: "dispatch",
4845
5631
  needs: ["operator-seat"],
4846
- description: "Start a role's headless agent session (claude/codex/gemini) with attribution set on its environment, recording the outcome through the Vinaya Log",
5632
+ description: "Start a role's headless agent session (claude/codex) with attribution set on its environment, recording the outcome through the Vinaya Log",
4847
5633
  flags: [
4848
5634
  {
4849
5635
  flag: "--agent",
4850
- description: "Vendor to start: `claude`, `codex`, or `gemini` (falls back to `dispatch.agent` in config)"
5636
+ description: "Vendor to start: `claude` or `codex` (falls back to `dispatch.agent` in config)"
4851
5637
  },
4852
5638
  { flag: "--prompt-file", description: "Path to the prompt text sent to the agent (never on argv)" },
4853
5639
  { flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
@@ -4864,9 +5650,9 @@ var COMMANDS = [
4864
5650
  ],
4865
5651
  details: [
4866
5652
  "Sets `VINAYA_RUN_ID`/`VINAYA_ROLE`/`VINAYA_TASK`/`VINAYA_ROUND` on the child only — never on this process's own environment — and refuses by name, before any spawn attempt, when the named vendor binary is absent from `PATH` or present but not executable.",
4867
- "Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, or `refused`) through the Vinaya Log's one `dispatch` family writer, `dispatchRole`. A wall-time ceiling (`dispatch.timeoutMs` in config, default one hour) sends `SIGTERM` then, after a grace window, `SIGKILL`.",
5653
+ "Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, `refused`, or `usage_limit`) through the Vinaya Log's one `dispatch` family writer, `dispatchRole`. A wall-time ceiling (`dispatch.timeoutMs` in config, default one hour) sends `SIGTERM` then, after a grace window, `SIGKILL`.",
4868
5654
  "Runs no flush of its own after the dispatch returns: every log line `dispatchRole` emits reaches its configured `logs` destination live, as it is emitted, so there is nothing left to ship in a trailing step. `--task`/`--pr` are attribution only, and remain mutually exclusive.",
4869
- "A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude/gemini: `session_id`; codex: `thread_id`), parsed from its stdout, `null` on any failure. Passing that value as `--resume <id>` on a later call swaps in that vendor's own resume invocation (`claude -p -r <id> ...`; `codex exec resume <id> ...`; `gemini ... --resume <id> ...`) in place of its first-dispatch args."
5655
+ "A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude: `session_id`; codex: `thread_id`), parsed from its stdout, `null` on any failure. Passing that value as `--resume <id>` on a later call swaps in that vendor's own resume invocation (`claude -p -r <id> ...`; `codex exec resume <id> ...`) in place of its first-dispatch args."
4870
5656
  ],
4871
5657
  status: "shipped"
4872
5658
  },
@@ -4877,7 +5663,7 @@ var COMMANDS = [
4877
5663
  flags: [
4878
5664
  { flag: "--task <n>", description: "This task's Issue number — its frozen `aeg:brief:v1` comment is the brief" },
4879
5665
  {
4880
- flag: "--agent <claude|codex|gemini>",
5666
+ flag: "--agent <claude|codex>",
4881
5667
  description: "Vendor for every dispatch this loop makes (falls back to `dispatch.agent` in config)"
4882
5668
  },
4883
5669
  { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
@@ -4948,10 +5734,10 @@ var COMMANDS = [
4948
5734
  }
4949
5735
  ];
4950
5736
  // ../../packages/sources/src/select-source.ts
4951
- import { z as z6 } from "zod";
4952
- var StateSourceConfigSchema = z6.discriminatedUnion("kind", [
4953
- z6.object({ kind: z6.literal("forge"), owner: z6.string(), repo: z6.string() }),
4954
- z6.object({ kind: z6.literal("file"), root: z6.string().optional() })
5737
+ import { z as z7 } from "zod";
5738
+ var StateSourceConfigSchema = z7.discriminatedUnion("kind", [
5739
+ z7.object({ kind: z7.literal("forge"), owner: z7.string(), repo: z7.string() }),
5740
+ z7.object({ kind: z7.literal("file"), root: z7.string().optional() })
4955
5741
  ]);
4956
5742
  // src/checks/edge-resolve.ts
4957
5743
  var issueCache = new Map;
@@ -4964,6 +5750,13 @@ import matter4 from "gray-matter";
4964
5750
  import matter2 from "gray-matter";
4965
5751
  // ../../packages/aeg-core/src/docs/surfaced-manifest.ts
4966
5752
  var NO_MODEL_BACKED_PATHS = new Set;
5753
+ // ../../packages/aeg-core/src/docs/published-prose.ts
5754
+ var ALLOWED_MECHANICS = rulesForGroup("published-prose")[0]?.exemptions ?? [];
5755
+ var PROSE_RULES = rulesForGroup("published-prose").map((rule) => ({
5756
+ id: rule.id,
5757
+ what: rule.message,
5758
+ pattern: rule.patterns.published
5759
+ }));
4967
5760
  // src/roles/contract.ts
4968
5761
  import matter3 from "gray-matter";
4969
5762