@attalabs/vinaya 0.24.0 → 0.25.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 (117) hide show
  1. package/README.md +25 -2
  2. package/aeg-root/contracts/developer-reviewer.md +3 -0
  3. package/aeg-root/contracts/planner-brief.md +13 -0
  4. package/aeg-root/enforcement.md +11 -7
  5. package/aeg-root/process.md +4 -4
  6. package/aeg-root/roles/brief-author.md +4 -2
  7. package/aeg-root/roles/developer.md +20 -14
  8. package/aeg-root/roles/planner.md +14 -0
  9. package/aeg-root/roles/principal.md +3 -0
  10. package/aeg-root/roles/reviewer.md +23 -7
  11. package/aeg-root/roles/security.md +21 -6
  12. package/aeg-root/skills/brief-authoring/SKILL.md +2 -2
  13. package/aeg-root/state-machine.md +2 -2
  14. package/aeg-root/templates/brief-template.md +20 -4
  15. package/aeg-root/templates/issue-rationale-template.md +34 -1
  16. package/aeg-root/templates/pr-report-template.md +5 -13
  17. package/dist/checks/bin/check-body-bare-digits.js +572 -127
  18. package/dist/checks/bin/check-branch-topology.js +629 -73
  19. package/dist/checks/bin/check-brief-shape.js +1675 -70
  20. package/dist/checks/bin/check-changeset-coverage.js +584 -127
  21. package/dist/checks/bin/check-closes-n.js +629 -73
  22. package/dist/checks/bin/check-coherence.js +696 -134
  23. package/dist/checks/bin/check-dead-branch-push.js +505 -66
  24. package/dist/checks/bin/check-dispatch-readiness.js +696 -134
  25. package/dist/checks/bin/check-doc-coverage-push.js +572 -127
  26. package/dist/checks/bin/check-doc-coverage.js +572 -127
  27. package/dist/checks/bin/check-doctrine-no-procedures.js +572 -127
  28. package/dist/checks/bin/check-doctrine-portability.js +572 -127
  29. package/dist/checks/bin/check-evidence-fresh.js +572 -127
  30. package/dist/checks/bin/check-exec-bits.js +572 -127
  31. package/dist/checks/bin/check-first-push-dispatch.js +696 -134
  32. package/dist/checks/bin/check-issue-assignment.js +629 -73
  33. package/dist/checks/bin/check-main-branch-refusal.js +505 -66
  34. package/dist/checks/bin/check-no-disk-state.js +505 -66
  35. package/dist/checks/bin/check-pr-report-density.js +505 -66
  36. package/dist/checks/bin/check-quoted-command.js +572 -127
  37. package/dist/checks/bin/check-reader-resolvable-prose.js +610 -133
  38. package/dist/checks/bin/check-registry-gates.js +517 -69
  39. package/dist/checks/bin/check-retired-vocabulary.js +572 -127
  40. package/dist/checks/bin/check-review-gate.js +646 -130
  41. package/dist/checks/bin/check-single-plan-pr.js +505 -66
  42. package/dist/checks/bin/check-test-plan.js +505 -66
  43. package/dist/checks/bin/check-token-collection-wired.js +505 -66
  44. package/dist/checks/bin/check-token-report.js +505 -66
  45. package/dist/checks/bin/check-workspace-escape.js +582 -129
  46. package/dist/index.js +7740 -4283
  47. package/package.json +2 -2
  48. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +2 -2
  49. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +26 -1
  50. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  51. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  52. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  53. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  54. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  55. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  56. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  57. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  58. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  59. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  60. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  61. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  62. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  63. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  64. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  65. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  66. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  70. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +2 -2
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0053k9k._.js +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0112h-k._.js +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0o771t1._.js +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1pndh3_._.js → [root-of-the-server]__0p8q38b._.js} +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0puovz5._.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1hs0dcu._.js +1 -1
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_03x_w6q._.js +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gvm3og._.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0lwxg63._.js +1 -1
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0wxycau._.js +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1n0cnq-._.js +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_1vo08dj._.js +2 -2
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_topbar_index_tsx_1h1gs1y._.js +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +3 -3
  107. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3m1kgax7j2vgs.js → 0bn8c8v5q429o.js} +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0doqwpd81sjzn.js → 0keji7wvbe1d1.js} +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1maoxbrl3pv5d.css +1 -0
  110. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1uogpj5w2n5ju.js → 3-6a3tinbdb-7.js} +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0zebsmmk1bvnb.js → 3_9xytdmiv1xi.js} +4 -4
  112. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  113. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3qc67qhcvbg0o.css +0 -1
  114. /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  115. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{QY2GhiI47-765D9DHGy1I → DMofV2-9FrHE7100GfrpI}/_buildManifest.js +0 -0
  116. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{QY2GhiI47-765D9DHGy1I → DMofV2-9FrHE7100GfrpI}/_clientMiddlewareManifest.js +0 -0
  117. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{QY2GhiI47-765D9DHGy1I → DMofV2-9FrHE7100GfrpI}/_ssgManifest.js +0 -0
@@ -1938,13 +1938,18 @@ function parseInlineFieldList(section) {
1938
1938
  }
1939
1939
  // ../../packages/aeg-core/src/verdict-extraction.ts
1940
1940
  var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
1941
- function firstThreeLines(comment) {
1941
+ var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
1942
+ function firstFiveLines(comment) {
1942
1943
  return comment.split(`
1943
- `).slice(0, 3).join(`
1944
+ `).slice(0, 5).join(`
1944
1945
  `);
1945
1946
  }
1946
1947
  function extractHeadSha(comment) {
1947
- const m = firstThreeLines(comment).match(HEAD_SHA_PATTERN);
1948
+ const m = firstFiveLines(comment).match(HEAD_SHA_PATTERN);
1949
+ return m ? m[1].toLowerCase() : null;
1950
+ }
1951
+ function extractObjectivesVersion(comment) {
1952
+ const m = firstFiveLines(comment).match(OBJECTIVES_VERSION_PATTERN);
1948
1953
  return m ? m[1].toLowerCase() : null;
1949
1954
  }
1950
1955
  function extractVerdict(comments, valuePattern, missingLabel) {
@@ -1953,21 +1958,24 @@ function extractVerdict(comments, valuePattern, missingLabel) {
1953
1958
  return {
1954
1959
  value: `no ${missingLabel} pass was run before merge — DANGLING, see below`,
1955
1960
  headSha: null,
1961
+ objectivesVersion: null,
1956
1962
  danglingNote: `no ${missingLabel} verdict comment found on this PR`
1957
1963
  };
1958
1964
  }
1959
1965
  const latest = candidates[candidates.length - 1];
1960
- const m = firstThreeLines(latest).match(valuePattern);
1966
+ const m = firstFiveLines(latest).match(valuePattern);
1961
1967
  if (!m) {
1962
1968
  return {
1963
- value: `the most recent ${missingLabel} comment's VERDICT line is not within its first three lines — DANGLING, see below`,
1969
+ value: `the most recent ${missingLabel} comment's VERDICT line is not within its first five lines — DANGLING, see below`,
1964
1970
  headSha: null,
1965
- danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-three-line read window`
1971
+ objectivesVersion: null,
1972
+ danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
1966
1973
  };
1967
1974
  }
1968
1975
  return {
1969
1976
  value: m[1].toUpperCase().replace(/[_-]/g, " "),
1970
1977
  headSha: extractHeadSha(latest),
1978
+ objectivesVersion: extractObjectivesVersion(latest),
1971
1979
  danglingNote: null
1972
1980
  };
1973
1981
  }
@@ -2324,8 +2332,105 @@ function overrideActive(opts) {
2324
2332
  return true;
2325
2333
  return false;
2326
2334
  }
2327
- // ../../packages/aeg-core/src/premise-check.ts
2335
+ // ../../packages/aeg-core/src/objectives.ts
2328
2336
  import { createHash as createHash2 } from "node:crypto";
2337
+ var HEADING_RE = /^##[ \t]*Objectives[ \t]*$/im;
2338
+ var NEXT_HEADING_RE = /^##[ \t]/m;
2339
+ var OBJECTIVE_LINE_RE = /^O(\d+)\.[ \t]*(.*)$/;
2340
+ function hasBacktickedPath(text) {
2341
+ let i = 0;
2342
+ while (i < text.length) {
2343
+ const start = text.indexOf("`", i);
2344
+ if (start === -1)
2345
+ return false;
2346
+ const end = text.indexOf("`", start + 1);
2347
+ if (end === -1)
2348
+ return false;
2349
+ if (text.slice(start + 1, end).includes("/"))
2350
+ return true;
2351
+ i = end + 1;
2352
+ }
2353
+ return false;
2354
+ }
2355
+ var MIN_WORDS_OUTSIDE_BACKTICKS = 3;
2356
+ function stripObjectiveBackticks(text) {
2357
+ return text.replace(/`[^`\n]*`/g, " ");
2358
+ }
2359
+ function wordCount(text) {
2360
+ return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
2361
+ }
2362
+ function objectivesSectionText(body) {
2363
+ const heading = HEADING_RE.exec(body);
2364
+ if (!heading)
2365
+ return null;
2366
+ const afterHeading = body.slice(heading.index + heading[0].length);
2367
+ const next = NEXT_HEADING_RE.exec(afterHeading);
2368
+ return next ? afterHeading.slice(0, next.index) : afterHeading;
2369
+ }
2370
+ function hasObjectivesHeading(body) {
2371
+ return HEADING_RE.test(body);
2372
+ }
2373
+ function objectivesOf(body) {
2374
+ const section = objectivesSectionText(body);
2375
+ if (section === null) {
2376
+ return { ok: false, errors: ["no `## Objectives` heading found in the body."] };
2377
+ }
2378
+ const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
2379
+ if (lines.length === 0) {
2380
+ return { ok: false, errors: ["the `## Objectives` section has no `O<n>.` lines."] };
2381
+ }
2382
+ const objectives = [];
2383
+ const errors = [];
2384
+ for (const line of lines) {
2385
+ const m = OBJECTIVE_LINE_RE.exec(line);
2386
+ if (!m) {
2387
+ errors.push(`"${line}" is not a well-formed objective line — expected \`O<n>. <sentence>\`, e.g. \`O1. …\`.`);
2388
+ continue;
2389
+ }
2390
+ const n = m[1];
2391
+ const text = m[2].trim();
2392
+ if (text.length === 0) {
2393
+ errors.push(`O${n} has no sentence — every objective is one observable sentence.`);
2394
+ continue;
2395
+ }
2396
+ if (hasBacktickedPath(text) && wordCount(stripObjectiveBackticks(text)) < MIN_WORDS_OUTSIDE_BACKTICKS) {
2397
+ errors.push(`O${n} is little more than a file path — an objective states an observable outcome, never a bare path (the Brief Author maps it to files).`);
2398
+ continue;
2399
+ }
2400
+ objectives.push({ id: `O${n}`, text });
2401
+ }
2402
+ for (let i = 0;i < objectives.length; i++) {
2403
+ const expected = i + 1;
2404
+ const actual = Number.parseInt(objectives[i].id.slice(1), 10);
2405
+ if (actual !== expected) {
2406
+ errors.push(`numbering is not contiguous from O1 — expected O${expected}, found ${objectives[i].id}.`);
2407
+ break;
2408
+ }
2409
+ }
2410
+ if (errors.length > 0)
2411
+ return { ok: false, errors };
2412
+ return { ok: true, objectives };
2413
+ }
2414
+ function normalizeText(text) {
2415
+ return text.trim().replace(/\s+/g, " ");
2416
+ }
2417
+ function objectivesVersion(objectives) {
2418
+ const normalized = objectives.map((o) => `${o.id} ${normalizeText(o.text)}`).join(`
2419
+ `);
2420
+ return createHash2("sha256").update(normalized).digest("hex");
2421
+ }
2422
+ function isIssueNotFoundError(err) {
2423
+ const stderr = err?.stderr;
2424
+ const haystack = [
2425
+ err?.message ?? "",
2426
+ typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
2427
+ ].join(`
2428
+ `);
2429
+ return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
2430
+ }
2431
+
2432
+ // ../../packages/aeg-core/src/premise-check.ts
2433
+ import { createHash as createHash3 } from "node:crypto";
2329
2434
  var ASSERTION_KINDS = new Set(["contains", "absent", "sha256"]);
2330
2435
  function isPremiseHeader(line) {
2331
2436
  const stripped = line.replace(/[*#]/g, "").trim();
@@ -2396,7 +2501,7 @@ function checkPremises(assertions, fileReader) {
2396
2501
  } else if (a.kind === "absent" && content.includes(a.value)) {
2397
2502
  failures.push(`premise-check: ${a.path} now contains "${a.value}", but the brief pinned it absent — the premise has moved; re-dig before proceeding.`);
2398
2503
  } else if (a.kind === "sha256") {
2399
- const actual = createHash2("sha256").update(content).digest("hex");
2504
+ const actual = createHash3("sha256").update(content).digest("hex");
2400
2505
  if (actual !== a.value.toLowerCase()) {
2401
2506
  failures.push(`premise-check: ${a.path} sha256 mismatch (brief pinned ${a.value}, file is now ${actual}) — the file changed since this brief was authored; re-dig before proceeding.`);
2402
2507
  }
@@ -2757,8 +2862,55 @@ function checkDefeatCases(prBody) {
2757
2862
  ]
2758
2863
  };
2759
2864
  }
2865
+ var PART_CITATION_RE = /Part\s+\d+\s*\(([^)]*)\)/gi;
2866
+ var OBJECTIVE_REF_RE = /O(\d+)/g;
2867
+ function citedObjectiveIds(section6) {
2868
+ const ids = new Set;
2869
+ for (const m of section6.matchAll(PART_CITATION_RE)) {
2870
+ for (const r of m[1].matchAll(OBJECTIVE_REF_RE))
2871
+ ids.add(Number.parseInt(r[1], 10));
2872
+ }
2873
+ return ids;
2874
+ }
2875
+ function checkObjectivesCopy(prBody, issueObjectives) {
2876
+ const parsed = objectivesOf(prBody);
2877
+ if (!parsed.ok) {
2878
+ return { status: "fail", errors: parsed.errors.map((e) => `brief-validation objectives copy: ${e}`) };
2879
+ }
2880
+ if (objectivesVersion(parsed.objectives) !== objectivesVersion(issueObjectives)) {
2881
+ return {
2882
+ status: "fail",
2883
+ errors: [
2884
+ "brief-validation objectives copy: the brief's `## Objectives` section does not match the Issue's — copy the Issue's `## Objectives` section (aeg-root/roles/developer.md)."
2885
+ ]
2886
+ };
2887
+ }
2888
+ return { status: "pass", errors: [] };
2889
+ }
2890
+ function checkObjectivesCoverage(prBody) {
2891
+ const parsed = objectivesOf(prBody);
2892
+ if (!parsed.ok) {
2893
+ return { status: "fail", errors: parsed.errors.map((e) => `brief-validation objectives coverage: ${e}`) };
2894
+ }
2895
+ const declaredIds = new Set(parsed.objectives.map((o) => Number.parseInt(o.id.slice(1), 10)));
2896
+ const section6 = extractNumberedSection(prBody, 6) ?? "";
2897
+ const cited = citedObjectiveIds(section6);
2898
+ const maxDeclared = Math.max(...declaredIds, 0);
2899
+ const errors = [];
2900
+ for (const id of declaredIds) {
2901
+ if (!cited.has(id)) {
2902
+ errors.push(`brief-validation objectives coverage: O${id} is not cited by any Part in §6 — every objective must be cited by at least one Part.`);
2903
+ }
2904
+ }
2905
+ for (const id of cited) {
2906
+ if (!declaredIds.has(id)) {
2907
+ errors.push(`brief-validation objectives coverage: a Part in §6 cites O${id}, but the Objectives section ends at O${maxDeclared}.`);
2908
+ }
2909
+ }
2910
+ return errors.length === 0 ? { status: "pass", errors: [] } : { status: "fail", errors };
2911
+ }
2760
2912
  function checkBriefSections(prBody, readTier, options = {}) {
2761
- const { requireClosesN = true, consumersOf = () => [] } = options;
2913
+ const { requireClosesN = true, consumersOf = () => [], issueObjectives } = options;
2762
2914
  const results = [
2763
2915
  checkTierField(prBody, readTier),
2764
2916
  checkTestPlan(prBody),
@@ -2776,6 +2928,7 @@ function checkBriefSections(prBody, readTier, options = {}) {
2776
2928
  checkCommandsCarryOutput(prBody),
2777
2929
  checkConsumerTests(prBody, consumersOf),
2778
2930
  checkDefeatCases(prBody),
2931
+ ...issueObjectives !== undefined ? [checkObjectivesCopy(prBody, issueObjectives), checkObjectivesCoverage(prBody)] : [],
2779
2932
  ...requireClosesN ? [checkClosesN(prBody)] : []
2780
2933
  ];
2781
2934
  return { errors: results.flatMap((r) => r.errors) };
@@ -2974,14 +3127,14 @@ function checkSectionDensity(prBody, heading) {
2974
3127
  ]
2975
3128
  };
2976
3129
  }
2977
- function checkSummaryDensity(prBody) {
2978
- return checkSectionDensity(prBody, "Summary");
3130
+ function checkDecisionsDensity(prBody) {
3131
+ return checkSectionDensity(prBody, "Decisions");
2979
3132
  }
2980
3133
  function checkScopeDensity(prBody) {
2981
3134
  return checkSectionDensity(prBody, "Scope");
2982
3135
  }
2983
3136
  function checkPrReportDensity(prBody) {
2984
- const results = [checkSummaryDensity(prBody), checkScopeDensity(prBody)];
3137
+ const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
2985
3138
  return { errors: results.flatMap((r) => r.errors) };
2986
3139
  }
2987
3140
  // ../../packages/aeg-core/src/issue-validation.ts
@@ -3013,6 +3166,15 @@ function checkIssueRationale(body) {
3013
3166
  }
3014
3167
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3015
3168
  }
3169
+ var OBJECTIVES_SINCE_ISSUE = 404;
3170
+ function checkIssueObjectives(body, issueNumber) {
3171
+ if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE)
3172
+ return { status: "pass", errors: [] };
3173
+ const result = objectivesOf(body);
3174
+ if (result.ok)
3175
+ return { status: "pass", errors: [] };
3176
+ return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
3177
+ }
3016
3178
  function isTaskIssueLabelSet(labels) {
3017
3179
  return hasLabel("tranche", labels);
3018
3180
  }
@@ -3274,7 +3436,8 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3274
3436
  continue;
3275
3437
  const errors = [
3276
3438
  ...checkIssueRationale(issue.body).errors,
3277
- ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors
3439
+ ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
3440
+ ...checkIssueObjectives(issue.body, issue.number).errors
3278
3441
  ];
3279
3442
  if (errors.length === 0)
3280
3443
  continue;
@@ -3389,6 +3552,27 @@ function checkClosesN2(branch, prBody, trancheFiles, taskIssueRefs) {
3389
3552
  }
3390
3553
  return { ok: true, expectedIssue };
3391
3554
  }
3555
+ // ../../packages/aeg-core/src/archive-task.ts
3556
+ function closesRefs(text) {
3557
+ return [...new Set([...text.matchAll(/Closes #(\d+)/gi)].map((m) => Number(m[1])))];
3558
+ }
3559
+ function extractIssue(body) {
3560
+ const stripped = stripCode(body);
3561
+ const bodyNums = closesRefs(stripped);
3562
+ const anchored = anchoredRegion(stripped, "CLOSES");
3563
+ if (anchored !== null) {
3564
+ const anchorNums = closesRefs(anchored);
3565
+ if (anchorNums.length === 0)
3566
+ return { issue: null, extraIssues: bodyNums, outsideHeader: false };
3567
+ const issue2 = anchorNums[0];
3568
+ return { issue: issue2, extraIssues: bodyNums.filter((n) => n !== issue2), outsideHeader: false };
3569
+ }
3570
+ const headerNums = closesRefs(headerRegion(stripped));
3571
+ if (bodyNums.length === 0)
3572
+ return { issue: null, extraIssues: [], outsideHeader: false };
3573
+ const issue = headerNums.length > 0 ? headerNums[0] : bodyNums[0];
3574
+ return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: headerNums.length === 0 };
3575
+ }
3392
3576
  // ../../packages/aeg-core/src/review-gate.ts
3393
3577
  function isBoundToHead(extraction, headSha) {
3394
3578
  if (!extraction.headSha)
@@ -3407,6 +3591,11 @@ function isBoundByPatchIdentity(extraction, headSha, patchIdOf) {
3407
3591
  function isBoundToPatch(extraction, headSha, patchIdOf) {
3408
3592
  return isBoundToHead(extraction, headSha) || isBoundByPatchIdentity(extraction, headSha, patchIdOf);
3409
3593
  }
3594
+ function isBoundToObjectives(extraction, currentVersion) {
3595
+ if (currentVersion === null)
3596
+ return true;
3597
+ return extraction.objectivesVersion === currentVersion;
3598
+ }
3410
3599
  function checkReviewGate(input) {
3411
3600
  const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
3412
3601
  const waived = isWaiverLabelActorVerified({
@@ -3433,7 +3622,9 @@ function checkReviewGate(input) {
3433
3622
  const securityClean = security.value === "PASS";
3434
3623
  const codeReviewBound = isBoundToPatch(codeReview, input.headSha, input.patchIdOf);
3435
3624
  const securityBound = isBoundToPatch(security, input.headSha, input.patchIdOf);
3436
- if (codeReviewClean && codeReviewBound && securityClean && securityBound && mechanicalChecksClean) {
3625
+ const codeReviewObjectivesBound = isBoundToObjectives(codeReview, input.objectivesVersion);
3626
+ const securityObjectivesBound = isBoundToObjectives(security, input.objectivesVersion);
3627
+ if (codeReviewClean && codeReviewBound && codeReviewObjectivesBound && securityClean && securityBound && securityObjectivesBound && mechanicalChecksClean) {
3437
3628
  return {
3438
3629
  verdict: "pass",
3439
3630
  reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}, and every reported mechanical check is green.`,
@@ -3445,11 +3636,15 @@ function checkReviewGate(input) {
3445
3636
  problems.push(`code-reviewer verdict is not a clean APPROVE (found: ${codeReview.value})`);
3446
3637
  } else if (!codeReviewBound) {
3447
3638
  problems.push(`the newest code-review verdict covers ${codeReview.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
3639
+ } else if (!codeReviewObjectivesBound) {
3640
+ problems.push(`the newest code-review verdict was cast against objectives version ${codeReview.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
3448
3641
  }
3449
3642
  if (!securityClean) {
3450
3643
  problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
3451
3644
  } else if (!securityBound) {
3452
3645
  problems.push(`the newest security-review verdict covers ${security.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
3646
+ } else if (!securityObjectivesBound) {
3647
+ problems.push(`the newest security-review verdict was cast against objectives version ${security.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
3453
3648
  }
3454
3649
  if (!mechanicalChecksClean) {
3455
3650
  problems.push(reportedMechanicalChecks.length === 0 ? "no mechanical checks have reported for this head yet" : `mechanical check(s) not green: ${reportedMechanicalChecks.filter((c) => c.bucket !== "pass").map((c) => `${c.name} (${c.bucket})`).join(", ")}`);
@@ -3685,55 +3880,20 @@ function checkG6(rows, registeredCheckNames) {
3685
3880
  }
3686
3881
  return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
3687
3882
  }
3688
- // ../../packages/aeg-core/src/dead-branch-push-guard.ts
3689
- function checkDeadBranchPush(input) {
3690
- const { branch, prState, prNumber } = input;
3691
- if (prState === "MERGED") {
3692
- return {
3693
- verdict: "refuse",
3694
- reason: `Branch \`${branch}\` already has a MERGED PR (#${prNumber}) — this branch's work is done. Push a new task branch instead of pushing onto an already-resolved one.`
3695
- };
3696
- }
3697
- if (prState === "CLOSED") {
3698
- return {
3699
- verdict: "refuse",
3700
- reason: `Branch \`${branch}\` has a CLOSED PR (#${prNumber}) that was never merged — pushing here would resurrect abandoned/rejected work. Open a new task branch instead.`
3701
- };
3702
- }
3703
- if (prState === "OPEN") {
3704
- return {
3705
- verdict: "allow",
3706
- reason: `Branch \`${branch}\` has an OPEN PR (#${prNumber}) — pushing more commits to it is normal.`
3707
- };
3708
- }
3709
- if (prState === "NONE") {
3710
- return {
3711
- verdict: "allow",
3712
- reason: `Branch \`${branch}\` has no PR yet — a brand-new task branch legitimately has none.`
3713
- };
3714
- }
3715
- return {
3716
- verdict: "allow",
3717
- reason: `Could not determine \`${branch}\`'s PR state (forge unreachable) — failing open rather than blocking the push on a transient issue.`
3718
- };
3719
- }
3720
- // ../../packages/aeg-core/src/baseline-capture.ts
3721
- function captureBaseline(counts, capturedAt) {
3722
- return counts.map((c) => ({ tool: c.tool, findingCount: c.findingCount, capturedAt }));
3883
+ // ../../packages/aeg-core/src/reader-resolvable-prose.ts
3884
+ var PRODUCT_SLUG_SCOPE = [
3885
+ "apps/cli/src",
3886
+ ".github/workflows",
3887
+ ".vinaya",
3888
+ "apps/cli/README.md",
3889
+ "packages/sources/README.md"
3890
+ ];
3891
+ function isUnderOrEqual(path, prefix) {
3892
+ return path === prefix || path.startsWith(`${prefix}/`);
3723
3893
  }
3724
- function compareToBaseline(current, baseline) {
3725
- const perTool = current.map((c) => {
3726
- const baselineEntry = baseline.find((b) => b.tool === c.tool);
3727
- const baselineCount = baselineEntry ? baselineEntry.findingCount : c.findingCount;
3728
- return { tool: c.tool, baseline: baselineCount, current: c.findingCount, delta: c.findingCount - baselineCount };
3729
- });
3730
- return {
3731
- withinBudget: perTool.every((t) => t.delta <= 0),
3732
- delta: perTool.reduce((sum, t) => sum + t.delta, 0),
3733
- perTool
3734
- };
3894
+ function isProductScopeFile(path) {
3895
+ return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
3735
3896
  }
3736
- // ../../packages/aeg-core/src/reader-resolvable-prose.ts
3737
3897
  var SHIPS_PREFIX = "aeg-root/";
3738
3898
  function shipsArchivePrefix(shipsPrefix) {
3739
3899
  return `${shipsPrefix}tranches/completed/`;
@@ -3753,6 +3913,8 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
3753
3913
  }
3754
3914
  if (isSpecFile2(path) || isClaudeMdFile(path))
3755
3915
  return "internal";
3916
+ if (isProductScopeFile(path))
3917
+ return "product";
3756
3918
  return null;
3757
3919
  }
3758
3920
  var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
@@ -3765,6 +3927,9 @@ function stripNonProse(path, content) {
3765
3927
  }
3766
3928
  return content;
3767
3929
  }
3930
+ function stripNonProseForProduct(path, content) {
3931
+ return path.endsWith(".md") ? stripNonProse(path, content) : content;
3932
+ }
3768
3933
  function lineAt(content, index) {
3769
3934
  let line = 1;
3770
3935
  for (let i = 0;i < index; i++) {
@@ -3789,12 +3954,19 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3789
3954
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
3790
3955
  ...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
3791
3956
  ];
3957
+ const productPatterns = [
3958
+ { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
3959
+ ];
3792
3960
  for (const file of files) {
3793
3961
  const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3794
- if (!cls || !SWEPT_CLASSES.has(cls))
3962
+ if (!cls || cls === "internal")
3795
3963
  continue;
3796
- const scrubbed = stripNonProse(file.path, file.content);
3797
- for (const { pattern, what, group } of patterns) {
3964
+ if (cls !== "product" && !SWEPT_CLASSES.has(cls))
3965
+ continue;
3966
+ const blocking = cls === "product";
3967
+ const scrubbed = blocking ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
3968
+ const patternsToRun = blocking ? productPatterns : patterns;
3969
+ for (const { pattern, what, group } of patternsToRun) {
3798
3970
  pattern.lastIndex = 0;
3799
3971
  let match = pattern.exec(scrubbed);
3800
3972
  while (match !== null) {
@@ -3802,7 +3974,8 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3802
3974
  findings.push({
3803
3975
  file: file.path,
3804
3976
  line: lineAt(scrubbed, match.index),
3805
- message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`
3977
+ message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
3978
+ blocking
3806
3979
  });
3807
3980
  match = pattern.exec(scrubbed);
3808
3981
  }
@@ -3852,7 +4025,8 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
3852
4025
  findings.push({
3853
4026
  file: file.path,
3854
4027
  line,
3855
- message: `uses coined term "${term}" without defining it inline or linking the glossary`
4028
+ message: `uses coined term "${term}" without defining it inline or linking the glossary`,
4029
+ blocking: false
3856
4030
  });
3857
4031
  }
3858
4032
  }
@@ -3875,6 +4049,7 @@ function parseGlossaryTerms(glossaryContent) {
3875
4049
  }
3876
4050
  return terms;
3877
4051
  }
4052
+
3878
4053
  // ../../packages/aeg-core/src/quoted-command.ts
3879
4054
  var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3880
4055
  var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
@@ -3969,6 +4144,54 @@ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3969
4144
  }
3970
4145
  return findings;
3971
4146
  }
4147
+ // ../../packages/aeg-core/src/dead-branch-push-guard.ts
4148
+ function checkDeadBranchPush(input) {
4149
+ const { branch, prState, prNumber } = input;
4150
+ if (prState === "MERGED") {
4151
+ return {
4152
+ verdict: "refuse",
4153
+ reason: `Branch \`${branch}\` already has a MERGED PR (#${prNumber}) — this branch's work is done. Push a new task branch instead of pushing onto an already-resolved one.`
4154
+ };
4155
+ }
4156
+ if (prState === "CLOSED") {
4157
+ return {
4158
+ verdict: "refuse",
4159
+ reason: `Branch \`${branch}\` has a CLOSED PR (#${prNumber}) that was never merged — pushing here would resurrect abandoned/rejected work. Open a new task branch instead.`
4160
+ };
4161
+ }
4162
+ if (prState === "OPEN") {
4163
+ return {
4164
+ verdict: "allow",
4165
+ reason: `Branch \`${branch}\` has an OPEN PR (#${prNumber}) — pushing more commits to it is normal.`
4166
+ };
4167
+ }
4168
+ if (prState === "NONE") {
4169
+ return {
4170
+ verdict: "allow",
4171
+ reason: `Branch \`${branch}\` has no PR yet — a brand-new task branch legitimately has none.`
4172
+ };
4173
+ }
4174
+ return {
4175
+ verdict: "allow",
4176
+ reason: `Could not determine \`${branch}\`'s PR state (forge unreachable) — failing open rather than blocking the push on a transient issue.`
4177
+ };
4178
+ }
4179
+ // ../../packages/aeg-core/src/baseline-capture.ts
4180
+ function captureBaseline(counts, capturedAt) {
4181
+ return counts.map((c) => ({ tool: c.tool, findingCount: c.findingCount, capturedAt }));
4182
+ }
4183
+ function compareToBaseline(current, baseline) {
4184
+ const perTool = current.map((c) => {
4185
+ const baselineEntry = baseline.find((b) => b.tool === c.tool);
4186
+ const baselineCount = baselineEntry ? baselineEntry.findingCount : c.findingCount;
4187
+ return { tool: c.tool, baseline: baselineCount, current: c.findingCount, delta: c.findingCount - baselineCount };
4188
+ });
4189
+ return {
4190
+ withinBudget: perTool.every((t) => t.delta <= 0),
4191
+ delta: perTool.reduce((sum, t) => sum + t.delta, 0),
4192
+ perTool
4193
+ };
4194
+ }
3972
4195
  // ../../packages/aeg-core/src/retired-vocabulary.ts
3973
4196
  var RETIRED_PATTERNS = [
3974
4197
  String.raw`\bD-[0-9]{3}\b`,
@@ -4438,6 +4661,222 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
4438
4661
  }
4439
4662
  return findings;
4440
4663
  }
4664
+ // ../../packages/aeg-core/src/log/schema.ts
4665
+ import { z } from "zod";
4666
+ var ROLE_VALUES = [
4667
+ "planner",
4668
+ "brief-author",
4669
+ "developer",
4670
+ "code-reviewer",
4671
+ "security",
4672
+ "principal",
4673
+ "archivist",
4674
+ "architect"
4675
+ ];
4676
+ var RoleSchema = z.enum(ROLE_VALUES);
4677
+ var HOST_VALUES = ["hook", "ci", "cli", "loop"];
4678
+ var HostSchema = z.enum(HOST_VALUES);
4679
+ var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
4680
+ var HeaderMetaSchema = z.object({
4681
+ schema: z.literal(1),
4682
+ ts: z.string(),
4683
+ run_id: z.string().regex(RUN_ID_PATTERN),
4684
+ seq: z.number().int().nonnegative(),
4685
+ repo: z.string().nullable(),
4686
+ vinaya: z.string(),
4687
+ doctrine: z.string(),
4688
+ host: HostSchema,
4689
+ machine: z.string()
4690
+ }).strict();
4691
+ var SubjectSchema = z.object({
4692
+ issue: z.number().int().nullable(),
4693
+ pr: z.number().int().optional(),
4694
+ sha: z.string().optional(),
4695
+ role: z.union([RoleSchema, z.literal("unattributed")]),
4696
+ round: z.number().int().optional(),
4697
+ objectives_version: z.string().optional()
4698
+ }).strict();
4699
+ var HeaderSchema = z.object({
4700
+ meta: HeaderMetaSchema,
4701
+ subject: SubjectSchema
4702
+ }).strict();
4703
+ var envelopeTail = {
4704
+ duration_ms: z.number().nonnegative().optional(),
4705
+ payload: z.object({}).strict()
4706
+ };
4707
+ var DispatchOutcomeSchema = z.discriminatedUnion("type", [
4708
+ z.object({ type: z.literal("pr_opened"), pr: z.number().int(), head: z.string() }).strict(),
4709
+ z.object({
4710
+ type: z.literal("round_pushed"),
4711
+ pr: z.number().int(),
4712
+ head: z.string(),
4713
+ comment_id: z.number().int()
4714
+ }).strict(),
4715
+ z.object({
4716
+ type: z.literal("verdict"),
4717
+ verdict: z.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
4718
+ head: z.string(),
4719
+ comment_id: z.number().int(),
4720
+ objectives: z.array(z.object({ id: z.string(), met: z.boolean() }).strict()),
4721
+ findings: z.array(z.object({ id: z.string(), severity: z.string(), state: z.string().optional() }).strict())
4722
+ }).strict(),
4723
+ z.object({
4724
+ type: z.literal("escalation"),
4725
+ class: z.enum(["authority", "strategy", "product"]),
4726
+ comment_id: z.number().int()
4727
+ }).strict(),
4728
+ z.object({ type: z.literal("brief"), comment_id: z.number().int(), hash: z.string() }).strict(),
4729
+ z.object({ type: z.literal("plan"), issues: z.array(z.number().int()) }).strict(),
4730
+ z.object({ type: z.literal("archive"), provenance_comment_id: z.number().int() }).strict()
4731
+ ]);
4732
+ var dispatchShared = {
4733
+ meta: HeaderMetaSchema,
4734
+ subject: SubjectSchema,
4735
+ kind: z.literal("dispatch"),
4736
+ ...envelopeTail,
4737
+ target_role: RoleSchema,
4738
+ model: z.string(),
4739
+ round: z.number().int().optional(),
4740
+ effect_id: z.string()
4741
+ };
4742
+ var DispatchEventSchema = z.discriminatedUnion("event", [
4743
+ z.object({ ...dispatchShared, event: z.literal("dispatched"), prompt_hash: z.string() }).strict(),
4744
+ z.object({
4745
+ ...dispatchShared,
4746
+ event: z.literal("outcome_received"),
4747
+ outcome: DispatchOutcomeSchema,
4748
+ usage: z.object({ input: z.number().nonnegative(), output: z.number().nonnegative() }).strict().nullable()
4749
+ }).strict(),
4750
+ z.object({
4751
+ ...dispatchShared,
4752
+ event: z.literal("dispatch_failed"),
4753
+ reason: z.enum(["timeout", "crash", "refused", "unattributed_write"])
4754
+ }).strict()
4755
+ ]);
4756
+ var loopShared = {
4757
+ meta: HeaderMetaSchema,
4758
+ subject: SubjectSchema,
4759
+ kind: z.literal("dev_review_loop"),
4760
+ ...envelopeTail,
4761
+ loop_id: z.string()
4762
+ };
4763
+ var DevReviewLoopEventSchema = z.discriminatedUnion("event", [
4764
+ z.object({
4765
+ ...loopShared,
4766
+ event: z.literal("loop_started"),
4767
+ task: z.number().int(),
4768
+ policy: z.object({
4769
+ max_rounds: z.number().int().nonnegative(),
4770
+ reviewers: z.array(RoleSchema),
4771
+ models: z.record(RoleSchema, z.string())
4772
+ }).strict()
4773
+ }).strict(),
4774
+ z.object({ ...loopShared, event: z.literal("round_started"), round: z.number().int(), base_head: z.string() }).strict(),
4775
+ z.object({
4776
+ ...loopShared,
4777
+ event: z.literal("gate_result_read"),
4778
+ round: z.number().int(),
4779
+ head: z.string(),
4780
+ green: z.boolean()
4781
+ }).strict(),
4782
+ z.object({
4783
+ ...loopShared,
4784
+ event: z.literal("verdicts_read"),
4785
+ round: z.number().int(),
4786
+ head: z.string(),
4787
+ all_approve: z.boolean(),
4788
+ blockers: z.number().int().nonnegative()
4789
+ }).strict(),
4790
+ z.object({
4791
+ ...loopShared,
4792
+ event: z.literal("findings_compared"),
4793
+ round: z.number().int(),
4794
+ open: z.array(z.string()),
4795
+ resolved: z.array(z.string()),
4796
+ new: z.array(z.string()),
4797
+ recurring: z.array(z.string())
4798
+ }).strict(),
4799
+ z.object({
4800
+ ...loopShared,
4801
+ event: z.literal("stop_condition_met"),
4802
+ round: z.number().int(),
4803
+ condition: z.enum([
4804
+ "green",
4805
+ "max_rounds",
4806
+ "no_progress",
4807
+ "escalated",
4808
+ "principal_stop",
4809
+ "confidence",
4810
+ "reappearance"
4811
+ ])
4812
+ }).strict(),
4813
+ z.object({
4814
+ ...loopShared,
4815
+ event: z.literal("paused"),
4816
+ round: z.number().int(),
4817
+ reason: z.enum(["escalation", "principal_item", "refreeze_needed"])
4818
+ }).strict(),
4819
+ z.object({
4820
+ ...loopShared,
4821
+ event: z.literal("resumed"),
4822
+ round: z.number().int(),
4823
+ by: z.literal("principal")
4824
+ }).strict(),
4825
+ z.object({
4826
+ ...loopShared,
4827
+ event: z.literal("round_ended"),
4828
+ round: z.number().int(),
4829
+ base_head: z.string(),
4830
+ head: z.string(),
4831
+ files_changed: z.number().int().nonnegative(),
4832
+ insertions: z.number().int().nonnegative(),
4833
+ deletions: z.number().int().nonnegative(),
4834
+ wall_ms: z.number().nonnegative(),
4835
+ outcome: z.enum(["green", "changes_requested", "escalated"])
4836
+ }).strict(),
4837
+ z.object({
4838
+ ...loopShared,
4839
+ event: z.literal("journal_finalized"),
4840
+ rounds: z.number().int().nonnegative(),
4841
+ total_wall_ms: z.number().nonnegative(),
4842
+ time_to_green_ms: z.number().nonnegative().nullable(),
4843
+ files_changed_total: z.number().int().nonnegative(),
4844
+ final_head: z.string(),
4845
+ result: z.enum(["merged_ready", "stopped"])
4846
+ }).strict()
4847
+ ]);
4848
+ var ForgeOpSchema = z.enum([
4849
+ "pr.create",
4850
+ "pr.comment",
4851
+ "pr.body.replace",
4852
+ "pr.refreeze",
4853
+ "issue.create",
4854
+ "issue.edit",
4855
+ "issue.comment",
4856
+ "milestone.create",
4857
+ "milestone.edit",
4858
+ "milestone.close",
4859
+ "label.add",
4860
+ "label.remove"
4861
+ ]);
4862
+ var ForgeWriteTargetSchema = z.object({
4863
+ issue: z.number().int().optional(),
4864
+ pr: z.number().int().optional()
4865
+ }).strict();
4866
+ var forgeWriteShared = {
4867
+ meta: HeaderMetaSchema,
4868
+ subject: SubjectSchema,
4869
+ kind: z.literal("forge_write"),
4870
+ ...envelopeTail,
4871
+ op: ForgeOpSchema,
4872
+ target: ForgeWriteTargetSchema
4873
+ };
4874
+ var ForgeWriteEventSchema = z.discriminatedUnion("event", [
4875
+ z.object({ ...forgeWriteShared, event: z.literal("validated") }).strict(),
4876
+ z.object({ ...forgeWriteShared, event: z.literal("refused"), reason: z.string() }).strict(),
4877
+ z.object({ ...forgeWriteShared, event: z.literal("written"), comment_ids: z.array(z.string()) }).strict()
4878
+ ]);
4879
+ var LogEventSchema = z.union([DispatchEventSchema, DevReviewLoopEventSchema, ForgeWriteEventSchema]);
4441
4880
  // ../../packages/sources/src/commands.ts
4442
4881
  var COMMANDS = [
4443
4882
  {
@@ -4551,11 +4990,24 @@ var COMMANDS = [
4551
4990
  { flag: "--out <path>", description: "Write the rendered brief to a file instead of stdout" }
4552
4991
  ],
4553
4992
  details: [
4554
- "Reads the task Issue (`vinaya/tranche:<tranche>`-labeled, id `<n>`) and the tree, and fills every section a program can derive: the header `Project:`/`Tier:`/`Closes #N`, the Step 0 worktree line, the dispatch-gate status as the pre-flight line, §4's file list (with consumer packages and a `sha256` premise pin per file), §7 from the `.vinaya/doc-owners` derivation, and every remaining section from the Issue's eight-field Planner rationale. Refuses — naming the missing fact — when a derived section cannot be derived: no Issue, the dispatch gate not clear, or a `--surfaces` glob matching no tracked file.",
4993
+ "Reads the task Issue (`vinaya/tranche:<tranche>`-labeled, id `<n>`) and the tree, and fills every section a program can derive: the header `Project:`/`Tier:`/`Closes #N`, the Step 0 worktree line, the dispatch-gate status as the pre-flight line, §4's file list (with consumer packages and a `sha256` premise pin per file, and Out of surface from the Issue's own `## Surface` `out:` list), §6 from the Issue's `## Parts`, §7 from the `.vinaya/doc-owners` derivation, §9 from the Issue's `## Test plan`, §10 from the Issue's `## Stop conditions` plus the rationale's Stop-and-escalate field, and every remaining section from the Issue's eight-field Planner rationale. Refuses — naming the missing section — when it cannot be derived: no Issue, the dispatch gate not clear, a `--surfaces` glob matching no tracked file, or the Issue missing/malformed `## Surface`/`## Parts`/`## Test plan`/`## Stop conditions` — never a bracketed placeholder.",
4555
4994
  "Never writes under `aeg-root/` or to the Issue — a brief is pasted to the Developer, never committed. Reads `aeg-root/templates/brief-template.md` at run time for its one fixed sentence and the standing autonomy clause; every other byte is generated from the forge/tree facts."
4556
4995
  ],
4557
4996
  status: "shipped"
4558
4997
  },
4998
+ {
4999
+ name: "task dispatch",
5000
+ description: "Render, pin, and post the brief on the Issue as the frozen original; start the developer",
5001
+ flags: [
5002
+ { flag: "--agent <claude|codex|gemini>", description: "Start the developer through dispatchRole once posted" }
5003
+ ],
5004
+ details: [
5005
+ "Renders the brief from the Issue and the tree (the same assembly `brief render` uses) and posts it once as an Issue comment whose first line is `<!-- aeg:brief:v1 -->` and whose second line is `Brief hash: <sha256>` — the hash covers only the body below those two lines, so any reader recomputes it. Refuses outright, naming the existing comment's URL, when a `v1` comment already exists on the Issue — the brief is frozen by design, never overwritten or silently reissued.",
5006
+ "With `--agent`, starts the Developer through `dispatchRole` when `apps/cli/src/lib/dispatch.ts` exports it; otherwise prints the rendered brief and the manual dispatch instruction and exits `0` — a soft dependency, never a hard block.",
5007
+ "Principal-only, with or without `--agent`: refuses before any render, forge read, or post when the authenticated `gh` identity is not on the Principal allowlist (or cannot be resolved at all) — dispatching is the `todo → in-flight` transition, not a general-purpose comment poster."
5008
+ ],
5009
+ status: "shipped"
5010
+ },
4559
5011
  {
4560
5012
  name: "pr create",
4561
5013
  description: "Open a pull request after full brief-schema validation",
@@ -4608,6 +5060,19 @@ var COMMANDS = [
4608
5060
  ],
4609
5061
  status: "shipped"
4610
5062
  },
5063
+ {
5064
+ name: "pr rule",
5065
+ description: "Post a Principal ruling on a PR, marked and versioned — never mistaken for a review verdict",
5066
+ flags: [
5067
+ { flag: "--file", description: "Path to the ruling file to post as a PR comment" },
5068
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5069
+ ],
5070
+ details: [
5071
+ "Refuses before posting when the file's first line reads as an escalation (`ESCALATE:`), or when the file carries verdict grammar anywhere `extractCodeReviewVerdict`/`extractSecurityReviewVerdict` would treat as a candidate — a `VERDICT:` line past the extractor's own first-five-line window still counts, since the whole-body candidate test is what disqualifies the file, not merely a clean read.",
5072
+ "Marker numbers (`<!-- aeg:principal:ruling:<pr>-<k> -->`) are counted on the forge at post time from `gh pr view --json comments`, never derived from a local file — two rulings racing to the same number are a known, undocumented-lock case."
5073
+ ],
5074
+ status: "shipped"
5075
+ },
4611
5076
  {
4612
5077
  name: "pr verify-evidence",
4613
5078
  description: "Prove a pull request's AEG:EVIDENCE region was machine-generated — regenerate it and compare",
@@ -4649,6 +5114,44 @@ var COMMANDS = [
4649
5114
  ],
4650
5115
  status: "shipped"
4651
5116
  },
5117
+ {
5118
+ name: "issue objectives edit",
5119
+ description: "Rewrite a task Issue's `## Objectives` section by command — versioned, findable on the forge",
5120
+ flags: [
5121
+ { flag: "--add", description: "Append a new objective as `O<max+1>` with the given sentence" },
5122
+ { flag: "--drop", description: "Remove an objective by id (`O<k>`) — never renumbers the survivors" },
5123
+ {
5124
+ flag: "--replace",
5125
+ description: 'Replace an objective\'s sentence in place, keeping its id (`O<k>` "<sentence>")'
5126
+ },
5127
+ { flag: "--reason", description: "Required, non-empty: why this change is being made" },
5128
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5129
+ ],
5130
+ details: [
5131
+ "Exactly one of `--add`/`--drop`/`--replace` is required. Every edit goes through the same validated `issue edit` write path (`writeValidatedIssueEdit`) as `vinaya issue edit` itself — no second, unvalidated write path.",
5132
+ "A `--drop` that leaves the surviving objectives non-contiguous from `O1` is refused with `objectivesOf`'s own parser message: dropping never renumbers survivors, and task 1's contiguous-from-O1 grammar is the one parser everything else reads, so a live contradiction between the two stops here for a Principal ruling rather than silently renumbering.",
5133
+ "Splices the rendered section back in place (`## Objectives` heading through the next `##` heading, or end of body) — every other byte of the Issue body is untouched. Posts one comment marked `<!-- aeg:objectives:v<k> -->` carrying the previous list, the new list, the reason, and the new `objectivesVersion`; `k` is counted on the forge at post time, never derived from a local file."
5134
+ ],
5135
+ status: "shipped"
5136
+ },
5137
+ {
5138
+ name: "log flush",
5139
+ description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
5140
+ flags: [
5141
+ { flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
5142
+ {
5143
+ flag: "--pr",
5144
+ description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
5145
+ },
5146
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5147
+ ],
5148
+ details: [
5149
+ "Exactly one of `--issue`/`--pr` is required. `--pr` resolves the Issue from the PR body's `Closes #N` line — the same anchor every gate reads — and refuses with a check error naming the missing line when the body carries none.",
5150
+ "Splits the outbox first at `run_id` boundaries (a maximal run of consecutive lines sharing one `run_id`, never a global group-by, so an interleaved outbox never produces a range spanning a gap), then at `FORGE_COMMENT_MAX_CHARS` (65536) within each run. Each comment opens with `<!-- aeg:log:<run_id>:<seq_from>-<seq_to> -->` on its own line, then one fenced `ndjson` block, one outbox line per line, verbatim. A single line too large to fit alone is refused by name, never split across two comments.",
5151
+ "Logs its own `forge_write` line — `validated` before posting, `written` (with every returned comment id) after the last post succeeds, or `refused` (with gh's error) on any failure — through the same `log()` every other family uses, into the same outbox, before truncating. The outbox is truncated only to the lines confirmed posted; a failed chunk's lines, and anything appended to the outbox during the flush (including the flush's own `validated`/`written`/`refused` line), always survive to ride the next flush."
5152
+ ],
5153
+ status: "shipped"
5154
+ },
4652
5155
  {
4653
5156
  name: "milestone create",
4654
5157
  description: "Create a GitHub Milestone from a validated body",
@@ -4741,6 +5244,10 @@ var COMMANDS = [
4741
5244
  flag: "--findings-file",
4742
5245
  description: "One finding per line: `SEVERITY|file:line|description` (`|`-delimited). A re-review names a prior id in the description as `F<n> <class> <state>:`. Omit for zero findings."
4743
5246
  },
5247
+ {
5248
+ flag: "--objectives-file",
5249
+ description: "One line per objective: `O<n>|MET|<evidence>` or `O<n>|NOT MET|<evidence>` (`|`-delimited; evidence is the rest of the line). Required whenever the closed Issue (or the PR body's own `## Objectives`) has an objectives list to judge; its ids must cover that list exactly, and a re-review must restate every prior objective. Never together with `--escalate`."
5250
+ },
4744
5251
  { flag: "--brief-conformance", description: "code-reviewer only: the BRIEF CONFORMANCE line" },
4745
5252
  { flag: "--spec-conformance", description: "code-reviewer only: the SPEC CONFORMANCE line" },
4746
5253
  { flag: "--scope", description: "code-reviewer only: the SCOPE line" },
@@ -4771,8 +5278,9 @@ var COMMANDS = [
4771
5278
  "`--print-only` runs the exact same render-then-self-check path as a real post, then returns before `gh pr comment` — closes atta-labs/vinaya#184, where the old command silently posted a verdict anyway after a reviewer guessed this flag existed.",
4772
5279
  "Every structural line (`VERDICT:`, `Judged head:`) is rendered from this command's own validated enum/sha inputs — never from a caller-supplied string — so a Reviewer's free-typed prose can no longer produce a shape the merge gate's line-anchored regex fails to see.",
4773
5280
  "The verdict is derived, not typed: a BLOCKER (or CRITICAL/HIGH) finding forces REQUEST_CHANGES/FAIL and its absence forces APPROVE/PASS, before posting anything — an explicit `--verdict` that disagrees is refused naming the derived value. When a same-role verdict comment already exists on the PR, a new findings file must carry every prior id with a state and no non-blocking finding outside the diff since that comment's judged head, or the post is refused.",
4774
- "Before the post ever reaches the forge, runs the exact `extractCodeReviewVerdict`/`extractSecurityReviewVerdict` functions `checkReviewGate` calls over its own rendered text and refuses (exit 2) unless exactly the intended verdict extracts and the other role extracts none an escalation requires both to extract none. Both extractors read only a comment's first three lines, which are always this command's own structural lines, so no caller-supplied field can smuggle a line the gate would misread.",
4775
- "After posting, re-fetches the PR's comments and runs them through the same extractors `checkReviewGate` calls the same functions, not a second implementation and exits non-zero naming precisely what failed to re-parse if the post does not come back clean, bound to the resolved head, and free of the other role's verdict. There is no `--skip-verify` escape."
5281
+ "Renders an `OBJECTIVES:` block (one `O<n>: MET | NOT MET <evidence>` line per objective) after `SPEC CONFORMANCE:`/before `CONFIG SCAN:`, and an `Objectives version:` line at line 5 resolved from the closed Issue's `## Objectives` list, or the PR body's own section when it closes none. A clean verdict (`APPROVE`/`PASS`) is refused alongside any `NOT MET`; an Issue below the objectives cutover renders neither line at all, matching the merge gate's own skip.",
5282
+ "Before the post ever reaches the forge, runs the exact `extractCodeReviewVerdict`/`extractSecurityReviewVerdict` functions `checkReviewGate` calls over its own rendered text and refuses (exit 2) unless exactly the intended verdict extracts and the other role extracts none an escalation requires both to extract none. Both extractors read only a comment's first five lines; a code-review or security render's caller-supplied fields never open one of those lines, but an escalation's `--summary` can (pre-cutover, it becomes line 5 unprefixed) — this pre-post re-parse, not the render's construction, is what catches that case before it ever reaches the forge.",
5283
+ "After posting, re-fetches the PR's comments and runs them through the same extractors `checkReviewGate` calls — the same functions, not a second implementation — and exits non-zero naming precisely what failed to re-parse if the post does not come back clean, bound to the resolved head and objectives version, and free of the other role's verdict. There is no `--skip-verify` escape."
4776
5284
  ],
4777
5285
  status: "shipped"
4778
5286
  },
@@ -4941,6 +5449,54 @@ var COMMANDS = [
4941
5449
  'This is the one procedure named in `apps/cli/specs/self-hosting.md`, "How the published version is produced" — publishing itself stays manual and human-triggered; this command only removes the hand-typed four-step recipe.'
4942
5450
  ],
4943
5451
  status: "shipped"
5452
+ },
5453
+ {
5454
+ name: "dispatch",
5455
+ description: "Start a role's headless agent session (claude/codex/gemini) with attribution set on its environment, recording the outcome through the Vinaya Log",
5456
+ flags: [
5457
+ {
5458
+ flag: "--agent",
5459
+ description: "Vendor to start: `claude`, `codex`, or `gemini` (falls back to `dispatch.agent` in config)"
5460
+ },
5461
+ { flag: "--prompt-file", description: "Path to the prompt text sent to the agent (never on argv)" },
5462
+ { flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
5463
+ {
5464
+ flag: "--pr",
5465
+ description: "Flush the outbox to this PR's Issue after the dispatch — mutually exclusive with `--task`"
5466
+ },
5467
+ { flag: "--round", description: "Round number, for a dispatch inside a review loop" },
5468
+ {
5469
+ flag: "--resume <id>",
5470
+ description: "Resume the vendor's own session/thread from a prior dispatch's returned `resumeId`, instead of starting a fresh one"
5471
+ },
5472
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5473
+ ],
5474
+ details: [
5475
+ "Sets `VINAYA_RUN_ID`/`VINAYA_ROLE`/`VINAYA_TASK`/`VINAYA_ROUND` on the child only — never on this process's own environment — and refuses by name, before any spawn attempt, when the named vendor binary is absent from `PATH` or present but not executable.",
5476
+ "Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, or `refused`) through the Vinaya Log's one `dispatch` family writer, `dispatchRole`. A wall-time ceiling (`dispatch.timeoutMs` in config, default one hour) sends `SIGTERM` then, after a grace window, `SIGKILL`.",
5477
+ "When `--task` or `--pr` is given, flushes that outbox via `vinaya log flush` immediately after the child settles — `--task` and `--pr` are mutually exclusive here, matching `log flush`'s own single-target rule. Without either, the dispatch still runs and logs; nothing is flushed, and the lines ride to the next flush.",
5478
+ "A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude/gemini: `session_id`; codex: `thread_id`), parsed from its stdout, `null` on any failure. Passing that value as `--resume <id>` on a later call swaps in that vendor's own resume invocation (`claude -p -r <id> ...`; `codex exec resume <id> ...`; `gemini ... --resume <id> ...`) in place of its first-dispatch args."
5479
+ ],
5480
+ status: "shipped"
5481
+ },
5482
+ {
5483
+ name: "dev-review-loop",
5484
+ description: "Dispatch the developer, run review rounds against the forge, resume the same developer session every round, and hold every verdict until the policy says publish",
5485
+ flags: [
5486
+ { flag: "--task <n>", description: "This task's Issue number — its frozen `aeg:brief:v1` comment is the brief" },
5487
+ {
5488
+ flag: "--agent <claude|codex|gemini>",
5489
+ description: "Vendor for every dispatch this loop makes (falls back to `dispatch.agent` in config)"
5490
+ },
5491
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
5492
+ ],
5493
+ details: [
5494
+ "Dispatches the developer through `dispatchRole` with the brief read from the Issue, waits for the PR it opens, then runs `assessRound` (`@attalabs/aeg-core`) — the entire policy — against observations this command reads from the forge: the head via `git ls-remote` only (never `gh pr view headRefOid`, which can lag a push), CI conclusion via the check-runs API (never run locally), and ruling comments matching `<!-- aeg:principal:ruling:<pr>-<k> -->`.",
5495
+ "Nothing is posted to the PR before the policy decides `publish`: each round's reviewer and security verdicts are dispatched fresh (never a resumed session) through `dispatchRole`, rendered through `review post`'s own render functions, and written to a local file under the outbox — never `gh pr comment`/`gh pr review`. Posting the held verdicts is a separate, later task.",
5496
+ "The developer's session is resumed every round via `dispatchRole`'s `resumeId` — never a fresh session — for every vendor; a round whose resume fails for a vendor that resumed successfully the round before stops the loop rather than silently falling back to a fresh developer session.",
5497
+ "Every dispatch and round transition is a log line through the Vinaya Log, flushed to the forge at each round boundary."
5498
+ ],
5499
+ status: "shipped"
4944
5500
  }
4945
5501
  ];
4946
5502
  // ../../packages/sources/src/forge-adapter.ts
@@ -4952,10 +5508,10 @@ function createForgeSource(config) {
4952
5508
  };
4953
5509
  }
4954
5510
  // ../../packages/sources/src/select-source.ts
4955
- import { z } from "zod";
4956
- var StateSourceConfigSchema = z.discriminatedUnion("kind", [
4957
- z.object({ kind: z.literal("forge"), owner: z.string(), repo: z.string() }),
4958
- z.object({ kind: z.literal("file"), root: z.string().optional() })
5511
+ import { z as z2 } from "zod";
5512
+ var StateSourceConfigSchema = z2.discriminatedUnion("kind", [
5513
+ z2.object({ kind: z2.literal("forge"), owner: z2.string(), repo: z2.string() }),
5514
+ z2.object({ kind: z2.literal("file"), root: z2.string().optional() })
4959
5515
  ]);
4960
5516
  // src/checks/contract.ts
4961
5517
  var CHECK_SCHEMA_VERSION = 1;
@@ -4969,27 +5525,27 @@ import { execFileSync as execFileSync2 } from "node:child_process";
4969
5525
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
4970
5526
  import { homedir } from "node:os";
4971
5527
  import { dirname, join, resolve } from "node:path";
4972
- import { z as z2 } from "zod";
5528
+ import { z as z3 } from "zod";
4973
5529
 
4974
5530
  // src/lib/agent-vendors.ts
4975
5531
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
4976
5532
 
4977
5533
  // src/lib/config.ts
4978
- var EnvEntrySchema = z2.union([
4979
- z2.literal(true),
4980
- z2.object({ optional: z2.literal(true) }),
4981
- z2.object({ anyOf: z2.array(z2.string()).min(2) }),
4982
- z2.string()
5534
+ var EnvEntrySchema = z3.union([
5535
+ z3.literal(true),
5536
+ z3.object({ optional: z3.literal(true) }),
5537
+ z3.object({ anyOf: z3.array(z3.string()).min(2) }),
5538
+ z3.string()
4983
5539
  ]);
4984
- var CheckEntrySchema = z2.object({
4985
- run: z2.string(),
4986
- scope: z2.enum(["diff", "full"]),
4987
- include: z2.array(z2.string()).optional(),
4988
- args: z2.array(z2.string()).optional(),
4989
- timeoutMs: z2.number().optional(),
4990
- env: z2.record(z2.string(), EnvEntrySchema).optional(),
4991
- requiresOpenPr: z2.boolean().optional(),
4992
- ownWorkflow: z2.boolean().optional()
5540
+ var CheckEntrySchema = z3.object({
5541
+ run: z3.string(),
5542
+ scope: z3.enum(["diff", "full"]),
5543
+ include: z3.array(z3.string()).optional(),
5544
+ args: z3.array(z3.string()).optional(),
5545
+ timeoutMs: z3.number().optional(),
5546
+ env: z3.record(z3.string(), EnvEntrySchema).optional(),
5547
+ requiresOpenPr: z3.boolean().optional(),
5548
+ ownWorkflow: z3.boolean().optional()
4993
5549
  }).superRefine((entry2, ctx) => {
4994
5550
  if (!entry2.env)
4995
5551
  return;
@@ -4999,22 +5555,22 @@ var CheckEntrySchema = z2.object({
4999
5555
  const members = value.anyOf;
5000
5556
  if (new Set(members).size !== members.length) {
5001
5557
  ctx.addIssue({
5002
- code: z2.ZodIssueCode.custom,
5558
+ code: z3.ZodIssueCode.custom,
5003
5559
  message: `env.${key}.anyOf has duplicate members`,
5004
5560
  path: ["env", key, "anyOf"]
5005
5561
  });
5006
5562
  }
5007
5563
  if (!members.includes(key)) {
5008
5564
  ctx.addIssue({
5009
- code: z2.ZodIssueCode.custom,
5565
+ code: z3.ZodIssueCode.custom,
5010
5566
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
5011
5567
  path: ["env", key, "anyOf"]
5012
5568
  });
5013
5569
  }
5014
5570
  }
5015
5571
  });
5016
- var RoleEntrySchema = z2.object({
5017
- contract: z2.string().refine((p) => p.includes("/"), {
5572
+ var RoleEntrySchema = z3.object({
5573
+ contract: z3.string().refine((p) => p.includes("/"), {
5018
5574
  message: 'must be a path (contain at least one "/"), not a bare filename'
5019
5575
  })
5020
5576
  });
@@ -5033,19 +5589,21 @@ var BRIEF_BUILTINS = [
5033
5589
  "closesN",
5034
5590
  "premiseCoverage",
5035
5591
  "issueRationale",
5592
+ "objectives",
5593
+ "briefSections",
5036
5594
  "milestoneShape"
5037
5595
  ];
5038
- var BriefSectionSchema = z2.union([
5039
- z2.object({ builtin: z2.enum(BRIEF_BUILTINS) }),
5040
- z2.object({ heading: z2.string().min(1), name: z2.string().optional() }),
5041
- z2.object({ field: z2.string().min(1), name: z2.string().optional() }),
5042
- z2.object({ phrase: z2.string().min(1), name: z2.string().optional() })
5596
+ var BriefSectionSchema = z3.union([
5597
+ z3.object({ builtin: z3.enum(BRIEF_BUILTINS) }),
5598
+ z3.object({ heading: z3.string().min(1), name: z3.string().optional() }),
5599
+ z3.object({ field: z3.string().min(1), name: z3.string().optional() }),
5600
+ z3.object({ phrase: z3.string().min(1), name: z3.string().optional() })
5043
5601
  ]);
5044
- var BriefSchemaSchema = z2.object({
5045
- pr: z2.object({ sections: z2.array(BriefSectionSchema) }).optional(),
5046
- issue: z2.object({ sections: z2.array(BriefSectionSchema) }).optional(),
5047
- milestone: z2.object({ sections: z2.array(BriefSectionSchema) }).optional(),
5048
- ack: z2.array(z2.enum(BRIEF_BUILTINS)).optional()
5602
+ var BriefSchemaSchema = z3.object({
5603
+ pr: z3.object({ sections: z3.array(BriefSectionSchema) }).optional(),
5604
+ issue: z3.object({ sections: z3.array(BriefSectionSchema) }).optional(),
5605
+ milestone: z3.object({ sections: z3.array(BriefSectionSchema) }).optional(),
5606
+ ack: z3.array(z3.enum(BRIEF_BUILTINS)).optional()
5049
5607
  });
5050
5608
  function isSafeRepoRelPath(p) {
5051
5609
  if (p.length === 0)
@@ -5054,7 +5612,7 @@ function isSafeRepoRelPath(p) {
5054
5612
  return false;
5055
5613
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
5056
5614
  }
5057
- var SafeRepoRelPath = z2.string().refine(isSafeRepoRelPath, {
5615
+ var SafeRepoRelPath = z3.string().refine(isSafeRepoRelPath, {
5058
5616
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
5059
5617
  });
5060
5618
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -5064,22 +5622,22 @@ function isCanonicalHookBlockPath(p) {
5064
5622
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
5065
5623
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
5066
5624
  });
5067
- var ManagedBlockRecordSchema = z2.object({
5625
+ var ManagedBlockRecordSchema = z3.object({
5068
5626
  path: ManagedHookBlockPath,
5069
- marker: z2.string(),
5070
- comment: z2.enum(["hash", "html"])
5627
+ marker: z3.string(),
5628
+ comment: z3.enum(["hash", "html"])
5071
5629
  });
5072
- var ManagedManifestSchema = z2.object({
5073
- version: z2.number().int().positive(),
5074
- files: z2.array(SafeRepoRelPath),
5075
- blocks: z2.array(ManagedBlockRecordSchema),
5076
- labels: z2.array(z2.string()),
5077
- agents: z2.array(z2.enum(AGENT_VENDORS)).optional()
5630
+ var ManagedManifestSchema = z3.object({
5631
+ version: z3.number().int().positive(),
5632
+ files: z3.array(SafeRepoRelPath),
5633
+ blocks: z3.array(ManagedBlockRecordSchema),
5634
+ labels: z3.array(z3.string()),
5635
+ agents: z3.array(z3.enum(AGENT_VENDORS)).optional()
5078
5636
  });
5079
- var ProjectEntrySchema = z2.object({
5080
- name: z2.string().min(1),
5081
- description: z2.string().min(1).optional(),
5082
- path: z2.string().min(1).optional()
5637
+ var ProjectEntrySchema = z3.object({
5638
+ name: z3.string().min(1),
5639
+ description: z3.string().min(1).optional(),
5640
+ path: z3.string().min(1).optional()
5083
5641
  });
5084
5642
  function parseTokensCollectDeclaration(value) {
5085
5643
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -5090,31 +5648,35 @@ function parseTokensCollectDeclaration(value) {
5090
5648
  return null;
5091
5649
  return { interpreter, script };
5092
5650
  }
5093
- var VinayaConfigSchema = z2.object({
5094
- rings: z2.object({
5095
- ring1_forgeWriteInterception: z2.boolean(),
5096
- ring2_asyncAudits: z2.boolean()
5651
+ var VinayaConfigSchema = z3.object({
5652
+ rings: z3.object({
5653
+ ring1_forgeWriteInterception: z3.boolean(),
5654
+ ring2_asyncAudits: z3.boolean()
5097
5655
  }).optional(),
5098
- checks: z2.record(z2.string(), CheckEntrySchema).optional(),
5099
- roles: z2.record(z2.string(), RoleEntrySchema).optional(),
5656
+ checks: z3.record(z3.string(), CheckEntrySchema).optional(),
5657
+ roles: z3.record(z3.string(), RoleEntrySchema).optional(),
5100
5658
  briefSchema: BriefSchemaSchema.optional(),
5101
5659
  managed: ManagedManifestSchema.optional(),
5102
- principals: z2.array(z2.string()).min(1).optional(),
5103
- releaseActor: z2.string().min(1).optional(),
5104
- ci: z2.object({ setup: z2.string().min(1) }).optional(),
5105
- tokens: z2.object({
5106
- collect: z2.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
5660
+ principals: z3.array(z3.string()).min(1).optional(),
5661
+ releaseActor: z3.string().min(1).optional(),
5662
+ ci: z3.object({ setup: z3.string().min(1) }).optional(),
5663
+ tokens: z3.object({
5664
+ collect: z3.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
5107
5665
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
5108
5666
  })
5109
5667
  }).optional(),
5110
- blastRadius: z2.object({ extraDomains: z2.array(z2.string()).optional() }).optional(),
5111
- proseGates: z2.object({
5112
- doctrineRoot: z2.string().min(1).optional(),
5113
- readerFacingPrefix: z2.string().min(1).optional(),
5114
- readerFacingSuffix: z2.string().min(1).optional(),
5115
- legacySlugDir: z2.string().min(1).optional()
5668
+ blastRadius: z3.object({ extraDomains: z3.array(z3.string()).optional() }).optional(),
5669
+ proseGates: z3.object({
5670
+ doctrineRoot: z3.string().min(1).optional(),
5671
+ readerFacingPrefix: z3.string().min(1).optional(),
5672
+ readerFacingSuffix: z3.string().min(1).optional(),
5673
+ legacySlugDir: z3.string().min(1).optional()
5116
5674
  }).optional(),
5117
- projects: z2.array(ProjectEntrySchema).optional()
5675
+ projects: z3.array(ProjectEntrySchema).optional(),
5676
+ dispatch: z3.object({
5677
+ timeoutMs: z3.number().int().positive().optional(),
5678
+ agent: z3.enum(["claude", "codex", "gemini"]).optional()
5679
+ }).optional()
5118
5680
  });
5119
5681
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
5120
5682
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");