@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
@@ -3,8 +3,8 @@ import { createRequire } from "node:module";
3
3
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
4
 
5
5
  // src/checks/bin/check-workspace-escape.ts
6
- import { readdirSync as readdirSync2, readFileSync as readFileSync6, statSync as statSync2 } from "node:fs";
7
- import { join as join9 } from "node:path";
6
+ import { readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync2 } from "node:fs";
7
+ import { join as join10 } from "node:path";
8
8
  // ../../packages/aeg-core/src/gate-audience.ts
9
9
  var GATE_AUDIENCE = {
10
10
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -199,8 +199,8 @@ function maskIndentedCode(body, fill) {
199
199
  var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
200
200
  var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
201
201
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
202
- var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
203
- var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
202
+ var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+$/i;
203
+ var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+)$/i;
204
204
  function splitSlugQualifiedEdge(edge) {
205
205
  const m = edge.trim().match(SLUG_QUALIFIED_ID);
206
206
  if (!m)
@@ -2621,7 +2621,7 @@ function isIssueNotFoundError(err) {
2621
2621
  return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
2622
2622
  }
2623
2623
  function resolveObjectivesSource(prBody, issue, cutoverIssue) {
2624
- if (issue !== null && issue < cutoverIssue)
2624
+ if (issue !== null && cutoverIssue !== null && issue < cutoverIssue)
2625
2625
  return { kind: "none" };
2626
2626
  if (issue !== null)
2627
2627
  return { kind: "issue", issue };
@@ -2897,9 +2897,18 @@ var COMMIT_TYPES = [
2897
2897
  ];
2898
2898
  var COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join("|")})(\\([a-z0-9-]+\\))?: \\S`);
2899
2899
  function checkForgeTitle(title) {
2900
- const taskStyle = /^\[[a-z0-9._-]+\] \S+ — \S/;
2900
+ const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/;
2901
2901
  if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title))
2902
2902
  return { status: "pass", errors: [] };
2903
+ const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title);
2904
+ if (letteredTaskId) {
2905
+ return {
2906
+ status: "fail",
2907
+ errors: [
2908
+ `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.`
2909
+ ]
2910
+ };
2911
+ }
2903
2912
  return {
2904
2913
  status: "fail",
2905
2914
  errors: [
@@ -2932,19 +2941,31 @@ function checkNoAgentBoxes(prBody) {
2932
2941
  ]
2933
2942
  };
2934
2943
  }
2935
- function rolloutThresholdFor(message) {
2944
+ function rolloutRuleFor(message) {
2936
2945
  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:")) {
2937
- return BRIEF_RULES_SINCE_PR;
2946
+ return "briefRules";
2938
2947
  }
2939
2948
  if (message.startsWith("brief-validation no agent boxes:"))
2940
- return AGENT_BOXES_REFUSED_SINCE_PR;
2949
+ return "agentBoxes";
2941
2950
  return null;
2942
2951
  }
2943
- function partitionBriefErrorsByRollout(errors, prNumber) {
2952
+ var DEFAULT_BRIEF_ROLLOUT_CUTOVERS = {
2953
+ briefRulesSincePr: BRIEF_RULES_SINCE_PR,
2954
+ agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
2955
+ };
2956
+ function rolloutThresholdFor(message, cutovers) {
2957
+ const rule = rolloutRuleFor(message);
2958
+ if (rule === "briefRules")
2959
+ return cutovers.briefRulesSincePr;
2960
+ if (rule === "agentBoxes")
2961
+ return cutovers.agentBoxesRefusedSincePr;
2962
+ return null;
2963
+ }
2964
+ function partitionBriefErrorsByRollout(errors, prNumber, cutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS) {
2944
2965
  const blocking = [];
2945
2966
  const info = [];
2946
2967
  for (const e of errors) {
2947
- const threshold = rolloutThresholdFor(e);
2968
+ const threshold = rolloutThresholdFor(e, cutovers);
2948
2969
  const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold;
2949
2970
  (grandfathered ? info : blocking).push(e);
2950
2971
  }
@@ -3412,8 +3433,8 @@ function checkIssueRationale(body) {
3412
3433
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3413
3434
  }
3414
3435
  var OBJECTIVES_SINCE_ISSUE = 404;
3415
- function checkIssueObjectives(body, issueNumber) {
3416
- if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE)
3436
+ function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3437
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3417
3438
  return { status: "pass", errors: [] };
3418
3439
  const result = objectivesOf(body);
3419
3440
  if (result.ok)
@@ -3858,7 +3879,7 @@ function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
3858
3879
  return issueToEntry.get(Number(issueMatch[1]));
3859
3880
  return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
3860
3881
  }
3861
- function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3882
+ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
3862
3883
  const failures = [];
3863
3884
  for (const [slug, issues] of issuesBySlug) {
3864
3885
  for (const issue of issues) {
@@ -3867,7 +3888,7 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3867
3888
  const errors = [
3868
3889
  ...checkIssueRationale(issue.body).errors,
3869
3890
  ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
3870
- ...checkIssueObjectives(issue.body, issue.number).errors,
3891
+ ...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
3871
3892
  ...checkPartsCiteDefinedObjectives(issue.body).errors
3872
3893
  ];
3873
3894
  if (errors.length === 0)
@@ -4490,13 +4511,27 @@ var SHIPS_PREFIX = "aeg-root/";
4490
4511
  function shipsArchivePrefix(shipsPrefix) {
4491
4512
  return `${shipsPrefix}tranches/completed/`;
4492
4513
  }
4493
- function isSpecFile2(path) {
4494
- return path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md");
4514
+ var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
4515
+ function normalizeSpecPath(entry) {
4516
+ let out = entry.replace(/\\/g, "/");
4517
+ while (out.startsWith("./"))
4518
+ out = out.slice(2);
4519
+ out = out.replace(/\/{2,}/g, "/");
4520
+ while (out.endsWith("/"))
4521
+ out = out.slice(0, -1);
4522
+ return out;
4523
+ }
4524
+ function isSpecFile2(path, specPaths) {
4525
+ if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
4526
+ return true;
4527
+ if (!path.endsWith(".md"))
4528
+ return false;
4529
+ return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
4495
4530
  }
4496
4531
  function isClaudeMdFile(path) {
4497
4532
  return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
4498
4533
  }
4499
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4534
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
4500
4535
  if (path.startsWith(shipsPrefix)) {
4501
4536
  return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
4502
4537
  }
@@ -4505,7 +4540,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
4505
4540
  }
4506
4541
  if (isClaudeMdFile(path))
4507
4542
  return "internal";
4508
- if (isSpecFile2(path))
4543
+ if (isSpecFile2(path, specPaths))
4509
4544
  return "spec";
4510
4545
  if (isProductScopeFile(path))
4511
4546
  return "product";
@@ -4534,13 +4569,14 @@ function lineAt(content, index) {
4534
4569
  }
4535
4570
  var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
4536
4571
  var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
4572
+ var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
4537
4573
  function legacySlugPattern(legacySlugs) {
4538
4574
  if (legacySlugs.length === 0)
4539
4575
  return null;
4540
4576
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
4541
4577
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
4542
4578
  }
4543
- function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4579
+ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4544
4580
  const findings = [];
4545
4581
  const legacyPattern = legacySlugPattern(legacySlugs);
4546
4582
  const grandfathered = new Set(specGrandfather);
@@ -4552,8 +4588,12 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4552
4588
  const productPatterns = [
4553
4589
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4554
4590
  ];
4591
+ const specPatterns = [
4592
+ ...patterns,
4593
+ { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
4594
+ ];
4555
4595
  for (const file of files) {
4556
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4596
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
4557
4597
  if (!cls || cls === "internal")
4558
4598
  continue;
4559
4599
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
@@ -4562,15 +4602,16 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4562
4602
  continue;
4563
4603
  const blocking = cls === "product" || cls === "spec";
4564
4604
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4565
- const patternsToRun = cls === "product" ? productPatterns : patterns;
4605
+ const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
4566
4606
  for (const { pattern, what, group } of patternsToRun) {
4567
4607
  pattern.lastIndex = 0;
4568
4608
  let match = pattern.exec(scrubbed);
4569
4609
  while (match !== null) {
4570
4610
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
4611
+ const citedIndex = match.index + match[0].indexOf(cited);
4571
4612
  findings.push({
4572
4613
  file: file.path,
4573
- line: lineAt(scrubbed, match.index),
4614
+ line: lineAt(scrubbed, citedIndex),
4574
4615
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4575
4616
  blocking
4576
4617
  });
@@ -4756,9 +4797,9 @@ function checkSourceComments(files, allowlist = []) {
4756
4797
  }
4757
4798
  return findings;
4758
4799
  }
4759
- function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4800
+ function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4760
4801
  return [
4761
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather),
4802
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
4762
4803
  ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4763
4804
  ];
4764
4805
  }
@@ -5223,7 +5264,8 @@ var TaskStatusItemSchema = z.object({
5223
5264
  }).merge(ObservedSchema);
5224
5265
  var TaskStatusResultSchema = z.object({
5225
5266
  items: z.array(TaskStatusItemSchema),
5226
- nextCursor: z.string().nullable()
5267
+ nextCursor: z.string().nullable(),
5268
+ table: z.string()
5227
5269
  });
5228
5270
  var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
5229
5271
  var EscalationInputsSchema = z.object({
@@ -5567,6 +5609,14 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5567
5609
  }
5568
5610
  return findings;
5569
5611
  }
5612
+ // ../../packages/aeg-core/src/gate-cutovers.ts
5613
+ var NO_GATE_CUTOVERS = {
5614
+ objectivesSinceIssue: null,
5615
+ briefSectionsSinceIssue: null,
5616
+ documentationSinceIssue: null,
5617
+ briefRulesSincePr: null,
5618
+ agentBoxesRefusedSincePr: null
5619
+ };
5570
5620
  // ../../packages/aeg-core/src/dev-review-loop/types.ts
5571
5621
  var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5572
5622
  // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
@@ -6016,6 +6066,8 @@ function attemptFromEnv(value) {
6016
6066
  function provenanceFor(input) {
6017
6067
  if (input.provenance)
6018
6068
  return input.provenance;
6069
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
6070
+ return "unavailable";
6019
6071
  if (input.env.role || input.env.task)
6020
6072
  return "env_correlated";
6021
6073
  return "unavailable";
@@ -6036,7 +6088,7 @@ function buildHeader(input) {
6036
6088
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6037
6089
  const round = roundFromEnv(input.env.round);
6038
6090
  const subject = {
6039
- issue: issueFromTask(input.env.task),
6091
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6040
6092
  role,
6041
6093
  ...round !== undefined ? { round } : {},
6042
6094
  ...input.subject ?? {}
@@ -6317,8 +6369,8 @@ var ResolutionRecordSchema = z3.object({
6317
6369
  consumedAt: isoTimestamp
6318
6370
  }).strict();
6319
6371
  // src/lib/diff-evidence.ts
6320
- import { execFileSync as execFileSync5 } from "node:child_process";
6321
- import { join as join8, relative, resolve as resolve2 } from "node:path";
6372
+ import { execFileSync as execFileSync6 } from "node:child_process";
6373
+ import { join as join9, relative, resolve as resolve2 } from "node:path";
6322
6374
 
6323
6375
  // src/lib/config.ts
6324
6376
  import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
@@ -6480,7 +6532,12 @@ var VinayaConfigSchema = z4.object({
6480
6532
  allowlist: z4.array(z4.string().min(1)).optional(),
6481
6533
  severity: z4.enum(["warning", "error"]).optional()
6482
6534
  }).optional(),
6483
- specGrandfather: z4.array(z4.string().min(1)).optional()
6535
+ specGrandfather: z4.array(z4.string().min(1)).optional(),
6536
+ specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6537
+ message: "must be a repository-relative path, not an absolute one"
6538
+ }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
6539
+ message: "must stay inside the repository — no `..` segment"
6540
+ })).optional()
6484
6541
  }).optional(),
6485
6542
  projects: z4.array(ProjectEntrySchema).optional(),
6486
6543
  dispatch: z4.object({
@@ -6494,6 +6551,13 @@ var VinayaConfigSchema = z4.object({
6494
6551
  securityThreshold: z4.string().min(1).optional(),
6495
6552
  maxRounds: z4.number().optional()
6496
6553
  }).optional(),
6554
+ gateCutovers: z4.object({
6555
+ objectivesSinceIssue: z4.number().int().nonnegative().optional(),
6556
+ briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
6557
+ documentationSinceIssue: z4.number().int().nonnegative().optional(),
6558
+ briefRulesSincePr: z4.number().int().nonnegative().optional(),
6559
+ agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
6560
+ }).optional(),
6497
6561
  prePush: z4.object({
6498
6562
  alwaysRun: z4.array(z4.string()).optional()
6499
6563
  }).optional(),
@@ -6631,6 +6695,18 @@ function resolveReviewPolicy(config) {
6631
6695
  maxRounds
6632
6696
  };
6633
6697
  }
6698
+ function resolveGateCutovers(config) {
6699
+ const raw = config?.gateCutovers;
6700
+ if (!raw)
6701
+ return NO_GATE_CUTOVERS;
6702
+ return {
6703
+ objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
6704
+ briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
6705
+ documentationSinceIssue: raw.documentationSinceIssue ?? null,
6706
+ briefRulesSincePr: raw.briefRulesSincePr ?? null,
6707
+ agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
6708
+ };
6709
+ }
6634
6710
  function resolveRuntimeDirSetting(config) {
6635
6711
  return config?.runtimeDir ?? null;
6636
6712
  }
@@ -6821,9 +6897,9 @@ function loadConfig() {
6821
6897
  var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
6822
6898
 
6823
6899
  // src/lib/brief-assembly.ts
6824
- import { execFileSync as execFileSync4 } from "node:child_process";
6825
- import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "node:fs";
6826
- import { join as join3 } from "node:path";
6900
+ import { execFileSync as execFileSync5 } from "node:child_process";
6901
+ import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
6902
+ import { join as join4 } from "node:path";
6827
6903
 
6828
6904
  // ../../packages/sources/src/commands.ts
6829
6905
  var COMMANDS = [
@@ -7329,6 +7405,10 @@ var COMMANDS = [
7329
7405
  flag: "--role <name>",
7330
7406
  description: "Resolve to a specific role file (roles/<name>.md) instead of the front door"
7331
7407
  },
7408
+ {
7409
+ flag: "--template <name>",
7410
+ description: "Print a template the package ships (templates/<name>-template.md) instead of the front door"
7411
+ },
7332
7412
  {
7333
7413
  flag: "--print",
7334
7414
  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."
@@ -7664,13 +7744,47 @@ function packageRoot(moduleUrl) {
7664
7744
  return dir;
7665
7745
  }
7666
7746
 
7747
+ // src/commands/doctrine.ts
7748
+ import { execFileSync as execFileSync4 } from "node:child_process";
7749
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
7750
+ import { dirname as dirname3, join as join3, sep } from "node:path";
7751
+ import matter2 from "gray-matter";
7752
+ var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
7753
+ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7754
+ return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
7755
+ }
7756
+ function gitToplevel(cwd) {
7757
+ try {
7758
+ return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
7759
+ encoding: "utf8",
7760
+ stdio: ["ignore", "pipe", "pipe"]
7761
+ }).trim();
7762
+ } catch {
7763
+ return null;
7764
+ }
7765
+ }
7766
+ function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7767
+ const toplevel = gitToplevel(cwd);
7768
+ if (toplevel !== null) {
7769
+ const treeRoot = join3(toplevel, "aeg-root");
7770
+ if (existsSync3(join3(treeRoot, "roles")))
7771
+ return { root: treeRoot, source: "tree" };
7772
+ }
7773
+ const fromSource = !pkg.split(sep).includes("node_modules");
7774
+ const bundleRoot = fromSource ? join3(dirname3(dirname3(pkg)), "aeg-root") : join3(pkg, "aeg-root");
7775
+ return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
7776
+ }
7777
+ function hasDoctrineEntry(root) {
7778
+ return existsSync3(join3(root, ...ENTRY_SEGMENTS));
7779
+ }
7780
+
7667
7781
  // src/lib/brief-assembly.ts
7668
7782
  var PACKAGE_ROOT = packageRoot(import.meta.url);
7669
- var PACKAGED_TEMPLATE_PATH = join3(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
7670
- var TEMPLATE_PATH = existsSync3(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join3(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7783
+ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
7784
+ var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7671
7785
  function git(args) {
7672
7786
  try {
7673
- return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7787
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7674
7788
  } catch {
7675
7789
  return "";
7676
7790
  }
@@ -7683,14 +7797,14 @@ function expandGlob(glob) {
7683
7797
  var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7684
7798
 
7685
7799
  // src/checks/registry.ts
7686
- import { existsSync as existsSync4 } from "node:fs";
7687
- import { join as join4 } from "node:path";
7688
- var DIST_BIN_DIR = join4(packageRoot(import.meta.url), "dist", "checks", "bin");
7689
- var SRC_BIN_DIR = join4(packageRoot(import.meta.url), "src", "checks", "bin");
7690
- var BIN_DIR = existsSync4(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7800
+ import { existsSync as existsSync5 } from "node:fs";
7801
+ import { join as join5 } from "node:path";
7802
+ var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
7803
+ var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
7804
+ var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7691
7805
  var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
7692
7806
  function bin(name) {
7693
- return join4(BIN_DIR, `${name}${BIN_EXT}`);
7807
+ return join5(BIN_DIR, `${name}${BIN_EXT}`);
7694
7808
  }
7695
7809
  var REGISTRY = [
7696
7810
  [
@@ -8254,21 +8368,21 @@ import { randomUUID as randomUUID2 } from "node:crypto";
8254
8368
  import {
8255
8369
  closeSync as closeSync3,
8256
8370
  constants as fsConstants3,
8257
- existsSync as existsSync6,
8371
+ existsSync as existsSync7,
8258
8372
  fstatSync as fstatSync2,
8259
8373
  mkdirSync as mkdirSync3,
8260
8374
  openSync as openSync3,
8261
- readFileSync as readFileSync5,
8375
+ readFileSync as readFileSync6,
8262
8376
  renameSync as renameSync2,
8263
8377
  writeSync as writeSync2
8264
8378
  } from "node:fs";
8265
8379
  import { hostname as osHostname, homedir as homedir3 } from "node:os";
8266
- import { dirname as dirname5, join as join7 } from "node:path";
8380
+ import { dirname as dirname6, join as join8 } from "node:path";
8267
8381
  import { promisify as promisify5 } from "node:util";
8268
8382
 
8269
8383
  // src/lib/run-paths.ts
8270
- import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
8271
- import { dirname as dirname3, join as join5, resolve as resolvePath } from "node:path";
8384
+ import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
8385
+ import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
8272
8386
  var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8273
8387
  function isSafeRepoSegment(segment) {
8274
8388
  return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
@@ -8279,7 +8393,7 @@ function repoSegment(repo) {
8279
8393
  return `${repo.owner}-${repo.repo}`;
8280
8394
  }
8281
8395
  function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
8282
- return join5(home, "runtime", repoSegment(repo));
8396
+ return join6(home, "runtime", repoSegment(repo));
8283
8397
  }
8284
8398
  function resolveRuntimeDir(input) {
8285
8399
  const local = resolveRuntimeDirSetting(input.localConfig);
@@ -8339,9 +8453,9 @@ function repoRootSync(start = process.cwd()) {
8339
8453
  return null;
8340
8454
  }
8341
8455
  for (;; ) {
8342
- if (existsSync5(join5(dir, ".git")))
8456
+ if (existsSync6(join6(dir, ".git")))
8343
8457
  return dir;
8344
- const parent = dirname3(dir);
8458
+ const parent = dirname4(dir);
8345
8459
  if (parent === dir)
8346
8460
  return null;
8347
8461
  dir = parent;
@@ -8356,7 +8470,7 @@ import {
8356
8470
  mkdirSync as mkdirSync2,
8357
8471
  openSync as openSync2,
8358
8472
  linkSync,
8359
- readFileSync as readFileSync4,
8473
+ readFileSync as readFileSync5,
8360
8474
  renameSync,
8361
8475
  statSync,
8362
8476
  unlinkSync,
@@ -8366,7 +8480,7 @@ import {
8366
8480
  } from "node:fs";
8367
8481
  import { randomUUID } from "node:crypto";
8368
8482
  import { homedir as homedir2 } from "node:os";
8369
- import { dirname as dirname4, join as join6 } from "node:path";
8483
+ import { dirname as dirname5, join as join7 } from "node:path";
8370
8484
  var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
8371
8485
  var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
8372
8486
  var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
@@ -8382,7 +8496,7 @@ function isEnoent(err) {
8382
8496
  var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
8383
8497
  function tryCreateLock(lockPath, token) {
8384
8498
  try {
8385
- mkdirSync2(dirname4(lockPath), { recursive: true, mode: 448 });
8499
+ mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
8386
8500
  const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
8387
8501
  try {
8388
8502
  writeSync(fd, `${token}
@@ -8447,7 +8561,7 @@ function acquireDrainLock(lockPath) {
8447
8561
  function renewDrainLock(lockPath, token) {
8448
8562
  let holder;
8449
8563
  try {
8450
- holder = readFileSync4(lockPath, "utf8").trim();
8564
+ holder = readFileSync5(lockPath, "utf8").trim();
8451
8565
  } catch (err) {
8452
8566
  if (!isEnoent(err))
8453
8567
  throw err;
@@ -8467,7 +8581,7 @@ function renewDrainLock(lockPath, token) {
8467
8581
  }
8468
8582
  function releaseDrainLock(lockPath, token) {
8469
8583
  try {
8470
- const holder = readFileSync4(lockPath, "utf8").trim();
8584
+ const holder = readFileSync5(lockPath, "utf8").trim();
8471
8585
  if (holder !== token)
8472
8586
  return;
8473
8587
  unlinkSync(lockPath);
@@ -8517,7 +8631,7 @@ function queueLines(buf) {
8517
8631
  return lines;
8518
8632
  }
8519
8633
  function removeQueueHead(path, cut) {
8520
- const remaining = readFileSync4(path);
8634
+ const remaining = readFileSync5(path);
8521
8635
  writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
8522
8636
  }
8523
8637
  function queueBucketSize(path) {
@@ -8538,7 +8652,7 @@ function queueBucketSize(path) {
8538
8652
  function readQueueFile(path) {
8539
8653
  if (queueBucketSize(path) === null)
8540
8654
  return null;
8541
- return readFileSync4(path);
8655
+ return readFileSync5(path);
8542
8656
  }
8543
8657
  function rejectLine(rejectedPath, reason, status, identity, raw) {
8544
8658
  const record = JSON.stringify({
@@ -8653,7 +8767,7 @@ async function drainRenamedAside(args, livePath, source) {
8653
8767
  async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
8654
8768
  const resolved = await resolveRepo();
8655
8769
  const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
8656
- const outboxRoot = () => join6(GLOBAL_VINAYA_HOME, "outbox");
8770
+ const outboxRoot = () => join7(GLOBAL_VINAYA_HOME, "outbox");
8657
8771
  const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
8658
8772
  const lockPath = `${path}.flush-lock`;
8659
8773
  const lockToken = acquireDrainLock(lockPath);
@@ -8765,7 +8879,7 @@ async function defaultResolveLogDestination(repo, env) {
8765
8879
  trustAnchorConfig: unattended ? await processTrustAnchor() : null,
8766
8880
  unattended,
8767
8881
  env,
8768
- defaultFolder: join7(await runtimeDirForRepoAsync(repo), "logs"),
8882
+ defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
8769
8883
  repoRoot: repoRootSync()
8770
8884
  });
8771
8885
  }
@@ -8780,7 +8894,7 @@ async function resolveDoctrine(cwd, vinayaVersion) {
8780
8894
  } catch (err) {
8781
8895
  return isEnoent2(err) ? "unknown" : vinayaVersion;
8782
8896
  }
8783
- if (!existsSync6(join7(toplevel, "aeg-root", "roles")))
8897
+ if (!existsSync7(join8(toplevel, "aeg-root", "roles")))
8784
8898
  return vinayaVersion;
8785
8899
  try {
8786
8900
  const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
@@ -8789,9 +8903,99 @@ async function resolveDoctrine(cwd, vinayaVersion) {
8789
8903
  return vinayaVersion;
8790
8904
  }
8791
8905
  }
8906
+ var TRANCHE_SLUG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
8907
+ function taskRefFromBranch2(branch) {
8908
+ const backlog = /^task\/issue-(\d+)$/.exec(branch);
8909
+ if (backlog) {
8910
+ const issue = Number(backlog[1]);
8911
+ return Number.isSafeInteger(issue) && issue > 0 ? { kind: "issue", issue } : null;
8912
+ }
8913
+ const tranche = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
8914
+ if (tranche && TRANCHE_SLUG_PATTERN.test(tranche[1] ?? "")) {
8915
+ return { kind: "tranche", tranche: tranche[1], taskId: tranche[2] };
8916
+ }
8917
+ return null;
8918
+ }
8919
+ var TRANCHE_ISSUE_LIST_LIMIT = 200;
8920
+ async function issueForTrancheTask(tranche, taskId, cwd, repo) {
8921
+ let stdout;
8922
+ try {
8923
+ ({ stdout } = await execFileAsync5("gh", [
8924
+ "issue",
8925
+ "list",
8926
+ "--state",
8927
+ "all",
8928
+ "--label",
8929
+ `vinaya/tranche:${tranche}`,
8930
+ "--json",
8931
+ "number,title,labels",
8932
+ "--limit",
8933
+ String(TRANCHE_ISSUE_LIST_LIMIT),
8934
+ ...repo === null ? [] : ["--repo", repo]
8935
+ ], {
8936
+ cwd,
8937
+ encoding: "utf8",
8938
+ maxBuffer: 8 * 1024 * 1024,
8939
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8940
+ killSignal: "SIGKILL"
8941
+ }));
8942
+ } catch {
8943
+ return null;
8944
+ }
8945
+ let issues;
8946
+ try {
8947
+ issues = JSON.parse(stdout);
8948
+ } catch {
8949
+ return null;
8950
+ }
8951
+ for (const issue of issues) {
8952
+ const ref = resolveTaskIssueRef(issue.title, issue.labels.map((l) => l.name));
8953
+ if (ref && ref.trancheSlug === tranche && ref.taskId === taskId)
8954
+ return issue.number;
8955
+ }
8956
+ return null;
8957
+ }
8958
+ async function confirmBacklogIssue(issue, cwd, repo) {
8959
+ let stdout;
8960
+ try {
8961
+ ({ stdout } = await execFileAsync5("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
8962
+ cwd,
8963
+ encoding: "utf8",
8964
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8965
+ killSignal: "SIGKILL"
8966
+ }));
8967
+ } catch (err) {
8968
+ const stderr = typeof err.stderr === "string" ? err.stderr : "";
8969
+ return /could not resolve|not found|no such|does not exist/i.test(stderr) ? "denied" : "unknown";
8970
+ }
8971
+ try {
8972
+ return JSON.parse(stdout).number === issue ? "confirmed" : "denied";
8973
+ } catch {
8974
+ return "unknown";
8975
+ }
8976
+ }
8977
+ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
8978
+ let branch;
8979
+ try {
8980
+ branch = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
8981
+ encoding: "utf8",
8982
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8983
+ killSignal: "SIGKILL"
8984
+ })).stdout.trim();
8985
+ } catch {
8986
+ return null;
8987
+ }
8988
+ const named = branch === "HEAD" ? env.GITHUB_HEAD_REF ?? "" : branch;
8989
+ const ref = taskRefFromBranch2(named);
8990
+ if (ref === null)
8991
+ return null;
8992
+ if (ref.kind === "tranche")
8993
+ return await issueForTrancheTask(ref.tranche, ref.taskId, cwd, repo);
8994
+ return await confirmBacklogIssue(ref.issue, cwd, repo) === "denied" ? null : ref.issue;
8995
+ }
8792
8996
  function readVinayaVersion() {
8793
8997
  try {
8794
- const pkg = JSON.parse(readFileSync5(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
8998
+ const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
8795
8999
  return pkg.version ?? "unknown";
8796
9000
  } catch {
8797
9001
  return "unknown";
@@ -8801,10 +9005,15 @@ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8801
9005
  function isSafeRepoSegment3(segment) {
8802
9006
  return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
8803
9007
  }
9008
+ function safeRepoSlug(repo) {
9009
+ if (repo === null)
9010
+ return null;
9011
+ return isSafeRepoSegment3(repo.owner) && isSafeRepoSegment3(repo.repo) ? `${repo.owner}/${repo.repo}` : null;
9012
+ }
8804
9013
  function outboxPathFor(deps, repo, issue) {
8805
9014
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
8806
9015
  const fileName = `${issue ?? "none"}.ndjson`;
8807
- return join7(deps.outboxRoot(), dirName, fileName);
9016
+ return join8(deps.outboxRoot(), dirName, fileName);
8808
9017
  }
8809
9018
  function hostFromEnv(env) {
8810
9019
  if (env.GITHUB_ACTIONS)
@@ -8822,9 +9031,21 @@ function defaultStderr(message) {
8822
9031
  warnedThisProcess = true;
8823
9032
  process.stderr.write(message);
8824
9033
  }
9034
+ var branchIssueFallbackEnabled = true;
9035
+ var branchIssueByCwd = new Map;
9036
+ function branchIssueRead(key, read, shared) {
9037
+ if (!shared)
9038
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9039
+ const cached = branchIssueByCwd.get(key);
9040
+ if (cached !== undefined)
9041
+ return cached;
9042
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9043
+ branchIssueByCwd.set(key, reading);
9044
+ return reading;
9045
+ }
8825
9046
  function defaultDeps() {
8826
9047
  return {
8827
- outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
9048
+ outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
8828
9049
  home: () => homedir3(),
8829
9050
  hostname: () => osHostname(),
8830
9051
  cwd: () => process.cwd(),
@@ -8849,7 +9070,7 @@ function guardedAppendOpen(path) {
8849
9070
  }
8850
9071
  function appendHardenedLine(path, line) {
8851
9072
  try {
8852
- mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
9073
+ mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
8853
9074
  const fd = guardedAppendOpen(path);
8854
9075
  if (fd === undefined)
8855
9076
  return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
@@ -8868,7 +9089,7 @@ function appendHardenedLine(path, line) {
8868
9089
  function reportRotationOverflow(backupPath, warn) {
8869
9090
  let raw;
8870
9091
  try {
8871
- raw = readFileSync5(backupPath, "utf8");
9092
+ raw = readFileSync6(backupPath, "utf8");
8872
9093
  } catch {
8873
9094
  return;
8874
9095
  }
@@ -8891,7 +9112,7 @@ function reportRotationOverflow(backupPath, warn) {
8891
9112
  }
8892
9113
  function appendLine(path, line, warn) {
8893
9114
  try {
8894
- mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
9115
+ mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
8895
9116
  let fd = guardedAppendOpen(path);
8896
9117
  if (fd === undefined) {
8897
9118
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -8932,7 +9153,11 @@ function appendLine(path, line, warn) {
8932
9153
  }
8933
9154
  }
8934
9155
  function createLogSink(overrides = {}) {
8935
- const deps = { ...defaultDeps(), ...overrides };
9156
+ const deps = {
9157
+ ...defaultDeps(),
9158
+ resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
9159
+ ...overrides
9160
+ };
8936
9161
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
8937
9162
  const processId = randomUUID2();
8938
9163
  let seq = 0;
@@ -8952,6 +9177,19 @@ function createLogSink(overrides = {}) {
8952
9177
  }
8953
9178
  return doctrineCache;
8954
9179
  };
9180
+ const readerIsReal = overrides.resolveBranchIssue === undefined;
9181
+ let ownBranchIssue;
9182
+ const branchIssueOnce = (repo) => {
9183
+ if (!branchIssueFallbackEnabled)
9184
+ return Promise.resolve(null);
9185
+ const slug = safeRepoSlug(repo);
9186
+ const read = () => deps.resolveBranchIssue(slug);
9187
+ if (readerIsReal)
9188
+ return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
9189
+ if (ownBranchIssue === undefined)
9190
+ ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
9191
+ return ownBranchIssue;
9192
+ };
8955
9193
  let resolveRepoCache;
8956
9194
  const resolveRepoOnce = () => {
8957
9195
  if (resolveRepoCache === undefined)
@@ -8974,6 +9212,7 @@ function createLogSink(overrides = {}) {
8974
9212
  };
8975
9213
  let drainChain = Promise.resolve();
8976
9214
  const pendingWrites = new Set;
9215
+ let writeChain = Promise.resolve();
8977
9216
  const scheduleWebhookDrain = (issue, url, headers) => {
8978
9217
  drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
8979
9218
  return;
@@ -8996,7 +9235,14 @@ function createLogSink(overrides = {}) {
8996
9235
  attempt: env.VINAYA_ATTEMPT,
8997
9236
  parent: env.VINAYA_PARENT_EVENT
8998
9237
  };
8999
- const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
9238
+ const write = async () => {
9239
+ const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
9240
+ if (resolvedDestination.kind === "none") {
9241
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9242
+ `);
9243
+ return;
9244
+ }
9245
+ const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
9000
9246
  const header = buildHeader({
9001
9247
  now,
9002
9248
  runId,
@@ -9007,15 +9253,11 @@ function createLogSink(overrides = {}) {
9007
9253
  host,
9008
9254
  hostname: deps.hostname(),
9009
9255
  env: envFields,
9256
+ branchIssue,
9010
9257
  eventId: randomUUID2(),
9011
9258
  processId,
9012
9259
  inputVersions: deps.inputVersions()
9013
9260
  });
9014
- if (resolvedDestination.kind === "none") {
9015
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9016
- `);
9017
- return;
9018
- }
9019
9261
  const full = { ...e, ...header };
9020
9262
  const parsed = LogEventSchema.safeParse(full);
9021
9263
  if (!parsed.success) {
@@ -9032,10 +9274,12 @@ function createLogSink(overrides = {}) {
9032
9274
  } else {
9033
9275
  appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9034
9276
  }
9035
- }).catch((err) => {
9277
+ };
9278
+ const written = writeChain.then(write).catch((err) => {
9036
9279
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
9037
9280
  `);
9038
9281
  });
9282
+ writeChain = written;
9039
9283
  pendingWrites.add(written);
9040
9284
  written.finally(() => pendingWrites.delete(written));
9041
9285
  } catch (err) {
@@ -9111,7 +9355,7 @@ function parseChangedLineRanges(diffOutput) {
9111
9355
  function fileDiffAgainst(ref, path) {
9112
9356
  let out;
9113
9357
  try {
9114
- out = execFileSync5("git", ["diff", `${ref}...HEAD`, "--", path], {
9358
+ out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
9115
9359
  encoding: "utf8",
9116
9360
  stdio: ["ignore", "pipe", "pipe"]
9117
9361
  }).trim();
@@ -9122,7 +9366,7 @@ function fileDiffAgainst(ref, path) {
9122
9366
  }
9123
9367
  function revParse(ref) {
9124
9368
  try {
9125
- return execFileSync5("git", ["rev-parse", "--verify", ref], {
9369
+ return execFileSync6("git", ["rev-parse", "--verify", ref], {
9126
9370
  encoding: "utf8",
9127
9371
  stdio: ["ignore", "pipe", "pipe"]
9128
9372
  }).trim();
@@ -9132,7 +9376,7 @@ function revParse(ref) {
9132
9376
  }
9133
9377
  function repoRoot() {
9134
9378
  try {
9135
- return execFileSync5("git", ["rev-parse", "--show-toplevel"], {
9379
+ return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
9136
9380
  encoding: "utf8",
9137
9381
  stdio: ["ignore", "pipe", "pipe"]
9138
9382
  }).trim();
@@ -9143,7 +9387,7 @@ function repoRoot() {
9143
9387
  function changedFiles(base) {
9144
9388
  let out;
9145
9389
  try {
9146
- out = execFileSync5("git", ["diff", "--name-only", `${base}...HEAD`], {
9390
+ out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
9147
9391
  encoding: "utf8",
9148
9392
  stdio: ["ignore", "pipe", "pipe"]
9149
9393
  }).trim();
@@ -9168,7 +9412,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
9168
9412
  const relPaths = changedFiles(ref);
9169
9413
  if (relPaths === null)
9170
9414
  continue;
9171
- return { base: ref, root, files: relPaths.map((p) => join8(root, p)) };
9415
+ return { base: ref, root, files: relPaths.map((p) => join9(root, p)) };
9172
9416
  }
9173
9417
  return null;
9174
9418
  }
@@ -9210,14 +9454,14 @@ function isTestFile(path) {
9210
9454
  function collectAllPaths(dir, out = []) {
9211
9455
  let entries;
9212
9456
  try {
9213
- entries = readdirSync2(dir);
9457
+ entries = readdirSync3(dir);
9214
9458
  } catch {
9215
9459
  return out;
9216
9460
  }
9217
9461
  for (const name of entries) {
9218
9462
  if (EXCLUDED_DIRS.has(name))
9219
9463
  continue;
9220
- const full = join9(dir, name);
9464
+ const full = join10(dir, name);
9221
9465
  let isDir;
9222
9466
  try {
9223
9467
  isDir = statSync2(full).isDirectory();
@@ -9233,7 +9477,7 @@ function collectAllPaths(dir, out = []) {
9233
9477
  function main() {
9234
9478
  const allPaths = WORKSPACE_DIRS.flatMap((d) => collectAllPaths(d)).map((p) => p.split("\\").join("/"));
9235
9479
  const knownPaths = new Set(allPaths);
9236
- const sourceFiles = allPaths.filter((p) => SOURCE_EXTENSIONS.some((ext) => p.endsWith(ext))).filter((p) => !isTestFile(p)).map((p) => ({ path: p, content: readFileSync6(p, "utf8") }));
9480
+ const sourceFiles = allPaths.filter((p) => SOURCE_EXTENSIONS.some((ext) => p.endsWith(ext))).filter((p) => !isTestFile(p)).map((p) => ({ path: p, content: readFileSync7(p, "utf8") }));
9237
9481
  const findings = findWorkspaceEscapes(sourceFiles, knownPaths, WORKSPACE_DIRS);
9238
9482
  const reportable = findingsInThisDiff(findings);
9239
9483
  console.log(`${CHECK_NAME}: ${sourceFiles.length} source file(s) scanned under ${WORKSPACE_DIRS.join("/")}; ${findings.length} finding(s), ${reportable.length} in this diff`);