@attalabs/vinaya 0.39.0 → 0.40.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.
- package/README.md +9 -9
- package/aeg-root/contracts/planner-developer.md +1 -1
- package/aeg-root/enforcement.md +22 -22
- package/aeg-root/process.md +1 -1
- package/aeg-root/roles/archivist.md +1 -1
- package/aeg-root/roles/developer/reference.md +4 -1
- package/aeg-root/roles/developer.md +1 -1
- package/aeg-root/roles/planner/reference.md +18 -5
- package/aeg-root/roles/principal.md +1 -1
- package/aeg-root/roles/reviewer.md +3 -3
- package/aeg-root/roles/security.md +4 -4
- package/aeg-root/roles/tranche-archivist.md +2 -2
- package/aeg-root/skills/aeg/SKILL.md +1 -1
- package/aeg-root/state-machine.md +8 -13
- package/aeg-root/templates/brief-template.md +4 -1
- package/aeg-root/templates/decision-record-template.md +38 -0
- package/aeg-root/templates/issue-rationale-template.md +1 -1
- package/aeg-root/tranche-model.md +1 -1
- package/dist/checks/bin/check-body-bare-digits.js +1867 -347
- package/dist/checks/bin/check-branch-topology.js +1181 -237
- package/dist/checks/bin/check-brief-shape.js +1911 -433
- package/dist/checks/bin/check-changeset-coverage.js +2144 -517
- package/dist/checks/bin/check-ci-shard-coverage.js +12133 -11
- package/dist/checks/bin/check-closes-n.js +1181 -237
- package/dist/checks/bin/check-coherence.js +1785 -1126
- package/dist/checks/bin/check-dead-branch-push.js +1154 -225
- package/dist/checks/bin/check-dispatch-readiness.js +2068 -436
- package/dist/checks/bin/check-doc-claims.js +2104 -231
- package/dist/checks/bin/check-doc-coverage-push.js +2181 -515
- package/dist/checks/bin/check-doc-coverage.js +2181 -519
- package/dist/checks/bin/check-doctrine-no-procedures.js +1668 -345
- package/dist/checks/bin/check-doctrine-portability.js +2143 -516
- package/dist/checks/bin/check-evidence-fresh.js +2080 -465
- package/dist/checks/bin/check-exec-bits.js +2130 -503
- package/dist/checks/bin/check-first-push-dispatch.js +1845 -371
- package/dist/checks/bin/check-issue-assignment.js +712 -170
- package/dist/checks/bin/check-issue-milestone-attach.js +1145 -225
- package/dist/checks/bin/check-issue-objectives-numbering.js +1661 -338
- package/dist/checks/bin/check-issue-parts-coverage.js +1145 -225
- package/dist/checks/bin/check-issue-surface-globs.js +1787 -369
- package/dist/checks/bin/check-issue-title-grammar.js +1145 -225
- package/dist/checks/bin/check-issue-tranche-label.js +702 -170
- package/dist/checks/bin/check-main-branch-refusal.js +1157 -227
- package/dist/checks/bin/check-no-disk-state.js +1145 -225
- package/dist/checks/bin/check-pr-premise-reassert.js +1661 -338
- package/dist/checks/bin/check-pr-report-density.js +1145 -225
- package/dist/checks/bin/check-principal-test-plan-wait.js +2379 -249
- package/dist/checks/bin/check-quoted-command.js +2128 -501
- package/dist/checks/bin/check-reader-resolvable-prose.js +2170 -517
- package/dist/checks/bin/check-registry-gates.js +1228 -272
- package/dist/checks/bin/check-retired-vocabulary.js +2153 -507
- package/dist/checks/bin/check-review-gate.js +1932 -350
- package/dist/checks/bin/check-single-plan-pr.js +1208 -229
- package/dist/checks/bin/check-surface-scope.js +1414 -244
- package/dist/checks/bin/check-test-plan.js +2381 -252
- package/dist/checks/bin/check-token-collection-wired.js +1145 -225
- package/dist/checks/bin/check-workspace-escape.js +2141 -514
- package/dist/checks/bin/verify-coherence.js +493 -86
- package/dist/checks/bin/verify-dispatch.js +512 -132
- package/dist/checks/bin/verify-docs.js +549 -124
- package/dist/index.js +22702 -17900
- package/dist/lib/pre-push-cache-test-run.js +1026 -233
- package/dist/lib/pre-push-select-tests.js +922 -173
- package/package.json +12 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +13 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +55 -26
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +12 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +22 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/entry-point.ts +27 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +2 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +19 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +593 -55
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +6 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +19 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +32 -13
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
- 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
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0sxadt2._.js +13 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +57 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1ug9syi._.js → [root-of-the-server]__1wzfiav._.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{06_55xbp7rcbi.js → 1p3vr9qts86_b.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2brkwv169ygep.js → 21tunzmxjvm2a.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{33rszkngkuoko.js → 38kom-9c-oi65.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +0 -57
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +0 -13
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_ssgManifest.js +0 -0
|
@@ -39,7 +39,6 @@ var GATE_AUDIENCE = {
|
|
|
39
39
|
};
|
|
40
40
|
var NON_GATE_BINS = [
|
|
41
41
|
"archive-task",
|
|
42
|
-
"assign-task-issue",
|
|
43
42
|
"dead-branch-audit",
|
|
44
43
|
"eval-agent-compliance",
|
|
45
44
|
"open-issue",
|
|
@@ -302,6 +301,25 @@ async function runAsync(args) {
|
|
|
302
301
|
function ghApiGet(path) {
|
|
303
302
|
return JSON.parse(run(["api", path]));
|
|
304
303
|
}
|
|
304
|
+
var MAX_PER_PAGE = 100;
|
|
305
|
+
var MAX_PAGES = 100;
|
|
306
|
+
async function ghApiGetAllPagesAsync(pathWithoutPage, opts) {
|
|
307
|
+
const [base = pathWithoutPage, query = ""] = pathWithoutPage.split("?");
|
|
308
|
+
const params = new URLSearchParams(query);
|
|
309
|
+
params.set("per_page", String(MAX_PER_PAGE));
|
|
310
|
+
const all = [];
|
|
311
|
+
for (let page = 1;page <= MAX_PAGES; page++) {
|
|
312
|
+
params.set("page", String(page));
|
|
313
|
+
const args = ["api", `${base}?${params.toString()}`];
|
|
314
|
+
if (opts?.jq)
|
|
315
|
+
args.push("-q", opts.jq);
|
|
316
|
+
const batch = JSON.parse(await runAsync(args));
|
|
317
|
+
all.push(...batch);
|
|
318
|
+
if (batch.length < MAX_PER_PAGE)
|
|
319
|
+
return all;
|
|
320
|
+
}
|
|
321
|
+
throw new Error(`ghApiGetAllPagesAsync: "${pathWithoutPage}" did not terminate within ${MAX_PAGES} pages (${MAX_PAGES * MAX_PER_PAGE} items) — refusing to keep walking.`);
|
|
322
|
+
}
|
|
305
323
|
function issueListByLabelArgs(owner, repo, label) {
|
|
306
324
|
return [
|
|
307
325
|
"issue",
|
|
@@ -713,6 +731,10 @@ function intentGoalForSlug(description, slug) {
|
|
|
713
731
|
function matchesLegacyMilestone(milestones, slug) {
|
|
714
732
|
return milestones.find((m) => m.title === slug) ?? null;
|
|
715
733
|
}
|
|
734
|
+
var TRANCHE_SLUG_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*-v\d+$/;
|
|
735
|
+
function slugShapedTitles(milestones) {
|
|
736
|
+
return milestones.map((m) => m.title).filter((t) => TRANCHE_SLUG_SHAPE.test(t));
|
|
737
|
+
}
|
|
716
738
|
function factsFromLegacyMilestone(milestone) {
|
|
717
739
|
return {
|
|
718
740
|
goal: milestone.description ?? "",
|
|
@@ -746,6 +768,90 @@ function findMilestoneForSlug(owner, repo, slug) {
|
|
|
746
768
|
return resolveLegacyFacts(legacy, issues);
|
|
747
769
|
return { goal: goalFromMilestones(milestones, slug), lifecycle: lifecycleFromIssues(issues) };
|
|
748
770
|
}
|
|
771
|
+
function trancheSlugsFromLabels(labels) {
|
|
772
|
+
const slugs = [];
|
|
773
|
+
for (const l of labels) {
|
|
774
|
+
const slug = trancheSlugOf(l.name);
|
|
775
|
+
if (slug !== null)
|
|
776
|
+
slugs.push(slug);
|
|
777
|
+
}
|
|
778
|
+
return slugs;
|
|
779
|
+
}
|
|
780
|
+
async function indexTrancheMilestonesAsync(owner, repo) {
|
|
781
|
+
const [milestones, labels] = await Promise.all([
|
|
782
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
783
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`)
|
|
784
|
+
]);
|
|
785
|
+
const active = [];
|
|
786
|
+
const archived = [];
|
|
787
|
+
const facts = new Map;
|
|
788
|
+
const legacySlugs = new Set(slugShapedTitles(milestones));
|
|
789
|
+
const legacyMilestoneBySlug = new Map(milestones.filter((m) => legacySlugs.has(m.title)).map((m) => [m.title, m]));
|
|
790
|
+
const newPathSlugs = trancheSlugsFromLabels(labels).filter((slug) => !legacySlugs.has(slug));
|
|
791
|
+
const uniqueNewPathSlugs = [...new Set(newPathSlugs)];
|
|
792
|
+
const uniqueLegacySlugs = [...legacySlugs];
|
|
793
|
+
const [legacyIssuesBySlug, newPathIssuesBySlug] = await Promise.all([
|
|
794
|
+
Promise.all(uniqueLegacySlugs.map((slug) => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))),
|
|
795
|
+
Promise.all(uniqueNewPathSlugs.map((slug) => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))))
|
|
796
|
+
]);
|
|
797
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
798
|
+
const m = legacyMilestoneBySlug.get(slug);
|
|
799
|
+
if (!m)
|
|
800
|
+
return;
|
|
801
|
+
const ref = { slug, goal: m.description ?? "" };
|
|
802
|
+
const f = resolveLegacyFacts(m, legacyIssuesBySlug[i] ?? []);
|
|
803
|
+
if (f.lifecycle === "complete")
|
|
804
|
+
archived.push(ref);
|
|
805
|
+
else if (f.lifecycle === "active")
|
|
806
|
+
active.push(ref);
|
|
807
|
+
facts.set(slug, f);
|
|
808
|
+
});
|
|
809
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
810
|
+
const issues = newPathIssuesBySlug[i] ?? [];
|
|
811
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
812
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
813
|
+
const f = { goal, lifecycle };
|
|
814
|
+
facts.set(slug, f);
|
|
815
|
+
if (lifecycle === "active")
|
|
816
|
+
active.push({ slug, goal });
|
|
817
|
+
else if (lifecycle === "complete")
|
|
818
|
+
archived.push({ slug, goal });
|
|
819
|
+
});
|
|
820
|
+
return { active, archived, facts, legacySlugs };
|
|
821
|
+
}
|
|
822
|
+
async function indexTrancheMilestonesForSlugAsync(owner, repo, slug) {
|
|
823
|
+
const [milestones, labels, issues] = await Promise.all([
|
|
824
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
825
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`),
|
|
826
|
+
ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))
|
|
827
|
+
]);
|
|
828
|
+
const active = [];
|
|
829
|
+
const archived = [];
|
|
830
|
+
const facts = new Map;
|
|
831
|
+
const legacySlugs = new Set;
|
|
832
|
+
const legacyMilestone = slugShapedTitles(milestones).includes(slug) ? matchesLegacyMilestone(milestones, slug) : null;
|
|
833
|
+
if (legacyMilestone) {
|
|
834
|
+
legacySlugs.add(slug);
|
|
835
|
+
const ref = { slug, goal: legacyMilestone.description ?? "" };
|
|
836
|
+
const f = resolveLegacyFacts(legacyMilestone, issues);
|
|
837
|
+
if (f.lifecycle === "complete")
|
|
838
|
+
archived.push(ref);
|
|
839
|
+
else if (f.lifecycle === "active")
|
|
840
|
+
active.push(ref);
|
|
841
|
+
facts.set(slug, f);
|
|
842
|
+
} else if (trancheSlugsFromLabels(labels).includes(slug)) {
|
|
843
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
844
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
845
|
+
facts.set(slug, { goal, lifecycle });
|
|
846
|
+
if (lifecycle === "active")
|
|
847
|
+
active.push({ slug, goal });
|
|
848
|
+
else if (lifecycle === "complete")
|
|
849
|
+
archived.push({ slug, goal });
|
|
850
|
+
}
|
|
851
|
+
const openLegacyTitles = new Set(slugShapedTitles(milestones.filter((m) => m.state === "open")));
|
|
852
|
+
const otherOpenLegacySlugs = [...openLegacyTitles].filter((t) => t !== slug);
|
|
853
|
+
return { active, archived, facts, legacySlugs, otherOpenLegacySlugs };
|
|
854
|
+
}
|
|
749
855
|
|
|
750
856
|
// ../../packages/aeg-forge-state/src/derive-from-forge.ts
|
|
751
857
|
function trancheFromIssues(slug, issues, known) {
|
|
@@ -1406,6 +1512,125 @@ var graphql2 = withDefaults3(request, {
|
|
|
1406
1512
|
method: "POST",
|
|
1407
1513
|
url: "/graphql"
|
|
1408
1514
|
});
|
|
1515
|
+
|
|
1516
|
+
// ../../packages/aeg-forge-state/src/fetch-provenance.ts
|
|
1517
|
+
var PROVENANCE_PATTERN = /^###\s+AEG provenance\b/im;
|
|
1518
|
+
function provenanceMatchesIssue(text, issueNum) {
|
|
1519
|
+
if (!PROVENANCE_PATTERN.test(text))
|
|
1520
|
+
return false;
|
|
1521
|
+
const m = text.match(/^-\s*Issue:\s*#(\d+)/im);
|
|
1522
|
+
return m !== null && Number(m[1]) === issueNum;
|
|
1523
|
+
}
|
|
1524
|
+
function isPrCloser(closer) {
|
|
1525
|
+
return closer !== null && typeof closer.number === "number";
|
|
1526
|
+
}
|
|
1527
|
+
async function fetchProvenanceViaCrossReferences(issueNums, owner, repo, token) {
|
|
1528
|
+
const result = new Map;
|
|
1529
|
+
if (issueNums.length === 0)
|
|
1530
|
+
return result;
|
|
1531
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1532
|
+
const perIssue = issueNums.map((n) => `
|
|
1533
|
+
i_${n}: issue(number: ${n}) {
|
|
1534
|
+
timelineItems(first: 50, itemTypes: [CROSS_REFERENCED_EVENT]) {
|
|
1535
|
+
nodes {
|
|
1536
|
+
... on CrossReferencedEvent {
|
|
1537
|
+
source {
|
|
1538
|
+
... on PullRequest {
|
|
1539
|
+
number
|
|
1540
|
+
body
|
|
1541
|
+
comments(first: 50) { nodes { body } }
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
}`).join("");
|
|
1548
|
+
const query = `query ProvenanceCrossRef($owner: String!, $repo: String!) {
|
|
1549
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1550
|
+
}
|
|
1551
|
+
}`;
|
|
1552
|
+
let response;
|
|
1553
|
+
try {
|
|
1554
|
+
response = await client(query, { owner, repo });
|
|
1555
|
+
} catch {
|
|
1556
|
+
return result;
|
|
1557
|
+
}
|
|
1558
|
+
if (!response.repository)
|
|
1559
|
+
return result;
|
|
1560
|
+
for (const n of issueNums) {
|
|
1561
|
+
const raw = response.repository[`i_${n}`];
|
|
1562
|
+
const nodes = raw?.timelineItems?.nodes ?? [];
|
|
1563
|
+
const found = nodes.some(({ source }) => {
|
|
1564
|
+
if (!source || typeof source.number !== "number")
|
|
1565
|
+
return false;
|
|
1566
|
+
const pr = source;
|
|
1567
|
+
if (provenanceMatchesIssue(pr.body ?? "", n))
|
|
1568
|
+
return true;
|
|
1569
|
+
return pr.comments.nodes.some((c) => provenanceMatchesIssue(c.body, n));
|
|
1570
|
+
});
|
|
1571
|
+
result.set(n, found);
|
|
1572
|
+
}
|
|
1573
|
+
return result;
|
|
1574
|
+
}
|
|
1575
|
+
async function fetchProvenance(issueNums, owner, repo, token) {
|
|
1576
|
+
const result = new Map;
|
|
1577
|
+
if (issueNums.length === 0)
|
|
1578
|
+
return result;
|
|
1579
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1580
|
+
const perIssue = issueNums.map((n) => `
|
|
1581
|
+
i_${n}: issue(number: ${n}) {
|
|
1582
|
+
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1583
|
+
nodes {
|
|
1584
|
+
... on ClosedEvent {
|
|
1585
|
+
closer {
|
|
1586
|
+
... on PullRequest {
|
|
1587
|
+
number
|
|
1588
|
+
body
|
|
1589
|
+
comments(first: 50) {
|
|
1590
|
+
nodes { body }
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
}`).join("");
|
|
1598
|
+
const query = `query Provenance($owner: String!, $repo: String!) {
|
|
1599
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1600
|
+
}
|
|
1601
|
+
}`;
|
|
1602
|
+
let response;
|
|
1603
|
+
try {
|
|
1604
|
+
response = await client(query, { owner, repo });
|
|
1605
|
+
} catch {
|
|
1606
|
+
return result;
|
|
1607
|
+
}
|
|
1608
|
+
if (!response.repository)
|
|
1609
|
+
return result;
|
|
1610
|
+
const needsFallback = [];
|
|
1611
|
+
for (const n of issueNums) {
|
|
1612
|
+
const raw = response.repository[`i_${n}`];
|
|
1613
|
+
if (!raw) {
|
|
1614
|
+
result.set(n, false);
|
|
1615
|
+
continue;
|
|
1616
|
+
}
|
|
1617
|
+
const closer = raw.timelineItems?.nodes?.[0]?.closer;
|
|
1618
|
+
const c = closer ?? null;
|
|
1619
|
+
if (!isPrCloser(c)) {
|
|
1620
|
+
needsFallback.push(n);
|
|
1621
|
+
continue;
|
|
1622
|
+
}
|
|
1623
|
+
const bodyHas = PROVENANCE_PATTERN.test(c.body ?? "");
|
|
1624
|
+
const commentHas = c.comments.nodes.some((x) => PROVENANCE_PATTERN.test(x.body));
|
|
1625
|
+
result.set(n, bodyHas || commentHas);
|
|
1626
|
+
}
|
|
1627
|
+
if (needsFallback.length > 0) {
|
|
1628
|
+
const fallback = await fetchProvenanceViaCrossReferences(needsFallback, owner, repo, token);
|
|
1629
|
+
for (const [n, found] of fallback)
|
|
1630
|
+
result.set(n, found);
|
|
1631
|
+
}
|
|
1632
|
+
return result;
|
|
1633
|
+
}
|
|
1409
1634
|
// ../../packages/aeg-forge-state/src/github-token.ts
|
|
1410
1635
|
import { execFile as execFile2 } from "node:child_process";
|
|
1411
1636
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -1635,6 +1860,84 @@ function describeError(err) {
|
|
|
1635
1860
|
return err;
|
|
1636
1861
|
return "unknown error";
|
|
1637
1862
|
}
|
|
1863
|
+
// ../../packages/aeg-forge-state/src/prior-tranche-archival.ts
|
|
1864
|
+
function defaultPriorTrancheArchivalDeps() {
|
|
1865
|
+
let facts = new Map;
|
|
1866
|
+
return {
|
|
1867
|
+
activeTrancheSlugs: async (excludeSlug, repo) => {
|
|
1868
|
+
const index = await indexTrancheMilestonesAsync(repo.owner, repo.repo);
|
|
1869
|
+
facts = index.facts;
|
|
1870
|
+
return index.active.map((m) => m.slug).filter((slug) => slug !== excludeSlug);
|
|
1871
|
+
},
|
|
1872
|
+
deriveTranche: (slug, repo) => deriveTrancheFromForge(repo.owner, repo.repo, slug, facts.get(slug)),
|
|
1873
|
+
openIssues: async (slug, repo) => (await fetchTrancheIssuesAsync(repo.owner, repo.repo, slug)).filter((issue) => issue.state === "OPEN").map((issue) => ({ number: issue.number }))
|
|
1874
|
+
};
|
|
1875
|
+
}
|
|
1876
|
+
function reason(err) {
|
|
1877
|
+
return err instanceof Error ? err.message.split(`
|
|
1878
|
+
`)[0] ?? "failed" : String(err);
|
|
1879
|
+
}
|
|
1880
|
+
async function resolvePriorTrancheArchival(projects, excludeSlug, repo, deps = defaultPriorTrancheArchivalDeps()) {
|
|
1881
|
+
if (projects.length === 0)
|
|
1882
|
+
return { facts: [], infraFailure: null };
|
|
1883
|
+
let candidates;
|
|
1884
|
+
try {
|
|
1885
|
+
candidates = await deps.activeTrancheSlugs(excludeSlug, repo);
|
|
1886
|
+
} catch (err) {
|
|
1887
|
+
return {
|
|
1888
|
+
facts: [],
|
|
1889
|
+
infraFailure: `severity:infra — could not read the active tranches (${reason(err)}); whether a prior tranche is archived is unknown.`
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
const facts = [];
|
|
1893
|
+
const unreadable = [];
|
|
1894
|
+
const derived = new Map;
|
|
1895
|
+
const derive = (slug) => {
|
|
1896
|
+
let p = derived.get(slug);
|
|
1897
|
+
if (!p) {
|
|
1898
|
+
p = deps.deriveTranche(slug, repo);
|
|
1899
|
+
derived.set(slug, p);
|
|
1900
|
+
}
|
|
1901
|
+
return p;
|
|
1902
|
+
};
|
|
1903
|
+
for (const project of projects) {
|
|
1904
|
+
let found = null;
|
|
1905
|
+
let unknown = false;
|
|
1906
|
+
for (const slug of candidates) {
|
|
1907
|
+
let candidateTranche;
|
|
1908
|
+
try {
|
|
1909
|
+
candidateTranche = await derive(slug);
|
|
1910
|
+
} catch {
|
|
1911
|
+
unknown = true;
|
|
1912
|
+
unreadable.push(`the tasks of tranche \`${slug}\` (project \`${project}\`)`);
|
|
1913
|
+
break;
|
|
1914
|
+
}
|
|
1915
|
+
if (!candidateTranche.tasks.some((t) => t.projects.includes(project)))
|
|
1916
|
+
continue;
|
|
1917
|
+
let openIssues;
|
|
1918
|
+
try {
|
|
1919
|
+
openIssues = await deps.openIssues(slug, repo);
|
|
1920
|
+
} catch {
|
|
1921
|
+
openIssues = null;
|
|
1922
|
+
}
|
|
1923
|
+
if (openIssues === null) {
|
|
1924
|
+
unknown = true;
|
|
1925
|
+
unreadable.push(`the open Issues of tranche \`${slug}\` (project \`${project}\`)`);
|
|
1926
|
+
break;
|
|
1927
|
+
}
|
|
1928
|
+
if (openIssues.length === 0) {
|
|
1929
|
+
found = { project, priorTrancheSlug: slug, archived: false };
|
|
1930
|
+
break;
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
if (!unknown)
|
|
1934
|
+
facts.push(found ?? { project, priorTrancheSlug: null, archived: false });
|
|
1935
|
+
}
|
|
1936
|
+
return {
|
|
1937
|
+
facts,
|
|
1938
|
+
infraFailure: unreadable.length === 0 ? null : `severity:infra — could not read ${unreadable.join(", ")}; whether a prior tranche is archived is unknown.`
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1638
1941
|
// ../../packages/aeg-forge-state/src/fetch-open-issues.ts
|
|
1639
1942
|
async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
|
|
1640
1943
|
const result = new Map;
|
|
@@ -1709,6 +2012,10 @@ function buildQuery(issueNumbers) {
|
|
|
1709
2012
|
}
|
|
1710
2013
|
}`;
|
|
1711
2014
|
}
|
|
2015
|
+
// ../../packages/aeg-forge-state/src/list-issue-milestones.ts
|
|
2016
|
+
function issueMilestonesFromIssues(issues) {
|
|
2017
|
+
return issues.filter((i) => i.state === "OPEN").map((i) => ({ issue: i.number, milestoneTitle: i.milestone?.title ?? null }));
|
|
2018
|
+
}
|
|
1712
2019
|
// ../../packages/aeg-forge-state/src/resolve-repo.ts
|
|
1713
2020
|
import { execFile as execFile3 } from "node:child_process";
|
|
1714
2021
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -1771,7 +2078,8 @@ var ANCHOR_FIELDS = [
|
|
|
1771
2078
|
"PREMISE",
|
|
1772
2079
|
"TEST-PLAN",
|
|
1773
2080
|
"EVIDENCE",
|
|
1774
|
-
"BEYOND-SURFACE"
|
|
2081
|
+
"BEYOND-SURFACE",
|
|
2082
|
+
"LIVE"
|
|
1775
2083
|
];
|
|
1776
2084
|
function anchoredRegionBounds(body, field) {
|
|
1777
2085
|
const masked = maskCode(body);
|
|
@@ -1972,7 +2280,6 @@ var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
|
1972
2280
|
// ../../packages/aeg-core/src/waiver-label.ts
|
|
1973
2281
|
var WAIVER_LABEL = label("waiver-docs");
|
|
1974
2282
|
var WAIVER_LABEL_REVIEW = label("waiver-review");
|
|
1975
|
-
var PRINCIPAL_ALLOWLIST = ["daniboomerang"];
|
|
1976
2283
|
function isPrincipal(login, principalAllowlist) {
|
|
1977
2284
|
if (login === null)
|
|
1978
2285
|
return false;
|
|
@@ -1991,6 +2298,14 @@ var RULING_ORDINAL_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Ruling ordinal:\s*(\d+)(
|
|
|
1991
2298
|
var BRIEF_HASH_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Brief hash:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1992
2299
|
var POLICY_DIGEST_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Policy digest:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1993
2300
|
var BASE_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged base:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
|
|
2301
|
+
var MANIFEST_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Manifest version:\s*(\d+)\s*$/im;
|
|
2302
|
+
var PAUSE_BOUND_RULING_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Pause-bound ruling:\s*(?:(\S+)\|(\S+)\|([0-9a-f]{64})|\(none\))\s*$/im;
|
|
2303
|
+
function extractPauseBoundRuling(comment) {
|
|
2304
|
+
const m = comment.match(PAUSE_BOUND_RULING_PATTERN);
|
|
2305
|
+
if (!m)
|
|
2306
|
+
return;
|
|
2307
|
+
return m[1] ? { rulingId: m[1], pauseId: m[2], contentDigest: m[3] } : null;
|
|
2308
|
+
}
|
|
1994
2309
|
function firstFiveLines(comment) {
|
|
1995
2310
|
return comment.split(`
|
|
1996
2311
|
`).slice(0, 5).join(`
|
|
@@ -2084,6 +2399,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2084
2399
|
danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
|
|
2085
2400
|
};
|
|
2086
2401
|
}
|
|
2402
|
+
const versionMatch = latest.match(MANIFEST_VERSION_PATTERN);
|
|
2403
|
+
const pauseBoundRuling = extractPauseBoundRuling(latest);
|
|
2087
2404
|
return {
|
|
2088
2405
|
value: m[1].toUpperCase().replace(/[_-]/g, " "),
|
|
2089
2406
|
headSha: extractHeadSha(latest),
|
|
@@ -2092,6 +2409,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2092
2409
|
briefHash: extractBriefHash(latest),
|
|
2093
2410
|
policyDigest: extractPolicyDigest(latest),
|
|
2094
2411
|
baseSha: extractBaseSha(latest),
|
|
2412
|
+
...versionMatch ? { manifestVersion: Number.parseInt(versionMatch[1], 10) } : {},
|
|
2413
|
+
...pauseBoundRuling === undefined ? {} : { pauseBoundRuling },
|
|
2095
2414
|
findingSeverities: extractFindingSeverities(latest),
|
|
2096
2415
|
danglingNote: null
|
|
2097
2416
|
};
|
|
@@ -2102,6 +2421,16 @@ function extractCodeReviewVerdict(comments) {
|
|
|
2102
2421
|
function extractSecurityReviewVerdict(comments) {
|
|
2103
2422
|
return extractVerdict(comments, /^[ \t]*(?:\*{1,3}|_{1,3})?VERDICT:\s*(PASS|FAIL)(?![A-Za-z0-9])/im, "security-review");
|
|
2104
2423
|
}
|
|
2424
|
+
|
|
2425
|
+
// ../../packages/aeg-core/src/review-status.ts
|
|
2426
|
+
var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-(\d+)\s*-->/i;
|
|
2427
|
+
function parseDeveloperRoundMarker(body) {
|
|
2428
|
+
const m = body.match(DEVELOPER_ROUND_MARKER);
|
|
2429
|
+
if (!m)
|
|
2430
|
+
return null;
|
|
2431
|
+
const n = Number(m[1]);
|
|
2432
|
+
return Number.isFinite(n) ? n : null;
|
|
2433
|
+
}
|
|
2105
2434
|
// ../../packages/aeg-core/src/report-tokens.ts
|
|
2106
2435
|
var DASH_LOOKALIKES = {
|
|
2107
2436
|
"-": "‑",
|
|
@@ -2797,14 +3126,14 @@ function checkTestPlan(prBody) {
|
|
|
2797
3126
|
const region = located.found ? located.section : prBody;
|
|
2798
3127
|
if (TEST_PLAN_UNIT_TESTS_ONLY_RE.test(region))
|
|
2799
3128
|
return { status: "pass", errors: [] };
|
|
2800
|
-
if (/\*\*\[(?:agent|principal)\]\*\*/.test(region))
|
|
3129
|
+
if (/\*\*\[(?:agent|principal|live)\]\*\*/.test(region))
|
|
2801
3130
|
return { status: "pass", errors: [] };
|
|
2802
3131
|
if (located.found && extractFencedBlocks(region).length > 0)
|
|
2803
3132
|
return { status: "pass", errors: [] };
|
|
2804
3133
|
return {
|
|
2805
3134
|
status: "fail",
|
|
2806
3135
|
errors: [
|
|
2807
|
-
"brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`-tagged
|
|
3136
|
+
"brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`/`**[live]**`-tagged item."
|
|
2808
3137
|
]
|
|
2809
3138
|
};
|
|
2810
3139
|
}
|
|
@@ -3426,6 +3755,375 @@ function checkPrReportDensity(prBody) {
|
|
|
3426
3755
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3427
3756
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3428
3757
|
}
|
|
3758
|
+
// ../../packages/aeg-core/src/prose-rules.ts
|
|
3759
|
+
var RETIRED_GLOBAL_EXEMPTIONS = [
|
|
3760
|
+
"docs/decisions-legacy.md",
|
|
3761
|
+
"apps/herald-ai/docs/",
|
|
3762
|
+
"apps/vada-ai/docs/",
|
|
3763
|
+
"aeg-root/tranches/completed/",
|
|
3764
|
+
"packages/aeg-core/src/docs/published-prose",
|
|
3765
|
+
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
3766
|
+
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
3767
|
+
"/fixtures/",
|
|
3768
|
+
"/node_modules/",
|
|
3769
|
+
"/.next/",
|
|
3770
|
+
"/.turbo/"
|
|
3771
|
+
];
|
|
3772
|
+
var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
|
|
3773
|
+
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
3774
|
+
var RETIRED_PATTERN_EXEMPTIONS = {
|
|
3775
|
+
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
3776
|
+
[String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
|
|
3777
|
+
"docs-index.md",
|
|
3778
|
+
"apps/vada-ai/specs/legacy/README.md",
|
|
3779
|
+
"apps/vada-ai/specs/vada-product-spec.md",
|
|
3780
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3781
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3782
|
+
],
|
|
3783
|
+
"decisions-legacy": [
|
|
3784
|
+
"packages/aeg-core/src/file-classify.ts",
|
|
3785
|
+
"packages/aeg-core/src/file-classify.test.ts",
|
|
3786
|
+
"packages/aeg-core/src/pr-tier.test.ts",
|
|
3787
|
+
"docs-index.md",
|
|
3788
|
+
".claude/skills/database/SKILL.md",
|
|
3789
|
+
".claude/skills/vada-architecture/SKILL.md",
|
|
3790
|
+
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
3791
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3792
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3793
|
+
],
|
|
3794
|
+
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
3795
|
+
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
3796
|
+
};
|
|
3797
|
+
var retiredPatterns = [
|
|
3798
|
+
String.raw`\bD-[0-9]{3}\b`,
|
|
3799
|
+
"D-(###|NNN|nnn|xxx)",
|
|
3800
|
+
"decision (entry|logged)",
|
|
3801
|
+
"decision-log entry",
|
|
3802
|
+
"decision log entry",
|
|
3803
|
+
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
3804
|
+
"decision-log",
|
|
3805
|
+
"decision entr",
|
|
3806
|
+
"decisions? (are |is )?logged",
|
|
3807
|
+
"log entries",
|
|
3808
|
+
String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
|
|
3809
|
+
"decisions-legacy",
|
|
3810
|
+
"CONTRADICTION",
|
|
3811
|
+
"assumes Tier 3",
|
|
3812
|
+
"Lock: ?YES",
|
|
3813
|
+
"Lock: ?NO",
|
|
3814
|
+
"lock approvals?",
|
|
3815
|
+
"approves locks",
|
|
3816
|
+
"Conforms to lock",
|
|
3817
|
+
"Challenges lock",
|
|
3818
|
+
"checkDecisionNumbersFresh",
|
|
3819
|
+
String.raw`roles/team-leader\.md`,
|
|
3820
|
+
String.raw`\(,`,
|
|
3821
|
+
String.raw`,\)`,
|
|
3822
|
+
String.raw`\(\.\)`,
|
|
3823
|
+
...PLAN_ON_DISK_PATTERNS
|
|
3824
|
+
];
|
|
3825
|
+
var published = [
|
|
3826
|
+
["decision-id", "a decision id", /\bD-\d{3,}\b/],
|
|
3827
|
+
["section-ref", "a section reference", /§/],
|
|
3828
|
+
["forge-number", "a forge number", /#\d+/],
|
|
3829
|
+
["retired-name", "the retired public name", /\bAEG\b/],
|
|
3830
|
+
["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
|
|
3831
|
+
[
|
|
3832
|
+
"label-vocabulary",
|
|
3833
|
+
"forge label vocabulary",
|
|
3834
|
+
/(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
|
|
3835
|
+
],
|
|
3836
|
+
["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
|
|
3837
|
+
["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
|
|
3838
|
+
[
|
|
3839
|
+
"internal-path",
|
|
3840
|
+
"a repo-internal file",
|
|
3841
|
+
/(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
|
|
3842
|
+
]
|
|
3843
|
+
];
|
|
3844
|
+
var DEFAULT_PROSE_RULES = [
|
|
3845
|
+
{
|
|
3846
|
+
id: "forge-number",
|
|
3847
|
+
group: "reader-resolvable",
|
|
3848
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3849
|
+
patterns: { prose: /#[0-9]{2,4}/g },
|
|
3850
|
+
flags: ["global"],
|
|
3851
|
+
message: "a forge number",
|
|
3852
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3853
|
+
exemptions: []
|
|
3854
|
+
},
|
|
3855
|
+
{
|
|
3856
|
+
id: "tranche-slug",
|
|
3857
|
+
group: "reader-resolvable",
|
|
3858
|
+
scopes: ["ships", "reader-facing", "product", "spec"],
|
|
3859
|
+
patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
|
|
3860
|
+
flags: ["global"],
|
|
3861
|
+
message: "an internal tranche slug",
|
|
3862
|
+
severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
|
|
3863
|
+
exemptions: []
|
|
3864
|
+
},
|
|
3865
|
+
{
|
|
3866
|
+
id: "task-number",
|
|
3867
|
+
group: "reader-resolvable",
|
|
3868
|
+
scopes: ["spec"],
|
|
3869
|
+
patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
|
|
3870
|
+
flags: ["global", "ignore-case"],
|
|
3871
|
+
message: "a task number",
|
|
3872
|
+
severity: { spec: "error" },
|
|
3873
|
+
exemptions: []
|
|
3874
|
+
},
|
|
3875
|
+
{
|
|
3876
|
+
id: "source-comment-tranche-slug",
|
|
3877
|
+
group: "reader-resolvable",
|
|
3878
|
+
scopes: ["source-comment"],
|
|
3879
|
+
patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
|
|
3880
|
+
flags: ["global"],
|
|
3881
|
+
message: "a tranche-slug citation",
|
|
3882
|
+
severity: { "source-comment": "warning" },
|
|
3883
|
+
exemptions: []
|
|
3884
|
+
},
|
|
3885
|
+
{
|
|
3886
|
+
id: "source-comment-forge-number",
|
|
3887
|
+
group: "reader-resolvable",
|
|
3888
|
+
scopes: ["source-comment"],
|
|
3889
|
+
patterns: { comment: /#[0-9]{2,}/g },
|
|
3890
|
+
flags: ["global"],
|
|
3891
|
+
message: "a forge-number citation",
|
|
3892
|
+
severity: { "source-comment": "warning" },
|
|
3893
|
+
exemptions: []
|
|
3894
|
+
},
|
|
3895
|
+
{
|
|
3896
|
+
id: "legacy-batch-name",
|
|
3897
|
+
group: "reader-resolvable",
|
|
3898
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3899
|
+
patterns: {},
|
|
3900
|
+
flags: ["built-in"],
|
|
3901
|
+
message: "an internal tranche slug",
|
|
3902
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3903
|
+
exemptions: [],
|
|
3904
|
+
builtIn: true
|
|
3905
|
+
},
|
|
3906
|
+
{
|
|
3907
|
+
id: "coined-term",
|
|
3908
|
+
group: "reader-resolvable",
|
|
3909
|
+
scopes: ["ships", "reader-facing"],
|
|
3910
|
+
patterns: {},
|
|
3911
|
+
flags: ["built-in"],
|
|
3912
|
+
message: "uses coined term without defining it inline or linking the glossary",
|
|
3913
|
+
severity: { ships: "warning", "reader-facing": "warning" },
|
|
3914
|
+
exemptions: [],
|
|
3915
|
+
builtIn: true
|
|
3916
|
+
},
|
|
3917
|
+
...retiredPatterns.map((pattern, index) => ({
|
|
3918
|
+
id: `retired-vocabulary-${index + 1}`,
|
|
3919
|
+
group: "retired-vocabulary",
|
|
3920
|
+
scopes: ["repository"],
|
|
3921
|
+
patterns: { repository: pattern },
|
|
3922
|
+
flags: [],
|
|
3923
|
+
message: "retired vocabulary",
|
|
3924
|
+
severity: { repository: "error" },
|
|
3925
|
+
exemptions: RETIRED_GLOBAL_EXEMPTIONS,
|
|
3926
|
+
patternExemptions: RETIRED_PATTERN_EXEMPTIONS
|
|
3927
|
+
})),
|
|
3928
|
+
...published.map(([id, message, pattern]) => ({
|
|
3929
|
+
id,
|
|
3930
|
+
group: "published-prose",
|
|
3931
|
+
scopes: ["published"],
|
|
3932
|
+
patterns: { published: pattern },
|
|
3933
|
+
flags: [],
|
|
3934
|
+
message,
|
|
3935
|
+
severity: { published: "error" },
|
|
3936
|
+
exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
|
|
3937
|
+
}))
|
|
3938
|
+
];
|
|
3939
|
+
var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
|
|
3940
|
+
var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
|
|
3941
|
+
var RETIRED_SCOPES = ["repository"];
|
|
3942
|
+
var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
|
|
3943
|
+
function groupOfScope(scope) {
|
|
3944
|
+
if (RESOLVABLE_SCOPES.includes(scope))
|
|
3945
|
+
return "reader-resolvable";
|
|
3946
|
+
if (RETIRED_SCOPES.includes(scope))
|
|
3947
|
+
return "retired-vocabulary";
|
|
3948
|
+
return;
|
|
3949
|
+
}
|
|
3950
|
+
var CONFIGURED_PROSE_FLAGS = ["i", "u"];
|
|
3951
|
+
var CONFIGURED_PATTERN_MAX_LENGTH = 200;
|
|
3952
|
+
var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
|
|
3953
|
+
function allowedScopesFor(rule) {
|
|
3954
|
+
if (rule.builtIn)
|
|
3955
|
+
return rule.scopes;
|
|
3956
|
+
return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
|
|
3957
|
+
}
|
|
3958
|
+
function normalizeRepoPath(entry) {
|
|
3959
|
+
let out = entry.replace(/\\/g, "/");
|
|
3960
|
+
while (out.startsWith("./"))
|
|
3961
|
+
out = out.slice(2);
|
|
3962
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3963
|
+
while (out.endsWith("/"))
|
|
3964
|
+
out = out.slice(0, -1);
|
|
3965
|
+
return out;
|
|
3966
|
+
}
|
|
3967
|
+
function isConfiguredExempt(path, exempt, repoRoot) {
|
|
3968
|
+
if (exempt.length === 0)
|
|
3969
|
+
return false;
|
|
3970
|
+
const root = repoRoot === undefined ? undefined : normalizeRepoPath(repoRoot);
|
|
3971
|
+
let rel = normalizeRepoPath(path);
|
|
3972
|
+
if (root && rel.startsWith(`${root}/`))
|
|
3973
|
+
rel = rel.slice(root.length + 1);
|
|
3974
|
+
return exempt.some((entry) => {
|
|
3975
|
+
const e = normalizeRepoPath(entry);
|
|
3976
|
+
return rel === e || rel.startsWith(`${e}/`);
|
|
3977
|
+
});
|
|
3978
|
+
}
|
|
3979
|
+
function ruleReads(set, rule, path) {
|
|
3980
|
+
return !isConfiguredExempt(path, set.exempt, set.repoRoot) && !isConfiguredExempt(path, rule.exempt, set.repoRoot);
|
|
3981
|
+
}
|
|
3982
|
+
var RESOLVABLE_RUN_ORDER = [
|
|
3983
|
+
"forge-number",
|
|
3984
|
+
"tranche-slug",
|
|
3985
|
+
"legacy-batch-name",
|
|
3986
|
+
"task-number",
|
|
3987
|
+
"source-comment-tranche-slug",
|
|
3988
|
+
"source-comment-forge-number",
|
|
3989
|
+
"coined-term"
|
|
3990
|
+
];
|
|
3991
|
+
var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
|
|
3992
|
+
function scopeDefaultSeverity(scope, sourceCommentSeverity) {
|
|
3993
|
+
if (scope === "source-comment")
|
|
3994
|
+
return sourceCommentSeverity ?? "warning";
|
|
3995
|
+
if (scope === "repository")
|
|
3996
|
+
return "error";
|
|
3997
|
+
return "warning";
|
|
3998
|
+
}
|
|
3999
|
+
function applySeverity(scopes, base, setting) {
|
|
4000
|
+
const out = {};
|
|
4001
|
+
for (const scope of scopes) {
|
|
4002
|
+
const configured = typeof setting === "string" ? setting : setting?.[scope];
|
|
4003
|
+
const value = configured ?? base[scope];
|
|
4004
|
+
if (value !== undefined)
|
|
4005
|
+
out[scope] = value;
|
|
4006
|
+
}
|
|
4007
|
+
return out;
|
|
4008
|
+
}
|
|
4009
|
+
function defaultPatternFor(rule) {
|
|
4010
|
+
const cache = new Map;
|
|
4011
|
+
return (scope) => {
|
|
4012
|
+
if (cache.has(scope))
|
|
4013
|
+
return cache.get(scope) ?? null;
|
|
4014
|
+
const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
|
|
4015
|
+
const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
|
|
4016
|
+
cache.set(scope, compiled);
|
|
4017
|
+
return compiled;
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
function customPatternFor(rule, global) {
|
|
4021
|
+
const cache = new Map;
|
|
4022
|
+
return (scope) => {
|
|
4023
|
+
if (cache.has(scope))
|
|
4024
|
+
return cache.get(scope) ?? null;
|
|
4025
|
+
const source = rule.patterns?.[scope] ?? rule.pattern;
|
|
4026
|
+
const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
|
|
4027
|
+
cache.set(scope, compiled);
|
|
4028
|
+
return compiled;
|
|
4029
|
+
};
|
|
4030
|
+
}
|
|
4031
|
+
function resolveProseRules(config = undefined, options = {}) {
|
|
4032
|
+
const rules = [];
|
|
4033
|
+
const defaults = config?.defaults ?? {};
|
|
4034
|
+
for (const rule of CONFIGURABLE_DEFAULT_RULES) {
|
|
4035
|
+
const override = defaults[rule.id];
|
|
4036
|
+
if (override === "off")
|
|
4037
|
+
continue;
|
|
4038
|
+
const group = rule.group;
|
|
4039
|
+
const scopes = override?.scopes ?? rule.scopes;
|
|
4040
|
+
const base = {};
|
|
4041
|
+
for (const scope of scopes) {
|
|
4042
|
+
base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4043
|
+
}
|
|
4044
|
+
rules.push({
|
|
4045
|
+
id: rule.id,
|
|
4046
|
+
group,
|
|
4047
|
+
custom: false,
|
|
4048
|
+
builtIn: rule.builtIn === true,
|
|
4049
|
+
scopes,
|
|
4050
|
+
message: rule.message,
|
|
4051
|
+
severity: applySeverity(scopes, base, override?.severity),
|
|
4052
|
+
exempt: override?.exempt ?? [],
|
|
4053
|
+
substringExempt: rule.exemptions,
|
|
4054
|
+
reportGroup: REPORT_GROUPS[rule.id],
|
|
4055
|
+
patternFor: defaultPatternFor(rule)
|
|
4056
|
+
});
|
|
4057
|
+
}
|
|
4058
|
+
for (const rule of config?.custom ?? []) {
|
|
4059
|
+
const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
|
|
4060
|
+
const base = {};
|
|
4061
|
+
for (const scope of rule.scopes)
|
|
4062
|
+
base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4063
|
+
rules.push({
|
|
4064
|
+
id: rule.id,
|
|
4065
|
+
group,
|
|
4066
|
+
custom: true,
|
|
4067
|
+
builtIn: false,
|
|
4068
|
+
scopes: rule.scopes,
|
|
4069
|
+
message: rule.means,
|
|
4070
|
+
severity: applySeverity(rule.scopes, base, rule.severity),
|
|
4071
|
+
exempt: rule.exempt ?? [],
|
|
4072
|
+
substringExempt: [],
|
|
4073
|
+
patternFor: customPatternFor(rule, group === "reader-resolvable")
|
|
4074
|
+
});
|
|
4075
|
+
}
|
|
4076
|
+
if (options.decisionRecordsPath !== undefined)
|
|
4077
|
+
rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
|
|
4078
|
+
const order = (rule) => {
|
|
4079
|
+
const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
|
|
4080
|
+
return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
|
|
4081
|
+
};
|
|
4082
|
+
const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
|
|
4083
|
+
const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
|
|
4084
|
+
return {
|
|
4085
|
+
rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
|
|
4086
|
+
exempt: config?.exempt ?? [],
|
|
4087
|
+
repoRoot: options.repoRoot
|
|
4088
|
+
};
|
|
4089
|
+
}
|
|
4090
|
+
function rulesOfGroup(set, group) {
|
|
4091
|
+
return set.rules.filter((rule) => rule.group === group);
|
|
4092
|
+
}
|
|
4093
|
+
function rulesInScope(set, scope) {
|
|
4094
|
+
return set.rules.filter((rule) => rule.scopes.includes(scope));
|
|
4095
|
+
}
|
|
4096
|
+
var DEFAULT_PROSE_RULE_SET = resolveProseRules();
|
|
4097
|
+
var DECISION_RECORD_CITATION_ID = "decision-record-citation";
|
|
4098
|
+
var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
|
|
4099
|
+
var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
|
|
4100
|
+
function escapeRegExp(text) {
|
|
4101
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4102
|
+
}
|
|
4103
|
+
function decisionRecordCitationPattern(decisionRecordsPath) {
|
|
4104
|
+
const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
|
|
4105
|
+
return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
|
|
4106
|
+
}
|
|
4107
|
+
function decisionRecordCitationRule(decisionRecordsPath) {
|
|
4108
|
+
const folder = normalizeRepoPath(decisionRecordsPath);
|
|
4109
|
+
const pattern = decisionRecordCitationPattern(folder);
|
|
4110
|
+
const severity = {};
|
|
4111
|
+
for (const scope of DECISION_RECORD_CITATION_SCOPES)
|
|
4112
|
+
severity[scope] = "error";
|
|
4113
|
+
return {
|
|
4114
|
+
id: DECISION_RECORD_CITATION_ID,
|
|
4115
|
+
group: "reader-resolvable",
|
|
4116
|
+
custom: false,
|
|
4117
|
+
builtIn: false,
|
|
4118
|
+
scopes: DECISION_RECORD_CITATION_SCOPES,
|
|
4119
|
+
message: DECISION_RECORD_CITATION_MESSAGE,
|
|
4120
|
+
severity,
|
|
4121
|
+
exempt: [folder],
|
|
4122
|
+
substringExempt: [],
|
|
4123
|
+
patternFor: () => pattern
|
|
4124
|
+
};
|
|
4125
|
+
}
|
|
4126
|
+
|
|
3429
4127
|
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3430
4128
|
var PRODUCT_SLUG_SCOPE = [
|
|
3431
4129
|
"apps/cli/src",
|
|
@@ -3437,8 +4135,8 @@ var PRODUCT_SLUG_SCOPE = [
|
|
|
3437
4135
|
function isUnderOrEqual(path, prefix) {
|
|
3438
4136
|
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3439
4137
|
}
|
|
3440
|
-
function isProductScopeFile(path) {
|
|
3441
|
-
return
|
|
4138
|
+
function isProductScopeFile(path, productPaths) {
|
|
4139
|
+
return productPaths.some((prefix) => isUnderOrEqual(path, normalizeRepoPath(prefix)));
|
|
3442
4140
|
}
|
|
3443
4141
|
var SHIPS_PREFIX = "aeg-root/";
|
|
3444
4142
|
function shipsArchivePrefix(shipsPrefix) {
|
|
@@ -3446,13 +4144,7 @@ function shipsArchivePrefix(shipsPrefix) {
|
|
|
3446
4144
|
}
|
|
3447
4145
|
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3448
4146
|
function normalizeSpecPath(entry) {
|
|
3449
|
-
|
|
3450
|
-
while (out.startsWith("./"))
|
|
3451
|
-
out = out.slice(2);
|
|
3452
|
-
out = out.replace(/\/{2,}/g, "/");
|
|
3453
|
-
while (out.endsWith("/"))
|
|
3454
|
-
out = out.slice(0, -1);
|
|
3455
|
-
return out;
|
|
4147
|
+
return normalizeRepoPath(entry);
|
|
3456
4148
|
}
|
|
3457
4149
|
function isSpecFile2(path, specPaths) {
|
|
3458
4150
|
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
@@ -3464,7 +4156,7 @@ function isSpecFile2(path, specPaths) {
|
|
|
3464
4156
|
function isClaudeMdFile(path) {
|
|
3465
4157
|
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3466
4158
|
}
|
|
3467
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4159
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS, productPaths = PRODUCT_SLUG_SCOPE) {
|
|
3468
4160
|
if (path.startsWith(shipsPrefix)) {
|
|
3469
4161
|
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3470
4162
|
}
|
|
@@ -3475,7 +4167,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
|
|
|
3475
4167
|
return "internal";
|
|
3476
4168
|
if (isSpecFile2(path, specPaths))
|
|
3477
4169
|
return "spec";
|
|
3478
|
-
if (isProductScopeFile(path))
|
|
4170
|
+
if (isProductScopeFile(path, productPaths))
|
|
3479
4171
|
return "product";
|
|
3480
4172
|
return null;
|
|
3481
4173
|
}
|
|
@@ -3500,9 +4192,16 @@ function lineAt(content, index) {
|
|
|
3500
4192
|
}
|
|
3501
4193
|
return line;
|
|
3502
4194
|
}
|
|
3503
|
-
var
|
|
3504
|
-
var
|
|
3505
|
-
|
|
4195
|
+
var readerRules = rulesForGroup("reader-resolvable");
|
|
4196
|
+
var readerPattern = (id, scope = "prose") => {
|
|
4197
|
+
const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
|
|
4198
|
+
if (!(pattern instanceof RegExp))
|
|
4199
|
+
throw new Error(`default prose rule ${id} has no ${scope} pattern`);
|
|
4200
|
+
return pattern;
|
|
4201
|
+
};
|
|
4202
|
+
var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
|
|
4203
|
+
var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
|
|
4204
|
+
var TASK_NUMBER_PATTERN = readerPattern("task-number");
|
|
3506
4205
|
function legacySlugPattern(legacySlugs) {
|
|
3507
4206
|
if (legacySlugs.length === 0)
|
|
3508
4207
|
return null;
|
|
@@ -3512,48 +4211,61 @@ function legacySlugPattern(legacySlugs) {
|
|
|
3512
4211
|
function specGrandfatherPaths(specGrandfather) {
|
|
3513
4212
|
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
|
|
3514
4213
|
}
|
|
3515
|
-
|
|
4214
|
+
var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
|
|
4215
|
+
function referenceRulesFor(set, cls) {
|
|
4216
|
+
return rulesInScope(set, cls).filter((rule) => rule.group === "reader-resolvable" && rule.id !== "coined-term");
|
|
4217
|
+
}
|
|
4218
|
+
function citations(pattern, text, group) {
|
|
4219
|
+
const out = [];
|
|
4220
|
+
const re = pattern.global ? pattern : new RegExp(pattern.source, `${pattern.flags}g`);
|
|
4221
|
+
re.lastIndex = 0;
|
|
4222
|
+
let match = re.exec(text);
|
|
4223
|
+
while (match !== null) {
|
|
4224
|
+
if (match[0] === "") {
|
|
4225
|
+
re.lastIndex++;
|
|
4226
|
+
} else {
|
|
4227
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4228
|
+
out.push({ cited, index: match.index + match[0].indexOf(cited) });
|
|
4229
|
+
}
|
|
4230
|
+
match = re.exec(text);
|
|
4231
|
+
}
|
|
4232
|
+
re.lastIndex = 0;
|
|
4233
|
+
return out;
|
|
4234
|
+
}
|
|
4235
|
+
function customMessage(rule, cited) {
|
|
4236
|
+
return `${rule.id}: ${rule.message} ("${cited}")`;
|
|
4237
|
+
}
|
|
4238
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
4239
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4240
|
+
const productPaths = options.productPaths ?? PRODUCT_SLUG_SCOPE;
|
|
3516
4241
|
const findings = [];
|
|
3517
4242
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3518
4243
|
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
|
|
3519
4244
|
const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
|
|
3520
|
-
const patterns = [
|
|
3521
|
-
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3522
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3523
|
-
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3524
|
-
];
|
|
3525
|
-
const productPatterns = [
|
|
3526
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3527
|
-
];
|
|
3528
|
-
const specPatterns = [
|
|
3529
|
-
...patterns,
|
|
3530
|
-
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3531
|
-
];
|
|
3532
4245
|
for (const file of files) {
|
|
3533
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3534
|
-
if (!cls || cls
|
|
3535
|
-
continue;
|
|
3536
|
-
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
4246
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths, productPaths);
|
|
4247
|
+
if (!cls || !REFERENCE_CLASSES.has(cls))
|
|
3537
4248
|
continue;
|
|
3538
4249
|
if (cls === "spec" && grandfatheredWhole.has(file.path))
|
|
3539
4250
|
continue;
|
|
3540
|
-
const blocking = cls === "product" || cls === "spec";
|
|
3541
4251
|
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3542
|
-
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3543
4252
|
const fileFindings = [];
|
|
3544
|
-
for (const
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
4253
|
+
for (const rule of referenceRulesFor(set, cls)) {
|
|
4254
|
+
if (!ruleReads(set, rule, file.path))
|
|
4255
|
+
continue;
|
|
4256
|
+
const pattern = !rule.custom && rule.id === "legacy-batch-name" ? legacyPattern : rule.patternFor(cls);
|
|
4257
|
+
if (!pattern)
|
|
4258
|
+
continue;
|
|
4259
|
+
const blocking = rule.severity[cls] === "error";
|
|
4260
|
+
const what = cls === "product" ? `${rule.message} in product code` : rule.message;
|
|
4261
|
+
for (const { cited, index } of citations(pattern, scrubbed, rule.custom ? undefined : rule.reportGroup)) {
|
|
3550
4262
|
fileFindings.push({
|
|
3551
4263
|
file: file.path,
|
|
3552
|
-
line: lineAt(scrubbed,
|
|
3553
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3554
|
-
blocking
|
|
4264
|
+
line: lineAt(scrubbed, index),
|
|
4265
|
+
message: rule.custom ? customMessage(rule, cited) : `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4266
|
+
blocking,
|
|
4267
|
+
rule: rule.id
|
|
3555
4268
|
});
|
|
3556
|
-
match = pattern.exec(scrubbed);
|
|
3557
4269
|
}
|
|
3558
4270
|
}
|
|
3559
4271
|
const limit = cls === "spec" ? limits.get(file.path) : undefined;
|
|
@@ -3594,11 +4306,17 @@ function definesOrLinksGlossary(content, term) {
|
|
|
3594
4306
|
return true;
|
|
3595
4307
|
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3596
4308
|
}
|
|
3597
|
-
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4309
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, options = {}) {
|
|
3598
4310
|
const findings = [];
|
|
4311
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4312
|
+
const rule = set.rules.find((r) => !r.custom && r.id === "coined-term");
|
|
4313
|
+
if (!rule)
|
|
4314
|
+
return findings;
|
|
3599
4315
|
for (const file of files) {
|
|
3600
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3601
|
-
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
4316
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, DEFAULT_SPEC_PATHS, options.productPaths);
|
|
4317
|
+
if (!cls || !SWEPT_CLASSES.has(cls) || !rule.scopes.includes(cls))
|
|
4318
|
+
continue;
|
|
4319
|
+
if (!ruleReads(set, rule, file.path))
|
|
3602
4320
|
continue;
|
|
3603
4321
|
const scrubbed = stripNonProse(file.path, file.content);
|
|
3604
4322
|
for (const term of glossaryTerms) {
|
|
@@ -3611,14 +4329,15 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
|
|
|
3611
4329
|
file: file.path,
|
|
3612
4330
|
line,
|
|
3613
4331
|
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3614
|
-
blocking:
|
|
4332
|
+
blocking: rule.severity[cls] === "error",
|
|
4333
|
+
rule: rule.id
|
|
3615
4334
|
});
|
|
3616
4335
|
}
|
|
3617
4336
|
}
|
|
3618
4337
|
return findings;
|
|
3619
4338
|
}
|
|
3620
|
-
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN =
|
|
3621
|
-
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN =
|
|
4339
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
|
|
4340
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
|
|
3622
4341
|
function extractComments(path, content) {
|
|
3623
4342
|
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3624
4343
|
return content.replace(/[^\n]/g, "");
|
|
@@ -3715,39 +4434,40 @@ function extractComments(path, content) {
|
|
|
3715
4434
|
}
|
|
3716
4435
|
return out;
|
|
3717
4436
|
}
|
|
3718
|
-
function checkSourceComments(files, allowlist = []) {
|
|
4437
|
+
function checkSourceComments(files, allowlist = [], options = {}) {
|
|
3719
4438
|
const findings = [];
|
|
3720
4439
|
const allowed = new Set(allowlist);
|
|
3721
|
-
const
|
|
3722
|
-
|
|
3723
|
-
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3724
|
-
];
|
|
4440
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4441
|
+
const rules = rulesInScope(set, "source-comment").filter((rule) => rule.group === "reader-resolvable");
|
|
3725
4442
|
for (const file of files) {
|
|
3726
4443
|
if (!file.path.endsWith(".ts"))
|
|
3727
4444
|
continue;
|
|
3728
4445
|
if (allowed.has(file.path))
|
|
3729
4446
|
continue;
|
|
3730
4447
|
const comments = extractComments(file.path, file.content);
|
|
3731
|
-
for (const
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
4448
|
+
for (const rule of rules) {
|
|
4449
|
+
if (!ruleReads(set, rule, file.path))
|
|
4450
|
+
continue;
|
|
4451
|
+
const pattern = rule.patternFor("source-comment");
|
|
4452
|
+
if (!pattern)
|
|
4453
|
+
continue;
|
|
4454
|
+
for (const { cited, index } of citations(pattern, comments)) {
|
|
3735
4455
|
findings.push({
|
|
3736
4456
|
file: file.path,
|
|
3737
|
-
line: lineAt(comments,
|
|
3738
|
-
message: `comment cites ${
|
|
3739
|
-
blocking:
|
|
4457
|
+
line: lineAt(comments, index),
|
|
4458
|
+
message: rule.custom ? customMessage(rule, cited) : `comment cites ${rule.message} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4459
|
+
blocking: rule.severity["source-comment"] === "error",
|
|
4460
|
+
rule: rule.id
|
|
3740
4461
|
});
|
|
3741
|
-
match = pattern.exec(comments);
|
|
3742
4462
|
}
|
|
3743
4463
|
}
|
|
3744
4464
|
}
|
|
3745
4465
|
return findings;
|
|
3746
4466
|
}
|
|
3747
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4467
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
3748
4468
|
return [
|
|
3749
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3750
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4469
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths, options),
|
|
4470
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix, options)
|
|
3751
4471
|
];
|
|
3752
4472
|
}
|
|
3753
4473
|
function parseGlossaryTerms(glossaryContent) {
|
|
@@ -3950,6 +4670,17 @@ function checkDocClaims(files, fileReader) {
|
|
|
3950
4670
|
};
|
|
3951
4671
|
}
|
|
3952
4672
|
|
|
4673
|
+
// ../../packages/aeg-core/src/protected-paths.ts
|
|
4674
|
+
import { posix as posixPath } from "node:path";
|
|
4675
|
+
var PROTECTED_ADMIN_PATHS = ["vinaya.config.json", ".vinaya/doc-owners", ".github/", "aeg-root/"];
|
|
4676
|
+
function normalizeTouchedPath(path) {
|
|
4677
|
+
return posixPath.resolve("/", path.replace(/\\/g, "/")).replace(/^\/+/, "");
|
|
4678
|
+
}
|
|
4679
|
+
function isProtectedAdminPath(path) {
|
|
4680
|
+
const normalized = normalizeTouchedPath(path);
|
|
4681
|
+
return PROTECTED_ADMIN_PATHS.some((prefix) => normalized === prefix || normalized.startsWith(prefix));
|
|
4682
|
+
}
|
|
4683
|
+
|
|
3953
4684
|
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3954
4685
|
function hasRationaleField(body, labelPattern) {
|
|
3955
4686
|
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
@@ -4069,13 +4800,20 @@ function globCoversPath(glob, path) {
|
|
|
4069
4800
|
return !p.includes("/");
|
|
4070
4801
|
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
4071
4802
|
}
|
|
4803
|
+
function surfaceEntryResolves(entry, resolvesToFile, pinnedFiles) {
|
|
4804
|
+
if (resolvesToFile(entry))
|
|
4805
|
+
return true;
|
|
4806
|
+
const directory = entry.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
4807
|
+
return pinnedFiles.some((path) => path.startsWith(`${directory}/`));
|
|
4808
|
+
}
|
|
4072
4809
|
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
4073
4810
|
const surface = parseIssueSurface(body);
|
|
4074
4811
|
if (!surface.ok)
|
|
4075
4812
|
return { status: "pass", errors: [] };
|
|
4813
|
+
const pinnedFiles = boundaryPinnedFiles(body);
|
|
4076
4814
|
const errors = [];
|
|
4077
4815
|
for (const glob of surface.value.in) {
|
|
4078
|
-
if (!
|
|
4816
|
+
if (!surfaceEntryResolves(glob, resolvesToFile, pinnedFiles)) {
|
|
4079
4817
|
errors.push(`issue-validation Surface: \`${glob}\` in \`## Surface\`'s \`in:\` list matches no tracked file — a Surface that cannot resolve cannot render a brief's file list.`);
|
|
4080
4818
|
}
|
|
4081
4819
|
}
|
|
@@ -4105,6 +4843,14 @@ function recordedBeyondSurfacePaths(body) {
|
|
|
4105
4843
|
return paths;
|
|
4106
4844
|
}
|
|
4107
4845
|
function checkSurfaceScope(changedFiles, surface, recorded) {
|
|
4846
|
+
for (const path of changedFiles) {
|
|
4847
|
+
if (!isProtectedAdminPath(path))
|
|
4848
|
+
continue;
|
|
4849
|
+
const normalized = normalizeTouchedPath(path);
|
|
4850
|
+
if (!surface.in.some((glob) => globCoversPath(glob, normalized))) {
|
|
4851
|
+
return { ok: false, violation: { path, reason: "protected" } };
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4108
4854
|
const listed = new Set(recorded);
|
|
4109
4855
|
const violation = beyondSurfacePaths(changedFiles, surface).find((entry) => !listed.has(entry.path));
|
|
4110
4856
|
return violation ? { ok: false, violation } : { ok: true };
|
|
@@ -4160,12 +4906,22 @@ function checkPartsCiteDefinedObjectives(body) {
|
|
|
4160
4906
|
}
|
|
4161
4907
|
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4162
4908
|
}
|
|
4909
|
+
var ISSUE_LIVE_LINE_RE = /^-\s*\*{2}\[live\]\*{2}(.*)$/gim;
|
|
4910
|
+
function liveCommand(text) {
|
|
4911
|
+
const trimmed = text.trim();
|
|
4912
|
+
const span = /^(`+)(.+)\1$/.exec(trimmed);
|
|
4913
|
+
return span ? span[2].trim() : trimmed;
|
|
4914
|
+
}
|
|
4915
|
+
function liveItemsIn(region) {
|
|
4916
|
+
return [...region.matchAll(ISSUE_LIVE_LINE_RE)].map((m) => liveCommand(m[1] ?? "")).filter(Boolean);
|
|
4917
|
+
}
|
|
4918
|
+
function parseLiveTestPlanItems(body) {
|
|
4919
|
+
const located = locateTestPlanSection(body);
|
|
4920
|
+
return located.found ? liveItemsIn(located.section) : [];
|
|
4921
|
+
}
|
|
4163
4922
|
function isTaskIssueLabelSet(labels) {
|
|
4164
4923
|
return hasLabel("tranche", labels);
|
|
4165
4924
|
}
|
|
4166
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
4167
|
-
return { status: "pass", errors: [] };
|
|
4168
|
-
}
|
|
4169
4925
|
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4170
4926
|
if (!isTaskIssueLabelSet(labels))
|
|
4171
4927
|
return { status: "pass", errors: [] };
|
|
@@ -4181,6 +4937,7 @@ function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTi
|
|
|
4181
4937
|
};
|
|
4182
4938
|
}
|
|
4183
4939
|
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4940
|
+
var PATH_TEXT = (body) => stripCode(body, { inlineSpans: "keep" });
|
|
4184
4941
|
function isControlCodePoint(codePoint) {
|
|
4185
4942
|
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4186
4943
|
}
|
|
@@ -4241,8 +4998,14 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
|
4241
4998
|
}
|
|
4242
4999
|
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4243
5000
|
}
|
|
5001
|
+
function rationaleFieldText(text, labelPattern) {
|
|
5002
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})[^\\n]*\\n?([\\s\\S]*?)(?=\\n\\s*(?:\\*\\*[A-Z]|#{1,4}\\s)|(?![\\s\\S]))`, "im");
|
|
5003
|
+
const m = re.exec(text);
|
|
5004
|
+
return m ? m[0] : "";
|
|
5005
|
+
}
|
|
4244
5006
|
var DOC_PATH_RE = /(?:(?:aeg-root|apps|packages|specs|docs|tools|\.claude|\.github)\/[\w./@-]*\.(?:md|mdx)|\.claude\/(?:skills|rules)\/[\w./-]+|\b(?:docs-index|decisions|projects|state-machine|enforcement|process|README|CLAUDE)\.md\b|\b[\w-]+-(?:spec|decisions|backlog)\.md\b)/i;
|
|
4245
5007
|
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
5008
|
+
var RATIONALE_PATH_RE_GLOBAL = /`([\w.@-]+(?:\/[\w.@-]+)+)`/g;
|
|
4246
5009
|
function normalizeEdgeId(s) {
|
|
4247
5010
|
const qualified = splitSlugQualifiedEdge(s);
|
|
4248
5011
|
return (qualified ? qualified.bareId : s).replace(/^#/, "").trim();
|
|
@@ -4250,6 +5013,15 @@ function normalizeEdgeId(s) {
|
|
|
4250
5013
|
function edgesNameEachOther(a, b) {
|
|
4251
5014
|
return a.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(b.ref)) || b.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(a.ref));
|
|
4252
5015
|
}
|
|
5016
|
+
var BOUNDARY_OUT_RE = /\bOut\s*:\s*([\s\S]*)$/im;
|
|
5017
|
+
function boundaryOutText(body) {
|
|
5018
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5019
|
+
const m = BOUNDARY_OUT_RE.exec(boundary);
|
|
5020
|
+
return m ? m[1] : "";
|
|
5021
|
+
}
|
|
5022
|
+
function namedPathsIn(text) {
|
|
5023
|
+
return [...new Set([...text.matchAll(RATIONALE_PATH_RE_GLOBAL)].map((m) => m[1]))].filter((p) => !/^https?:\/\//i.test(p));
|
|
5024
|
+
}
|
|
4253
5025
|
var FILE_EXTENSIONS = new Set([
|
|
4254
5026
|
"ts",
|
|
4255
5027
|
"tsx",
|
|
@@ -4271,6 +5043,11 @@ var FILE_EXTENSIONS = new Set([
|
|
|
4271
5043
|
"html",
|
|
4272
5044
|
"css"
|
|
4273
5045
|
]);
|
|
5046
|
+
function boundaryPinnedFiles(body) {
|
|
5047
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5048
|
+
const excluded = new Set(namedPathsIn(boundaryOutText(body)));
|
|
5049
|
+
return namedPathsIn(boundary).filter((p) => looksLikeFilePath(p) && !excluded.has(p));
|
|
5050
|
+
}
|
|
4274
5051
|
var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
|
|
4275
5052
|
var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
|
|
4276
5053
|
|
|
@@ -4295,7 +5072,7 @@ function isGrandfathered(isoDate) {
|
|
|
4295
5072
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4296
5073
|
}
|
|
4297
5074
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4298
|
-
function checkA1(entries, principalAllowlist
|
|
5075
|
+
function checkA1(entries, principalAllowlist) {
|
|
4299
5076
|
const failures = [];
|
|
4300
5077
|
for (const e of entries) {
|
|
4301
5078
|
if (!e.facts)
|
|
@@ -4325,6 +5102,37 @@ function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
|
4325
5102
|
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4326
5103
|
};
|
|
4327
5104
|
}
|
|
5105
|
+
function checkA2(entries, hasProvenanceByKey) {
|
|
5106
|
+
const failures = [];
|
|
5107
|
+
for (const e of entries) {
|
|
5108
|
+
if (!e.facts)
|
|
5109
|
+
continue;
|
|
5110
|
+
if (e.facts.issueState !== "closed" || e.facts.prState !== "merged")
|
|
5111
|
+
continue;
|
|
5112
|
+
const key = `${e.trancheSlug}/${e.task.id}`;
|
|
5113
|
+
const hasProvenance = hasProvenanceByKey.get(key);
|
|
5114
|
+
if (hasProvenance === undefined)
|
|
5115
|
+
continue;
|
|
5116
|
+
if (!hasProvenance) {
|
|
5117
|
+
failures.push({
|
|
5118
|
+
code: "archived-without-provenance",
|
|
5119
|
+
issue: e.task.issue,
|
|
5120
|
+
tranche: e.trancheSlug,
|
|
5121
|
+
task: e.task.id,
|
|
5122
|
+
reason: "Closing PR has no `### AEG provenance` comment (Archivist close-out missing)",
|
|
5123
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
5124
|
+
});
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
5127
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
5128
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
5129
|
+
return {
|
|
5130
|
+
check: "A2",
|
|
5131
|
+
status,
|
|
5132
|
+
failures,
|
|
5133
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
5134
|
+
};
|
|
5135
|
+
}
|
|
4328
5136
|
function checkA3(entries) {
|
|
4329
5137
|
const failures = [];
|
|
4330
5138
|
for (const e of entries) {
|
|
@@ -4540,6 +5348,33 @@ function checkL1(files, entriesBySlug) {
|
|
|
4540
5348
|
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4541
5349
|
};
|
|
4542
5350
|
}
|
|
5351
|
+
function checkL2(files, entriesBySlug) {
|
|
5352
|
+
const failures = [];
|
|
5353
|
+
for (const f of files) {
|
|
5354
|
+
if (!f.archived)
|
|
5355
|
+
continue;
|
|
5356
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
5357
|
+
for (const e of entries) {
|
|
5358
|
+
if (!e.facts)
|
|
5359
|
+
continue;
|
|
5360
|
+
if (e.facts.issueState === "open") {
|
|
5361
|
+
failures.push({
|
|
5362
|
+
code: "premature-archive",
|
|
5363
|
+
issue: e.task.issue,
|
|
5364
|
+
tranche: f.slug,
|
|
5365
|
+
task: e.task.id,
|
|
5366
|
+
reason: `Archived tranche has open task-Issue #${e.task.issue ?? "?"} (premature archive)`
|
|
5367
|
+
});
|
|
5368
|
+
}
|
|
5369
|
+
}
|
|
5370
|
+
}
|
|
5371
|
+
return {
|
|
5372
|
+
check: "L2",
|
|
5373
|
+
status: "info",
|
|
5374
|
+
failures,
|
|
5375
|
+
note: failures.length > 0 ? `${failures.length} archived tranche(s) with an open task-Issue — investigate (advisory)` : undefined
|
|
5376
|
+
};
|
|
5377
|
+
}
|
|
4543
5378
|
function checkL3(files) {
|
|
4544
5379
|
const active = files.filter((f) => !f.archived);
|
|
4545
5380
|
return {
|
|
@@ -4549,6 +5384,51 @@ function checkL3(files) {
|
|
|
4549
5384
|
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4550
5385
|
};
|
|
4551
5386
|
}
|
|
5387
|
+
function checkL4(activeTrancheSlugs, issueMilestones) {
|
|
5388
|
+
const activeSet = new Set(activeTrancheSlugs);
|
|
5389
|
+
const failures = [];
|
|
5390
|
+
for (const f of issueMilestones) {
|
|
5391
|
+
if (!activeSet.has(f.tranche))
|
|
5392
|
+
continue;
|
|
5393
|
+
if (f.milestoneTitle === f.tranche)
|
|
5394
|
+
continue;
|
|
5395
|
+
failures.push({
|
|
5396
|
+
code: "milestone-drift",
|
|
5397
|
+
issue: f.issue,
|
|
5398
|
+
tranche: f.tranche,
|
|
5399
|
+
reason: f.milestoneTitle === null ? `Issue #${f.issue} carries ${trancheLabel(f.tranche)} (active) but has no GitHub-native milestone attached` : `Issue #${f.issue} carries ${trancheLabel(f.tranche)} (active) but is attached to Milestone "${f.milestoneTitle}" instead`
|
|
5400
|
+
});
|
|
5401
|
+
}
|
|
5402
|
+
return {
|
|
5403
|
+
check: "L4",
|
|
5404
|
+
status: "info",
|
|
5405
|
+
failures,
|
|
5406
|
+
note: failures.length > 0 ? `${failures.length} open task-Issue(s) in an active tranche whose GitHub-native milestone doesn't match their ${label("tranche")}<slug> label (cosmetic drift, advisory)` : undefined
|
|
5407
|
+
};
|
|
5408
|
+
}
|
|
5409
|
+
function checkL5(activeTrancheSlugs, entriesBySlug) {
|
|
5410
|
+
const failures = [];
|
|
5411
|
+
for (const slug of activeTrancheSlugs) {
|
|
5412
|
+
const entries = entriesBySlug.get(slug) ?? [];
|
|
5413
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
5414
|
+
if (withFacts.length === 0)
|
|
5415
|
+
continue;
|
|
5416
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
5417
|
+
if (allClosed) {
|
|
5418
|
+
failures.push({
|
|
5419
|
+
code: "tranche-not-archived",
|
|
5420
|
+
tranche: slug,
|
|
5421
|
+
reason: "Every task Issue is closed but the tranche is not recorded as complete — archive it"
|
|
5422
|
+
});
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
return {
|
|
5426
|
+
check: "L5",
|
|
5427
|
+
status: failures.length > 0 ? "fail" : "pass",
|
|
5428
|
+
failures,
|
|
5429
|
+
note: failures.length > 0 ? `${failures.length} tranche(s) whose task Issues are all closed but were never archived` : undefined
|
|
5430
|
+
};
|
|
5431
|
+
}
|
|
4552
5432
|
function extractClosesReferences(prBody) {
|
|
4553
5433
|
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4554
5434
|
const stripped = stripCode(prBody);
|
|
@@ -4644,6 +5524,58 @@ function extractIssue(body) {
|
|
|
4644
5524
|
}
|
|
4645
5525
|
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4646
5526
|
import { createHash as createHash4 } from "node:crypto";
|
|
5527
|
+
|
|
5528
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
5529
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
5530
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
5531
|
+
let best = 0;
|
|
5532
|
+
for (const c of comments) {
|
|
5533
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5534
|
+
continue;
|
|
5535
|
+
const firstLine = (c.body.split(`
|
|
5536
|
+
`)[0] ?? "").trim();
|
|
5537
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
5538
|
+
if (!m)
|
|
5539
|
+
continue;
|
|
5540
|
+
const k = Number.parseInt(m[1], 10);
|
|
5541
|
+
if (k > best)
|
|
5542
|
+
best = k;
|
|
5543
|
+
}
|
|
5544
|
+
return best;
|
|
5545
|
+
}
|
|
5546
|
+
function parseRulingIdentity(rulingId) {
|
|
5547
|
+
const m = /^(issue-)?(\d+)-(\d+)$/.exec(rulingId);
|
|
5548
|
+
if (!m)
|
|
5549
|
+
return null;
|
|
5550
|
+
const ref = Number.parseInt(m[2], 10);
|
|
5551
|
+
const ordinal = Number.parseInt(m[3], 10);
|
|
5552
|
+
if (ref <= 0 || ordinal <= 0)
|
|
5553
|
+
return null;
|
|
5554
|
+
return { target: m[1] ? "issue" : "pr", ref, ordinal };
|
|
5555
|
+
}
|
|
5556
|
+
function principalRulingTextById(comments, allowlist, rulingId) {
|
|
5557
|
+
const identity = parseRulingIdentity(rulingId);
|
|
5558
|
+
if (identity === null)
|
|
5559
|
+
return null;
|
|
5560
|
+
const matches = comments.filter((c) => {
|
|
5561
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5562
|
+
return false;
|
|
5563
|
+
const m = RULING_MARKER_ORDINAL.exec((c.body.split(`
|
|
5564
|
+
`)[0] ?? "").trim());
|
|
5565
|
+
return m !== null && Number.parseInt(m[1], 10) === identity.ordinal;
|
|
5566
|
+
});
|
|
5567
|
+
if (matches.length !== 1)
|
|
5568
|
+
return null;
|
|
5569
|
+
const body = matches[0].body;
|
|
5570
|
+
const idx = body.indexOf(`
|
|
5571
|
+
`);
|
|
5572
|
+
return idx === -1 ? "" : body.slice(idx + 1).trim();
|
|
5573
|
+
}
|
|
5574
|
+
|
|
5575
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
5576
|
+
function pauseBoundRulingDigest(rulingText) {
|
|
5577
|
+
return createHash4("sha256").update(rulingText).digest("hex");
|
|
5578
|
+
}
|
|
4647
5579
|
function briefHash(brief) {
|
|
4648
5580
|
return createHash4("sha256").update(`${brief}
|
|
4649
5581
|
`).digest("hex");
|
|
@@ -4704,14 +5636,19 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4704
5636
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4705
5637
|
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4706
5638
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
5639
|
+
const legacyCurrent = current.manifestVersion === undefined;
|
|
5640
|
+
const manifestVersion = legacyCurrent ? echoed.manifestVersion === undefined || echoed.manifestVersion === null : echoed.manifestVersion === current.manifestVersion;
|
|
5641
|
+
const pauseBoundRuling = legacyCurrent ? true : Object.hasOwn(echoed, "pauseBoundRuling") && JSON.stringify(echoed.pauseBoundRuling) === JSON.stringify(current.pauseBoundRuling);
|
|
4707
5642
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4708
5643
|
return {
|
|
4709
|
-
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
5644
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && pauseBoundRuling && manifestVersion && policyDigestBound,
|
|
4710
5645
|
head,
|
|
4711
5646
|
base,
|
|
4712
5647
|
briefHash: briefHashBound,
|
|
4713
5648
|
objectivesVersion,
|
|
4714
5649
|
rulingOrdinal,
|
|
5650
|
+
pauseBoundRuling,
|
|
5651
|
+
manifestVersion,
|
|
4715
5652
|
policyDigest: policyDigestBound
|
|
4716
5653
|
};
|
|
4717
5654
|
}
|
|
@@ -4727,7 +5664,7 @@ function renderGateDeferred(deferred) {
|
|
|
4727
5664
|
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4728
5665
|
}
|
|
4729
5666
|
function checkReviewGate(input) {
|
|
4730
|
-
const principalAllowlist = input
|
|
5667
|
+
const { principalAllowlist } = input;
|
|
4731
5668
|
const waived = isWaiverLabelActorVerified({
|
|
4732
5669
|
label: WAIVER_LABEL_REVIEW,
|
|
4733
5670
|
labels: input.labels,
|
|
@@ -4766,27 +5703,33 @@ function checkReviewGate(input) {
|
|
|
4766
5703
|
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4767
5704
|
const securityClean = securityTextClean && securityPolicyClean;
|
|
4768
5705
|
const currentManifest = {
|
|
5706
|
+
...input.manifestVersion === undefined ? {} : { manifestVersion: input.manifestVersion },
|
|
4769
5707
|
headSha: input.headSha,
|
|
4770
5708
|
baseSha: input.baseSha ?? null,
|
|
4771
5709
|
briefHash: input.briefHash ?? null,
|
|
4772
5710
|
objectivesVersion: input.objectivesVersion,
|
|
4773
5711
|
rulingOrdinal: input.rulingOrdinal,
|
|
5712
|
+
pauseBoundRuling: input.pauseBoundRuling ?? null,
|
|
4774
5713
|
policyDigest: policyDigest(policy)
|
|
4775
5714
|
};
|
|
4776
5715
|
const codeReviewEchoed = {
|
|
5716
|
+
manifestVersion: codeReview.manifestVersion,
|
|
4777
5717
|
headSha: codeReview.headSha,
|
|
4778
5718
|
baseSha: codeReview.baseSha,
|
|
4779
5719
|
briefHash: codeReview.briefHash,
|
|
4780
5720
|
objectivesVersion: codeReview.objectivesVersion,
|
|
4781
5721
|
rulingOrdinal: codeReview.rulingOrdinal,
|
|
5722
|
+
pauseBoundRuling: codeReview.pauseBoundRuling,
|
|
4782
5723
|
policyDigest: codeReview.policyDigest
|
|
4783
5724
|
};
|
|
4784
5725
|
const securityEchoed = {
|
|
5726
|
+
manifestVersion: security.manifestVersion,
|
|
4785
5727
|
headSha: security.headSha,
|
|
4786
5728
|
baseSha: security.baseSha,
|
|
4787
5729
|
briefHash: security.briefHash,
|
|
4788
5730
|
objectivesVersion: security.objectivesVersion,
|
|
4789
5731
|
rulingOrdinal: security.rulingOrdinal,
|
|
5732
|
+
pauseBoundRuling: security.pauseBoundRuling,
|
|
4790
5733
|
policyDigest: security.policyDigest
|
|
4791
5734
|
};
|
|
4792
5735
|
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
@@ -4825,6 +5768,10 @@ function checkReviewGate(input) {
|
|
|
4825
5768
|
problems.push(`the newest code-review verdict was cast against brief hash ${codeReview.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
|
|
4826
5769
|
} else if (!codeReviewBinding.policyDigest) {
|
|
4827
5770
|
problems.push(`the newest code-review verdict was cast against review policy digest ${codeReview.policyDigest ?? "none"}, this repository's current policy digest is ${currentManifest.policyDigest}`);
|
|
5771
|
+
} else if (!codeReviewBinding.manifestVersion) {
|
|
5772
|
+
problems.push(`the newest code-review verdict echoes manifest version ${codeReview.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5773
|
+
} else if (!codeReviewBinding.pauseBoundRuling) {
|
|
5774
|
+
problems.push(`the newest code-review verdict echoes pauseBoundRuling ${renderBinding(codeReview.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4828
5775
|
}
|
|
4829
5776
|
if (!securityTextClean) {
|
|
4830
5777
|
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
@@ -4842,6 +5789,10 @@ function checkReviewGate(input) {
|
|
|
4842
5789
|
problems.push(`the newest security-review verdict was cast against brief hash ${security.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
|
|
4843
5790
|
} else if (!securityBinding.policyDigest) {
|
|
4844
5791
|
problems.push(`the newest security-review verdict was cast against review policy digest ${security.policyDigest ?? "none"}, this repository's current policy digest is ${currentManifest.policyDigest}`);
|
|
5792
|
+
} else if (!securityBinding.manifestVersion) {
|
|
5793
|
+
problems.push(`the newest security-review verdict echoes manifest version ${security.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5794
|
+
} else if (!securityBinding.pauseBoundRuling) {
|
|
5795
|
+
problems.push(`the newest security-review verdict echoes pauseBoundRuling ${renderBinding(security.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4845
5796
|
}
|
|
4846
5797
|
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4847
5798
|
return {
|
|
@@ -4850,29 +5801,16 @@ function checkReviewGate(input) {
|
|
|
4850
5801
|
waived: false
|
|
4851
5802
|
};
|
|
4852
5803
|
}
|
|
5804
|
+
function renderBinding(binding) {
|
|
5805
|
+
if (binding === undefined)
|
|
5806
|
+
return "(absent)";
|
|
5807
|
+
return binding === null ? "(none)" : `${binding.rulingId}|${binding.pauseId}|${binding.contentDigest}`;
|
|
5808
|
+
}
|
|
4853
5809
|
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4854
5810
|
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4855
5811
|
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4856
5812
|
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4857
5813
|
}
|
|
4858
|
-
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4859
|
-
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4860
|
-
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4861
|
-
let best = 0;
|
|
4862
|
-
for (const c of comments) {
|
|
4863
|
-
if (!isPrincipal(c.author, allowlist))
|
|
4864
|
-
continue;
|
|
4865
|
-
const firstLine = (c.body.split(`
|
|
4866
|
-
`)[0] ?? "").trim();
|
|
4867
|
-
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4868
|
-
if (!m)
|
|
4869
|
-
continue;
|
|
4870
|
-
const k = Number.parseInt(m[1], 10);
|
|
4871
|
-
if (k > best)
|
|
4872
|
-
best = k;
|
|
4873
|
-
}
|
|
4874
|
-
return best;
|
|
4875
|
-
}
|
|
4876
5814
|
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4877
5815
|
function splitRow(line) {
|
|
4878
5816
|
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
@@ -5024,7 +5962,6 @@ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
|
5024
5962
|
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
5025
5963
|
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
5026
5964
|
"apps/cli/src/checks/bin/check-dead-branch-push.ts": 'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
|
|
5027
|
-
"apps/cli/src/checks/bin/check-issue-assignment.ts": `Ring 0 "A task branch's first push (Issue self-assignment)" (implementation: assign-task-issue.ts)`,
|
|
5028
5965
|
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
5029
5966
|
};
|
|
5030
5967
|
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
@@ -5248,72 +6185,10 @@ function compareToBaseline(current, baseline) {
|
|
|
5248
6185
|
};
|
|
5249
6186
|
}
|
|
5250
6187
|
// ../../packages/aeg-core/src/retired-vocabulary.ts
|
|
5251
|
-
var
|
|
5252
|
-
var RETIRED_PATTERNS =
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
"decision (entry|logged)",
|
|
5256
|
-
"decision-log entry",
|
|
5257
|
-
"decision log entry",
|
|
5258
|
-
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
5259
|
-
"decision-log",
|
|
5260
|
-
"decision entr",
|
|
5261
|
-
"decisions? (are |is )?logged",
|
|
5262
|
-
"log entries",
|
|
5263
|
-
String.raw`decisions\.md`,
|
|
5264
|
-
"decisions-legacy",
|
|
5265
|
-
"CONTRADICTION",
|
|
5266
|
-
"assumes Tier 3",
|
|
5267
|
-
"Lock: ?YES",
|
|
5268
|
-
"Lock: ?NO",
|
|
5269
|
-
"lock approvals?",
|
|
5270
|
-
"approves locks",
|
|
5271
|
-
"Conforms to lock",
|
|
5272
|
-
"Challenges lock",
|
|
5273
|
-
"checkDecisionNumbersFresh",
|
|
5274
|
-
String.raw`roles/team-leader\.md`,
|
|
5275
|
-
String.raw`\(,`,
|
|
5276
|
-
String.raw`,\)`,
|
|
5277
|
-
String.raw`\(\.\)`,
|
|
5278
|
-
...PLAN_ON_DISK_PATTERNS
|
|
5279
|
-
];
|
|
5280
|
-
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
5281
|
-
var RETIRED_EXEMPT_SUBSTRINGS = [
|
|
5282
|
-
"docs/decisions-legacy.md",
|
|
5283
|
-
"apps/herald-ai/docs/",
|
|
5284
|
-
"apps/vada-ai/docs/",
|
|
5285
|
-
"aeg-root/tranches/completed/",
|
|
5286
|
-
"packages/aeg-core/src/docs/published-prose",
|
|
5287
|
-
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
5288
|
-
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
5289
|
-
"/fixtures/",
|
|
5290
|
-
"/node_modules/",
|
|
5291
|
-
"/.next/",
|
|
5292
|
-
"/.turbo/"
|
|
5293
|
-
];
|
|
5294
|
-
var PATTERN_EXEMPT = {
|
|
5295
|
-
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
5296
|
-
[String.raw`decisions\.md`]: [
|
|
5297
|
-
"docs-index.md",
|
|
5298
|
-
"apps/vada-ai/specs/legacy/README.md",
|
|
5299
|
-
"apps/vada-ai/specs/vada-product-spec.md",
|
|
5300
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5301
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5302
|
-
],
|
|
5303
|
-
"decisions-legacy": [
|
|
5304
|
-
"packages/aeg-core/src/file-classify.ts",
|
|
5305
|
-
"packages/aeg-core/src/file-classify.test.ts",
|
|
5306
|
-
"packages/aeg-core/src/pr-tier.test.ts",
|
|
5307
|
-
"docs-index.md",
|
|
5308
|
-
".claude/skills/database/SKILL.md",
|
|
5309
|
-
".claude/skills/vada-architecture/SKILL.md",
|
|
5310
|
-
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
5311
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5312
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5313
|
-
],
|
|
5314
|
-
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
5315
|
-
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
5316
|
-
};
|
|
6188
|
+
var retiredRules = rulesForGroup("retired-vocabulary");
|
|
6189
|
+
var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
|
|
6190
|
+
var PATTERN_EXEMPT = RETIRED_PATTERN_EXEMPTIONS;
|
|
6191
|
+
var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
|
|
5317
6192
|
function lineNumbers(content, pattern) {
|
|
5318
6193
|
const out = [];
|
|
5319
6194
|
const lines = content.split(`
|
|
@@ -5324,22 +6199,29 @@ function lineNumbers(content, pattern) {
|
|
|
5324
6199
|
}
|
|
5325
6200
|
return out;
|
|
5326
6201
|
}
|
|
5327
|
-
function scanRetiredVocabulary(files) {
|
|
6202
|
+
function scanRetiredVocabulary(files, rules = DEFAULT_PROSE_RULE_SET) {
|
|
5328
6203
|
const findings = [];
|
|
6204
|
+
const retired = rulesOfGroup(rules, "retired-vocabulary");
|
|
5329
6205
|
for (const file of files) {
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
6206
|
+
for (const rule of retired) {
|
|
6207
|
+
if (rule.substringExempt.some((e) => file.path.includes(e)))
|
|
6208
|
+
continue;
|
|
6209
|
+
if (!ruleReads(rules, rule, file.path))
|
|
6210
|
+
continue;
|
|
6211
|
+
const re = rule.patternFor("repository");
|
|
6212
|
+
if (!re)
|
|
6213
|
+
continue;
|
|
6214
|
+
const pattern = rule.custom ? re.source : DEFAULT_PATTERN_OF.get(rule.id) ?? re.source;
|
|
6215
|
+
if (!rule.custom && (PATTERN_EXEMPT[pattern] ?? []).some((e) => file.path.includes(e)))
|
|
5335
6216
|
continue;
|
|
5336
|
-
const re = new RegExp(pattern);
|
|
5337
6217
|
for (const line of lineNumbers(file.content, re)) {
|
|
5338
6218
|
findings.push({
|
|
5339
6219
|
file: file.path,
|
|
5340
6220
|
line,
|
|
5341
6221
|
pattern,
|
|
5342
|
-
message: `claims a retired AEG mechanism is still live (matches /${pattern}/)
|
|
6222
|
+
message: rule.custom ? `${rule.id}: ${rule.message} (matches /${pattern}/)` : `claims a retired AEG mechanism is still live (matches /${pattern}/)`,
|
|
6223
|
+
rule: rule.id,
|
|
6224
|
+
blocking: rule.severity.repository === "error"
|
|
5343
6225
|
});
|
|
5344
6226
|
}
|
|
5345
6227
|
}
|
|
@@ -5363,7 +6245,7 @@ function isSelfDependency(dep, task, issue) {
|
|
|
5363
6245
|
function checkDispatchReadiness(input) {
|
|
5364
6246
|
const { trancheSlug, task } = input;
|
|
5365
6247
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
5366
|
-
const principalAllowlist = input
|
|
6248
|
+
const { principalAllowlist } = input;
|
|
5367
6249
|
const blockerDetails = [];
|
|
5368
6250
|
const push = (blockerClass, message) => {
|
|
5369
6251
|
blockerDetails.push({ class: blockerClass, message });
|
|
@@ -5455,6 +6337,16 @@ function pushesAnyBranchRef(pushRefs) {
|
|
|
5455
6337
|
return pushRefs.split(`
|
|
5456
6338
|
`).map((line) => line.trim()).filter((line) => line.length > 0).some((line) => line.split(/\s+/)[2]?.startsWith("refs/heads/") === true);
|
|
5457
6339
|
}
|
|
6340
|
+
function resolveDefaultBranch(facts) {
|
|
6341
|
+
const { originHead, hasOriginMain, hasOriginMaster } = facts;
|
|
6342
|
+
if (originHead !== null && originHead !== "")
|
|
6343
|
+
return originHead;
|
|
6344
|
+
if (hasOriginMain)
|
|
6345
|
+
return "main";
|
|
6346
|
+
if (hasOriginMaster)
|
|
6347
|
+
return "master";
|
|
6348
|
+
return null;
|
|
6349
|
+
}
|
|
5458
6350
|
function checkMainBranchRefusal(facts) {
|
|
5459
6351
|
const { currentSymbolicBranch, defaultBranch, pushRefs = null } = facts;
|
|
5460
6352
|
if (currentSymbolicBranch === null)
|
|
@@ -5715,54 +6607,61 @@ function checkFirstPushDispatchGate(input) {
|
|
|
5715
6607
|
reason: `verify-dispatch reports READY TO DISPATCH for \`${branch}\`.`
|
|
5716
6608
|
};
|
|
5717
6609
|
}
|
|
5718
|
-
// ../../packages/aeg-core/src/
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
6610
|
+
// ../../packages/aeg-core/src/live-record.ts
|
|
6611
|
+
var RECORD_LINE_RE = /^-\s*\[([ xX])\]\s*\*\*\[live\]\*\*\s+(`+) ?(.+?) ?\2(?!`)\s+—\s+(passed|failed|unverified)\s+at\s+`([^`]+)`/;
|
|
6612
|
+
function liveMarkers(body) {
|
|
6613
|
+
const masked = maskCode(body);
|
|
6614
|
+
return [...masked.matchAll(/<!--\s*AEG:LIVE:(?:START|END)\s*-->/g)].map((m) => ({
|
|
6615
|
+
start: m.index,
|
|
6616
|
+
end: m.index + m[0].length
|
|
6617
|
+
}));
|
|
6618
|
+
}
|
|
6619
|
+
var AMBIGUOUS_RECORD_LINE = {
|
|
6620
|
+
line: "- [ ] **[live]** the pull request body carries more than one `AEG:LIVE` marker pair, so the driver's record cannot be told apart",
|
|
6621
|
+
ticked: false,
|
|
6622
|
+
command: "",
|
|
6623
|
+
outcome: "failed",
|
|
6624
|
+
head: ""
|
|
6625
|
+
};
|
|
6626
|
+
function readLiveRecord(body) {
|
|
6627
|
+
const markers = liveMarkers(body).length;
|
|
6628
|
+
if (markers === 0)
|
|
6629
|
+
return [];
|
|
6630
|
+
if (markers !== 2)
|
|
6631
|
+
return [AMBIGUOUS_RECORD_LINE];
|
|
6632
|
+
const region = anchoredRegion(body, "LIVE");
|
|
6633
|
+
if (region === null)
|
|
6634
|
+
return [];
|
|
6635
|
+
const lines = [];
|
|
6636
|
+
for (const raw of region.split(`
|
|
6637
|
+
`)) {
|
|
6638
|
+
const line = raw.trim();
|
|
6639
|
+
const m = RECORD_LINE_RE.exec(line);
|
|
6640
|
+
if (!m)
|
|
6641
|
+
continue;
|
|
6642
|
+
lines.push({
|
|
6643
|
+
line,
|
|
6644
|
+
ticked: m[1].toLowerCase() === "x",
|
|
6645
|
+
command: m[3],
|
|
6646
|
+
outcome: m[4],
|
|
6647
|
+
head: m[5]
|
|
6648
|
+
});
|
|
5756
6649
|
}
|
|
5757
|
-
return
|
|
5758
|
-
action: "assign",
|
|
5759
|
-
issue,
|
|
5760
|
-
login,
|
|
5761
|
-
reason: `First push of \`${branch}\` — assigning Issue #${issue} to @${login} (the authenticated pusher).`
|
|
5762
|
-
};
|
|
6650
|
+
return lines;
|
|
5763
6651
|
}
|
|
5764
6652
|
// ../../packages/aeg-core/src/test-plan-gate.ts
|
|
5765
|
-
function
|
|
6653
|
+
function gradedLiveLines(record, live) {
|
|
6654
|
+
if (live === undefined)
|
|
6655
|
+
return record.map((entry) => entry.line);
|
|
6656
|
+
const commands = new Set(live.liveCommands);
|
|
6657
|
+
const others = record.filter((entry) => !commands.has(entry.command)).map((entry) => entry.line);
|
|
6658
|
+
const graded = live.liveCommands.map((command) => {
|
|
6659
|
+
const atHead = record.filter((entry) => entry.command === command && entry.head === live.head);
|
|
6660
|
+
return (atHead.find((entry) => entry.ticked) ?? atHead[0])?.line ?? `- [ ] **[live]** \`${command}\` — no passed run recorded at \`${live.head || "an unknown head"}\``;
|
|
6661
|
+
});
|
|
6662
|
+
return [...others, ...graded];
|
|
6663
|
+
}
|
|
6664
|
+
function evaluateTestPlanGate(body, branch, live) {
|
|
5766
6665
|
if (!body) {
|
|
5767
6666
|
return {
|
|
5768
6667
|
verdict: "pass",
|
|
@@ -5773,7 +6672,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5773
6672
|
};
|
|
5774
6673
|
}
|
|
5775
6674
|
const located = locateTestPlanSection(body);
|
|
5776
|
-
|
|
6675
|
+
const liveLines = gradedLiveLines(readLiveRecord(body), live);
|
|
6676
|
+
const liveUnticked = liveLines.some((line) => /^[-*]\s+\[\s\]/.test(line));
|
|
6677
|
+
if (!located.found && !liveUnticked) {
|
|
5777
6678
|
if (parseTaskBranchIdentity(branch) !== null) {
|
|
5778
6679
|
return {
|
|
5779
6680
|
verdict: "fail",
|
|
@@ -5793,15 +6694,18 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5793
6694
|
]
|
|
5794
6695
|
};
|
|
5795
6696
|
}
|
|
5796
|
-
const section = located.section;
|
|
5797
|
-
if (/unit-tests-only/i.test(section)) {
|
|
6697
|
+
const section = located.found ? located.section : "";
|
|
6698
|
+
if (/unit-tests-only/i.test(section) && !liveUnticked) {
|
|
5798
6699
|
return {
|
|
5799
6700
|
verdict: "pass",
|
|
5800
6701
|
messages: ["Test Plan: unit-tests-only — pure-logic brief, CI unit-tests are the proof.", "PASS."]
|
|
5801
6702
|
};
|
|
5802
6703
|
}
|
|
5803
|
-
const checkboxLines =
|
|
5804
|
-
|
|
6704
|
+
const checkboxLines = [
|
|
6705
|
+
...section.split(`
|
|
6706
|
+
`).map((line) => line.trimStart()).filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line)),
|
|
6707
|
+
...liveLines
|
|
6708
|
+
];
|
|
5805
6709
|
if (checkboxLines.length === 0) {
|
|
5806
6710
|
return {
|
|
5807
6711
|
verdict: "pass",
|
|
@@ -5818,7 +6722,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5818
6722
|
messages.push("", "FAIL — the following [principal] Test Plan items are unticked:");
|
|
5819
6723
|
for (const line of unchecked)
|
|
5820
6724
|
messages.push(` ${line}`);
|
|
5821
|
-
messages.push("", "Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.", "The Principal runs the item in a real signed-in browser and ticks the box.",
|
|
6725
|
+
messages.push("", "Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.", "The Principal runs the item in a real signed-in browser and ticks the box.", ...liveUnticked ? [
|
|
6726
|
+
"An unticked [live] line is a live run that failed or that the review loop could not verify on its host: a later head re-runs it, or the Principal runs it and ticks the box."
|
|
6727
|
+
] : [], "Note: editing the PR body does not retrigger most workflows. If your PR body changes do not surface here, push an empty commit to re-run.");
|
|
5822
6728
|
return { verdict: "fail", messages };
|
|
5823
6729
|
}
|
|
5824
6730
|
messages.push("All [principal] Test Plan items ticked — runtime verification complete.", "PASS.");
|
|
@@ -6007,9 +6913,11 @@ var LineageSchema = z3.object({
|
|
|
6007
6913
|
parent: z3.string().nullable()
|
|
6008
6914
|
}).strict();
|
|
6009
6915
|
var InputVersionsSchema = z3.object({
|
|
6916
|
+
manifest_version: z3.literal(2).nullable().optional(),
|
|
6010
6917
|
objectives_version: z3.string().nullable(),
|
|
6011
6918
|
brief_hash: z3.string().nullable(),
|
|
6012
6919
|
ruling_ordinal: z3.number().int().nullable(),
|
|
6920
|
+
pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
|
|
6013
6921
|
policy_digest: z3.string().nullable()
|
|
6014
6922
|
}).strict();
|
|
6015
6923
|
var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
@@ -6557,17 +7465,19 @@ function buildHeader(input) {
|
|
|
6557
7465
|
parent: lineageFieldFromEnv(input.env.parent)
|
|
6558
7466
|
},
|
|
6559
7467
|
input_versions: {
|
|
7468
|
+
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
6560
7469
|
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
6561
7470
|
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
6562
7471
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
7472
|
+
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
6563
7473
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
6564
7474
|
},
|
|
6565
7475
|
provenance: provenanceFor(input),
|
|
6566
7476
|
work: {
|
|
6567
7477
|
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
6568
7478
|
repo: input.repo,
|
|
6569
|
-
change: null,
|
|
6570
|
-
revision: null
|
|
7479
|
+
change: pr === undefined ? null : String(pr),
|
|
7480
|
+
revision: input.revision ?? null
|
|
6571
7481
|
},
|
|
6572
7482
|
flow: {
|
|
6573
7483
|
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
@@ -6755,6 +7665,12 @@ var ManifestRecordSchema = z4.object({
|
|
|
6755
7665
|
briefHash: z4.string().min(1).nullable(),
|
|
6756
7666
|
objectivesVersion: z4.string().min(1).nullable(),
|
|
6757
7667
|
rulingOrdinal: epochNumber,
|
|
7668
|
+
manifestVersion: z4.literal(2).optional(),
|
|
7669
|
+
pauseBoundRuling: z4.object({
|
|
7670
|
+
rulingId: z4.string().min(1),
|
|
7671
|
+
pauseId: z4.string().min(1),
|
|
7672
|
+
contentDigest: z4.string().min(1)
|
|
7673
|
+
}).strict().nullable().optional(),
|
|
6758
7674
|
policyDigest: z4.string().min(1),
|
|
6759
7675
|
recordedAt: isoTimestamp
|
|
6760
7676
|
}).strict();
|
|
@@ -6776,7 +7692,11 @@ var LoopStateRecordSchema = z4.object({
|
|
|
6776
7692
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6777
7693
|
repeatMemory: z4.object({
|
|
6778
7694
|
blockingFindings: z4.array(z4.string()),
|
|
6779
|
-
lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
|
|
7695
|
+
lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
|
|
7696
|
+
}).strict().optional(),
|
|
7697
|
+
developerHandoff: z4.object({
|
|
7698
|
+
findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
|
|
7699
|
+
failingChecks: z4.array(z4.string().min(1))
|
|
6780
7700
|
}).strict().optional(),
|
|
6781
7701
|
publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
6782
7702
|
taskStartedAt: isoTimestamp.optional(),
|
|
@@ -6840,32 +7760,1240 @@ function emitCheckError(error) {
|
|
|
6840
7760
|
`);
|
|
6841
7761
|
}
|
|
6842
7762
|
|
|
6843
|
-
// src/
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
7763
|
+
// src/lib/config.ts
|
|
7764
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
7765
|
+
import { promisify as promisify4 } from "node:util";
|
|
7766
|
+
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
7767
|
+
import { homedir } from "node:os";
|
|
7768
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
7769
|
+
import { z as z6 } from "zod";
|
|
7770
|
+
|
|
7771
|
+
// src/lib/agent-vendors.ts
|
|
7772
|
+
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
7773
|
+
|
|
7774
|
+
// src/lib/prose-rules-config.ts
|
|
7775
|
+
import safeRegex from "safe-regex2";
|
|
7776
|
+
import { z as z5 } from "zod";
|
|
7777
|
+
var SEVERITIES = ["error", "warning"];
|
|
7778
|
+
var OVERRIDE_KEYS = ["scopes", "severity", "exempt"];
|
|
7779
|
+
var FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
|
|
7780
|
+
var CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
|
|
7781
|
+
var DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
|
|
7782
|
+
function isPlainObject3(value) {
|
|
7783
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7784
|
+
}
|
|
7785
|
+
function outsideRepositoryReason(entry) {
|
|
7786
|
+
if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
|
|
7787
|
+
return "must be a repository-relative path, not an absolute one";
|
|
7788
|
+
if (entry.split(/[\\/]/).includes(".."))
|
|
7789
|
+
return "must stay inside the repository — no `..` segment";
|
|
7790
|
+
return null;
|
|
7791
|
+
}
|
|
7792
|
+
var RepoRelativePathSchema = z5.string().min(1).superRefine((entry, ctx) => {
|
|
7793
|
+
const reason = outsideRepositoryReason(entry);
|
|
7794
|
+
if (reason)
|
|
7795
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, message: reason });
|
|
7796
|
+
});
|
|
7797
|
+
function pathListIssues(value, path, issues) {
|
|
7798
|
+
if (!Array.isArray(value)) {
|
|
7799
|
+
issues.push({ path, message: "must be a list of repository-relative paths" });
|
|
7800
|
+
return;
|
|
7801
|
+
}
|
|
7802
|
+
value.forEach((entry, index) => {
|
|
7803
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
7804
|
+
issues.push({ path: [...path, index], message: "must be a non-empty repository-relative path" });
|
|
7805
|
+
return;
|
|
7806
|
+
}
|
|
7807
|
+
const reason = outsideRepositoryReason(entry);
|
|
7808
|
+
if (reason)
|
|
7809
|
+
issues.push({ path: [...path, index], message: reason });
|
|
7810
|
+
});
|
|
7811
|
+
}
|
|
7812
|
+
function scopeListIssues(value, path, allowed, issues) {
|
|
7813
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
7814
|
+
issues.push({ path, message: "must name at least one scope" });
|
|
7815
|
+
return null;
|
|
7816
|
+
}
|
|
7817
|
+
const scopes = [];
|
|
7818
|
+
value.forEach((scope, index) => {
|
|
7819
|
+
if (typeof scope !== "string" || !CONFIGURABLE_PROSE_SCOPES.includes(scope)) {
|
|
7820
|
+
issues.push({
|
|
7821
|
+
path: [...path, index],
|
|
7822
|
+
message: scope === "published" ? 'scope "published" is not configurable here — the published pass is configured by proseGates.published.allow' : `unknown scope ${JSON.stringify(scope)} — the scopes are: ${CONFIGURABLE_PROSE_SCOPES.join(", ")}`
|
|
7823
|
+
});
|
|
7824
|
+
return;
|
|
7825
|
+
}
|
|
7826
|
+
if (!allowed.includes(scope)) {
|
|
7827
|
+
issues.push({
|
|
7828
|
+
path: [...path, index],
|
|
7829
|
+
message: `scope "${scope}" is not one this rule can run in — it can run in: ${allowed.join(", ")}`
|
|
7830
|
+
});
|
|
7831
|
+
return;
|
|
7832
|
+
}
|
|
7833
|
+
scopes.push(scope);
|
|
7834
|
+
});
|
|
7835
|
+
return scopes;
|
|
7836
|
+
}
|
|
7837
|
+
function severityIssues(value, path, scopes, issues) {
|
|
7838
|
+
if (typeof value === "string") {
|
|
7839
|
+
if (!SEVERITIES.includes(value)) {
|
|
7840
|
+
issues.push({ path, message: `unknown severity ${JSON.stringify(value)} — use "error" or "warning"` });
|
|
7841
|
+
}
|
|
7842
|
+
return;
|
|
7843
|
+
}
|
|
7844
|
+
if (!isPlainObject3(value)) {
|
|
7845
|
+
issues.push({ path, message: 'must be "error", "warning", or a map from scope to one of them' });
|
|
7846
|
+
return;
|
|
7847
|
+
}
|
|
7848
|
+
for (const [scope, severity] of Object.entries(value)) {
|
|
7849
|
+
if (!scopes.includes(scope)) {
|
|
7850
|
+
issues.push({ path: [...path, scope], message: `names scope "${scope}", which this rule's scopes do not cover` });
|
|
7851
|
+
}
|
|
7852
|
+
if (typeof severity !== "string" || !SEVERITIES.includes(severity)) {
|
|
7853
|
+
issues.push({
|
|
7854
|
+
path: [...path, scope],
|
|
7855
|
+
message: `unknown severity ${JSON.stringify(severity)} — use "error" or "warning"`
|
|
7856
|
+
});
|
|
7857
|
+
}
|
|
7858
|
+
}
|
|
7859
|
+
}
|
|
7860
|
+
function patternIssues(source, flags, path, issues) {
|
|
7861
|
+
if (typeof source !== "string" || source.length === 0) {
|
|
7862
|
+
issues.push({ path, message: "must be a non-empty regular expression" });
|
|
7863
|
+
return;
|
|
7864
|
+
}
|
|
7865
|
+
if (source.length > CONFIGURED_PATTERN_MAX_LENGTH) {
|
|
7866
|
+
issues.push({
|
|
7867
|
+
path,
|
|
7868
|
+
message: `is ${source.length} characters, over the ${CONFIGURED_PATTERN_MAX_LENGTH}-character limit for a configured pattern`
|
|
7869
|
+
});
|
|
7870
|
+
return;
|
|
7871
|
+
}
|
|
7872
|
+
try {
|
|
7873
|
+
new RegExp(source, flags);
|
|
7874
|
+
} catch (err) {
|
|
7875
|
+
issues.push({ path, message: `does not compile: ${err.message}` });
|
|
7876
|
+
return;
|
|
7877
|
+
}
|
|
7878
|
+
if (!safeRegex(source, { limit: Number.MAX_SAFE_INTEGER })) {
|
|
7879
|
+
issues.push({
|
|
7880
|
+
path,
|
|
7881
|
+
message: "has star height above one (a repeated group that itself repeats), which can take exponential time — " + "safe-regex2 refuses it. The shipped defaults are not held to this limit, so a pattern copied from one of " + "them can still be refused here; rewrite it without the nested repetition."
|
|
7882
|
+
});
|
|
7883
|
+
}
|
|
7884
|
+
}
|
|
7885
|
+
function flagIssues(value, path, issues) {
|
|
7886
|
+
if (value === undefined)
|
|
7887
|
+
return "";
|
|
7888
|
+
if (typeof value !== "string") {
|
|
7889
|
+
issues.push({ path, message: 'must be a string of flags, e.g. "i"' });
|
|
7890
|
+
return "";
|
|
7891
|
+
}
|
|
7892
|
+
const seen = new Set;
|
|
7893
|
+
for (const flag of value) {
|
|
7894
|
+
if (!CONFIGURED_PROSE_FLAGS.includes(flag)) {
|
|
7895
|
+
issues.push({
|
|
7896
|
+
path,
|
|
7897
|
+
message: `unknown flag ${JSON.stringify(flag)} — only ${CONFIGURED_PROSE_FLAGS.map((f) => `"${f}"`).join(" and ")} are allowed`
|
|
7898
|
+
});
|
|
7899
|
+
return "";
|
|
7900
|
+
}
|
|
7901
|
+
if (seen.has(flag)) {
|
|
7902
|
+
issues.push({ path, message: `repeats the flag "${flag}"` });
|
|
7903
|
+
return "";
|
|
7904
|
+
}
|
|
7905
|
+
seen.add(flag);
|
|
7906
|
+
}
|
|
7907
|
+
return value;
|
|
7908
|
+
}
|
|
7909
|
+
function defaultsIssues(value, issues) {
|
|
7910
|
+
const base = ["defaults"];
|
|
7911
|
+
if (!isPlainObject3(value)) {
|
|
7912
|
+
issues.push({ path: base, message: 'must map a default rule id to "off" or an override' });
|
|
7913
|
+
return;
|
|
7914
|
+
}
|
|
7915
|
+
for (const [id, override] of Object.entries(value)) {
|
|
7916
|
+
const path = [...base, id];
|
|
7917
|
+
const rule = CONFIGURABLE_DEFAULT_RULES.find((candidate) => candidate.id === id);
|
|
7918
|
+
if (!rule) {
|
|
7919
|
+
issues.push({
|
|
7920
|
+
path,
|
|
7921
|
+
message: `unknown default rule id "${id}" — \`vinaya check --plan\` lists the rules each prose check runs`
|
|
7922
|
+
});
|
|
7923
|
+
continue;
|
|
7924
|
+
}
|
|
7925
|
+
if (override === "off")
|
|
7926
|
+
continue;
|
|
7927
|
+
if (!isPlainObject3(override)) {
|
|
7928
|
+
issues.push({ path, message: 'must be "off" or an object with any of scopes, severity, exempt' });
|
|
7929
|
+
continue;
|
|
7930
|
+
}
|
|
7931
|
+
for (const key of Object.keys(override)) {
|
|
7932
|
+
if (OVERRIDE_KEYS.includes(key))
|
|
7933
|
+
continue;
|
|
7934
|
+
issues.push({
|
|
7935
|
+
path: [...path, key],
|
|
7936
|
+
message: FIXED_DEFAULT_KEYS.includes(key) ? `a default rule's ${key} is fixed — add a custom rule under proseGates.rules.custom instead` : `unknown key "${key}" — a default rule takes only scopes, severity and exempt`
|
|
7937
|
+
});
|
|
7938
|
+
}
|
|
7939
|
+
const scopes = override.scopes === undefined ? [...rule.scopes] : scopeListIssues(override.scopes, [...path, "scopes"], allowedScopesFor(rule), issues);
|
|
7940
|
+
if (override.severity !== undefined && scopes)
|
|
7941
|
+
severityIssues(override.severity, [...path, "severity"], scopes, issues);
|
|
7942
|
+
if (override.exempt !== undefined)
|
|
7943
|
+
pathListIssues(override.exempt, [...path, "exempt"], issues);
|
|
7944
|
+
}
|
|
7945
|
+
}
|
|
7946
|
+
function customIssues(value, issues) {
|
|
7947
|
+
if (!Array.isArray(value)) {
|
|
7948
|
+
issues.push({ path: ["custom"], message: "must be a list of rules" });
|
|
7949
|
+
return;
|
|
7950
|
+
}
|
|
7951
|
+
const ids = new Set;
|
|
7952
|
+
value.forEach((rule, index) => {
|
|
7953
|
+
const path = ["custom", index];
|
|
7954
|
+
if (!isPlainObject3(rule)) {
|
|
7955
|
+
issues.push({ path, message: "must be a rule object" });
|
|
7956
|
+
return;
|
|
7957
|
+
}
|
|
7958
|
+
for (const key of Object.keys(rule)) {
|
|
7959
|
+
if (!CUSTOM_KEYS.includes(key)) {
|
|
7960
|
+
issues.push({ path: [...path, key], message: `unknown key "${key}" — a rule takes ${CUSTOM_KEYS.join(", ")}` });
|
|
7961
|
+
}
|
|
7962
|
+
}
|
|
7963
|
+
if (typeof rule.id !== "string" || rule.id.length === 0) {
|
|
7964
|
+
issues.push({ path: [...path, "id"], message: "a custom rule needs an id" });
|
|
7965
|
+
} else if (DEFAULT_IDS.has(rule.id)) {
|
|
7966
|
+
issues.push({
|
|
7967
|
+
path: [...path, "id"],
|
|
7968
|
+
message: `"${rule.id}" is a default rule id — a custom rule needs its own id; retune the default under proseGates.rules.defaults instead`
|
|
7969
|
+
});
|
|
7970
|
+
} else if (ids.has(rule.id)) {
|
|
7971
|
+
issues.push({ path: [...path, "id"], message: `"${rule.id}" is used by an earlier custom rule` });
|
|
7972
|
+
} else {
|
|
7973
|
+
ids.add(rule.id);
|
|
7974
|
+
}
|
|
7975
|
+
if (typeof rule.means !== "string" || rule.means.trim().length === 0) {
|
|
7976
|
+
issues.push({ path: [...path, "means"], message: "a custom rule needs a message (`means`)" });
|
|
7977
|
+
}
|
|
7978
|
+
let scopes = null;
|
|
7979
|
+
if (rule.scopes === undefined) {
|
|
7980
|
+
issues.push({ path: [...path, "scopes"], message: "a custom rule needs at least one scope (`scopes`)" });
|
|
7981
|
+
} else {
|
|
7982
|
+
scopes = scopeListIssues(rule.scopes, [...path, "scopes"], CONFIGURABLE_PROSE_SCOPES, issues);
|
|
7983
|
+
}
|
|
7984
|
+
if (scopes && new Set(scopes.map(groupOfScope)).size > 1) {
|
|
7985
|
+
issues.push({
|
|
7986
|
+
path: [...path, "scopes"],
|
|
7987
|
+
message: 'mixes scopes of both prose checks — "repository" belongs to retired-vocabulary and every other scope to reader-resolvable-prose; write one rule per check'
|
|
7988
|
+
});
|
|
7989
|
+
}
|
|
7990
|
+
const flags = flagIssues(rule.flags, [...path, "flags"], issues);
|
|
7991
|
+
if (rule.pattern === undefined && rule.patterns === undefined) {
|
|
7992
|
+
issues.push({
|
|
7993
|
+
path: [...path, "pattern"],
|
|
7994
|
+
message: "a custom rule needs a `pattern` or a per-scope `patterns` map"
|
|
7995
|
+
});
|
|
7996
|
+
}
|
|
7997
|
+
if (rule.pattern !== undefined)
|
|
7998
|
+
patternIssues(rule.pattern, flags, [...path, "pattern"], issues);
|
|
7999
|
+
if (rule.patterns !== undefined) {
|
|
8000
|
+
if (!isPlainObject3(rule.patterns)) {
|
|
8001
|
+
issues.push({ path: [...path, "patterns"], message: "must map a scope to a regular expression" });
|
|
8002
|
+
} else {
|
|
8003
|
+
for (const [scope, source] of Object.entries(rule.patterns)) {
|
|
8004
|
+
if (scopes && !scopes.includes(scope)) {
|
|
8005
|
+
issues.push({
|
|
8006
|
+
path: [...path, "patterns", scope],
|
|
8007
|
+
message: `names scope "${scope}", which this rule's scopes do not cover`
|
|
8008
|
+
});
|
|
8009
|
+
continue;
|
|
8010
|
+
}
|
|
8011
|
+
patternIssues(source, flags, [...path, "patterns", scope], issues);
|
|
8012
|
+
}
|
|
8013
|
+
if (rule.pattern === undefined && scopes) {
|
|
8014
|
+
for (const scope of scopes) {
|
|
8015
|
+
if (!(scope in rule.patterns)) {
|
|
8016
|
+
issues.push({
|
|
8017
|
+
path: [...path, "patterns"],
|
|
8018
|
+
message: `has no pattern for scope "${scope}" — add one, or a \`pattern\` every other scope uses`
|
|
8019
|
+
});
|
|
8020
|
+
}
|
|
8021
|
+
}
|
|
8022
|
+
}
|
|
8023
|
+
}
|
|
8024
|
+
}
|
|
8025
|
+
if (rule.severity !== undefined && scopes)
|
|
8026
|
+
severityIssues(rule.severity, [...path, "severity"], scopes, issues);
|
|
8027
|
+
if (rule.exempt !== undefined)
|
|
8028
|
+
pathListIssues(rule.exempt, [...path, "exempt"], issues);
|
|
8029
|
+
});
|
|
8030
|
+
}
|
|
8031
|
+
function proseRulesIssues(value) {
|
|
8032
|
+
const issues = [];
|
|
8033
|
+
if (!isPlainObject3(value))
|
|
8034
|
+
return [{ path: [], message: "must be an object with any of exempt, defaults, custom" }];
|
|
8035
|
+
for (const key of Object.keys(value)) {
|
|
8036
|
+
if (!["exempt", "defaults", "custom"].includes(key)) {
|
|
8037
|
+
issues.push({ path: [key], message: `unknown key "${key}" — proseGates.rules takes exempt, defaults and custom` });
|
|
8038
|
+
}
|
|
8039
|
+
}
|
|
8040
|
+
if (value.exempt !== undefined)
|
|
8041
|
+
pathListIssues(value.exempt, ["exempt"], issues);
|
|
8042
|
+
if (value.defaults !== undefined)
|
|
8043
|
+
defaultsIssues(value.defaults, issues);
|
|
8044
|
+
if (value.custom !== undefined)
|
|
8045
|
+
customIssues(value.custom, issues);
|
|
8046
|
+
return issues;
|
|
8047
|
+
}
|
|
8048
|
+
var ProseRulesSchema = z5.unknown().superRefine((value, ctx) => {
|
|
8049
|
+
for (const issue of proseRulesIssues(value)) {
|
|
8050
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: issue.path, message: issue.message });
|
|
8051
|
+
}
|
|
8052
|
+
}).transform((value) => value);
|
|
8053
|
+
var PublishedProseSchema = z5.object({
|
|
8054
|
+
allow: z5.array(z5.string().min(1)).optional()
|
|
8055
|
+
}).strict();
|
|
8056
|
+
|
|
8057
|
+
// src/lib/config.ts
|
|
8058
|
+
var EnvEntrySchema = z6.union([
|
|
8059
|
+
z6.literal(true),
|
|
8060
|
+
z6.object({ optional: z6.literal(true) }),
|
|
8061
|
+
z6.object({ anyOf: z6.array(z6.string()).min(2) }),
|
|
8062
|
+
z6.string()
|
|
8063
|
+
]);
|
|
8064
|
+
var CheckEntrySchema = z6.object({
|
|
8065
|
+
run: z6.string(),
|
|
8066
|
+
scope: z6.enum(["diff", "full"]),
|
|
8067
|
+
include: z6.array(z6.string()).optional(),
|
|
8068
|
+
args: z6.array(z6.string()).optional(),
|
|
8069
|
+
timeoutMs: z6.number().optional(),
|
|
8070
|
+
env: z6.record(z6.string(), EnvEntrySchema).optional(),
|
|
8071
|
+
requiresOpenPr: z6.boolean().optional(),
|
|
8072
|
+
ownWorkflow: z6.boolean().optional(),
|
|
8073
|
+
principalOwed: z6.literal(true).optional(),
|
|
8074
|
+
validates: z6.enum(["body", "issue"]).optional(),
|
|
8075
|
+
advisory: z6.literal(true).optional()
|
|
8076
|
+
}).superRefine((entry, ctx) => {
|
|
8077
|
+
if (!entry.env)
|
|
8078
|
+
return;
|
|
8079
|
+
for (const [key, value] of Object.entries(entry.env)) {
|
|
8080
|
+
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
8081
|
+
continue;
|
|
8082
|
+
const members = value.anyOf;
|
|
8083
|
+
if (new Set(members).size !== members.length) {
|
|
8084
|
+
ctx.addIssue({
|
|
8085
|
+
code: z6.ZodIssueCode.custom,
|
|
8086
|
+
message: `env.${key}.anyOf has duplicate members`,
|
|
8087
|
+
path: ["env", key, "anyOf"]
|
|
8088
|
+
});
|
|
8089
|
+
}
|
|
8090
|
+
if (!members.includes(key)) {
|
|
8091
|
+
ctx.addIssue({
|
|
8092
|
+
code: z6.ZodIssueCode.custom,
|
|
8093
|
+
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
8094
|
+
path: ["env", key, "anyOf"]
|
|
8095
|
+
});
|
|
8096
|
+
}
|
|
8097
|
+
}
|
|
8098
|
+
});
|
|
8099
|
+
var RoleEntrySchema = z6.object({
|
|
8100
|
+
contract: z6.string().refine((p) => p.includes("/"), {
|
|
8101
|
+
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
8102
|
+
})
|
|
8103
|
+
});
|
|
8104
|
+
var MAX_REPORT_COMMAND_TIMEOUT_MS = 3600000;
|
|
8105
|
+
var BRIEF_BUILTINS = [
|
|
8106
|
+
"tier",
|
|
8107
|
+
"testPlan",
|
|
8108
|
+
"testPlanExclusivity",
|
|
8109
|
+
"principalPlaceholder",
|
|
8110
|
+
"surfaceMap",
|
|
8111
|
+
"docUpdateList",
|
|
8112
|
+
"worktreeStep0",
|
|
8113
|
+
"stopConditions",
|
|
8114
|
+
"autonomyClause",
|
|
8115
|
+
"project",
|
|
8116
|
+
"for",
|
|
8117
|
+
"closesN",
|
|
8118
|
+
"premiseCoverage",
|
|
8119
|
+
"issueRationale",
|
|
8120
|
+
"objectives",
|
|
8121
|
+
"briefSections",
|
|
8122
|
+
"milestoneShape"
|
|
8123
|
+
];
|
|
8124
|
+
var BriefSectionSchema = z6.union([
|
|
8125
|
+
z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
|
|
8126
|
+
z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
|
|
8127
|
+
z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
|
|
8128
|
+
z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
|
|
8129
|
+
]);
|
|
8130
|
+
var BriefSchemaSchema = z6.object({
|
|
8131
|
+
pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8132
|
+
issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8133
|
+
milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8134
|
+
ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
|
|
8135
|
+
});
|
|
8136
|
+
function isSafeRepoRelPath(p) {
|
|
8137
|
+
if (p.length === 0)
|
|
8138
|
+
return false;
|
|
8139
|
+
if (p.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(p))
|
|
8140
|
+
return false;
|
|
8141
|
+
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
8142
|
+
}
|
|
8143
|
+
var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
|
|
8144
|
+
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
8145
|
+
});
|
|
8146
|
+
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
8147
|
+
function isCanonicalHookBlockPath(p) {
|
|
8148
|
+
return CANONICAL_HOOK_BLOCK_PREFIXES.some((prefix) => p.startsWith(prefix) && p.length > prefix.length);
|
|
8149
|
+
}
|
|
8150
|
+
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
8151
|
+
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
8152
|
+
});
|
|
8153
|
+
var ManagedBlockRecordSchema = z6.object({
|
|
8154
|
+
path: ManagedHookBlockPath,
|
|
8155
|
+
marker: z6.string(),
|
|
8156
|
+
comment: z6.enum(["hash", "html"])
|
|
8157
|
+
});
|
|
8158
|
+
var ManagedManifestSchema = z6.object({
|
|
8159
|
+
version: z6.number().int().positive(),
|
|
8160
|
+
files: z6.array(SafeRepoRelPath),
|
|
8161
|
+
blocks: z6.array(ManagedBlockRecordSchema),
|
|
8162
|
+
labels: z6.array(z6.string()),
|
|
8163
|
+
agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
|
|
8164
|
+
});
|
|
8165
|
+
var ProjectEntrySchema = z6.object({
|
|
8166
|
+
name: z6.string().min(1),
|
|
8167
|
+
description: z6.string().min(1).optional(),
|
|
8168
|
+
path: z6.string().min(1).optional()
|
|
8169
|
+
});
|
|
8170
|
+
function parseTokensCollectDeclaration(value) {
|
|
8171
|
+
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
8172
|
+
if (!m)
|
|
8173
|
+
return null;
|
|
8174
|
+
const [, interpreter, script] = m;
|
|
8175
|
+
if (!isSafeRepoRelPath(script))
|
|
8176
|
+
return null;
|
|
8177
|
+
return { interpreter, script };
|
|
8178
|
+
}
|
|
8179
|
+
var VinayaConfigObjectSchema = z6.object({
|
|
8180
|
+
rings: z6.object({
|
|
8181
|
+
ring1_forgeWriteInterception: z6.boolean(),
|
|
8182
|
+
ring2_asyncAudits: z6.boolean()
|
|
8183
|
+
}).optional(),
|
|
8184
|
+
checks: z6.record(z6.string(), CheckEntrySchema).optional(),
|
|
8185
|
+
roles: z6.record(z6.string(), RoleEntrySchema).optional(),
|
|
8186
|
+
briefSchema: BriefSchemaSchema.optional(),
|
|
8187
|
+
managed: ManagedManifestSchema.optional(),
|
|
8188
|
+
principals: z6.array(z6.string()).min(1).optional(),
|
|
8189
|
+
releaseActor: z6.string().min(1).optional(),
|
|
8190
|
+
ci: z6.object({ setup: z6.string().min(1) }).optional(),
|
|
8191
|
+
tokens: z6.object({
|
|
8192
|
+
collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
8193
|
+
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
8194
|
+
})
|
|
8195
|
+
}).optional(),
|
|
8196
|
+
blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
|
|
8197
|
+
proseGates: z6.object({
|
|
8198
|
+
doctrineRoot: z6.string().min(1).optional(),
|
|
8199
|
+
readerFacingPrefix: z6.string().min(1).optional(),
|
|
8200
|
+
readerFacingSuffix: z6.string().min(1).optional(),
|
|
8201
|
+
legacySlugDir: z6.string().min(1).optional(),
|
|
8202
|
+
sourceComments: z6.object({
|
|
8203
|
+
globs: z6.array(z6.string().min(1)).optional(),
|
|
8204
|
+
allowlist: z6.array(z6.string().min(1)).optional(),
|
|
8205
|
+
severity: z6.enum(["warning", "error"]).optional()
|
|
8206
|
+
}).optional(),
|
|
8207
|
+
specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
|
|
8208
|
+
specPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8209
|
+
productPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8210
|
+
published: PublishedProseSchema.optional(),
|
|
8211
|
+
rules: ProseRulesSchema.optional()
|
|
8212
|
+
}).optional(),
|
|
8213
|
+
projects: z6.array(ProjectEntrySchema).optional(),
|
|
8214
|
+
dispatch: z6.object({
|
|
8215
|
+
timeoutMs: z6.number().int().positive().optional(),
|
|
8216
|
+
reviewerTimeoutMs: z6.number().int().positive().optional(),
|
|
8217
|
+
killGraceMs: z6.number().int().positive().optional(),
|
|
8218
|
+
agent: z6.enum(["claude", "codex"]).optional()
|
|
8219
|
+
}).optional(),
|
|
8220
|
+
reviewPolicy: z6.object({
|
|
8221
|
+
codeReviewThreshold: z6.string().min(1).optional(),
|
|
8222
|
+
securityThreshold: z6.string().min(1).optional(),
|
|
8223
|
+
maxRounds: z6.number().optional(),
|
|
8224
|
+
maxTaskMinutes: z6.number().optional()
|
|
8225
|
+
}).optional(),
|
|
8226
|
+
securityScan: z6.object({
|
|
8227
|
+
command: z6.array(z6.string().min(1)).min(1)
|
|
8228
|
+
}).optional(),
|
|
8229
|
+
gateCutovers: z6.object({
|
|
8230
|
+
objectivesSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8231
|
+
briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8232
|
+
documentationSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8233
|
+
briefRulesSincePr: z6.number().int().nonnegative().optional(),
|
|
8234
|
+
agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
|
|
8235
|
+
}).optional(),
|
|
8236
|
+
planning: z6.object({
|
|
8237
|
+
collisionThreshold: z6.number().int().nonnegative().optional()
|
|
8238
|
+
}).optional(),
|
|
8239
|
+
prePush: z6.object({
|
|
8240
|
+
alwaysRun: z6.array(z6.string()).optional()
|
|
8241
|
+
}).optional(),
|
|
8242
|
+
report: z6.object({
|
|
8243
|
+
commandTimeoutMs: z6.number().int().positive().optional()
|
|
8244
|
+
}).superRefine((report, ctx) => {
|
|
8245
|
+
const commandTimeoutMs = report.commandTimeoutMs;
|
|
8246
|
+
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
8247
|
+
ctx.addIssue({
|
|
8248
|
+
code: z6.ZodIssueCode.custom,
|
|
8249
|
+
path: ["commandTimeoutMs"],
|
|
8250
|
+
message: "must be at most 3600000 (1 hour)"
|
|
8251
|
+
});
|
|
8252
|
+
}
|
|
8253
|
+
}).optional(),
|
|
8254
|
+
logPublish: z6.unknown().refine((v) => v === undefined, {
|
|
8255
|
+
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
8256
|
+
}),
|
|
8257
|
+
runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
8258
|
+
logs: z6.object({
|
|
8259
|
+
folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
8260
|
+
url: z6.string().url().optional(),
|
|
8261
|
+
headers: z6.record(z6.string()).optional(),
|
|
8262
|
+
readHeaders: z6.record(z6.string()).optional(),
|
|
8263
|
+
events: CustomEventDeclarationsSchema.optional()
|
|
8264
|
+
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
8265
|
+
message: "logs: set at most one of folder/url"
|
|
8266
|
+
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
8267
|
+
message: "logs: headers requires url"
|
|
8268
|
+
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
8269
|
+
message: "logs: readHeaders requires url"
|
|
8270
|
+
}).optional(),
|
|
8271
|
+
decisionRecords: z6.object({
|
|
8272
|
+
path: RepoRelativePathSchema
|
|
8273
|
+
}).strict().optional()
|
|
8274
|
+
});
|
|
8275
|
+
function decisionRecordsPathIssue(path, doctrineRoot) {
|
|
8276
|
+
const reason = outsideRepositoryReason(path);
|
|
8277
|
+
if (reason)
|
|
8278
|
+
return reason;
|
|
8279
|
+
const folder = normalizeSpecPath(path);
|
|
8280
|
+
if (folder === "" || folder === ".")
|
|
8281
|
+
return "must name a folder, not the repository root";
|
|
8282
|
+
const root = normalizeSpecPath(doctrineRoot ?? "aeg-root");
|
|
8283
|
+
if (folder === root || folder.startsWith(`${root}/`)) {
|
|
8284
|
+
return `must be outside the doctrine tree "${root}" — decision records belong to this repository, not to the doctrine it ships`;
|
|
8285
|
+
}
|
|
8286
|
+
return null;
|
|
8287
|
+
}
|
|
8288
|
+
var VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
|
|
8289
|
+
const path = config.decisionRecords?.path;
|
|
8290
|
+
if (path === undefined || outsideRepositoryReason(path))
|
|
8291
|
+
return;
|
|
8292
|
+
const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
|
|
8293
|
+
if (issue)
|
|
8294
|
+
ctx.addIssue({ code: z6.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
|
|
8295
|
+
});
|
|
8296
|
+
var VinayaConfigShape = VinayaConfigObjectSchema.shape;
|
|
8297
|
+
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
8298
|
+
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
8299
|
+
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
8300
|
+
function findLocalConfig() {
|
|
8301
|
+
let dir = process.cwd();
|
|
8302
|
+
while (true) {
|
|
8303
|
+
const candidate = join(dir, LOCAL_CONFIG_FILENAME);
|
|
8304
|
+
if (existsSync(candidate))
|
|
8305
|
+
return candidate;
|
|
8306
|
+
if (existsSync(join(dir, ".git")))
|
|
8307
|
+
return null;
|
|
8308
|
+
const parent = dirname(dir);
|
|
8309
|
+
if (parent === dir)
|
|
8310
|
+
return null;
|
|
8311
|
+
dir = parent;
|
|
8312
|
+
}
|
|
8313
|
+
}
|
|
8314
|
+
function configPath() {
|
|
8315
|
+
const local = findLocalConfig();
|
|
8316
|
+
if (local)
|
|
8317
|
+
return local;
|
|
8318
|
+
if (existsSync(GLOBAL_CONFIG_PATH))
|
|
8319
|
+
return GLOBAL_CONFIG_PATH;
|
|
8320
|
+
return null;
|
|
8321
|
+
}
|
|
8322
|
+
function globalChecksIgnoredWarning(path) {
|
|
8323
|
+
return `${path}: "checks" registration in the global config is ignored — checks may only be registered from a repo-local vinaya.config.json.`;
|
|
8324
|
+
}
|
|
8325
|
+
function globalPrincipalsIgnoredWarning(path) {
|
|
8326
|
+
return `${path}: "principals" in the global config is ignored — principals may only be declared from a repo-local vinaya.config.json.`;
|
|
8327
|
+
}
|
|
8328
|
+
function globalRolesIgnoredWarning(path) {
|
|
8329
|
+
return `${path}: "roles" registration in the global config is ignored — roles may only be registered from a repo-local vinaya.config.json.`;
|
|
8330
|
+
}
|
|
8331
|
+
function globalReleaseActorIgnoredWarning(path) {
|
|
8332
|
+
return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
|
|
8333
|
+
}
|
|
8334
|
+
function globalTokensCollectIgnoredWarning(path) {
|
|
8335
|
+
return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
|
|
8336
|
+
}
|
|
8337
|
+
function globalRuntimeDirIgnoredWarning(path) {
|
|
8338
|
+
return `${path}: "runtimeDir" in the global config is ignored — it carries no repository segment, so a machine-wide value would collapse every repository's task folders into one tree. Declare it from a repo-local vinaya.config.json.`;
|
|
8339
|
+
}
|
|
8340
|
+
var emittedGlobalKeyWarnings = new Set;
|
|
8341
|
+
function warnGlobalKeyIgnoredOnce(message) {
|
|
8342
|
+
if (emittedGlobalKeyWarnings.has(message))
|
|
8343
|
+
return;
|
|
8344
|
+
emittedGlobalKeyWarnings.add(message);
|
|
8345
|
+
console.error(`⚠ ${message}`);
|
|
8346
|
+
}
|
|
8347
|
+
function stripGlobalOnlyKeys(config, path) {
|
|
8348
|
+
if (path !== GLOBAL_CONFIG_PATH)
|
|
8349
|
+
return config;
|
|
8350
|
+
let result = config;
|
|
8351
|
+
if (result.checks && Object.keys(result.checks).length > 0) {
|
|
8352
|
+
warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
|
|
8353
|
+
result = { ...result, checks: undefined };
|
|
8354
|
+
}
|
|
8355
|
+
if (result.roles && Object.keys(result.roles).length > 0) {
|
|
8356
|
+
warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
|
|
8357
|
+
result = { ...result, roles: undefined };
|
|
8358
|
+
}
|
|
8359
|
+
if (result.principals && result.principals.length > 0) {
|
|
8360
|
+
warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
|
|
8361
|
+
result = { ...result, principals: undefined };
|
|
8362
|
+
}
|
|
8363
|
+
if (result.releaseActor) {
|
|
8364
|
+
warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
|
|
8365
|
+
result = { ...result, releaseActor: undefined };
|
|
8366
|
+
}
|
|
8367
|
+
if (result.tokens) {
|
|
8368
|
+
warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
|
|
8369
|
+
result = { ...result, tokens: undefined };
|
|
8370
|
+
}
|
|
8371
|
+
if (result.runtimeDir) {
|
|
8372
|
+
warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
|
|
8373
|
+
result = { ...result, runtimeDir: undefined };
|
|
8374
|
+
}
|
|
8375
|
+
return result;
|
|
8376
|
+
}
|
|
8377
|
+
function resolveReleaseActor(config) {
|
|
8378
|
+
return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
|
|
8379
|
+
}
|
|
8380
|
+
function resolveReviewPolicy(config) {
|
|
8381
|
+
const raw = config?.reviewPolicy;
|
|
8382
|
+
if (!raw)
|
|
8383
|
+
return DEFAULT_REVIEW_POLICY;
|
|
8384
|
+
const codeReviewThreshold = raw.codeReviewThreshold ?? DEFAULT_REVIEW_POLICY.codeReviewThreshold;
|
|
8385
|
+
if (!isKnownSeverity(CODE_REVIEW_SEVERITY_ORDER, codeReviewThreshold)) {
|
|
8386
|
+
throw new Error(`vinaya.config.json: reviewPolicy.codeReviewThreshold "${codeReviewThreshold}" is not one of ${CODE_REVIEW_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
|
|
8387
|
+
}
|
|
8388
|
+
const securityThreshold = raw.securityThreshold ?? DEFAULT_REVIEW_POLICY.securityThreshold;
|
|
8389
|
+
if (!isKnownSeverity(SECURITY_SEVERITY_ORDER, securityThreshold)) {
|
|
8390
|
+
throw new Error(`vinaya.config.json: reviewPolicy.securityThreshold "${securityThreshold}" is not one of ${SECURITY_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
|
|
8391
|
+
}
|
|
8392
|
+
const maxRounds = raw.maxRounds ?? DEFAULT_REVIEW_POLICY.maxRounds;
|
|
8393
|
+
if (!Number.isInteger(maxRounds) || maxRounds < 1) {
|
|
8394
|
+
throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
|
|
8395
|
+
}
|
|
8396
|
+
const maxTaskMinutes = raw.maxTaskMinutes ?? DEFAULT_REVIEW_POLICY.maxTaskMinutes;
|
|
8397
|
+
if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
|
|
8398
|
+
throw new Error(`vinaya.config.json: reviewPolicy.maxTaskMinutes "${maxTaskMinutes}" is not a non-negative integer (0 turns the budget off) — fix the config, this never falls back to a default.`);
|
|
8399
|
+
}
|
|
8400
|
+
return {
|
|
8401
|
+
codeReviewThreshold,
|
|
8402
|
+
securityThreshold,
|
|
8403
|
+
maxRounds,
|
|
8404
|
+
maxTaskMinutes
|
|
8405
|
+
};
|
|
8406
|
+
}
|
|
8407
|
+
function resolveGateCutovers(config) {
|
|
8408
|
+
const raw = config?.gateCutovers;
|
|
8409
|
+
if (!raw)
|
|
8410
|
+
return NO_GATE_CUTOVERS;
|
|
8411
|
+
return {
|
|
8412
|
+
objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
|
|
8413
|
+
briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
|
|
8414
|
+
documentationSinceIssue: raw.documentationSinceIssue ?? null,
|
|
8415
|
+
briefRulesSincePr: raw.briefRulesSincePr ?? null,
|
|
8416
|
+
agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
|
|
8417
|
+
};
|
|
8418
|
+
}
|
|
8419
|
+
function resolveRuntimeDirSetting(config) {
|
|
8420
|
+
return config?.runtimeDir ?? null;
|
|
8421
|
+
}
|
|
8422
|
+
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
8423
|
+
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
8424
|
+
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
8425
|
+
}
|
|
8426
|
+
function resolveLogsSetting(config) {
|
|
8427
|
+
const raw = config?.logs;
|
|
8428
|
+
if (!raw)
|
|
8429
|
+
return null;
|
|
8430
|
+
if (raw.url !== undefined)
|
|
8431
|
+
return { url: raw.url, headers: raw.headers };
|
|
8432
|
+
if (raw.folder !== undefined)
|
|
8433
|
+
return { folder: raw.folder };
|
|
8434
|
+
return null;
|
|
8435
|
+
}
|
|
8436
|
+
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
8437
|
+
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
8438
|
+
if (!anchored)
|
|
8439
|
+
return null;
|
|
8440
|
+
if ("url" in local)
|
|
8441
|
+
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
8442
|
+
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
8443
|
+
}
|
|
8444
|
+
function resolveLogsHeaderValues(headers, env) {
|
|
8445
|
+
if (!headers)
|
|
8446
|
+
return;
|
|
8447
|
+
const resolved = {};
|
|
8448
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
8449
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
8450
|
+
}
|
|
8451
|
+
return resolved;
|
|
8452
|
+
}
|
|
8453
|
+
function trustAnchorRepo() {
|
|
8454
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
8455
|
+
if (fromRunner)
|
|
8456
|
+
return fromRunner;
|
|
8457
|
+
try {
|
|
8458
|
+
const url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
8459
|
+
encoding: "utf-8",
|
|
8460
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
8461
|
+
});
|
|
8462
|
+
return trustAnchorRepoFromRemoteUrl(url);
|
|
8463
|
+
} catch {
|
|
8464
|
+
return null;
|
|
8465
|
+
}
|
|
8466
|
+
}
|
|
8467
|
+
async function trustAnchorRepoAsync() {
|
|
8468
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
8469
|
+
if (fromRunner)
|
|
8470
|
+
return fromRunner;
|
|
8471
|
+
try {
|
|
8472
|
+
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
8473
|
+
encoding: "utf-8",
|
|
8474
|
+
timeout: 1e4,
|
|
8475
|
+
killSignal: "SIGKILL"
|
|
8476
|
+
});
|
|
8477
|
+
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
8478
|
+
} catch {
|
|
8479
|
+
return null;
|
|
8480
|
+
}
|
|
8481
|
+
}
|
|
8482
|
+
function wellFormedRepoSlug(slug) {
|
|
8483
|
+
return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
8484
|
+
}
|
|
8485
|
+
function trustAnchorRepoFromRunner() {
|
|
8486
|
+
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
8487
|
+
return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
|
|
8488
|
+
}
|
|
8489
|
+
function trustAnchorRepoFromRemoteUrl(url) {
|
|
8490
|
+
const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
8491
|
+
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
8492
|
+
}
|
|
8493
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
8494
|
+
function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
8495
|
+
const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
|
|
8496
|
+
if (!ref)
|
|
8497
|
+
return null;
|
|
8498
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
8499
|
+
return null;
|
|
8500
|
+
if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
|
|
8501
|
+
return null;
|
|
8502
|
+
return ref;
|
|
8503
|
+
}
|
|
8504
|
+
function readTrustAnchorConfigAtRef(ref) {
|
|
8505
|
+
const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
8506
|
+
encoding: "utf-8",
|
|
8507
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
8508
|
+
timeout: 1e4
|
|
8509
|
+
});
|
|
8510
|
+
return Buffer.from(raw, "utf-8").toString("base64");
|
|
8511
|
+
}
|
|
8512
|
+
var NO_TRUST_ANCHOR_REPO_MESSAGE = "could not resolve repo identity for the trust-anchor read";
|
|
8513
|
+
function ghFetchTrustAnchorConfig() {
|
|
8514
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
8515
|
+
if (probeRef)
|
|
8516
|
+
return readTrustAnchorConfigAtRef(probeRef);
|
|
8517
|
+
const repo = trustAnchorRepo();
|
|
8518
|
+
if (!repo)
|
|
8519
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
8520
|
+
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
8521
|
+
encoding: "utf-8",
|
|
8522
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
8523
|
+
});
|
|
8524
|
+
}
|
|
8525
|
+
async function ghFetchTrustAnchorConfigAsync() {
|
|
8526
|
+
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
8527
|
+
if (probeRef) {
|
|
8528
|
+
const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
|
|
8529
|
+
encoding: "utf-8",
|
|
8530
|
+
timeout: 1e4
|
|
8531
|
+
});
|
|
8532
|
+
return Buffer.from(stdout, "utf-8").toString("base64");
|
|
8533
|
+
}
|
|
8534
|
+
const repo = await trustAnchorRepoAsync();
|
|
8535
|
+
if (!repo)
|
|
8536
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
8537
|
+
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
8538
|
+
return stdout;
|
|
8539
|
+
}
|
|
8540
|
+
function firstLine(err) {
|
|
8541
|
+
return err?.message?.split(`
|
|
8542
|
+
`)[0] ?? "unknown error";
|
|
8543
|
+
}
|
|
8544
|
+
function isMissingFileError(err) {
|
|
8545
|
+
const stderr = err?.stderr;
|
|
8546
|
+
const haystack = [
|
|
8547
|
+
err?.message ?? "",
|
|
8548
|
+
typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
|
|
8549
|
+
].join(`
|
|
8550
|
+
`);
|
|
8551
|
+
return /\b404\b|not found/i.test(haystack);
|
|
8552
|
+
}
|
|
8553
|
+
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
8554
|
+
let base64;
|
|
8555
|
+
try {
|
|
8556
|
+
base64 = fetcher();
|
|
8557
|
+
} catch (err) {
|
|
8558
|
+
return trustAnchorFetchFailed(err);
|
|
8559
|
+
}
|
|
8560
|
+
return parseTrustAnchorContent(base64);
|
|
8561
|
+
}
|
|
8562
|
+
class PrincipalsUnresolvedError extends Error {
|
|
8563
|
+
kind;
|
|
8564
|
+
constructor(kind, message) {
|
|
8565
|
+
super(message);
|
|
8566
|
+
this.name = "PrincipalsUnresolvedError";
|
|
8567
|
+
this.kind = kind;
|
|
8568
|
+
}
|
|
8569
|
+
}
|
|
8570
|
+
var PRINCIPALS_FIX = 'add "principals": [...] to vinaya.config.json on the default branch';
|
|
8571
|
+
function fetchFailureReason(err) {
|
|
8572
|
+
const stderr = err?.stderr;
|
|
8573
|
+
const text = (typeof stderr === "string" ? stderr : stderr?.toString() ?? "").trim();
|
|
8574
|
+
return text.split(`
|
|
8575
|
+
`)[0]?.trim() || firstLine(err);
|
|
8576
|
+
}
|
|
8577
|
+
function principalsNotConfigured(why) {
|
|
8578
|
+
return new PrincipalsUnresolvedError("not-configured", `no Principal is configured (${why}) — ${PRINCIPALS_FIX}.`);
|
|
8579
|
+
}
|
|
8580
|
+
function resolveTrustedPrincipals(fetcher = ghFetchTrustAnchorConfig) {
|
|
8581
|
+
let content;
|
|
8582
|
+
try {
|
|
8583
|
+
content = fetcher();
|
|
8584
|
+
} catch (err) {
|
|
8585
|
+
if (err?.message === NO_TRUST_ANCHOR_REPO_MESSAGE) {
|
|
8586
|
+
throw principalsNotConfigured("no repository resolves for the read");
|
|
8587
|
+
}
|
|
8588
|
+
if (isMissingFileError(err))
|
|
8589
|
+
throw principalsNotConfigured("the default branch has no vinaya.config.json");
|
|
8590
|
+
throw new PrincipalsUnresolvedError("read-failed", `could not read "principals" from vinaya.config.json on the default branch: ${fetchFailureReason(err)}`);
|
|
8591
|
+
}
|
|
8592
|
+
const unusable = { why: "" };
|
|
8593
|
+
const config = parseTrustAnchorContent(content, (why) => {
|
|
8594
|
+
unusable.why = why;
|
|
8595
|
+
});
|
|
8596
|
+
if (config === null) {
|
|
8597
|
+
throw principalsNotConfigured(`vinaya.config.json on the default branch ${unusable.why ? `is unusable: ${unusable.why}` : "is empty"}`);
|
|
8598
|
+
}
|
|
8599
|
+
if (!config.principals)
|
|
8600
|
+
throw principalsNotConfigured('vinaya.config.json on the default branch sets no "principals"');
|
|
8601
|
+
return config.principals;
|
|
8602
|
+
}
|
|
8603
|
+
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
8604
|
+
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
8605
|
+
let base64;
|
|
8606
|
+
try {
|
|
8607
|
+
base64 = await fetcher();
|
|
8608
|
+
} catch (err) {
|
|
8609
|
+
return trustAnchorFetchFailed(err, warn);
|
|
8610
|
+
}
|
|
8611
|
+
return parseTrustAnchorContent(base64, warn);
|
|
8612
|
+
}
|
|
8613
|
+
function warnTrustAnchorFallback(why) {
|
|
8614
|
+
process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
|
|
8615
|
+
`);
|
|
8616
|
+
}
|
|
8617
|
+
function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
8618
|
+
if (!isMissingFileError(err))
|
|
8619
|
+
warn(firstLine(err));
|
|
8620
|
+
return null;
|
|
8621
|
+
}
|
|
8622
|
+
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
8623
|
+
const base64 = content.trim();
|
|
8624
|
+
if (!base64)
|
|
8625
|
+
return null;
|
|
8626
|
+
try {
|
|
8627
|
+
const raw = Buffer.from(base64, "base64").toString("utf-8");
|
|
8628
|
+
const parsed = VinayaConfigSchema.safeParse(JSON.parse(raw));
|
|
8629
|
+
if (parsed.success)
|
|
8630
|
+
return parsed.data;
|
|
8631
|
+
warn("it did not satisfy the config schema");
|
|
8632
|
+
return null;
|
|
8633
|
+
} catch {
|
|
8634
|
+
warn("it was not readable as JSON");
|
|
8635
|
+
return null;
|
|
8636
|
+
}
|
|
8637
|
+
}
|
|
8638
|
+
function loadConfig() {
|
|
8639
|
+
const path = configPath();
|
|
8640
|
+
if (!path)
|
|
8641
|
+
return null;
|
|
8642
|
+
let text;
|
|
8643
|
+
try {
|
|
8644
|
+
text = readFileSync2(path, "utf-8");
|
|
8645
|
+
} catch (err) {
|
|
8646
|
+
reportInvalidConfigOnce(path, `unreadable: ${err.message}`);
|
|
8647
|
+
return null;
|
|
8648
|
+
}
|
|
8649
|
+
let raw;
|
|
8650
|
+
try {
|
|
8651
|
+
raw = JSON.parse(text);
|
|
8652
|
+
} catch (err) {
|
|
8653
|
+
reportInvalidConfigOnce(path, `invalid JSON: ${err.message}`);
|
|
8654
|
+
return null;
|
|
8655
|
+
}
|
|
8656
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8657
|
+
if (!parsed.success) {
|
|
8658
|
+
reportInvalidConfigOnce(path, schemaIssueDetail(parsed.error));
|
|
8659
|
+
return null;
|
|
8660
|
+
}
|
|
8661
|
+
return stripGlobalOnlyKeys(parsed.data, path);
|
|
8662
|
+
}
|
|
8663
|
+
function schemaIssueDetail(error) {
|
|
8664
|
+
return error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
|
|
8665
|
+
}
|
|
8666
|
+
var emittedInvalidConfigReports = new Set;
|
|
8667
|
+
function reportInvalidConfigOnce(path, detail) {
|
|
8668
|
+
const key = `${path}
|
|
8669
|
+
${detail}`;
|
|
8670
|
+
if (emittedInvalidConfigReports.has(key))
|
|
8671
|
+
return;
|
|
8672
|
+
emittedInvalidConfigReports.add(key);
|
|
8673
|
+
const message = `${path} is not a valid Vinaya configuration (${detail}) — falling back to built-in defaults.`;
|
|
8674
|
+
const checkName = process.env.VINAYA_CHECK_NAME;
|
|
8675
|
+
if (checkName) {
|
|
8676
|
+
emitCheckError({
|
|
8677
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8678
|
+
check: checkName,
|
|
8679
|
+
severity: "warning",
|
|
8680
|
+
message,
|
|
8681
|
+
agent_recovery_prompt: `Fix the failing keys in ${path} (${detail}) so the file parses and satisfies the configuration schema, then re-run.`,
|
|
8682
|
+
file: path
|
|
8683
|
+
});
|
|
8684
|
+
return;
|
|
8685
|
+
}
|
|
8686
|
+
console.error(`⚠ ${message}`);
|
|
8687
|
+
}
|
|
8688
|
+
function loadConfigChecked() {
|
|
8689
|
+
const path = configPath();
|
|
8690
|
+
if (!path)
|
|
8691
|
+
return { ok: true, config: null };
|
|
8692
|
+
let raw;
|
|
8693
|
+
try {
|
|
8694
|
+
raw = JSON.parse(readFileSync2(path, "utf-8"));
|
|
8695
|
+
} catch (err) {
|
|
8696
|
+
return { ok: false, path, error: `invalid JSON: ${err.message}` };
|
|
8697
|
+
}
|
|
8698
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8699
|
+
if (!parsed.success) {
|
|
8700
|
+
return { ok: false, path, error: schemaIssueDetail(parsed.error) };
|
|
8701
|
+
}
|
|
8702
|
+
return { ok: true, config: stripGlobalOnlyKeys(parsed.data, path) };
|
|
8703
|
+
}
|
|
8704
|
+
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
8705
|
+
|
|
8706
|
+
// src/lib/forge-read.ts
|
|
8707
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
8708
|
+
|
|
8709
|
+
// src/lib/forge-snapshot.ts
|
|
8710
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
8711
|
+
import { join as join2 } from "node:path";
|
|
8712
|
+
var FORGE_SNAPSHOT_DIR_ENV = "VINAYA_FORGE_SNAPSHOT_DIR";
|
|
8713
|
+
var PULL_FILE = "pull.json";
|
|
8714
|
+
var PULL_COMMENTS_FILE = "pull-comments.json";
|
|
8715
|
+
var ISSUE_FILE = "issue.json";
|
|
8716
|
+
var ISSUE_COMMENTS_FILE = "issue-comments.json";
|
|
8717
|
+
function forgeSnapshotDir(env = process.env) {
|
|
8718
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
8719
|
+
return null;
|
|
8720
|
+
const dir = env[FORGE_SNAPSHOT_DIR_ENV];
|
|
8721
|
+
return dir ? dir : null;
|
|
8722
|
+
}
|
|
8723
|
+
|
|
8724
|
+
class ForgeSnapshotIncompleteError extends Error {
|
|
8725
|
+
constructor(dir, file) {
|
|
8726
|
+
super(`the forge snapshot ${dir} has no ${file} — the pull request read that writes it did not complete, so this check refuses to read the forge in its place.`);
|
|
8727
|
+
this.name = "ForgeSnapshotIncompleteError";
|
|
8728
|
+
}
|
|
8729
|
+
}
|
|
8730
|
+
|
|
8731
|
+
class ForgeSnapshotIssueNotFoundError extends Error {
|
|
8732
|
+
constructor(issue) {
|
|
8733
|
+
super(`Issue #${issue} did not resolve (HTTP 404) when this run's forge snapshot was read.`);
|
|
8734
|
+
this.name = "ForgeSnapshotIssueNotFoundError";
|
|
8735
|
+
}
|
|
8736
|
+
}
|
|
8737
|
+
function readSnapshotFile(dir, file) {
|
|
8738
|
+
let text;
|
|
8739
|
+
try {
|
|
8740
|
+
text = readFileSync3(join2(dir, file), "utf8");
|
|
8741
|
+
} catch {
|
|
8742
|
+
throw new ForgeSnapshotIncompleteError(dir, file);
|
|
8743
|
+
}
|
|
8744
|
+
return JSON.parse(text);
|
|
8745
|
+
}
|
|
8746
|
+
function readComments(dir, file, number) {
|
|
8747
|
+
const parsed = readSnapshotFile(dir, file);
|
|
8748
|
+
if (parsed.number !== number)
|
|
8749
|
+
throw new ForgeSnapshotIncompleteError(dir, `${file} for #${number}`);
|
|
8750
|
+
return parsed.comments;
|
|
8751
|
+
}
|
|
8752
|
+
function snapshotPullRequest(number, env = process.env) {
|
|
8753
|
+
const dir = forgeSnapshotDir(env);
|
|
8754
|
+
if (dir === null)
|
|
8755
|
+
return null;
|
|
8756
|
+
const pull = readSnapshotFile(dir, PULL_FILE);
|
|
8757
|
+
return pull.number === number ? pull : null;
|
|
8758
|
+
}
|
|
8759
|
+
function snapshotIssue(number, env = process.env) {
|
|
8760
|
+
const dir = forgeSnapshotDir(env);
|
|
8761
|
+
if (dir === null)
|
|
8762
|
+
return null;
|
|
8763
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
8764
|
+
if (issue.number !== number)
|
|
8765
|
+
return null;
|
|
8766
|
+
if ("notFound" in issue)
|
|
8767
|
+
throw new ForgeSnapshotIssueNotFoundError(number);
|
|
8768
|
+
return issue;
|
|
8769
|
+
}
|
|
8770
|
+
function snapshotComments(number, env = process.env) {
|
|
8771
|
+
const dir = forgeSnapshotDir(env);
|
|
8772
|
+
if (dir === null)
|
|
8773
|
+
return null;
|
|
8774
|
+
if (snapshotPullRequest(number, env) !== null)
|
|
8775
|
+
return readComments(dir, PULL_COMMENTS_FILE, number);
|
|
8776
|
+
if (snapshotIssue(number, env) !== null)
|
|
8777
|
+
return readComments(dir, ISSUE_COMMENTS_FILE, number);
|
|
8778
|
+
return null;
|
|
8779
|
+
}
|
|
8780
|
+
function snapshotBody(number, env = process.env) {
|
|
8781
|
+
const pull = snapshotPullRequest(number, env);
|
|
8782
|
+
if (pull !== null)
|
|
8783
|
+
return pull.body;
|
|
8784
|
+
return snapshotIssue(number, env)?.body ?? null;
|
|
8785
|
+
}
|
|
8786
|
+
function incompleteForgeSnapshot(env = process.env) {
|
|
8787
|
+
const dir = forgeSnapshotDir(env);
|
|
8788
|
+
if (dir === null)
|
|
8789
|
+
return null;
|
|
8790
|
+
for (const file of [PULL_FILE, PULL_COMMENTS_FILE, ISSUE_FILE]) {
|
|
8791
|
+
if (!existsSync2(join2(dir, file)))
|
|
8792
|
+
return new ForgeSnapshotIncompleteError(dir, file).message;
|
|
8793
|
+
}
|
|
8794
|
+
try {
|
|
8795
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
8796
|
+
if (typeof issue.number === "number" && !("notFound" in issue) && !existsSync2(join2(dir, ISSUE_COMMENTS_FILE))) {
|
|
8797
|
+
return new ForgeSnapshotIncompleteError(dir, ISSUE_COMMENTS_FILE).message;
|
|
8798
|
+
}
|
|
8799
|
+
} catch (err) {
|
|
8800
|
+
return `the forge snapshot ${dir} has an unreadable ${ISSUE_FILE}: ${err.message}`;
|
|
8801
|
+
}
|
|
8802
|
+
return null;
|
|
8803
|
+
}
|
|
8804
|
+
function exitOnIncompleteForgeSnapshot(checkName, env = process.env) {
|
|
8805
|
+
const reason = incompleteForgeSnapshot(env);
|
|
8806
|
+
if (reason === null)
|
|
8807
|
+
return;
|
|
8808
|
+
emitCheckError({
|
|
8809
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8810
|
+
check: checkName,
|
|
8811
|
+
severity: "error",
|
|
8812
|
+
message: `${checkName}: ${reason}`,
|
|
8813
|
+
agent_recovery_prompt: `Re-run the whole workflow run so its pull request read step writes the snapshot again (its own log names the failed read), then let \`vinaya check ${checkName}\` re-run.`
|
|
8814
|
+
});
|
|
8815
|
+
process.exit(1);
|
|
8816
|
+
}
|
|
8817
|
+
|
|
8818
|
+
// src/lib/forge-read.ts
|
|
8819
|
+
var FORGE_READ_CEILING_BYTES = 64 * 1024 * 1024;
|
|
8820
|
+
var PAGE_SIZE = 100;
|
|
8821
|
+
var ghRunner = (args, maxBuffer) => execFileSync3("gh", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], maxBuffer });
|
|
8822
|
+
|
|
8823
|
+
class ForgeReadOversizeError extends Error {
|
|
8824
|
+
subject;
|
|
8825
|
+
ceilingBytes;
|
|
8826
|
+
observedBytes;
|
|
8827
|
+
constructor(subject, observedBytes, atLeast = false, ceilingBytes = FORGE_READ_CEILING_BYTES) {
|
|
8828
|
+
super(`The forge response for ${subject} is ${atLeast ? "at least " : ""}${observedBytes} bytes, above the ${ceilingBytes}-byte read ceiling (FORGE_READ_CEILING_BYTES) — refusing rather than buffering it.`);
|
|
8829
|
+
this.name = "ForgeReadOversizeError";
|
|
8830
|
+
this.subject = subject;
|
|
8831
|
+
this.ceilingBytes = ceilingBytes;
|
|
8832
|
+
this.observedBytes = observedBytes;
|
|
8833
|
+
}
|
|
8834
|
+
}
|
|
8835
|
+
function isForgeReadOversize(err) {
|
|
8836
|
+
return err instanceof ForgeReadOversizeError;
|
|
8837
|
+
}
|
|
8838
|
+
function isBufferOverflow(err) {
|
|
8839
|
+
return err?.code === "ENOBUFS";
|
|
8840
|
+
}
|
|
8841
|
+
function runBounded(runner, args, subject, usedBytes) {
|
|
8842
|
+
const remaining = FORGE_READ_CEILING_BYTES - usedBytes;
|
|
8843
|
+
let out;
|
|
8844
|
+
try {
|
|
8845
|
+
out = runner(args, remaining);
|
|
8846
|
+
} catch (err) {
|
|
8847
|
+
if (isBufferOverflow(err))
|
|
8848
|
+
throw new ForgeReadOversizeError(subject, FORGE_READ_CEILING_BYTES + 1, true);
|
|
8849
|
+
throw err;
|
|
8850
|
+
}
|
|
8851
|
+
const size = Buffer.byteLength(out, "utf8");
|
|
8852
|
+
if (usedBytes + size > FORGE_READ_CEILING_BYTES)
|
|
8853
|
+
throw new ForgeReadOversizeError(subject, usedBytes + size);
|
|
8854
|
+
return out;
|
|
8855
|
+
}
|
|
8856
|
+
function readRestCommentRows(number, subjectLabel = `Issue ${number}`, runner = ghRunner) {
|
|
8857
|
+
const rows = [];
|
|
8858
|
+
let used = 0;
|
|
8859
|
+
for (let page = 1;; page++) {
|
|
8860
|
+
const out = runBounded(runner, ["api", `repos/{owner}/{repo}/issues/${number}/comments?per_page=${PAGE_SIZE}&page=${page}`], subjectLabel, used);
|
|
8861
|
+
used += Buffer.byteLength(out, "utf8");
|
|
8862
|
+
const pageRows = JSON.parse(out);
|
|
8863
|
+
rows.push(...pageRows);
|
|
8864
|
+
if (pageRows.length < PAGE_SIZE)
|
|
8865
|
+
return rows;
|
|
8866
|
+
}
|
|
8867
|
+
}
|
|
8868
|
+
function readIssueComments(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
8869
|
+
const number = resolveNumber(issue, subjectLabel, runner);
|
|
8870
|
+
const fromSnapshot = snapshotComments(number);
|
|
8871
|
+
if (fromSnapshot !== null)
|
|
8872
|
+
return fromSnapshot;
|
|
8873
|
+
return readRestCommentRows(number, subjectLabel, runner).map((r) => ({
|
|
8874
|
+
body: r.body ?? "",
|
|
8875
|
+
url: r.html_url ?? "",
|
|
8876
|
+
author: r.user?.login ? { login: r.user.login } : null
|
|
8877
|
+
}));
|
|
8878
|
+
}
|
|
8879
|
+
function readIssueBody(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
8880
|
+
if (forgeSnapshotDir() !== null) {
|
|
8881
|
+
const fromSnapshot = snapshotBody(resolveNumber(issue, subjectLabel, runner));
|
|
8882
|
+
if (fromSnapshot !== null)
|
|
8883
|
+
return fromSnapshot;
|
|
8884
|
+
}
|
|
8885
|
+
const out = runBounded(runner, ["issue", "view", String(issue), "--json", "body"], subjectLabel, 0);
|
|
8886
|
+
return JSON.parse(out).body ?? "";
|
|
8887
|
+
}
|
|
8888
|
+
function readIssueFields(issue, fields, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
8889
|
+
return JSON.parse(runBounded(runner, ["issue", "view", String(issue), "--json", fields], subjectLabel, 0));
|
|
8890
|
+
}
|
|
8891
|
+
function resolveNumber(issue, subjectLabel, runner) {
|
|
8892
|
+
if (typeof issue === "number")
|
|
8893
|
+
return issue;
|
|
8894
|
+
if (/^\d+$/.test(issue))
|
|
8895
|
+
return Number(issue);
|
|
8896
|
+
return readIssueFields(issue, "number", subjectLabel, runner).number;
|
|
8897
|
+
}
|
|
8898
|
+
|
|
8899
|
+
// src/checks/frozen-brief.ts
|
|
8900
|
+
function resolveTaskFrozenBrief(prBody, fetchComments, principalAllowlist, purpose) {
|
|
8901
|
+
const { issue } = extractIssue(prBody);
|
|
8902
|
+
if (issue === null) {
|
|
8903
|
+
return {
|
|
8904
|
+
ok: false,
|
|
8905
|
+
notFound: false,
|
|
8906
|
+
message: "not dispatched — no `Closes #N` in the PR body to resolve the task Issue."
|
|
8907
|
+
};
|
|
8908
|
+
}
|
|
8909
|
+
let comments;
|
|
8910
|
+
try {
|
|
8911
|
+
comments = fetchComments(issue);
|
|
8912
|
+
} catch (err) {
|
|
8913
|
+
if (isForgeReadOversize(err))
|
|
8914
|
+
return { ok: false, notFound: false, message: err.message };
|
|
8915
|
+
return {
|
|
8916
|
+
ok: false,
|
|
8917
|
+
notFound: isIssueNotFoundError(err),
|
|
8918
|
+
message: `could not fetch Issue #${issue}'s comments to ${purpose}: ${err instanceof Error ? err.message : String(err)}`
|
|
8919
|
+
};
|
|
8920
|
+
}
|
|
8921
|
+
let principals;
|
|
8922
|
+
try {
|
|
8923
|
+
principals = principalAllowlist();
|
|
8924
|
+
} catch (err) {
|
|
8925
|
+
if (err instanceof PrincipalsUnresolvedError)
|
|
8926
|
+
return { ok: false, notFound: false, message: err.message };
|
|
8927
|
+
throw err;
|
|
8928
|
+
}
|
|
8929
|
+
const resolved = resolveNewestFrozenBrief(comments.map((c) => ({ body: c.body, author: c.author?.login ?? null })), principals);
|
|
8930
|
+
if (!resolved) {
|
|
8931
|
+
return { ok: false, notFound: false, message: `not dispatched — no \`aeg:brief:v<k>\` comment on Issue #${issue}.` };
|
|
8932
|
+
}
|
|
8933
|
+
return { ok: true, content: resolved.content };
|
|
8934
|
+
}
|
|
8935
|
+
var defaultLiveCheckDeps = {
|
|
8936
|
+
fetchIssueComments: (issue) => readIssueComments(issue, `Issue #${issue}`),
|
|
8937
|
+
principalAllowlist: () => resolveTrustedPrincipals()
|
|
8938
|
+
};
|
|
8939
|
+
function resolveLiveCheckInputs(inputs, deps = defaultLiveCheckDeps) {
|
|
8940
|
+
const { body, branch, head } = inputs;
|
|
8941
|
+
const incomplete = incompleteForgeSnapshot();
|
|
8942
|
+
if (incomplete !== null)
|
|
8943
|
+
return { ok: false, message: incomplete };
|
|
8944
|
+
if (!isTaskBranch(branch))
|
|
8945
|
+
return { ok: true, live: undefined };
|
|
8946
|
+
if (!body) {
|
|
8947
|
+
return head ? { ok: false, message: `no pull request body was supplied for the pull request at \`${head}\`.` } : { ok: true, live: undefined };
|
|
8948
|
+
}
|
|
8949
|
+
const brief = resolveTaskFrozenBrief(body, deps.fetchIssueComments, deps.principalAllowlist, "learn its frozen brief's `[live]` lines");
|
|
8950
|
+
if (!brief.ok)
|
|
8951
|
+
return { ok: false, message: brief.message };
|
|
8952
|
+
return { ok: true, live: { liveCommands: parseLiveTestPlanItems(brief.content), head } };
|
|
8953
|
+
}
|
|
8954
|
+
|
|
8955
|
+
// src/checks/bin/check-test-plan.ts
|
|
8956
|
+
var CHECK_NAME = "test-plan";
|
|
8957
|
+
function buildTestPlanCheckErrors(result) {
|
|
8958
|
+
if (result.verdict !== "fail")
|
|
8959
|
+
return [];
|
|
8960
|
+
const principalPending = result.messages.some((m) => m.startsWith("FAIL — the following [principal] Test Plan items are unticked:"));
|
|
8961
|
+
const errors = [];
|
|
8962
|
+
for (const message of result.messages) {
|
|
8963
|
+
if (!message)
|
|
8964
|
+
continue;
|
|
8965
|
+
errors.push({
|
|
8966
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8967
|
+
check: CHECK_NAME,
|
|
8968
|
+
severity: "error",
|
|
8969
|
+
message,
|
|
8970
|
+
agent_recovery_prompt: principalPending ? "Nothing for the Developer to fix here — wait for the Principal to verify in a real signed-in browser and tick each `[principal]` Test Plan box, then re-run `vinaya check test-plan`." : "Add a `## Test Plan` section to the PR body (or the `Test Plan: unit-tests-only` sentinel for a pure-logic brief with no runtime surface), then re-run `vinaya check test-plan`.",
|
|
8971
|
+
...principalPending ? { pending: true } : {}
|
|
8972
|
+
});
|
|
8973
|
+
}
|
|
8974
|
+
return errors;
|
|
8975
|
+
}
|
|
8976
|
+
function runTestPlanCheck(inputs, deps = defaultLiveCheckDeps) {
|
|
8977
|
+
const resolved = resolveLiveCheckInputs(inputs, deps);
|
|
8978
|
+
if (!resolved.ok) {
|
|
8979
|
+
return [
|
|
8980
|
+
{
|
|
8981
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8982
|
+
check: CHECK_NAME,
|
|
8983
|
+
severity: "error",
|
|
8984
|
+
message: `test-plan: ${resolved.message} The \`[live]\` lines this pull request must have passed are unknown, so the check fails closed.`,
|
|
8985
|
+
agent_recovery_prompt: "Check `gh auth status` and network, and that the task Issue carries its frozen `aeg:brief:v<k>` comment, then re-run `vinaya check test-plan`."
|
|
8986
|
+
}
|
|
8987
|
+
];
|
|
8988
|
+
}
|
|
8989
|
+
return buildTestPlanCheckErrors(evaluateTestPlanGate(inputs.body, inputs.branch, resolved.live));
|
|
8990
|
+
}
|
|
8991
|
+
function main() {
|
|
8992
|
+
const errors = runTestPlanCheck({
|
|
8993
|
+
body: process.env.PR_BODY ?? "",
|
|
8994
|
+
branch: process.env.BRANCH ?? "",
|
|
8995
|
+
head: process.env.PULL_REQUEST_HEAD_SHA ?? ""
|
|
8996
|
+
});
|
|
6869
8997
|
if (errors.length > 0) {
|
|
6870
8998
|
for (const error of errors)
|
|
6871
8999
|
emitCheckError(error);
|
|
@@ -6877,5 +9005,6 @@ if (isEntryPoint(import.meta.url, "check-test-plan")) {
|
|
|
6877
9005
|
main();
|
|
6878
9006
|
}
|
|
6879
9007
|
export {
|
|
6880
|
-
buildTestPlanCheckErrors
|
|
9008
|
+
buildTestPlanCheckErrors,
|
|
9009
|
+
runTestPlanCheck
|
|
6881
9010
|
};
|