@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
|
@@ -43,7 +43,6 @@ var GATE_AUDIENCE = {
|
|
|
43
43
|
};
|
|
44
44
|
var NON_GATE_BINS = [
|
|
45
45
|
"archive-task",
|
|
46
|
-
"assign-task-issue",
|
|
47
46
|
"dead-branch-audit",
|
|
48
47
|
"eval-agent-compliance",
|
|
49
48
|
"open-issue",
|
|
@@ -306,6 +305,25 @@ async function runAsync(args) {
|
|
|
306
305
|
function ghApiGet(path) {
|
|
307
306
|
return JSON.parse(run(["api", path]));
|
|
308
307
|
}
|
|
308
|
+
var MAX_PER_PAGE = 100;
|
|
309
|
+
var MAX_PAGES = 100;
|
|
310
|
+
async function ghApiGetAllPagesAsync(pathWithoutPage, opts) {
|
|
311
|
+
const [base = pathWithoutPage, query = ""] = pathWithoutPage.split("?");
|
|
312
|
+
const params = new URLSearchParams(query);
|
|
313
|
+
params.set("per_page", String(MAX_PER_PAGE));
|
|
314
|
+
const all = [];
|
|
315
|
+
for (let page = 1;page <= MAX_PAGES; page++) {
|
|
316
|
+
params.set("page", String(page));
|
|
317
|
+
const args = ["api", `${base}?${params.toString()}`];
|
|
318
|
+
if (opts?.jq)
|
|
319
|
+
args.push("-q", opts.jq);
|
|
320
|
+
const batch = JSON.parse(await runAsync(args));
|
|
321
|
+
all.push(...batch);
|
|
322
|
+
if (batch.length < MAX_PER_PAGE)
|
|
323
|
+
return all;
|
|
324
|
+
}
|
|
325
|
+
throw new Error(`ghApiGetAllPagesAsync: "${pathWithoutPage}" did not terminate within ${MAX_PAGES} pages (${MAX_PAGES * MAX_PER_PAGE} items) — refusing to keep walking.`);
|
|
326
|
+
}
|
|
309
327
|
function issueListByLabelArgs(owner, repo, label) {
|
|
310
328
|
return [
|
|
311
329
|
"issue",
|
|
@@ -717,6 +735,10 @@ function intentGoalForSlug(description, slug) {
|
|
|
717
735
|
function matchesLegacyMilestone(milestones, slug) {
|
|
718
736
|
return milestones.find((m) => m.title === slug) ?? null;
|
|
719
737
|
}
|
|
738
|
+
var TRANCHE_SLUG_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*-v\d+$/;
|
|
739
|
+
function slugShapedTitles(milestones) {
|
|
740
|
+
return milestones.map((m) => m.title).filter((t) => TRANCHE_SLUG_SHAPE.test(t));
|
|
741
|
+
}
|
|
720
742
|
function factsFromLegacyMilestone(milestone) {
|
|
721
743
|
return {
|
|
722
744
|
goal: milestone.description ?? "",
|
|
@@ -750,6 +772,90 @@ function findMilestoneForSlug(owner, repo, slug) {
|
|
|
750
772
|
return resolveLegacyFacts(legacy, issues);
|
|
751
773
|
return { goal: goalFromMilestones(milestones, slug), lifecycle: lifecycleFromIssues(issues) };
|
|
752
774
|
}
|
|
775
|
+
function trancheSlugsFromLabels(labels) {
|
|
776
|
+
const slugs = [];
|
|
777
|
+
for (const l of labels) {
|
|
778
|
+
const slug = trancheSlugOf(l.name);
|
|
779
|
+
if (slug !== null)
|
|
780
|
+
slugs.push(slug);
|
|
781
|
+
}
|
|
782
|
+
return slugs;
|
|
783
|
+
}
|
|
784
|
+
async function indexTrancheMilestonesAsync(owner, repo) {
|
|
785
|
+
const [milestones, labels] = await Promise.all([
|
|
786
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
787
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`)
|
|
788
|
+
]);
|
|
789
|
+
const active = [];
|
|
790
|
+
const archived = [];
|
|
791
|
+
const facts = new Map;
|
|
792
|
+
const legacySlugs = new Set(slugShapedTitles(milestones));
|
|
793
|
+
const legacyMilestoneBySlug = new Map(milestones.filter((m) => legacySlugs.has(m.title)).map((m) => [m.title, m]));
|
|
794
|
+
const newPathSlugs = trancheSlugsFromLabels(labels).filter((slug) => !legacySlugs.has(slug));
|
|
795
|
+
const uniqueNewPathSlugs = [...new Set(newPathSlugs)];
|
|
796
|
+
const uniqueLegacySlugs = [...legacySlugs];
|
|
797
|
+
const [legacyIssuesBySlug, newPathIssuesBySlug] = await Promise.all([
|
|
798
|
+
Promise.all(uniqueLegacySlugs.map((slug) => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))),
|
|
799
|
+
Promise.all(uniqueNewPathSlugs.map((slug) => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))))
|
|
800
|
+
]);
|
|
801
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
802
|
+
const m = legacyMilestoneBySlug.get(slug);
|
|
803
|
+
if (!m)
|
|
804
|
+
return;
|
|
805
|
+
const ref = { slug, goal: m.description ?? "" };
|
|
806
|
+
const f = resolveLegacyFacts(m, legacyIssuesBySlug[i] ?? []);
|
|
807
|
+
if (f.lifecycle === "complete")
|
|
808
|
+
archived.push(ref);
|
|
809
|
+
else if (f.lifecycle === "active")
|
|
810
|
+
active.push(ref);
|
|
811
|
+
facts.set(slug, f);
|
|
812
|
+
});
|
|
813
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
814
|
+
const issues = newPathIssuesBySlug[i] ?? [];
|
|
815
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
816
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
817
|
+
const f = { goal, lifecycle };
|
|
818
|
+
facts.set(slug, f);
|
|
819
|
+
if (lifecycle === "active")
|
|
820
|
+
active.push({ slug, goal });
|
|
821
|
+
else if (lifecycle === "complete")
|
|
822
|
+
archived.push({ slug, goal });
|
|
823
|
+
});
|
|
824
|
+
return { active, archived, facts, legacySlugs };
|
|
825
|
+
}
|
|
826
|
+
async function indexTrancheMilestonesForSlugAsync(owner, repo, slug) {
|
|
827
|
+
const [milestones, labels, issues] = await Promise.all([
|
|
828
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
829
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`),
|
|
830
|
+
ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))
|
|
831
|
+
]);
|
|
832
|
+
const active = [];
|
|
833
|
+
const archived = [];
|
|
834
|
+
const facts = new Map;
|
|
835
|
+
const legacySlugs = new Set;
|
|
836
|
+
const legacyMilestone = slugShapedTitles(milestones).includes(slug) ? matchesLegacyMilestone(milestones, slug) : null;
|
|
837
|
+
if (legacyMilestone) {
|
|
838
|
+
legacySlugs.add(slug);
|
|
839
|
+
const ref = { slug, goal: legacyMilestone.description ?? "" };
|
|
840
|
+
const f = resolveLegacyFacts(legacyMilestone, issues);
|
|
841
|
+
if (f.lifecycle === "complete")
|
|
842
|
+
archived.push(ref);
|
|
843
|
+
else if (f.lifecycle === "active")
|
|
844
|
+
active.push(ref);
|
|
845
|
+
facts.set(slug, f);
|
|
846
|
+
} else if (trancheSlugsFromLabels(labels).includes(slug)) {
|
|
847
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
848
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
849
|
+
facts.set(slug, { goal, lifecycle });
|
|
850
|
+
if (lifecycle === "active")
|
|
851
|
+
active.push({ slug, goal });
|
|
852
|
+
else if (lifecycle === "complete")
|
|
853
|
+
archived.push({ slug, goal });
|
|
854
|
+
}
|
|
855
|
+
const openLegacyTitles = new Set(slugShapedTitles(milestones.filter((m) => m.state === "open")));
|
|
856
|
+
const otherOpenLegacySlugs = [...openLegacyTitles].filter((t) => t !== slug);
|
|
857
|
+
return { active, archived, facts, legacySlugs, otherOpenLegacySlugs };
|
|
858
|
+
}
|
|
753
859
|
|
|
754
860
|
// ../../packages/aeg-forge-state/src/derive-from-forge.ts
|
|
755
861
|
function trancheFromIssues(slug, issues, known) {
|
|
@@ -1410,6 +1516,125 @@ var graphql2 = withDefaults3(request, {
|
|
|
1410
1516
|
method: "POST",
|
|
1411
1517
|
url: "/graphql"
|
|
1412
1518
|
});
|
|
1519
|
+
|
|
1520
|
+
// ../../packages/aeg-forge-state/src/fetch-provenance.ts
|
|
1521
|
+
var PROVENANCE_PATTERN = /^###\s+AEG provenance\b/im;
|
|
1522
|
+
function provenanceMatchesIssue(text, issueNum) {
|
|
1523
|
+
if (!PROVENANCE_PATTERN.test(text))
|
|
1524
|
+
return false;
|
|
1525
|
+
const m = text.match(/^-\s*Issue:\s*#(\d+)/im);
|
|
1526
|
+
return m !== null && Number(m[1]) === issueNum;
|
|
1527
|
+
}
|
|
1528
|
+
function isPrCloser(closer) {
|
|
1529
|
+
return closer !== null && typeof closer.number === "number";
|
|
1530
|
+
}
|
|
1531
|
+
async function fetchProvenanceViaCrossReferences(issueNums, owner, repo, token) {
|
|
1532
|
+
const result = new Map;
|
|
1533
|
+
if (issueNums.length === 0)
|
|
1534
|
+
return result;
|
|
1535
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1536
|
+
const perIssue = issueNums.map((n) => `
|
|
1537
|
+
i_${n}: issue(number: ${n}) {
|
|
1538
|
+
timelineItems(first: 50, itemTypes: [CROSS_REFERENCED_EVENT]) {
|
|
1539
|
+
nodes {
|
|
1540
|
+
... on CrossReferencedEvent {
|
|
1541
|
+
source {
|
|
1542
|
+
... on PullRequest {
|
|
1543
|
+
number
|
|
1544
|
+
body
|
|
1545
|
+
comments(first: 50) { nodes { body } }
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
}`).join("");
|
|
1552
|
+
const query = `query ProvenanceCrossRef($owner: String!, $repo: String!) {
|
|
1553
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1554
|
+
}
|
|
1555
|
+
}`;
|
|
1556
|
+
let response;
|
|
1557
|
+
try {
|
|
1558
|
+
response = await client(query, { owner, repo });
|
|
1559
|
+
} catch {
|
|
1560
|
+
return result;
|
|
1561
|
+
}
|
|
1562
|
+
if (!response.repository)
|
|
1563
|
+
return result;
|
|
1564
|
+
for (const n of issueNums) {
|
|
1565
|
+
const raw = response.repository[`i_${n}`];
|
|
1566
|
+
const nodes = raw?.timelineItems?.nodes ?? [];
|
|
1567
|
+
const found = nodes.some(({ source }) => {
|
|
1568
|
+
if (!source || typeof source.number !== "number")
|
|
1569
|
+
return false;
|
|
1570
|
+
const pr = source;
|
|
1571
|
+
if (provenanceMatchesIssue(pr.body ?? "", n))
|
|
1572
|
+
return true;
|
|
1573
|
+
return pr.comments.nodes.some((c) => provenanceMatchesIssue(c.body, n));
|
|
1574
|
+
});
|
|
1575
|
+
result.set(n, found);
|
|
1576
|
+
}
|
|
1577
|
+
return result;
|
|
1578
|
+
}
|
|
1579
|
+
async function fetchProvenance(issueNums, owner, repo, token) {
|
|
1580
|
+
const result = new Map;
|
|
1581
|
+
if (issueNums.length === 0)
|
|
1582
|
+
return result;
|
|
1583
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1584
|
+
const perIssue = issueNums.map((n) => `
|
|
1585
|
+
i_${n}: issue(number: ${n}) {
|
|
1586
|
+
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1587
|
+
nodes {
|
|
1588
|
+
... on ClosedEvent {
|
|
1589
|
+
closer {
|
|
1590
|
+
... on PullRequest {
|
|
1591
|
+
number
|
|
1592
|
+
body
|
|
1593
|
+
comments(first: 50) {
|
|
1594
|
+
nodes { body }
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
}`).join("");
|
|
1602
|
+
const query = `query Provenance($owner: String!, $repo: String!) {
|
|
1603
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1604
|
+
}
|
|
1605
|
+
}`;
|
|
1606
|
+
let response;
|
|
1607
|
+
try {
|
|
1608
|
+
response = await client(query, { owner, repo });
|
|
1609
|
+
} catch {
|
|
1610
|
+
return result;
|
|
1611
|
+
}
|
|
1612
|
+
if (!response.repository)
|
|
1613
|
+
return result;
|
|
1614
|
+
const needsFallback = [];
|
|
1615
|
+
for (const n of issueNums) {
|
|
1616
|
+
const raw = response.repository[`i_${n}`];
|
|
1617
|
+
if (!raw) {
|
|
1618
|
+
result.set(n, false);
|
|
1619
|
+
continue;
|
|
1620
|
+
}
|
|
1621
|
+
const closer = raw.timelineItems?.nodes?.[0]?.closer;
|
|
1622
|
+
const c = closer ?? null;
|
|
1623
|
+
if (!isPrCloser(c)) {
|
|
1624
|
+
needsFallback.push(n);
|
|
1625
|
+
continue;
|
|
1626
|
+
}
|
|
1627
|
+
const bodyHas = PROVENANCE_PATTERN.test(c.body ?? "");
|
|
1628
|
+
const commentHas = c.comments.nodes.some((x) => PROVENANCE_PATTERN.test(x.body));
|
|
1629
|
+
result.set(n, bodyHas || commentHas);
|
|
1630
|
+
}
|
|
1631
|
+
if (needsFallback.length > 0) {
|
|
1632
|
+
const fallback = await fetchProvenanceViaCrossReferences(needsFallback, owner, repo, token);
|
|
1633
|
+
for (const [n, found] of fallback)
|
|
1634
|
+
result.set(n, found);
|
|
1635
|
+
}
|
|
1636
|
+
return result;
|
|
1637
|
+
}
|
|
1413
1638
|
// ../../packages/aeg-forge-state/src/github-token.ts
|
|
1414
1639
|
import { execFile as execFile2 } from "node:child_process";
|
|
1415
1640
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -1639,6 +1864,84 @@ function describeError(err) {
|
|
|
1639
1864
|
return err;
|
|
1640
1865
|
return "unknown error";
|
|
1641
1866
|
}
|
|
1867
|
+
// ../../packages/aeg-forge-state/src/prior-tranche-archival.ts
|
|
1868
|
+
function defaultPriorTrancheArchivalDeps() {
|
|
1869
|
+
let facts = new Map;
|
|
1870
|
+
return {
|
|
1871
|
+
activeTrancheSlugs: async (excludeSlug, repo) => {
|
|
1872
|
+
const index = await indexTrancheMilestonesAsync(repo.owner, repo.repo);
|
|
1873
|
+
facts = index.facts;
|
|
1874
|
+
return index.active.map((m) => m.slug).filter((slug) => slug !== excludeSlug);
|
|
1875
|
+
},
|
|
1876
|
+
deriveTranche: (slug, repo) => deriveTrancheFromForge(repo.owner, repo.repo, slug, facts.get(slug)),
|
|
1877
|
+
openIssues: async (slug, repo) => (await fetchTrancheIssuesAsync(repo.owner, repo.repo, slug)).filter((issue) => issue.state === "OPEN").map((issue) => ({ number: issue.number }))
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
function reason(err) {
|
|
1881
|
+
return err instanceof Error ? err.message.split(`
|
|
1882
|
+
`)[0] ?? "failed" : String(err);
|
|
1883
|
+
}
|
|
1884
|
+
async function resolvePriorTrancheArchival(projects, excludeSlug, repo, deps = defaultPriorTrancheArchivalDeps()) {
|
|
1885
|
+
if (projects.length === 0)
|
|
1886
|
+
return { facts: [], infraFailure: null };
|
|
1887
|
+
let candidates;
|
|
1888
|
+
try {
|
|
1889
|
+
candidates = await deps.activeTrancheSlugs(excludeSlug, repo);
|
|
1890
|
+
} catch (err) {
|
|
1891
|
+
return {
|
|
1892
|
+
facts: [],
|
|
1893
|
+
infraFailure: `severity:infra — could not read the active tranches (${reason(err)}); whether a prior tranche is archived is unknown.`
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
const facts = [];
|
|
1897
|
+
const unreadable = [];
|
|
1898
|
+
const derived = new Map;
|
|
1899
|
+
const derive = (slug) => {
|
|
1900
|
+
let p = derived.get(slug);
|
|
1901
|
+
if (!p) {
|
|
1902
|
+
p = deps.deriveTranche(slug, repo);
|
|
1903
|
+
derived.set(slug, p);
|
|
1904
|
+
}
|
|
1905
|
+
return p;
|
|
1906
|
+
};
|
|
1907
|
+
for (const project of projects) {
|
|
1908
|
+
let found = null;
|
|
1909
|
+
let unknown = false;
|
|
1910
|
+
for (const slug of candidates) {
|
|
1911
|
+
let candidateTranche;
|
|
1912
|
+
try {
|
|
1913
|
+
candidateTranche = await derive(slug);
|
|
1914
|
+
} catch {
|
|
1915
|
+
unknown = true;
|
|
1916
|
+
unreadable.push(`the tasks of tranche \`${slug}\` (project \`${project}\`)`);
|
|
1917
|
+
break;
|
|
1918
|
+
}
|
|
1919
|
+
if (!candidateTranche.tasks.some((t) => t.projects.includes(project)))
|
|
1920
|
+
continue;
|
|
1921
|
+
let openIssues;
|
|
1922
|
+
try {
|
|
1923
|
+
openIssues = await deps.openIssues(slug, repo);
|
|
1924
|
+
} catch {
|
|
1925
|
+
openIssues = null;
|
|
1926
|
+
}
|
|
1927
|
+
if (openIssues === null) {
|
|
1928
|
+
unknown = true;
|
|
1929
|
+
unreadable.push(`the open Issues of tranche \`${slug}\` (project \`${project}\`)`);
|
|
1930
|
+
break;
|
|
1931
|
+
}
|
|
1932
|
+
if (openIssues.length === 0) {
|
|
1933
|
+
found = { project, priorTrancheSlug: slug, archived: false };
|
|
1934
|
+
break;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
if (!unknown)
|
|
1938
|
+
facts.push(found ?? { project, priorTrancheSlug: null, archived: false });
|
|
1939
|
+
}
|
|
1940
|
+
return {
|
|
1941
|
+
facts,
|
|
1942
|
+
infraFailure: unreadable.length === 0 ? null : `severity:infra — could not read ${unreadable.join(", ")}; whether a prior tranche is archived is unknown.`
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1642
1945
|
// ../../packages/aeg-forge-state/src/fetch-open-issues.ts
|
|
1643
1946
|
async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
|
|
1644
1947
|
const result = new Map;
|
|
@@ -1713,6 +2016,10 @@ function buildQuery(issueNumbers) {
|
|
|
1713
2016
|
}
|
|
1714
2017
|
}`;
|
|
1715
2018
|
}
|
|
2019
|
+
// ../../packages/aeg-forge-state/src/list-issue-milestones.ts
|
|
2020
|
+
function issueMilestonesFromIssues(issues) {
|
|
2021
|
+
return issues.filter((i) => i.state === "OPEN").map((i) => ({ issue: i.number, milestoneTitle: i.milestone?.title ?? null }));
|
|
2022
|
+
}
|
|
1716
2023
|
// ../../packages/aeg-forge-state/src/resolve-repo.ts
|
|
1717
2024
|
import { execFile as execFile3 } from "node:child_process";
|
|
1718
2025
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -1775,7 +2082,8 @@ var ANCHOR_FIELDS = [
|
|
|
1775
2082
|
"PREMISE",
|
|
1776
2083
|
"TEST-PLAN",
|
|
1777
2084
|
"EVIDENCE",
|
|
1778
|
-
"BEYOND-SURFACE"
|
|
2085
|
+
"BEYOND-SURFACE",
|
|
2086
|
+
"LIVE"
|
|
1779
2087
|
];
|
|
1780
2088
|
function anchoredRegionBounds(body, field) {
|
|
1781
2089
|
const masked = maskCode(body);
|
|
@@ -1976,7 +2284,6 @@ var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
|
1976
2284
|
// ../../packages/aeg-core/src/waiver-label.ts
|
|
1977
2285
|
var WAIVER_LABEL = label("waiver-docs");
|
|
1978
2286
|
var WAIVER_LABEL_REVIEW = label("waiver-review");
|
|
1979
|
-
var PRINCIPAL_ALLOWLIST = ["daniboomerang"];
|
|
1980
2287
|
function isPrincipal(login, principalAllowlist) {
|
|
1981
2288
|
if (login === null)
|
|
1982
2289
|
return false;
|
|
@@ -1995,6 +2302,14 @@ var RULING_ORDINAL_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Ruling ordinal:\s*(\d+)(
|
|
|
1995
2302
|
var BRIEF_HASH_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Brief hash:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1996
2303
|
var POLICY_DIGEST_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Policy digest:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1997
2304
|
var BASE_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged base:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
|
|
2305
|
+
var MANIFEST_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Manifest version:\s*(\d+)\s*$/im;
|
|
2306
|
+
var PAUSE_BOUND_RULING_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Pause-bound ruling:\s*(?:(\S+)\|(\S+)\|([0-9a-f]{64})|\(none\))\s*$/im;
|
|
2307
|
+
function extractPauseBoundRuling(comment) {
|
|
2308
|
+
const m = comment.match(PAUSE_BOUND_RULING_PATTERN);
|
|
2309
|
+
if (!m)
|
|
2310
|
+
return;
|
|
2311
|
+
return m[1] ? { rulingId: m[1], pauseId: m[2], contentDigest: m[3] } : null;
|
|
2312
|
+
}
|
|
1998
2313
|
function firstFiveLines(comment) {
|
|
1999
2314
|
return comment.split(`
|
|
2000
2315
|
`).slice(0, 5).join(`
|
|
@@ -2088,6 +2403,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2088
2403
|
danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
|
|
2089
2404
|
};
|
|
2090
2405
|
}
|
|
2406
|
+
const versionMatch = latest.match(MANIFEST_VERSION_PATTERN);
|
|
2407
|
+
const pauseBoundRuling = extractPauseBoundRuling(latest);
|
|
2091
2408
|
return {
|
|
2092
2409
|
value: m[1].toUpperCase().replace(/[_-]/g, " "),
|
|
2093
2410
|
headSha: extractHeadSha(latest),
|
|
@@ -2096,6 +2413,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2096
2413
|
briefHash: extractBriefHash(latest),
|
|
2097
2414
|
policyDigest: extractPolicyDigest(latest),
|
|
2098
2415
|
baseSha: extractBaseSha(latest),
|
|
2416
|
+
...versionMatch ? { manifestVersion: Number.parseInt(versionMatch[1], 10) } : {},
|
|
2417
|
+
...pauseBoundRuling === undefined ? {} : { pauseBoundRuling },
|
|
2099
2418
|
findingSeverities: extractFindingSeverities(latest),
|
|
2100
2419
|
danglingNote: null
|
|
2101
2420
|
};
|
|
@@ -2106,6 +2425,16 @@ function extractCodeReviewVerdict(comments) {
|
|
|
2106
2425
|
function extractSecurityReviewVerdict(comments) {
|
|
2107
2426
|
return extractVerdict(comments, /^[ \t]*(?:\*{1,3}|_{1,3})?VERDICT:\s*(PASS|FAIL)(?![A-Za-z0-9])/im, "security-review");
|
|
2108
2427
|
}
|
|
2428
|
+
|
|
2429
|
+
// ../../packages/aeg-core/src/review-status.ts
|
|
2430
|
+
var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-(\d+)\s*-->/i;
|
|
2431
|
+
function parseDeveloperRoundMarker(body) {
|
|
2432
|
+
const m = body.match(DEVELOPER_ROUND_MARKER);
|
|
2433
|
+
if (!m)
|
|
2434
|
+
return null;
|
|
2435
|
+
const n = Number(m[1]);
|
|
2436
|
+
return Number.isFinite(n) ? n : null;
|
|
2437
|
+
}
|
|
2109
2438
|
// ../../packages/aeg-core/src/report-tokens.ts
|
|
2110
2439
|
var DASH_LOOKALIKES = {
|
|
2111
2440
|
"-": "‑",
|
|
@@ -2801,14 +3130,14 @@ function checkTestPlan(prBody) {
|
|
|
2801
3130
|
const region = located.found ? located.section : prBody;
|
|
2802
3131
|
if (TEST_PLAN_UNIT_TESTS_ONLY_RE.test(region))
|
|
2803
3132
|
return { status: "pass", errors: [] };
|
|
2804
|
-
if (/\*\*\[(?:agent|principal)\]\*\*/.test(region))
|
|
3133
|
+
if (/\*\*\[(?:agent|principal|live)\]\*\*/.test(region))
|
|
2805
3134
|
return { status: "pass", errors: [] };
|
|
2806
3135
|
if (located.found && extractFencedBlocks(region).length > 0)
|
|
2807
3136
|
return { status: "pass", errors: [] };
|
|
2808
3137
|
return {
|
|
2809
3138
|
status: "fail",
|
|
2810
3139
|
errors: [
|
|
2811
|
-
"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
|
|
3140
|
+
"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."
|
|
2812
3141
|
]
|
|
2813
3142
|
};
|
|
2814
3143
|
}
|
|
@@ -3430,6 +3759,375 @@ function checkPrReportDensity(prBody) {
|
|
|
3430
3759
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3431
3760
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3432
3761
|
}
|
|
3762
|
+
// ../../packages/aeg-core/src/prose-rules.ts
|
|
3763
|
+
var RETIRED_GLOBAL_EXEMPTIONS = [
|
|
3764
|
+
"docs/decisions-legacy.md",
|
|
3765
|
+
"apps/herald-ai/docs/",
|
|
3766
|
+
"apps/vada-ai/docs/",
|
|
3767
|
+
"aeg-root/tranches/completed/",
|
|
3768
|
+
"packages/aeg-core/src/docs/published-prose",
|
|
3769
|
+
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
3770
|
+
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
3771
|
+
"/fixtures/",
|
|
3772
|
+
"/node_modules/",
|
|
3773
|
+
"/.next/",
|
|
3774
|
+
"/.turbo/"
|
|
3775
|
+
];
|
|
3776
|
+
var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
|
|
3777
|
+
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
3778
|
+
var RETIRED_PATTERN_EXEMPTIONS = {
|
|
3779
|
+
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
3780
|
+
[String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
|
|
3781
|
+
"docs-index.md",
|
|
3782
|
+
"apps/vada-ai/specs/legacy/README.md",
|
|
3783
|
+
"apps/vada-ai/specs/vada-product-spec.md",
|
|
3784
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3785
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3786
|
+
],
|
|
3787
|
+
"decisions-legacy": [
|
|
3788
|
+
"packages/aeg-core/src/file-classify.ts",
|
|
3789
|
+
"packages/aeg-core/src/file-classify.test.ts",
|
|
3790
|
+
"packages/aeg-core/src/pr-tier.test.ts",
|
|
3791
|
+
"docs-index.md",
|
|
3792
|
+
".claude/skills/database/SKILL.md",
|
|
3793
|
+
".claude/skills/vada-architecture/SKILL.md",
|
|
3794
|
+
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
3795
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3796
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3797
|
+
],
|
|
3798
|
+
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
3799
|
+
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
3800
|
+
};
|
|
3801
|
+
var retiredPatterns = [
|
|
3802
|
+
String.raw`\bD-[0-9]{3}\b`,
|
|
3803
|
+
"D-(###|NNN|nnn|xxx)",
|
|
3804
|
+
"decision (entry|logged)",
|
|
3805
|
+
"decision-log entry",
|
|
3806
|
+
"decision log entry",
|
|
3807
|
+
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
3808
|
+
"decision-log",
|
|
3809
|
+
"decision entr",
|
|
3810
|
+
"decisions? (are |is )?logged",
|
|
3811
|
+
"log entries",
|
|
3812
|
+
String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
|
|
3813
|
+
"decisions-legacy",
|
|
3814
|
+
"CONTRADICTION",
|
|
3815
|
+
"assumes Tier 3",
|
|
3816
|
+
"Lock: ?YES",
|
|
3817
|
+
"Lock: ?NO",
|
|
3818
|
+
"lock approvals?",
|
|
3819
|
+
"approves locks",
|
|
3820
|
+
"Conforms to lock",
|
|
3821
|
+
"Challenges lock",
|
|
3822
|
+
"checkDecisionNumbersFresh",
|
|
3823
|
+
String.raw`roles/team-leader\.md`,
|
|
3824
|
+
String.raw`\(,`,
|
|
3825
|
+
String.raw`,\)`,
|
|
3826
|
+
String.raw`\(\.\)`,
|
|
3827
|
+
...PLAN_ON_DISK_PATTERNS
|
|
3828
|
+
];
|
|
3829
|
+
var published = [
|
|
3830
|
+
["decision-id", "a decision id", /\bD-\d{3,}\b/],
|
|
3831
|
+
["section-ref", "a section reference", /§/],
|
|
3832
|
+
["forge-number", "a forge number", /#\d+/],
|
|
3833
|
+
["retired-name", "the retired public name", /\bAEG\b/],
|
|
3834
|
+
["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
|
|
3835
|
+
[
|
|
3836
|
+
"label-vocabulary",
|
|
3837
|
+
"forge label vocabulary",
|
|
3838
|
+
/(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
|
|
3839
|
+
],
|
|
3840
|
+
["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
|
|
3841
|
+
["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
|
|
3842
|
+
[
|
|
3843
|
+
"internal-path",
|
|
3844
|
+
"a repo-internal file",
|
|
3845
|
+
/(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
|
|
3846
|
+
]
|
|
3847
|
+
];
|
|
3848
|
+
var DEFAULT_PROSE_RULES = [
|
|
3849
|
+
{
|
|
3850
|
+
id: "forge-number",
|
|
3851
|
+
group: "reader-resolvable",
|
|
3852
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3853
|
+
patterns: { prose: /#[0-9]{2,4}/g },
|
|
3854
|
+
flags: ["global"],
|
|
3855
|
+
message: "a forge number",
|
|
3856
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3857
|
+
exemptions: []
|
|
3858
|
+
},
|
|
3859
|
+
{
|
|
3860
|
+
id: "tranche-slug",
|
|
3861
|
+
group: "reader-resolvable",
|
|
3862
|
+
scopes: ["ships", "reader-facing", "product", "spec"],
|
|
3863
|
+
patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
|
|
3864
|
+
flags: ["global"],
|
|
3865
|
+
message: "an internal tranche slug",
|
|
3866
|
+
severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
|
|
3867
|
+
exemptions: []
|
|
3868
|
+
},
|
|
3869
|
+
{
|
|
3870
|
+
id: "task-number",
|
|
3871
|
+
group: "reader-resolvable",
|
|
3872
|
+
scopes: ["spec"],
|
|
3873
|
+
patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
|
|
3874
|
+
flags: ["global", "ignore-case"],
|
|
3875
|
+
message: "a task number",
|
|
3876
|
+
severity: { spec: "error" },
|
|
3877
|
+
exemptions: []
|
|
3878
|
+
},
|
|
3879
|
+
{
|
|
3880
|
+
id: "source-comment-tranche-slug",
|
|
3881
|
+
group: "reader-resolvable",
|
|
3882
|
+
scopes: ["source-comment"],
|
|
3883
|
+
patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
|
|
3884
|
+
flags: ["global"],
|
|
3885
|
+
message: "a tranche-slug citation",
|
|
3886
|
+
severity: { "source-comment": "warning" },
|
|
3887
|
+
exemptions: []
|
|
3888
|
+
},
|
|
3889
|
+
{
|
|
3890
|
+
id: "source-comment-forge-number",
|
|
3891
|
+
group: "reader-resolvable",
|
|
3892
|
+
scopes: ["source-comment"],
|
|
3893
|
+
patterns: { comment: /#[0-9]{2,}/g },
|
|
3894
|
+
flags: ["global"],
|
|
3895
|
+
message: "a forge-number citation",
|
|
3896
|
+
severity: { "source-comment": "warning" },
|
|
3897
|
+
exemptions: []
|
|
3898
|
+
},
|
|
3899
|
+
{
|
|
3900
|
+
id: "legacy-batch-name",
|
|
3901
|
+
group: "reader-resolvable",
|
|
3902
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3903
|
+
patterns: {},
|
|
3904
|
+
flags: ["built-in"],
|
|
3905
|
+
message: "an internal tranche slug",
|
|
3906
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3907
|
+
exemptions: [],
|
|
3908
|
+
builtIn: true
|
|
3909
|
+
},
|
|
3910
|
+
{
|
|
3911
|
+
id: "coined-term",
|
|
3912
|
+
group: "reader-resolvable",
|
|
3913
|
+
scopes: ["ships", "reader-facing"],
|
|
3914
|
+
patterns: {},
|
|
3915
|
+
flags: ["built-in"],
|
|
3916
|
+
message: "uses coined term without defining it inline or linking the glossary",
|
|
3917
|
+
severity: { ships: "warning", "reader-facing": "warning" },
|
|
3918
|
+
exemptions: [],
|
|
3919
|
+
builtIn: true
|
|
3920
|
+
},
|
|
3921
|
+
...retiredPatterns.map((pattern, index) => ({
|
|
3922
|
+
id: `retired-vocabulary-${index + 1}`,
|
|
3923
|
+
group: "retired-vocabulary",
|
|
3924
|
+
scopes: ["repository"],
|
|
3925
|
+
patterns: { repository: pattern },
|
|
3926
|
+
flags: [],
|
|
3927
|
+
message: "retired vocabulary",
|
|
3928
|
+
severity: { repository: "error" },
|
|
3929
|
+
exemptions: RETIRED_GLOBAL_EXEMPTIONS,
|
|
3930
|
+
patternExemptions: RETIRED_PATTERN_EXEMPTIONS
|
|
3931
|
+
})),
|
|
3932
|
+
...published.map(([id, message, pattern]) => ({
|
|
3933
|
+
id,
|
|
3934
|
+
group: "published-prose",
|
|
3935
|
+
scopes: ["published"],
|
|
3936
|
+
patterns: { published: pattern },
|
|
3937
|
+
flags: [],
|
|
3938
|
+
message,
|
|
3939
|
+
severity: { published: "error" },
|
|
3940
|
+
exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
|
|
3941
|
+
}))
|
|
3942
|
+
];
|
|
3943
|
+
var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
|
|
3944
|
+
var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
|
|
3945
|
+
var RETIRED_SCOPES = ["repository"];
|
|
3946
|
+
var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
|
|
3947
|
+
function groupOfScope(scope) {
|
|
3948
|
+
if (RESOLVABLE_SCOPES.includes(scope))
|
|
3949
|
+
return "reader-resolvable";
|
|
3950
|
+
if (RETIRED_SCOPES.includes(scope))
|
|
3951
|
+
return "retired-vocabulary";
|
|
3952
|
+
return;
|
|
3953
|
+
}
|
|
3954
|
+
var CONFIGURED_PROSE_FLAGS = ["i", "u"];
|
|
3955
|
+
var CONFIGURED_PATTERN_MAX_LENGTH = 200;
|
|
3956
|
+
var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
|
|
3957
|
+
function allowedScopesFor(rule) {
|
|
3958
|
+
if (rule.builtIn)
|
|
3959
|
+
return rule.scopes;
|
|
3960
|
+
return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
|
|
3961
|
+
}
|
|
3962
|
+
function normalizeRepoPath(entry) {
|
|
3963
|
+
let out = entry.replace(/\\/g, "/");
|
|
3964
|
+
while (out.startsWith("./"))
|
|
3965
|
+
out = out.slice(2);
|
|
3966
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3967
|
+
while (out.endsWith("/"))
|
|
3968
|
+
out = out.slice(0, -1);
|
|
3969
|
+
return out;
|
|
3970
|
+
}
|
|
3971
|
+
function isConfiguredExempt(path, exempt, repoRoot) {
|
|
3972
|
+
if (exempt.length === 0)
|
|
3973
|
+
return false;
|
|
3974
|
+
const root = repoRoot === undefined ? undefined : normalizeRepoPath(repoRoot);
|
|
3975
|
+
let rel = normalizeRepoPath(path);
|
|
3976
|
+
if (root && rel.startsWith(`${root}/`))
|
|
3977
|
+
rel = rel.slice(root.length + 1);
|
|
3978
|
+
return exempt.some((entry) => {
|
|
3979
|
+
const e = normalizeRepoPath(entry);
|
|
3980
|
+
return rel === e || rel.startsWith(`${e}/`);
|
|
3981
|
+
});
|
|
3982
|
+
}
|
|
3983
|
+
function ruleReads(set, rule, path) {
|
|
3984
|
+
return !isConfiguredExempt(path, set.exempt, set.repoRoot) && !isConfiguredExempt(path, rule.exempt, set.repoRoot);
|
|
3985
|
+
}
|
|
3986
|
+
var RESOLVABLE_RUN_ORDER = [
|
|
3987
|
+
"forge-number",
|
|
3988
|
+
"tranche-slug",
|
|
3989
|
+
"legacy-batch-name",
|
|
3990
|
+
"task-number",
|
|
3991
|
+
"source-comment-tranche-slug",
|
|
3992
|
+
"source-comment-forge-number",
|
|
3993
|
+
"coined-term"
|
|
3994
|
+
];
|
|
3995
|
+
var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
|
|
3996
|
+
function scopeDefaultSeverity(scope, sourceCommentSeverity) {
|
|
3997
|
+
if (scope === "source-comment")
|
|
3998
|
+
return sourceCommentSeverity ?? "warning";
|
|
3999
|
+
if (scope === "repository")
|
|
4000
|
+
return "error";
|
|
4001
|
+
return "warning";
|
|
4002
|
+
}
|
|
4003
|
+
function applySeverity(scopes, base, setting) {
|
|
4004
|
+
const out = {};
|
|
4005
|
+
for (const scope of scopes) {
|
|
4006
|
+
const configured = typeof setting === "string" ? setting : setting?.[scope];
|
|
4007
|
+
const value = configured ?? base[scope];
|
|
4008
|
+
if (value !== undefined)
|
|
4009
|
+
out[scope] = value;
|
|
4010
|
+
}
|
|
4011
|
+
return out;
|
|
4012
|
+
}
|
|
4013
|
+
function defaultPatternFor(rule) {
|
|
4014
|
+
const cache = new Map;
|
|
4015
|
+
return (scope) => {
|
|
4016
|
+
if (cache.has(scope))
|
|
4017
|
+
return cache.get(scope) ?? null;
|
|
4018
|
+
const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
|
|
4019
|
+
const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
|
|
4020
|
+
cache.set(scope, compiled);
|
|
4021
|
+
return compiled;
|
|
4022
|
+
};
|
|
4023
|
+
}
|
|
4024
|
+
function customPatternFor(rule, global) {
|
|
4025
|
+
const cache = new Map;
|
|
4026
|
+
return (scope) => {
|
|
4027
|
+
if (cache.has(scope))
|
|
4028
|
+
return cache.get(scope) ?? null;
|
|
4029
|
+
const source = rule.patterns?.[scope] ?? rule.pattern;
|
|
4030
|
+
const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
|
|
4031
|
+
cache.set(scope, compiled);
|
|
4032
|
+
return compiled;
|
|
4033
|
+
};
|
|
4034
|
+
}
|
|
4035
|
+
function resolveProseRules(config = undefined, options = {}) {
|
|
4036
|
+
const rules = [];
|
|
4037
|
+
const defaults = config?.defaults ?? {};
|
|
4038
|
+
for (const rule of CONFIGURABLE_DEFAULT_RULES) {
|
|
4039
|
+
const override = defaults[rule.id];
|
|
4040
|
+
if (override === "off")
|
|
4041
|
+
continue;
|
|
4042
|
+
const group = rule.group;
|
|
4043
|
+
const scopes = override?.scopes ?? rule.scopes;
|
|
4044
|
+
const base = {};
|
|
4045
|
+
for (const scope of scopes) {
|
|
4046
|
+
base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4047
|
+
}
|
|
4048
|
+
rules.push({
|
|
4049
|
+
id: rule.id,
|
|
4050
|
+
group,
|
|
4051
|
+
custom: false,
|
|
4052
|
+
builtIn: rule.builtIn === true,
|
|
4053
|
+
scopes,
|
|
4054
|
+
message: rule.message,
|
|
4055
|
+
severity: applySeverity(scopes, base, override?.severity),
|
|
4056
|
+
exempt: override?.exempt ?? [],
|
|
4057
|
+
substringExempt: rule.exemptions,
|
|
4058
|
+
reportGroup: REPORT_GROUPS[rule.id],
|
|
4059
|
+
patternFor: defaultPatternFor(rule)
|
|
4060
|
+
});
|
|
4061
|
+
}
|
|
4062
|
+
for (const rule of config?.custom ?? []) {
|
|
4063
|
+
const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
|
|
4064
|
+
const base = {};
|
|
4065
|
+
for (const scope of rule.scopes)
|
|
4066
|
+
base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4067
|
+
rules.push({
|
|
4068
|
+
id: rule.id,
|
|
4069
|
+
group,
|
|
4070
|
+
custom: true,
|
|
4071
|
+
builtIn: false,
|
|
4072
|
+
scopes: rule.scopes,
|
|
4073
|
+
message: rule.means,
|
|
4074
|
+
severity: applySeverity(rule.scopes, base, rule.severity),
|
|
4075
|
+
exempt: rule.exempt ?? [],
|
|
4076
|
+
substringExempt: [],
|
|
4077
|
+
patternFor: customPatternFor(rule, group === "reader-resolvable")
|
|
4078
|
+
});
|
|
4079
|
+
}
|
|
4080
|
+
if (options.decisionRecordsPath !== undefined)
|
|
4081
|
+
rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
|
|
4082
|
+
const order = (rule) => {
|
|
4083
|
+
const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
|
|
4084
|
+
return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
|
|
4085
|
+
};
|
|
4086
|
+
const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
|
|
4087
|
+
const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
|
|
4088
|
+
return {
|
|
4089
|
+
rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
|
|
4090
|
+
exempt: config?.exempt ?? [],
|
|
4091
|
+
repoRoot: options.repoRoot
|
|
4092
|
+
};
|
|
4093
|
+
}
|
|
4094
|
+
function rulesOfGroup(set, group) {
|
|
4095
|
+
return set.rules.filter((rule) => rule.group === group);
|
|
4096
|
+
}
|
|
4097
|
+
function rulesInScope(set, scope) {
|
|
4098
|
+
return set.rules.filter((rule) => rule.scopes.includes(scope));
|
|
4099
|
+
}
|
|
4100
|
+
var DEFAULT_PROSE_RULE_SET = resolveProseRules();
|
|
4101
|
+
var DECISION_RECORD_CITATION_ID = "decision-record-citation";
|
|
4102
|
+
var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
|
|
4103
|
+
var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
|
|
4104
|
+
function escapeRegExp(text) {
|
|
4105
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4106
|
+
}
|
|
4107
|
+
function decisionRecordCitationPattern(decisionRecordsPath) {
|
|
4108
|
+
const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
|
|
4109
|
+
return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
|
|
4110
|
+
}
|
|
4111
|
+
function decisionRecordCitationRule(decisionRecordsPath) {
|
|
4112
|
+
const folder = normalizeRepoPath(decisionRecordsPath);
|
|
4113
|
+
const pattern = decisionRecordCitationPattern(folder);
|
|
4114
|
+
const severity = {};
|
|
4115
|
+
for (const scope of DECISION_RECORD_CITATION_SCOPES)
|
|
4116
|
+
severity[scope] = "error";
|
|
4117
|
+
return {
|
|
4118
|
+
id: DECISION_RECORD_CITATION_ID,
|
|
4119
|
+
group: "reader-resolvable",
|
|
4120
|
+
custom: false,
|
|
4121
|
+
builtIn: false,
|
|
4122
|
+
scopes: DECISION_RECORD_CITATION_SCOPES,
|
|
4123
|
+
message: DECISION_RECORD_CITATION_MESSAGE,
|
|
4124
|
+
severity,
|
|
4125
|
+
exempt: [folder],
|
|
4126
|
+
substringExempt: [],
|
|
4127
|
+
patternFor: () => pattern
|
|
4128
|
+
};
|
|
4129
|
+
}
|
|
4130
|
+
|
|
3433
4131
|
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3434
4132
|
var PRODUCT_SLUG_SCOPE = [
|
|
3435
4133
|
"apps/cli/src",
|
|
@@ -3441,8 +4139,8 @@ var PRODUCT_SLUG_SCOPE = [
|
|
|
3441
4139
|
function isUnderOrEqual(path, prefix) {
|
|
3442
4140
|
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3443
4141
|
}
|
|
3444
|
-
function isProductScopeFile(path) {
|
|
3445
|
-
return
|
|
4142
|
+
function isProductScopeFile(path, productPaths) {
|
|
4143
|
+
return productPaths.some((prefix) => isUnderOrEqual(path, normalizeRepoPath(prefix)));
|
|
3446
4144
|
}
|
|
3447
4145
|
var SHIPS_PREFIX = "aeg-root/";
|
|
3448
4146
|
function shipsArchivePrefix(shipsPrefix) {
|
|
@@ -3450,13 +4148,7 @@ function shipsArchivePrefix(shipsPrefix) {
|
|
|
3450
4148
|
}
|
|
3451
4149
|
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3452
4150
|
function normalizeSpecPath(entry) {
|
|
3453
|
-
|
|
3454
|
-
while (out.startsWith("./"))
|
|
3455
|
-
out = out.slice(2);
|
|
3456
|
-
out = out.replace(/\/{2,}/g, "/");
|
|
3457
|
-
while (out.endsWith("/"))
|
|
3458
|
-
out = out.slice(0, -1);
|
|
3459
|
-
return out;
|
|
4151
|
+
return normalizeRepoPath(entry);
|
|
3460
4152
|
}
|
|
3461
4153
|
function isSpecFile2(path, specPaths) {
|
|
3462
4154
|
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
@@ -3468,7 +4160,7 @@ function isSpecFile2(path, specPaths) {
|
|
|
3468
4160
|
function isClaudeMdFile(path) {
|
|
3469
4161
|
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3470
4162
|
}
|
|
3471
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4163
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS, productPaths = PRODUCT_SLUG_SCOPE) {
|
|
3472
4164
|
if (path.startsWith(shipsPrefix)) {
|
|
3473
4165
|
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3474
4166
|
}
|
|
@@ -3479,7 +4171,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
|
|
|
3479
4171
|
return "internal";
|
|
3480
4172
|
if (isSpecFile2(path, specPaths))
|
|
3481
4173
|
return "spec";
|
|
3482
|
-
if (isProductScopeFile(path))
|
|
4174
|
+
if (isProductScopeFile(path, productPaths))
|
|
3483
4175
|
return "product";
|
|
3484
4176
|
return null;
|
|
3485
4177
|
}
|
|
@@ -3504,9 +4196,16 @@ function lineAt(content, index) {
|
|
|
3504
4196
|
}
|
|
3505
4197
|
return line;
|
|
3506
4198
|
}
|
|
3507
|
-
var
|
|
3508
|
-
var
|
|
3509
|
-
|
|
4199
|
+
var readerRules = rulesForGroup("reader-resolvable");
|
|
4200
|
+
var readerPattern = (id, scope = "prose") => {
|
|
4201
|
+
const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
|
|
4202
|
+
if (!(pattern instanceof RegExp))
|
|
4203
|
+
throw new Error(`default prose rule ${id} has no ${scope} pattern`);
|
|
4204
|
+
return pattern;
|
|
4205
|
+
};
|
|
4206
|
+
var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
|
|
4207
|
+
var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
|
|
4208
|
+
var TASK_NUMBER_PATTERN = readerPattern("task-number");
|
|
3510
4209
|
function legacySlugPattern(legacySlugs) {
|
|
3511
4210
|
if (legacySlugs.length === 0)
|
|
3512
4211
|
return null;
|
|
@@ -3516,48 +4215,61 @@ function legacySlugPattern(legacySlugs) {
|
|
|
3516
4215
|
function specGrandfatherPaths(specGrandfather) {
|
|
3517
4216
|
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
|
|
3518
4217
|
}
|
|
3519
|
-
|
|
4218
|
+
var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
|
|
4219
|
+
function referenceRulesFor(set, cls) {
|
|
4220
|
+
return rulesInScope(set, cls).filter((rule) => rule.group === "reader-resolvable" && rule.id !== "coined-term");
|
|
4221
|
+
}
|
|
4222
|
+
function citations(pattern, text, group) {
|
|
4223
|
+
const out = [];
|
|
4224
|
+
const re = pattern.global ? pattern : new RegExp(pattern.source, `${pattern.flags}g`);
|
|
4225
|
+
re.lastIndex = 0;
|
|
4226
|
+
let match = re.exec(text);
|
|
4227
|
+
while (match !== null) {
|
|
4228
|
+
if (match[0] === "") {
|
|
4229
|
+
re.lastIndex++;
|
|
4230
|
+
} else {
|
|
4231
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4232
|
+
out.push({ cited, index: match.index + match[0].indexOf(cited) });
|
|
4233
|
+
}
|
|
4234
|
+
match = re.exec(text);
|
|
4235
|
+
}
|
|
4236
|
+
re.lastIndex = 0;
|
|
4237
|
+
return out;
|
|
4238
|
+
}
|
|
4239
|
+
function customMessage(rule, cited) {
|
|
4240
|
+
return `${rule.id}: ${rule.message} ("${cited}")`;
|
|
4241
|
+
}
|
|
4242
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
4243
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4244
|
+
const productPaths = options.productPaths ?? PRODUCT_SLUG_SCOPE;
|
|
3520
4245
|
const findings = [];
|
|
3521
4246
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3522
4247
|
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
|
|
3523
4248
|
const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
|
|
3524
|
-
const patterns = [
|
|
3525
|
-
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3526
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3527
|
-
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3528
|
-
];
|
|
3529
|
-
const productPatterns = [
|
|
3530
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3531
|
-
];
|
|
3532
|
-
const specPatterns = [
|
|
3533
|
-
...patterns,
|
|
3534
|
-
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3535
|
-
];
|
|
3536
4249
|
for (const file of files) {
|
|
3537
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3538
|
-
if (!cls || cls
|
|
3539
|
-
continue;
|
|
3540
|
-
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
4250
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths, productPaths);
|
|
4251
|
+
if (!cls || !REFERENCE_CLASSES.has(cls))
|
|
3541
4252
|
continue;
|
|
3542
4253
|
if (cls === "spec" && grandfatheredWhole.has(file.path))
|
|
3543
4254
|
continue;
|
|
3544
|
-
const blocking = cls === "product" || cls === "spec";
|
|
3545
4255
|
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3546
|
-
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3547
4256
|
const fileFindings = [];
|
|
3548
|
-
for (const
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
4257
|
+
for (const rule of referenceRulesFor(set, cls)) {
|
|
4258
|
+
if (!ruleReads(set, rule, file.path))
|
|
4259
|
+
continue;
|
|
4260
|
+
const pattern = !rule.custom && rule.id === "legacy-batch-name" ? legacyPattern : rule.patternFor(cls);
|
|
4261
|
+
if (!pattern)
|
|
4262
|
+
continue;
|
|
4263
|
+
const blocking = rule.severity[cls] === "error";
|
|
4264
|
+
const what = cls === "product" ? `${rule.message} in product code` : rule.message;
|
|
4265
|
+
for (const { cited, index } of citations(pattern, scrubbed, rule.custom ? undefined : rule.reportGroup)) {
|
|
3554
4266
|
fileFindings.push({
|
|
3555
4267
|
file: file.path,
|
|
3556
|
-
line: lineAt(scrubbed,
|
|
3557
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3558
|
-
blocking
|
|
4268
|
+
line: lineAt(scrubbed, index),
|
|
4269
|
+
message: rule.custom ? customMessage(rule, cited) : `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4270
|
+
blocking,
|
|
4271
|
+
rule: rule.id
|
|
3559
4272
|
});
|
|
3560
|
-
match = pattern.exec(scrubbed);
|
|
3561
4273
|
}
|
|
3562
4274
|
}
|
|
3563
4275
|
const limit = cls === "spec" ? limits.get(file.path) : undefined;
|
|
@@ -3598,11 +4310,17 @@ function definesOrLinksGlossary(content, term) {
|
|
|
3598
4310
|
return true;
|
|
3599
4311
|
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3600
4312
|
}
|
|
3601
|
-
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4313
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, options = {}) {
|
|
3602
4314
|
const findings = [];
|
|
4315
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4316
|
+
const rule = set.rules.find((r) => !r.custom && r.id === "coined-term");
|
|
4317
|
+
if (!rule)
|
|
4318
|
+
return findings;
|
|
3603
4319
|
for (const file of files) {
|
|
3604
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3605
|
-
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
4320
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, DEFAULT_SPEC_PATHS, options.productPaths);
|
|
4321
|
+
if (!cls || !SWEPT_CLASSES.has(cls) || !rule.scopes.includes(cls))
|
|
4322
|
+
continue;
|
|
4323
|
+
if (!ruleReads(set, rule, file.path))
|
|
3606
4324
|
continue;
|
|
3607
4325
|
const scrubbed = stripNonProse(file.path, file.content);
|
|
3608
4326
|
for (const term of glossaryTerms) {
|
|
@@ -3615,14 +4333,15 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
|
|
|
3615
4333
|
file: file.path,
|
|
3616
4334
|
line,
|
|
3617
4335
|
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3618
|
-
blocking:
|
|
4336
|
+
blocking: rule.severity[cls] === "error",
|
|
4337
|
+
rule: rule.id
|
|
3619
4338
|
});
|
|
3620
4339
|
}
|
|
3621
4340
|
}
|
|
3622
4341
|
return findings;
|
|
3623
4342
|
}
|
|
3624
|
-
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN =
|
|
3625
|
-
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN =
|
|
4343
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
|
|
4344
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
|
|
3626
4345
|
function extractComments(path, content) {
|
|
3627
4346
|
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3628
4347
|
return content.replace(/[^\n]/g, "");
|
|
@@ -3719,39 +4438,40 @@ function extractComments(path, content) {
|
|
|
3719
4438
|
}
|
|
3720
4439
|
return out;
|
|
3721
4440
|
}
|
|
3722
|
-
function checkSourceComments(files, allowlist = []) {
|
|
4441
|
+
function checkSourceComments(files, allowlist = [], options = {}) {
|
|
3723
4442
|
const findings = [];
|
|
3724
4443
|
const allowed = new Set(allowlist);
|
|
3725
|
-
const
|
|
3726
|
-
|
|
3727
|
-
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3728
|
-
];
|
|
4444
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4445
|
+
const rules = rulesInScope(set, "source-comment").filter((rule) => rule.group === "reader-resolvable");
|
|
3729
4446
|
for (const file of files) {
|
|
3730
4447
|
if (!file.path.endsWith(".ts"))
|
|
3731
4448
|
continue;
|
|
3732
4449
|
if (allowed.has(file.path))
|
|
3733
4450
|
continue;
|
|
3734
4451
|
const comments = extractComments(file.path, file.content);
|
|
3735
|
-
for (const
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
4452
|
+
for (const rule of rules) {
|
|
4453
|
+
if (!ruleReads(set, rule, file.path))
|
|
4454
|
+
continue;
|
|
4455
|
+
const pattern = rule.patternFor("source-comment");
|
|
4456
|
+
if (!pattern)
|
|
4457
|
+
continue;
|
|
4458
|
+
for (const { cited, index } of citations(pattern, comments)) {
|
|
3739
4459
|
findings.push({
|
|
3740
4460
|
file: file.path,
|
|
3741
|
-
line: lineAt(comments,
|
|
3742
|
-
message: `comment cites ${
|
|
3743
|
-
blocking:
|
|
4461
|
+
line: lineAt(comments, index),
|
|
4462
|
+
message: rule.custom ? customMessage(rule, cited) : `comment cites ${rule.message} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4463
|
+
blocking: rule.severity["source-comment"] === "error",
|
|
4464
|
+
rule: rule.id
|
|
3744
4465
|
});
|
|
3745
|
-
match = pattern.exec(comments);
|
|
3746
4466
|
}
|
|
3747
4467
|
}
|
|
3748
4468
|
}
|
|
3749
4469
|
return findings;
|
|
3750
4470
|
}
|
|
3751
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4471
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
3752
4472
|
return [
|
|
3753
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3754
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4473
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths, options),
|
|
4474
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix, options)
|
|
3755
4475
|
];
|
|
3756
4476
|
}
|
|
3757
4477
|
function parseGlossaryTerms(glossaryContent) {
|
|
@@ -3954,6 +4674,17 @@ function checkDocClaims(files, fileReader) {
|
|
|
3954
4674
|
};
|
|
3955
4675
|
}
|
|
3956
4676
|
|
|
4677
|
+
// ../../packages/aeg-core/src/protected-paths.ts
|
|
4678
|
+
import { posix as posixPath } from "node:path";
|
|
4679
|
+
var PROTECTED_ADMIN_PATHS = ["vinaya.config.json", ".vinaya/doc-owners", ".github/", "aeg-root/"];
|
|
4680
|
+
function normalizeTouchedPath(path) {
|
|
4681
|
+
return posixPath.resolve("/", path.replace(/\\/g, "/")).replace(/^\/+/, "");
|
|
4682
|
+
}
|
|
4683
|
+
function isProtectedAdminPath(path) {
|
|
4684
|
+
const normalized = normalizeTouchedPath(path);
|
|
4685
|
+
return PROTECTED_ADMIN_PATHS.some((prefix) => normalized === prefix || normalized.startsWith(prefix));
|
|
4686
|
+
}
|
|
4687
|
+
|
|
3957
4688
|
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3958
4689
|
function hasRationaleField(body, labelPattern) {
|
|
3959
4690
|
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
@@ -4073,13 +4804,20 @@ function globCoversPath(glob, path) {
|
|
|
4073
4804
|
return !p.includes("/");
|
|
4074
4805
|
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
4075
4806
|
}
|
|
4807
|
+
function surfaceEntryResolves(entry, resolvesToFile, pinnedFiles) {
|
|
4808
|
+
if (resolvesToFile(entry))
|
|
4809
|
+
return true;
|
|
4810
|
+
const directory = entry.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
4811
|
+
return pinnedFiles.some((path) => path.startsWith(`${directory}/`));
|
|
4812
|
+
}
|
|
4076
4813
|
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
4077
4814
|
const surface = parseIssueSurface(body);
|
|
4078
4815
|
if (!surface.ok)
|
|
4079
4816
|
return { status: "pass", errors: [] };
|
|
4817
|
+
const pinnedFiles = boundaryPinnedFiles(body);
|
|
4080
4818
|
const errors = [];
|
|
4081
4819
|
for (const glob of surface.value.in) {
|
|
4082
|
-
if (!
|
|
4820
|
+
if (!surfaceEntryResolves(glob, resolvesToFile, pinnedFiles)) {
|
|
4083
4821
|
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.`);
|
|
4084
4822
|
}
|
|
4085
4823
|
}
|
|
@@ -4109,6 +4847,14 @@ function recordedBeyondSurfacePaths(body) {
|
|
|
4109
4847
|
return paths;
|
|
4110
4848
|
}
|
|
4111
4849
|
function checkSurfaceScope(changedFiles, surface, recorded) {
|
|
4850
|
+
for (const path of changedFiles) {
|
|
4851
|
+
if (!isProtectedAdminPath(path))
|
|
4852
|
+
continue;
|
|
4853
|
+
const normalized = normalizeTouchedPath(path);
|
|
4854
|
+
if (!surface.in.some((glob) => globCoversPath(glob, normalized))) {
|
|
4855
|
+
return { ok: false, violation: { path, reason: "protected" } };
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4112
4858
|
const listed = new Set(recorded);
|
|
4113
4859
|
const violation = beyondSurfacePaths(changedFiles, surface).find((entry) => !listed.has(entry.path));
|
|
4114
4860
|
return violation ? { ok: false, violation } : { ok: true };
|
|
@@ -4164,12 +4910,22 @@ function checkPartsCiteDefinedObjectives(body) {
|
|
|
4164
4910
|
}
|
|
4165
4911
|
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4166
4912
|
}
|
|
4913
|
+
var ISSUE_LIVE_LINE_RE = /^-\s*\*{2}\[live\]\*{2}(.*)$/gim;
|
|
4914
|
+
function liveCommand(text) {
|
|
4915
|
+
const trimmed = text.trim();
|
|
4916
|
+
const span = /^(`+)(.+)\1$/.exec(trimmed);
|
|
4917
|
+
return span ? span[2].trim() : trimmed;
|
|
4918
|
+
}
|
|
4919
|
+
function liveItemsIn(region) {
|
|
4920
|
+
return [...region.matchAll(ISSUE_LIVE_LINE_RE)].map((m) => liveCommand(m[1] ?? "")).filter(Boolean);
|
|
4921
|
+
}
|
|
4922
|
+
function parseLiveTestPlanItems(body) {
|
|
4923
|
+
const located = locateTestPlanSection(body);
|
|
4924
|
+
return located.found ? liveItemsIn(located.section) : [];
|
|
4925
|
+
}
|
|
4167
4926
|
function isTaskIssueLabelSet(labels) {
|
|
4168
4927
|
return hasLabel("tranche", labels);
|
|
4169
4928
|
}
|
|
4170
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
4171
|
-
return { status: "pass", errors: [] };
|
|
4172
|
-
}
|
|
4173
4929
|
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4174
4930
|
if (!isTaskIssueLabelSet(labels))
|
|
4175
4931
|
return { status: "pass", errors: [] };
|
|
@@ -4185,6 +4941,7 @@ function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTi
|
|
|
4185
4941
|
};
|
|
4186
4942
|
}
|
|
4187
4943
|
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4944
|
+
var PATH_TEXT = (body) => stripCode(body, { inlineSpans: "keep" });
|
|
4188
4945
|
function isControlCodePoint(codePoint) {
|
|
4189
4946
|
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4190
4947
|
}
|
|
@@ -4245,8 +5002,14 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
|
4245
5002
|
}
|
|
4246
5003
|
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4247
5004
|
}
|
|
5005
|
+
function rationaleFieldText(text, labelPattern) {
|
|
5006
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})[^\\n]*\\n?([\\s\\S]*?)(?=\\n\\s*(?:\\*\\*[A-Z]|#{1,4}\\s)|(?![\\s\\S]))`, "im");
|
|
5007
|
+
const m = re.exec(text);
|
|
5008
|
+
return m ? m[0] : "";
|
|
5009
|
+
}
|
|
4248
5010
|
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;
|
|
4249
5011
|
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
5012
|
+
var RATIONALE_PATH_RE_GLOBAL = /`([\w.@-]+(?:\/[\w.@-]+)+)`/g;
|
|
4250
5013
|
function normalizeEdgeId(s) {
|
|
4251
5014
|
const qualified = splitSlugQualifiedEdge(s);
|
|
4252
5015
|
return (qualified ? qualified.bareId : s).replace(/^#/, "").trim();
|
|
@@ -4254,6 +5017,15 @@ function normalizeEdgeId(s) {
|
|
|
4254
5017
|
function edgesNameEachOther(a, b) {
|
|
4255
5018
|
return a.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(b.ref)) || b.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(a.ref));
|
|
4256
5019
|
}
|
|
5020
|
+
var BOUNDARY_OUT_RE = /\bOut\s*:\s*([\s\S]*)$/im;
|
|
5021
|
+
function boundaryOutText(body) {
|
|
5022
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5023
|
+
const m = BOUNDARY_OUT_RE.exec(boundary);
|
|
5024
|
+
return m ? m[1] : "";
|
|
5025
|
+
}
|
|
5026
|
+
function namedPathsIn(text) {
|
|
5027
|
+
return [...new Set([...text.matchAll(RATIONALE_PATH_RE_GLOBAL)].map((m) => m[1]))].filter((p) => !/^https?:\/\//i.test(p));
|
|
5028
|
+
}
|
|
4257
5029
|
var FILE_EXTENSIONS = new Set([
|
|
4258
5030
|
"ts",
|
|
4259
5031
|
"tsx",
|
|
@@ -4275,6 +5047,11 @@ var FILE_EXTENSIONS = new Set([
|
|
|
4275
5047
|
"html",
|
|
4276
5048
|
"css"
|
|
4277
5049
|
]);
|
|
5050
|
+
function boundaryPinnedFiles(body) {
|
|
5051
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5052
|
+
const excluded = new Set(namedPathsIn(boundaryOutText(body)));
|
|
5053
|
+
return namedPathsIn(boundary).filter((p) => looksLikeFilePath(p) && !excluded.has(p));
|
|
5054
|
+
}
|
|
4278
5055
|
var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
|
|
4279
5056
|
var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
|
|
4280
5057
|
|
|
@@ -4299,7 +5076,7 @@ function isGrandfathered(isoDate) {
|
|
|
4299
5076
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4300
5077
|
}
|
|
4301
5078
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4302
|
-
function checkA1(entries, principalAllowlist
|
|
5079
|
+
function checkA1(entries, principalAllowlist) {
|
|
4303
5080
|
const failures = [];
|
|
4304
5081
|
for (const e of entries) {
|
|
4305
5082
|
if (!e.facts)
|
|
@@ -4329,6 +5106,37 @@ function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
|
4329
5106
|
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4330
5107
|
};
|
|
4331
5108
|
}
|
|
5109
|
+
function checkA2(entries, hasProvenanceByKey) {
|
|
5110
|
+
const failures = [];
|
|
5111
|
+
for (const e of entries) {
|
|
5112
|
+
if (!e.facts)
|
|
5113
|
+
continue;
|
|
5114
|
+
if (e.facts.issueState !== "closed" || e.facts.prState !== "merged")
|
|
5115
|
+
continue;
|
|
5116
|
+
const key = `${e.trancheSlug}/${e.task.id}`;
|
|
5117
|
+
const hasProvenance = hasProvenanceByKey.get(key);
|
|
5118
|
+
if (hasProvenance === undefined)
|
|
5119
|
+
continue;
|
|
5120
|
+
if (!hasProvenance) {
|
|
5121
|
+
failures.push({
|
|
5122
|
+
code: "archived-without-provenance",
|
|
5123
|
+
issue: e.task.issue,
|
|
5124
|
+
tranche: e.trancheSlug,
|
|
5125
|
+
task: e.task.id,
|
|
5126
|
+
reason: "Closing PR has no `### AEG provenance` comment (Archivist close-out missing)",
|
|
5127
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
5128
|
+
});
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
5132
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
5133
|
+
return {
|
|
5134
|
+
check: "A2",
|
|
5135
|
+
status,
|
|
5136
|
+
failures,
|
|
5137
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
5138
|
+
};
|
|
5139
|
+
}
|
|
4332
5140
|
function checkA3(entries) {
|
|
4333
5141
|
const failures = [];
|
|
4334
5142
|
for (const e of entries) {
|
|
@@ -4544,6 +5352,33 @@ function checkL1(files, entriesBySlug) {
|
|
|
4544
5352
|
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4545
5353
|
};
|
|
4546
5354
|
}
|
|
5355
|
+
function checkL2(files, entriesBySlug) {
|
|
5356
|
+
const failures = [];
|
|
5357
|
+
for (const f of files) {
|
|
5358
|
+
if (!f.archived)
|
|
5359
|
+
continue;
|
|
5360
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
5361
|
+
for (const e of entries) {
|
|
5362
|
+
if (!e.facts)
|
|
5363
|
+
continue;
|
|
5364
|
+
if (e.facts.issueState === "open") {
|
|
5365
|
+
failures.push({
|
|
5366
|
+
code: "premature-archive",
|
|
5367
|
+
issue: e.task.issue,
|
|
5368
|
+
tranche: f.slug,
|
|
5369
|
+
task: e.task.id,
|
|
5370
|
+
reason: `Archived tranche has open task-Issue #${e.task.issue ?? "?"} (premature archive)`
|
|
5371
|
+
});
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
return {
|
|
5376
|
+
check: "L2",
|
|
5377
|
+
status: "info",
|
|
5378
|
+
failures,
|
|
5379
|
+
note: failures.length > 0 ? `${failures.length} archived tranche(s) with an open task-Issue — investigate (advisory)` : undefined
|
|
5380
|
+
};
|
|
5381
|
+
}
|
|
4547
5382
|
function checkL3(files) {
|
|
4548
5383
|
const active = files.filter((f) => !f.archived);
|
|
4549
5384
|
return {
|
|
@@ -4553,6 +5388,51 @@ function checkL3(files) {
|
|
|
4553
5388
|
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4554
5389
|
};
|
|
4555
5390
|
}
|
|
5391
|
+
function checkL4(activeTrancheSlugs, issueMilestones) {
|
|
5392
|
+
const activeSet = new Set(activeTrancheSlugs);
|
|
5393
|
+
const failures = [];
|
|
5394
|
+
for (const f of issueMilestones) {
|
|
5395
|
+
if (!activeSet.has(f.tranche))
|
|
5396
|
+
continue;
|
|
5397
|
+
if (f.milestoneTitle === f.tranche)
|
|
5398
|
+
continue;
|
|
5399
|
+
failures.push({
|
|
5400
|
+
code: "milestone-drift",
|
|
5401
|
+
issue: f.issue,
|
|
5402
|
+
tranche: f.tranche,
|
|
5403
|
+
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`
|
|
5404
|
+
});
|
|
5405
|
+
}
|
|
5406
|
+
return {
|
|
5407
|
+
check: "L4",
|
|
5408
|
+
status: "info",
|
|
5409
|
+
failures,
|
|
5410
|
+
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
|
|
5411
|
+
};
|
|
5412
|
+
}
|
|
5413
|
+
function checkL5(activeTrancheSlugs, entriesBySlug) {
|
|
5414
|
+
const failures = [];
|
|
5415
|
+
for (const slug of activeTrancheSlugs) {
|
|
5416
|
+
const entries = entriesBySlug.get(slug) ?? [];
|
|
5417
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
5418
|
+
if (withFacts.length === 0)
|
|
5419
|
+
continue;
|
|
5420
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
5421
|
+
if (allClosed) {
|
|
5422
|
+
failures.push({
|
|
5423
|
+
code: "tranche-not-archived",
|
|
5424
|
+
tranche: slug,
|
|
5425
|
+
reason: "Every task Issue is closed but the tranche is not recorded as complete — archive it"
|
|
5426
|
+
});
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
return {
|
|
5430
|
+
check: "L5",
|
|
5431
|
+
status: failures.length > 0 ? "fail" : "pass",
|
|
5432
|
+
failures,
|
|
5433
|
+
note: failures.length > 0 ? `${failures.length} tranche(s) whose task Issues are all closed but were never archived` : undefined
|
|
5434
|
+
};
|
|
5435
|
+
}
|
|
4556
5436
|
function extractClosesReferences(prBody) {
|
|
4557
5437
|
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4558
5438
|
const stripped = stripCode(prBody);
|
|
@@ -4648,6 +5528,58 @@ function extractIssue(body) {
|
|
|
4648
5528
|
}
|
|
4649
5529
|
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4650
5530
|
import { createHash as createHash4 } from "node:crypto";
|
|
5531
|
+
|
|
5532
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
5533
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
5534
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
5535
|
+
let best = 0;
|
|
5536
|
+
for (const c of comments) {
|
|
5537
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5538
|
+
continue;
|
|
5539
|
+
const firstLine = (c.body.split(`
|
|
5540
|
+
`)[0] ?? "").trim();
|
|
5541
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
5542
|
+
if (!m)
|
|
5543
|
+
continue;
|
|
5544
|
+
const k = Number.parseInt(m[1], 10);
|
|
5545
|
+
if (k > best)
|
|
5546
|
+
best = k;
|
|
5547
|
+
}
|
|
5548
|
+
return best;
|
|
5549
|
+
}
|
|
5550
|
+
function parseRulingIdentity(rulingId) {
|
|
5551
|
+
const m = /^(issue-)?(\d+)-(\d+)$/.exec(rulingId);
|
|
5552
|
+
if (!m)
|
|
5553
|
+
return null;
|
|
5554
|
+
const ref = Number.parseInt(m[2], 10);
|
|
5555
|
+
const ordinal = Number.parseInt(m[3], 10);
|
|
5556
|
+
if (ref <= 0 || ordinal <= 0)
|
|
5557
|
+
return null;
|
|
5558
|
+
return { target: m[1] ? "issue" : "pr", ref, ordinal };
|
|
5559
|
+
}
|
|
5560
|
+
function principalRulingTextById(comments, allowlist, rulingId) {
|
|
5561
|
+
const identity = parseRulingIdentity(rulingId);
|
|
5562
|
+
if (identity === null)
|
|
5563
|
+
return null;
|
|
5564
|
+
const matches = comments.filter((c) => {
|
|
5565
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5566
|
+
return false;
|
|
5567
|
+
const m = RULING_MARKER_ORDINAL.exec((c.body.split(`
|
|
5568
|
+
`)[0] ?? "").trim());
|
|
5569
|
+
return m !== null && Number.parseInt(m[1], 10) === identity.ordinal;
|
|
5570
|
+
});
|
|
5571
|
+
if (matches.length !== 1)
|
|
5572
|
+
return null;
|
|
5573
|
+
const body = matches[0].body;
|
|
5574
|
+
const idx = body.indexOf(`
|
|
5575
|
+
`);
|
|
5576
|
+
return idx === -1 ? "" : body.slice(idx + 1).trim();
|
|
5577
|
+
}
|
|
5578
|
+
|
|
5579
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
5580
|
+
function pauseBoundRulingDigest(rulingText) {
|
|
5581
|
+
return createHash4("sha256").update(rulingText).digest("hex");
|
|
5582
|
+
}
|
|
4651
5583
|
function briefHash(brief) {
|
|
4652
5584
|
return createHash4("sha256").update(`${brief}
|
|
4653
5585
|
`).digest("hex");
|
|
@@ -4708,14 +5640,19 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4708
5640
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4709
5641
|
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4710
5642
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
5643
|
+
const legacyCurrent = current.manifestVersion === undefined;
|
|
5644
|
+
const manifestVersion = legacyCurrent ? echoed.manifestVersion === undefined || echoed.manifestVersion === null : echoed.manifestVersion === current.manifestVersion;
|
|
5645
|
+
const pauseBoundRuling = legacyCurrent ? true : Object.hasOwn(echoed, "pauseBoundRuling") && JSON.stringify(echoed.pauseBoundRuling) === JSON.stringify(current.pauseBoundRuling);
|
|
4711
5646
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4712
5647
|
return {
|
|
4713
|
-
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
5648
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && pauseBoundRuling && manifestVersion && policyDigestBound,
|
|
4714
5649
|
head,
|
|
4715
5650
|
base,
|
|
4716
5651
|
briefHash: briefHashBound,
|
|
4717
5652
|
objectivesVersion,
|
|
4718
5653
|
rulingOrdinal,
|
|
5654
|
+
pauseBoundRuling,
|
|
5655
|
+
manifestVersion,
|
|
4719
5656
|
policyDigest: policyDigestBound
|
|
4720
5657
|
};
|
|
4721
5658
|
}
|
|
@@ -4731,7 +5668,7 @@ function renderGateDeferred(deferred) {
|
|
|
4731
5668
|
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4732
5669
|
}
|
|
4733
5670
|
function checkReviewGate(input) {
|
|
4734
|
-
const principalAllowlist = input
|
|
5671
|
+
const { principalAllowlist } = input;
|
|
4735
5672
|
const waived = isWaiverLabelActorVerified({
|
|
4736
5673
|
label: WAIVER_LABEL_REVIEW,
|
|
4737
5674
|
labels: input.labels,
|
|
@@ -4770,27 +5707,33 @@ function checkReviewGate(input) {
|
|
|
4770
5707
|
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4771
5708
|
const securityClean = securityTextClean && securityPolicyClean;
|
|
4772
5709
|
const currentManifest = {
|
|
5710
|
+
...input.manifestVersion === undefined ? {} : { manifestVersion: input.manifestVersion },
|
|
4773
5711
|
headSha: input.headSha,
|
|
4774
5712
|
baseSha: input.baseSha ?? null,
|
|
4775
5713
|
briefHash: input.briefHash ?? null,
|
|
4776
5714
|
objectivesVersion: input.objectivesVersion,
|
|
4777
5715
|
rulingOrdinal: input.rulingOrdinal,
|
|
5716
|
+
pauseBoundRuling: input.pauseBoundRuling ?? null,
|
|
4778
5717
|
policyDigest: policyDigest(policy)
|
|
4779
5718
|
};
|
|
4780
5719
|
const codeReviewEchoed = {
|
|
5720
|
+
manifestVersion: codeReview.manifestVersion,
|
|
4781
5721
|
headSha: codeReview.headSha,
|
|
4782
5722
|
baseSha: codeReview.baseSha,
|
|
4783
5723
|
briefHash: codeReview.briefHash,
|
|
4784
5724
|
objectivesVersion: codeReview.objectivesVersion,
|
|
4785
5725
|
rulingOrdinal: codeReview.rulingOrdinal,
|
|
5726
|
+
pauseBoundRuling: codeReview.pauseBoundRuling,
|
|
4786
5727
|
policyDigest: codeReview.policyDigest
|
|
4787
5728
|
};
|
|
4788
5729
|
const securityEchoed = {
|
|
5730
|
+
manifestVersion: security.manifestVersion,
|
|
4789
5731
|
headSha: security.headSha,
|
|
4790
5732
|
baseSha: security.baseSha,
|
|
4791
5733
|
briefHash: security.briefHash,
|
|
4792
5734
|
objectivesVersion: security.objectivesVersion,
|
|
4793
5735
|
rulingOrdinal: security.rulingOrdinal,
|
|
5736
|
+
pauseBoundRuling: security.pauseBoundRuling,
|
|
4794
5737
|
policyDigest: security.policyDigest
|
|
4795
5738
|
};
|
|
4796
5739
|
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
@@ -4829,6 +5772,10 @@ function checkReviewGate(input) {
|
|
|
4829
5772
|
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"}`);
|
|
4830
5773
|
} else if (!codeReviewBinding.policyDigest) {
|
|
4831
5774
|
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}`);
|
|
5775
|
+
} else if (!codeReviewBinding.manifestVersion) {
|
|
5776
|
+
problems.push(`the newest code-review verdict echoes manifest version ${codeReview.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5777
|
+
} else if (!codeReviewBinding.pauseBoundRuling) {
|
|
5778
|
+
problems.push(`the newest code-review verdict echoes pauseBoundRuling ${renderBinding(codeReview.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4832
5779
|
}
|
|
4833
5780
|
if (!securityTextClean) {
|
|
4834
5781
|
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
@@ -4846,6 +5793,10 @@ function checkReviewGate(input) {
|
|
|
4846
5793
|
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"}`);
|
|
4847
5794
|
} else if (!securityBinding.policyDigest) {
|
|
4848
5795
|
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}`);
|
|
5796
|
+
} else if (!securityBinding.manifestVersion) {
|
|
5797
|
+
problems.push(`the newest security-review verdict echoes manifest version ${security.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5798
|
+
} else if (!securityBinding.pauseBoundRuling) {
|
|
5799
|
+
problems.push(`the newest security-review verdict echoes pauseBoundRuling ${renderBinding(security.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4849
5800
|
}
|
|
4850
5801
|
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4851
5802
|
return {
|
|
@@ -4854,29 +5805,16 @@ function checkReviewGate(input) {
|
|
|
4854
5805
|
waived: false
|
|
4855
5806
|
};
|
|
4856
5807
|
}
|
|
5808
|
+
function renderBinding(binding) {
|
|
5809
|
+
if (binding === undefined)
|
|
5810
|
+
return "(absent)";
|
|
5811
|
+
return binding === null ? "(none)" : `${binding.rulingId}|${binding.pauseId}|${binding.contentDigest}`;
|
|
5812
|
+
}
|
|
4857
5813
|
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4858
5814
|
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4859
5815
|
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4860
5816
|
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4861
5817
|
}
|
|
4862
|
-
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4863
|
-
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4864
|
-
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4865
|
-
let best = 0;
|
|
4866
|
-
for (const c of comments) {
|
|
4867
|
-
if (!isPrincipal(c.author, allowlist))
|
|
4868
|
-
continue;
|
|
4869
|
-
const firstLine = (c.body.split(`
|
|
4870
|
-
`)[0] ?? "").trim();
|
|
4871
|
-
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4872
|
-
if (!m)
|
|
4873
|
-
continue;
|
|
4874
|
-
const k = Number.parseInt(m[1], 10);
|
|
4875
|
-
if (k > best)
|
|
4876
|
-
best = k;
|
|
4877
|
-
}
|
|
4878
|
-
return best;
|
|
4879
|
-
}
|
|
4880
5818
|
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4881
5819
|
function splitRow(line) {
|
|
4882
5820
|
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
@@ -5028,7 +5966,6 @@ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
|
5028
5966
|
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
5029
5967
|
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
5030
5968
|
"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)',
|
|
5031
|
-
"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)`,
|
|
5032
5969
|
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
5033
5970
|
};
|
|
5034
5971
|
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
@@ -5252,72 +6189,10 @@ function compareToBaseline(current, baseline) {
|
|
|
5252
6189
|
};
|
|
5253
6190
|
}
|
|
5254
6191
|
// ../../packages/aeg-core/src/retired-vocabulary.ts
|
|
5255
|
-
var
|
|
5256
|
-
var RETIRED_PATTERNS =
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
"decision (entry|logged)",
|
|
5260
|
-
"decision-log entry",
|
|
5261
|
-
"decision log entry",
|
|
5262
|
-
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
5263
|
-
"decision-log",
|
|
5264
|
-
"decision entr",
|
|
5265
|
-
"decisions? (are |is )?logged",
|
|
5266
|
-
"log entries",
|
|
5267
|
-
String.raw`decisions\.md`,
|
|
5268
|
-
"decisions-legacy",
|
|
5269
|
-
"CONTRADICTION",
|
|
5270
|
-
"assumes Tier 3",
|
|
5271
|
-
"Lock: ?YES",
|
|
5272
|
-
"Lock: ?NO",
|
|
5273
|
-
"lock approvals?",
|
|
5274
|
-
"approves locks",
|
|
5275
|
-
"Conforms to lock",
|
|
5276
|
-
"Challenges lock",
|
|
5277
|
-
"checkDecisionNumbersFresh",
|
|
5278
|
-
String.raw`roles/team-leader\.md`,
|
|
5279
|
-
String.raw`\(,`,
|
|
5280
|
-
String.raw`,\)`,
|
|
5281
|
-
String.raw`\(\.\)`,
|
|
5282
|
-
...PLAN_ON_DISK_PATTERNS
|
|
5283
|
-
];
|
|
5284
|
-
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
5285
|
-
var RETIRED_EXEMPT_SUBSTRINGS = [
|
|
5286
|
-
"docs/decisions-legacy.md",
|
|
5287
|
-
"apps/herald-ai/docs/",
|
|
5288
|
-
"apps/vada-ai/docs/",
|
|
5289
|
-
"aeg-root/tranches/completed/",
|
|
5290
|
-
"packages/aeg-core/src/docs/published-prose",
|
|
5291
|
-
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
5292
|
-
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
5293
|
-
"/fixtures/",
|
|
5294
|
-
"/node_modules/",
|
|
5295
|
-
"/.next/",
|
|
5296
|
-
"/.turbo/"
|
|
5297
|
-
];
|
|
5298
|
-
var PATTERN_EXEMPT = {
|
|
5299
|
-
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
5300
|
-
[String.raw`decisions\.md`]: [
|
|
5301
|
-
"docs-index.md",
|
|
5302
|
-
"apps/vada-ai/specs/legacy/README.md",
|
|
5303
|
-
"apps/vada-ai/specs/vada-product-spec.md",
|
|
5304
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5305
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5306
|
-
],
|
|
5307
|
-
"decisions-legacy": [
|
|
5308
|
-
"packages/aeg-core/src/file-classify.ts",
|
|
5309
|
-
"packages/aeg-core/src/file-classify.test.ts",
|
|
5310
|
-
"packages/aeg-core/src/pr-tier.test.ts",
|
|
5311
|
-
"docs-index.md",
|
|
5312
|
-
".claude/skills/database/SKILL.md",
|
|
5313
|
-
".claude/skills/vada-architecture/SKILL.md",
|
|
5314
|
-
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
5315
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5316
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5317
|
-
],
|
|
5318
|
-
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
5319
|
-
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
5320
|
-
};
|
|
6192
|
+
var retiredRules = rulesForGroup("retired-vocabulary");
|
|
6193
|
+
var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
|
|
6194
|
+
var PATTERN_EXEMPT = RETIRED_PATTERN_EXEMPTIONS;
|
|
6195
|
+
var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
|
|
5321
6196
|
function lineNumbers(content, pattern) {
|
|
5322
6197
|
const out = [];
|
|
5323
6198
|
const lines = content.split(`
|
|
@@ -5328,22 +6203,29 @@ function lineNumbers(content, pattern) {
|
|
|
5328
6203
|
}
|
|
5329
6204
|
return out;
|
|
5330
6205
|
}
|
|
5331
|
-
function scanRetiredVocabulary(files) {
|
|
6206
|
+
function scanRetiredVocabulary(files, rules = DEFAULT_PROSE_RULE_SET) {
|
|
5332
6207
|
const findings = [];
|
|
6208
|
+
const retired = rulesOfGroup(rules, "retired-vocabulary");
|
|
5333
6209
|
for (const file of files) {
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
6210
|
+
for (const rule of retired) {
|
|
6211
|
+
if (rule.substringExempt.some((e) => file.path.includes(e)))
|
|
6212
|
+
continue;
|
|
6213
|
+
if (!ruleReads(rules, rule, file.path))
|
|
6214
|
+
continue;
|
|
6215
|
+
const re = rule.patternFor("repository");
|
|
6216
|
+
if (!re)
|
|
6217
|
+
continue;
|
|
6218
|
+
const pattern = rule.custom ? re.source : DEFAULT_PATTERN_OF.get(rule.id) ?? re.source;
|
|
6219
|
+
if (!rule.custom && (PATTERN_EXEMPT[pattern] ?? []).some((e) => file.path.includes(e)))
|
|
5339
6220
|
continue;
|
|
5340
|
-
const re = new RegExp(pattern);
|
|
5341
6221
|
for (const line of lineNumbers(file.content, re)) {
|
|
5342
6222
|
findings.push({
|
|
5343
6223
|
file: file.path,
|
|
5344
6224
|
line,
|
|
5345
6225
|
pattern,
|
|
5346
|
-
message: `claims a retired AEG mechanism is still live (matches /${pattern}/)
|
|
6226
|
+
message: rule.custom ? `${rule.id}: ${rule.message} (matches /${pattern}/)` : `claims a retired AEG mechanism is still live (matches /${pattern}/)`,
|
|
6227
|
+
rule: rule.id,
|
|
6228
|
+
blocking: rule.severity.repository === "error"
|
|
5347
6229
|
});
|
|
5348
6230
|
}
|
|
5349
6231
|
}
|
|
@@ -5367,7 +6249,7 @@ function isSelfDependency(dep, task, issue) {
|
|
|
5367
6249
|
function checkDispatchReadiness(input) {
|
|
5368
6250
|
const { trancheSlug, task } = input;
|
|
5369
6251
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
5370
|
-
const principalAllowlist = input
|
|
6252
|
+
const { principalAllowlist } = input;
|
|
5371
6253
|
const blockerDetails = [];
|
|
5372
6254
|
const push = (blockerClass, message) => {
|
|
5373
6255
|
blockerDetails.push({ class: blockerClass, message });
|
|
@@ -5459,6 +6341,16 @@ function pushesAnyBranchRef(pushRefs) {
|
|
|
5459
6341
|
return pushRefs.split(`
|
|
5460
6342
|
`).map((line) => line.trim()).filter((line) => line.length > 0).some((line) => line.split(/\s+/)[2]?.startsWith("refs/heads/") === true);
|
|
5461
6343
|
}
|
|
6344
|
+
function resolveDefaultBranch(facts) {
|
|
6345
|
+
const { originHead, hasOriginMain, hasOriginMaster } = facts;
|
|
6346
|
+
if (originHead !== null && originHead !== "")
|
|
6347
|
+
return originHead;
|
|
6348
|
+
if (hasOriginMain)
|
|
6349
|
+
return "main";
|
|
6350
|
+
if (hasOriginMaster)
|
|
6351
|
+
return "master";
|
|
6352
|
+
return null;
|
|
6353
|
+
}
|
|
5462
6354
|
function checkMainBranchRefusal(facts) {
|
|
5463
6355
|
const { currentSymbolicBranch, defaultBranch, pushRefs = null } = facts;
|
|
5464
6356
|
if (currentSymbolicBranch === null)
|
|
@@ -5719,54 +6611,61 @@ function checkFirstPushDispatchGate(input) {
|
|
|
5719
6611
|
reason: `verify-dispatch reports READY TO DISPATCH for \`${branch}\`.`
|
|
5720
6612
|
};
|
|
5721
6613
|
}
|
|
5722
|
-
// ../../packages/aeg-core/src/
|
|
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
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
6614
|
+
// ../../packages/aeg-core/src/live-record.ts
|
|
6615
|
+
var RECORD_LINE_RE = /^-\s*\[([ xX])\]\s*\*\*\[live\]\*\*\s+(`+) ?(.+?) ?\2(?!`)\s+—\s+(passed|failed|unverified)\s+at\s+`([^`]+)`/;
|
|
6616
|
+
function liveMarkers(body) {
|
|
6617
|
+
const masked = maskCode(body);
|
|
6618
|
+
return [...masked.matchAll(/<!--\s*AEG:LIVE:(?:START|END)\s*-->/g)].map((m) => ({
|
|
6619
|
+
start: m.index,
|
|
6620
|
+
end: m.index + m[0].length
|
|
6621
|
+
}));
|
|
6622
|
+
}
|
|
6623
|
+
var AMBIGUOUS_RECORD_LINE = {
|
|
6624
|
+
line: "- [ ] **[live]** the pull request body carries more than one `AEG:LIVE` marker pair, so the driver's record cannot be told apart",
|
|
6625
|
+
ticked: false,
|
|
6626
|
+
command: "",
|
|
6627
|
+
outcome: "failed",
|
|
6628
|
+
head: ""
|
|
6629
|
+
};
|
|
6630
|
+
function readLiveRecord(body) {
|
|
6631
|
+
const markers = liveMarkers(body).length;
|
|
6632
|
+
if (markers === 0)
|
|
6633
|
+
return [];
|
|
6634
|
+
if (markers !== 2)
|
|
6635
|
+
return [AMBIGUOUS_RECORD_LINE];
|
|
6636
|
+
const region = anchoredRegion(body, "LIVE");
|
|
6637
|
+
if (region === null)
|
|
6638
|
+
return [];
|
|
6639
|
+
const lines = [];
|
|
6640
|
+
for (const raw of region.split(`
|
|
6641
|
+
`)) {
|
|
6642
|
+
const line = raw.trim();
|
|
6643
|
+
const m = RECORD_LINE_RE.exec(line);
|
|
6644
|
+
if (!m)
|
|
6645
|
+
continue;
|
|
6646
|
+
lines.push({
|
|
6647
|
+
line,
|
|
6648
|
+
ticked: m[1].toLowerCase() === "x",
|
|
6649
|
+
command: m[3],
|
|
6650
|
+
outcome: m[4],
|
|
6651
|
+
head: m[5]
|
|
6652
|
+
});
|
|
5760
6653
|
}
|
|
5761
|
-
return
|
|
5762
|
-
action: "assign",
|
|
5763
|
-
issue,
|
|
5764
|
-
login,
|
|
5765
|
-
reason: `First push of \`${branch}\` — assigning Issue #${issue} to @${login} (the authenticated pusher).`
|
|
5766
|
-
};
|
|
6654
|
+
return lines;
|
|
5767
6655
|
}
|
|
5768
6656
|
// ../../packages/aeg-core/src/test-plan-gate.ts
|
|
5769
|
-
function
|
|
6657
|
+
function gradedLiveLines(record, live) {
|
|
6658
|
+
if (live === undefined)
|
|
6659
|
+
return record.map((entry) => entry.line);
|
|
6660
|
+
const commands = new Set(live.liveCommands);
|
|
6661
|
+
const others = record.filter((entry) => !commands.has(entry.command)).map((entry) => entry.line);
|
|
6662
|
+
const graded = live.liveCommands.map((command) => {
|
|
6663
|
+
const atHead = record.filter((entry) => entry.command === command && entry.head === live.head);
|
|
6664
|
+
return (atHead.find((entry) => entry.ticked) ?? atHead[0])?.line ?? `- [ ] **[live]** \`${command}\` — no passed run recorded at \`${live.head || "an unknown head"}\``;
|
|
6665
|
+
});
|
|
6666
|
+
return [...others, ...graded];
|
|
6667
|
+
}
|
|
6668
|
+
function evaluateTestPlanGate(body, branch, live) {
|
|
5770
6669
|
if (!body) {
|
|
5771
6670
|
return {
|
|
5772
6671
|
verdict: "pass",
|
|
@@ -5777,7 +6676,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5777
6676
|
};
|
|
5778
6677
|
}
|
|
5779
6678
|
const located = locateTestPlanSection(body);
|
|
5780
|
-
|
|
6679
|
+
const liveLines = gradedLiveLines(readLiveRecord(body), live);
|
|
6680
|
+
const liveUnticked = liveLines.some((line) => /^[-*]\s+\[\s\]/.test(line));
|
|
6681
|
+
if (!located.found && !liveUnticked) {
|
|
5781
6682
|
if (parseTaskBranchIdentity(branch) !== null) {
|
|
5782
6683
|
return {
|
|
5783
6684
|
verdict: "fail",
|
|
@@ -5797,15 +6698,18 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5797
6698
|
]
|
|
5798
6699
|
};
|
|
5799
6700
|
}
|
|
5800
|
-
const section = located.section;
|
|
5801
|
-
if (/unit-tests-only/i.test(section)) {
|
|
6701
|
+
const section = located.found ? located.section : "";
|
|
6702
|
+
if (/unit-tests-only/i.test(section) && !liveUnticked) {
|
|
5802
6703
|
return {
|
|
5803
6704
|
verdict: "pass",
|
|
5804
6705
|
messages: ["Test Plan: unit-tests-only — pure-logic brief, CI unit-tests are the proof.", "PASS."]
|
|
5805
6706
|
};
|
|
5806
6707
|
}
|
|
5807
|
-
const checkboxLines =
|
|
5808
|
-
|
|
6708
|
+
const checkboxLines = [
|
|
6709
|
+
...section.split(`
|
|
6710
|
+
`).map((line) => line.trimStart()).filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line)),
|
|
6711
|
+
...liveLines
|
|
6712
|
+
];
|
|
5809
6713
|
if (checkboxLines.length === 0) {
|
|
5810
6714
|
return {
|
|
5811
6715
|
verdict: "pass",
|
|
@@ -5822,7 +6726,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5822
6726
|
messages.push("", "FAIL — the following [principal] Test Plan items are unticked:");
|
|
5823
6727
|
for (const line of unchecked)
|
|
5824
6728
|
messages.push(` ${line}`);
|
|
5825
|
-
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.",
|
|
6729
|
+
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 ? [
|
|
6730
|
+
"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."
|
|
6731
|
+
] : [], "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.");
|
|
5826
6732
|
return { verdict: "fail", messages };
|
|
5827
6733
|
}
|
|
5828
6734
|
messages.push("All [principal] Test Plan items ticked — runtime verification complete.", "PASS.");
|
|
@@ -6011,9 +6917,11 @@ var LineageSchema = z3.object({
|
|
|
6011
6917
|
parent: z3.string().nullable()
|
|
6012
6918
|
}).strict();
|
|
6013
6919
|
var InputVersionsSchema = z3.object({
|
|
6920
|
+
manifest_version: z3.literal(2).nullable().optional(),
|
|
6014
6921
|
objectives_version: z3.string().nullable(),
|
|
6015
6922
|
brief_hash: z3.string().nullable(),
|
|
6016
6923
|
ruling_ordinal: z3.number().int().nullable(),
|
|
6924
|
+
pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
|
|
6017
6925
|
policy_digest: z3.string().nullable()
|
|
6018
6926
|
}).strict();
|
|
6019
6927
|
var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
@@ -6561,17 +7469,19 @@ function buildHeader(input) {
|
|
|
6561
7469
|
parent: lineageFieldFromEnv(input.env.parent)
|
|
6562
7470
|
},
|
|
6563
7471
|
input_versions: {
|
|
7472
|
+
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
6564
7473
|
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
6565
7474
|
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
6566
7475
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
7476
|
+
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
6567
7477
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
6568
7478
|
},
|
|
6569
7479
|
provenance: provenanceFor(input),
|
|
6570
7480
|
work: {
|
|
6571
7481
|
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
6572
7482
|
repo: input.repo,
|
|
6573
|
-
change: null,
|
|
6574
|
-
revision: null
|
|
7483
|
+
change: pr === undefined ? null : String(pr),
|
|
7484
|
+
revision: input.revision ?? null
|
|
6575
7485
|
},
|
|
6576
7486
|
flow: {
|
|
6577
7487
|
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
@@ -6759,6 +7669,12 @@ var ManifestRecordSchema = z4.object({
|
|
|
6759
7669
|
briefHash: z4.string().min(1).nullable(),
|
|
6760
7670
|
objectivesVersion: z4.string().min(1).nullable(),
|
|
6761
7671
|
rulingOrdinal: epochNumber,
|
|
7672
|
+
manifestVersion: z4.literal(2).optional(),
|
|
7673
|
+
pauseBoundRuling: z4.object({
|
|
7674
|
+
rulingId: z4.string().min(1),
|
|
7675
|
+
pauseId: z4.string().min(1),
|
|
7676
|
+
contentDigest: z4.string().min(1)
|
|
7677
|
+
}).strict().nullable().optional(),
|
|
6762
7678
|
policyDigest: z4.string().min(1),
|
|
6763
7679
|
recordedAt: isoTimestamp
|
|
6764
7680
|
}).strict();
|
|
@@ -6780,7 +7696,11 @@ var LoopStateRecordSchema = z4.object({
|
|
|
6780
7696
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6781
7697
|
repeatMemory: z4.object({
|
|
6782
7698
|
blockingFindings: z4.array(z4.string()),
|
|
6783
|
-
lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
|
|
7699
|
+
lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
|
|
7700
|
+
}).strict().optional(),
|
|
7701
|
+
developerHandoff: z4.object({
|
|
7702
|
+
findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
|
|
7703
|
+
failingChecks: z4.array(z4.string().min(1))
|
|
6784
7704
|
}).strict().optional(),
|
|
6785
7705
|
publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
6786
7706
|
taskStartedAt: isoTimestamp.optional(),
|
|
@@ -6843,29 +7763,320 @@ import { promisify as promisify4 } from "node:util";
|
|
|
6843
7763
|
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
6844
7764
|
import { homedir } from "node:os";
|
|
6845
7765
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
6846
|
-
import { z as
|
|
7766
|
+
import { z as z6 } from "zod";
|
|
7767
|
+
|
|
7768
|
+
// src/checks/contract.ts
|
|
7769
|
+
var CHECK_SCHEMA_VERSION = 1;
|
|
7770
|
+
function emitCheckError(error) {
|
|
7771
|
+
process.stderr.write(`${JSON.stringify(error)}
|
|
7772
|
+
`);
|
|
7773
|
+
}
|
|
6847
7774
|
|
|
6848
7775
|
// src/lib/agent-vendors.ts
|
|
6849
7776
|
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
6850
7777
|
|
|
7778
|
+
// src/lib/prose-rules-config.ts
|
|
7779
|
+
import safeRegex from "safe-regex2";
|
|
7780
|
+
import { z as z5 } from "zod";
|
|
7781
|
+
var SEVERITIES = ["error", "warning"];
|
|
7782
|
+
var OVERRIDE_KEYS = ["scopes", "severity", "exempt"];
|
|
7783
|
+
var FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
|
|
7784
|
+
var CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
|
|
7785
|
+
var DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
|
|
7786
|
+
function isPlainObject3(value) {
|
|
7787
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7788
|
+
}
|
|
7789
|
+
function outsideRepositoryReason(entry) {
|
|
7790
|
+
if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
|
|
7791
|
+
return "must be a repository-relative path, not an absolute one";
|
|
7792
|
+
if (entry.split(/[\\/]/).includes(".."))
|
|
7793
|
+
return "must stay inside the repository — no `..` segment";
|
|
7794
|
+
return null;
|
|
7795
|
+
}
|
|
7796
|
+
var RepoRelativePathSchema = z5.string().min(1).superRefine((entry, ctx) => {
|
|
7797
|
+
const reason = outsideRepositoryReason(entry);
|
|
7798
|
+
if (reason)
|
|
7799
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, message: reason });
|
|
7800
|
+
});
|
|
7801
|
+
function pathListIssues(value, path, issues) {
|
|
7802
|
+
if (!Array.isArray(value)) {
|
|
7803
|
+
issues.push({ path, message: "must be a list of repository-relative paths" });
|
|
7804
|
+
return;
|
|
7805
|
+
}
|
|
7806
|
+
value.forEach((entry, index) => {
|
|
7807
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
7808
|
+
issues.push({ path: [...path, index], message: "must be a non-empty repository-relative path" });
|
|
7809
|
+
return;
|
|
7810
|
+
}
|
|
7811
|
+
const reason = outsideRepositoryReason(entry);
|
|
7812
|
+
if (reason)
|
|
7813
|
+
issues.push({ path: [...path, index], message: reason });
|
|
7814
|
+
});
|
|
7815
|
+
}
|
|
7816
|
+
function scopeListIssues(value, path, allowed, issues) {
|
|
7817
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
7818
|
+
issues.push({ path, message: "must name at least one scope" });
|
|
7819
|
+
return null;
|
|
7820
|
+
}
|
|
7821
|
+
const scopes = [];
|
|
7822
|
+
value.forEach((scope, index) => {
|
|
7823
|
+
if (typeof scope !== "string" || !CONFIGURABLE_PROSE_SCOPES.includes(scope)) {
|
|
7824
|
+
issues.push({
|
|
7825
|
+
path: [...path, index],
|
|
7826
|
+
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(", ")}`
|
|
7827
|
+
});
|
|
7828
|
+
return;
|
|
7829
|
+
}
|
|
7830
|
+
if (!allowed.includes(scope)) {
|
|
7831
|
+
issues.push({
|
|
7832
|
+
path: [...path, index],
|
|
7833
|
+
message: `scope "${scope}" is not one this rule can run in — it can run in: ${allowed.join(", ")}`
|
|
7834
|
+
});
|
|
7835
|
+
return;
|
|
7836
|
+
}
|
|
7837
|
+
scopes.push(scope);
|
|
7838
|
+
});
|
|
7839
|
+
return scopes;
|
|
7840
|
+
}
|
|
7841
|
+
function severityIssues(value, path, scopes, issues) {
|
|
7842
|
+
if (typeof value === "string") {
|
|
7843
|
+
if (!SEVERITIES.includes(value)) {
|
|
7844
|
+
issues.push({ path, message: `unknown severity ${JSON.stringify(value)} — use "error" or "warning"` });
|
|
7845
|
+
}
|
|
7846
|
+
return;
|
|
7847
|
+
}
|
|
7848
|
+
if (!isPlainObject3(value)) {
|
|
7849
|
+
issues.push({ path, message: 'must be "error", "warning", or a map from scope to one of them' });
|
|
7850
|
+
return;
|
|
7851
|
+
}
|
|
7852
|
+
for (const [scope, severity] of Object.entries(value)) {
|
|
7853
|
+
if (!scopes.includes(scope)) {
|
|
7854
|
+
issues.push({ path: [...path, scope], message: `names scope "${scope}", which this rule's scopes do not cover` });
|
|
7855
|
+
}
|
|
7856
|
+
if (typeof severity !== "string" || !SEVERITIES.includes(severity)) {
|
|
7857
|
+
issues.push({
|
|
7858
|
+
path: [...path, scope],
|
|
7859
|
+
message: `unknown severity ${JSON.stringify(severity)} — use "error" or "warning"`
|
|
7860
|
+
});
|
|
7861
|
+
}
|
|
7862
|
+
}
|
|
7863
|
+
}
|
|
7864
|
+
function patternIssues(source, flags, path, issues) {
|
|
7865
|
+
if (typeof source !== "string" || source.length === 0) {
|
|
7866
|
+
issues.push({ path, message: "must be a non-empty regular expression" });
|
|
7867
|
+
return;
|
|
7868
|
+
}
|
|
7869
|
+
if (source.length > CONFIGURED_PATTERN_MAX_LENGTH) {
|
|
7870
|
+
issues.push({
|
|
7871
|
+
path,
|
|
7872
|
+
message: `is ${source.length} characters, over the ${CONFIGURED_PATTERN_MAX_LENGTH}-character limit for a configured pattern`
|
|
7873
|
+
});
|
|
7874
|
+
return;
|
|
7875
|
+
}
|
|
7876
|
+
try {
|
|
7877
|
+
new RegExp(source, flags);
|
|
7878
|
+
} catch (err) {
|
|
7879
|
+
issues.push({ path, message: `does not compile: ${err.message}` });
|
|
7880
|
+
return;
|
|
7881
|
+
}
|
|
7882
|
+
if (!safeRegex(source, { limit: Number.MAX_SAFE_INTEGER })) {
|
|
7883
|
+
issues.push({
|
|
7884
|
+
path,
|
|
7885
|
+
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."
|
|
7886
|
+
});
|
|
7887
|
+
}
|
|
7888
|
+
}
|
|
7889
|
+
function flagIssues(value, path, issues) {
|
|
7890
|
+
if (value === undefined)
|
|
7891
|
+
return "";
|
|
7892
|
+
if (typeof value !== "string") {
|
|
7893
|
+
issues.push({ path, message: 'must be a string of flags, e.g. "i"' });
|
|
7894
|
+
return "";
|
|
7895
|
+
}
|
|
7896
|
+
const seen = new Set;
|
|
7897
|
+
for (const flag of value) {
|
|
7898
|
+
if (!CONFIGURED_PROSE_FLAGS.includes(flag)) {
|
|
7899
|
+
issues.push({
|
|
7900
|
+
path,
|
|
7901
|
+
message: `unknown flag ${JSON.stringify(flag)} — only ${CONFIGURED_PROSE_FLAGS.map((f) => `"${f}"`).join(" and ")} are allowed`
|
|
7902
|
+
});
|
|
7903
|
+
return "";
|
|
7904
|
+
}
|
|
7905
|
+
if (seen.has(flag)) {
|
|
7906
|
+
issues.push({ path, message: `repeats the flag "${flag}"` });
|
|
7907
|
+
return "";
|
|
7908
|
+
}
|
|
7909
|
+
seen.add(flag);
|
|
7910
|
+
}
|
|
7911
|
+
return value;
|
|
7912
|
+
}
|
|
7913
|
+
function defaultsIssues(value, issues) {
|
|
7914
|
+
const base = ["defaults"];
|
|
7915
|
+
if (!isPlainObject3(value)) {
|
|
7916
|
+
issues.push({ path: base, message: 'must map a default rule id to "off" or an override' });
|
|
7917
|
+
return;
|
|
7918
|
+
}
|
|
7919
|
+
for (const [id, override] of Object.entries(value)) {
|
|
7920
|
+
const path = [...base, id];
|
|
7921
|
+
const rule = CONFIGURABLE_DEFAULT_RULES.find((candidate) => candidate.id === id);
|
|
7922
|
+
if (!rule) {
|
|
7923
|
+
issues.push({
|
|
7924
|
+
path,
|
|
7925
|
+
message: `unknown default rule id "${id}" — \`vinaya check --plan\` lists the rules each prose check runs`
|
|
7926
|
+
});
|
|
7927
|
+
continue;
|
|
7928
|
+
}
|
|
7929
|
+
if (override === "off")
|
|
7930
|
+
continue;
|
|
7931
|
+
if (!isPlainObject3(override)) {
|
|
7932
|
+
issues.push({ path, message: 'must be "off" or an object with any of scopes, severity, exempt' });
|
|
7933
|
+
continue;
|
|
7934
|
+
}
|
|
7935
|
+
for (const key of Object.keys(override)) {
|
|
7936
|
+
if (OVERRIDE_KEYS.includes(key))
|
|
7937
|
+
continue;
|
|
7938
|
+
issues.push({
|
|
7939
|
+
path: [...path, key],
|
|
7940
|
+
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`
|
|
7941
|
+
});
|
|
7942
|
+
}
|
|
7943
|
+
const scopes = override.scopes === undefined ? [...rule.scopes] : scopeListIssues(override.scopes, [...path, "scopes"], allowedScopesFor(rule), issues);
|
|
7944
|
+
if (override.severity !== undefined && scopes)
|
|
7945
|
+
severityIssues(override.severity, [...path, "severity"], scopes, issues);
|
|
7946
|
+
if (override.exempt !== undefined)
|
|
7947
|
+
pathListIssues(override.exempt, [...path, "exempt"], issues);
|
|
7948
|
+
}
|
|
7949
|
+
}
|
|
7950
|
+
function customIssues(value, issues) {
|
|
7951
|
+
if (!Array.isArray(value)) {
|
|
7952
|
+
issues.push({ path: ["custom"], message: "must be a list of rules" });
|
|
7953
|
+
return;
|
|
7954
|
+
}
|
|
7955
|
+
const ids = new Set;
|
|
7956
|
+
value.forEach((rule, index) => {
|
|
7957
|
+
const path = ["custom", index];
|
|
7958
|
+
if (!isPlainObject3(rule)) {
|
|
7959
|
+
issues.push({ path, message: "must be a rule object" });
|
|
7960
|
+
return;
|
|
7961
|
+
}
|
|
7962
|
+
for (const key of Object.keys(rule)) {
|
|
7963
|
+
if (!CUSTOM_KEYS.includes(key)) {
|
|
7964
|
+
issues.push({ path: [...path, key], message: `unknown key "${key}" — a rule takes ${CUSTOM_KEYS.join(", ")}` });
|
|
7965
|
+
}
|
|
7966
|
+
}
|
|
7967
|
+
if (typeof rule.id !== "string" || rule.id.length === 0) {
|
|
7968
|
+
issues.push({ path: [...path, "id"], message: "a custom rule needs an id" });
|
|
7969
|
+
} else if (DEFAULT_IDS.has(rule.id)) {
|
|
7970
|
+
issues.push({
|
|
7971
|
+
path: [...path, "id"],
|
|
7972
|
+
message: `"${rule.id}" is a default rule id — a custom rule needs its own id; retune the default under proseGates.rules.defaults instead`
|
|
7973
|
+
});
|
|
7974
|
+
} else if (ids.has(rule.id)) {
|
|
7975
|
+
issues.push({ path: [...path, "id"], message: `"${rule.id}" is used by an earlier custom rule` });
|
|
7976
|
+
} else {
|
|
7977
|
+
ids.add(rule.id);
|
|
7978
|
+
}
|
|
7979
|
+
if (typeof rule.means !== "string" || rule.means.trim().length === 0) {
|
|
7980
|
+
issues.push({ path: [...path, "means"], message: "a custom rule needs a message (`means`)" });
|
|
7981
|
+
}
|
|
7982
|
+
let scopes = null;
|
|
7983
|
+
if (rule.scopes === undefined) {
|
|
7984
|
+
issues.push({ path: [...path, "scopes"], message: "a custom rule needs at least one scope (`scopes`)" });
|
|
7985
|
+
} else {
|
|
7986
|
+
scopes = scopeListIssues(rule.scopes, [...path, "scopes"], CONFIGURABLE_PROSE_SCOPES, issues);
|
|
7987
|
+
}
|
|
7988
|
+
if (scopes && new Set(scopes.map(groupOfScope)).size > 1) {
|
|
7989
|
+
issues.push({
|
|
7990
|
+
path: [...path, "scopes"],
|
|
7991
|
+
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'
|
|
7992
|
+
});
|
|
7993
|
+
}
|
|
7994
|
+
const flags = flagIssues(rule.flags, [...path, "flags"], issues);
|
|
7995
|
+
if (rule.pattern === undefined && rule.patterns === undefined) {
|
|
7996
|
+
issues.push({
|
|
7997
|
+
path: [...path, "pattern"],
|
|
7998
|
+
message: "a custom rule needs a `pattern` or a per-scope `patterns` map"
|
|
7999
|
+
});
|
|
8000
|
+
}
|
|
8001
|
+
if (rule.pattern !== undefined)
|
|
8002
|
+
patternIssues(rule.pattern, flags, [...path, "pattern"], issues);
|
|
8003
|
+
if (rule.patterns !== undefined) {
|
|
8004
|
+
if (!isPlainObject3(rule.patterns)) {
|
|
8005
|
+
issues.push({ path: [...path, "patterns"], message: "must map a scope to a regular expression" });
|
|
8006
|
+
} else {
|
|
8007
|
+
for (const [scope, source] of Object.entries(rule.patterns)) {
|
|
8008
|
+
if (scopes && !scopes.includes(scope)) {
|
|
8009
|
+
issues.push({
|
|
8010
|
+
path: [...path, "patterns", scope],
|
|
8011
|
+
message: `names scope "${scope}", which this rule's scopes do not cover`
|
|
8012
|
+
});
|
|
8013
|
+
continue;
|
|
8014
|
+
}
|
|
8015
|
+
patternIssues(source, flags, [...path, "patterns", scope], issues);
|
|
8016
|
+
}
|
|
8017
|
+
if (rule.pattern === undefined && scopes) {
|
|
8018
|
+
for (const scope of scopes) {
|
|
8019
|
+
if (!(scope in rule.patterns)) {
|
|
8020
|
+
issues.push({
|
|
8021
|
+
path: [...path, "patterns"],
|
|
8022
|
+
message: `has no pattern for scope "${scope}" — add one, or a \`pattern\` every other scope uses`
|
|
8023
|
+
});
|
|
8024
|
+
}
|
|
8025
|
+
}
|
|
8026
|
+
}
|
|
8027
|
+
}
|
|
8028
|
+
}
|
|
8029
|
+
if (rule.severity !== undefined && scopes)
|
|
8030
|
+
severityIssues(rule.severity, [...path, "severity"], scopes, issues);
|
|
8031
|
+
if (rule.exempt !== undefined)
|
|
8032
|
+
pathListIssues(rule.exempt, [...path, "exempt"], issues);
|
|
8033
|
+
});
|
|
8034
|
+
}
|
|
8035
|
+
function proseRulesIssues(value) {
|
|
8036
|
+
const issues = [];
|
|
8037
|
+
if (!isPlainObject3(value))
|
|
8038
|
+
return [{ path: [], message: "must be an object with any of exempt, defaults, custom" }];
|
|
8039
|
+
for (const key of Object.keys(value)) {
|
|
8040
|
+
if (!["exempt", "defaults", "custom"].includes(key)) {
|
|
8041
|
+
issues.push({ path: [key], message: `unknown key "${key}" — proseGates.rules takes exempt, defaults and custom` });
|
|
8042
|
+
}
|
|
8043
|
+
}
|
|
8044
|
+
if (value.exempt !== undefined)
|
|
8045
|
+
pathListIssues(value.exempt, ["exempt"], issues);
|
|
8046
|
+
if (value.defaults !== undefined)
|
|
8047
|
+
defaultsIssues(value.defaults, issues);
|
|
8048
|
+
if (value.custom !== undefined)
|
|
8049
|
+
customIssues(value.custom, issues);
|
|
8050
|
+
return issues;
|
|
8051
|
+
}
|
|
8052
|
+
var ProseRulesSchema = z5.unknown().superRefine((value, ctx) => {
|
|
8053
|
+
for (const issue of proseRulesIssues(value)) {
|
|
8054
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: issue.path, message: issue.message });
|
|
8055
|
+
}
|
|
8056
|
+
}).transform((value) => value);
|
|
8057
|
+
var PublishedProseSchema = z5.object({
|
|
8058
|
+
allow: z5.array(z5.string().min(1)).optional()
|
|
8059
|
+
}).strict();
|
|
8060
|
+
|
|
6851
8061
|
// src/lib/config.ts
|
|
6852
|
-
var EnvEntrySchema =
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
8062
|
+
var EnvEntrySchema = z6.union([
|
|
8063
|
+
z6.literal(true),
|
|
8064
|
+
z6.object({ optional: z6.literal(true) }),
|
|
8065
|
+
z6.object({ anyOf: z6.array(z6.string()).min(2) }),
|
|
8066
|
+
z6.string()
|
|
6857
8067
|
]);
|
|
6858
|
-
var CheckEntrySchema =
|
|
6859
|
-
run:
|
|
6860
|
-
scope:
|
|
6861
|
-
include:
|
|
6862
|
-
args:
|
|
6863
|
-
timeoutMs:
|
|
6864
|
-
env:
|
|
6865
|
-
requiresOpenPr:
|
|
6866
|
-
ownWorkflow:
|
|
6867
|
-
principalOwed:
|
|
6868
|
-
validates:
|
|
8068
|
+
var CheckEntrySchema = z6.object({
|
|
8069
|
+
run: z6.string(),
|
|
8070
|
+
scope: z6.enum(["diff", "full"]),
|
|
8071
|
+
include: z6.array(z6.string()).optional(),
|
|
8072
|
+
args: z6.array(z6.string()).optional(),
|
|
8073
|
+
timeoutMs: z6.number().optional(),
|
|
8074
|
+
env: z6.record(z6.string(), EnvEntrySchema).optional(),
|
|
8075
|
+
requiresOpenPr: z6.boolean().optional(),
|
|
8076
|
+
ownWorkflow: z6.boolean().optional(),
|
|
8077
|
+
principalOwed: z6.literal(true).optional(),
|
|
8078
|
+
validates: z6.enum(["body", "issue"]).optional(),
|
|
8079
|
+
advisory: z6.literal(true).optional()
|
|
6869
8080
|
}).superRefine((entry, ctx) => {
|
|
6870
8081
|
if (!entry.env)
|
|
6871
8082
|
return;
|
|
@@ -6875,22 +8086,22 @@ var CheckEntrySchema = z5.object({
|
|
|
6875
8086
|
const members = value.anyOf;
|
|
6876
8087
|
if (new Set(members).size !== members.length) {
|
|
6877
8088
|
ctx.addIssue({
|
|
6878
|
-
code:
|
|
8089
|
+
code: z6.ZodIssueCode.custom,
|
|
6879
8090
|
message: `env.${key}.anyOf has duplicate members`,
|
|
6880
8091
|
path: ["env", key, "anyOf"]
|
|
6881
8092
|
});
|
|
6882
8093
|
}
|
|
6883
8094
|
if (!members.includes(key)) {
|
|
6884
8095
|
ctx.addIssue({
|
|
6885
|
-
code:
|
|
8096
|
+
code: z6.ZodIssueCode.custom,
|
|
6886
8097
|
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
6887
8098
|
path: ["env", key, "anyOf"]
|
|
6888
8099
|
});
|
|
6889
8100
|
}
|
|
6890
8101
|
}
|
|
6891
8102
|
});
|
|
6892
|
-
var RoleEntrySchema =
|
|
6893
|
-
contract:
|
|
8103
|
+
var RoleEntrySchema = z6.object({
|
|
8104
|
+
contract: z6.string().refine((p) => p.includes("/"), {
|
|
6894
8105
|
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
6895
8106
|
})
|
|
6896
8107
|
});
|
|
@@ -6914,17 +8125,17 @@ var BRIEF_BUILTINS = [
|
|
|
6914
8125
|
"briefSections",
|
|
6915
8126
|
"milestoneShape"
|
|
6916
8127
|
];
|
|
6917
|
-
var BriefSectionSchema =
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
8128
|
+
var BriefSectionSchema = z6.union([
|
|
8129
|
+
z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
|
|
8130
|
+
z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
|
|
8131
|
+
z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
|
|
8132
|
+
z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
|
|
6922
8133
|
]);
|
|
6923
|
-
var BriefSchemaSchema =
|
|
6924
|
-
pr:
|
|
6925
|
-
issue:
|
|
6926
|
-
milestone:
|
|
6927
|
-
ack:
|
|
8134
|
+
var BriefSchemaSchema = z6.object({
|
|
8135
|
+
pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8136
|
+
issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8137
|
+
milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8138
|
+
ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
|
|
6928
8139
|
});
|
|
6929
8140
|
function isSafeRepoRelPath(p) {
|
|
6930
8141
|
if (p.length === 0)
|
|
@@ -6933,7 +8144,7 @@ function isSafeRepoRelPath(p) {
|
|
|
6933
8144
|
return false;
|
|
6934
8145
|
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
6935
8146
|
}
|
|
6936
|
-
var SafeRepoRelPath =
|
|
8147
|
+
var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
|
|
6937
8148
|
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
6938
8149
|
});
|
|
6939
8150
|
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
@@ -6943,22 +8154,22 @@ function isCanonicalHookBlockPath(p) {
|
|
|
6943
8154
|
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
6944
8155
|
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
6945
8156
|
});
|
|
6946
|
-
var ManagedBlockRecordSchema =
|
|
8157
|
+
var ManagedBlockRecordSchema = z6.object({
|
|
6947
8158
|
path: ManagedHookBlockPath,
|
|
6948
|
-
marker:
|
|
6949
|
-
comment:
|
|
8159
|
+
marker: z6.string(),
|
|
8160
|
+
comment: z6.enum(["hash", "html"])
|
|
6950
8161
|
});
|
|
6951
|
-
var ManagedManifestSchema =
|
|
6952
|
-
version:
|
|
6953
|
-
files:
|
|
6954
|
-
blocks:
|
|
6955
|
-
labels:
|
|
6956
|
-
agents:
|
|
8162
|
+
var ManagedManifestSchema = z6.object({
|
|
8163
|
+
version: z6.number().int().positive(),
|
|
8164
|
+
files: z6.array(SafeRepoRelPath),
|
|
8165
|
+
blocks: z6.array(ManagedBlockRecordSchema),
|
|
8166
|
+
labels: z6.array(z6.string()),
|
|
8167
|
+
agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
|
|
6957
8168
|
});
|
|
6958
|
-
var ProjectEntrySchema =
|
|
6959
|
-
name:
|
|
6960
|
-
description:
|
|
6961
|
-
path:
|
|
8169
|
+
var ProjectEntrySchema = z6.object({
|
|
8170
|
+
name: z6.string().min(1),
|
|
8171
|
+
description: z6.string().min(1).optional(),
|
|
8172
|
+
path: z6.string().min(1).optional()
|
|
6962
8173
|
});
|
|
6963
8174
|
function parseTokensCollectDeclaration(value) {
|
|
6964
8175
|
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
@@ -6969,90 +8180,90 @@ function parseTokensCollectDeclaration(value) {
|
|
|
6969
8180
|
return null;
|
|
6970
8181
|
return { interpreter, script };
|
|
6971
8182
|
}
|
|
6972
|
-
var
|
|
6973
|
-
rings:
|
|
6974
|
-
ring1_forgeWriteInterception:
|
|
6975
|
-
ring2_asyncAudits:
|
|
8183
|
+
var VinayaConfigObjectSchema = z6.object({
|
|
8184
|
+
rings: z6.object({
|
|
8185
|
+
ring1_forgeWriteInterception: z6.boolean(),
|
|
8186
|
+
ring2_asyncAudits: z6.boolean()
|
|
6976
8187
|
}).optional(),
|
|
6977
|
-
checks:
|
|
6978
|
-
roles:
|
|
8188
|
+
checks: z6.record(z6.string(), CheckEntrySchema).optional(),
|
|
8189
|
+
roles: z6.record(z6.string(), RoleEntrySchema).optional(),
|
|
6979
8190
|
briefSchema: BriefSchemaSchema.optional(),
|
|
6980
8191
|
managed: ManagedManifestSchema.optional(),
|
|
6981
|
-
principals:
|
|
6982
|
-
releaseActor:
|
|
6983
|
-
ci:
|
|
6984
|
-
tokens:
|
|
6985
|
-
collect:
|
|
8192
|
+
principals: z6.array(z6.string()).min(1).optional(),
|
|
8193
|
+
releaseActor: z6.string().min(1).optional(),
|
|
8194
|
+
ci: z6.object({ setup: z6.string().min(1) }).optional(),
|
|
8195
|
+
tokens: z6.object({
|
|
8196
|
+
collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
6986
8197
|
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
6987
8198
|
})
|
|
6988
8199
|
}).optional(),
|
|
6989
|
-
blastRadius:
|
|
6990
|
-
proseGates:
|
|
6991
|
-
doctrineRoot:
|
|
6992
|
-
readerFacingPrefix:
|
|
6993
|
-
readerFacingSuffix:
|
|
6994
|
-
legacySlugDir:
|
|
6995
|
-
sourceComments:
|
|
6996
|
-
globs:
|
|
6997
|
-
allowlist:
|
|
6998
|
-
severity:
|
|
8200
|
+
blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
|
|
8201
|
+
proseGates: z6.object({
|
|
8202
|
+
doctrineRoot: z6.string().min(1).optional(),
|
|
8203
|
+
readerFacingPrefix: z6.string().min(1).optional(),
|
|
8204
|
+
readerFacingSuffix: z6.string().min(1).optional(),
|
|
8205
|
+
legacySlugDir: z6.string().min(1).optional(),
|
|
8206
|
+
sourceComments: z6.object({
|
|
8207
|
+
globs: z6.array(z6.string().min(1)).optional(),
|
|
8208
|
+
allowlist: z6.array(z6.string().min(1)).optional(),
|
|
8209
|
+
severity: z6.enum(["warning", "error"]).optional()
|
|
6999
8210
|
}).optional(),
|
|
7000
|
-
specGrandfather:
|
|
7001
|
-
specPaths:
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
})).optional()
|
|
8211
|
+
specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
|
|
8212
|
+
specPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8213
|
+
productPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8214
|
+
published: PublishedProseSchema.optional(),
|
|
8215
|
+
rules: ProseRulesSchema.optional()
|
|
7006
8216
|
}).optional(),
|
|
7007
|
-
projects:
|
|
7008
|
-
dispatch:
|
|
7009
|
-
timeoutMs:
|
|
7010
|
-
|
|
7011
|
-
|
|
8217
|
+
projects: z6.array(ProjectEntrySchema).optional(),
|
|
8218
|
+
dispatch: z6.object({
|
|
8219
|
+
timeoutMs: z6.number().int().positive().optional(),
|
|
8220
|
+
reviewerTimeoutMs: z6.number().int().positive().optional(),
|
|
8221
|
+
killGraceMs: z6.number().int().positive().optional(),
|
|
8222
|
+
agent: z6.enum(["claude", "codex"]).optional()
|
|
7012
8223
|
}).optional(),
|
|
7013
|
-
reviewPolicy:
|
|
7014
|
-
codeReviewThreshold:
|
|
7015
|
-
securityThreshold:
|
|
7016
|
-
maxRounds:
|
|
7017
|
-
maxTaskMinutes:
|
|
8224
|
+
reviewPolicy: z6.object({
|
|
8225
|
+
codeReviewThreshold: z6.string().min(1).optional(),
|
|
8226
|
+
securityThreshold: z6.string().min(1).optional(),
|
|
8227
|
+
maxRounds: z6.number().optional(),
|
|
8228
|
+
maxTaskMinutes: z6.number().optional()
|
|
7018
8229
|
}).optional(),
|
|
7019
|
-
securityScan:
|
|
7020
|
-
command:
|
|
8230
|
+
securityScan: z6.object({
|
|
8231
|
+
command: z6.array(z6.string().min(1)).min(1)
|
|
7021
8232
|
}).optional(),
|
|
7022
|
-
gateCutovers:
|
|
7023
|
-
objectivesSinceIssue:
|
|
7024
|
-
briefSectionsSinceIssue:
|
|
7025
|
-
documentationSinceIssue:
|
|
7026
|
-
briefRulesSincePr:
|
|
7027
|
-
agentBoxesRefusedSincePr:
|
|
8233
|
+
gateCutovers: z6.object({
|
|
8234
|
+
objectivesSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8235
|
+
briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8236
|
+
documentationSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8237
|
+
briefRulesSincePr: z6.number().int().nonnegative().optional(),
|
|
8238
|
+
agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
|
|
7028
8239
|
}).optional(),
|
|
7029
|
-
planning:
|
|
7030
|
-
collisionThreshold:
|
|
8240
|
+
planning: z6.object({
|
|
8241
|
+
collisionThreshold: z6.number().int().nonnegative().optional()
|
|
7031
8242
|
}).optional(),
|
|
7032
|
-
prePush:
|
|
7033
|
-
alwaysRun:
|
|
8243
|
+
prePush: z6.object({
|
|
8244
|
+
alwaysRun: z6.array(z6.string()).optional()
|
|
7034
8245
|
}).optional(),
|
|
7035
|
-
report:
|
|
7036
|
-
commandTimeoutMs:
|
|
8246
|
+
report: z6.object({
|
|
8247
|
+
commandTimeoutMs: z6.number().int().positive().optional()
|
|
7037
8248
|
}).superRefine((report, ctx) => {
|
|
7038
8249
|
const commandTimeoutMs = report.commandTimeoutMs;
|
|
7039
8250
|
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
7040
8251
|
ctx.addIssue({
|
|
7041
|
-
code:
|
|
8252
|
+
code: z6.ZodIssueCode.custom,
|
|
7042
8253
|
path: ["commandTimeoutMs"],
|
|
7043
8254
|
message: "must be at most 3600000 (1 hour)"
|
|
7044
8255
|
});
|
|
7045
8256
|
}
|
|
7046
8257
|
}).optional(),
|
|
7047
|
-
logPublish:
|
|
8258
|
+
logPublish: z6.unknown().refine((v) => v === undefined, {
|
|
7048
8259
|
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
7049
8260
|
}),
|
|
7050
|
-
runtimeDir:
|
|
7051
|
-
logs:
|
|
7052
|
-
folder:
|
|
7053
|
-
url:
|
|
7054
|
-
headers:
|
|
7055
|
-
readHeaders:
|
|
8261
|
+
runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
8262
|
+
logs: z6.object({
|
|
8263
|
+
folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
8264
|
+
url: z6.string().url().optional(),
|
|
8265
|
+
headers: z6.record(z6.string()).optional(),
|
|
8266
|
+
readHeaders: z6.record(z6.string()).optional(),
|
|
7056
8267
|
events: CustomEventDeclarationsSchema.optional()
|
|
7057
8268
|
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
7058
8269
|
message: "logs: set at most one of folder/url"
|
|
@@ -7060,8 +8271,33 @@ var VinayaConfigSchema = z5.object({
|
|
|
7060
8271
|
message: "logs: headers requires url"
|
|
7061
8272
|
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
7062
8273
|
message: "logs: readHeaders requires url"
|
|
7063
|
-
}).optional()
|
|
8274
|
+
}).optional(),
|
|
8275
|
+
decisionRecords: z6.object({
|
|
8276
|
+
path: RepoRelativePathSchema
|
|
8277
|
+
}).strict().optional()
|
|
7064
8278
|
});
|
|
8279
|
+
function decisionRecordsPathIssue(path, doctrineRoot) {
|
|
8280
|
+
const reason = outsideRepositoryReason(path);
|
|
8281
|
+
if (reason)
|
|
8282
|
+
return reason;
|
|
8283
|
+
const folder = normalizeSpecPath(path);
|
|
8284
|
+
if (folder === "" || folder === ".")
|
|
8285
|
+
return "must name a folder, not the repository root";
|
|
8286
|
+
const root = normalizeSpecPath(doctrineRoot ?? "aeg-root");
|
|
8287
|
+
if (folder === root || folder.startsWith(`${root}/`)) {
|
|
8288
|
+
return `must be outside the doctrine tree "${root}" — decision records belong to this repository, not to the doctrine it ships`;
|
|
8289
|
+
}
|
|
8290
|
+
return null;
|
|
8291
|
+
}
|
|
8292
|
+
var VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
|
|
8293
|
+
const path = config.decisionRecords?.path;
|
|
8294
|
+
if (path === undefined || outsideRepositoryReason(path))
|
|
8295
|
+
return;
|
|
8296
|
+
const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
|
|
8297
|
+
if (issue)
|
|
8298
|
+
ctx.addIssue({ code: z6.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
|
|
8299
|
+
});
|
|
8300
|
+
var VinayaConfigShape = VinayaConfigObjectSchema.shape;
|
|
7065
8301
|
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
7066
8302
|
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
7067
8303
|
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
@@ -7142,9 +8378,6 @@ function stripGlobalOnlyKeys(config, path) {
|
|
|
7142
8378
|
}
|
|
7143
8379
|
return result;
|
|
7144
8380
|
}
|
|
7145
|
-
function resolvePrincipalAllowlist(config) {
|
|
7146
|
-
return config?.principals ?? PRINCIPAL_ALLOWLIST;
|
|
7147
|
-
}
|
|
7148
8381
|
function resolveReleaseActor(config) {
|
|
7149
8382
|
return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
|
|
7150
8383
|
}
|
|
@@ -7280,13 +8513,14 @@ function readTrustAnchorConfigAtRef(ref) {
|
|
|
7280
8513
|
});
|
|
7281
8514
|
return Buffer.from(raw, "utf-8").toString("base64");
|
|
7282
8515
|
}
|
|
8516
|
+
var NO_TRUST_ANCHOR_REPO_MESSAGE = "could not resolve repo identity for the trust-anchor read";
|
|
7283
8517
|
function ghFetchTrustAnchorConfig() {
|
|
7284
8518
|
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
7285
8519
|
if (probeRef)
|
|
7286
8520
|
return readTrustAnchorConfigAtRef(probeRef);
|
|
7287
8521
|
const repo = trustAnchorRepo();
|
|
7288
8522
|
if (!repo)
|
|
7289
|
-
throw new Error(
|
|
8523
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7290
8524
|
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
7291
8525
|
encoding: "utf-8",
|
|
7292
8526
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -7303,7 +8537,7 @@ async function ghFetchTrustAnchorConfigAsync() {
|
|
|
7303
8537
|
}
|
|
7304
8538
|
const repo = await trustAnchorRepoAsync();
|
|
7305
8539
|
if (!repo)
|
|
7306
|
-
throw new Error(
|
|
8540
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7307
8541
|
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
7308
8542
|
return stdout;
|
|
7309
8543
|
}
|
|
@@ -7329,6 +8563,47 @@ function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
|
7329
8563
|
}
|
|
7330
8564
|
return parseTrustAnchorContent(base64);
|
|
7331
8565
|
}
|
|
8566
|
+
class PrincipalsUnresolvedError extends Error {
|
|
8567
|
+
kind;
|
|
8568
|
+
constructor(kind, message) {
|
|
8569
|
+
super(message);
|
|
8570
|
+
this.name = "PrincipalsUnresolvedError";
|
|
8571
|
+
this.kind = kind;
|
|
8572
|
+
}
|
|
8573
|
+
}
|
|
8574
|
+
var PRINCIPALS_FIX = 'add "principals": [...] to vinaya.config.json on the default branch';
|
|
8575
|
+
function fetchFailureReason(err) {
|
|
8576
|
+
const stderr = err?.stderr;
|
|
8577
|
+
const text = (typeof stderr === "string" ? stderr : stderr?.toString() ?? "").trim();
|
|
8578
|
+
return text.split(`
|
|
8579
|
+
`)[0]?.trim() || firstLine(err);
|
|
8580
|
+
}
|
|
8581
|
+
function principalsNotConfigured(why) {
|
|
8582
|
+
return new PrincipalsUnresolvedError("not-configured", `no Principal is configured (${why}) — ${PRINCIPALS_FIX}.`);
|
|
8583
|
+
}
|
|
8584
|
+
function resolveTrustedPrincipals(fetcher = ghFetchTrustAnchorConfig) {
|
|
8585
|
+
let content;
|
|
8586
|
+
try {
|
|
8587
|
+
content = fetcher();
|
|
8588
|
+
} catch (err) {
|
|
8589
|
+
if (err?.message === NO_TRUST_ANCHOR_REPO_MESSAGE) {
|
|
8590
|
+
throw principalsNotConfigured("no repository resolves for the read");
|
|
8591
|
+
}
|
|
8592
|
+
if (isMissingFileError(err))
|
|
8593
|
+
throw principalsNotConfigured("the default branch has no vinaya.config.json");
|
|
8594
|
+
throw new PrincipalsUnresolvedError("read-failed", `could not read "principals" from vinaya.config.json on the default branch: ${fetchFailureReason(err)}`);
|
|
8595
|
+
}
|
|
8596
|
+
const unusable = { why: "" };
|
|
8597
|
+
const config = parseTrustAnchorContent(content, (why) => {
|
|
8598
|
+
unusable.why = why;
|
|
8599
|
+
});
|
|
8600
|
+
if (config === null) {
|
|
8601
|
+
throw principalsNotConfigured(`vinaya.config.json on the default branch ${unusable.why ? `is unusable: ${unusable.why}` : "is empty"}`);
|
|
8602
|
+
}
|
|
8603
|
+
if (!config.principals)
|
|
8604
|
+
throw principalsNotConfigured('vinaya.config.json on the default branch sets no "principals"');
|
|
8605
|
+
return config.principals;
|
|
8606
|
+
}
|
|
7332
8607
|
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
7333
8608
|
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
7334
8609
|
let base64;
|
|
@@ -7368,21 +8643,69 @@ function loadConfig() {
|
|
|
7368
8643
|
const path = configPath();
|
|
7369
8644
|
if (!path)
|
|
7370
8645
|
return null;
|
|
8646
|
+
let text;
|
|
7371
8647
|
try {
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
8648
|
+
text = readFileSync2(path, "utf-8");
|
|
8649
|
+
} catch (err) {
|
|
8650
|
+
reportInvalidConfigOnce(path, `unreadable: ${err.message}`);
|
|
8651
|
+
return null;
|
|
8652
|
+
}
|
|
8653
|
+
let raw;
|
|
8654
|
+
try {
|
|
8655
|
+
raw = JSON.parse(text);
|
|
8656
|
+
} catch (err) {
|
|
8657
|
+
reportInvalidConfigOnce(path, `invalid JSON: ${err.message}`);
|
|
8658
|
+
return null;
|
|
8659
|
+
}
|
|
8660
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8661
|
+
if (!parsed.success) {
|
|
8662
|
+
reportInvalidConfigOnce(path, schemaIssueDetail(parsed.error));
|
|
7375
8663
|
return null;
|
|
7376
8664
|
}
|
|
8665
|
+
return stripGlobalOnlyKeys(parsed.data, path);
|
|
7377
8666
|
}
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
var
|
|
7382
|
-
function
|
|
7383
|
-
|
|
7384
|
-
|
|
8667
|
+
function schemaIssueDetail(error) {
|
|
8668
|
+
return error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
|
|
8669
|
+
}
|
|
8670
|
+
var emittedInvalidConfigReports = new Set;
|
|
8671
|
+
function reportInvalidConfigOnce(path, detail) {
|
|
8672
|
+
const key = `${path}
|
|
8673
|
+
${detail}`;
|
|
8674
|
+
if (emittedInvalidConfigReports.has(key))
|
|
8675
|
+
return;
|
|
8676
|
+
emittedInvalidConfigReports.add(key);
|
|
8677
|
+
const message = `${path} is not a valid Vinaya configuration (${detail}) — falling back to built-in defaults.`;
|
|
8678
|
+
const checkName = process.env.VINAYA_CHECK_NAME;
|
|
8679
|
+
if (checkName) {
|
|
8680
|
+
emitCheckError({
|
|
8681
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8682
|
+
check: checkName,
|
|
8683
|
+
severity: "warning",
|
|
8684
|
+
message,
|
|
8685
|
+
agent_recovery_prompt: `Fix the failing keys in ${path} (${detail}) so the file parses and satisfies the configuration schema, then re-run.`,
|
|
8686
|
+
file: path
|
|
8687
|
+
});
|
|
8688
|
+
return;
|
|
8689
|
+
}
|
|
8690
|
+
console.error(`⚠ ${message}`);
|
|
8691
|
+
}
|
|
8692
|
+
function loadConfigChecked() {
|
|
8693
|
+
const path = configPath();
|
|
8694
|
+
if (!path)
|
|
8695
|
+
return { ok: true, config: null };
|
|
8696
|
+
let raw;
|
|
8697
|
+
try {
|
|
8698
|
+
raw = JSON.parse(readFileSync2(path, "utf-8"));
|
|
8699
|
+
} catch (err) {
|
|
8700
|
+
return { ok: false, path, error: `invalid JSON: ${err.message}` };
|
|
8701
|
+
}
|
|
8702
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8703
|
+
if (!parsed.success) {
|
|
8704
|
+
return { ok: false, path, error: schemaIssueDetail(parsed.error) };
|
|
8705
|
+
}
|
|
8706
|
+
return { ok: true, config: stripGlobalOnlyKeys(parsed.data, path) };
|
|
7385
8707
|
}
|
|
8708
|
+
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
7386
8709
|
|
|
7387
8710
|
// src/checks/bin/check-doctrine-no-procedures.ts
|
|
7388
8711
|
var CHECK_NAME = "doctrine-no-procedures";
|