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