@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-exec-bits.ts
4
- import { execFileSync as execFileSync6 } from "node:child_process";
5
- import { readFileSync as readFileSync6 } from "node:fs";
4
+ import { execFileSync as execFileSync7 } from "node:child_process";
5
+ import { readFileSync as readFileSync7 } from "node:fs";
6
6
 
7
7
  // src/checks/contract.ts
8
8
  var CHECK_SCHEMA_VERSION = 1;
@@ -12,8 +12,8 @@ function emitCheckError(error) {
12
12
  }
13
13
 
14
14
  // src/lib/diff-evidence.ts
15
- import { execFileSync as execFileSync5 } from "node:child_process";
16
- import { join as join8, relative, resolve as resolve2 } from "node:path";
15
+ import { execFileSync as execFileSync6 } from "node:child_process";
16
+ import { join as join9, relative, resolve as resolve2 } from "node:path";
17
17
  // ../../packages/aeg-core/src/gate-audience.ts
18
18
  var GATE_AUDIENCE = {
19
19
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -208,8 +208,8 @@ function maskIndentedCode(body, fill) {
208
208
  var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
209
209
  var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
210
210
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
211
- var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
212
- var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
211
+ var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+$/i;
212
+ var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+)$/i;
213
213
  function splitSlugQualifiedEdge(edge) {
214
214
  const m = edge.trim().match(SLUG_QUALIFIED_ID);
215
215
  if (!m)
@@ -2630,7 +2630,7 @@ function isIssueNotFoundError(err) {
2630
2630
  return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
2631
2631
  }
2632
2632
  function resolveObjectivesSource(prBody, issue, cutoverIssue) {
2633
- if (issue !== null && issue < cutoverIssue)
2633
+ if (issue !== null && cutoverIssue !== null && issue < cutoverIssue)
2634
2634
  return { kind: "none" };
2635
2635
  if (issue !== null)
2636
2636
  return { kind: "issue", issue };
@@ -2906,9 +2906,18 @@ var COMMIT_TYPES = [
2906
2906
  ];
2907
2907
  var COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join("|")})(\\([a-z0-9-]+\\))?: \\S`);
2908
2908
  function checkForgeTitle(title) {
2909
- const taskStyle = /^\[[a-z0-9._-]+\] \S+ — \S/;
2909
+ const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/;
2910
2910
  if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title))
2911
2911
  return { status: "pass", errors: [] };
2912
+ const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title);
2913
+ if (letteredTaskId) {
2914
+ return {
2915
+ status: "fail",
2916
+ errors: [
2917
+ `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.`
2918
+ ]
2919
+ };
2920
+ }
2912
2921
  return {
2913
2922
  status: "fail",
2914
2923
  errors: [
@@ -2941,19 +2950,31 @@ function checkNoAgentBoxes(prBody) {
2941
2950
  ]
2942
2951
  };
2943
2952
  }
2944
- function rolloutThresholdFor(message) {
2953
+ function rolloutRuleFor(message) {
2945
2954
  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:")) {
2946
- return BRIEF_RULES_SINCE_PR;
2955
+ return "briefRules";
2947
2956
  }
2948
2957
  if (message.startsWith("brief-validation no agent boxes:"))
2949
- return AGENT_BOXES_REFUSED_SINCE_PR;
2958
+ return "agentBoxes";
2959
+ return null;
2960
+ }
2961
+ var DEFAULT_BRIEF_ROLLOUT_CUTOVERS = {
2962
+ briefRulesSincePr: BRIEF_RULES_SINCE_PR,
2963
+ agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
2964
+ };
2965
+ function rolloutThresholdFor(message, cutovers) {
2966
+ const rule = rolloutRuleFor(message);
2967
+ if (rule === "briefRules")
2968
+ return cutovers.briefRulesSincePr;
2969
+ if (rule === "agentBoxes")
2970
+ return cutovers.agentBoxesRefusedSincePr;
2950
2971
  return null;
2951
2972
  }
2952
- function partitionBriefErrorsByRollout(errors, prNumber) {
2973
+ function partitionBriefErrorsByRollout(errors, prNumber, cutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS) {
2953
2974
  const blocking = [];
2954
2975
  const info = [];
2955
2976
  for (const e of errors) {
2956
- const threshold = rolloutThresholdFor(e);
2977
+ const threshold = rolloutThresholdFor(e, cutovers);
2957
2978
  const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold;
2958
2979
  (grandfathered ? info : blocking).push(e);
2959
2980
  }
@@ -3421,8 +3442,8 @@ function checkIssueRationale(body) {
3421
3442
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3422
3443
  }
3423
3444
  var OBJECTIVES_SINCE_ISSUE = 404;
3424
- function checkIssueObjectives(body, issueNumber) {
3425
- if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE)
3445
+ function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3446
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3426
3447
  return { status: "pass", errors: [] };
3427
3448
  const result = objectivesOf(body);
3428
3449
  if (result.ok)
@@ -3867,7 +3888,7 @@ function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
3867
3888
  return issueToEntry.get(Number(issueMatch[1]));
3868
3889
  return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
3869
3890
  }
3870
- function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3891
+ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
3871
3892
  const failures = [];
3872
3893
  for (const [slug, issues] of issuesBySlug) {
3873
3894
  for (const issue of issues) {
@@ -3876,7 +3897,7 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3876
3897
  const errors = [
3877
3898
  ...checkIssueRationale(issue.body).errors,
3878
3899
  ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
3879
- ...checkIssueObjectives(issue.body, issue.number).errors,
3900
+ ...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
3880
3901
  ...checkPartsCiteDefinedObjectives(issue.body).errors
3881
3902
  ];
3882
3903
  if (errors.length === 0)
@@ -4499,13 +4520,27 @@ var SHIPS_PREFIX = "aeg-root/";
4499
4520
  function shipsArchivePrefix(shipsPrefix) {
4500
4521
  return `${shipsPrefix}tranches/completed/`;
4501
4522
  }
4502
- function isSpecFile2(path) {
4503
- return path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md");
4523
+ var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
4524
+ function normalizeSpecPath(entry) {
4525
+ let out = entry.replace(/\\/g, "/");
4526
+ while (out.startsWith("./"))
4527
+ out = out.slice(2);
4528
+ out = out.replace(/\/{2,}/g, "/");
4529
+ while (out.endsWith("/"))
4530
+ out = out.slice(0, -1);
4531
+ return out;
4532
+ }
4533
+ function isSpecFile2(path, specPaths) {
4534
+ if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
4535
+ return true;
4536
+ if (!path.endsWith(".md"))
4537
+ return false;
4538
+ return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
4504
4539
  }
4505
4540
  function isClaudeMdFile(path) {
4506
4541
  return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
4507
4542
  }
4508
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4543
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
4509
4544
  if (path.startsWith(shipsPrefix)) {
4510
4545
  return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
4511
4546
  }
@@ -4514,7 +4549,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
4514
4549
  }
4515
4550
  if (isClaudeMdFile(path))
4516
4551
  return "internal";
4517
- if (isSpecFile2(path))
4552
+ if (isSpecFile2(path, specPaths))
4518
4553
  return "spec";
4519
4554
  if (isProductScopeFile(path))
4520
4555
  return "product";
@@ -4543,13 +4578,14 @@ function lineAt(content, index) {
4543
4578
  }
4544
4579
  var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
4545
4580
  var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
4581
+ var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
4546
4582
  function legacySlugPattern(legacySlugs) {
4547
4583
  if (legacySlugs.length === 0)
4548
4584
  return null;
4549
4585
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
4550
4586
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
4551
4587
  }
4552
- function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4588
+ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4553
4589
  const findings = [];
4554
4590
  const legacyPattern = legacySlugPattern(legacySlugs);
4555
4591
  const grandfathered = new Set(specGrandfather);
@@ -4561,8 +4597,12 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4561
4597
  const productPatterns = [
4562
4598
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4563
4599
  ];
4600
+ const specPatterns = [
4601
+ ...patterns,
4602
+ { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
4603
+ ];
4564
4604
  for (const file of files) {
4565
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4605
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
4566
4606
  if (!cls || cls === "internal")
4567
4607
  continue;
4568
4608
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
@@ -4571,15 +4611,16 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4571
4611
  continue;
4572
4612
  const blocking = cls === "product" || cls === "spec";
4573
4613
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4574
- const patternsToRun = cls === "product" ? productPatterns : patterns;
4614
+ const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
4575
4615
  for (const { pattern, what, group } of patternsToRun) {
4576
4616
  pattern.lastIndex = 0;
4577
4617
  let match = pattern.exec(scrubbed);
4578
4618
  while (match !== null) {
4579
4619
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
4620
+ const citedIndex = match.index + match[0].indexOf(cited);
4580
4621
  findings.push({
4581
4622
  file: file.path,
4582
- line: lineAt(scrubbed, match.index),
4623
+ line: lineAt(scrubbed, citedIndex),
4583
4624
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4584
4625
  blocking
4585
4626
  });
@@ -4765,9 +4806,9 @@ function checkSourceComments(files, allowlist = []) {
4765
4806
  }
4766
4807
  return findings;
4767
4808
  }
4768
- function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4809
+ function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4769
4810
  return [
4770
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather),
4811
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
4771
4812
  ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4772
4813
  ];
4773
4814
  }
@@ -5232,7 +5273,8 @@ var TaskStatusItemSchema = z.object({
5232
5273
  }).merge(ObservedSchema);
5233
5274
  var TaskStatusResultSchema = z.object({
5234
5275
  items: z.array(TaskStatusItemSchema),
5235
- nextCursor: z.string().nullable()
5276
+ nextCursor: z.string().nullable(),
5277
+ table: z.string()
5236
5278
  });
5237
5279
  var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
5238
5280
  var EscalationInputsSchema = z.object({
@@ -5576,6 +5618,14 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5576
5618
  }
5577
5619
  return findings;
5578
5620
  }
5621
+ // ../../packages/aeg-core/src/gate-cutovers.ts
5622
+ var NO_GATE_CUTOVERS = {
5623
+ objectivesSinceIssue: null,
5624
+ briefSectionsSinceIssue: null,
5625
+ documentationSinceIssue: null,
5626
+ briefRulesSincePr: null,
5627
+ agentBoxesRefusedSincePr: null
5628
+ };
5579
5629
  // ../../packages/aeg-core/src/dev-review-loop/types.ts
5580
5630
  var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5581
5631
  // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
@@ -6025,6 +6075,8 @@ function attemptFromEnv(value) {
6025
6075
  function provenanceFor(input) {
6026
6076
  if (input.provenance)
6027
6077
  return input.provenance;
6078
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
6079
+ return "unavailable";
6028
6080
  if (input.env.role || input.env.task)
6029
6081
  return "env_correlated";
6030
6082
  return "unavailable";
@@ -6045,7 +6097,7 @@ function buildHeader(input) {
6045
6097
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6046
6098
  const round = roundFromEnv(input.env.round);
6047
6099
  const subject = {
6048
- issue: issueFromTask(input.env.task),
6100
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6049
6101
  role,
6050
6102
  ...round !== undefined ? { round } : {},
6051
6103
  ...input.subject ?? {}
@@ -6485,7 +6537,12 @@ var VinayaConfigSchema = z4.object({
6485
6537
  allowlist: z4.array(z4.string().min(1)).optional(),
6486
6538
  severity: z4.enum(["warning", "error"]).optional()
6487
6539
  }).optional(),
6488
- specGrandfather: z4.array(z4.string().min(1)).optional()
6540
+ specGrandfather: z4.array(z4.string().min(1)).optional(),
6541
+ specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6542
+ message: "must be a repository-relative path, not an absolute one"
6543
+ }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
6544
+ message: "must stay inside the repository — no `..` segment"
6545
+ })).optional()
6489
6546
  }).optional(),
6490
6547
  projects: z4.array(ProjectEntrySchema).optional(),
6491
6548
  dispatch: z4.object({
@@ -6499,6 +6556,13 @@ var VinayaConfigSchema = z4.object({
6499
6556
  securityThreshold: z4.string().min(1).optional(),
6500
6557
  maxRounds: z4.number().optional()
6501
6558
  }).optional(),
6559
+ gateCutovers: z4.object({
6560
+ objectivesSinceIssue: z4.number().int().nonnegative().optional(),
6561
+ briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
6562
+ documentationSinceIssue: z4.number().int().nonnegative().optional(),
6563
+ briefRulesSincePr: z4.number().int().nonnegative().optional(),
6564
+ agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
6565
+ }).optional(),
6502
6566
  prePush: z4.object({
6503
6567
  alwaysRun: z4.array(z4.string()).optional()
6504
6568
  }).optional(),
@@ -6636,6 +6700,18 @@ function resolveReviewPolicy(config) {
6636
6700
  maxRounds
6637
6701
  };
6638
6702
  }
6703
+ function resolveGateCutovers(config) {
6704
+ const raw = config?.gateCutovers;
6705
+ if (!raw)
6706
+ return NO_GATE_CUTOVERS;
6707
+ return {
6708
+ objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
6709
+ briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
6710
+ documentationSinceIssue: raw.documentationSinceIssue ?? null,
6711
+ briefRulesSincePr: raw.briefRulesSincePr ?? null,
6712
+ agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
6713
+ };
6714
+ }
6639
6715
  function resolveRuntimeDirSetting(config) {
6640
6716
  return config?.runtimeDir ?? null;
6641
6717
  }
@@ -6826,9 +6902,9 @@ function loadConfig() {
6826
6902
  var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
6827
6903
 
6828
6904
  // src/lib/brief-assembly.ts
6829
- import { execFileSync as execFileSync4 } from "node:child_process";
6830
- import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "node:fs";
6831
- import { join as join3 } from "node:path";
6905
+ import { execFileSync as execFileSync5 } from "node:child_process";
6906
+ import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
6907
+ import { join as join4 } from "node:path";
6832
6908
 
6833
6909
  // ../../packages/sources/src/commands.ts
6834
6910
  var COMMANDS = [
@@ -7334,6 +7410,10 @@ var COMMANDS = [
7334
7410
  flag: "--role <name>",
7335
7411
  description: "Resolve to a specific role file (roles/<name>.md) instead of the front door"
7336
7412
  },
7413
+ {
7414
+ flag: "--template <name>",
7415
+ description: "Print a template the package ships (templates/<name>-template.md) instead of the front door"
7416
+ },
7337
7417
  {
7338
7418
  flag: "--print",
7339
7419
  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."
@@ -7669,13 +7749,47 @@ function packageRoot(moduleUrl) {
7669
7749
  return dir;
7670
7750
  }
7671
7751
 
7752
+ // src/commands/doctrine.ts
7753
+ import { execFileSync as execFileSync4 } from "node:child_process";
7754
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
7755
+ import { dirname as dirname3, join as join3, sep } from "node:path";
7756
+ import matter2 from "gray-matter";
7757
+ var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
7758
+ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7759
+ return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
7760
+ }
7761
+ function gitToplevel(cwd) {
7762
+ try {
7763
+ return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
7764
+ encoding: "utf8",
7765
+ stdio: ["ignore", "pipe", "pipe"]
7766
+ }).trim();
7767
+ } catch {
7768
+ return null;
7769
+ }
7770
+ }
7771
+ function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7772
+ const toplevel = gitToplevel(cwd);
7773
+ if (toplevel !== null) {
7774
+ const treeRoot = join3(toplevel, "aeg-root");
7775
+ if (existsSync3(join3(treeRoot, "roles")))
7776
+ return { root: treeRoot, source: "tree" };
7777
+ }
7778
+ const fromSource = !pkg.split(sep).includes("node_modules");
7779
+ const bundleRoot = fromSource ? join3(dirname3(dirname3(pkg)), "aeg-root") : join3(pkg, "aeg-root");
7780
+ return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
7781
+ }
7782
+ function hasDoctrineEntry(root) {
7783
+ return existsSync3(join3(root, ...ENTRY_SEGMENTS));
7784
+ }
7785
+
7672
7786
  // src/lib/brief-assembly.ts
7673
7787
  var PACKAGE_ROOT = packageRoot(import.meta.url);
7674
- var PACKAGED_TEMPLATE_PATH = join3(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
7675
- var TEMPLATE_PATH = existsSync3(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join3(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7788
+ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
7789
+ var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7676
7790
  function git(args) {
7677
7791
  try {
7678
- return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7792
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7679
7793
  } catch {
7680
7794
  return "";
7681
7795
  }
@@ -7688,14 +7802,14 @@ function expandGlob(glob) {
7688
7802
  var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7689
7803
 
7690
7804
  // src/checks/registry.ts
7691
- import { existsSync as existsSync4 } from "node:fs";
7692
- import { join as join4 } from "node:path";
7693
- var DIST_BIN_DIR = join4(packageRoot(import.meta.url), "dist", "checks", "bin");
7694
- var SRC_BIN_DIR = join4(packageRoot(import.meta.url), "src", "checks", "bin");
7695
- var BIN_DIR = existsSync4(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7805
+ import { existsSync as existsSync5 } from "node:fs";
7806
+ import { join as join5 } from "node:path";
7807
+ var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
7808
+ var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
7809
+ var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7696
7810
  var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
7697
7811
  function bin(name) {
7698
- return join4(BIN_DIR, `${name}${BIN_EXT}`);
7812
+ return join5(BIN_DIR, `${name}${BIN_EXT}`);
7699
7813
  }
7700
7814
  var REGISTRY = [
7701
7815
  [
@@ -8259,21 +8373,21 @@ import { randomUUID as randomUUID2 } from "node:crypto";
8259
8373
  import {
8260
8374
  closeSync as closeSync3,
8261
8375
  constants as fsConstants3,
8262
- existsSync as existsSync6,
8376
+ existsSync as existsSync7,
8263
8377
  fstatSync as fstatSync2,
8264
8378
  mkdirSync as mkdirSync3,
8265
8379
  openSync as openSync3,
8266
- readFileSync as readFileSync5,
8380
+ readFileSync as readFileSync6,
8267
8381
  renameSync as renameSync2,
8268
8382
  writeSync as writeSync2
8269
8383
  } from "node:fs";
8270
8384
  import { hostname as osHostname, homedir as homedir3 } from "node:os";
8271
- import { dirname as dirname5, join as join7 } from "node:path";
8385
+ import { dirname as dirname6, join as join8 } from "node:path";
8272
8386
  import { promisify as promisify5 } from "node:util";
8273
8387
 
8274
8388
  // src/lib/run-paths.ts
8275
- import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
8276
- import { dirname as dirname3, join as join5, resolve as resolvePath } from "node:path";
8389
+ import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
8390
+ import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
8277
8391
  var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8278
8392
  function isSafeRepoSegment(segment) {
8279
8393
  return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
@@ -8284,7 +8398,7 @@ function repoSegment(repo) {
8284
8398
  return `${repo.owner}-${repo.repo}`;
8285
8399
  }
8286
8400
  function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
8287
- return join5(home, "runtime", repoSegment(repo));
8401
+ return join6(home, "runtime", repoSegment(repo));
8288
8402
  }
8289
8403
  function resolveRuntimeDir(input) {
8290
8404
  const local = resolveRuntimeDirSetting(input.localConfig);
@@ -8344,9 +8458,9 @@ function repoRootSync(start = process.cwd()) {
8344
8458
  return null;
8345
8459
  }
8346
8460
  for (;; ) {
8347
- if (existsSync5(join5(dir, ".git")))
8461
+ if (existsSync6(join6(dir, ".git")))
8348
8462
  return dir;
8349
- const parent = dirname3(dir);
8463
+ const parent = dirname4(dir);
8350
8464
  if (parent === dir)
8351
8465
  return null;
8352
8466
  dir = parent;
@@ -8361,7 +8475,7 @@ import {
8361
8475
  mkdirSync as mkdirSync2,
8362
8476
  openSync as openSync2,
8363
8477
  linkSync,
8364
- readFileSync as readFileSync4,
8478
+ readFileSync as readFileSync5,
8365
8479
  renameSync,
8366
8480
  statSync,
8367
8481
  unlinkSync,
@@ -8371,7 +8485,7 @@ import {
8371
8485
  } from "node:fs";
8372
8486
  import { randomUUID } from "node:crypto";
8373
8487
  import { homedir as homedir2 } from "node:os";
8374
- import { dirname as dirname4, join as join6 } from "node:path";
8488
+ import { dirname as dirname5, join as join7 } from "node:path";
8375
8489
  var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
8376
8490
  var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
8377
8491
  var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
@@ -8387,7 +8501,7 @@ function isEnoent(err) {
8387
8501
  var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
8388
8502
  function tryCreateLock(lockPath, token) {
8389
8503
  try {
8390
- mkdirSync2(dirname4(lockPath), { recursive: true, mode: 448 });
8504
+ mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
8391
8505
  const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
8392
8506
  try {
8393
8507
  writeSync(fd, `${token}
@@ -8452,7 +8566,7 @@ function acquireDrainLock(lockPath) {
8452
8566
  function renewDrainLock(lockPath, token) {
8453
8567
  let holder;
8454
8568
  try {
8455
- holder = readFileSync4(lockPath, "utf8").trim();
8569
+ holder = readFileSync5(lockPath, "utf8").trim();
8456
8570
  } catch (err) {
8457
8571
  if (!isEnoent(err))
8458
8572
  throw err;
@@ -8472,7 +8586,7 @@ function renewDrainLock(lockPath, token) {
8472
8586
  }
8473
8587
  function releaseDrainLock(lockPath, token) {
8474
8588
  try {
8475
- const holder = readFileSync4(lockPath, "utf8").trim();
8589
+ const holder = readFileSync5(lockPath, "utf8").trim();
8476
8590
  if (holder !== token)
8477
8591
  return;
8478
8592
  unlinkSync(lockPath);
@@ -8522,7 +8636,7 @@ function queueLines(buf) {
8522
8636
  return lines;
8523
8637
  }
8524
8638
  function removeQueueHead(path, cut) {
8525
- const remaining = readFileSync4(path);
8639
+ const remaining = readFileSync5(path);
8526
8640
  writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
8527
8641
  }
8528
8642
  function queueBucketSize(path) {
@@ -8543,7 +8657,7 @@ function queueBucketSize(path) {
8543
8657
  function readQueueFile(path) {
8544
8658
  if (queueBucketSize(path) === null)
8545
8659
  return null;
8546
- return readFileSync4(path);
8660
+ return readFileSync5(path);
8547
8661
  }
8548
8662
  function rejectLine(rejectedPath, reason, status, identity, raw) {
8549
8663
  const record = JSON.stringify({
@@ -8658,7 +8772,7 @@ async function drainRenamedAside(args, livePath, source) {
8658
8772
  async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
8659
8773
  const resolved = await resolveRepo();
8660
8774
  const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
8661
- const outboxRoot = () => join6(GLOBAL_VINAYA_HOME, "outbox");
8775
+ const outboxRoot = () => join7(GLOBAL_VINAYA_HOME, "outbox");
8662
8776
  const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
8663
8777
  const lockPath = `${path}.flush-lock`;
8664
8778
  const lockToken = acquireDrainLock(lockPath);
@@ -8770,7 +8884,7 @@ async function defaultResolveLogDestination(repo, env) {
8770
8884
  trustAnchorConfig: unattended ? await processTrustAnchor() : null,
8771
8885
  unattended,
8772
8886
  env,
8773
- defaultFolder: join7(await runtimeDirForRepoAsync(repo), "logs"),
8887
+ defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
8774
8888
  repoRoot: repoRootSync()
8775
8889
  });
8776
8890
  }
@@ -8785,7 +8899,7 @@ async function resolveDoctrine(cwd, vinayaVersion) {
8785
8899
  } catch (err) {
8786
8900
  return isEnoent2(err) ? "unknown" : vinayaVersion;
8787
8901
  }
8788
- if (!existsSync6(join7(toplevel, "aeg-root", "roles")))
8902
+ if (!existsSync7(join8(toplevel, "aeg-root", "roles")))
8789
8903
  return vinayaVersion;
8790
8904
  try {
8791
8905
  const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
@@ -8794,9 +8908,99 @@ async function resolveDoctrine(cwd, vinayaVersion) {
8794
8908
  return vinayaVersion;
8795
8909
  }
8796
8910
  }
8911
+ var TRANCHE_SLUG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
8912
+ function taskRefFromBranch2(branch) {
8913
+ const backlog = /^task\/issue-(\d+)$/.exec(branch);
8914
+ if (backlog) {
8915
+ const issue = Number(backlog[1]);
8916
+ return Number.isSafeInteger(issue) && issue > 0 ? { kind: "issue", issue } : null;
8917
+ }
8918
+ const tranche = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
8919
+ if (tranche && TRANCHE_SLUG_PATTERN.test(tranche[1] ?? "")) {
8920
+ return { kind: "tranche", tranche: tranche[1], taskId: tranche[2] };
8921
+ }
8922
+ return null;
8923
+ }
8924
+ var TRANCHE_ISSUE_LIST_LIMIT = 200;
8925
+ async function issueForTrancheTask(tranche, taskId, cwd, repo) {
8926
+ let stdout;
8927
+ try {
8928
+ ({ stdout } = await execFileAsync5("gh", [
8929
+ "issue",
8930
+ "list",
8931
+ "--state",
8932
+ "all",
8933
+ "--label",
8934
+ `vinaya/tranche:${tranche}`,
8935
+ "--json",
8936
+ "number,title,labels",
8937
+ "--limit",
8938
+ String(TRANCHE_ISSUE_LIST_LIMIT),
8939
+ ...repo === null ? [] : ["--repo", repo]
8940
+ ], {
8941
+ cwd,
8942
+ encoding: "utf8",
8943
+ maxBuffer: 8 * 1024 * 1024,
8944
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8945
+ killSignal: "SIGKILL"
8946
+ }));
8947
+ } catch {
8948
+ return null;
8949
+ }
8950
+ let issues;
8951
+ try {
8952
+ issues = JSON.parse(stdout);
8953
+ } catch {
8954
+ return null;
8955
+ }
8956
+ for (const issue of issues) {
8957
+ const ref = resolveTaskIssueRef(issue.title, issue.labels.map((l) => l.name));
8958
+ if (ref && ref.trancheSlug === tranche && ref.taskId === taskId)
8959
+ return issue.number;
8960
+ }
8961
+ return null;
8962
+ }
8963
+ async function confirmBacklogIssue(issue, cwd, repo) {
8964
+ let stdout;
8965
+ try {
8966
+ ({ stdout } = await execFileAsync5("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
8967
+ cwd,
8968
+ encoding: "utf8",
8969
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8970
+ killSignal: "SIGKILL"
8971
+ }));
8972
+ } catch (err) {
8973
+ const stderr = typeof err.stderr === "string" ? err.stderr : "";
8974
+ return /could not resolve|not found|no such|does not exist/i.test(stderr) ? "denied" : "unknown";
8975
+ }
8976
+ try {
8977
+ return JSON.parse(stdout).number === issue ? "confirmed" : "denied";
8978
+ } catch {
8979
+ return "unknown";
8980
+ }
8981
+ }
8982
+ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
8983
+ let branch;
8984
+ try {
8985
+ branch = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
8986
+ encoding: "utf8",
8987
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8988
+ killSignal: "SIGKILL"
8989
+ })).stdout.trim();
8990
+ } catch {
8991
+ return null;
8992
+ }
8993
+ const named = branch === "HEAD" ? env.GITHUB_HEAD_REF ?? "" : branch;
8994
+ const ref = taskRefFromBranch2(named);
8995
+ if (ref === null)
8996
+ return null;
8997
+ if (ref.kind === "tranche")
8998
+ return await issueForTrancheTask(ref.tranche, ref.taskId, cwd, repo);
8999
+ return await confirmBacklogIssue(ref.issue, cwd, repo) === "denied" ? null : ref.issue;
9000
+ }
8797
9001
  function readVinayaVersion() {
8798
9002
  try {
8799
- const pkg = JSON.parse(readFileSync5(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
9003
+ const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
8800
9004
  return pkg.version ?? "unknown";
8801
9005
  } catch {
8802
9006
  return "unknown";
@@ -8806,10 +9010,15 @@ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8806
9010
  function isSafeRepoSegment3(segment) {
8807
9011
  return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
8808
9012
  }
9013
+ function safeRepoSlug(repo) {
9014
+ if (repo === null)
9015
+ return null;
9016
+ return isSafeRepoSegment3(repo.owner) && isSafeRepoSegment3(repo.repo) ? `${repo.owner}/${repo.repo}` : null;
9017
+ }
8809
9018
  function outboxPathFor(deps, repo, issue) {
8810
9019
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
8811
9020
  const fileName = `${issue ?? "none"}.ndjson`;
8812
- return join7(deps.outboxRoot(), dirName, fileName);
9021
+ return join8(deps.outboxRoot(), dirName, fileName);
8813
9022
  }
8814
9023
  function hostFromEnv(env) {
8815
9024
  if (env.GITHUB_ACTIONS)
@@ -8827,9 +9036,21 @@ function defaultStderr(message) {
8827
9036
  warnedThisProcess = true;
8828
9037
  process.stderr.write(message);
8829
9038
  }
9039
+ var branchIssueFallbackEnabled = true;
9040
+ var branchIssueByCwd = new Map;
9041
+ function branchIssueRead(key, read, shared) {
9042
+ if (!shared)
9043
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9044
+ const cached = branchIssueByCwd.get(key);
9045
+ if (cached !== undefined)
9046
+ return cached;
9047
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9048
+ branchIssueByCwd.set(key, reading);
9049
+ return reading;
9050
+ }
8830
9051
  function defaultDeps() {
8831
9052
  return {
8832
- outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
9053
+ outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
8833
9054
  home: () => homedir3(),
8834
9055
  hostname: () => osHostname(),
8835
9056
  cwd: () => process.cwd(),
@@ -8854,7 +9075,7 @@ function guardedAppendOpen(path) {
8854
9075
  }
8855
9076
  function appendHardenedLine(path, line) {
8856
9077
  try {
8857
- mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
9078
+ mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
8858
9079
  const fd = guardedAppendOpen(path);
8859
9080
  if (fd === undefined)
8860
9081
  return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
@@ -8873,7 +9094,7 @@ function appendHardenedLine(path, line) {
8873
9094
  function reportRotationOverflow(backupPath, warn) {
8874
9095
  let raw;
8875
9096
  try {
8876
- raw = readFileSync5(backupPath, "utf8");
9097
+ raw = readFileSync6(backupPath, "utf8");
8877
9098
  } catch {
8878
9099
  return;
8879
9100
  }
@@ -8896,7 +9117,7 @@ function reportRotationOverflow(backupPath, warn) {
8896
9117
  }
8897
9118
  function appendLine(path, line, warn) {
8898
9119
  try {
8899
- mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
9120
+ mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
8900
9121
  let fd = guardedAppendOpen(path);
8901
9122
  if (fd === undefined) {
8902
9123
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -8937,7 +9158,11 @@ function appendLine(path, line, warn) {
8937
9158
  }
8938
9159
  }
8939
9160
  function createLogSink(overrides = {}) {
8940
- const deps = { ...defaultDeps(), ...overrides };
9161
+ const deps = {
9162
+ ...defaultDeps(),
9163
+ resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
9164
+ ...overrides
9165
+ };
8941
9166
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
8942
9167
  const processId = randomUUID2();
8943
9168
  let seq = 0;
@@ -8957,6 +9182,19 @@ function createLogSink(overrides = {}) {
8957
9182
  }
8958
9183
  return doctrineCache;
8959
9184
  };
9185
+ const readerIsReal = overrides.resolveBranchIssue === undefined;
9186
+ let ownBranchIssue;
9187
+ const branchIssueOnce = (repo) => {
9188
+ if (!branchIssueFallbackEnabled)
9189
+ return Promise.resolve(null);
9190
+ const slug = safeRepoSlug(repo);
9191
+ const read = () => deps.resolveBranchIssue(slug);
9192
+ if (readerIsReal)
9193
+ return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
9194
+ if (ownBranchIssue === undefined)
9195
+ ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
9196
+ return ownBranchIssue;
9197
+ };
8960
9198
  let resolveRepoCache;
8961
9199
  const resolveRepoOnce = () => {
8962
9200
  if (resolveRepoCache === undefined)
@@ -8979,6 +9217,7 @@ function createLogSink(overrides = {}) {
8979
9217
  };
8980
9218
  let drainChain = Promise.resolve();
8981
9219
  const pendingWrites = new Set;
9220
+ let writeChain = Promise.resolve();
8982
9221
  const scheduleWebhookDrain = (issue, url, headers) => {
8983
9222
  drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
8984
9223
  return;
@@ -9001,7 +9240,14 @@ function createLogSink(overrides = {}) {
9001
9240
  attempt: env.VINAYA_ATTEMPT,
9002
9241
  parent: env.VINAYA_PARENT_EVENT
9003
9242
  };
9004
- const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
9243
+ const write = async () => {
9244
+ const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
9245
+ if (resolvedDestination.kind === "none") {
9246
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9247
+ `);
9248
+ return;
9249
+ }
9250
+ const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
9005
9251
  const header = buildHeader({
9006
9252
  now,
9007
9253
  runId,
@@ -9012,15 +9258,11 @@ function createLogSink(overrides = {}) {
9012
9258
  host,
9013
9259
  hostname: deps.hostname(),
9014
9260
  env: envFields,
9261
+ branchIssue,
9015
9262
  eventId: randomUUID2(),
9016
9263
  processId,
9017
9264
  inputVersions: deps.inputVersions()
9018
9265
  });
9019
- if (resolvedDestination.kind === "none") {
9020
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9021
- `);
9022
- return;
9023
- }
9024
9266
  const full = { ...e, ...header };
9025
9267
  const parsed = LogEventSchema.safeParse(full);
9026
9268
  if (!parsed.success) {
@@ -9037,10 +9279,12 @@ function createLogSink(overrides = {}) {
9037
9279
  } else {
9038
9280
  appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9039
9281
  }
9040
- }).catch((err) => {
9282
+ };
9283
+ const written = writeChain.then(write).catch((err) => {
9041
9284
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
9042
9285
  `);
9043
9286
  });
9287
+ writeChain = written;
9044
9288
  pendingWrites.add(written);
9045
9289
  written.finally(() => pendingWrites.delete(written));
9046
9290
  } 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
  }
@@ -9202,7 +9446,7 @@ var CHECK_NAME = "exec-bits";
9202
9446
  var EXECUTABLE_MODE = "100755";
9203
9447
  function git2(args) {
9204
9448
  try {
9205
- return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9449
+ return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9206
9450
  } catch {
9207
9451
  return null;
9208
9452
  }
@@ -9216,7 +9460,7 @@ function indexMode(path) {
9216
9460
  }
9217
9461
  function hasShebang(path) {
9218
9462
  try {
9219
- return readFileSync6(path, "utf8").startsWith("#!");
9463
+ return readFileSync7(path, "utf8").startsWith("#!");
9220
9464
  } catch {
9221
9465
  return false;
9222
9466
  }