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