@attalabs/vinaya 0.33.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/aeg-root/enforcement.md +1 -1
  2. package/aeg-root/glossary.md +4 -0
  3. package/aeg-root/roles/developer.md +3 -0
  4. package/aeg-root/roles/operator.md +30 -10
  5. package/aeg-root/roles/planner/reference.md +2 -1
  6. package/aeg-root/roles/planner.md +3 -1
  7. package/aeg-root/templates/brief-template.md +9 -7
  8. package/aeg-root/templates/pr-report-template.md +3 -1
  9. package/dist/checks/bin/check-body-bare-digits.js +102 -26
  10. package/dist/checks/bin/check-branch-topology.js +81 -25
  11. package/dist/checks/bin/check-brief-shape.js +108 -31
  12. package/dist/checks/bin/check-changeset-coverage.js +331 -87
  13. package/dist/checks/bin/check-closes-n.js +81 -25
  14. package/dist/checks/bin/check-coherence.js +108 -27
  15. package/dist/checks/bin/check-dead-branch-push.js +77 -25
  16. package/dist/checks/bin/check-dispatch-readiness.js +106 -26
  17. package/dist/checks/bin/check-doc-coverage-push.js +327 -83
  18. package/dist/checks/bin/check-doc-coverage.js +329 -85
  19. package/dist/checks/bin/check-doctrine-no-procedures.js +102 -26
  20. package/dist/checks/bin/check-doctrine-portability.js +328 -84
  21. package/dist/checks/bin/check-evidence-fresh.js +300 -56
  22. package/dist/checks/bin/check-exec-bits.js +325 -81
  23. package/dist/checks/bin/check-first-push-dispatch.js +106 -26
  24. package/dist/checks/bin/check-issue-assignment.js +81 -25
  25. package/dist/checks/bin/check-issue-milestone-attach.js +77 -25
  26. package/dist/checks/bin/check-issue-objectives-numbering.js +603 -26
  27. package/dist/checks/bin/check-issue-parts-coverage.js +77 -25
  28. package/dist/checks/bin/check-issue-surface-globs.js +146 -32
  29. package/dist/checks/bin/check-issue-title-grammar.js +77 -25
  30. package/dist/checks/bin/check-issue-tranche-label.js +77 -25
  31. package/dist/checks/bin/check-main-branch-refusal.js +77 -25
  32. package/dist/checks/bin/check-no-disk-state.js +77 -25
  33. package/dist/checks/bin/check-pr-premise-reassert.js +102 -26
  34. package/dist/checks/bin/check-pr-report-density.js +77 -25
  35. package/dist/checks/bin/check-principal-test-plan-wait.js +77 -25
  36. package/dist/checks/bin/check-quoted-command.js +244 -34
  37. package/dist/checks/bin/check-reader-resolvable-prose.js +295 -42
  38. package/dist/checks/bin/check-registry-gates.js +77 -25
  39. package/dist/checks/bin/check-retired-vocabulary.js +244 -34
  40. package/dist/checks/bin/check-review-gate.js +106 -29
  41. package/dist/checks/bin/check-single-plan-pr.js +77 -25
  42. package/dist/checks/bin/check-surface-scope.js +81 -25
  43. package/dist/checks/bin/check-test-plan.js +77 -25
  44. package/dist/checks/bin/check-token-collection-wired.js +77 -25
  45. package/dist/checks/bin/check-token-report.js +77 -25
  46. package/dist/checks/bin/check-workspace-escape.js +326 -82
  47. package/dist/index.js +2862 -1953
  48. package/dist/lib/pre-push-cache-test-run.js +190 -11
  49. package/dist/lib/pre-push-select-tests.js +45 -3
  50. package/package.json +1 -1
  51. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +13 -3
  52. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +5 -2
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +116 -20
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +72 -2
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +48 -2
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +18 -3
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +24 -0
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +15 -10
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +16 -0
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +194 -0
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +276 -52
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +62 -8
  63. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  64. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  65. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  66. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  70. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +4 -4
  102. 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
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__18paley._.js → [root-of-the-server]__07uhu5z._.js} +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  117. 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
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  122. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ko698wh8xx2g.css +1 -0
  123. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1ce2dj27_cgbj.js → 0q9p7c6vn-x2w.js} +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{22s44f5k3ecmj.js → 2174nz5he_oc4.js} +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{34hhdtbp20krb.js → 3xnma0-359j17.js} +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  127. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bm4nrrzwc7zi.css +0 -1
  128. /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  129. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{vl7QVqELe1AQ-9kaOd9mR → HmoeqXdX1E4drt7GReFOO}/_buildManifest.js +0 -0
  130. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{vl7QVqELe1AQ-9kaOd9mR → HmoeqXdX1E4drt7GReFOO}/_clientMiddlewareManifest.js +0 -0
  131. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{vl7QVqELe1AQ-9kaOd9mR → HmoeqXdX1E4drt7GReFOO}/_ssgManifest.js +0 -0
@@ -193,8 +193,8 @@ function maskIndentedCode(body, fill) {
193
193
  var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
194
194
  var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
195
195
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
196
- var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
197
- var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
196
+ var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+$/i;
197
+ var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+)$/i;
198
198
  function splitSlugQualifiedEdge(edge) {
199
199
  const m = edge.trim().match(SLUG_QUALIFIED_ID);
200
200
  if (!m)
@@ -2615,7 +2615,7 @@ function isIssueNotFoundError(err) {
2615
2615
  return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
2616
2616
  }
2617
2617
  function resolveObjectivesSource(prBody, issue, cutoverIssue) {
2618
- if (issue !== null && issue < cutoverIssue)
2618
+ if (issue !== null && cutoverIssue !== null && issue < cutoverIssue)
2619
2619
  return { kind: "none" };
2620
2620
  if (issue !== null)
2621
2621
  return { kind: "issue", issue };
@@ -2891,9 +2891,18 @@ var COMMIT_TYPES = [
2891
2891
  ];
2892
2892
  var COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join("|")})(\\([a-z0-9-]+\\))?: \\S`);
2893
2893
  function checkForgeTitle(title) {
2894
- const taskStyle = /^\[[a-z0-9._-]+\] \S+ — \S/;
2894
+ const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/;
2895
2895
  if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title))
2896
2896
  return { status: "pass", errors: [] };
2897
+ const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title);
2898
+ if (letteredTaskId) {
2899
+ return {
2900
+ status: "fail",
2901
+ errors: [
2902
+ `brief-validation title: "${title}" names task id \`${letteredTaskId[1]}\` — task ids are whole numbers (\`1\`, \`2\`), never lettered (\`2a\`). \`vinaya task run\` and \`task dispatch\` refuse a non-numeric id, so a plan titled this way names a task that cannot be started.`
2903
+ ]
2904
+ };
2905
+ }
2897
2906
  return {
2898
2907
  status: "fail",
2899
2908
  errors: [
@@ -2926,19 +2935,31 @@ function checkNoAgentBoxes(prBody) {
2926
2935
  ]
2927
2936
  };
2928
2937
  }
2929
- function rolloutThresholdFor(message) {
2938
+ function rolloutRuleFor(message) {
2930
2939
  if (message.startsWith("brief-validation unpinned code claim:") || message.startsWith("brief-validation commands carry output:") || message.startsWith("brief-validation consumer tests:") || message.startsWith("brief-validation defeat cases:")) {
2931
- return BRIEF_RULES_SINCE_PR;
2940
+ return "briefRules";
2932
2941
  }
2933
2942
  if (message.startsWith("brief-validation no agent boxes:"))
2934
- return AGENT_BOXES_REFUSED_SINCE_PR;
2943
+ return "agentBoxes";
2935
2944
  return null;
2936
2945
  }
2937
- function partitionBriefErrorsByRollout(errors, prNumber) {
2946
+ var DEFAULT_BRIEF_ROLLOUT_CUTOVERS = {
2947
+ briefRulesSincePr: BRIEF_RULES_SINCE_PR,
2948
+ agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
2949
+ };
2950
+ function rolloutThresholdFor(message, cutovers) {
2951
+ const rule = rolloutRuleFor(message);
2952
+ if (rule === "briefRules")
2953
+ return cutovers.briefRulesSincePr;
2954
+ if (rule === "agentBoxes")
2955
+ return cutovers.agentBoxesRefusedSincePr;
2956
+ return null;
2957
+ }
2958
+ function partitionBriefErrorsByRollout(errors, prNumber, cutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS) {
2938
2959
  const blocking = [];
2939
2960
  const info = [];
2940
2961
  for (const e of errors) {
2941
- const threshold = rolloutThresholdFor(e);
2962
+ const threshold = rolloutThresholdFor(e, cutovers);
2942
2963
  const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold;
2943
2964
  (grandfathered ? info : blocking).push(e);
2944
2965
  }
@@ -3406,8 +3427,8 @@ function checkIssueRationale(body) {
3406
3427
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3407
3428
  }
3408
3429
  var OBJECTIVES_SINCE_ISSUE = 404;
3409
- function checkIssueObjectives(body, issueNumber) {
3410
- if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE)
3430
+ function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3431
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3411
3432
  return { status: "pass", errors: [] };
3412
3433
  const result = objectivesOf(body);
3413
3434
  if (result.ok)
@@ -3852,7 +3873,7 @@ function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
3852
3873
  return issueToEntry.get(Number(issueMatch[1]));
3853
3874
  return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
3854
3875
  }
3855
- function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3876
+ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
3856
3877
  const failures = [];
3857
3878
  for (const [slug, issues] of issuesBySlug) {
3858
3879
  for (const issue of issues) {
@@ -3861,7 +3882,7 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3861
3882
  const errors = [
3862
3883
  ...checkIssueRationale(issue.body).errors,
3863
3884
  ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
3864
- ...checkIssueObjectives(issue.body, issue.number).errors,
3885
+ ...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
3865
3886
  ...checkPartsCiteDefinedObjectives(issue.body).errors
3866
3887
  ];
3867
3888
  if (errors.length === 0)
@@ -4484,13 +4505,27 @@ var SHIPS_PREFIX = "aeg-root/";
4484
4505
  function shipsArchivePrefix(shipsPrefix) {
4485
4506
  return `${shipsPrefix}tranches/completed/`;
4486
4507
  }
4487
- function isSpecFile2(path) {
4488
- return path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md");
4508
+ var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
4509
+ function normalizeSpecPath(entry) {
4510
+ let out = entry.replace(/\\/g, "/");
4511
+ while (out.startsWith("./"))
4512
+ out = out.slice(2);
4513
+ out = out.replace(/\/{2,}/g, "/");
4514
+ while (out.endsWith("/"))
4515
+ out = out.slice(0, -1);
4516
+ return out;
4517
+ }
4518
+ function isSpecFile2(path, specPaths) {
4519
+ if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
4520
+ return true;
4521
+ if (!path.endsWith(".md"))
4522
+ return false;
4523
+ return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
4489
4524
  }
4490
4525
  function isClaudeMdFile(path) {
4491
4526
  return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
4492
4527
  }
4493
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4528
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
4494
4529
  if (path.startsWith(shipsPrefix)) {
4495
4530
  return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
4496
4531
  }
@@ -4499,7 +4534,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
4499
4534
  }
4500
4535
  if (isClaudeMdFile(path))
4501
4536
  return "internal";
4502
- if (isSpecFile2(path))
4537
+ if (isSpecFile2(path, specPaths))
4503
4538
  return "spec";
4504
4539
  if (isProductScopeFile(path))
4505
4540
  return "product";
@@ -4528,13 +4563,14 @@ function lineAt(content, index) {
4528
4563
  }
4529
4564
  var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
4530
4565
  var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
4566
+ var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
4531
4567
  function legacySlugPattern(legacySlugs) {
4532
4568
  if (legacySlugs.length === 0)
4533
4569
  return null;
4534
4570
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
4535
4571
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
4536
4572
  }
4537
- function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4573
+ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4538
4574
  const findings = [];
4539
4575
  const legacyPattern = legacySlugPattern(legacySlugs);
4540
4576
  const grandfathered = new Set(specGrandfather);
@@ -4546,8 +4582,12 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4546
4582
  const productPatterns = [
4547
4583
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4548
4584
  ];
4585
+ const specPatterns = [
4586
+ ...patterns,
4587
+ { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
4588
+ ];
4549
4589
  for (const file of files) {
4550
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4590
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
4551
4591
  if (!cls || cls === "internal")
4552
4592
  continue;
4553
4593
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
@@ -4556,15 +4596,16 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4556
4596
  continue;
4557
4597
  const blocking = cls === "product" || cls === "spec";
4558
4598
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4559
- const patternsToRun = cls === "product" ? productPatterns : patterns;
4599
+ const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
4560
4600
  for (const { pattern, what, group } of patternsToRun) {
4561
4601
  pattern.lastIndex = 0;
4562
4602
  let match = pattern.exec(scrubbed);
4563
4603
  while (match !== null) {
4564
4604
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
4605
+ const citedIndex = match.index + match[0].indexOf(cited);
4565
4606
  findings.push({
4566
4607
  file: file.path,
4567
- line: lineAt(scrubbed, match.index),
4608
+ line: lineAt(scrubbed, citedIndex),
4568
4609
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4569
4610
  blocking
4570
4611
  });
@@ -4750,9 +4791,9 @@ function checkSourceComments(files, allowlist = []) {
4750
4791
  }
4751
4792
  return findings;
4752
4793
  }
4753
- function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4794
+ function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4754
4795
  return [
4755
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather),
4796
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
4756
4797
  ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4757
4798
  ];
4758
4799
  }
@@ -5217,7 +5258,8 @@ var TaskStatusItemSchema = z.object({
5217
5258
  }).merge(ObservedSchema);
5218
5259
  var TaskStatusResultSchema = z.object({
5219
5260
  items: z.array(TaskStatusItemSchema),
5220
- nextCursor: z.string().nullable()
5261
+ nextCursor: z.string().nullable(),
5262
+ table: z.string()
5221
5263
  });
5222
5264
  var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
5223
5265
  var EscalationInputsSchema = z.object({
@@ -5561,6 +5603,14 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5561
5603
  }
5562
5604
  return findings;
5563
5605
  }
5606
+ // ../../packages/aeg-core/src/gate-cutovers.ts
5607
+ var NO_GATE_CUTOVERS = {
5608
+ objectivesSinceIssue: null,
5609
+ briefSectionsSinceIssue: null,
5610
+ documentationSinceIssue: null,
5611
+ briefRulesSincePr: null,
5612
+ agentBoxesRefusedSincePr: null
5613
+ };
5564
5614
  // ../../packages/aeg-core/src/dev-review-loop/types.ts
5565
5615
  var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5566
5616
  // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
@@ -6010,6 +6060,8 @@ function attemptFromEnv(value) {
6010
6060
  function provenanceFor(input) {
6011
6061
  if (input.provenance)
6012
6062
  return input.provenance;
6063
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
6064
+ return "unavailable";
6013
6065
  if (input.env.role || input.env.task)
6014
6066
  return "env_correlated";
6015
6067
  return "unavailable";
@@ -6030,7 +6082,7 @@ function buildHeader(input) {
6030
6082
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6031
6083
  const round = roundFromEnv(input.env.round);
6032
6084
  const subject = {
6033
- issue: issueFromTask(input.env.task),
6085
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6034
6086
  role,
6035
6087
  ...round !== undefined ? { round } : {},
6036
6088
  ...input.subject ?? {}
@@ -6317,6 +6369,530 @@ function emitCheckError(error) {
6317
6369
  `);
6318
6370
  }
6319
6371
 
6372
+ // src/lib/config.ts
6373
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6374
+ import { promisify as promisify4 } from "node:util";
6375
+ import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6376
+ import { homedir } from "node:os";
6377
+ import { dirname, isAbsolute, join, resolve } from "node:path";
6378
+ import { z as z4 } from "zod";
6379
+
6380
+ // src/lib/agent-vendors.ts
6381
+ var AGENT_VENDORS = ["skills", "claude", "gemini"];
6382
+
6383
+ // src/lib/config.ts
6384
+ var EnvEntrySchema = z4.union([
6385
+ z4.literal(true),
6386
+ z4.object({ optional: z4.literal(true) }),
6387
+ z4.object({ anyOf: z4.array(z4.string()).min(2) }),
6388
+ z4.string()
6389
+ ]);
6390
+ var CheckEntrySchema = z4.object({
6391
+ run: z4.string(),
6392
+ scope: z4.enum(["diff", "full"]),
6393
+ include: z4.array(z4.string()).optional(),
6394
+ args: z4.array(z4.string()).optional(),
6395
+ timeoutMs: z4.number().optional(),
6396
+ env: z4.record(z4.string(), EnvEntrySchema).optional(),
6397
+ requiresOpenPr: z4.boolean().optional(),
6398
+ ownWorkflow: z4.boolean().optional(),
6399
+ principalOwed: z4.literal(true).optional(),
6400
+ validates: z4.enum(["body", "issue"]).optional()
6401
+ }).superRefine((entry, ctx) => {
6402
+ if (!entry.env)
6403
+ return;
6404
+ for (const [key, value] of Object.entries(entry.env)) {
6405
+ if (typeof value !== "object" || value === null || !("anyOf" in value))
6406
+ continue;
6407
+ const members = value.anyOf;
6408
+ if (new Set(members).size !== members.length) {
6409
+ ctx.addIssue({
6410
+ code: z4.ZodIssueCode.custom,
6411
+ message: `env.${key}.anyOf has duplicate members`,
6412
+ path: ["env", key, "anyOf"]
6413
+ });
6414
+ }
6415
+ if (!members.includes(key)) {
6416
+ ctx.addIssue({
6417
+ code: z4.ZodIssueCode.custom,
6418
+ message: `env.${key}.anyOf must include "${key}" itself as a member`,
6419
+ path: ["env", key, "anyOf"]
6420
+ });
6421
+ }
6422
+ }
6423
+ });
6424
+ var RoleEntrySchema = z4.object({
6425
+ contract: z4.string().refine((p) => p.includes("/"), {
6426
+ message: 'must be a path (contain at least one "/"), not a bare filename'
6427
+ })
6428
+ });
6429
+ var MAX_REPORT_COMMAND_TIMEOUT_MS = 3600000;
6430
+ var BRIEF_BUILTINS = [
6431
+ "tier",
6432
+ "testPlan",
6433
+ "testPlanExclusivity",
6434
+ "principalPlaceholder",
6435
+ "surfaceMap",
6436
+ "docUpdateList",
6437
+ "worktreeStep0",
6438
+ "stopConditions",
6439
+ "autonomyClause",
6440
+ "project",
6441
+ "for",
6442
+ "closesN",
6443
+ "premiseCoverage",
6444
+ "issueRationale",
6445
+ "objectives",
6446
+ "briefSections",
6447
+ "milestoneShape"
6448
+ ];
6449
+ var BriefSectionSchema = z4.union([
6450
+ z4.object({ builtin: z4.enum(BRIEF_BUILTINS) }),
6451
+ z4.object({ heading: z4.string().min(1), name: z4.string().optional() }),
6452
+ z4.object({ field: z4.string().min(1), name: z4.string().optional() }),
6453
+ z4.object({ phrase: z4.string().min(1), name: z4.string().optional() })
6454
+ ]);
6455
+ var BriefSchemaSchema = z4.object({
6456
+ pr: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6457
+ issue: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6458
+ milestone: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6459
+ ack: z4.array(z4.enum(BRIEF_BUILTINS)).optional()
6460
+ });
6461
+ function isSafeRepoRelPath(p) {
6462
+ if (p.length === 0)
6463
+ return false;
6464
+ if (p.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(p))
6465
+ return false;
6466
+ return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
6467
+ }
6468
+ var SafeRepoRelPath = z4.string().refine(isSafeRepoRelPath, {
6469
+ message: "must be a repo-root-relative path with no `..` segment or absolute root"
6470
+ });
6471
+ var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
6472
+ function isCanonicalHookBlockPath(p) {
6473
+ return CANONICAL_HOOK_BLOCK_PREFIXES.some((prefix) => p.startsWith(prefix) && p.length > prefix.length);
6474
+ }
6475
+ var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
6476
+ message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
6477
+ });
6478
+ var ManagedBlockRecordSchema = z4.object({
6479
+ path: ManagedHookBlockPath,
6480
+ marker: z4.string(),
6481
+ comment: z4.enum(["hash", "html"])
6482
+ });
6483
+ var ManagedManifestSchema = z4.object({
6484
+ version: z4.number().int().positive(),
6485
+ files: z4.array(SafeRepoRelPath),
6486
+ blocks: z4.array(ManagedBlockRecordSchema),
6487
+ labels: z4.array(z4.string()),
6488
+ agents: z4.array(z4.enum(AGENT_VENDORS)).optional()
6489
+ });
6490
+ var ProjectEntrySchema = z4.object({
6491
+ name: z4.string().min(1),
6492
+ description: z4.string().min(1).optional(),
6493
+ path: z4.string().min(1).optional()
6494
+ });
6495
+ function parseTokensCollectDeclaration(value) {
6496
+ const m = value.trim().match(/^(\S+)\s+(\S+)$/);
6497
+ if (!m)
6498
+ return null;
6499
+ const [, interpreter, script] = m;
6500
+ if (!isSafeRepoRelPath(script))
6501
+ return null;
6502
+ return { interpreter, script };
6503
+ }
6504
+ var VinayaConfigSchema = z4.object({
6505
+ rings: z4.object({
6506
+ ring1_forgeWriteInterception: z4.boolean(),
6507
+ ring2_asyncAudits: z4.boolean()
6508
+ }).optional(),
6509
+ checks: z4.record(z4.string(), CheckEntrySchema).optional(),
6510
+ roles: z4.record(z4.string(), RoleEntrySchema).optional(),
6511
+ briefSchema: BriefSchemaSchema.optional(),
6512
+ managed: ManagedManifestSchema.optional(),
6513
+ principals: z4.array(z4.string()).min(1).optional(),
6514
+ releaseActor: z4.string().min(1).optional(),
6515
+ ci: z4.object({ setup: z4.string().min(1) }).optional(),
6516
+ tokens: z4.object({
6517
+ collect: z4.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
6518
+ message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
6519
+ })
6520
+ }).optional(),
6521
+ blastRadius: z4.object({ extraDomains: z4.array(z4.string()).optional() }).optional(),
6522
+ proseGates: z4.object({
6523
+ doctrineRoot: z4.string().min(1).optional(),
6524
+ readerFacingPrefix: z4.string().min(1).optional(),
6525
+ readerFacingSuffix: z4.string().min(1).optional(),
6526
+ legacySlugDir: z4.string().min(1).optional(),
6527
+ sourceComments: z4.object({
6528
+ globs: z4.array(z4.string().min(1)).optional(),
6529
+ allowlist: z4.array(z4.string().min(1)).optional(),
6530
+ severity: z4.enum(["warning", "error"]).optional()
6531
+ }).optional(),
6532
+ specGrandfather: z4.array(z4.string().min(1)).optional(),
6533
+ specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6534
+ message: "must be a repository-relative path, not an absolute one"
6535
+ }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
6536
+ message: "must stay inside the repository — no `..` segment"
6537
+ })).optional()
6538
+ }).optional(),
6539
+ projects: z4.array(ProjectEntrySchema).optional(),
6540
+ dispatch: z4.object({
6541
+ timeoutMs: z4.number().int().positive().optional(),
6542
+ killGraceMs: z4.number().int().positive().optional(),
6543
+ agent: z4.enum(["claude", "codex", "gemini"]).optional(),
6544
+ requireWorkerIsolation: z4.boolean().optional()
6545
+ }).optional(),
6546
+ reviewPolicy: z4.object({
6547
+ codeReviewThreshold: z4.string().min(1).optional(),
6548
+ securityThreshold: z4.string().min(1).optional(),
6549
+ maxRounds: z4.number().optional()
6550
+ }).optional(),
6551
+ gateCutovers: z4.object({
6552
+ objectivesSinceIssue: z4.number().int().nonnegative().optional(),
6553
+ briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
6554
+ documentationSinceIssue: z4.number().int().nonnegative().optional(),
6555
+ briefRulesSincePr: z4.number().int().nonnegative().optional(),
6556
+ agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
6557
+ }).optional(),
6558
+ prePush: z4.object({
6559
+ alwaysRun: z4.array(z4.string()).optional()
6560
+ }).optional(),
6561
+ report: z4.object({
6562
+ commandTimeoutMs: z4.number().int().positive().optional()
6563
+ }).superRefine((report, ctx) => {
6564
+ const commandTimeoutMs = report.commandTimeoutMs;
6565
+ if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
6566
+ ctx.addIssue({
6567
+ code: z4.ZodIssueCode.custom,
6568
+ path: ["commandTimeoutMs"],
6569
+ message: "must be at most 3600000 (1 hour)"
6570
+ });
6571
+ }
6572
+ }).optional(),
6573
+ logPublish: z4.unknown().refine((v) => v === undefined, {
6574
+ message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
6575
+ }),
6576
+ runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6577
+ logs: z4.object({
6578
+ folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6579
+ url: z4.string().url().optional(),
6580
+ headers: z4.record(z4.string()).optional()
6581
+ }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
6582
+ message: "logs: set at most one of folder/url"
6583
+ }).refine((v) => v.headers === undefined || v.url !== undefined, {
6584
+ message: "logs: headers requires url"
6585
+ }).optional()
6586
+ });
6587
+ var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
6588
+ var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
6589
+ var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
6590
+ function findLocalConfig() {
6591
+ let dir = process.cwd();
6592
+ while (true) {
6593
+ const candidate = join(dir, LOCAL_CONFIG_FILENAME);
6594
+ if (existsSync(candidate))
6595
+ return candidate;
6596
+ if (existsSync(join(dir, ".git")))
6597
+ return null;
6598
+ const parent = dirname(dir);
6599
+ if (parent === dir)
6600
+ return null;
6601
+ dir = parent;
6602
+ }
6603
+ }
6604
+ function configPath() {
6605
+ const local = findLocalConfig();
6606
+ if (local)
6607
+ return local;
6608
+ if (existsSync(GLOBAL_CONFIG_PATH))
6609
+ return GLOBAL_CONFIG_PATH;
6610
+ return null;
6611
+ }
6612
+ function globalChecksIgnoredWarning(path) {
6613
+ return `${path}: "checks" registration in the global config is ignored — checks may only be registered from a repo-local vinaya.config.json.`;
6614
+ }
6615
+ function globalPrincipalsIgnoredWarning(path) {
6616
+ return `${path}: "principals" in the global config is ignored — principals may only be declared from a repo-local vinaya.config.json.`;
6617
+ }
6618
+ function globalRolesIgnoredWarning(path) {
6619
+ return `${path}: "roles" registration in the global config is ignored — roles may only be registered from a repo-local vinaya.config.json.`;
6620
+ }
6621
+ function globalReleaseActorIgnoredWarning(path) {
6622
+ return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
6623
+ }
6624
+ function globalTokensCollectIgnoredWarning(path) {
6625
+ return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
6626
+ }
6627
+ function globalRuntimeDirIgnoredWarning(path) {
6628
+ return `${path}: "runtimeDir" in the global config is ignored — it carries no repository segment, so a machine-wide value would collapse every repository's task folders into one tree. Declare it from a repo-local vinaya.config.json.`;
6629
+ }
6630
+ var emittedGlobalKeyWarnings = new Set;
6631
+ function warnGlobalKeyIgnoredOnce(message) {
6632
+ if (emittedGlobalKeyWarnings.has(message))
6633
+ return;
6634
+ emittedGlobalKeyWarnings.add(message);
6635
+ console.error(`⚠ ${message}`);
6636
+ }
6637
+ function stripGlobalOnlyKeys(config, path) {
6638
+ if (path !== GLOBAL_CONFIG_PATH)
6639
+ return config;
6640
+ let result = config;
6641
+ if (result.checks && Object.keys(result.checks).length > 0) {
6642
+ warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
6643
+ result = { ...result, checks: undefined };
6644
+ }
6645
+ if (result.roles && Object.keys(result.roles).length > 0) {
6646
+ warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
6647
+ result = { ...result, roles: undefined };
6648
+ }
6649
+ if (result.principals && result.principals.length > 0) {
6650
+ warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
6651
+ result = { ...result, principals: undefined };
6652
+ }
6653
+ if (result.releaseActor) {
6654
+ warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
6655
+ result = { ...result, releaseActor: undefined };
6656
+ }
6657
+ if (result.tokens) {
6658
+ warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
6659
+ result = { ...result, tokens: undefined };
6660
+ }
6661
+ if (result.runtimeDir) {
6662
+ warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
6663
+ result = { ...result, runtimeDir: undefined };
6664
+ }
6665
+ return result;
6666
+ }
6667
+ function resolvePrincipalAllowlist(config) {
6668
+ return config?.principals ?? PRINCIPAL_ALLOWLIST;
6669
+ }
6670
+ function resolveReleaseActor(config) {
6671
+ return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
6672
+ }
6673
+ function resolveReviewPolicy(config) {
6674
+ const raw = config?.reviewPolicy;
6675
+ if (!raw)
6676
+ return DEFAULT_REVIEW_POLICY;
6677
+ const codeReviewThreshold = raw.codeReviewThreshold ?? DEFAULT_REVIEW_POLICY.codeReviewThreshold;
6678
+ if (!isKnownSeverity(CODE_REVIEW_SEVERITY_ORDER, codeReviewThreshold)) {
6679
+ throw new Error(`vinaya.config.json: reviewPolicy.codeReviewThreshold "${codeReviewThreshold}" is not one of ${CODE_REVIEW_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
6680
+ }
6681
+ const securityThreshold = raw.securityThreshold ?? DEFAULT_REVIEW_POLICY.securityThreshold;
6682
+ if (!isKnownSeverity(SECURITY_SEVERITY_ORDER, securityThreshold)) {
6683
+ throw new Error(`vinaya.config.json: reviewPolicy.securityThreshold "${securityThreshold}" is not one of ${SECURITY_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
6684
+ }
6685
+ const maxRounds = raw.maxRounds ?? DEFAULT_REVIEW_POLICY.maxRounds;
6686
+ if (!Number.isInteger(maxRounds) || maxRounds < 1) {
6687
+ throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
6688
+ }
6689
+ return {
6690
+ codeReviewThreshold,
6691
+ securityThreshold,
6692
+ maxRounds
6693
+ };
6694
+ }
6695
+ function resolveGateCutovers(config) {
6696
+ const raw = config?.gateCutovers;
6697
+ if (!raw)
6698
+ return NO_GATE_CUTOVERS;
6699
+ return {
6700
+ objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
6701
+ briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
6702
+ documentationSinceIssue: raw.documentationSinceIssue ?? null,
6703
+ briefRulesSincePr: raw.briefRulesSincePr ?? null,
6704
+ agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
6705
+ };
6706
+ }
6707
+ function resolveRuntimeDirSetting(config) {
6708
+ return config?.runtimeDir ?? null;
6709
+ }
6710
+ function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
6711
+ const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
6712
+ return anchored !== null && anchored === localRuntimeDir ? anchored : null;
6713
+ }
6714
+ function resolveLogsSetting(config) {
6715
+ const raw = config?.logs;
6716
+ if (!raw)
6717
+ return null;
6718
+ if (raw.url !== undefined)
6719
+ return { url: raw.url, headers: raw.headers };
6720
+ if (raw.folder !== undefined)
6721
+ return { folder: raw.folder };
6722
+ return null;
6723
+ }
6724
+ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
6725
+ const anchored = resolveLogsSetting(trustAnchorConfig);
6726
+ if (!anchored)
6727
+ return null;
6728
+ if ("url" in local)
6729
+ return "url" in anchored && anchored.url === local.url ? anchored : null;
6730
+ return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
6731
+ }
6732
+ function resolveLogsHeaderValues(headers, env) {
6733
+ if (!headers)
6734
+ return;
6735
+ const resolved = {};
6736
+ for (const [key, value] of Object.entries(headers)) {
6737
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
6738
+ }
6739
+ return resolved;
6740
+ }
6741
+ function trustAnchorRepo() {
6742
+ const fromRunner = trustAnchorRepoFromRunner();
6743
+ if (fromRunner)
6744
+ return fromRunner;
6745
+ try {
6746
+ const url = execFileSync2("git", ["remote", "get-url", "origin"], {
6747
+ encoding: "utf-8",
6748
+ stdio: ["ignore", "pipe", "pipe"]
6749
+ });
6750
+ return trustAnchorRepoFromRemoteUrl(url);
6751
+ } catch {
6752
+ return null;
6753
+ }
6754
+ }
6755
+ async function trustAnchorRepoAsync() {
6756
+ const fromRunner = trustAnchorRepoFromRunner();
6757
+ if (fromRunner)
6758
+ return fromRunner;
6759
+ try {
6760
+ const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
6761
+ encoding: "utf-8",
6762
+ timeout: 1e4
6763
+ });
6764
+ return trustAnchorRepoFromRemoteUrl(stdout);
6765
+ } catch {
6766
+ return null;
6767
+ }
6768
+ }
6769
+ function wellFormedRepoSlug(slug) {
6770
+ return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
6771
+ }
6772
+ function trustAnchorRepoFromRunner() {
6773
+ const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
6774
+ return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
6775
+ }
6776
+ function trustAnchorRepoFromRemoteUrl(url) {
6777
+ const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
6778
+ return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
6779
+ }
6780
+ var execFileAsync4 = promisify4(execFile4);
6781
+ function resolveCiTrustAnchorProbeRef(env = process.env) {
6782
+ const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
6783
+ if (!ref)
6784
+ return null;
6785
+ if (env.GITHUB_ACTIONS !== "true")
6786
+ return null;
6787
+ if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
6788
+ return null;
6789
+ return ref;
6790
+ }
6791
+ function readTrustAnchorConfigAtRef(ref) {
6792
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
6793
+ encoding: "utf-8",
6794
+ stdio: ["ignore", "pipe", "pipe"],
6795
+ timeout: 1e4
6796
+ });
6797
+ return Buffer.from(raw, "utf-8").toString("base64");
6798
+ }
6799
+ function ghFetchTrustAnchorConfig() {
6800
+ const probeRef = resolveCiTrustAnchorProbeRef();
6801
+ if (probeRef)
6802
+ return readTrustAnchorConfigAtRef(probeRef);
6803
+ const repo = trustAnchorRepo();
6804
+ if (!repo)
6805
+ throw new Error("could not resolve repo identity for the trust-anchor read");
6806
+ return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
6807
+ encoding: "utf-8",
6808
+ stdio: ["ignore", "pipe", "pipe"]
6809
+ });
6810
+ }
6811
+ async function ghFetchTrustAnchorConfigAsync() {
6812
+ const probeRef = resolveCiTrustAnchorProbeRef();
6813
+ if (probeRef) {
6814
+ const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
6815
+ encoding: "utf-8",
6816
+ timeout: 1e4
6817
+ });
6818
+ return Buffer.from(stdout, "utf-8").toString("base64");
6819
+ }
6820
+ const repo = await trustAnchorRepoAsync();
6821
+ if (!repo)
6822
+ throw new Error("could not resolve repo identity for the trust-anchor read");
6823
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
6824
+ return stdout;
6825
+ }
6826
+ function firstLine(err) {
6827
+ return err?.message?.split(`
6828
+ `)[0] ?? "unknown error";
6829
+ }
6830
+ function isMissingFileError(err) {
6831
+ const stderr = err?.stderr;
6832
+ const haystack = [
6833
+ err?.message ?? "",
6834
+ typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
6835
+ ].join(`
6836
+ `);
6837
+ return /\b404\b|not found/i.test(haystack);
6838
+ }
6839
+ function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
6840
+ let base64;
6841
+ try {
6842
+ base64 = fetcher();
6843
+ } catch (err) {
6844
+ return trustAnchorFetchFailed(err);
6845
+ }
6846
+ return parseTrustAnchorContent(base64);
6847
+ }
6848
+ async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
6849
+ const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
6850
+ let base64;
6851
+ try {
6852
+ base64 = await fetcher();
6853
+ } catch (err) {
6854
+ return trustAnchorFetchFailed(err, warn);
6855
+ }
6856
+ return parseTrustAnchorContent(base64, warn);
6857
+ }
6858
+ function warnTrustAnchorFallback(why) {
6859
+ process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
6860
+ `);
6861
+ }
6862
+ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
6863
+ if (!isMissingFileError(err))
6864
+ warn(firstLine(err));
6865
+ return null;
6866
+ }
6867
+ function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
6868
+ const base64 = content.trim();
6869
+ if (!base64)
6870
+ return null;
6871
+ try {
6872
+ const raw = Buffer.from(base64, "base64").toString("utf-8");
6873
+ const parsed = VinayaConfigSchema.safeParse(JSON.parse(raw));
6874
+ if (parsed.success)
6875
+ return parsed.data;
6876
+ warn("it did not satisfy the config schema");
6877
+ return null;
6878
+ } catch {
6879
+ warn("it was not readable as JSON");
6880
+ return null;
6881
+ }
6882
+ }
6883
+ function loadConfig() {
6884
+ const path = configPath();
6885
+ if (!path)
6886
+ return null;
6887
+ try {
6888
+ const raw = JSON.parse(readFileSync2(path, "utf-8"));
6889
+ return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
6890
+ } catch {
6891
+ return null;
6892
+ }
6893
+ }
6894
+ var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
6895
+
6320
6896
  // src/checks/issue-check-env.ts
6321
6897
  function nullIfEmpty(value) {
6322
6898
  return value && value.length > 0 ? value : null;
@@ -6341,7 +6917,8 @@ function main() {
6341
6917
  const { body, issueNumber } = readIssueCheckEnv();
6342
6918
  if (!body)
6343
6919
  process.exit(0);
6344
- const result = checkIssueObjectives(body, issueNumber);
6920
+ const { objectivesSinceIssue } = resolveGateCutovers(loadConfig());
6921
+ const result = checkIssueObjectives(body, issueNumber, objectivesSinceIssue);
6345
6922
  if (result.status === "pass")
6346
6923
  process.exit(0);
6347
6924
  for (const message of result.errors) {