@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,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/checks/bin/check-evidence-fresh.ts
4
- import { execFileSync as execFileSync7 } from "node:child_process";
4
+ import { execFileSync as execFileSync8 } from "node:child_process";
5
5
  // ../../packages/aeg-core/src/gate-audience.ts
6
6
  var GATE_AUDIENCE = {
7
7
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -196,8 +196,8 @@ function maskIndentedCode(body, fill) {
196
196
  var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
197
197
  var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
198
198
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
199
- var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
200
- var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
199
+ var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+$/i;
200
+ var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+)$/i;
201
201
  function splitSlugQualifiedEdge(edge) {
202
202
  const m = edge.trim().match(SLUG_QUALIFIED_ID);
203
203
  if (!m)
@@ -2618,7 +2618,7 @@ function isIssueNotFoundError(err) {
2618
2618
  return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
2619
2619
  }
2620
2620
  function resolveObjectivesSource(prBody, issue, cutoverIssue) {
2621
- if (issue !== null && issue < cutoverIssue)
2621
+ if (issue !== null && cutoverIssue !== null && issue < cutoverIssue)
2622
2622
  return { kind: "none" };
2623
2623
  if (issue !== null)
2624
2624
  return { kind: "issue", issue };
@@ -2894,9 +2894,18 @@ var COMMIT_TYPES = [
2894
2894
  ];
2895
2895
  var COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join("|")})(\\([a-z0-9-]+\\))?: \\S`);
2896
2896
  function checkForgeTitle(title) {
2897
- const taskStyle = /^\[[a-z0-9._-]+\] \S+ — \S/;
2897
+ const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/;
2898
2898
  if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title))
2899
2899
  return { status: "pass", errors: [] };
2900
+ const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title);
2901
+ if (letteredTaskId) {
2902
+ return {
2903
+ status: "fail",
2904
+ errors: [
2905
+ `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.`
2906
+ ]
2907
+ };
2908
+ }
2900
2909
  return {
2901
2910
  status: "fail",
2902
2911
  errors: [
@@ -2929,19 +2938,31 @@ function checkNoAgentBoxes(prBody) {
2929
2938
  ]
2930
2939
  };
2931
2940
  }
2932
- function rolloutThresholdFor(message) {
2941
+ function rolloutRuleFor(message) {
2933
2942
  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:")) {
2934
- return BRIEF_RULES_SINCE_PR;
2943
+ return "briefRules";
2935
2944
  }
2936
2945
  if (message.startsWith("brief-validation no agent boxes:"))
2937
- return AGENT_BOXES_REFUSED_SINCE_PR;
2946
+ return "agentBoxes";
2938
2947
  return null;
2939
2948
  }
2940
- function partitionBriefErrorsByRollout(errors, prNumber) {
2949
+ var DEFAULT_BRIEF_ROLLOUT_CUTOVERS = {
2950
+ briefRulesSincePr: BRIEF_RULES_SINCE_PR,
2951
+ agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
2952
+ };
2953
+ function rolloutThresholdFor(message, cutovers) {
2954
+ const rule = rolloutRuleFor(message);
2955
+ if (rule === "briefRules")
2956
+ return cutovers.briefRulesSincePr;
2957
+ if (rule === "agentBoxes")
2958
+ return cutovers.agentBoxesRefusedSincePr;
2959
+ return null;
2960
+ }
2961
+ function partitionBriefErrorsByRollout(errors, prNumber, cutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS) {
2941
2962
  const blocking = [];
2942
2963
  const info = [];
2943
2964
  for (const e of errors) {
2944
- const threshold = rolloutThresholdFor(e);
2965
+ const threshold = rolloutThresholdFor(e, cutovers);
2945
2966
  const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold;
2946
2967
  (grandfathered ? info : blocking).push(e);
2947
2968
  }
@@ -3409,8 +3430,8 @@ function checkIssueRationale(body) {
3409
3430
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3410
3431
  }
3411
3432
  var OBJECTIVES_SINCE_ISSUE = 404;
3412
- function checkIssueObjectives(body, issueNumber) {
3413
- if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE)
3433
+ function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3434
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3414
3435
  return { status: "pass", errors: [] };
3415
3436
  const result = objectivesOf(body);
3416
3437
  if (result.ok)
@@ -3486,6 +3507,8 @@ function parseIssueSurface(body) {
3486
3507
  function globCoversPath(glob, path) {
3487
3508
  const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
3488
3509
  const p = path.replace(/\/+$/, "");
3510
+ if (g === "*")
3511
+ return !p.includes("/");
3489
3512
  return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
3490
3513
  }
3491
3514
  function checkSurfaceGlobsResolve(body, resolvesToFile) {
@@ -3855,7 +3878,7 @@ function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
3855
3878
  return issueToEntry.get(Number(issueMatch[1]));
3856
3879
  return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
3857
3880
  }
3858
- function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3881
+ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
3859
3882
  const failures = [];
3860
3883
  for (const [slug, issues] of issuesBySlug) {
3861
3884
  for (const issue of issues) {
@@ -3864,7 +3887,7 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3864
3887
  const errors = [
3865
3888
  ...checkIssueRationale(issue.body).errors,
3866
3889
  ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
3867
- ...checkIssueObjectives(issue.body, issue.number).errors,
3890
+ ...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
3868
3891
  ...checkPartsCiteDefinedObjectives(issue.body).errors
3869
3892
  ];
3870
3893
  if (errors.length === 0)
@@ -4487,13 +4510,27 @@ var SHIPS_PREFIX = "aeg-root/";
4487
4510
  function shipsArchivePrefix(shipsPrefix) {
4488
4511
  return `${shipsPrefix}tranches/completed/`;
4489
4512
  }
4490
- function isSpecFile2(path) {
4491
- 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)));
4492
4529
  }
4493
4530
  function isClaudeMdFile(path) {
4494
4531
  return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
4495
4532
  }
4496
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4533
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
4497
4534
  if (path.startsWith(shipsPrefix)) {
4498
4535
  return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
4499
4536
  }
@@ -4502,7 +4539,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
4502
4539
  }
4503
4540
  if (isClaudeMdFile(path))
4504
4541
  return "internal";
4505
- if (isSpecFile2(path))
4542
+ if (isSpecFile2(path, specPaths))
4506
4543
  return "spec";
4507
4544
  if (isProductScopeFile(path))
4508
4545
  return "product";
@@ -4531,13 +4568,14 @@ function lineAt(content, index) {
4531
4568
  }
4532
4569
  var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
4533
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;
4534
4572
  function legacySlugPattern(legacySlugs) {
4535
4573
  if (legacySlugs.length === 0)
4536
4574
  return null;
4537
4575
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
4538
4576
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
4539
4577
  }
4540
- 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) {
4541
4579
  const findings = [];
4542
4580
  const legacyPattern = legacySlugPattern(legacySlugs);
4543
4581
  const grandfathered = new Set(specGrandfather);
@@ -4549,8 +4587,12 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4549
4587
  const productPatterns = [
4550
4588
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4551
4589
  ];
4590
+ const specPatterns = [
4591
+ ...patterns,
4592
+ { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
4593
+ ];
4552
4594
  for (const file of files) {
4553
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4595
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
4554
4596
  if (!cls || cls === "internal")
4555
4597
  continue;
4556
4598
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
@@ -4559,15 +4601,16 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4559
4601
  continue;
4560
4602
  const blocking = cls === "product" || cls === "spec";
4561
4603
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4562
- const patternsToRun = cls === "product" ? productPatterns : patterns;
4604
+ const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
4563
4605
  for (const { pattern, what, group } of patternsToRun) {
4564
4606
  pattern.lastIndex = 0;
4565
4607
  let match = pattern.exec(scrubbed);
4566
4608
  while (match !== null) {
4567
4609
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
4610
+ const citedIndex = match.index + match[0].indexOf(cited);
4568
4611
  findings.push({
4569
4612
  file: file.path,
4570
- line: lineAt(scrubbed, match.index),
4613
+ line: lineAt(scrubbed, citedIndex),
4571
4614
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4572
4615
  blocking
4573
4616
  });
@@ -4753,9 +4796,9 @@ function checkSourceComments(files, allowlist = []) {
4753
4796
  }
4754
4797
  return findings;
4755
4798
  }
4756
- 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) {
4757
4800
  return [
4758
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather),
4801
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
4759
4802
  ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4760
4803
  ];
4761
4804
  }
@@ -5220,7 +5263,8 @@ var TaskStatusItemSchema = z.object({
5220
5263
  }).merge(ObservedSchema);
5221
5264
  var TaskStatusResultSchema = z.object({
5222
5265
  items: z.array(TaskStatusItemSchema),
5223
- nextCursor: z.string().nullable()
5266
+ nextCursor: z.string().nullable(),
5267
+ table: z.string()
5224
5268
  });
5225
5269
  var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
5226
5270
  var EscalationInputsSchema = z.object({
@@ -5564,6 +5608,14 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5564
5608
  }
5565
5609
  return findings;
5566
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
+ };
5567
5619
  // ../../packages/aeg-core/src/dev-review-loop/types.ts
5568
5620
  var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5569
5621
  // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
@@ -6013,6 +6065,8 @@ function attemptFromEnv(value) {
6013
6065
  function provenanceFor(input) {
6014
6066
  if (input.provenance)
6015
6067
  return input.provenance;
6068
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
6069
+ return "unavailable";
6016
6070
  if (input.env.role || input.env.task)
6017
6071
  return "env_correlated";
6018
6072
  return "unavailable";
@@ -6033,7 +6087,7 @@ function buildHeader(input) {
6033
6087
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6034
6088
  const round = roundFromEnv(input.env.round);
6035
6089
  const subject = {
6036
- issue: issueFromTask(input.env.task),
6090
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6037
6091
  role,
6038
6092
  ...round !== undefined ? { round } : {},
6039
6093
  ...input.subject ?? {}
@@ -7080,7 +7134,12 @@ var VinayaConfigSchema = z4.object({
7080
7134
  allowlist: z4.array(z4.string().min(1)).optional(),
7081
7135
  severity: z4.enum(["warning", "error"]).optional()
7082
7136
  }).optional(),
7083
- specGrandfather: z4.array(z4.string().min(1)).optional()
7137
+ specGrandfather: z4.array(z4.string().min(1)).optional(),
7138
+ specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
7139
+ message: "must be a repository-relative path, not an absolute one"
7140
+ }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
7141
+ message: "must stay inside the repository — no `..` segment"
7142
+ })).optional()
7084
7143
  }).optional(),
7085
7144
  projects: z4.array(ProjectEntrySchema).optional(),
7086
7145
  dispatch: z4.object({
@@ -7094,6 +7153,13 @@ var VinayaConfigSchema = z4.object({
7094
7153
  securityThreshold: z4.string().min(1).optional(),
7095
7154
  maxRounds: z4.number().optional()
7096
7155
  }).optional(),
7156
+ gateCutovers: z4.object({
7157
+ objectivesSinceIssue: z4.number().int().nonnegative().optional(),
7158
+ briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
7159
+ documentationSinceIssue: z4.number().int().nonnegative().optional(),
7160
+ briefRulesSincePr: z4.number().int().nonnegative().optional(),
7161
+ agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
7162
+ }).optional(),
7097
7163
  prePush: z4.object({
7098
7164
  alwaysRun: z4.array(z4.string()).optional()
7099
7165
  }).optional(),
@@ -7231,6 +7297,18 @@ function resolveReviewPolicy(config) {
7231
7297
  maxRounds
7232
7298
  };
7233
7299
  }
7300
+ function resolveGateCutovers(config) {
7301
+ const raw = config?.gateCutovers;
7302
+ if (!raw)
7303
+ return NO_GATE_CUTOVERS;
7304
+ return {
7305
+ objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
7306
+ briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
7307
+ documentationSinceIssue: raw.documentationSinceIssue ?? null,
7308
+ briefRulesSincePr: raw.briefRulesSincePr ?? null,
7309
+ agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
7310
+ };
7311
+ }
7234
7312
  function resolveRuntimeDirSetting(config) {
7235
7313
  return config?.runtimeDir ?? null;
7236
7314
  }
@@ -7286,7 +7364,8 @@ async function trustAnchorRepoAsync() {
7286
7364
  try {
7287
7365
  const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
7288
7366
  encoding: "utf-8",
7289
- timeout: 1e4
7367
+ timeout: 1e4,
7368
+ killSignal: "SIGKILL"
7290
7369
  });
7291
7370
  return trustAnchorRepoFromRemoteUrl(stdout);
7292
7371
  } catch {
@@ -7347,7 +7426,7 @@ async function ghFetchTrustAnchorConfigAsync() {
7347
7426
  const repo = await trustAnchorRepoAsync();
7348
7427
  if (!repo)
7349
7428
  throw new Error("could not resolve repo identity for the trust-anchor read");
7350
- const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
7429
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
7351
7430
  return stdout;
7352
7431
  }
7353
7432
  function firstLine(err) {
@@ -7844,7 +7923,14 @@ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeou
7844
7923
 
7845
7924
  // src/lib/log-sink.ts
7846
7925
  var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
7926
+ function describeFolderFallback(reason) {
7927
+ if (reason.kind === "anchor-unreadable") {
7928
+ 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`";
7929
+ }
7930
+ 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";
7931
+ }
7847
7932
  var LOG_CONTEXT_LOOKUP_DEADLINE_MS = 3000;
7933
+ var LOG_DESTINATION_ANCHOR_DEADLINE_MS = 8000;
7848
7934
  function withDeadline(work, ms, fallback) {
7849
7935
  return new Promise((resolve) => {
7850
7936
  const timer = setTimeout(() => resolve(fallback), ms);
@@ -7859,7 +7945,7 @@ function withDeadline(work, ms, fallback) {
7859
7945
  });
7860
7946
  }
7861
7947
  async function safeLoadTrustAnchorConfig() {
7862
- return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
7948
+ return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_DESTINATION_ANCHOR_DEADLINE_MS, null);
7863
7949
  }
7864
7950
  function logsCredentialMissing(headers, env) {
7865
7951
  if (!headers)
@@ -7876,8 +7962,16 @@ function logsCredentialMissing(headers, env) {
7876
7962
  function resolveLogDestinationFrom(input) {
7877
7963
  const local = resolveLogsSetting(input.localConfig);
7878
7964
  let effective = null;
7965
+ let fallbackReason;
7879
7966
  if (input.unattended) {
7880
- effective = local ? resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig) : resolveLogsSetting(input.trustAnchorConfig);
7967
+ if (local) {
7968
+ effective = resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig);
7969
+ if (effective === null && "url" in local) {
7970
+ fallbackReason = input.trustAnchorConfig === null ? { kind: "anchor-unreadable", intendedUrl: local.url } : { kind: "anchor-mismatch", intendedUrl: local.url };
7971
+ }
7972
+ } else {
7973
+ effective = resolveLogsSetting(input.trustAnchorConfig);
7974
+ }
7881
7975
  } else {
7882
7976
  effective = local;
7883
7977
  }
@@ -7903,7 +7997,7 @@ function resolveLogDestinationFrom(input) {
7903
7997
  effective = null;
7904
7998
  }
7905
7999
  const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
7906
- return { kind: "folder", folder };
8000
+ return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
7907
8001
  }
7908
8002
  var processTrustAnchorOnce;
7909
8003
  function processTrustAnchor() {
@@ -7943,6 +8037,96 @@ async function resolveDoctrine(cwd, vinayaVersion) {
7943
8037
  return vinayaVersion;
7944
8038
  }
7945
8039
  }
8040
+ var TRANCHE_SLUG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
8041
+ function taskRefFromBranch2(branch) {
8042
+ const backlog = /^task\/issue-(\d+)$/.exec(branch);
8043
+ if (backlog) {
8044
+ const issue = Number(backlog[1]);
8045
+ return Number.isSafeInteger(issue) && issue > 0 ? { kind: "issue", issue } : null;
8046
+ }
8047
+ const tranche = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
8048
+ if (tranche && TRANCHE_SLUG_PATTERN.test(tranche[1] ?? "")) {
8049
+ return { kind: "tranche", tranche: tranche[1], taskId: tranche[2] };
8050
+ }
8051
+ return null;
8052
+ }
8053
+ var TRANCHE_ISSUE_LIST_LIMIT = 200;
8054
+ async function issueForTrancheTask(tranche, taskId, cwd, repo) {
8055
+ let stdout;
8056
+ try {
8057
+ ({ stdout } = await execFileAsync5("gh", [
8058
+ "issue",
8059
+ "list",
8060
+ "--state",
8061
+ "all",
8062
+ "--label",
8063
+ `vinaya/tranche:${tranche}`,
8064
+ "--json",
8065
+ "number,title,labels",
8066
+ "--limit",
8067
+ String(TRANCHE_ISSUE_LIST_LIMIT),
8068
+ ...repo === null ? [] : ["--repo", repo]
8069
+ ], {
8070
+ cwd,
8071
+ encoding: "utf8",
8072
+ maxBuffer: 8 * 1024 * 1024,
8073
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8074
+ killSignal: "SIGKILL"
8075
+ }));
8076
+ } catch {
8077
+ return null;
8078
+ }
8079
+ let issues;
8080
+ try {
8081
+ issues = JSON.parse(stdout);
8082
+ } catch {
8083
+ return null;
8084
+ }
8085
+ for (const issue of issues) {
8086
+ const ref = resolveTaskIssueRef(issue.title, issue.labels.map((l) => l.name));
8087
+ if (ref && ref.trancheSlug === tranche && ref.taskId === taskId)
8088
+ return issue.number;
8089
+ }
8090
+ return null;
8091
+ }
8092
+ async function confirmBacklogIssue(issue, cwd, repo) {
8093
+ let stdout;
8094
+ try {
8095
+ ({ stdout } = await execFileAsync5("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
8096
+ cwd,
8097
+ encoding: "utf8",
8098
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8099
+ killSignal: "SIGKILL"
8100
+ }));
8101
+ } catch (err) {
8102
+ const stderr = typeof err.stderr === "string" ? err.stderr : "";
8103
+ return /could not resolve|not found|no such|does not exist/i.test(stderr) ? "denied" : "unknown";
8104
+ }
8105
+ try {
8106
+ return JSON.parse(stdout).number === issue ? "confirmed" : "denied";
8107
+ } catch {
8108
+ return "unknown";
8109
+ }
8110
+ }
8111
+ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
8112
+ let branch;
8113
+ try {
8114
+ branch = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
8115
+ encoding: "utf8",
8116
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8117
+ killSignal: "SIGKILL"
8118
+ })).stdout.trim();
8119
+ } catch {
8120
+ return null;
8121
+ }
8122
+ const named = branch === "HEAD" ? env.GITHUB_HEAD_REF ?? "" : branch;
8123
+ const ref = taskRefFromBranch2(named);
8124
+ if (ref === null)
8125
+ return null;
8126
+ if (ref.kind === "tranche")
8127
+ return await issueForTrancheTask(ref.tranche, ref.taskId, cwd, repo);
8128
+ return await confirmBacklogIssue(ref.issue, cwd, repo) === "denied" ? null : ref.issue;
8129
+ }
7946
8130
  function readVinayaVersion() {
7947
8131
  try {
7948
8132
  const pkg = JSON.parse(readFileSync4(join6(packageRoot(import.meta.url), "package.json"), "utf8"));
@@ -7955,6 +8139,11 @@ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
7955
8139
  function isSafeRepoSegment3(segment) {
7956
8140
  return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
7957
8141
  }
8142
+ function safeRepoSlug(repo) {
8143
+ if (repo === null)
8144
+ return null;
8145
+ return isSafeRepoSegment3(repo.owner) && isSafeRepoSegment3(repo.repo) ? `${repo.owner}/${repo.repo}` : null;
8146
+ }
7958
8147
  function outboxPathFor(deps, repo, issue) {
7959
8148
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
7960
8149
  const fileName = `${issue ?? "none"}.ndjson`;
@@ -7976,6 +8165,18 @@ function defaultStderr(message) {
7976
8165
  warnedThisProcess = true;
7977
8166
  process.stderr.write(message);
7978
8167
  }
8168
+ var branchIssueFallbackEnabled = true;
8169
+ var branchIssueByCwd = new Map;
8170
+ function branchIssueRead(key, read, shared) {
8171
+ if (!shared)
8172
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8173
+ const cached = branchIssueByCwd.get(key);
8174
+ if (cached !== undefined)
8175
+ return cached;
8176
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8177
+ branchIssueByCwd.set(key, reading);
8178
+ return reading;
8179
+ }
7979
8180
  function defaultDeps() {
7980
8181
  return {
7981
8182
  outboxRoot: () => join6(GLOBAL_VINAYA_HOME, "outbox"),
@@ -8086,7 +8287,11 @@ function appendLine(path, line, warn) {
8086
8287
  }
8087
8288
  }
8088
8289
  function createLogSink(overrides = {}) {
8089
- const deps = { ...defaultDeps(), ...overrides };
8290
+ const deps = {
8291
+ ...defaultDeps(),
8292
+ resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
8293
+ ...overrides
8294
+ };
8090
8295
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
8091
8296
  const processId = randomUUID2();
8092
8297
  let seq = 0;
@@ -8106,6 +8311,19 @@ function createLogSink(overrides = {}) {
8106
8311
  }
8107
8312
  return doctrineCache;
8108
8313
  };
8314
+ const readerIsReal = overrides.resolveBranchIssue === undefined;
8315
+ let ownBranchIssue;
8316
+ const branchIssueOnce = (repo) => {
8317
+ if (!branchIssueFallbackEnabled)
8318
+ return Promise.resolve(null);
8319
+ const slug = safeRepoSlug(repo);
8320
+ const read = () => deps.resolveBranchIssue(slug);
8321
+ if (readerIsReal)
8322
+ return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
8323
+ if (ownBranchIssue === undefined)
8324
+ ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
8325
+ return ownBranchIssue;
8326
+ };
8109
8327
  let resolveRepoCache;
8110
8328
  const resolveRepoOnce = () => {
8111
8329
  if (resolveRepoCache === undefined)
@@ -8128,6 +8346,7 @@ function createLogSink(overrides = {}) {
8128
8346
  };
8129
8347
  let drainChain = Promise.resolve();
8130
8348
  const pendingWrites = new Set;
8349
+ let writeChain = Promise.resolve();
8131
8350
  const scheduleWebhookDrain = (issue, url, headers) => {
8132
8351
  drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
8133
8352
  return;
@@ -8150,7 +8369,18 @@ function createLogSink(overrides = {}) {
8150
8369
  attempt: env.VINAYA_ATTEMPT,
8151
8370
  parent: env.VINAYA_PARENT_EVENT
8152
8371
  };
8153
- const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
8372
+ const write = async () => {
8373
+ const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
8374
+ if (resolvedDestination.kind === "none") {
8375
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
8376
+ `);
8377
+ return;
8378
+ }
8379
+ if (resolvedDestination.kind === "folder" && resolvedDestination.fallbackReason) {
8380
+ warnOnce(`vinaya: ${describeFolderFallback(resolvedDestination.fallbackReason)}
8381
+ `);
8382
+ }
8383
+ const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
8154
8384
  const header = buildHeader({
8155
8385
  now,
8156
8386
  runId,
@@ -8161,15 +8391,11 @@ function createLogSink(overrides = {}) {
8161
8391
  host,
8162
8392
  hostname: deps.hostname(),
8163
8393
  env: envFields,
8394
+ branchIssue,
8164
8395
  eventId: randomUUID2(),
8165
8396
  processId,
8166
8397
  inputVersions: deps.inputVersions()
8167
8398
  });
8168
- if (resolvedDestination.kind === "none") {
8169
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
8170
- `);
8171
- return;
8172
- }
8173
8399
  const full = { ...e, ...header };
8174
8400
  const parsed = LogEventSchema.safeParse(full);
8175
8401
  if (!parsed.success) {
@@ -8186,10 +8412,12 @@ function createLogSink(overrides = {}) {
8186
8412
  } else {
8187
8413
  appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
8188
8414
  }
8189
- }).catch((err) => {
8415
+ };
8416
+ const written = writeChain.then(write).catch((err) => {
8190
8417
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
8191
8418
  `);
8192
8419
  });
8420
+ writeChain = written;
8193
8421
  pendingWrites.add(written);
8194
8422
  written.finally(() => pendingWrites.delete(written));
8195
8423
  } catch (err) {
@@ -8307,13 +8535,13 @@ function summaryLineIndex(maskedRegion) {
8307
8535
  var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
8308
8536
 
8309
8537
  // src/lib/diff-evidence.ts
8310
- import { execFileSync as execFileSync5 } from "node:child_process";
8311
- import { join as join8, relative, resolve as resolve2 } from "node:path";
8538
+ import { execFileSync as execFileSync6 } from "node:child_process";
8539
+ import { join as join9, relative, resolve as resolve2 } from "node:path";
8312
8540
 
8313
8541
  // src/lib/brief-assembly.ts
8314
- import { execFileSync as execFileSync4 } from "node:child_process";
8315
- import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync } from "node:fs";
8316
- import { join as join7 } from "node:path";
8542
+ import { execFileSync as execFileSync5 } from "node:child_process";
8543
+ import { existsSync as existsSync7, readFileSync as readFileSync6, readdirSync as readdirSync2 } from "node:fs";
8544
+ import { join as join8 } from "node:path";
8317
8545
 
8318
8546
  // ../../packages/sources/src/commands.ts
8319
8547
  var COMMANDS = [
@@ -8819,6 +9047,10 @@ var COMMANDS = [
8819
9047
  flag: "--role <name>",
8820
9048
  description: "Resolve to a specific role file (roles/<name>.md) instead of the front door"
8821
9049
  },
9050
+ {
9051
+ flag: "--template <name>",
9052
+ description: "Print a template the package ships (templates/<name>-template.md) instead of the front door"
9053
+ },
8822
9054
  {
8823
9055
  flag: "--print",
8824
9056
  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."
@@ -9003,6 +9235,17 @@ var COMMANDS = [
9003
9235
  "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)."
9004
9236
  ],
9005
9237
  status: "shipped"
9238
+ },
9239
+ {
9240
+ name: "log send",
9241
+ description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
9242
+ flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }],
9243
+ details: [
9244
+ "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.",
9245
+ "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.",
9246
+ "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."
9247
+ ],
9248
+ status: "shipped"
9006
9249
  }
9007
9250
  ];
9008
9251
  // ../../packages/sources/src/forge-adapter.ts
@@ -9137,13 +9380,47 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
9137
9380
  };
9138
9381
  }
9139
9382
 
9383
+ // src/commands/doctrine.ts
9384
+ import { execFileSync as execFileSync4 } from "node:child_process";
9385
+ import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync5 } from "node:fs";
9386
+ import { dirname as dirname6, join as join7, sep } from "node:path";
9387
+ import matter2 from "gray-matter";
9388
+ var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
9389
+ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
9390
+ return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
9391
+ }
9392
+ function gitToplevel(cwd) {
9393
+ try {
9394
+ return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
9395
+ encoding: "utf8",
9396
+ stdio: ["ignore", "pipe", "pipe"]
9397
+ }).trim();
9398
+ } catch {
9399
+ return null;
9400
+ }
9401
+ }
9402
+ function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
9403
+ const toplevel = gitToplevel(cwd);
9404
+ if (toplevel !== null) {
9405
+ const treeRoot = join7(toplevel, "aeg-root");
9406
+ if (existsSync6(join7(treeRoot, "roles")))
9407
+ return { root: treeRoot, source: "tree" };
9408
+ }
9409
+ const fromSource = !pkg.split(sep).includes("node_modules");
9410
+ const bundleRoot = fromSource ? join7(dirname6(dirname6(pkg)), "aeg-root") : join7(pkg, "aeg-root");
9411
+ return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
9412
+ }
9413
+ function hasDoctrineEntry(root) {
9414
+ return existsSync6(join7(root, ...ENTRY_SEGMENTS));
9415
+ }
9416
+
9140
9417
  // src/lib/brief-assembly.ts
9141
9418
  var PACKAGE_ROOT = packageRoot(import.meta.url);
9142
- var PACKAGED_TEMPLATE_PATH = join7(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
9143
- var TEMPLATE_PATH = existsSync6(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join7(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
9419
+ var PACKAGED_TEMPLATE_PATH = join8(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
9420
+ var TEMPLATE_PATH = existsSync7(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join8(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
9144
9421
  function git(args) {
9145
9422
  try {
9146
- return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
9423
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
9147
9424
  } catch {
9148
9425
  return "";
9149
9426
  }
@@ -9192,7 +9469,7 @@ function parseChangedLineRanges(diffOutput) {
9192
9469
  function fileDiffAgainst(ref, path) {
9193
9470
  let out;
9194
9471
  try {
9195
- out = execFileSync5("git", ["diff", `${ref}...HEAD`, "--", path], {
9472
+ out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
9196
9473
  encoding: "utf8",
9197
9474
  stdio: ["ignore", "pipe", "pipe"]
9198
9475
  }).trim();
@@ -9203,7 +9480,7 @@ function fileDiffAgainst(ref, path) {
9203
9480
  }
9204
9481
  function revParse(ref) {
9205
9482
  try {
9206
- return execFileSync5("git", ["rev-parse", "--verify", ref], {
9483
+ return execFileSync6("git", ["rev-parse", "--verify", ref], {
9207
9484
  encoding: "utf8",
9208
9485
  stdio: ["ignore", "pipe", "pipe"]
9209
9486
  }).trim();
@@ -9213,7 +9490,7 @@ function revParse(ref) {
9213
9490
  }
9214
9491
  function repoRoot() {
9215
9492
  try {
9216
- return execFileSync5("git", ["rev-parse", "--show-toplevel"], {
9493
+ return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
9217
9494
  encoding: "utf8",
9218
9495
  stdio: ["ignore", "pipe", "pipe"]
9219
9496
  }).trim();
@@ -9224,7 +9501,7 @@ function repoRoot() {
9224
9501
  function changedFiles(base) {
9225
9502
  let out;
9226
9503
  try {
9227
- out = execFileSync5("git", ["diff", "--name-only", `${base}...HEAD`], {
9504
+ out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
9228
9505
  encoding: "utf8",
9229
9506
  stdio: ["ignore", "pipe", "pipe"]
9230
9507
  }).trim();
@@ -9249,7 +9526,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
9249
9526
  const relPaths = changedFiles(ref);
9250
9527
  if (relPaths === null)
9251
9528
  continue;
9252
- return { base: ref, root, files: relPaths.map((p) => join8(root, p)) };
9529
+ return { base: ref, root, files: relPaths.map((p) => join9(root, p)) };
9253
9530
  }
9254
9531
  return null;
9255
9532
  }
@@ -9350,20 +9627,20 @@ var TOKEN_ROW_REMEDY = [
9350
9627
  var USAGE2 = "Usage: vinaya pr report [--write <body-file> | --push <pr> [--body-file <path>]] [--phase <phase>] " + "[--role <role>] [--model <id>] [--transcript <path>]";
9351
9628
 
9352
9629
  // src/lib/patch-id.ts
9353
- import { execFileSync as execFileSync6 } from "node:child_process";
9630
+ import { execFileSync as execFileSync7 } from "node:child_process";
9354
9631
  function patchIdAt(base, sha) {
9355
9632
  try {
9356
- execFileSync6("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
9633
+ execFileSync7("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
9357
9634
  } catch {}
9358
9635
  try {
9359
- const diff = execFileSync6("git", ["diff", `origin/${base}...${sha}`], {
9636
+ const diff = execFileSync7("git", ["diff", `origin/${base}...${sha}`], {
9360
9637
  encoding: "utf8",
9361
9638
  maxBuffer: 64 * 1024 * 1024,
9362
9639
  stdio: ["ignore", "pipe", "pipe"]
9363
9640
  });
9364
9641
  if (diff === "")
9365
9642
  return null;
9366
- const out = execFileSync6("git", ["patch-id", "--stable"], {
9643
+ const out = execFileSync7("git", ["patch-id", "--stable"], {
9367
9644
  input: diff,
9368
9645
  encoding: "utf8",
9369
9646
  stdio: ["pipe", "pipe", "pipe"]
@@ -9475,7 +9752,7 @@ function compareEvidenceBlock(resolved, resolvedHead, actualNumstat, expectedGro
9475
9752
  var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-\d+\s*-->/i;
9476
9753
  function fetchHasPriorDeveloperRound(prNumber) {
9477
9754
  try {
9478
- const out = execFileSync7("gh", ["pr", "view", String(prNumber), "--json", "comments"], {
9755
+ const out = execFileSync8("gh", ["pr", "view", String(prNumber), "--json", "comments"], {
9479
9756
  encoding: "utf8",
9480
9757
  stdio: ["ignore", "pipe", "pipe"]
9481
9758
  });
@@ -9489,7 +9766,7 @@ function fetchHasPriorDeveloperRound(prNumber) {
9489
9766
  var CHECK_NAME = "evidence-fresh";
9490
9767
  function git2(args) {
9491
9768
  try {
9492
- return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9769
+ return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9493
9770
  } catch {
9494
9771
  return "";
9495
9772
  }
@@ -9508,7 +9785,7 @@ class GitCommandError2 extends Error {
9508
9785
  }
9509
9786
  function gitStrict(args) {
9510
9787
  try {
9511
- return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9788
+ return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9512
9789
  } catch (err) {
9513
9790
  const stderr = err.stderr;
9514
9791
  throw new GitCommandError2(args, String(stderr ?? err.message).trim() || "non-zero exit");
@@ -9526,7 +9803,7 @@ function resolveMergeBase(head) {
9526
9803
  }
9527
9804
  function fetchPrRefs(prNumber) {
9528
9805
  try {
9529
- const out = execFileSync7("gh", ["pr", "view", String(prNumber), "--json", "headRefOid,baseRefName"], {
9806
+ const out = execFileSync8("gh", ["pr", "view", String(prNumber), "--json", "headRefOid,baseRefName"], {
9530
9807
  encoding: "utf8",
9531
9808
  stdio: ["ignore", "pipe", "pipe"]
9532
9809
  });