@attalabs/vinaya 0.33.0 → 0.35.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 (143) hide show
  1. package/LICENSE +104 -201
  2. package/README.md +1 -1
  3. package/aeg-root/enforcement.md +1 -1
  4. package/aeg-root/glossary.md +4 -0
  5. package/aeg-root/roles/developer.md +3 -0
  6. package/aeg-root/roles/operator.md +30 -10
  7. package/aeg-root/roles/planner/reference.md +3 -2
  8. package/aeg-root/roles/planner.md +3 -1
  9. package/aeg-root/templates/brief-template.md +9 -7
  10. package/aeg-root/templates/pr-report-template.md +3 -1
  11. package/dist/checks/bin/check-body-bare-digits.js +107 -28
  12. package/dist/checks/bin/check-branch-topology.js +94 -25
  13. package/dist/checks/bin/check-brief-shape.js +113 -33
  14. package/dist/checks/bin/check-changeset-coverage.js +369 -92
  15. package/dist/checks/bin/check-closes-n.js +94 -25
  16. package/dist/checks/bin/check-coherence.js +124 -29
  17. package/dist/checks/bin/check-dead-branch-push.js +79 -25
  18. package/dist/checks/bin/check-dispatch-readiness.js +122 -28
  19. package/dist/checks/bin/check-doc-coverage-push.js +365 -88
  20. package/dist/checks/bin/check-doc-coverage.js +367 -90
  21. package/dist/checks/bin/check-doctrine-no-procedures.js +107 -28
  22. package/dist/checks/bin/check-doctrine-portability.js +366 -89
  23. package/dist/checks/bin/check-evidence-fresh.js +338 -61
  24. package/dist/checks/bin/check-exec-bits.js +363 -86
  25. package/dist/checks/bin/check-first-push-dispatch.js +122 -28
  26. package/dist/checks/bin/check-issue-assignment.js +94 -25
  27. package/dist/checks/bin/check-issue-milestone-attach.js +79 -25
  28. package/dist/checks/bin/check-issue-objectives-numbering.js +606 -26
  29. package/dist/checks/bin/check-issue-parts-coverage.js +79 -25
  30. package/dist/checks/bin/check-issue-surface-globs.js +162 -34
  31. package/dist/checks/bin/check-issue-title-grammar.js +79 -25
  32. package/dist/checks/bin/check-issue-tranche-label.js +79 -25
  33. package/dist/checks/bin/check-main-branch-refusal.js +79 -25
  34. package/dist/checks/bin/check-no-disk-state.js +79 -25
  35. package/dist/checks/bin/check-pr-premise-reassert.js +107 -28
  36. package/dist/checks/bin/check-pr-report-density.js +79 -25
  37. package/dist/checks/bin/check-principal-test-plan-wait.js +79 -25
  38. package/dist/checks/bin/check-quoted-command.js +282 -39
  39. package/dist/checks/bin/check-reader-resolvable-prose.js +333 -47
  40. package/dist/checks/bin/check-registry-gates.js +79 -25
  41. package/dist/checks/bin/check-retired-vocabulary.js +282 -39
  42. package/dist/checks/bin/check-review-gate.js +111 -31
  43. package/dist/checks/bin/check-single-plan-pr.js +79 -25
  44. package/dist/checks/bin/check-surface-scope.js +94 -25
  45. package/dist/checks/bin/check-test-plan.js +79 -25
  46. package/dist/checks/bin/check-token-collection-wired.js +79 -25
  47. package/dist/checks/bin/check-token-report.js +79 -25
  48. package/dist/checks/bin/check-workspace-escape.js +364 -87
  49. package/dist/index.js +2713 -1609
  50. package/dist/lib/pre-push-cache-test-run.js +226 -16
  51. package/dist/lib/pre-push-select-tests.js +48 -5
  52. package/package.json +2 -2
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +153 -37
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +87 -24
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +9 -2
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +13 -3
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +7 -0
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +5 -2
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +116 -20
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +100 -4
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-cutovers.ts +49 -0
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +60 -4
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +138 -54
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +26 -3
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives-cutover-config.ts +31 -0
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +15 -6
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +122 -23
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +18 -3
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +24 -0
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +15 -10
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +16 -0
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +194 -0
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +312 -53
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +62 -8
  75. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  77. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +4 -4
  114. 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
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__18paley._.js → [root-of-the-server]__0zc_0gx._.js} +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +2 -2
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  129. 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
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  134. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ko698wh8xx2g.css +1 -0
  135. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{22s44f5k3ecmj.js → 3goaig_rysc6p.js} +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1ce2dj27_cgbj.js → 3ip5z3cf43bgo.js} +4 -4
  137. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{34hhdtbp20krb.js → 3u9emqjwpd0t9.js} +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  139. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bm4nrrzwc7zi.css +0 -1
  140. /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/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  141. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{vl7QVqELe1AQ-9kaOd9mR → ca66rAHI_w9D7S7ceXDvR}/_buildManifest.js +0 -0
  142. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{vl7QVqELe1AQ-9kaOd9mR → ca66rAHI_w9D7S7ceXDvR}/_clientMiddlewareManifest.js +0 -0
  143. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{vl7QVqELe1AQ-9kaOd9mR → ca66rAHI_w9D7S7ceXDvR}/_ssgManifest.js +0 -0
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/checks/bin/check-reader-resolvable-prose.ts
4
- import { existsSync as existsSync8, readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync2 } from "node:fs";
5
- import { extname, join as join10 } from "node:path";
4
+ import { existsSync as existsSync8, readdirSync as readdirSync3, readFileSync as readFileSync7, realpathSync as realpathSync3, statSync as statSync2 } from "node:fs";
5
+ import { extname, isAbsolute as isAbsolute2, join as join10, relative as relative2, resolve as resolve3, sep as sep2 } from "node:path";
6
6
  // ../../packages/aeg-core/src/gate-audience.ts
7
7
  var GATE_AUDIENCE = {
8
8
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -197,8 +197,8 @@ function maskIndentedCode(body, fill) {
197
197
  var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
198
198
  var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
199
199
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
200
- var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
201
- var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
200
+ var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+$/i;
201
+ var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+)$/i;
202
202
  function splitSlugQualifiedEdge(edge) {
203
203
  const m = edge.trim().match(SLUG_QUALIFIED_ID);
204
204
  if (!m)
@@ -2619,7 +2619,7 @@ function isIssueNotFoundError(err) {
2619
2619
  return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
2620
2620
  }
2621
2621
  function resolveObjectivesSource(prBody, issue, cutoverIssue) {
2622
- if (issue !== null && issue < cutoverIssue)
2622
+ if (issue !== null && cutoverIssue !== null && issue < cutoverIssue)
2623
2623
  return { kind: "none" };
2624
2624
  if (issue !== null)
2625
2625
  return { kind: "issue", issue };
@@ -2895,9 +2895,18 @@ var COMMIT_TYPES = [
2895
2895
  ];
2896
2896
  var COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join("|")})(\\([a-z0-9-]+\\))?: \\S`);
2897
2897
  function checkForgeTitle(title) {
2898
- const taskStyle = /^\[[a-z0-9._-]+\] \S+ — \S/;
2898
+ const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/;
2899
2899
  if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title))
2900
2900
  return { status: "pass", errors: [] };
2901
+ const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title);
2902
+ if (letteredTaskId) {
2903
+ return {
2904
+ status: "fail",
2905
+ errors: [
2906
+ `brief-validation title: "${title}" names task id \`${letteredTaskId[1]}\` — task ids are whole numbers (\`1\`, \`2\`), never lettered (\`2a\`). \`vinaya task run\` and \`task dispatch\` refuse a non-numeric id, so a plan titled this way names a task that cannot be started.`
2907
+ ]
2908
+ };
2909
+ }
2901
2910
  return {
2902
2911
  status: "fail",
2903
2912
  errors: [
@@ -2930,19 +2939,31 @@ function checkNoAgentBoxes(prBody) {
2930
2939
  ]
2931
2940
  };
2932
2941
  }
2933
- function rolloutThresholdFor(message) {
2942
+ function rolloutRuleFor(message) {
2934
2943
  if (message.startsWith("brief-validation unpinned code claim:") || message.startsWith("brief-validation commands carry output:") || message.startsWith("brief-validation consumer tests:") || message.startsWith("brief-validation defeat cases:")) {
2935
- return BRIEF_RULES_SINCE_PR;
2944
+ return "briefRules";
2936
2945
  }
2937
2946
  if (message.startsWith("brief-validation no agent boxes:"))
2938
- return AGENT_BOXES_REFUSED_SINCE_PR;
2947
+ return "agentBoxes";
2939
2948
  return null;
2940
2949
  }
2941
- function partitionBriefErrorsByRollout(errors, prNumber) {
2950
+ var DEFAULT_BRIEF_ROLLOUT_CUTOVERS = {
2951
+ briefRulesSincePr: BRIEF_RULES_SINCE_PR,
2952
+ agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
2953
+ };
2954
+ function rolloutThresholdFor(message, cutovers) {
2955
+ const rule = rolloutRuleFor(message);
2956
+ if (rule === "briefRules")
2957
+ return cutovers.briefRulesSincePr;
2958
+ if (rule === "agentBoxes")
2959
+ return cutovers.agentBoxesRefusedSincePr;
2960
+ return null;
2961
+ }
2962
+ function partitionBriefErrorsByRollout(errors, prNumber, cutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS) {
2942
2963
  const blocking = [];
2943
2964
  const info = [];
2944
2965
  for (const e of errors) {
2945
- const threshold = rolloutThresholdFor(e);
2966
+ const threshold = rolloutThresholdFor(e, cutovers);
2946
2967
  const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold;
2947
2968
  (grandfathered ? info : blocking).push(e);
2948
2969
  }
@@ -3410,8 +3431,8 @@ function checkIssueRationale(body) {
3410
3431
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3411
3432
  }
3412
3433
  var OBJECTIVES_SINCE_ISSUE = 404;
3413
- function checkIssueObjectives(body, issueNumber) {
3414
- if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE)
3434
+ function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3435
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3415
3436
  return { status: "pass", errors: [] };
3416
3437
  const result = objectivesOf(body);
3417
3438
  if (result.ok)
@@ -3487,6 +3508,8 @@ function parseIssueSurface(body) {
3487
3508
  function globCoversPath(glob, path) {
3488
3509
  const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
3489
3510
  const p = path.replace(/\/+$/, "");
3511
+ if (g === "*")
3512
+ return !p.includes("/");
3490
3513
  return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
3491
3514
  }
3492
3515
  function checkSurfaceGlobsResolve(body, resolvesToFile) {
@@ -3856,7 +3879,7 @@ function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
3856
3879
  return issueToEntry.get(Number(issueMatch[1]));
3857
3880
  return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
3858
3881
  }
3859
- function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3882
+ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
3860
3883
  const failures = [];
3861
3884
  for (const [slug, issues] of issuesBySlug) {
3862
3885
  for (const issue of issues) {
@@ -3865,7 +3888,7 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3865
3888
  const errors = [
3866
3889
  ...checkIssueRationale(issue.body).errors,
3867
3890
  ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
3868
- ...checkIssueObjectives(issue.body, issue.number).errors,
3891
+ ...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
3869
3892
  ...checkPartsCiteDefinedObjectives(issue.body).errors
3870
3893
  ];
3871
3894
  if (errors.length === 0)
@@ -4488,13 +4511,27 @@ var SHIPS_PREFIX = "aeg-root/";
4488
4511
  function shipsArchivePrefix(shipsPrefix) {
4489
4512
  return `${shipsPrefix}tranches/completed/`;
4490
4513
  }
4491
- function isSpecFile2(path) {
4492
- return path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md");
4514
+ var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
4515
+ function normalizeSpecPath(entry) {
4516
+ let out = entry.replace(/\\/g, "/");
4517
+ while (out.startsWith("./"))
4518
+ out = out.slice(2);
4519
+ out = out.replace(/\/{2,}/g, "/");
4520
+ while (out.endsWith("/"))
4521
+ out = out.slice(0, -1);
4522
+ return out;
4523
+ }
4524
+ function isSpecFile2(path, specPaths) {
4525
+ if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
4526
+ return true;
4527
+ if (!path.endsWith(".md"))
4528
+ return false;
4529
+ return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
4493
4530
  }
4494
4531
  function isClaudeMdFile(path) {
4495
4532
  return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
4496
4533
  }
4497
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4534
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
4498
4535
  if (path.startsWith(shipsPrefix)) {
4499
4536
  return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
4500
4537
  }
@@ -4503,7 +4540,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
4503
4540
  }
4504
4541
  if (isClaudeMdFile(path))
4505
4542
  return "internal";
4506
- if (isSpecFile2(path))
4543
+ if (isSpecFile2(path, specPaths))
4507
4544
  return "spec";
4508
4545
  if (isProductScopeFile(path))
4509
4546
  return "product";
@@ -4532,13 +4569,14 @@ function lineAt(content, index) {
4532
4569
  }
4533
4570
  var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
4534
4571
  var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
4572
+ var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
4535
4573
  function legacySlugPattern(legacySlugs) {
4536
4574
  if (legacySlugs.length === 0)
4537
4575
  return null;
4538
4576
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
4539
4577
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
4540
4578
  }
4541
- function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4579
+ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4542
4580
  const findings = [];
4543
4581
  const legacyPattern = legacySlugPattern(legacySlugs);
4544
4582
  const grandfathered = new Set(specGrandfather);
@@ -4550,8 +4588,12 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4550
4588
  const productPatterns = [
4551
4589
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4552
4590
  ];
4591
+ const specPatterns = [
4592
+ ...patterns,
4593
+ { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
4594
+ ];
4553
4595
  for (const file of files) {
4554
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4596
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
4555
4597
  if (!cls || cls === "internal")
4556
4598
  continue;
4557
4599
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
@@ -4560,15 +4602,16 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4560
4602
  continue;
4561
4603
  const blocking = cls === "product" || cls === "spec";
4562
4604
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4563
- const patternsToRun = cls === "product" ? productPatterns : patterns;
4605
+ const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
4564
4606
  for (const { pattern, what, group } of patternsToRun) {
4565
4607
  pattern.lastIndex = 0;
4566
4608
  let match = pattern.exec(scrubbed);
4567
4609
  while (match !== null) {
4568
4610
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
4611
+ const citedIndex = match.index + match[0].indexOf(cited);
4569
4612
  findings.push({
4570
4613
  file: file.path,
4571
- line: lineAt(scrubbed, match.index),
4614
+ line: lineAt(scrubbed, citedIndex),
4572
4615
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4573
4616
  blocking
4574
4617
  });
@@ -4754,9 +4797,9 @@ function checkSourceComments(files, allowlist = []) {
4754
4797
  }
4755
4798
  return findings;
4756
4799
  }
4757
- function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4800
+ function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4758
4801
  return [
4759
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather),
4802
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
4760
4803
  ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4761
4804
  ];
4762
4805
  }
@@ -5221,7 +5264,8 @@ var TaskStatusItemSchema = z.object({
5221
5264
  }).merge(ObservedSchema);
5222
5265
  var TaskStatusResultSchema = z.object({
5223
5266
  items: z.array(TaskStatusItemSchema),
5224
- nextCursor: z.string().nullable()
5267
+ nextCursor: z.string().nullable(),
5268
+ table: z.string()
5225
5269
  });
5226
5270
  var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
5227
5271
  var EscalationInputsSchema = z.object({
@@ -5565,6 +5609,14 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5565
5609
  }
5566
5610
  return findings;
5567
5611
  }
5612
+ // ../../packages/aeg-core/src/gate-cutovers.ts
5613
+ var NO_GATE_CUTOVERS = {
5614
+ objectivesSinceIssue: null,
5615
+ briefSectionsSinceIssue: null,
5616
+ documentationSinceIssue: null,
5617
+ briefRulesSincePr: null,
5618
+ agentBoxesRefusedSincePr: null
5619
+ };
5568
5620
  // ../../packages/aeg-core/src/dev-review-loop/types.ts
5569
5621
  var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5570
5622
  // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
@@ -6014,6 +6066,8 @@ function attemptFromEnv(value) {
6014
6066
  function provenanceFor(input) {
6015
6067
  if (input.provenance)
6016
6068
  return input.provenance;
6069
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
6070
+ return "unavailable";
6017
6071
  if (input.env.role || input.env.task)
6018
6072
  return "env_correlated";
6019
6073
  return "unavailable";
@@ -6034,7 +6088,7 @@ function buildHeader(input) {
6034
6088
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6035
6089
  const round = roundFromEnv(input.env.round);
6036
6090
  const subject = {
6037
- issue: issueFromTask(input.env.task),
6091
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6038
6092
  role,
6039
6093
  ...round !== undefined ? { round } : {},
6040
6094
  ...input.subject ?? {}
@@ -6527,7 +6581,12 @@ var VinayaConfigSchema = z4.object({
6527
6581
  allowlist: z4.array(z4.string().min(1)).optional(),
6528
6582
  severity: z4.enum(["warning", "error"]).optional()
6529
6583
  }).optional(),
6530
- specGrandfather: z4.array(z4.string().min(1)).optional()
6584
+ specGrandfather: z4.array(z4.string().min(1)).optional(),
6585
+ specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6586
+ message: "must be a repository-relative path, not an absolute one"
6587
+ }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
6588
+ message: "must stay inside the repository — no `..` segment"
6589
+ })).optional()
6531
6590
  }).optional(),
6532
6591
  projects: z4.array(ProjectEntrySchema).optional(),
6533
6592
  dispatch: z4.object({
@@ -6541,6 +6600,13 @@ var VinayaConfigSchema = z4.object({
6541
6600
  securityThreshold: z4.string().min(1).optional(),
6542
6601
  maxRounds: z4.number().optional()
6543
6602
  }).optional(),
6603
+ gateCutovers: z4.object({
6604
+ objectivesSinceIssue: z4.number().int().nonnegative().optional(),
6605
+ briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
6606
+ documentationSinceIssue: z4.number().int().nonnegative().optional(),
6607
+ briefRulesSincePr: z4.number().int().nonnegative().optional(),
6608
+ agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
6609
+ }).optional(),
6544
6610
  prePush: z4.object({
6545
6611
  alwaysRun: z4.array(z4.string()).optional()
6546
6612
  }).optional(),
@@ -6678,6 +6744,18 @@ function resolveReviewPolicy(config) {
6678
6744
  maxRounds
6679
6745
  };
6680
6746
  }
6747
+ function resolveGateCutovers(config) {
6748
+ const raw = config?.gateCutovers;
6749
+ if (!raw)
6750
+ return NO_GATE_CUTOVERS;
6751
+ return {
6752
+ objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
6753
+ briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
6754
+ documentationSinceIssue: raw.documentationSinceIssue ?? null,
6755
+ briefRulesSincePr: raw.briefRulesSincePr ?? null,
6756
+ agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
6757
+ };
6758
+ }
6681
6759
  function resolveRuntimeDirSetting(config) {
6682
6760
  return config?.runtimeDir ?? null;
6683
6761
  }
@@ -6733,7 +6811,8 @@ async function trustAnchorRepoAsync() {
6733
6811
  try {
6734
6812
  const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
6735
6813
  encoding: "utf-8",
6736
- timeout: 1e4
6814
+ timeout: 1e4,
6815
+ killSignal: "SIGKILL"
6737
6816
  });
6738
6817
  return trustAnchorRepoFromRemoteUrl(stdout);
6739
6818
  } catch {
@@ -6794,7 +6873,7 @@ async function ghFetchTrustAnchorConfigAsync() {
6794
6873
  const repo = await trustAnchorRepoAsync();
6795
6874
  if (!repo)
6796
6875
  throw new Error("could not resolve repo identity for the trust-anchor read");
6797
- const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
6876
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
6798
6877
  return stdout;
6799
6878
  }
6800
6879
  function firstLine(err) {
@@ -7387,6 +7466,10 @@ var COMMANDS = [
7387
7466
  flag: "--role <name>",
7388
7467
  description: "Resolve to a specific role file (roles/<name>.md) instead of the front door"
7389
7468
  },
7469
+ {
7470
+ flag: "--template <name>",
7471
+ description: "Print a template the package ships (templates/<name>-template.md) instead of the front door"
7472
+ },
7390
7473
  {
7391
7474
  flag: "--print",
7392
7475
  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."
@@ -7571,6 +7654,17 @@ var COMMANDS = [
7571
7654
  "issue-711 O4: this command — `--task <n>`, `--resume <pr>`, `--cancel <pr>` alike — stays `task run`'s own one-shot debug/direct entry; the watching driver that survives a pause and continues on its own is `task run`'s (see that command's own entry)."
7572
7655
  ],
7573
7656
  status: "shipped"
7657
+ },
7658
+ {
7659
+ name: "log send",
7660
+ description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
7661
+ flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }],
7662
+ details: [
7663
+ "For a run whose events ended up on local disk instead of the configured server — an unattended run that fell back to the local folder because the trust-anchor read could not confirm its `logs.url` (a developer machine slower than the read deadline, or genuinely offline), or a retry queue holding a backlog or a `.draining.ndjson` a dead drain left behind. It moves the local folder's events into the retry queue and drains every queue for this repository through the SAME webhook delivery a live event uses.",
7664
+ "It resolves the destination exactly the way a normal event does — the sink's own decision over `vinaya.config.json`'s `logs` setting, trust-anchor-gated for an unattended caller — never a URL passed on the command line. A repository whose destination is a folder (or none) has nothing to send to a server and the command says so.",
7665
+ "Safe to run more than once: the server stores events by `event_id` and ignores one it already holds, so a re-sent chunk creates no duplicate, and a second run finds the folder emptied and the queue drained."
7666
+ ],
7667
+ status: "shipped"
7574
7668
  }
7575
7669
  ];
7576
7670
  // ../../packages/sources/src/forge-adapter.ts
@@ -8731,7 +8825,14 @@ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeou
8731
8825
 
8732
8826
  // src/lib/log-sink.ts
8733
8827
  var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
8828
+ function describeFolderFallback(reason) {
8829
+ if (reason.kind === "anchor-unreadable") {
8830
+ return `not delivering to the configured log server ${reason.intendedUrl} — the default branch's ` + "vinaya.config.json could not be read to confirm it (the trust-anchor read via `gh` was offline, " + "unauthenticated, or slower than its deadline); events are written to the local folder and can be " + "delivered later with `vinaya log send`";
8831
+ }
8832
+ return `not delivering to the working-tree log server ${reason.intendedUrl} — the default branch's ` + "vinaya.config.json does not declare it, so an unattended run does not honour it (a pull request cannot " + "redirect telemetry); events are written to the local folder";
8833
+ }
8734
8834
  var LOG_CONTEXT_LOOKUP_DEADLINE_MS = 3000;
8835
+ var LOG_DESTINATION_ANCHOR_DEADLINE_MS = 8000;
8735
8836
  function withDeadline(work, ms, fallback) {
8736
8837
  return new Promise((resolve) => {
8737
8838
  const timer = setTimeout(() => resolve(fallback), ms);
@@ -8746,7 +8847,7 @@ function withDeadline(work, ms, fallback) {
8746
8847
  });
8747
8848
  }
8748
8849
  async function safeLoadTrustAnchorConfig() {
8749
- return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8850
+ return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_DESTINATION_ANCHOR_DEADLINE_MS, null);
8750
8851
  }
8751
8852
  function logsCredentialMissing(headers, env) {
8752
8853
  if (!headers)
@@ -8763,8 +8864,16 @@ function logsCredentialMissing(headers, env) {
8763
8864
  function resolveLogDestinationFrom(input) {
8764
8865
  const local = resolveLogsSetting(input.localConfig);
8765
8866
  let effective = null;
8867
+ let fallbackReason;
8766
8868
  if (input.unattended) {
8767
- effective = local ? resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig) : resolveLogsSetting(input.trustAnchorConfig);
8869
+ if (local) {
8870
+ effective = resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig);
8871
+ if (effective === null && "url" in local) {
8872
+ fallbackReason = input.trustAnchorConfig === null ? { kind: "anchor-unreadable", intendedUrl: local.url } : { kind: "anchor-mismatch", intendedUrl: local.url };
8873
+ }
8874
+ } else {
8875
+ effective = resolveLogsSetting(input.trustAnchorConfig);
8876
+ }
8768
8877
  } else {
8769
8878
  effective = local;
8770
8879
  }
@@ -8790,7 +8899,7 @@ function resolveLogDestinationFrom(input) {
8790
8899
  effective = null;
8791
8900
  }
8792
8901
  const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
8793
- return { kind: "folder", folder };
8902
+ return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
8794
8903
  }
8795
8904
  var processTrustAnchorOnce;
8796
8905
  function processTrustAnchor() {
@@ -8830,6 +8939,96 @@ async function resolveDoctrine(cwd, vinayaVersion) {
8830
8939
  return vinayaVersion;
8831
8940
  }
8832
8941
  }
8942
+ var TRANCHE_SLUG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
8943
+ function taskRefFromBranch2(branch) {
8944
+ const backlog = /^task\/issue-(\d+)$/.exec(branch);
8945
+ if (backlog) {
8946
+ const issue = Number(backlog[1]);
8947
+ return Number.isSafeInteger(issue) && issue > 0 ? { kind: "issue", issue } : null;
8948
+ }
8949
+ const tranche = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
8950
+ if (tranche && TRANCHE_SLUG_PATTERN.test(tranche[1] ?? "")) {
8951
+ return { kind: "tranche", tranche: tranche[1], taskId: tranche[2] };
8952
+ }
8953
+ return null;
8954
+ }
8955
+ var TRANCHE_ISSUE_LIST_LIMIT = 200;
8956
+ async function issueForTrancheTask(tranche, taskId, cwd, repo) {
8957
+ let stdout;
8958
+ try {
8959
+ ({ stdout } = await execFileAsync5("gh", [
8960
+ "issue",
8961
+ "list",
8962
+ "--state",
8963
+ "all",
8964
+ "--label",
8965
+ `vinaya/tranche:${tranche}`,
8966
+ "--json",
8967
+ "number,title,labels",
8968
+ "--limit",
8969
+ String(TRANCHE_ISSUE_LIST_LIMIT),
8970
+ ...repo === null ? [] : ["--repo", repo]
8971
+ ], {
8972
+ cwd,
8973
+ encoding: "utf8",
8974
+ maxBuffer: 8 * 1024 * 1024,
8975
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8976
+ killSignal: "SIGKILL"
8977
+ }));
8978
+ } catch {
8979
+ return null;
8980
+ }
8981
+ let issues;
8982
+ try {
8983
+ issues = JSON.parse(stdout);
8984
+ } catch {
8985
+ return null;
8986
+ }
8987
+ for (const issue of issues) {
8988
+ const ref = resolveTaskIssueRef(issue.title, issue.labels.map((l) => l.name));
8989
+ if (ref && ref.trancheSlug === tranche && ref.taskId === taskId)
8990
+ return issue.number;
8991
+ }
8992
+ return null;
8993
+ }
8994
+ async function confirmBacklogIssue(issue, cwd, repo) {
8995
+ let stdout;
8996
+ try {
8997
+ ({ stdout } = await execFileAsync5("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
8998
+ cwd,
8999
+ encoding: "utf8",
9000
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
9001
+ killSignal: "SIGKILL"
9002
+ }));
9003
+ } catch (err) {
9004
+ const stderr = typeof err.stderr === "string" ? err.stderr : "";
9005
+ return /could not resolve|not found|no such|does not exist/i.test(stderr) ? "denied" : "unknown";
9006
+ }
9007
+ try {
9008
+ return JSON.parse(stdout).number === issue ? "confirmed" : "denied";
9009
+ } catch {
9010
+ return "unknown";
9011
+ }
9012
+ }
9013
+ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
9014
+ let branch;
9015
+ try {
9016
+ branch = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
9017
+ encoding: "utf8",
9018
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
9019
+ killSignal: "SIGKILL"
9020
+ })).stdout.trim();
9021
+ } catch {
9022
+ return null;
9023
+ }
9024
+ const named = branch === "HEAD" ? env.GITHUB_HEAD_REF ?? "" : branch;
9025
+ const ref = taskRefFromBranch2(named);
9026
+ if (ref === null)
9027
+ return null;
9028
+ if (ref.kind === "tranche")
9029
+ return await issueForTrancheTask(ref.tranche, ref.taskId, cwd, repo);
9030
+ return await confirmBacklogIssue(ref.issue, cwd, repo) === "denied" ? null : ref.issue;
9031
+ }
8833
9032
  function readVinayaVersion() {
8834
9033
  try {
8835
9034
  const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
@@ -8842,6 +9041,11 @@ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8842
9041
  function isSafeRepoSegment3(segment) {
8843
9042
  return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
8844
9043
  }
9044
+ function safeRepoSlug(repo) {
9045
+ if (repo === null)
9046
+ return null;
9047
+ return isSafeRepoSegment3(repo.owner) && isSafeRepoSegment3(repo.repo) ? `${repo.owner}/${repo.repo}` : null;
9048
+ }
8845
9049
  function outboxPathFor(deps, repo, issue) {
8846
9050
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
8847
9051
  const fileName = `${issue ?? "none"}.ndjson`;
@@ -8863,6 +9067,18 @@ function defaultStderr(message) {
8863
9067
  warnedThisProcess = true;
8864
9068
  process.stderr.write(message);
8865
9069
  }
9070
+ var branchIssueFallbackEnabled = true;
9071
+ var branchIssueByCwd = new Map;
9072
+ function branchIssueRead(key, read, shared) {
9073
+ if (!shared)
9074
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9075
+ const cached = branchIssueByCwd.get(key);
9076
+ if (cached !== undefined)
9077
+ return cached;
9078
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9079
+ branchIssueByCwd.set(key, reading);
9080
+ return reading;
9081
+ }
8866
9082
  function defaultDeps() {
8867
9083
  return {
8868
9084
  outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
@@ -8973,7 +9189,11 @@ function appendLine(path, line, warn) {
8973
9189
  }
8974
9190
  }
8975
9191
  function createLogSink(overrides = {}) {
8976
- const deps = { ...defaultDeps(), ...overrides };
9192
+ const deps = {
9193
+ ...defaultDeps(),
9194
+ resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
9195
+ ...overrides
9196
+ };
8977
9197
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
8978
9198
  const processId = randomUUID2();
8979
9199
  let seq = 0;
@@ -8993,6 +9213,19 @@ function createLogSink(overrides = {}) {
8993
9213
  }
8994
9214
  return doctrineCache;
8995
9215
  };
9216
+ const readerIsReal = overrides.resolveBranchIssue === undefined;
9217
+ let ownBranchIssue;
9218
+ const branchIssueOnce = (repo) => {
9219
+ if (!branchIssueFallbackEnabled)
9220
+ return Promise.resolve(null);
9221
+ const slug = safeRepoSlug(repo);
9222
+ const read = () => deps.resolveBranchIssue(slug);
9223
+ if (readerIsReal)
9224
+ return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
9225
+ if (ownBranchIssue === undefined)
9226
+ ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
9227
+ return ownBranchIssue;
9228
+ };
8996
9229
  let resolveRepoCache;
8997
9230
  const resolveRepoOnce = () => {
8998
9231
  if (resolveRepoCache === undefined)
@@ -9015,6 +9248,7 @@ function createLogSink(overrides = {}) {
9015
9248
  };
9016
9249
  let drainChain = Promise.resolve();
9017
9250
  const pendingWrites = new Set;
9251
+ let writeChain = Promise.resolve();
9018
9252
  const scheduleWebhookDrain = (issue, url, headers) => {
9019
9253
  drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
9020
9254
  return;
@@ -9037,7 +9271,18 @@ function createLogSink(overrides = {}) {
9037
9271
  attempt: env.VINAYA_ATTEMPT,
9038
9272
  parent: env.VINAYA_PARENT_EVENT
9039
9273
  };
9040
- const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
9274
+ const write = async () => {
9275
+ const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
9276
+ if (resolvedDestination.kind === "none") {
9277
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9278
+ `);
9279
+ return;
9280
+ }
9281
+ if (resolvedDestination.kind === "folder" && resolvedDestination.fallbackReason) {
9282
+ warnOnce(`vinaya: ${describeFolderFallback(resolvedDestination.fallbackReason)}
9283
+ `);
9284
+ }
9285
+ const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
9041
9286
  const header = buildHeader({
9042
9287
  now,
9043
9288
  runId,
@@ -9048,15 +9293,11 @@ function createLogSink(overrides = {}) {
9048
9293
  host,
9049
9294
  hostname: deps.hostname(),
9050
9295
  env: envFields,
9296
+ branchIssue,
9051
9297
  eventId: randomUUID2(),
9052
9298
  processId,
9053
9299
  inputVersions: deps.inputVersions()
9054
9300
  });
9055
- if (resolvedDestination.kind === "none") {
9056
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9057
- `);
9058
- return;
9059
- }
9060
9301
  const full = { ...e, ...header };
9061
9302
  const parsed = LogEventSchema.safeParse(full);
9062
9303
  if (!parsed.success) {
@@ -9073,10 +9314,12 @@ function createLogSink(overrides = {}) {
9073
9314
  } else {
9074
9315
  appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9075
9316
  }
9076
- }).catch((err) => {
9317
+ };
9318
+ const written = writeChain.then(write).catch((err) => {
9077
9319
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
9078
9320
  `);
9079
9321
  });
9322
+ writeChain = written;
9080
9323
  pendingWrites.add(written);
9081
9324
  written.finally(() => pendingWrites.delete(written));
9082
9325
  } catch (err) {
@@ -9256,6 +9499,26 @@ var SOURCE_COMMENTS_GLOBS = proseGates?.sourceComments?.globs ?? [];
9256
9499
  var SOURCE_COMMENTS_ALLOWLIST = proseGates?.sourceComments?.allowlist ?? [];
9257
9500
  var SOURCE_COMMENTS_SEVERITY = proseGates?.sourceComments?.severity ?? "warning";
9258
9501
  var SPEC_GRANDFATHER = proseGates?.specGrandfather ?? [];
9502
+ var SPEC_PATHS = [...DEFAULT_SPEC_PATHS, ...proseGates?.specPaths ?? []].map(normalizeSpecPath);
9503
+ function containedRelativePath(root, path) {
9504
+ const abs = resolve3(root, path);
9505
+ const lexical = relative2(resolve3(root), abs);
9506
+ if (escapesRoot(lexical))
9507
+ return null;
9508
+ if (existsSync8(abs) && escapesRoot(relative2(realPathOrSelf(resolve3(root)), realPathOrSelf(abs))))
9509
+ return null;
9510
+ return normalizeSpecPath(lexical);
9511
+ }
9512
+ function escapesRoot(rel) {
9513
+ return rel === "" || rel === ".." || rel.startsWith(`..${sep2}`) || rel.startsWith("../") || isAbsolute2(rel);
9514
+ }
9515
+ function realPathOrSelf(path) {
9516
+ try {
9517
+ return realpathSync3(path);
9518
+ } catch {
9519
+ return path;
9520
+ }
9521
+ }
9259
9522
  function collect(dir, out = []) {
9260
9523
  let entries;
9261
9524
  try {
@@ -9310,8 +9573,31 @@ function collectProductScopeFiles(root) {
9310
9573
  function readProductFiles(root, relPaths) {
9311
9574
  return relPaths.map((rel) => ({ path: rel, content: readFileSync7(join10(root, rel), "utf8") }));
9312
9575
  }
9313
- function collectSpecFiles(root) {
9576
+ function collectSpecFiles(root, specPaths) {
9314
9577
  const out = [];
9578
+ for (const entry of specPaths) {
9579
+ const rel = containedRelativePath(root, entry);
9580
+ if (rel === null) {
9581
+ console.log(`${CHECK_NAME}: ignoring spec path "${entry}" — it resolves outside the repository under check, and this class only ever reads this repository's own files.`);
9582
+ continue;
9583
+ }
9584
+ const abs = join10(root, rel);
9585
+ let isDir;
9586
+ try {
9587
+ isDir = statSync2(abs).isDirectory();
9588
+ } catch {
9589
+ continue;
9590
+ }
9591
+ if (isDir) {
9592
+ for (const f of collect(abs)) {
9593
+ const child = containedRelativePath(root, f);
9594
+ if (child?.endsWith(".md"))
9595
+ out.push(child);
9596
+ }
9597
+ } else if (rel.endsWith(".md")) {
9598
+ out.push(rel);
9599
+ }
9600
+ }
9315
9601
  const appsDir = join10(root, "apps");
9316
9602
  let appNames;
9317
9603
  try {
@@ -9323,7 +9609,7 @@ function collectSpecFiles(root) {
9323
9609
  }
9324
9610
  });
9325
9611
  } catch {
9326
- return out;
9612
+ return [...new Set(out)];
9327
9613
  }
9328
9614
  for (const app of appNames) {
9329
9615
  const specsDir = join10(appsDir, app, "specs");
@@ -9341,7 +9627,7 @@ function collectSpecFiles(root) {
9341
9627
  out.push(rel);
9342
9628
  }
9343
9629
  }
9344
- return out;
9630
+ return [...new Set(out)];
9345
9631
  }
9346
9632
  function collectSourceCommentFiles(root, globs) {
9347
9633
  const out = [];
@@ -9396,7 +9682,7 @@ function main() {
9396
9682
  const productFiles = readProductFiles(productRoot, productRelPaths);
9397
9683
  const sourceCommentRelPaths = collectSourceCommentFiles(productRoot, SOURCE_COMMENTS_GLOBS);
9398
9684
  const sourceCommentFiles = readProductFiles(productRoot, sourceCommentRelPaths);
9399
- const specRelPaths = collectSpecFiles(productRoot);
9685
+ const specRelPaths = collectSpecFiles(productRoot, SPEC_PATHS);
9400
9686
  const specFiles = readProductFiles(productRoot, specRelPaths);
9401
9687
  const files = [...readAll([...shipsPaths, ...readerFacingPaths]), ...productFiles, ...specFiles];
9402
9688
  const glossaryPath = join10(DOCTRINE_ROOT, "glossary.md");
@@ -9405,7 +9691,7 @@ function main() {
9405
9691
  const { slugs, dormant: legacySlugsDormant } = legacySlugs(legacySlugDir);
9406
9692
  const readerFacingPrefix = READER_FACING_ACTIVE && READER_FACING_PREFIX !== null ? `${READER_FACING_PREFIX}/` : "/no-reader-facing-surface";
9407
9693
  const readerFacingSuffix = READER_FACING_ACTIVE && READER_FACING_SUFFIX !== null ? READER_FACING_SUFFIX : "/page.tsx";
9408
- const findings = checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, slugs, shipsPrefix, SPEC_GRANDFATHER);
9694
+ const findings = checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, slugs, shipsPrefix, SPEC_GRANDFATHER, SPEC_PATHS);
9409
9695
  const reportable = findingsInThisDiff(findings);
9410
9696
  const sourceCommentFindings = checkSourceComments(sourceCommentFiles, SOURCE_COMMENTS_ALLOWLIST);
9411
9697
  const reportableSourceComments = findingsInThisDiff(sourceCommentFindings);
@@ -9421,7 +9707,7 @@ function main() {
9421
9707
  message: `${finding.file}:${finding.line}: ${finding.message}`,
9422
9708
  file: finding.file,
9423
9709
  line: finding.line,
9424
- agent_recovery_prompt: finding.message.includes("coined term") ? "This page uses AEG/Vinaya-internal vocabulary a first-time reader cannot resolve. Either define the term " + 'inline (the same "Term — one-sentence definition" shape the glossary uses) at its first use on this page, ' + "or link to the glossary. Do not simply delete the word if the sentence needs it." : finding.blocking && finding.file.includes("/specs/") ? "This product spec cites a tranche, an Issue/PR number, or names a document outside this repository as " + "its authority — a reader with no forge to resolve it against (a fork, an export, someone reading this " + "spec after the Issue is closed) gets nothing from the citation. Rewrite the sentence to state the fact " + "plainly instead. If this spec is pre-existing backlog, list its path in " + "`proseGates.specGrandfather` rather than fixing it as a drive-by in an unrelated PR — do not add a " + "NEW citation to a spec even while it is grandfathered." : finding.blocking ? "This product-code file cites an internal tranche slug a reader outside this repo cannot resolve " + "(the reader-resolvable-prose product class). Remove the citation or rewrite the comment/doc to state " + "the fact plainly instead of pointing at the tranche that did it. This finding blocks the push and CI." : "This doctrine or page cites a forge number or an internal tranche slug the reader has no tracker to " + "resolve. Rewrite the sentence to state the fact plainly instead of pointing at the citation — say " + "what was learned/decided, not where it was logged."
9710
+ agent_recovery_prompt: finding.message.includes("coined term") ? "This page uses AEG/Vinaya-internal vocabulary a first-time reader cannot resolve. Either define the term " + 'inline (the same "Term — one-sentence definition" shape the glossary uses) at its first use on this page, ' + "or link to the glossary. Do not simply delete the word if the sentence needs it." : finding.blocking && !finding.message.includes("in product code") ? "This spec cites a tranche, a task number, an Issue/PR number, or names a document outside this " + "repository as its authority — a reader with no forge to resolve it against (a fork, an export, someone " + "reading this spec after the Issue is closed) gets nothing from the citation, and a copied task number " + "goes stale the moment the plan is renumbered. Rewrite the sentence to state the fact " + "plainly instead. If this spec is pre-existing backlog, list its path in " + "`proseGates.specGrandfather` rather than fixing it as a drive-by in an unrelated PR — do not add a " + "NEW citation to a spec even while it is grandfathered." : finding.blocking ? "This product-code file cites an internal tranche slug a reader outside this repo cannot resolve " + "(the reader-resolvable-prose product class). Remove the citation or rewrite the comment/doc to state " + "the fact plainly instead of pointing at the tranche that did it. This finding blocks the push and CI." : "This doctrine or page cites a forge number or an internal tranche slug the reader has no tracker to " + "resolve. Rewrite the sentence to state the fact plainly instead of pointing at the citation — say " + "what was learned/decided, not where it was logged."
9425
9711
  });
9426
9712
  }
9427
9713
  for (const finding of reportableSourceComments) {