@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/labels.ts
52
55
  function entry(key) {
@@ -489,6 +492,7 @@ var init_doctrine_map = __esm(() => {
489
492
  { key: "roles/developer.md", source: "executing/developer/doctrine.md", role: "developer", ships: true },
490
493
  { key: "roles/developer/reference.md", source: "executing/developer/reference.md", ships: true },
491
494
  { key: "roles/operator.md", source: "executing/operator/doctrine.md", role: "operator", ships: true },
495
+ { key: "roles/plan-reviewer.md", source: "thinking/plan-reviewer/doctrine.md", role: "plan-reviewer", ships: true },
492
496
  { key: "roles/planner.md", source: "thinking/planner/doctrine.md", role: "planner", ships: true },
493
497
  { key: "roles/planner/reference.md", source: "thinking/planner/reference.md", ships: true },
494
498
  { key: "roles/principal.md", source: "doctrine/roles/principal.md", role: "principal", ships: true },
@@ -644,7 +648,7 @@ function commentMarkerFamily(name) {
644
648
  function anchorAlternation(spellings) {
645
649
  return `(?:${spellings.map((spelling) => spelling.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})`;
646
650
  }
647
- 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;
651
+ 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;
648
652
  var init_legacy_markers = __esm(() => {
649
653
  REGION_PREFIX = { old: "AEG", current: "VINAYA" };
650
654
  PROVENANCE_HEADING = {
@@ -666,6 +670,7 @@ var init_legacy_markers = __esm(() => {
666
670
  LOOP_UNPUSHED_WORK_RESUME_MARKER = commentMarkerFamily("loop:unpushed-work-resume");
667
671
  PRINCIPAL_RULING_MARKER = commentMarkerFamily("principal:ruling");
668
672
  OBJECTIVES_VERSION_MARKER = commentMarkerFamily("objectives");
673
+ DOCUMENTATION_EDIT_MARKER = commentMarkerFamily("documentation");
669
674
  DEFERRED_FINDINGS_MARKER = commentMarkerFamily("deferred-findings");
670
675
  COMMENT_MARKER_PREFIX_CURRENT = COMMENT_MARKER_PREFIX.current;
671
676
  COMMENT_MARKER_PREFIXES = [COMMENT_MARKER_PREFIX.current, COMMENT_MARKER_PREFIX.old];
@@ -1163,7 +1168,7 @@ init_review_gate();
1163
1168
  init_diff_evidence();
1164
1169
  import { execFileSync as execFileSync2 } from "node:child_process";
1165
1170
  import { readdirSync, readFileSync } from "node:fs";
1166
- import { join as join2, relative as relative2 } from "node:path";
1171
+ import { join as join2 } from "node:path";
1167
1172
 
1168
1173
  // ../../harness/processes/vinaya-strict/checks/changeset-coverage-logic.ts
1169
1174
  function stripTrailingSlash(entry) {
@@ -1218,7 +1223,7 @@ function isShippedPath(member, repoRelativePath) {
1218
1223
  return isShippedRelPath(member.files, repoRelativePath.slice(prefix.length));
1219
1224
  }
1220
1225
  function isChangesetFile(repoRelativePath) {
1221
- return /^\.changeset\/(?!README\.md$).+\.md$/.test(repoRelativePath);
1226
+ return /^\.changeset\/(?!README\.md$).+\.md$/s.test(repoRelativePath);
1222
1227
  }
1223
1228
  function evaluateChangesetCoverage(fixedGroup, changedFiles, isReleaseBranch) {
1224
1229
  if (isReleaseBranch)
@@ -1230,6 +1235,42 @@ function evaluateChangesetCoverage(fixedGroup, changedFiles, isReleaseBranch) {
1230
1235
  return { status: "pass" };
1231
1236
  return { status: "finding", shippedPathsHit };
1232
1237
  }
1238
+ function changesetPackageNames(text) {
1239
+ const lines = text.split(/\r?\n/);
1240
+ const start = lines.findIndex((line) => line.trimEnd() === "---");
1241
+ if (start < 0)
1242
+ return [];
1243
+ const end = lines.findIndex((line, index) => index > start && line.trimEnd() === "---");
1244
+ if (end < 0)
1245
+ return [];
1246
+ const names = new Set;
1247
+ for (const line of lines.slice(start + 1, end)) {
1248
+ const key = /^\s*(?:'((?:[^']|'')+)'|"((?:[^"\\]|\\.)+)"|([^\s:'"#]+))\s*:\s*\S/.exec(line);
1249
+ const name = key?.[1]?.replaceAll("''", "'") ?? decodeDoubleQuotedKey(key?.[2]) ?? key?.[3];
1250
+ if (name)
1251
+ names.add(name);
1252
+ }
1253
+ return [...names];
1254
+ }
1255
+ function decodeDoubleQuotedKey(key) {
1256
+ return key?.replace(/\\(?:x([a-fA-F\d]{2})|u([a-fA-F\d]{4})|U([a-fA-F\d]{8})|(\/)|.)/g, (sequence, short, medium, long, slash) => {
1257
+ if (slash)
1258
+ return slash;
1259
+ const code = Number.parseInt(short ?? medium ?? long ?? "", 16);
1260
+ return code <= 1114111 ? String.fromCodePoint(code) : sequence;
1261
+ });
1262
+ }
1263
+ function evaluateIgnoredChangesets(ignore, changedChangesets, isReleaseBranch) {
1264
+ if (isReleaseBranch)
1265
+ return [];
1266
+ const patterns = ignore.filter((entry) => !entry.startsWith("!") && !/[?{}]/.test(entry)).map(filesGlobToRegex);
1267
+ if (patterns.length === 0)
1268
+ return [];
1269
+ return changedChangesets.flatMap(({ path, text }) => {
1270
+ const packages = changesetPackageNames(text).filter((name) => patterns.some((pattern) => pattern.test(name)));
1271
+ return packages.length > 0 ? [{ path, packages }] : [];
1272
+ });
1273
+ }
1233
1274
 
1234
1275
  // ../../harness/processes/vinaya-strict/checks/bin/check-changeset-coverage.ts
1235
1276
  var CHECK_NAME = "changeset-coverage";
@@ -1240,6 +1281,15 @@ function git(args) {
1240
1281
  return "";
1241
1282
  }
1242
1283
  }
1284
+ function readSnapshotFile(root, path, staged) {
1285
+ const args = staged ? ["ls-files", "--stage"] : ["ls-tree", "HEAD"];
1286
+ const options = { cwd: root, encoding: "utf8", stdio: "pipe" };
1287
+ const entry = execFileSync2("git", ["--literal-pathspecs", ...args, "-z", "--", path], options);
1288
+ const oid = (staged ? /^100(?:644|755) ([a-f0-9]+) 0\t/.exec(entry) : /^100(?:644|755) blob ([a-f0-9]+)\t/.exec(entry))?.[1];
1289
+ if (!oid)
1290
+ return null;
1291
+ return execFileSync2("git", ["cat-file", "blob", oid], options);
1292
+ }
1243
1293
  function currentBranch() {
1244
1294
  return git(["symbolic-ref", "--quiet", "--short", "HEAD"]);
1245
1295
  }
@@ -1247,8 +1297,13 @@ function defaultBranch() {
1247
1297
  const ref = git(["symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"]);
1248
1298
  return ref.startsWith("origin/") ? ref.slice("origin/".length) : "";
1249
1299
  }
1250
- function toPosix(p) {
1251
- return p.split("\\").join("/");
1300
+ function changedPaths(staged) {
1301
+ const diff = resolveDiff();
1302
+ if (!diff)
1303
+ return null;
1304
+ const options = { cwd: diff.root, encoding: "utf8", stdio: "pipe" };
1305
+ const args = staged ? ["--cached", "--merge-base", diff.base] : [`${diff.base}...HEAD`];
1306
+ return execFileSync2("git", ["diff", "--name-only", "-z", ...args], options).split("\x00").filter(Boolean);
1252
1307
  }
1253
1308
  function readPackageJson(path) {
1254
1309
  try {
@@ -1294,9 +1349,7 @@ function resolveWorkspaceMembers(root) {
1294
1349
  }
1295
1350
  return members;
1296
1351
  }
1297
- function fixedGroupNames(root) {
1298
- const pkg = readPackageJson(join2(root, ".changeset", "config.json"));
1299
- const fixed = pkg?.fixed;
1352
+ function fixedGroupNames(fixed) {
1300
1353
  if (!Array.isArray(fixed))
1301
1354
  return [];
1302
1355
  return fixed.flat().filter((n) => typeof n === "string");
@@ -1308,8 +1361,9 @@ function main() {
1308
1361
  if (current !== "" && current === base) {
1309
1362
  process.exit(0);
1310
1363
  }
1311
- const changedAbs = resolveChangedFiles();
1312
- if (changedAbs === null) {
1364
+ const staged = process.env.VINAYA_COMMIT_HOOK === "1" && Boolean(process.env.GIT_INDEX_FILE);
1365
+ const changedFiles = changedPaths(staged);
1366
+ if (changedFiles === null) {
1313
1367
  emitCheckError({
1314
1368
  schema: CHECK_SCHEMA_VERSION,
1315
1369
  check: CHECK_NAME,
@@ -1319,28 +1373,52 @@ function main() {
1319
1373
  });
1320
1374
  process.exit(0);
1321
1375
  }
1322
- if (changedAbs.length === 0) {
1376
+ if (changedFiles.length === 0) {
1323
1377
  process.exit(0);
1324
1378
  }
1325
- const changedFiles = changedAbs.map((p) => toPosix(relative2(root, p)));
1326
1379
  const branch = git(["rev-parse", "--abbrev-ref", "HEAD"]);
1327
1380
  const isReleaseBranch = branch === CHANGESET_RELEASE_BRANCH;
1381
+ const config = readPackageJson(join2(root, ".changeset", "config.json"));
1382
+ const snapshotConfig = isReleaseBranch ? null : readSnapshotFile(root, ".changeset/config.json", staged);
1383
+ let snapshotIgnore;
1384
+ if (snapshotConfig !== null) {
1385
+ try {
1386
+ snapshotIgnore = JSON.parse(snapshotConfig)?.ignore;
1387
+ } catch {}
1388
+ }
1389
+ const ignore = Array.isArray(snapshotIgnore) ? snapshotIgnore.filter((entry) => typeof entry === "string") : [];
1390
+ const changedChangesets = ignore.length > 0 && !isReleaseBranch ? changedFiles.filter(isChangesetFile).flatMap((path) => {
1391
+ const text = readSnapshotFile(root, path, staged);
1392
+ return text === null ? [] : [{ path, text }];
1393
+ }) : [];
1394
+ const ignored = evaluateIgnoredChangesets(ignore, changedChangesets, isReleaseBranch);
1328
1395
  const workspaceMembers = resolveWorkspaceMembers(root);
1329
- const fixedGroup = fixedGroupNames(root).map((name) => {
1396
+ const fixedGroup = fixedGroupNames(config?.fixed).map((name) => {
1330
1397
  const member = workspaceMembers.get(name);
1331
1398
  return member ? { name, dir: member.dir, files: member.files } : null;
1332
1399
  }).filter((m) => m !== null);
1333
- const result = evaluateChangesetCoverage(fixedGroup, changedFiles, isReleaseBranch);
1400
+ const refusedChangesets = new Set(ignored.map(({ path }) => path));
1401
+ const result = evaluateChangesetCoverage(fixedGroup, changedFiles.filter((path) => !refusedChangesets.has(path)), isReleaseBranch);
1334
1402
  console.log(`${CHECK_NAME}: ${fixedGroup.length} fixed-group member(s) resolved; ${result.status === "finding" ? result.shippedPathsHit.length : 0} shipped path(s) hit`);
1335
1403
  if (result.status === "finding") {
1336
1404
  emitCheckError({
1337
1405
  schema: CHECK_SCHEMA_VERSION,
1338
1406
  check: CHECK_NAME,
1339
1407
  severity: "error",
1340
- message: `changeset-coverage: this diff changes a published package's shipped file(s) with no \`.changeset/*.md\` in the same diff: ${result.shippedPathsHit.join(", ")}. Add a changeset describing the change, or add an empty one when the change ships nothing users see.`,
1408
+ message: `changeset-coverage: this diff changes a published package's shipped file(s) with no accepted \`.changeset/*.md\` in the same diff: ${result.shippedPathsHit.join(", ")}. Add a changeset describing the change, or add an empty one when the change ships nothing users see.`,
1341
1409
  agent_recovery_prompt: "Either add a `.changeset/*.md` entry describing the change in user terms (run the repo's changeset CLI, e.g. `bunx changeset`), or, when the change ships nothing users see, add an empty changeset (`bunx changeset add --empty`). Commit it in the same PR."
1342
1410
  });
1343
- process.exit(1);
1344
1411
  }
1412
+ for (const { path, packages } of ignored) {
1413
+ emitCheckError({
1414
+ schema: CHECK_SCHEMA_VERSION,
1415
+ check: CHECK_NAME,
1416
+ severity: "error",
1417
+ message: `changeset-coverage: ${path} names ignored package(s): ${packages.join(", ")}.`,
1418
+ agent_recovery_prompt: "Remove the ignored package entries from the changeset frontmatter. If no release is intended, use an empty changeset or delete the file when a changeset is unnecessary."
1419
+ });
1420
+ }
1421
+ if (result.status === "finding" || ignored.length > 0)
1422
+ process.exit(1);
1345
1423
  }
1346
1424
  main();
@@ -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/kernel/connectors/git/changed-line-ranges.ts
52
55
  function parseChangedLineRanges(diffOutput) {
@@ -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/kernel/adapters/code-host/github/gh.ts
52
55
  import { execFile as execFile2, execFileSync } from "node:child_process";
@@ -82,6 +85,23 @@ async function ghApiGetAllPagesAsync(pathWithoutPage, opts) {
82
85
  }
83
86
  throw new Error(`ghApiGetAllPagesAsync: "${pathWithoutPage}" did not terminate within ${MAX_PAGES} pages (${MAX_PAGES * MAX_PER_PAGE} items) — refusing to keep walking.`);
84
87
  }
88
+ async function ghLabelIssueCountsAsync(owner, repo, labelQuery) {
89
+ const stdout = await runAsync([
90
+ "api",
91
+ "graphql",
92
+ "--paginate",
93
+ "-f",
94
+ `query=${LABEL_ISSUE_COUNTS_QUERY.replace("$labelQuery", JSON.stringify(labelQuery))}`,
95
+ "-f",
96
+ `owner=${owner}`,
97
+ "-f",
98
+ `name=${repo}`,
99
+ "--jq",
100
+ ".data.repository.labels.nodes[] | {name, open: .open.totalCount, total: .all.totalCount}"
101
+ ]);
102
+ return stdout.split(`
103
+ `).filter((line) => line.trim() !== "").map((line) => JSON.parse(line));
104
+ }
85
105
  function issueListByLabelArgs(owner, repo, label) {
86
106
  return [
87
107
  "issue",
@@ -115,7 +135,14 @@ async function ghIssueListByAnyLabelAsync(owner, repo, labels) {
115
135
  const perLabel = await Promise.all(labels.map((l) => ghIssueListByLabelAsync(owner, repo, l)));
116
136
  return dedupeByNumber(perLabel.flat());
117
137
  }
118
- var execFileAsync2, systemEnv2, MAX_PER_PAGE = 100, MAX_PAGES = 100;
138
+ var execFileAsync2, systemEnv2, MAX_PER_PAGE = 100, MAX_PAGES = 100, LABEL_ISSUE_COUNTS_QUERY = `query($owner: String!, $name: String!, $endCursor: String) {
139
+ repository(owner: $owner, name: $name) {
140
+ labels(first: 100, after: $endCursor, query: $labelQuery) {
141
+ pageInfo { hasNextPage endCursor }
142
+ nodes { name open: issues(states: OPEN) { totalCount } all: issues { totalCount } }
143
+ }
144
+ }
145
+ }`;
119
146
  var init_gh = __esm(() => {
120
147
  execFileAsync2 = promisify2(execFile2);
121
148
  systemEnv2 = {
@@ -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" },
@@ -3954,6 +4009,7 @@ function parseTaskBranchIdentity(branch) {
3954
4009
  // ../../harness/processes/vinaya-strict/checks/coherence-checks.ts
3955
4010
  init_parse_rationale_deps();
3956
4011
  init_labels();
4012
+ init_list_tasks();
3957
4013
  init_anchored_region();
3958
4014
  init_legacy_markers();
3959
4015
  init_issue_validation();
@@ -3965,6 +4021,21 @@ function isGrandfathered(isoDate) {
3965
4021
  return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
3966
4022
  }
3967
4023
  var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
4024
+ function buildIssueEntries(trancheSlug, archived, tasks, factsByIssue) {
4025
+ return tasks.map((task) => ({
4026
+ trancheSlug,
4027
+ archived,
4028
+ task,
4029
+ facts: task.issue === null ? undefined : factsByIssue?.get(task.issue)
4030
+ }));
4031
+ }
4032
+ function buildTaskEntries(trancheSlug, archived, tasks, factsByIssue) {
4033
+ const { tasks: standing } = resolveDuplicateTasks(tasks, (n) => factsByIssue?.get(n)?.issueState === "open");
4034
+ return buildIssueEntries(trancheSlug, archived, standing, factsByIssue);
4035
+ }
4036
+ function provenanceKey(issue) {
4037
+ return String(issue);
4038
+ }
3968
4039
  function checkA1(entries, principalAllowlist) {
3969
4040
  const failures = [];
3970
4041
  for (const e of entries) {
@@ -4000,10 +4071,13 @@ function checkA2(entries, hasProvenanceByKey) {
4000
4071
  for (const e of entries) {
4001
4072
  if (!e.facts)
4002
4073
  continue;
4074
+ if (e.task.issue === null)
4075
+ continue;
4076
+ if (e.facts.stateReason === "not_planned")
4077
+ continue;
4003
4078
  if (e.facts.issueState !== "closed" || e.facts.prState !== "merged")
4004
4079
  continue;
4005
- const key = `${e.trancheSlug}/${e.task.id}`;
4006
- const hasProvenance = hasProvenanceByKey.get(key);
4080
+ const hasProvenance = hasProvenanceByKey.get(provenanceKey(e.task.issue));
4007
4081
  if (hasProvenance === undefined)
4008
4082
  continue;
4009
4083
  if (!hasProvenance) {
@@ -4451,6 +4525,19 @@ function lifecycleFromIssues(issues) {
4451
4525
  return "planned";
4452
4526
  return issues.some((i) => i.state === "OPEN") ? "active" : "complete";
4453
4527
  }
4528
+ function lifecycleFromCounts(open, total) {
4529
+ if (total === 0)
4530
+ return "planned";
4531
+ return open > 0 ? "active" : "complete";
4532
+ }
4533
+ function resolveLegacyFactsFromCounts(milestone, open, total) {
4534
+ if (milestone.state === "closed" && total > 0) {
4535
+ return { goal: milestone.description ?? "", lifecycle: lifecycleFromCounts(open, total) };
4536
+ }
4537
+ return factsFromLegacyMilestone(milestone);
4538
+ }
4539
+ var TRANCHE_LABEL_QUERY = "vinaya/tranche:";
4540
+ var ACTIVE_ISSUE_READ_CONCURRENCY = 4;
4454
4541
  function goalFromMilestones(milestones, slug) {
4455
4542
  for (const m of milestones) {
4456
4543
  const goal = intentGoalForSlug(m.description ?? "", slug);
@@ -4478,10 +4565,20 @@ function trancheSlugsFromLabels(labels) {
4478
4565
  }
4479
4566
  async function indexTrancheMilestonesAsync(owner, repo, options = {}) {
4480
4567
  const read = (fetch) => options.retryFailedReads ? retryOnce(fetch) : fetch();
4481
- const [milestones, labels] = await Promise.all([
4568
+ const [milestones, labels, counts] = await Promise.all([
4482
4569
  read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`)),
4483
- read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`))
4570
+ read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`)),
4571
+ read(() => ghLabelIssueCountsAsync(owner, repo, TRANCHE_LABEL_QUERY))
4484
4572
  ]);
4573
+ const countsByLabel = new Map(counts.map((c) => [c.name, c]));
4574
+ const uncounted = trancheSlugsFromLabels(labels).map((slug) => trancheLabel(slug)).filter((label) => !countsByLabel.has(label));
4575
+ if (uncounted.length > 0) {
4576
+ throw new Error(`the label Issue-count query returned no count for ${uncounted.join(", ")}`);
4577
+ }
4578
+ const lifecycleOf = (slug) => {
4579
+ const c = countsByLabel.get(trancheLabel(slug));
4580
+ return lifecycleFromCounts(c?.open ?? 0, c?.total ?? 0);
4581
+ };
4485
4582
  const active = [];
4486
4583
  const archived = [];
4487
4584
  const facts = new Map;
@@ -4489,33 +4586,21 @@ async function indexTrancheMilestonesAsync(owner, repo, options = {}) {
4489
4586
  const legacyMilestoneBySlug = new Map(milestones.filter((m) => legacySlugs.has(m.title)).map((m) => [m.title, m]));
4490
4587
  const newPathSlugs = trancheSlugsFromLabels(labels).filter((slug) => !legacySlugs.has(slug));
4491
4588
  const uniqueNewPathSlugs = [...new Set(newPathSlugs)];
4492
- const uniqueLegacySlugs = [...legacySlugs];
4493
- const [legacyIssuesBySlug, newPathIssuesBySlug] = await Promise.all([
4494
- Promise.all(uniqueLegacySlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))))),
4495
- Promise.all(uniqueNewPathSlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))))
4496
- ]);
4497
- const issuesBySlug = new Map;
4498
- uniqueLegacySlugs.forEach((slug, i) => {
4499
- issuesBySlug.set(slug, legacyIssuesBySlug[i] ?? []);
4500
- });
4501
- uniqueNewPathSlugs.forEach((slug, i) => {
4502
- issuesBySlug.set(slug, newPathIssuesBySlug[i] ?? []);
4503
- });
4504
- uniqueLegacySlugs.forEach((slug, i) => {
4589
+ for (const slug of legacySlugs) {
4505
4590
  const m = legacyMilestoneBySlug.get(slug);
4506
4591
  if (!m)
4507
- return;
4592
+ continue;
4508
4593
  const ref = { slug, goal: m.description ?? "" };
4509
- const f = resolveLegacyFacts(m, legacyIssuesBySlug[i] ?? []);
4594
+ const c = countsByLabel.get(trancheLabel(slug));
4595
+ const f = resolveLegacyFactsFromCounts(m, c?.open ?? 0, c?.total ?? 0);
4510
4596
  if (f.lifecycle === "complete")
4511
4597
  archived.push(ref);
4512
4598
  else if (f.lifecycle === "active")
4513
4599
  active.push(ref);
4514
4600
  facts.set(slug, f);
4515
- });
4516
- uniqueNewPathSlugs.forEach((slug, i) => {
4517
- const issues = newPathIssuesBySlug[i] ?? [];
4518
- const lifecycle = lifecycleFromIssues(issues);
4601
+ }
4602
+ for (const slug of uniqueNewPathSlugs) {
4603
+ const lifecycle = lifecycleOf(slug);
4519
4604
  const goal = goalFromMilestones(milestones, slug);
4520
4605
  const f = { goal, lifecycle };
4521
4606
  facts.set(slug, f);
@@ -4523,7 +4608,16 @@ async function indexTrancheMilestonesAsync(owner, repo, options = {}) {
4523
4608
  active.push({ slug, goal });
4524
4609
  else if (lifecycle === "complete")
4525
4610
  archived.push({ slug, goal });
4526
- });
4611
+ }
4612
+ const issuesBySlug = new Map;
4613
+ const activeSlugs = active.map((r) => r.slug);
4614
+ for (let i = 0;i < activeSlugs.length; i += ACTIVE_ISSUE_READ_CONCURRENCY) {
4615
+ const batch = activeSlugs.slice(i, i + ACTIVE_ISSUE_READ_CONCURRENCY);
4616
+ const lists = await Promise.all(batch.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))));
4617
+ batch.forEach((slug, j) => {
4618
+ issuesBySlug.set(slug, lists[j] ?? []);
4619
+ });
4620
+ }
4527
4621
  return { active, archived, facts, legacySlugs, issuesBySlug };
4528
4622
  }
4529
4623
  async function retryOnce(fetch) {