@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
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/checks/bin/check-doc-coverage-push.ts
4
- import { execFileSync as execFileSync6 } from "node:child_process";
5
- import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
4
+ import { execFileSync as execFileSync7 } from "node:child_process";
5
+ import { existsSync as existsSync8, readFileSync as readFileSync7 } from "node:fs";
6
6
  // ../../packages/aeg-core/src/gate-audience.ts
7
7
  var GATE_AUDIENCE = {
8
8
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -197,8 +197,8 @@ function maskIndentedCode(body, fill) {
197
197
  var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
198
198
  var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
199
199
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
200
- var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
201
- var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
200
+ var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+$/i;
201
+ var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+)$/i;
202
202
  function splitSlugQualifiedEdge(edge) {
203
203
  const m = edge.trim().match(SLUG_QUALIFIED_ID);
204
204
  if (!m)
@@ -2619,7 +2619,7 @@ function isIssueNotFoundError(err) {
2619
2619
  return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
2620
2620
  }
2621
2621
  function resolveObjectivesSource(prBody, issue, cutoverIssue) {
2622
- if (issue !== null && issue < cutoverIssue)
2622
+ if (issue !== null && cutoverIssue !== null && issue < cutoverIssue)
2623
2623
  return { kind: "none" };
2624
2624
  if (issue !== null)
2625
2625
  return { kind: "issue", issue };
@@ -2895,9 +2895,18 @@ var COMMIT_TYPES = [
2895
2895
  ];
2896
2896
  var COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join("|")})(\\([a-z0-9-]+\\))?: \\S`);
2897
2897
  function checkForgeTitle(title) {
2898
- const taskStyle = /^\[[a-z0-9._-]+\] \S+ — \S/;
2898
+ const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/;
2899
2899
  if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title))
2900
2900
  return { status: "pass", errors: [] };
2901
+ const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title);
2902
+ if (letteredTaskId) {
2903
+ return {
2904
+ status: "fail",
2905
+ errors: [
2906
+ `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.`
2907
+ ]
2908
+ };
2909
+ }
2901
2910
  return {
2902
2911
  status: "fail",
2903
2912
  errors: [
@@ -2930,19 +2939,31 @@ function checkNoAgentBoxes(prBody) {
2930
2939
  ]
2931
2940
  };
2932
2941
  }
2933
- function rolloutThresholdFor(message) {
2942
+ function rolloutRuleFor(message) {
2934
2943
  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:")) {
2935
- return BRIEF_RULES_SINCE_PR;
2944
+ return "briefRules";
2936
2945
  }
2937
2946
  if (message.startsWith("brief-validation no agent boxes:"))
2938
- return AGENT_BOXES_REFUSED_SINCE_PR;
2947
+ return "agentBoxes";
2939
2948
  return null;
2940
2949
  }
2941
- function partitionBriefErrorsByRollout(errors, prNumber) {
2950
+ var DEFAULT_BRIEF_ROLLOUT_CUTOVERS = {
2951
+ briefRulesSincePr: BRIEF_RULES_SINCE_PR,
2952
+ agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
2953
+ };
2954
+ function rolloutThresholdFor(message, cutovers) {
2955
+ const rule = rolloutRuleFor(message);
2956
+ if (rule === "briefRules")
2957
+ return cutovers.briefRulesSincePr;
2958
+ if (rule === "agentBoxes")
2959
+ return cutovers.agentBoxesRefusedSincePr;
2960
+ return null;
2961
+ }
2962
+ function partitionBriefErrorsByRollout(errors, prNumber, cutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS) {
2942
2963
  const blocking = [];
2943
2964
  const info = [];
2944
2965
  for (const e of errors) {
2945
- const threshold = rolloutThresholdFor(e);
2966
+ const threshold = rolloutThresholdFor(e, cutovers);
2946
2967
  const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold;
2947
2968
  (grandfathered ? info : blocking).push(e);
2948
2969
  }
@@ -3410,8 +3431,8 @@ function checkIssueRationale(body) {
3410
3431
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3411
3432
  }
3412
3433
  var OBJECTIVES_SINCE_ISSUE = 404;
3413
- function checkIssueObjectives(body, issueNumber) {
3414
- if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE)
3434
+ function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3435
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3415
3436
  return { status: "pass", errors: [] };
3416
3437
  const result = objectivesOf(body);
3417
3438
  if (result.ok)
@@ -3856,7 +3877,7 @@ function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
3856
3877
  return issueToEntry.get(Number(issueMatch[1]));
3857
3878
  return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
3858
3879
  }
3859
- function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3880
+ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
3860
3881
  const failures = [];
3861
3882
  for (const [slug, issues] of issuesBySlug) {
3862
3883
  for (const issue of issues) {
@@ -3865,7 +3886,7 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3865
3886
  const errors = [
3866
3887
  ...checkIssueRationale(issue.body).errors,
3867
3888
  ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
3868
- ...checkIssueObjectives(issue.body, issue.number).errors,
3889
+ ...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
3869
3890
  ...checkPartsCiteDefinedObjectives(issue.body).errors
3870
3891
  ];
3871
3892
  if (errors.length === 0)
@@ -4488,13 +4509,27 @@ var SHIPS_PREFIX = "aeg-root/";
4488
4509
  function shipsArchivePrefix(shipsPrefix) {
4489
4510
  return `${shipsPrefix}tranches/completed/`;
4490
4511
  }
4491
- function isSpecFile2(path) {
4492
- return path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md");
4512
+ var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
4513
+ function normalizeSpecPath(entry) {
4514
+ let out = entry.replace(/\\/g, "/");
4515
+ while (out.startsWith("./"))
4516
+ out = out.slice(2);
4517
+ out = out.replace(/\/{2,}/g, "/");
4518
+ while (out.endsWith("/"))
4519
+ out = out.slice(0, -1);
4520
+ return out;
4521
+ }
4522
+ function isSpecFile2(path, specPaths) {
4523
+ if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
4524
+ return true;
4525
+ if (!path.endsWith(".md"))
4526
+ return false;
4527
+ return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
4493
4528
  }
4494
4529
  function isClaudeMdFile(path) {
4495
4530
  return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
4496
4531
  }
4497
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4532
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
4498
4533
  if (path.startsWith(shipsPrefix)) {
4499
4534
  return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
4500
4535
  }
@@ -4503,7 +4538,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
4503
4538
  }
4504
4539
  if (isClaudeMdFile(path))
4505
4540
  return "internal";
4506
- if (isSpecFile2(path))
4541
+ if (isSpecFile2(path, specPaths))
4507
4542
  return "spec";
4508
4543
  if (isProductScopeFile(path))
4509
4544
  return "product";
@@ -4532,13 +4567,14 @@ function lineAt(content, index) {
4532
4567
  }
4533
4568
  var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
4534
4569
  var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
4570
+ var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
4535
4571
  function legacySlugPattern(legacySlugs) {
4536
4572
  if (legacySlugs.length === 0)
4537
4573
  return null;
4538
4574
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
4539
4575
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
4540
4576
  }
4541
- function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4577
+ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4542
4578
  const findings = [];
4543
4579
  const legacyPattern = legacySlugPattern(legacySlugs);
4544
4580
  const grandfathered = new Set(specGrandfather);
@@ -4550,8 +4586,12 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4550
4586
  const productPatterns = [
4551
4587
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4552
4588
  ];
4589
+ const specPatterns = [
4590
+ ...patterns,
4591
+ { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
4592
+ ];
4553
4593
  for (const file of files) {
4554
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4594
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
4555
4595
  if (!cls || cls === "internal")
4556
4596
  continue;
4557
4597
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
@@ -4560,15 +4600,16 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4560
4600
  continue;
4561
4601
  const blocking = cls === "product" || cls === "spec";
4562
4602
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4563
- const patternsToRun = cls === "product" ? productPatterns : patterns;
4603
+ const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
4564
4604
  for (const { pattern, what, group } of patternsToRun) {
4565
4605
  pattern.lastIndex = 0;
4566
4606
  let match = pattern.exec(scrubbed);
4567
4607
  while (match !== null) {
4568
4608
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
4609
+ const citedIndex = match.index + match[0].indexOf(cited);
4569
4610
  findings.push({
4570
4611
  file: file.path,
4571
- line: lineAt(scrubbed, match.index),
4612
+ line: lineAt(scrubbed, citedIndex),
4572
4613
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4573
4614
  blocking
4574
4615
  });
@@ -4754,9 +4795,9 @@ function checkSourceComments(files, allowlist = []) {
4754
4795
  }
4755
4796
  return findings;
4756
4797
  }
4757
- function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4798
+ function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4758
4799
  return [
4759
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather),
4800
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
4760
4801
  ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4761
4802
  ];
4762
4803
  }
@@ -5221,7 +5262,8 @@ var TaskStatusItemSchema = z.object({
5221
5262
  }).merge(ObservedSchema);
5222
5263
  var TaskStatusResultSchema = z.object({
5223
5264
  items: z.array(TaskStatusItemSchema),
5224
- nextCursor: z.string().nullable()
5265
+ nextCursor: z.string().nullable(),
5266
+ table: z.string()
5225
5267
  });
5226
5268
  var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
5227
5269
  var EscalationInputsSchema = z.object({
@@ -5565,6 +5607,14 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5565
5607
  }
5566
5608
  return findings;
5567
5609
  }
5610
+ // ../../packages/aeg-core/src/gate-cutovers.ts
5611
+ var NO_GATE_CUTOVERS = {
5612
+ objectivesSinceIssue: null,
5613
+ briefSectionsSinceIssue: null,
5614
+ documentationSinceIssue: null,
5615
+ briefRulesSincePr: null,
5616
+ agentBoxesRefusedSincePr: null
5617
+ };
5568
5618
  // ../../packages/aeg-core/src/dev-review-loop/types.ts
5569
5619
  var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5570
5620
  // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
@@ -6014,6 +6064,8 @@ function attemptFromEnv(value) {
6014
6064
  function provenanceFor(input) {
6015
6065
  if (input.provenance)
6016
6066
  return input.provenance;
6067
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
6068
+ return "unavailable";
6017
6069
  if (input.env.role || input.env.task)
6018
6070
  return "env_correlated";
6019
6071
  return "unavailable";
@@ -6034,7 +6086,7 @@ function buildHeader(input) {
6034
6086
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6035
6087
  const round = roundFromEnv(input.env.round);
6036
6088
  const subject = {
6037
- issue: issueFromTask(input.env.task),
6089
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6038
6090
  role,
6039
6091
  ...round !== undefined ? { round } : {},
6040
6092
  ...input.subject ?? {}
@@ -6315,8 +6367,8 @@ var ResolutionRecordSchema = z3.object({
6315
6367
  consumedAt: isoTimestamp
6316
6368
  }).strict();
6317
6369
  // src/lib/diff-evidence.ts
6318
- import { execFileSync as execFileSync5 } from "node:child_process";
6319
- import { join as join8, relative, resolve as resolve2 } from "node:path";
6370
+ import { execFileSync as execFileSync6 } from "node:child_process";
6371
+ import { join as join9, relative, resolve as resolve2 } from "node:path";
6320
6372
 
6321
6373
  // src/lib/config.ts
6322
6374
  import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
@@ -6478,7 +6530,12 @@ var VinayaConfigSchema = z4.object({
6478
6530
  allowlist: z4.array(z4.string().min(1)).optional(),
6479
6531
  severity: z4.enum(["warning", "error"]).optional()
6480
6532
  }).optional(),
6481
- specGrandfather: z4.array(z4.string().min(1)).optional()
6533
+ specGrandfather: z4.array(z4.string().min(1)).optional(),
6534
+ specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6535
+ message: "must be a repository-relative path, not an absolute one"
6536
+ }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
6537
+ message: "must stay inside the repository — no `..` segment"
6538
+ })).optional()
6482
6539
  }).optional(),
6483
6540
  projects: z4.array(ProjectEntrySchema).optional(),
6484
6541
  dispatch: z4.object({
@@ -6492,6 +6549,13 @@ var VinayaConfigSchema = z4.object({
6492
6549
  securityThreshold: z4.string().min(1).optional(),
6493
6550
  maxRounds: z4.number().optional()
6494
6551
  }).optional(),
6552
+ gateCutovers: z4.object({
6553
+ objectivesSinceIssue: z4.number().int().nonnegative().optional(),
6554
+ briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
6555
+ documentationSinceIssue: z4.number().int().nonnegative().optional(),
6556
+ briefRulesSincePr: z4.number().int().nonnegative().optional(),
6557
+ agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
6558
+ }).optional(),
6495
6559
  prePush: z4.object({
6496
6560
  alwaysRun: z4.array(z4.string()).optional()
6497
6561
  }).optional(),
@@ -6629,6 +6693,18 @@ function resolveReviewPolicy(config) {
6629
6693
  maxRounds
6630
6694
  };
6631
6695
  }
6696
+ function resolveGateCutovers(config) {
6697
+ const raw = config?.gateCutovers;
6698
+ if (!raw)
6699
+ return NO_GATE_CUTOVERS;
6700
+ return {
6701
+ objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
6702
+ briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
6703
+ documentationSinceIssue: raw.documentationSinceIssue ?? null,
6704
+ briefRulesSincePr: raw.briefRulesSincePr ?? null,
6705
+ agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
6706
+ };
6707
+ }
6632
6708
  function resolveRuntimeDirSetting(config) {
6633
6709
  return config?.runtimeDir ?? null;
6634
6710
  }
@@ -6819,9 +6895,9 @@ function loadConfig() {
6819
6895
  var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
6820
6896
 
6821
6897
  // src/lib/brief-assembly.ts
6822
- import { execFileSync as execFileSync4 } from "node:child_process";
6823
- import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "node:fs";
6824
- import { join as join3 } from "node:path";
6898
+ import { execFileSync as execFileSync5 } from "node:child_process";
6899
+ import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
6900
+ import { join as join4 } from "node:path";
6825
6901
 
6826
6902
  // ../../packages/sources/src/commands.ts
6827
6903
  var COMMANDS = [
@@ -7327,6 +7403,10 @@ var COMMANDS = [
7327
7403
  flag: "--role <name>",
7328
7404
  description: "Resolve to a specific role file (roles/<name>.md) instead of the front door"
7329
7405
  },
7406
+ {
7407
+ flag: "--template <name>",
7408
+ description: "Print a template the package ships (templates/<name>-template.md) instead of the front door"
7409
+ },
7330
7410
  {
7331
7411
  flag: "--print",
7332
7412
  description: "Emit the resolved file's body (frontmatter stripped) instead of its path — the one-hop mode every generated skill and slash command invokes. A role file whose frontmatter carries an `ack-token` emits that token as the output's own first line."
@@ -7662,13 +7742,47 @@ function packageRoot(moduleUrl) {
7662
7742
  return dir;
7663
7743
  }
7664
7744
 
7745
+ // src/commands/doctrine.ts
7746
+ import { execFileSync as execFileSync4 } from "node:child_process";
7747
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
7748
+ import { dirname as dirname3, join as join3, sep } from "node:path";
7749
+ import matter2 from "gray-matter";
7750
+ var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
7751
+ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7752
+ return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
7753
+ }
7754
+ function gitToplevel(cwd) {
7755
+ try {
7756
+ return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
7757
+ encoding: "utf8",
7758
+ stdio: ["ignore", "pipe", "pipe"]
7759
+ }).trim();
7760
+ } catch {
7761
+ return null;
7762
+ }
7763
+ }
7764
+ function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7765
+ const toplevel = gitToplevel(cwd);
7766
+ if (toplevel !== null) {
7767
+ const treeRoot = join3(toplevel, "aeg-root");
7768
+ if (existsSync3(join3(treeRoot, "roles")))
7769
+ return { root: treeRoot, source: "tree" };
7770
+ }
7771
+ const fromSource = !pkg.split(sep).includes("node_modules");
7772
+ const bundleRoot = fromSource ? join3(dirname3(dirname3(pkg)), "aeg-root") : join3(pkg, "aeg-root");
7773
+ return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
7774
+ }
7775
+ function hasDoctrineEntry(root) {
7776
+ return existsSync3(join3(root, ...ENTRY_SEGMENTS));
7777
+ }
7778
+
7665
7779
  // src/lib/brief-assembly.ts
7666
7780
  var PACKAGE_ROOT = packageRoot(import.meta.url);
7667
- var PACKAGED_TEMPLATE_PATH = join3(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
7668
- var TEMPLATE_PATH = existsSync3(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join3(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7781
+ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
7782
+ var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7669
7783
  function git(args) {
7670
7784
  try {
7671
- return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7785
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7672
7786
  } catch {
7673
7787
  return "";
7674
7788
  }
@@ -7681,14 +7795,14 @@ function expandGlob(glob) {
7681
7795
  var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7682
7796
 
7683
7797
  // src/checks/registry.ts
7684
- import { existsSync as existsSync4 } from "node:fs";
7685
- import { join as join4 } from "node:path";
7686
- var DIST_BIN_DIR = join4(packageRoot(import.meta.url), "dist", "checks", "bin");
7687
- var SRC_BIN_DIR = join4(packageRoot(import.meta.url), "src", "checks", "bin");
7688
- var BIN_DIR = existsSync4(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7798
+ import { existsSync as existsSync5 } from "node:fs";
7799
+ import { join as join5 } from "node:path";
7800
+ var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
7801
+ var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
7802
+ var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7689
7803
  var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
7690
7804
  function bin(name) {
7691
- return join4(BIN_DIR, `${name}${BIN_EXT}`);
7805
+ return join5(BIN_DIR, `${name}${BIN_EXT}`);
7692
7806
  }
7693
7807
  var REGISTRY = [
7694
7808
  [
@@ -8252,21 +8366,21 @@ import { randomUUID as randomUUID2 } from "node:crypto";
8252
8366
  import {
8253
8367
  closeSync as closeSync3,
8254
8368
  constants as fsConstants3,
8255
- existsSync as existsSync6,
8369
+ existsSync as existsSync7,
8256
8370
  fstatSync as fstatSync2,
8257
8371
  mkdirSync as mkdirSync3,
8258
8372
  openSync as openSync3,
8259
- readFileSync as readFileSync5,
8373
+ readFileSync as readFileSync6,
8260
8374
  renameSync as renameSync2,
8261
8375
  writeSync as writeSync2
8262
8376
  } from "node:fs";
8263
8377
  import { hostname as osHostname, homedir as homedir3 } from "node:os";
8264
- import { dirname as dirname5, join as join7 } from "node:path";
8378
+ import { dirname as dirname6, join as join8 } from "node:path";
8265
8379
  import { promisify as promisify5 } from "node:util";
8266
8380
 
8267
8381
  // src/lib/run-paths.ts
8268
- import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
8269
- import { dirname as dirname3, join as join5, resolve as resolvePath } from "node:path";
8382
+ import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
8383
+ import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
8270
8384
  var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8271
8385
  function isSafeRepoSegment(segment) {
8272
8386
  return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
@@ -8277,7 +8391,7 @@ function repoSegment(repo) {
8277
8391
  return `${repo.owner}-${repo.repo}`;
8278
8392
  }
8279
8393
  function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
8280
- return join5(home, "runtime", repoSegment(repo));
8394
+ return join6(home, "runtime", repoSegment(repo));
8281
8395
  }
8282
8396
  function resolveRuntimeDir(input) {
8283
8397
  const local = resolveRuntimeDirSetting(input.localConfig);
@@ -8337,9 +8451,9 @@ function repoRootSync(start = process.cwd()) {
8337
8451
  return null;
8338
8452
  }
8339
8453
  for (;; ) {
8340
- if (existsSync5(join5(dir, ".git")))
8454
+ if (existsSync6(join6(dir, ".git")))
8341
8455
  return dir;
8342
- const parent = dirname3(dir);
8456
+ const parent = dirname4(dir);
8343
8457
  if (parent === dir)
8344
8458
  return null;
8345
8459
  dir = parent;
@@ -8354,7 +8468,7 @@ import {
8354
8468
  mkdirSync as mkdirSync2,
8355
8469
  openSync as openSync2,
8356
8470
  linkSync,
8357
- readFileSync as readFileSync4,
8471
+ readFileSync as readFileSync5,
8358
8472
  renameSync,
8359
8473
  statSync,
8360
8474
  unlinkSync,
@@ -8364,7 +8478,7 @@ import {
8364
8478
  } from "node:fs";
8365
8479
  import { randomUUID } from "node:crypto";
8366
8480
  import { homedir as homedir2 } from "node:os";
8367
- import { dirname as dirname4, join as join6 } from "node:path";
8481
+ import { dirname as dirname5, join as join7 } from "node:path";
8368
8482
  var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
8369
8483
  var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
8370
8484
  var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
@@ -8380,7 +8494,7 @@ function isEnoent(err) {
8380
8494
  var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
8381
8495
  function tryCreateLock(lockPath, token) {
8382
8496
  try {
8383
- mkdirSync2(dirname4(lockPath), { recursive: true, mode: 448 });
8497
+ mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
8384
8498
  const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
8385
8499
  try {
8386
8500
  writeSync(fd, `${token}
@@ -8445,7 +8559,7 @@ function acquireDrainLock(lockPath) {
8445
8559
  function renewDrainLock(lockPath, token) {
8446
8560
  let holder;
8447
8561
  try {
8448
- holder = readFileSync4(lockPath, "utf8").trim();
8562
+ holder = readFileSync5(lockPath, "utf8").trim();
8449
8563
  } catch (err) {
8450
8564
  if (!isEnoent(err))
8451
8565
  throw err;
@@ -8465,7 +8579,7 @@ function renewDrainLock(lockPath, token) {
8465
8579
  }
8466
8580
  function releaseDrainLock(lockPath, token) {
8467
8581
  try {
8468
- const holder = readFileSync4(lockPath, "utf8").trim();
8582
+ const holder = readFileSync5(lockPath, "utf8").trim();
8469
8583
  if (holder !== token)
8470
8584
  return;
8471
8585
  unlinkSync(lockPath);
@@ -8515,7 +8629,7 @@ function queueLines(buf) {
8515
8629
  return lines;
8516
8630
  }
8517
8631
  function removeQueueHead(path, cut) {
8518
- const remaining = readFileSync4(path);
8632
+ const remaining = readFileSync5(path);
8519
8633
  writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
8520
8634
  }
8521
8635
  function queueBucketSize(path) {
@@ -8536,7 +8650,7 @@ function queueBucketSize(path) {
8536
8650
  function readQueueFile(path) {
8537
8651
  if (queueBucketSize(path) === null)
8538
8652
  return null;
8539
- return readFileSync4(path);
8653
+ return readFileSync5(path);
8540
8654
  }
8541
8655
  function rejectLine(rejectedPath, reason, status, identity, raw) {
8542
8656
  const record = JSON.stringify({
@@ -8651,7 +8765,7 @@ async function drainRenamedAside(args, livePath, source) {
8651
8765
  async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
8652
8766
  const resolved = await resolveRepo();
8653
8767
  const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
8654
- const outboxRoot = () => join6(GLOBAL_VINAYA_HOME, "outbox");
8768
+ const outboxRoot = () => join7(GLOBAL_VINAYA_HOME, "outbox");
8655
8769
  const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
8656
8770
  const lockPath = `${path}.flush-lock`;
8657
8771
  const lockToken = acquireDrainLock(lockPath);
@@ -8763,7 +8877,7 @@ async function defaultResolveLogDestination(repo, env) {
8763
8877
  trustAnchorConfig: unattended ? await processTrustAnchor() : null,
8764
8878
  unattended,
8765
8879
  env,
8766
- defaultFolder: join7(await runtimeDirForRepoAsync(repo), "logs"),
8880
+ defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
8767
8881
  repoRoot: repoRootSync()
8768
8882
  });
8769
8883
  }
@@ -8778,7 +8892,7 @@ async function resolveDoctrine(cwd, vinayaVersion) {
8778
8892
  } catch (err) {
8779
8893
  return isEnoent2(err) ? "unknown" : vinayaVersion;
8780
8894
  }
8781
- if (!existsSync6(join7(toplevel, "aeg-root", "roles")))
8895
+ if (!existsSync7(join8(toplevel, "aeg-root", "roles")))
8782
8896
  return vinayaVersion;
8783
8897
  try {
8784
8898
  const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
@@ -8787,9 +8901,99 @@ async function resolveDoctrine(cwd, vinayaVersion) {
8787
8901
  return vinayaVersion;
8788
8902
  }
8789
8903
  }
8904
+ var TRANCHE_SLUG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
8905
+ function taskRefFromBranch2(branch) {
8906
+ const backlog = /^task\/issue-(\d+)$/.exec(branch);
8907
+ if (backlog) {
8908
+ const issue = Number(backlog[1]);
8909
+ return Number.isSafeInteger(issue) && issue > 0 ? { kind: "issue", issue } : null;
8910
+ }
8911
+ const tranche = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
8912
+ if (tranche && TRANCHE_SLUG_PATTERN.test(tranche[1] ?? "")) {
8913
+ return { kind: "tranche", tranche: tranche[1], taskId: tranche[2] };
8914
+ }
8915
+ return null;
8916
+ }
8917
+ var TRANCHE_ISSUE_LIST_LIMIT = 200;
8918
+ async function issueForTrancheTask(tranche, taskId, cwd, repo) {
8919
+ let stdout;
8920
+ try {
8921
+ ({ stdout } = await execFileAsync5("gh", [
8922
+ "issue",
8923
+ "list",
8924
+ "--state",
8925
+ "all",
8926
+ "--label",
8927
+ `vinaya/tranche:${tranche}`,
8928
+ "--json",
8929
+ "number,title,labels",
8930
+ "--limit",
8931
+ String(TRANCHE_ISSUE_LIST_LIMIT),
8932
+ ...repo === null ? [] : ["--repo", repo]
8933
+ ], {
8934
+ cwd,
8935
+ encoding: "utf8",
8936
+ maxBuffer: 8 * 1024 * 1024,
8937
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8938
+ killSignal: "SIGKILL"
8939
+ }));
8940
+ } catch {
8941
+ return null;
8942
+ }
8943
+ let issues;
8944
+ try {
8945
+ issues = JSON.parse(stdout);
8946
+ } catch {
8947
+ return null;
8948
+ }
8949
+ for (const issue of issues) {
8950
+ const ref = resolveTaskIssueRef(issue.title, issue.labels.map((l) => l.name));
8951
+ if (ref && ref.trancheSlug === tranche && ref.taskId === taskId)
8952
+ return issue.number;
8953
+ }
8954
+ return null;
8955
+ }
8956
+ async function confirmBacklogIssue(issue, cwd, repo) {
8957
+ let stdout;
8958
+ try {
8959
+ ({ stdout } = await execFileAsync5("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
8960
+ cwd,
8961
+ encoding: "utf8",
8962
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8963
+ killSignal: "SIGKILL"
8964
+ }));
8965
+ } catch (err) {
8966
+ const stderr = typeof err.stderr === "string" ? err.stderr : "";
8967
+ return /could not resolve|not found|no such|does not exist/i.test(stderr) ? "denied" : "unknown";
8968
+ }
8969
+ try {
8970
+ return JSON.parse(stdout).number === issue ? "confirmed" : "denied";
8971
+ } catch {
8972
+ return "unknown";
8973
+ }
8974
+ }
8975
+ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
8976
+ let branch;
8977
+ try {
8978
+ branch = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
8979
+ encoding: "utf8",
8980
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8981
+ killSignal: "SIGKILL"
8982
+ })).stdout.trim();
8983
+ } catch {
8984
+ return null;
8985
+ }
8986
+ const named = branch === "HEAD" ? env.GITHUB_HEAD_REF ?? "" : branch;
8987
+ const ref = taskRefFromBranch2(named);
8988
+ if (ref === null)
8989
+ return null;
8990
+ if (ref.kind === "tranche")
8991
+ return await issueForTrancheTask(ref.tranche, ref.taskId, cwd, repo);
8992
+ return await confirmBacklogIssue(ref.issue, cwd, repo) === "denied" ? null : ref.issue;
8993
+ }
8790
8994
  function readVinayaVersion() {
8791
8995
  try {
8792
- const pkg = JSON.parse(readFileSync5(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
8996
+ const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
8793
8997
  return pkg.version ?? "unknown";
8794
8998
  } catch {
8795
8999
  return "unknown";
@@ -8799,10 +9003,15 @@ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8799
9003
  function isSafeRepoSegment3(segment) {
8800
9004
  return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
8801
9005
  }
9006
+ function safeRepoSlug(repo) {
9007
+ if (repo === null)
9008
+ return null;
9009
+ return isSafeRepoSegment3(repo.owner) && isSafeRepoSegment3(repo.repo) ? `${repo.owner}/${repo.repo}` : null;
9010
+ }
8802
9011
  function outboxPathFor(deps, repo, issue) {
8803
9012
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
8804
9013
  const fileName = `${issue ?? "none"}.ndjson`;
8805
- return join7(deps.outboxRoot(), dirName, fileName);
9014
+ return join8(deps.outboxRoot(), dirName, fileName);
8806
9015
  }
8807
9016
  function hostFromEnv(env) {
8808
9017
  if (env.GITHUB_ACTIONS)
@@ -8820,9 +9029,21 @@ function defaultStderr(message) {
8820
9029
  warnedThisProcess = true;
8821
9030
  process.stderr.write(message);
8822
9031
  }
9032
+ var branchIssueFallbackEnabled = true;
9033
+ var branchIssueByCwd = new Map;
9034
+ function branchIssueRead(key, read, shared) {
9035
+ if (!shared)
9036
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9037
+ const cached = branchIssueByCwd.get(key);
9038
+ if (cached !== undefined)
9039
+ return cached;
9040
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9041
+ branchIssueByCwd.set(key, reading);
9042
+ return reading;
9043
+ }
8823
9044
  function defaultDeps() {
8824
9045
  return {
8825
- outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
9046
+ outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
8826
9047
  home: () => homedir3(),
8827
9048
  hostname: () => osHostname(),
8828
9049
  cwd: () => process.cwd(),
@@ -8847,7 +9068,7 @@ function guardedAppendOpen(path) {
8847
9068
  }
8848
9069
  function appendHardenedLine(path, line) {
8849
9070
  try {
8850
- mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
9071
+ mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
8851
9072
  const fd = guardedAppendOpen(path);
8852
9073
  if (fd === undefined)
8853
9074
  return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
@@ -8866,7 +9087,7 @@ function appendHardenedLine(path, line) {
8866
9087
  function reportRotationOverflow(backupPath, warn) {
8867
9088
  let raw;
8868
9089
  try {
8869
- raw = readFileSync5(backupPath, "utf8");
9090
+ raw = readFileSync6(backupPath, "utf8");
8870
9091
  } catch {
8871
9092
  return;
8872
9093
  }
@@ -8889,7 +9110,7 @@ function reportRotationOverflow(backupPath, warn) {
8889
9110
  }
8890
9111
  function appendLine(path, line, warn) {
8891
9112
  try {
8892
- mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
9113
+ mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
8893
9114
  let fd = guardedAppendOpen(path);
8894
9115
  if (fd === undefined) {
8895
9116
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -8930,7 +9151,11 @@ function appendLine(path, line, warn) {
8930
9151
  }
8931
9152
  }
8932
9153
  function createLogSink(overrides = {}) {
8933
- const deps = { ...defaultDeps(), ...overrides };
9154
+ const deps = {
9155
+ ...defaultDeps(),
9156
+ resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
9157
+ ...overrides
9158
+ };
8934
9159
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
8935
9160
  const processId = randomUUID2();
8936
9161
  let seq = 0;
@@ -8950,6 +9175,19 @@ function createLogSink(overrides = {}) {
8950
9175
  }
8951
9176
  return doctrineCache;
8952
9177
  };
9178
+ const readerIsReal = overrides.resolveBranchIssue === undefined;
9179
+ let ownBranchIssue;
9180
+ const branchIssueOnce = (repo) => {
9181
+ if (!branchIssueFallbackEnabled)
9182
+ return Promise.resolve(null);
9183
+ const slug = safeRepoSlug(repo);
9184
+ const read = () => deps.resolveBranchIssue(slug);
9185
+ if (readerIsReal)
9186
+ return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
9187
+ if (ownBranchIssue === undefined)
9188
+ ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
9189
+ return ownBranchIssue;
9190
+ };
8953
9191
  let resolveRepoCache;
8954
9192
  const resolveRepoOnce = () => {
8955
9193
  if (resolveRepoCache === undefined)
@@ -8972,6 +9210,7 @@ function createLogSink(overrides = {}) {
8972
9210
  };
8973
9211
  let drainChain = Promise.resolve();
8974
9212
  const pendingWrites = new Set;
9213
+ let writeChain = Promise.resolve();
8975
9214
  const scheduleWebhookDrain = (issue, url, headers) => {
8976
9215
  drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
8977
9216
  return;
@@ -8994,7 +9233,14 @@ function createLogSink(overrides = {}) {
8994
9233
  attempt: env.VINAYA_ATTEMPT,
8995
9234
  parent: env.VINAYA_PARENT_EVENT
8996
9235
  };
8997
- const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
9236
+ const write = async () => {
9237
+ const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
9238
+ if (resolvedDestination.kind === "none") {
9239
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9240
+ `);
9241
+ return;
9242
+ }
9243
+ const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
8998
9244
  const header = buildHeader({
8999
9245
  now,
9000
9246
  runId,
@@ -9005,15 +9251,11 @@ function createLogSink(overrides = {}) {
9005
9251
  host,
9006
9252
  hostname: deps.hostname(),
9007
9253
  env: envFields,
9254
+ branchIssue,
9008
9255
  eventId: randomUUID2(),
9009
9256
  processId,
9010
9257
  inputVersions: deps.inputVersions()
9011
9258
  });
9012
- if (resolvedDestination.kind === "none") {
9013
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9014
- `);
9015
- return;
9016
- }
9017
9259
  const full = { ...e, ...header };
9018
9260
  const parsed = LogEventSchema.safeParse(full);
9019
9261
  if (!parsed.success) {
@@ -9030,10 +9272,12 @@ function createLogSink(overrides = {}) {
9030
9272
  } else {
9031
9273
  appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9032
9274
  }
9033
- }).catch((err) => {
9275
+ };
9276
+ const written = writeChain.then(write).catch((err) => {
9034
9277
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
9035
9278
  `);
9036
9279
  });
9280
+ writeChain = written;
9037
9281
  pendingWrites.add(written);
9038
9282
  written.finally(() => pendingWrites.delete(written));
9039
9283
  } catch (err) {
@@ -9109,7 +9353,7 @@ function parseChangedLineRanges(diffOutput) {
9109
9353
  function fileDiffAgainst(ref, path) {
9110
9354
  let out;
9111
9355
  try {
9112
- out = execFileSync5("git", ["diff", `${ref}...HEAD`, "--", path], {
9356
+ out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
9113
9357
  encoding: "utf8",
9114
9358
  stdio: ["ignore", "pipe", "pipe"]
9115
9359
  }).trim();
@@ -9120,7 +9364,7 @@ function fileDiffAgainst(ref, path) {
9120
9364
  }
9121
9365
  function revParse(ref) {
9122
9366
  try {
9123
- return execFileSync5("git", ["rev-parse", "--verify", ref], {
9367
+ return execFileSync6("git", ["rev-parse", "--verify", ref], {
9124
9368
  encoding: "utf8",
9125
9369
  stdio: ["ignore", "pipe", "pipe"]
9126
9370
  }).trim();
@@ -9130,7 +9374,7 @@ function revParse(ref) {
9130
9374
  }
9131
9375
  function repoRoot() {
9132
9376
  try {
9133
- return execFileSync5("git", ["rev-parse", "--show-toplevel"], {
9377
+ return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
9134
9378
  encoding: "utf8",
9135
9379
  stdio: ["ignore", "pipe", "pipe"]
9136
9380
  }).trim();
@@ -9141,7 +9385,7 @@ function repoRoot() {
9141
9385
  function changedFiles(base) {
9142
9386
  let out;
9143
9387
  try {
9144
- out = execFileSync5("git", ["diff", "--name-only", `${base}...HEAD`], {
9388
+ out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
9145
9389
  encoding: "utf8",
9146
9390
  stdio: ["ignore", "pipe", "pipe"]
9147
9391
  }).trim();
@@ -9166,7 +9410,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
9166
9410
  const relPaths = changedFiles(ref);
9167
9411
  if (relPaths === null)
9168
9412
  continue;
9169
- return { base: ref, root, files: relPaths.map((p) => join8(root, p)) };
9413
+ return { base: ref, root, files: relPaths.map((p) => join9(root, p)) };
9170
9414
  }
9171
9415
  return null;
9172
9416
  }
@@ -9201,7 +9445,7 @@ function findingsInThisDiff(findings) {
9201
9445
  var CHECK_NAME = "doc-coverage-push";
9202
9446
  function git2(args) {
9203
9447
  try {
9204
- return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9448
+ return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9205
9449
  } catch {
9206
9450
  return "";
9207
9451
  }
@@ -9215,7 +9459,7 @@ function resolvePrBody() {
9215
9459
  return process.env.PR_BODY;
9216
9460
  if (process.env.PR_BODY_FILE) {
9217
9461
  try {
9218
- return readFileSync6(process.env.PR_BODY_FILE, "utf8");
9462
+ return readFileSync7(process.env.PR_BODY_FILE, "utf8");
9219
9463
  } catch {
9220
9464
  return "";
9221
9465
  }
@@ -9250,8 +9494,8 @@ function main() {
9250
9494
  }
9251
9495
  if (changed.length === 0)
9252
9496
  process.exit(0);
9253
- const content = existsSync7(DOC_OWNERS_PATH) ? readFileSync6(DOC_OWNERS_PATH, "utf8") : null;
9254
- const result = evaluateC5(changed, content, resolvePrBody(), existsSync7, waiverActiveFromEnv(), (p) => fileDiffAgainst(ref, p));
9497
+ const content = existsSync8(DOC_OWNERS_PATH) ? readFileSync7(DOC_OWNERS_PATH, "utf8") : null;
9498
+ const result = evaluateC5(changed, content, resolvePrBody(), existsSync8, waiverActiveFromEnv(), (p) => fileDiffAgainst(ref, p));
9255
9499
  for (const message of result.errors) {
9256
9500
  emitCheckError({
9257
9501
  schema: CHECK_SCHEMA_VERSION,