@attalabs/vinaya 0.44.1 → 0.47.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/README.md +6 -4
  2. package/dist/checks/bin/check-body-bare-digits.js +233 -195
  3. package/dist/checks/bin/check-branch-topology.js +70 -23
  4. package/dist/checks/bin/check-brief-shape.js +233 -195
  5. package/dist/checks/bin/check-changeset-coverage.js +94 -16
  6. package/dist/checks/bin/check-ci-shard-coverage.js +3 -0
  7. package/dist/checks/bin/check-closes-n.js +128 -34
  8. package/dist/checks/bin/check-coherence.js +336 -245
  9. package/dist/checks/bin/check-dispatch-readiness.js +3623 -463
  10. package/dist/checks/bin/check-doc-claims.js +233 -195
  11. package/dist/checks/bin/check-doc-coverage-push.js +243 -196
  12. package/dist/checks/bin/check-doc-coverage.js +243 -196
  13. package/dist/checks/bin/check-doctrine-no-procedures.js +233 -195
  14. package/dist/checks/bin/check-doctrine-portability.js +233 -195
  15. package/dist/checks/bin/check-evidence-fresh.js +9983 -1995
  16. package/dist/checks/bin/check-exec-bits.js +3 -0
  17. package/dist/checks/bin/check-first-push-dispatch.js +301 -224
  18. package/dist/checks/bin/check-issue-milestone-attach.js +65 -10
  19. package/dist/checks/bin/check-issue-objectives-numbering.js +233 -195
  20. package/dist/checks/bin/check-issue-parts-coverage.js +65 -10
  21. package/dist/checks/bin/check-issue-surface-globs.js +1032 -236
  22. package/dist/checks/bin/check-issue-title-grammar.js +5 -1
  23. package/dist/checks/bin/check-no-disk-state.js +5 -1
  24. package/dist/checks/bin/check-pr-premise-reassert.js +10 -1
  25. package/dist/checks/bin/check-pr-report-density.js +5 -1
  26. package/dist/checks/bin/check-principal-test-plan-wait.js +253 -201
  27. package/dist/checks/bin/check-quoted-command.js +233 -195
  28. package/dist/checks/bin/check-reader-resolvable-prose.js +233 -195
  29. package/dist/checks/bin/check-registry-gates.js +131 -34
  30. package/dist/checks/bin/check-retired-vocabulary.js +233 -195
  31. package/dist/checks/bin/check-review-gate.js +233 -195
  32. package/dist/checks/bin/check-single-plan-pr.js +5 -1
  33. package/dist/checks/bin/check-surface-scope.js +107 -32
  34. package/dist/checks/bin/check-test-plan.js +253 -201
  35. package/dist/checks/bin/check-token-collection-wired.js +3 -0
  36. package/dist/checks/bin/check-workspace-escape.js +3 -0
  37. package/dist/checks/bin/verify-coherence.js +237 -148
  38. package/dist/checks/bin/verify-dispatch.js +870 -66
  39. package/dist/checks/bin/verify-docs.js +13 -6
  40. package/dist/harness.js +57 -10
  41. package/dist/index.js +16617 -7187
  42. package/dist/lib/pre-push-cache-test-run.js +4487 -2170
  43. package/dist/lib/pre-push-changed-files.js +251 -12
  44. package/dist/lib/pre-push-mode.js +69 -19
  45. package/dist/lib/pre-push-progress-dir.js +10265 -2853
  46. package/dist/lib/pre-push-record-tests.js +67 -19
  47. package/dist/lib/pre-push-select-tests.js +520 -222
  48. package/dist/lib/push-progress-observer.js +9176 -1757
  49. package/dist/process.js +2 -0
  50. package/dist/programs/archive.js +8948 -1547
  51. package/dist/programs/audit.js +9176 -1772
  52. package/dist/programs/check.js +9248 -1845
  53. package/dist/programs/commit-msg.js +8984 -1583
  54. package/dist/programs/dev-review-loop.js +15612 -7634
  55. package/dist/programs/dispatch.js +9977 -2726
  56. package/dist/programs/log-emit.js +9011 -1660
  57. package/dist/programs/log-selftest.js +8908 -1507
  58. package/dist/programs/log-send.js +9081 -1594
  59. package/dist/programs/pr-report.js +9476 -1820
  60. package/dist/programs/pr-snapshot.js +8916 -1515
  61. package/dist/programs/pr-verify-evidence.js +9481 -1825
  62. package/dist/programs/pr.js +11709 -4033
  63. package/dist/programs/review-post.js +11140 -3496
  64. package/dist/programs/review-status.js +8996 -1533
  65. package/dist/programs/run-engine.js +22031 -18759
  66. package/dist/programs/sync.js +9030 -1629
  67. package/dist/programs/task-brief.js +10185 -1821
  68. package/dist/programs/task-sweep.js +9266 -1621
  69. package/dist/programs/task-tools-serve.js +77118 -16678
  70. package/dist/programs/tokens.js +8966 -1565
  71. package/dist/programs/waiver.js +8983 -1582
  72. package/dist/types/harness/kernel/dev-process-socket/loader/load-process.d.ts +1 -1
  73. package/dist/types/harness/processes/vinaya-strict/tools/legacy-markers.d.ts +8 -0
  74. package/dist/types/harness/processes/vinaya-strict/tools/task-contract/brief-validation.d.ts +3 -3
  75. package/dist/types/harness/processes/vinaya-strict/tools/task-contract/objectives.d.ts +5 -6
  76. package/dist/vinaya-strict/checks/registry.ts +2 -2
  77. package/dist/vinaya-strict/executing/developer/developer-doctrine-shape.test.ts +8 -0
  78. package/dist/vinaya-strict/executing/developer/developer-turn-result.ts +1 -1
  79. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.test.ts +2 -2
  80. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.ts +30 -20
  81. package/dist/vinaya-strict/executing/developer/reference.md +5 -3
  82. package/dist/vinaya-strict/integration/config/vinaya-config-section.ts +29 -7
  83. package/dist/vinaya-strict/integration/policies/vinaya-policies.ts +4 -4
  84. package/dist/vinaya-strict/integration/process/process-integration.ts +5 -1
  85. package/dist/vinaya-strict/process.yaml +6 -1
  86. package/dist/vinaya-strict/thinking/plan-reviewer/doctrine.md +68 -0
  87. package/dist/vinaya-strict/thinking/plan-reviewer/grants.yaml +19 -0
  88. package/dist/vinaya-strict/thinking/plan-reviewer/output.schema.json +388 -0
  89. package/dist/vinaya-strict/thinking/planner/doctrine.md +4 -1
  90. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.test.ts +10 -2
  91. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.ts +5 -1
  92. package/dist/vinaya-strict/thinking/planner/tools/open-issue.test.ts +198 -34
  93. package/dist/vinaya-strict/thinking/planner/tools/open-issue.ts +120 -193
  94. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.test.ts +629 -15
  95. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.ts +726 -62
  96. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.test.ts +505 -5
  97. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.ts +636 -21
  98. package/package.json +3 -2
  99. package/studio-standalone/apps/vinaya-studio/.next/BUILD_ID +1 -1
  100. package/studio-standalone/apps/vinaya-studio/.next/build-manifest.json +2 -2
  101. package/studio-standalone/apps/vinaya-studio/.next/prerender-manifest.json +3 -3
  102. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  103. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.html +1 -1
  104. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.rsc +1 -1
  105. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  106. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  107. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  108. package/studio-standalone/apps/vinaya-studio/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  109. package/studio-standalone/apps/vinaya-studio/.next/server/app/milestones/page_client-reference-manifest.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/.next/server/app/page_client-reference-manifest.js +1 -1
  111. package/studio-standalone/apps/vinaya-studio/.next/server/app/tasks/page_client-reference-manifest.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/.next/server/chunks/209.js +2 -2
  113. package/studio-standalone/apps/vinaya-studio/.next/server/chunks/951.js +1 -1
  114. package/studio-standalone/apps/vinaya-studio/.next/server/middleware-build-manifest.js +1 -1
  115. package/studio-standalone/apps/vinaya-studio/.next/server/pages/500.html +1 -1
  116. package/studio-standalone/apps/vinaya-studio/.next/server/preview-props.json +3 -3
  117. package/studio-standalone/apps/vinaya-studio/.next/server/server-reference-manifest.json +1 -1
  118. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/151-c365f0ef8268ad13.js +1 -0
  119. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/19-aa314f13784dcc58.js +4 -0
  120. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/{layout-dfa2186095e797bd.js → layout-f038e8deecb2bf5f.js} +1 -1
  121. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/milestones/{page-2fffb49104860a15.js → page-12314f4deb06a414.js} +1 -1
  122. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/{page-6ae258f663623b2a.js → page-7a06aa3cdd046fa8.js} +1 -1
  123. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/app/tasks/{page-2fffb49104860a15.js → page-12314f4deb06a414.js} +1 -1
  124. package/studio-standalone/apps/vinaya-studio/.next/static/css/8eb5ed5b65b9692e.css +1 -0
  125. package/studio-standalone/apps/vinaya-studio/log-follow.mjs +708 -93
  126. package/studio-standalone/apps/vinaya-studio/log-sync-folder-source.mjs +699 -84
  127. package/studio-standalone/apps/vinaya-studio/studio-server.mjs +4692 -3116
  128. package/vinaya-strict/artifacts/templates/brief-template.md +4 -0
  129. package/vinaya-strict/artifacts/templates/issue-rationale-template.md +7 -3
  130. package/vinaya-strict/artifacts/templates/pr-report-template.md +1 -1
  131. package/vinaya-strict/doctrine/contracts/planner-developer.md +2 -1
  132. package/vinaya-strict/doctrine/enforcement.md +4 -4
  133. package/vinaya-strict/doctrine/roles/principal.md +1 -1
  134. package/vinaya-strict/doctrine/state-machine.md +7 -2
  135. package/vinaya-strict/executing/developer/reference.md +5 -3
  136. package/vinaya-strict/thinking/plan-reviewer/doctrine.md +68 -0
  137. package/vinaya-strict/thinking/planner/doctrine.md +4 -1
  138. package/vinaya-strict/thinking/planner/reference.md +29 -8
  139. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/151-23bea4cac9687151.js +0 -1
  140. package/studio-standalone/apps/vinaya-studio/.next/static/chunks/853-1d5548ff3a55a75f.js +0 -4
  141. package/studio-standalone/apps/vinaya-studio/.next/static/css/fb16828fc3128d4c.css +0 -1
  142. /package/studio-standalone/apps/vinaya-studio/.next/static/{3URbt6IPajL5OOhijN1-x → bJrgAp9Kl4JsCUYkeAYez}/_buildManifest.js +0 -0
  143. /package/studio-standalone/apps/vinaya-studio/.next/static/{3URbt6IPajL5OOhijN1-x → bJrgAp9Kl4JsCUYkeAYez}/_ssgManifest.js +0 -0
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -23,6 +24,7 @@ var __toCommonJS = (from) => {
23
24
  return entry;
24
25
  };
25
26
  var __moduleCache;
27
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
26
28
  var __returnValue = (v) => v;
27
29
  function __exportSetter(name, newValue) {
28
30
  this[name] = __returnValue.bind(null, newValue);
@@ -47,6 +49,7 @@ var __esm = (fn, res, err) => () => {
47
49
  throw err[0];
48
50
  return res;
49
51
  };
52
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
50
53
 
51
54
  // ../../harness/processes/vinaya-strict/tools/task-contract/forge/parse-rationale-deps.ts
52
55
  function splitSlugQualifiedEdge(edge) {
@@ -392,6 +395,23 @@ async function ghApiGetAllPagesAsync(pathWithoutPage, opts) {
392
395
  }
393
396
  throw new Error(`ghApiGetAllPagesAsync: "${pathWithoutPage}" did not terminate within ${MAX_PAGES} pages (${MAX_PAGES * MAX_PER_PAGE} items) — refusing to keep walking.`);
394
397
  }
398
+ async function ghLabelIssueCountsAsync(owner, repo, labelQuery) {
399
+ const stdout = await runAsync([
400
+ "api",
401
+ "graphql",
402
+ "--paginate",
403
+ "-f",
404
+ `query=${LABEL_ISSUE_COUNTS_QUERY.replace("$labelQuery", JSON.stringify(labelQuery))}`,
405
+ "-f",
406
+ `owner=${owner}`,
407
+ "-f",
408
+ `name=${repo}`,
409
+ "--jq",
410
+ ".data.repository.labels.nodes[] | {name, open: .open.totalCount, total: .all.totalCount}"
411
+ ]);
412
+ return stdout.split(`
413
+ `).filter((line) => line.trim() !== "").map((line) => JSON.parse(line));
414
+ }
395
415
  function issueListByLabelArgs(owner, repo, label) {
396
416
  return [
397
417
  "issue",
@@ -425,7 +445,14 @@ async function ghIssueListByAnyLabelAsync(owner, repo, labels) {
425
445
  const perLabel = await Promise.all(labels.map((l) => ghIssueListByLabelAsync(owner, repo, l)));
426
446
  return dedupeByNumber(perLabel.flat());
427
447
  }
428
- var execFileAsync, systemEnv, MAX_PER_PAGE = 100, MAX_PAGES = 100;
448
+ var execFileAsync, systemEnv, MAX_PER_PAGE = 100, MAX_PAGES = 100, LABEL_ISSUE_COUNTS_QUERY = `query($owner: String!, $name: String!, $endCursor: String) {
449
+ repository(owner: $owner, name: $name) {
450
+ labels(first: 100, after: $endCursor, query: $labelQuery) {
451
+ pageInfo { hasNextPage endCursor }
452
+ nodes { name open: issues(states: OPEN) { totalCount } all: issues { totalCount } }
453
+ }
454
+ }
455
+ }`;
429
456
  var init_gh = __esm(() => {
430
457
  execFileAsync = promisify(execFile);
431
458
  systemEnv = {
@@ -766,7 +793,7 @@ function commentMarkerFamily(name) {
766
793
  function anchorAlternation(spellings) {
767
794
  return `(?:${spellings.map((spelling) => spelling.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})`;
768
795
  }
769
- var REGION_PREFIX, PROVENANCE_HEADING, CLAIM_ANCHOR, QUOTES_FILE_ANCHOR, VENDOR_EXAMPLE_ANCHOR, COMMENT_MARKER_PREFIX, FROZEN_BRIEF_MARKER, DEVELOPER_ROUND_MARKER, DEVELOPER_STOP_MARKER, LOOP_PUBLISHED_MARKER, LOOP_PAUSED_MARKER, LOOP_UNPUSHED_WORK_RESUME_MARKER, PRINCIPAL_RULING_MARKER, OBJECTIVES_VERSION_MARKER, DEFERRED_FINDINGS_MARKER, COMMENT_MARKER_PREFIX_CURRENT, COMMENT_MARKER_PREFIXES, COMMENT_MARKER_PREFIX_PATTERN, REGION_PREFIX_CURRENT, REGION_PREFIXES, PROVENANCE_HEADINGS, CLAIM_ANCHORS, QUOTES_FILE_ANCHORS, VENDOR_EXAMPLE_ANCHORS;
796
+ var REGION_PREFIX, PROVENANCE_HEADING, CLAIM_ANCHOR, QUOTES_FILE_ANCHOR, VENDOR_EXAMPLE_ANCHOR, COMMENT_MARKER_PREFIX, FROZEN_BRIEF_MARKER, DEVELOPER_ROUND_MARKER, DEVELOPER_STOP_MARKER, LOOP_PUBLISHED_MARKER, LOOP_PAUSED_MARKER, LOOP_UNPUSHED_WORK_RESUME_MARKER, PRINCIPAL_RULING_MARKER, OBJECTIVES_VERSION_MARKER, DOCUMENTATION_EDIT_MARKER, DEFERRED_FINDINGS_MARKER, COMMENT_MARKER_PREFIX_CURRENT, COMMENT_MARKER_PREFIXES, COMMENT_MARKER_PREFIX_PATTERN, REGION_PREFIX_CURRENT, REGION_PREFIXES, PROVENANCE_HEADINGS, CLAIM_ANCHORS, QUOTES_FILE_ANCHORS, VENDOR_EXAMPLE_ANCHORS;
770
797
  var init_legacy_markers = __esm(() => {
771
798
  REGION_PREFIX = { old: "AEG", current: "VINAYA" };
772
799
  PROVENANCE_HEADING = {
@@ -788,6 +815,7 @@ var init_legacy_markers = __esm(() => {
788
815
  LOOP_UNPUSHED_WORK_RESUME_MARKER = commentMarkerFamily("loop:unpushed-work-resume");
789
816
  PRINCIPAL_RULING_MARKER = commentMarkerFamily("principal:ruling");
790
817
  OBJECTIVES_VERSION_MARKER = commentMarkerFamily("objectives");
818
+ DOCUMENTATION_EDIT_MARKER = commentMarkerFamily("documentation");
791
819
  DEFERRED_FINDINGS_MARKER = commentMarkerFamily("deferred-findings");
792
820
  COMMENT_MARKER_PREFIX_CURRENT = COMMENT_MARKER_PREFIX.current;
793
821
  COMMENT_MARKER_PREFIXES = [COMMENT_MARKER_PREFIX.current, COMMENT_MARKER_PREFIX.old];
@@ -1598,6 +1626,7 @@ var init_doctrine_map = __esm(() => {
1598
1626
  { key: "roles/developer.md", source: "executing/developer/doctrine.md", role: "developer", ships: true },
1599
1627
  { key: "roles/developer/reference.md", source: "executing/developer/reference.md", ships: true },
1600
1628
  { key: "roles/operator.md", source: "executing/operator/doctrine.md", role: "operator", ships: true },
1629
+ { key: "roles/plan-reviewer.md", source: "thinking/plan-reviewer/doctrine.md", role: "plan-reviewer", ships: true },
1601
1630
  { key: "roles/planner.md", source: "thinking/planner/doctrine.md", role: "planner", ships: true },
1602
1631
  { key: "roles/planner/reference.md", source: "thinking/planner/reference.md", ships: true },
1603
1632
  { key: "roles/principal.md", source: "doctrine/roles/principal.md", role: "principal", ships: true },
@@ -2720,7 +2749,13 @@ function isMechanicallyNeutralDiff(diffText, path) {
2720
2749
  }
2721
2750
  return sawChange;
2722
2751
  }
2723
- function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive, getDiff) {
2752
+ function prBodyGiven(env = process.env) {
2753
+ return env.PR_BODY !== undefined || env.PR_BODY_FILE !== undefined;
2754
+ }
2755
+ function owedNeutralNotes(result) {
2756
+ return result.notes.filter((n) => n.startsWith(DOC_NEUTRAL_OWED_PREFIX));
2757
+ }
2758
+ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive, getDiff, bodyGiven = true) {
2724
2759
  const out = { errors: [], notes: [] };
2725
2760
  if (docOwnersContent === null)
2726
2761
  return out;
@@ -2760,24 +2795,28 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
2760
2795
  }
2761
2796
  if (changed.includes(pointerPath))
2762
2797
  continue;
2798
+ const evidenced = () => getDiff !== undefined && matchedFiles.every((f) => {
2799
+ const diff = getDiff(f);
2800
+ return diff !== null && isMechanicallyNeutralDiff(diff, f);
2801
+ });
2763
2802
  const declared = neutrals.find((n) => n.surface === b.pointer);
2764
2803
  if (declared) {
2765
- const evidenced = getDiff !== undefined && matchedFiles.every((f) => {
2766
- const diff = getDiff(f);
2767
- return diff !== null && isMechanicallyNeutralDiff(diff, f);
2768
- });
2769
- if (evidenced) {
2804
+ if (evidenced()) {
2770
2805
  out.notes.push(`C5 doc-neutral: ${b.pointer} not required for ${DOC_OWNERS_PATH}:${b.lineNum} (glob \`${b.glob}\`) — declared neutral ("${declared.note}"), diff of ${matchedFiles.join(", ")} confirmed comment/whitespace-only.`);
2771
2806
  continue;
2772
2807
  }
2773
2808
  out.errors.push(`C5 doc-neutral-unverified: ${DOC_OWNERS_PATH}:${b.lineNum} (glob \`${b.glob}\` → ${b.pointer}) declared \`Doc-neutral: ${b.pointer} — ${declared.note}\`, but the diff of ${matchedFiles.join(", ")} contains changes beyond comments/whitespace. Update ${pointerPath}, or have a principal apply the \`${WAIVER_LABEL}\` label.`);
2774
2809
  continue;
2775
2810
  }
2811
+ if (!bodyGiven && evidenced()) {
2812
+ out.notes.push(`${DOC_NEUTRAL_OWED_PREFIX} ${b.pointer} not required in this run for ${DOC_OWNERS_PATH}:${b.lineNum} (glob \`${b.glob}\`) — no pull request body was given, and the diff of ${matchedFiles.join(", ")} is comment/whitespace-only. The pull request body owes \`Doc-neutral: ${b.pointer} — <why>\`.`);
2813
+ continue;
2814
+ }
2776
2815
  out.errors.push(`C5 doc-coverage: code change matched ${DOC_OWNERS_PATH}:${b.lineNum} (glob \`${b.glob}\` → ${b.pointer}), but ${pointerPath} is not in the PR diff. Update it, declare \`Doc-neutral: ${b.pointer} — <why>\` if the change is genuinely mechanically-neutral, or have a principal apply the \`${WAIVER_LABEL}\` label.`);
2777
2816
  }
2778
2817
  return out;
2779
2818
  }
2780
- var DOC_OWNERS_PATH = ".vinaya/doc-owners", SEPARATOR, LANGUAGE_COMMENT_PREFIXES;
2819
+ var DOC_OWNERS_PATH = ".vinaya/doc-owners", SEPARATOR, LANGUAGE_COMMENT_PREFIXES, DOC_NEUTRAL_OWED_PREFIX = "C5 doc-neutral-owed:";
2781
2820
  var init_doc_owners = __esm(() => {
2782
2821
  init_file_classify();
2783
2822
  init_waiver_label();
@@ -2832,6 +2871,20 @@ var init_protected_paths = __esm(() => {
2832
2871
  ];
2833
2872
  });
2834
2873
 
2874
+ // ../../harness/processes/vinaya-strict/tools/task-contract/test-plan-proof.ts
2875
+ function stripObjectiveIdSpans(text) {
2876
+ return text.replace(ITEM_IDS_SPAN_RE, "").trim();
2877
+ }
2878
+ var ID_LIST, LINE_IDS_RE, ITEM_IDS_SPAN_RE;
2879
+ var init_test_plan_proof = __esm(() => {
2880
+ init_brief_validation();
2881
+ init_objectives();
2882
+ init_test_plan_section();
2883
+ ID_LIST = String.raw`O\d+(?:\s*,\s*O\d+)*`;
2884
+ LINE_IDS_RE = new RegExp(String.raw`\(\s*(${ID_LIST})\s*\)\s*$`);
2885
+ ITEM_IDS_SPAN_RE = new RegExp(String.raw`(?<!\`)(\`+)\s*\(?\s*(${ID_LIST})\s*\)?\s*\1(?!\`)`, "g");
2886
+ });
2887
+
2835
2888
  // ../../harness/processes/vinaya-strict/tools/task-contract/issue-validation.ts
2836
2889
  function hasRationaleField(body, labelPattern) {
2837
2890
  const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
@@ -3030,7 +3083,7 @@ function checkPartsCiteDefinedObjectives(body) {
3030
3083
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3031
3084
  }
3032
3085
  function liveCommand(text) {
3033
- const trimmed = text.trim();
3086
+ const trimmed = stripObjectiveIdSpans(text);
3034
3087
  const span = /^(`+)(.+)\1$/.exec(trimmed);
3035
3088
  return span ? span[2].trim() : trimmed;
3036
3089
  }
@@ -3165,11 +3218,13 @@ var init_issue_validation = __esm(() => {
3165
3218
  init_derive_section7();
3166
3219
  init_doctrine_map();
3167
3220
  init_objectives();
3221
+ init_waiver_label();
3168
3222
  init_issue_documentation();
3169
3223
  init_touched_path();
3170
3224
  init_protected_paths();
3171
3225
  init_quoted_command();
3172
3226
  init_test_plan_section();
3227
+ init_test_plan_proof();
3173
3228
  RATIONALE_FIELDS = [
3174
3229
  { name: "Boundary", pattern: "Boundary" },
3175
3230
  { name: "Sizing", pattern: "Sizing" },
@@ -3225,59 +3280,22 @@ function emitCheckError(error) {
3225
3280
  var CHECK_SCHEMA_VERSION = 1;
3226
3281
 
3227
3282
  // ../../harness/kernel/log/custom.ts
3228
- import { z } from "zod";
3229
- var CUSTOM_EVENT_NAME_PATTERN, CUSTOM_EVENT_NAME_MAX_LENGTH = 64, CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya", CUSTOM_EVENT_MAX_FIELDS = 20, CUSTOM_FIELD_NAME_PATTERN, CUSTOM_FIELD_NAME_MAX_LENGTH = 64, CUSTOM_TEXT_MAX_LENGTH = 500, CUSTOM_WORD_PATTERN, CUSTOM_WORD_MAX_LENGTH = 64, CUSTOM_FIELD_MAX_WORDS = 50, CustomFieldTypeSchema, CustomEventDeclarationsSchema;
3230
- var init_custom = __esm(() => {
3231
- CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
3232
- CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
3233
- CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
3234
- CustomFieldTypeSchema = z.union([z.enum(["text", "number", "boolean"]), z.array(z.string())]);
3235
- CustomEventDeclarationsSchema = z.record(z.string(), z.object({
3236
- fields: z.record(z.string(), CustomFieldTypeSchema)
3237
- }).strict()).superRefine((events, ctx) => {
3238
- for (const [name, declaration] of Object.entries(events)) {
3239
- const refuse = (message, path = []) => {
3240
- ctx.addIssue({
3241
- code: z.ZodIssueCode.custom,
3242
- path: [name, ...path],
3243
- message: `logs.events "${name}": ${message}`
3244
- });
3245
- };
3246
- if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
3247
- refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
3248
- }
3249
- if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
3250
- refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
3251
- } else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
3252
- refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
3253
- }
3254
- const fieldEntries = Object.entries(declaration.fields);
3255
- if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
3256
- refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
3257
- }
3258
- for (const [field, type] of fieldEntries) {
3259
- if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
3260
- refuse(`field "${field}": a field name is lowercase letters, digits and \`_\`, starting with a letter, at most ${CUSTOM_FIELD_NAME_MAX_LENGTH} characters`, ["fields", field]);
3261
- }
3262
- if (typeof type === "string")
3263
- continue;
3264
- if (type.length === 0) {
3265
- refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
3266
- }
3267
- if (type.length > CUSTOM_FIELD_MAX_WORDS) {
3268
- refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
3269
- }
3270
- const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
3271
- if (bad.length > 0) {
3272
- refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
3273
- }
3274
- if (new Set(type).size !== type.length) {
3275
- refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
3276
- }
3277
- }
3278
- }
3279
- });
3280
- });
3283
+ import {
3284
+ CUSTOM_EVENT_MAX_FIELDS,
3285
+ CUSTOM_EVENT_NAME_MAX_LENGTH,
3286
+ CUSTOM_EVENT_NAME_PATTERN,
3287
+ CUSTOM_EVENT_RESERVED_NAMESPACE,
3288
+ CUSTOM_FIELD_MAX_WORDS,
3289
+ CUSTOM_FIELD_NAME_MAX_LENGTH,
3290
+ CUSTOM_FIELD_NAME_PATTERN,
3291
+ CUSTOM_TEXT_MAX_LENGTH,
3292
+ CUSTOM_WORD_MAX_LENGTH,
3293
+ CUSTOM_WORD_PATTERN,
3294
+ CustomEventDeclarationsSchema,
3295
+ checkCustomEvent,
3296
+ UNRECORDABLE_FIELD_NAME
3297
+ } from "@attalabs/vinaya-log-sdk";
3298
+ var init_custom = () => {};
3281
3299
 
3282
3300
  // ../../harness/kernel/adapters/agents/agent-vendors.ts
3283
3301
  var AGENT_VENDORS;
@@ -3617,14 +3635,15 @@ ${detail}`;
3617
3635
  return null;
3618
3636
  }
3619
3637
  }
3620
- function loadTrustAnchorConfig(fetcher = fetchTrustAnchorConfig) {
3638
+ function loadTrustAnchorConfig(fetcher = fetchTrustAnchorConfig, loadOptions = {}) {
3639
+ const warn = loadOptions.quiet ? () => {} : warnTrustAnchorFallback;
3621
3640
  let base64;
3622
3641
  try {
3623
3642
  base64 = fetcher();
3624
3643
  } catch (err) {
3625
- return trustAnchorFetchFailed(err);
3644
+ return trustAnchorFetchFailed(err, warn);
3626
3645
  }
3627
- return parseTrustAnchorContent(base64);
3646
+ return parseTrustAnchorContent(base64, warn);
3628
3647
  }
3629
3648
  function loadTrustAnchorConfigOrThrow(fetcher = fetchTrustAnchorConfig) {
3630
3649
  let base64;
@@ -3683,9 +3702,9 @@ var installed = null, NO_CONFIG_PROVIDER_MESSAGE = "no configuration provider is
3683
3702
 
3684
3703
  // ../../harness/kernel/config/schema/config-schema.ts
3685
3704
  import { isAbsolute } from "node:path";
3686
- import { z as z2 } from "zod";
3705
+ import { z } from "zod";
3687
3706
  function checkEntrySchema(fields) {
3688
- return z2.object(fields).superRefine((entry, ctx) => {
3707
+ return z.object(fields).superRefine((entry, ctx) => {
3689
3708
  const env = entry.env;
3690
3709
  if (!env)
3691
3710
  return;
@@ -3695,14 +3714,14 @@ function checkEntrySchema(fields) {
3695
3714
  const members = value.anyOf;
3696
3715
  if (new Set(members).size !== members.length) {
3697
3716
  ctx.addIssue({
3698
- code: z2.ZodIssueCode.custom,
3717
+ code: z.ZodIssueCode.custom,
3699
3718
  message: `env.${key}.anyOf has duplicate members`,
3700
3719
  path: ["env", key, "anyOf"]
3701
3720
  });
3702
3721
  }
3703
3722
  if (!members.includes(key)) {
3704
3723
  ctx.addIssue({
3705
- code: z2.ZodIssueCode.custom,
3724
+ code: z.ZodIssueCode.custom,
3706
3725
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
3707
3726
  path: ["env", key, "anyOf"]
3708
3727
  });
@@ -3725,26 +3744,31 @@ function hookBlockPathRule(prefixes) {
3725
3744
  return { isCanonical, schema };
3726
3745
  }
3727
3746
  function managedManifestSchemas(agentVendors, hookBlockPrefixes) {
3728
- const block = z2.object({
3747
+ const block = z.object({
3729
3748
  path: hookBlockPathRule(hookBlockPrefixes).schema,
3730
- marker: z2.string(),
3731
- comment: z2.enum(["hash", "html"])
3749
+ marker: z.string(),
3750
+ comment: z.enum(["hash", "html"])
3732
3751
  });
3733
- const manifest = z2.object({
3734
- version: z2.number().int().positive(),
3735
- files: z2.array(SafeRepoRelPath),
3736
- blocks: z2.array(block),
3737
- labels: z2.array(z2.string()),
3738
- agents: z2.array(z2.enum(agentVendors)).optional()
3752
+ const manifest = z.object({
3753
+ version: z.number().int().positive(),
3754
+ files: z.array(SafeRepoRelPath),
3755
+ blocks: z.array(block),
3756
+ labels: z.array(z.string()),
3757
+ agents: z.array(z.enum(agentVendors)).optional()
3739
3758
  });
3740
3759
  return { block, manifest };
3741
3760
  }
3742
3761
  function logsSchema(events) {
3743
- return z2.object({
3744
- folder: z2.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
3745
- url: z2.string().url().optional(),
3746
- headers: z2.record(z2.string()).optional(),
3747
- readHeaders: z2.record(z2.string()).optional(),
3762
+ return z.object({
3763
+ folder: z.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
3764
+ url: z.string().url().optional(),
3765
+ otlp: z.object({
3766
+ url: z.string().url().regex(/^https?:\/\//i),
3767
+ headers: z.record(z.string()).optional()
3768
+ }).strict().optional(),
3769
+ headers: z.record(z.string()).optional(),
3770
+ readHeaders: z.record(z.string()).optional(),
3771
+ keepDays: z.number({ invalid_type_error: "must be a whole number of days" }).int({ message: "must be a whole number of days" }).min(1, { message: "must be at least 1" }).optional(),
3748
3772
  events: events.optional()
3749
3773
  }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
3750
3774
  message: "logs: set at most one of folder/url"
@@ -3752,22 +3776,22 @@ function logsSchema(events) {
3752
3776
  message: "logs: headers requires url"
3753
3777
  }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
3754
3778
  message: "logs: readHeaders requires url"
3755
- }).or(z2.literal(false)).optional();
3779
+ }).or(z.literal(false)).optional();
3756
3780
  }
3757
3781
  function kernelConfigFragment(leaves) {
3758
3782
  return {
3759
- rings: z2.object({
3760
- ring1_forgeWriteInterception: z2.boolean(),
3761
- ring2_asyncAudits: z2.boolean()
3783
+ rings: z.object({
3784
+ ring1_forgeWriteInterception: z.boolean(),
3785
+ ring2_asyncAudits: z.boolean()
3762
3786
  }).optional(),
3763
- checks: z2.record(z2.string(), checkEntrySchema(leaves.checkEntryFields)).optional(),
3787
+ checks: z.record(z.string(), checkEntrySchema(leaves.checkEntryFields)).optional(),
3764
3788
  managed: managedManifestSchemas(leaves.agentVendors, leaves.hookBlockPrefixes).manifest.optional(),
3765
- ci: z2.object({ setup: z2.string().min(1) }).optional(),
3766
- logPublish: z2.unknown().refine((v) => v === undefined, {
3789
+ ci: z.object({ setup: z.string().min(1) }).optional(),
3790
+ logPublish: z.unknown().refine((v) => v === undefined, {
3767
3791
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
3768
3792
  }),
3769
- runtimeDir: z2.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
3770
- runner: z2.enum(["standalone", "atta-engine"]).optional(),
3793
+ runtimeDir: z.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
3794
+ runner: z.enum(["standalone", "atta-engine"]).optional(),
3771
3795
  logs: logsSchema(leaves.logEvents)
3772
3796
  };
3773
3797
  }
@@ -3807,25 +3831,25 @@ function resolveLogsHeaderValues(headers, env) {
3807
3831
  }
3808
3832
  var EnvEntrySchema, KERNEL_CHECK_ENTRY_FIELDS, SafeRepoRelPath, KERNEL_CONFIG_REFINEMENTS;
3809
3833
  var init_config_schema = __esm(() => {
3810
- EnvEntrySchema = z2.union([
3811
- z2.literal(true),
3812
- z2.object({ optional: z2.literal(true) }),
3813
- z2.object({ anyOf: z2.array(z2.string()).min(2) }),
3814
- z2.string()
3834
+ EnvEntrySchema = z.union([
3835
+ z.literal(true),
3836
+ z.object({ optional: z.literal(true) }),
3837
+ z.object({ anyOf: z.array(z.string()).min(2) }),
3838
+ z.string()
3815
3839
  ]);
3816
3840
  KERNEL_CHECK_ENTRY_FIELDS = {
3817
- run: z2.string(),
3818
- scope: z2.enum(["diff", "full"]),
3819
- include: z2.array(z2.string()).optional(),
3820
- args: z2.array(z2.string()).optional(),
3821
- timeoutMs: z2.number().optional(),
3822
- env: z2.record(z2.string(), EnvEntrySchema).optional(),
3823
- requiresOpenPr: z2.boolean().optional(),
3824
- ownWorkflow: z2.boolean().optional(),
3825
- validates: z2.enum(["body", "issue"]).optional(),
3826
- advisory: z2.literal(true).optional()
3841
+ run: z.string(),
3842
+ scope: z.enum(["diff", "full"]),
3843
+ include: z.array(z.string()).optional(),
3844
+ args: z.array(z.string()).optional(),
3845
+ timeoutMs: z.number().optional(),
3846
+ env: z.record(z.string(), EnvEntrySchema).optional(),
3847
+ requiresOpenPr: z.boolean().optional(),
3848
+ ownWorkflow: z.boolean().optional(),
3849
+ validates: z.enum(["body", "issue"]).optional(),
3850
+ advisory: z.literal(true).optional()
3827
3851
  };
3828
- SafeRepoRelPath = z2.string().refine(isSafeRepoRelPath, {
3852
+ SafeRepoRelPath = z.string().refine(isSafeRepoRelPath, {
3829
3853
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
3830
3854
  });
3831
3855
  KERNEL_CONFIG_REFINEMENTS = [];
@@ -4393,7 +4417,7 @@ var init_review_gate = __esm(() => {
4393
4417
 
4394
4418
  // ../../harness/processes/vinaya-strict/tools/prose-rules-config.ts
4395
4419
  import safeRegex from "safe-regex2";
4396
- import { z as z3 } from "zod";
4420
+ import { z as z2 } from "zod";
4397
4421
  function isPlainObject3(value) {
4398
4422
  return typeof value === "object" && value !== null && !Array.isArray(value);
4399
4423
  }
@@ -4663,18 +4687,18 @@ var init_prose_rules_config = __esm(() => {
4663
4687
  FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
4664
4688
  CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
4665
4689
  DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
4666
- RepoRelativePathSchema = z3.string().min(1).superRefine((entry, ctx) => {
4690
+ RepoRelativePathSchema = z2.string().min(1).superRefine((entry, ctx) => {
4667
4691
  const reason = outsideRepositoryReason(entry);
4668
4692
  if (reason)
4669
- ctx.addIssue({ code: z3.ZodIssueCode.custom, message: reason });
4693
+ ctx.addIssue({ code: z2.ZodIssueCode.custom, message: reason });
4670
4694
  });
4671
- ProseRulesSchema = z3.unknown().superRefine((value, ctx) => {
4695
+ ProseRulesSchema = z2.unknown().superRefine((value, ctx) => {
4672
4696
  for (const issue of proseRulesIssues(value)) {
4673
- ctx.addIssue({ code: z3.ZodIssueCode.custom, path: issue.path, message: issue.message });
4697
+ ctx.addIssue({ code: z2.ZodIssueCode.custom, path: issue.path, message: issue.message });
4674
4698
  }
4675
4699
  }).transform((value) => value);
4676
- PublishedProseSchema = z3.object({
4677
- allow: z3.array(z3.string().min(1)).optional()
4700
+ PublishedProseSchema = z2.object({
4701
+ allow: z2.array(z2.string().min(1)).optional()
4678
4702
  }).strict();
4679
4703
  });
4680
4704
 
@@ -4689,10 +4713,13 @@ var exports_vinaya_config_section = {};
4689
4713
  __export(exports_vinaya_config_section, {
4690
4714
  BRIEF_BUILTINS: () => BRIEF_BUILTINS,
4691
4715
  CANONICAL_HOOK_BLOCK_PREFIXES: () => CANONICAL_HOOK_BLOCK_PREFIXES,
4716
+ DEFAULT_REVIEW_AGENT: () => DEFAULT_REVIEW_AGENT,
4717
+ DEFAULT_REVIEW_ROUND_LIMIT: () => DEFAULT_REVIEW_ROUND_LIMIT,
4692
4718
  LOCAL_OVERRIDABLE_KEYS: () => LOCAL_OVERRIDABLE_KEYS,
4693
4719
  LOCAL_OVERRIDE_FILENAME: () => LOCAL_OVERRIDE_FILENAME,
4694
4720
  PRINCIPALS_FIX: () => PRINCIPALS_FIX,
4695
4721
  PrincipalsUnresolvedError: () => PrincipalsUnresolvedError,
4722
+ REVIEW_AGENT_SETTINGS: () => REVIEW_AGENT_SETTINGS,
4696
4723
  VINAYA_CHECK_ENTRY_FIELDS: () => VINAYA_CHECK_ENTRY_FIELDS,
4697
4724
  VINAYA_CONFIG_FILENAME: () => VINAYA_CONFIG_FILENAME,
4698
4725
  VINAYA_CONFIG_FRAGMENT: () => VINAYA_CONFIG_FRAGMENT,
@@ -4714,7 +4741,9 @@ __export(exports_vinaya_config_section, {
4714
4741
  resolveGateCutovers: () => resolveGateCutovers,
4715
4742
  resolveLocalPacingOverride: () => resolveLocalPacingOverride,
4716
4743
  resolveReleaseActor: () => resolveReleaseActor,
4744
+ resolveReviewAgent: () => resolveReviewAgent,
4717
4745
  resolveReviewPolicy: () => resolveReviewPolicy,
4746
+ resolveReviewRoundLimit: () => resolveReviewRoundLimit,
4718
4747
  resolveSecurityScanCommand: () => resolveSecurityScanCommand,
4719
4748
  tokensCollectTrustKey: () => tokensCollectTrustKey,
4720
4749
  trustAnchorFallbackWarning: () => trustAnchorFallbackWarning,
@@ -4725,7 +4754,7 @@ import { execFileSync as execFileSync3 } from "node:child_process";
4725
4754
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
4726
4755
  import { homedir } from "node:os";
4727
4756
  import { dirname as dirname2, join as join2 } from "node:path";
4728
- import { z as z4 } from "zod";
4757
+ import { z as z3 } from "zod";
4729
4758
  function isDefaultedAgentVendorPath(path, manifest) {
4730
4759
  if (manifest.agents !== undefined)
4731
4760
  return false;
@@ -4759,7 +4788,7 @@ function decisionRecordsOutsideDoctrine(config, ctx) {
4759
4788
  return;
4760
4789
  const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
4761
4790
  if (issue)
4762
- ctx.addIssue({ code: z4.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
4791
+ ctx.addIssue({ code: z3.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
4763
4792
  }
4764
4793
  function globalPrincipalsIgnoredWarning(path) {
4765
4794
  return `${path}: "principals" in the global config is ignored — principals may only be declared from a repo-local vinaya.config.json.`;
@@ -4863,6 +4892,12 @@ function resolveGateCutovers(config) {
4863
4892
  function resolveCollisionThreshold(config) {
4864
4893
  return config?.planning?.collisionThreshold ?? DEFAULT_COLLISION_THRESHOLD;
4865
4894
  }
4895
+ function resolveReviewRoundLimit(config) {
4896
+ return config?.planning?.reviewRoundLimit ?? DEFAULT_REVIEW_ROUND_LIMIT;
4897
+ }
4898
+ function resolveReviewAgent(config) {
4899
+ return config?.planning?.reviewAgent ?? DEFAULT_REVIEW_AGENT;
4900
+ }
4866
4901
  function principalsNotConfigured(why) {
4867
4902
  return new PrincipalsUnresolvedError("not-configured", `no Principal is configured (${why}) — ${PRINCIPALS_FIX}.`);
4868
4903
  }
@@ -4877,7 +4912,7 @@ function createTrustedPrincipalsResolver(reads) {
4877
4912
  }
4878
4913
  if (isMissingFileError(err))
4879
4914
  throw principalsNotConfigured("the default branch has no vinaya.config.json");
4880
- throw new PrincipalsUnresolvedError("read-failed", `could not read "principals" from vinaya.config.json on the default branch: ${fetchFailureReason(err)}`);
4915
+ throw new PrincipalsUnresolvedError("read-failed", `could not read "principals" from vinaya.config.json on the default branch: ${fetchFailureReason(err)}`, { cause: err });
4881
4916
  }
4882
4917
  const unusable = { why: "" };
4883
4918
  const config = reads.parse(content, (why) => {
@@ -4937,7 +4972,7 @@ function trustTokensCollectCommand(repoGitCommonDir, interpreter, script, script
4937
4972
  store[key] = { interpreter, script, scriptBlobHash, trustedAt: new Date().toISOString() };
4938
4973
  writeTokensCollectTrustStore(storePath, store);
4939
4974
  }
4940
- var VINAYA_HOME, VINAYA_GLOBAL_CONFIG_FILENAME = "config.json", VINAYA_CONFIG_FILENAME = "vinaya.config.json", CANONICAL_HOOK_BLOCK_PREFIXES, VINAYA_CHECK_ENTRY_FIELDS, AGENTS_SKILLS_PREFIX = ".agents/skills/", CLAUDE_SKILLS_PREFIX = ".claude/skills/vinaya-", RoleEntrySchema, MAX_REPORT_COMMAND_TIMEOUT_MS = 3600000, BRIEF_BUILTINS, BriefSectionSchema, BriefSchemaSchema, ProjectEntrySchema, VINAYA_CONFIG_FRAGMENT, LOCAL_OVERRIDE_FILENAME = "vinaya.config.local.json", LOCAL_OVERRIDABLE_KEYS, PrincipalsUnresolvedError, PRINCIPALS_FIX = 'add "principals": [...] to vinaya.config.json on the default branch', TOKENS_COLLECT_TRUST_PATH, VINAYA_GLOBAL_ONLY_KEYS, VINAYA_CONFIG_SECTION;
4975
+ var VINAYA_HOME, VINAYA_GLOBAL_CONFIG_FILENAME = "config.json", VINAYA_CONFIG_FILENAME = "vinaya.config.json", CANONICAL_HOOK_BLOCK_PREFIXES, VINAYA_CHECK_ENTRY_FIELDS, AGENTS_SKILLS_PREFIX = ".agents/skills/", CLAUDE_SKILLS_PREFIX = ".claude/skills/vinaya-", RoleEntrySchema, MAX_REPORT_COMMAND_TIMEOUT_MS = 3600000, BRIEF_BUILTINS, BriefSectionSchema, BriefSchemaSchema, ProjectEntrySchema, VINAYA_CONFIG_FRAGMENT, LOCAL_OVERRIDE_FILENAME = "vinaya.config.local.json", LOCAL_OVERRIDABLE_KEYS, DEFAULT_REVIEW_ROUND_LIMIT = 2, REVIEW_AGENT_SETTINGS, DEFAULT_REVIEW_AGENT = "same", PrincipalsUnresolvedError, PRINCIPALS_FIX = 'add "principals": [...] to vinaya.config.json on the default branch', TOKENS_COLLECT_TRUST_PATH, VINAYA_GLOBAL_ONLY_KEYS, VINAYA_CONFIG_SECTION;
4941
4976
  var init_vinaya_config_section = __esm(() => {
4942
4977
  init_review_policy();
4943
4978
  init_issue_validation();
@@ -4951,10 +4986,10 @@ var init_vinaya_config_section = __esm(() => {
4951
4986
  VINAYA_HOME = join2(homedir(), ".vinaya");
4952
4987
  CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
4953
4988
  VINAYA_CHECK_ENTRY_FIELDS = {
4954
- principalOwed: z4.literal(true).optional()
4989
+ principalOwed: z3.literal(true).optional()
4955
4990
  };
4956
- RoleEntrySchema = z4.object({
4957
- contract: z4.string().refine((p) => p.includes("/"), {
4991
+ RoleEntrySchema = z3.object({
4992
+ contract: z3.string().refine((p) => p.includes("/"), {
4958
4993
  message: 'must be a path (contain at least one "/"), not a bare filename'
4959
4994
  })
4960
4995
  });
@@ -4977,102 +5012,104 @@ var init_vinaya_config_section = __esm(() => {
4977
5012
  "briefSections",
4978
5013
  "milestoneShape"
4979
5014
  ];
4980
- BriefSectionSchema = z4.union([
4981
- z4.object({ builtin: z4.enum(BRIEF_BUILTINS) }),
4982
- z4.object({ heading: z4.string().min(1), name: z4.string().optional() }),
4983
- z4.object({ field: z4.string().min(1), name: z4.string().optional() }),
4984
- z4.object({ phrase: z4.string().min(1), name: z4.string().optional() })
5015
+ BriefSectionSchema = z3.union([
5016
+ z3.object({ builtin: z3.enum(BRIEF_BUILTINS) }),
5017
+ z3.object({ heading: z3.string().min(1), name: z3.string().optional() }),
5018
+ z3.object({ field: z3.string().min(1), name: z3.string().optional() }),
5019
+ z3.object({ phrase: z3.string().min(1), name: z3.string().optional() })
4985
5020
  ]);
4986
- BriefSchemaSchema = z4.object({
4987
- pr: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
4988
- issue: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
4989
- milestone: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
4990
- ack: z4.array(z4.enum(BRIEF_BUILTINS)).optional()
5021
+ BriefSchemaSchema = z3.object({
5022
+ pr: z3.object({ sections: z3.array(BriefSectionSchema) }).optional(),
5023
+ issue: z3.object({ sections: z3.array(BriefSectionSchema) }).optional(),
5024
+ milestone: z3.object({ sections: z3.array(BriefSectionSchema) }).optional(),
5025
+ ack: z3.array(z3.enum(BRIEF_BUILTINS)).optional()
4991
5026
  });
4992
- ProjectEntrySchema = z4.object({
4993
- name: z4.string().min(1),
4994
- description: z4.string().min(1).optional(),
4995
- path: z4.string().min(1).optional()
5027
+ ProjectEntrySchema = z3.object({
5028
+ name: z3.string().min(1),
5029
+ description: z3.string().min(1).optional(),
5030
+ path: z3.string().min(1).optional()
4996
5031
  });
4997
5032
  VINAYA_CONFIG_FRAGMENT = {
4998
- roles: z4.record(z4.string(), RoleEntrySchema).optional(),
5033
+ roles: z3.record(z3.string(), RoleEntrySchema).optional(),
4999
5034
  briefSchema: BriefSchemaSchema.optional(),
5000
- principals: z4.array(z4.string()).min(1).optional(),
5001
- releaseActor: z4.string().min(1).optional(),
5002
- tokens: z4.object({
5003
- collect: z4.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
5035
+ principals: z3.array(z3.string()).min(1).optional(),
5036
+ releaseActor: z3.string().min(1).optional(),
5037
+ tokens: z3.object({
5038
+ collect: z3.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
5004
5039
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
5005
5040
  })
5006
5041
  }).optional(),
5007
- blastRadius: z4.object({ extraDomains: z4.array(z4.string()).optional() }).optional(),
5008
- proseGates: z4.object({
5009
- doctrineRoot: z4.string().min(1).optional(),
5010
- readerFacingPrefix: z4.string().min(1).optional(),
5011
- readerFacingSuffix: z4.string().min(1).optional(),
5012
- legacySlugDir: z4.string().min(1).optional(),
5013
- sourceComments: z4.object({
5014
- globs: z4.array(z4.string().min(1)).optional(),
5015
- allowlist: z4.array(z4.string().min(1)).optional(),
5016
- severity: z4.enum(["warning", "error"]).optional()
5042
+ blastRadius: z3.object({ extraDomains: z3.array(z3.string()).optional() }).optional(),
5043
+ proseGates: z3.object({
5044
+ doctrineRoot: z3.string().min(1).optional(),
5045
+ readerFacingPrefix: z3.string().min(1).optional(),
5046
+ readerFacingSuffix: z3.string().min(1).optional(),
5047
+ legacySlugDir: z3.string().min(1).optional(),
5048
+ sourceComments: z3.object({
5049
+ globs: z3.array(z3.string().min(1)).optional(),
5050
+ allowlist: z3.array(z3.string().min(1)).optional(),
5051
+ severity: z3.enum(["warning", "error"]).optional()
5017
5052
  }).optional(),
5018
- specGrandfather: z4.union([z4.array(z4.string().min(1)), z4.record(z4.string().min(1), z4.number().int().min(0))]).optional(),
5019
- specPaths: z4.array(RepoRelativePathSchema).optional(),
5020
- productPaths: z4.array(RepoRelativePathSchema).optional(),
5053
+ specGrandfather: z3.union([z3.array(z3.string().min(1)), z3.record(z3.string().min(1), z3.number().int().min(0))]).optional(),
5054
+ specPaths: z3.array(RepoRelativePathSchema).optional(),
5055
+ productPaths: z3.array(RepoRelativePathSchema).optional(),
5021
5056
  published: PublishedProseSchema.optional(),
5022
5057
  rules: ProseRulesSchema.optional()
5023
5058
  }).optional(),
5024
- projects: z4.array(ProjectEntrySchema).optional(),
5025
- dispatch: z4.object({
5026
- timeoutMs: z4.number().int().positive().optional(),
5027
- reviewerTimeoutMs: z4.number().int().positive().optional(),
5028
- killGraceMs: z4.number().int().positive().optional(),
5029
- agent: z4.enum(["claude", "codex"]).optional()
5059
+ projects: z3.array(ProjectEntrySchema).optional(),
5060
+ dispatch: z3.object({
5061
+ timeoutMs: z3.number().int().positive().optional(),
5062
+ reviewerTimeoutMs: z3.number().int().positive().optional(),
5063
+ killGraceMs: z3.number().int().positive().optional(),
5064
+ agent: z3.enum(["claude", "codex"]).optional()
5030
5065
  }).optional(),
5031
- reviewPolicy: z4.object({
5032
- codeReviewThreshold: z4.string().min(1).optional(),
5033
- securityThreshold: z4.string().min(1).optional(),
5034
- maxRounds: z4.number().optional(),
5035
- maxTaskMinutes: z4.number().optional(),
5036
- readyPushTimeoutMinutes: z4.number().optional()
5066
+ reviewPolicy: z3.object({
5067
+ codeReviewThreshold: z3.string().min(1).optional(),
5068
+ securityThreshold: z3.string().min(1).optional(),
5069
+ maxRounds: z3.number().optional(),
5070
+ maxTaskMinutes: z3.number().optional(),
5071
+ readyPushTimeoutMinutes: z3.number().optional()
5037
5072
  }).optional(),
5038
- securityScan: z4.object({
5039
- command: z4.array(z4.string().min(1)).min(1)
5073
+ securityScan: z3.object({
5074
+ command: z3.array(z3.string().min(1)).min(1)
5040
5075
  }).optional(),
5041
- gateCutovers: z4.object({
5042
- objectivesSinceIssue: z4.number().int().nonnegative().optional(),
5043
- briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
5044
- documentationSinceIssue: z4.number().int().nonnegative().optional(),
5045
- briefRulesSincePr: z4.number().int().nonnegative().optional(),
5046
- agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
5076
+ gateCutovers: z3.object({
5077
+ objectivesSinceIssue: z3.number().int().nonnegative().optional(),
5078
+ briefSectionsSinceIssue: z3.number().int().nonnegative().optional(),
5079
+ documentationSinceIssue: z3.number().int().nonnegative().optional(),
5080
+ briefRulesSincePr: z3.number().int().nonnegative().optional(),
5081
+ agentBoxesRefusedSincePr: z3.number().int().nonnegative().optional()
5047
5082
  }).optional(),
5048
- planning: z4.object({
5049
- collisionThreshold: z4.number().int().nonnegative().optional()
5083
+ planning: z3.object({
5084
+ collisionThreshold: z3.number().int().nonnegative().optional(),
5085
+ reviewRoundLimit: z3.number().int().positive().optional(),
5086
+ reviewAgent: z3.enum(["same", "different"]).optional()
5050
5087
  }).optional(),
5051
- prePush: z4.object({
5052
- alwaysRun: z4.array(z4.string()).optional(),
5053
- readyTests: z4.object({
5054
- mode: z4.literal("ci"),
5055
- workflow: z4.literal(".github/workflows/ci.yml"),
5056
- check: z4.literal("Vinaya CI")
5088
+ prePush: z3.object({
5089
+ alwaysRun: z3.array(z3.string()).optional(),
5090
+ readyTests: z3.object({
5091
+ mode: z3.literal("ci"),
5092
+ workflow: z3.literal(".github/workflows/ci.yml"),
5093
+ check: z3.literal("Vinaya CI")
5057
5094
  }).strict().optional(),
5058
- requiredCi: z4.object({
5059
- workflow: z4.literal(".github/workflows/ci.yml"),
5060
- check: z4.literal("Vinaya CI")
5095
+ requiredCi: z3.object({
5096
+ workflow: z3.literal(".github/workflows/ci.yml"),
5097
+ check: z3.literal("Vinaya CI")
5061
5098
  }).strict().optional()
5062
5099
  }).optional(),
5063
- report: z4.object({
5064
- commandTimeoutMs: z4.number().int().positive().optional()
5100
+ report: z3.object({
5101
+ commandTimeoutMs: z3.number().int().positive().optional()
5065
5102
  }).superRefine((report, ctx) => {
5066
5103
  const commandTimeoutMs = report.commandTimeoutMs;
5067
5104
  if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
5068
5105
  ctx.addIssue({
5069
- code: z4.ZodIssueCode.custom,
5106
+ code: z3.ZodIssueCode.custom,
5070
5107
  path: ["commandTimeoutMs"],
5071
5108
  message: "must be at most 3600000 (1 hour)"
5072
5109
  });
5073
5110
  }
5074
5111
  }).optional(),
5075
- decisionRecords: z4.object({
5112
+ decisionRecords: z3.object({
5076
5113
  path: RepoRelativePathSchema
5077
5114
  }).strict().optional()
5078
5115
  };
@@ -5081,10 +5118,11 @@ var init_vinaya_config_section = __esm(() => {
5081
5118
  "reviewPolicy.maxTaskMinutes",
5082
5119
  "reviewPolicy.readyPushTimeoutMinutes"
5083
5120
  ];
5121
+ REVIEW_AGENT_SETTINGS = ["same", "different"];
5084
5122
  PrincipalsUnresolvedError = class PrincipalsUnresolvedError extends Error {
5085
5123
  kind;
5086
- constructor(kind, message) {
5087
- super(message);
5124
+ constructor(kind, message, options) {
5125
+ super(message, options);
5088
5126
  this.name = "PrincipalsUnresolvedError";
5089
5127
  this.kind = kind;
5090
5128
  }
@@ -5128,7 +5166,7 @@ var init_vinaya_config_section = __esm(() => {
5128
5166
  });
5129
5167
 
5130
5168
  // ../../harness/processes/vinaya-strict/integration/config/compose.ts
5131
- import { z as z5 } from "zod";
5169
+ import { z as z4 } from "zod";
5132
5170
  function globalChecksIgnoredWarning(path) {
5133
5171
  return `${path}: "checks" registration in the global config is ignored — checks may only be registered from a repo-local vinaya.config.json.`;
5134
5172
  }
@@ -5200,7 +5238,7 @@ var init_compose = __esm(() => {
5200
5238
  "logs",
5201
5239
  "decisionRecords"
5202
5240
  ];
5203
- VinayaConfigObjectSchema = z5.object(orderedShape(CONFIG_KEY_ORDER, KERNEL_FRAGMENT, VINAYA_CONFIG_SECTION.fragment));
5241
+ VinayaConfigObjectSchema = z4.object(orderedShape(CONFIG_KEY_ORDER, KERNEL_FRAGMENT, VINAYA_CONFIG_SECTION.fragment));
5204
5242
  VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
5205
5243
  for (const refine of KERNEL_CONFIG_REFINEMENTS)
5206
5244
  refine(config, ctx);
@@ -5251,7 +5289,7 @@ var init_compose = __esm(() => {
5251
5289
  vinayaConfigProvider = {
5252
5290
  homeDir: VINAYA_HOME,
5253
5291
  loadConfig: () => loadConfig(),
5254
- loadTrustAnchorConfig: () => loadTrustAnchorConfig(),
5292
+ loadTrustAnchorConfig: (options) => loadTrustAnchorConfig(undefined, options),
5255
5293
  loadTrustAnchorConfigAsync: (fetcher, options) => loadTrustAnchorConfigAsync(fetcher, options)
5256
5294
  };
5257
5295
  installVinayaConfigProvider();
@@ -6142,10 +6180,23 @@ function describeError(err) {
6142
6180
 
6143
6181
  // ../../harness/processes/vinaya-strict/tools/task-contract/forge/fetch-open-issues.ts
6144
6182
  init_labels();
6145
- async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
6183
+ function failureReason(err, token) {
6184
+ const message = err instanceof Error ? err.message : String(err);
6185
+ if (token.length > 0 && message.includes(token))
6186
+ return null;
6187
+ return message;
6188
+ }
6189
+ async function fetchOpenIssuesByLabel(slugs, owner, repo, token, onFailedRead) {
6190
+ const read = await readOpenIssuesByLabel(slugs, owner, repo, token);
6191
+ if (read.ok)
6192
+ return read.issues;
6193
+ onFailedRead?.(read.reason);
6194
+ return new Map;
6195
+ }
6196
+ async function readOpenIssuesByLabel(slugs, owner, repo, token) {
6146
6197
  const result = new Map;
6147
6198
  if (slugs.length === 0)
6148
- return result;
6199
+ return { ok: true, issues: result };
6149
6200
  const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
6150
6201
  const toAlias = (slug) => `tranche_${slug.replace(/-/g, "_")}`;
6151
6202
  const perSlug = slugs.map((slug) => `
@@ -6159,11 +6210,12 @@ async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
6159
6210
  let response;
6160
6211
  try {
6161
6212
  response = await client(query, { owner, repo });
6162
- } catch {
6163
- return result;
6213
+ } catch (err) {
6214
+ return { ok: false, reason: failureReason(err, token) };
6215
+ }
6216
+ if (!response.repository) {
6217
+ return { ok: false, reason: `the repository ${owner}/${repo} is not visible to the token` };
6164
6218
  }
6165
- if (!response.repository)
6166
- return result;
6167
6219
  for (const slug of slugs) {
6168
6220
  const conn = response.repository[toAlias(slug)];
6169
6221
  const issues = (conn?.nodes ?? []).map((n) => ({
@@ -6173,7 +6225,7 @@ async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
6173
6225
  }));
6174
6226
  result.set(slug, issues);
6175
6227
  }
6176
- return result;
6228
+ return { ok: true, issues: result };
6177
6229
  }
6178
6230
 
6179
6231
  // ../../harness/processes/vinaya-strict/tools/dispatch-gate.ts
@@ -6186,6 +6238,9 @@ function siblingsSharingConflictEdge(subject, siblings) {
6186
6238
  function isHandClosedByRecognizedPrincipal(dep, principalAllowlist) {
6187
6239
  return dep.issueState === "closed" && dep.stateReason === "completed" && isPrincipal(dep.closedByActor ?? null, principalAllowlist);
6188
6240
  }
6241
+ function issueReadFailedMessage(prefix, issueNumber, error) {
6242
+ return `${prefix} issue-read-failed: the forge could not be read for Issue #${issueNumber}, so whether it exists is unknown — this is not a claim that the Issue is missing. gh reported: ${error}`;
6243
+ }
6189
6244
  function isSelfDependency(dep, task, issue) {
6190
6245
  if (dep.issue !== null && issue !== null && dep.issue === issue.number)
6191
6246
  return true;
@@ -6202,6 +6257,8 @@ function checkDispatchReadiness(input) {
6202
6257
  };
6203
6258
  if (task.issue === null) {
6204
6259
  push("issue-existence", `dispatch-gate issue-existence: ${taskLabel} has no Issue (#TBD or blank) in the topology — not dispatchable until the Planner cuts the Issue.`);
6260
+ } else if (input.issueReadFailed !== undefined) {
6261
+ push("issue-read-failed", issueReadFailedMessage("dispatch-gate", task.issue, input.issueReadFailed));
6205
6262
  } else if (input.issue === null) {
6206
6263
  push("issue-existence", `dispatch-gate issue-existence: ${taskLabel} names Issue #${task.issue}, but it does not resolve to a real GitHub Issue (phantom reference).`);
6207
6264
  }
@@ -6350,6 +6407,19 @@ function lifecycleFromIssues(issues) {
6350
6407
  return "planned";
6351
6408
  return issues.some((i) => i.state === "OPEN") ? "active" : "complete";
6352
6409
  }
6410
+ function lifecycleFromCounts(open, total) {
6411
+ if (total === 0)
6412
+ return "planned";
6413
+ return open > 0 ? "active" : "complete";
6414
+ }
6415
+ function resolveLegacyFactsFromCounts(milestone, open, total) {
6416
+ if (milestone.state === "closed" && total > 0) {
6417
+ return { goal: milestone.description ?? "", lifecycle: lifecycleFromCounts(open, total) };
6418
+ }
6419
+ return factsFromLegacyMilestone(milestone);
6420
+ }
6421
+ var TRANCHE_LABEL_QUERY = "vinaya/tranche:";
6422
+ var ACTIVE_ISSUE_READ_CONCURRENCY = 4;
6353
6423
  function goalFromMilestones(milestones, slug) {
6354
6424
  for (const m of milestones) {
6355
6425
  const goal = intentGoalForSlug(m.description ?? "", slug);
@@ -6377,10 +6447,20 @@ function trancheSlugsFromLabels(labels) {
6377
6447
  }
6378
6448
  async function indexTrancheMilestonesAsync(owner, repo, options = {}) {
6379
6449
  const read = (fetch) => options.retryFailedReads ? retryOnce(fetch) : fetch();
6380
- const [milestones, labels] = await Promise.all([
6450
+ const [milestones, labels, counts] = await Promise.all([
6381
6451
  read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`)),
6382
- read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`))
6452
+ read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`)),
6453
+ read(() => ghLabelIssueCountsAsync(owner, repo, TRANCHE_LABEL_QUERY))
6383
6454
  ]);
6455
+ const countsByLabel = new Map(counts.map((c) => [c.name, c]));
6456
+ const uncounted = trancheSlugsFromLabels(labels).map((slug) => trancheLabel(slug)).filter((label) => !countsByLabel.has(label));
6457
+ if (uncounted.length > 0) {
6458
+ throw new Error(`the label Issue-count query returned no count for ${uncounted.join(", ")}`);
6459
+ }
6460
+ const lifecycleOf = (slug) => {
6461
+ const c = countsByLabel.get(trancheLabel(slug));
6462
+ return lifecycleFromCounts(c?.open ?? 0, c?.total ?? 0);
6463
+ };
6384
6464
  const active = [];
6385
6465
  const archived = [];
6386
6466
  const facts = new Map;
@@ -6388,33 +6468,21 @@ async function indexTrancheMilestonesAsync(owner, repo, options = {}) {
6388
6468
  const legacyMilestoneBySlug = new Map(milestones.filter((m) => legacySlugs.has(m.title)).map((m) => [m.title, m]));
6389
6469
  const newPathSlugs = trancheSlugsFromLabels(labels).filter((slug) => !legacySlugs.has(slug));
6390
6470
  const uniqueNewPathSlugs = [...new Set(newPathSlugs)];
6391
- const uniqueLegacySlugs = [...legacySlugs];
6392
- const [legacyIssuesBySlug, newPathIssuesBySlug] = await Promise.all([
6393
- Promise.all(uniqueLegacySlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))))),
6394
- Promise.all(uniqueNewPathSlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))))
6395
- ]);
6396
- const issuesBySlug = new Map;
6397
- uniqueLegacySlugs.forEach((slug, i) => {
6398
- issuesBySlug.set(slug, legacyIssuesBySlug[i] ?? []);
6399
- });
6400
- uniqueNewPathSlugs.forEach((slug, i) => {
6401
- issuesBySlug.set(slug, newPathIssuesBySlug[i] ?? []);
6402
- });
6403
- uniqueLegacySlugs.forEach((slug, i) => {
6471
+ for (const slug of legacySlugs) {
6404
6472
  const m = legacyMilestoneBySlug.get(slug);
6405
6473
  if (!m)
6406
- return;
6474
+ continue;
6407
6475
  const ref = { slug, goal: m.description ?? "" };
6408
- const f = resolveLegacyFacts(m, legacyIssuesBySlug[i] ?? []);
6476
+ const c = countsByLabel.get(trancheLabel(slug));
6477
+ const f = resolveLegacyFactsFromCounts(m, c?.open ?? 0, c?.total ?? 0);
6409
6478
  if (f.lifecycle === "complete")
6410
6479
  archived.push(ref);
6411
6480
  else if (f.lifecycle === "active")
6412
6481
  active.push(ref);
6413
6482
  facts.set(slug, f);
6414
- });
6415
- uniqueNewPathSlugs.forEach((slug, i) => {
6416
- const issues = newPathIssuesBySlug[i] ?? [];
6417
- const lifecycle = lifecycleFromIssues(issues);
6483
+ }
6484
+ for (const slug of uniqueNewPathSlugs) {
6485
+ const lifecycle = lifecycleOf(slug);
6418
6486
  const goal = goalFromMilestones(milestones, slug);
6419
6487
  const f = { goal, lifecycle };
6420
6488
  facts.set(slug, f);
@@ -6422,7 +6490,16 @@ async function indexTrancheMilestonesAsync(owner, repo, options = {}) {
6422
6490
  active.push({ slug, goal });
6423
6491
  else if (lifecycle === "complete")
6424
6492
  archived.push({ slug, goal });
6425
- });
6493
+ }
6494
+ const issuesBySlug = new Map;
6495
+ const activeSlugs = active.map((r) => r.slug);
6496
+ for (let i = 0;i < activeSlugs.length; i += ACTIVE_ISSUE_READ_CONCURRENCY) {
6497
+ const batch = activeSlugs.slice(i, i + ACTIVE_ISSUE_READ_CONCURRENCY);
6498
+ const lists = await Promise.all(batch.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))));
6499
+ batch.forEach((slug, j) => {
6500
+ issuesBySlug.set(slug, lists[j] ?? []);
6501
+ });
6502
+ }
6426
6503
  return { active, archived, facts, legacySlugs, issuesBySlug };
6427
6504
  }
6428
6505
  async function retryOnce(fetch) {