@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,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-evidence-fresh.ts
|
|
4
|
-
import { execFileSync as
|
|
4
|
+
import { execFileSync as execFileSync10 } from "node:child_process";
|
|
5
5
|
|
|
6
6
|
// ../../packages/aeg-core/src/entry-point.ts
|
|
7
7
|
import { realpathSync } from "node:fs";
|
|
@@ -42,7 +42,6 @@ var GATE_AUDIENCE = {
|
|
|
42
42
|
};
|
|
43
43
|
var NON_GATE_BINS = [
|
|
44
44
|
"archive-task",
|
|
45
|
-
"assign-task-issue",
|
|
46
45
|
"dead-branch-audit",
|
|
47
46
|
"eval-agent-compliance",
|
|
48
47
|
"open-issue",
|
|
@@ -305,6 +304,25 @@ async function runAsync(args) {
|
|
|
305
304
|
function ghApiGet(path) {
|
|
306
305
|
return JSON.parse(run(["api", path]));
|
|
307
306
|
}
|
|
307
|
+
var MAX_PER_PAGE = 100;
|
|
308
|
+
var MAX_PAGES = 100;
|
|
309
|
+
async function ghApiGetAllPagesAsync(pathWithoutPage, opts) {
|
|
310
|
+
const [base = pathWithoutPage, query = ""] = pathWithoutPage.split("?");
|
|
311
|
+
const params = new URLSearchParams(query);
|
|
312
|
+
params.set("per_page", String(MAX_PER_PAGE));
|
|
313
|
+
const all = [];
|
|
314
|
+
for (let page = 1;page <= MAX_PAGES; page++) {
|
|
315
|
+
params.set("page", String(page));
|
|
316
|
+
const args = ["api", `${base}?${params.toString()}`];
|
|
317
|
+
if (opts?.jq)
|
|
318
|
+
args.push("-q", opts.jq);
|
|
319
|
+
const batch = JSON.parse(await runAsync(args));
|
|
320
|
+
all.push(...batch);
|
|
321
|
+
if (batch.length < MAX_PER_PAGE)
|
|
322
|
+
return all;
|
|
323
|
+
}
|
|
324
|
+
throw new Error(`ghApiGetAllPagesAsync: "${pathWithoutPage}" did not terminate within ${MAX_PAGES} pages (${MAX_PAGES * MAX_PER_PAGE} items) — refusing to keep walking.`);
|
|
325
|
+
}
|
|
308
326
|
function issueListByLabelArgs(owner, repo, label) {
|
|
309
327
|
return [
|
|
310
328
|
"issue",
|
|
@@ -716,6 +734,10 @@ function intentGoalForSlug(description, slug) {
|
|
|
716
734
|
function matchesLegacyMilestone(milestones, slug) {
|
|
717
735
|
return milestones.find((m) => m.title === slug) ?? null;
|
|
718
736
|
}
|
|
737
|
+
var TRANCHE_SLUG_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*-v\d+$/;
|
|
738
|
+
function slugShapedTitles(milestones) {
|
|
739
|
+
return milestones.map((m) => m.title).filter((t) => TRANCHE_SLUG_SHAPE.test(t));
|
|
740
|
+
}
|
|
719
741
|
function factsFromLegacyMilestone(milestone) {
|
|
720
742
|
return {
|
|
721
743
|
goal: milestone.description ?? "",
|
|
@@ -749,6 +771,90 @@ function findMilestoneForSlug(owner, repo, slug) {
|
|
|
749
771
|
return resolveLegacyFacts(legacy, issues);
|
|
750
772
|
return { goal: goalFromMilestones(milestones, slug), lifecycle: lifecycleFromIssues(issues) };
|
|
751
773
|
}
|
|
774
|
+
function trancheSlugsFromLabels(labels) {
|
|
775
|
+
const slugs = [];
|
|
776
|
+
for (const l of labels) {
|
|
777
|
+
const slug = trancheSlugOf(l.name);
|
|
778
|
+
if (slug !== null)
|
|
779
|
+
slugs.push(slug);
|
|
780
|
+
}
|
|
781
|
+
return slugs;
|
|
782
|
+
}
|
|
783
|
+
async function indexTrancheMilestonesAsync(owner, repo) {
|
|
784
|
+
const [milestones, labels] = await Promise.all([
|
|
785
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
786
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`)
|
|
787
|
+
]);
|
|
788
|
+
const active = [];
|
|
789
|
+
const archived = [];
|
|
790
|
+
const facts = new Map;
|
|
791
|
+
const legacySlugs = new Set(slugShapedTitles(milestones));
|
|
792
|
+
const legacyMilestoneBySlug = new Map(milestones.filter((m) => legacySlugs.has(m.title)).map((m) => [m.title, m]));
|
|
793
|
+
const newPathSlugs = trancheSlugsFromLabels(labels).filter((slug) => !legacySlugs.has(slug));
|
|
794
|
+
const uniqueNewPathSlugs = [...new Set(newPathSlugs)];
|
|
795
|
+
const uniqueLegacySlugs = [...legacySlugs];
|
|
796
|
+
const [legacyIssuesBySlug, newPathIssuesBySlug] = await Promise.all([
|
|
797
|
+
Promise.all(uniqueLegacySlugs.map((slug) => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))),
|
|
798
|
+
Promise.all(uniqueNewPathSlugs.map((slug) => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))))
|
|
799
|
+
]);
|
|
800
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
801
|
+
const m = legacyMilestoneBySlug.get(slug);
|
|
802
|
+
if (!m)
|
|
803
|
+
return;
|
|
804
|
+
const ref = { slug, goal: m.description ?? "" };
|
|
805
|
+
const f = resolveLegacyFacts(m, legacyIssuesBySlug[i] ?? []);
|
|
806
|
+
if (f.lifecycle === "complete")
|
|
807
|
+
archived.push(ref);
|
|
808
|
+
else if (f.lifecycle === "active")
|
|
809
|
+
active.push(ref);
|
|
810
|
+
facts.set(slug, f);
|
|
811
|
+
});
|
|
812
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
813
|
+
const issues = newPathIssuesBySlug[i] ?? [];
|
|
814
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
815
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
816
|
+
const f = { goal, lifecycle };
|
|
817
|
+
facts.set(slug, f);
|
|
818
|
+
if (lifecycle === "active")
|
|
819
|
+
active.push({ slug, goal });
|
|
820
|
+
else if (lifecycle === "complete")
|
|
821
|
+
archived.push({ slug, goal });
|
|
822
|
+
});
|
|
823
|
+
return { active, archived, facts, legacySlugs };
|
|
824
|
+
}
|
|
825
|
+
async function indexTrancheMilestonesForSlugAsync(owner, repo, slug) {
|
|
826
|
+
const [milestones, labels, issues] = await Promise.all([
|
|
827
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
828
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`),
|
|
829
|
+
ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))
|
|
830
|
+
]);
|
|
831
|
+
const active = [];
|
|
832
|
+
const archived = [];
|
|
833
|
+
const facts = new Map;
|
|
834
|
+
const legacySlugs = new Set;
|
|
835
|
+
const legacyMilestone = slugShapedTitles(milestones).includes(slug) ? matchesLegacyMilestone(milestones, slug) : null;
|
|
836
|
+
if (legacyMilestone) {
|
|
837
|
+
legacySlugs.add(slug);
|
|
838
|
+
const ref = { slug, goal: legacyMilestone.description ?? "" };
|
|
839
|
+
const f = resolveLegacyFacts(legacyMilestone, issues);
|
|
840
|
+
if (f.lifecycle === "complete")
|
|
841
|
+
archived.push(ref);
|
|
842
|
+
else if (f.lifecycle === "active")
|
|
843
|
+
active.push(ref);
|
|
844
|
+
facts.set(slug, f);
|
|
845
|
+
} else if (trancheSlugsFromLabels(labels).includes(slug)) {
|
|
846
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
847
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
848
|
+
facts.set(slug, { goal, lifecycle });
|
|
849
|
+
if (lifecycle === "active")
|
|
850
|
+
active.push({ slug, goal });
|
|
851
|
+
else if (lifecycle === "complete")
|
|
852
|
+
archived.push({ slug, goal });
|
|
853
|
+
}
|
|
854
|
+
const openLegacyTitles = new Set(slugShapedTitles(milestones.filter((m) => m.state === "open")));
|
|
855
|
+
const otherOpenLegacySlugs = [...openLegacyTitles].filter((t) => t !== slug);
|
|
856
|
+
return { active, archived, facts, legacySlugs, otherOpenLegacySlugs };
|
|
857
|
+
}
|
|
752
858
|
|
|
753
859
|
// ../../packages/aeg-forge-state/src/derive-from-forge.ts
|
|
754
860
|
function trancheFromIssues(slug, issues, known) {
|
|
@@ -1409,6 +1515,125 @@ var graphql2 = withDefaults3(request, {
|
|
|
1409
1515
|
method: "POST",
|
|
1410
1516
|
url: "/graphql"
|
|
1411
1517
|
});
|
|
1518
|
+
|
|
1519
|
+
// ../../packages/aeg-forge-state/src/fetch-provenance.ts
|
|
1520
|
+
var PROVENANCE_PATTERN = /^###\s+AEG provenance\b/im;
|
|
1521
|
+
function provenanceMatchesIssue(text, issueNum) {
|
|
1522
|
+
if (!PROVENANCE_PATTERN.test(text))
|
|
1523
|
+
return false;
|
|
1524
|
+
const m = text.match(/^-\s*Issue:\s*#(\d+)/im);
|
|
1525
|
+
return m !== null && Number(m[1]) === issueNum;
|
|
1526
|
+
}
|
|
1527
|
+
function isPrCloser(closer) {
|
|
1528
|
+
return closer !== null && typeof closer.number === "number";
|
|
1529
|
+
}
|
|
1530
|
+
async function fetchProvenanceViaCrossReferences(issueNums, owner, repo, token) {
|
|
1531
|
+
const result = new Map;
|
|
1532
|
+
if (issueNums.length === 0)
|
|
1533
|
+
return result;
|
|
1534
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1535
|
+
const perIssue = issueNums.map((n) => `
|
|
1536
|
+
i_${n}: issue(number: ${n}) {
|
|
1537
|
+
timelineItems(first: 50, itemTypes: [CROSS_REFERENCED_EVENT]) {
|
|
1538
|
+
nodes {
|
|
1539
|
+
... on CrossReferencedEvent {
|
|
1540
|
+
source {
|
|
1541
|
+
... on PullRequest {
|
|
1542
|
+
number
|
|
1543
|
+
body
|
|
1544
|
+
comments(first: 50) { nodes { body } }
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}`).join("");
|
|
1551
|
+
const query = `query ProvenanceCrossRef($owner: String!, $repo: String!) {
|
|
1552
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1553
|
+
}
|
|
1554
|
+
}`;
|
|
1555
|
+
let response;
|
|
1556
|
+
try {
|
|
1557
|
+
response = await client(query, { owner, repo });
|
|
1558
|
+
} catch {
|
|
1559
|
+
return result;
|
|
1560
|
+
}
|
|
1561
|
+
if (!response.repository)
|
|
1562
|
+
return result;
|
|
1563
|
+
for (const n of issueNums) {
|
|
1564
|
+
const raw = response.repository[`i_${n}`];
|
|
1565
|
+
const nodes = raw?.timelineItems?.nodes ?? [];
|
|
1566
|
+
const found = nodes.some(({ source }) => {
|
|
1567
|
+
if (!source || typeof source.number !== "number")
|
|
1568
|
+
return false;
|
|
1569
|
+
const pr = source;
|
|
1570
|
+
if (provenanceMatchesIssue(pr.body ?? "", n))
|
|
1571
|
+
return true;
|
|
1572
|
+
return pr.comments.nodes.some((c) => provenanceMatchesIssue(c.body, n));
|
|
1573
|
+
});
|
|
1574
|
+
result.set(n, found);
|
|
1575
|
+
}
|
|
1576
|
+
return result;
|
|
1577
|
+
}
|
|
1578
|
+
async function fetchProvenance(issueNums, owner, repo, token) {
|
|
1579
|
+
const result = new Map;
|
|
1580
|
+
if (issueNums.length === 0)
|
|
1581
|
+
return result;
|
|
1582
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1583
|
+
const perIssue = issueNums.map((n) => `
|
|
1584
|
+
i_${n}: issue(number: ${n}) {
|
|
1585
|
+
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1586
|
+
nodes {
|
|
1587
|
+
... on ClosedEvent {
|
|
1588
|
+
closer {
|
|
1589
|
+
... on PullRequest {
|
|
1590
|
+
number
|
|
1591
|
+
body
|
|
1592
|
+
comments(first: 50) {
|
|
1593
|
+
nodes { body }
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}`).join("");
|
|
1601
|
+
const query = `query Provenance($owner: String!, $repo: String!) {
|
|
1602
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1603
|
+
}
|
|
1604
|
+
}`;
|
|
1605
|
+
let response;
|
|
1606
|
+
try {
|
|
1607
|
+
response = await client(query, { owner, repo });
|
|
1608
|
+
} catch {
|
|
1609
|
+
return result;
|
|
1610
|
+
}
|
|
1611
|
+
if (!response.repository)
|
|
1612
|
+
return result;
|
|
1613
|
+
const needsFallback = [];
|
|
1614
|
+
for (const n of issueNums) {
|
|
1615
|
+
const raw = response.repository[`i_${n}`];
|
|
1616
|
+
if (!raw) {
|
|
1617
|
+
result.set(n, false);
|
|
1618
|
+
continue;
|
|
1619
|
+
}
|
|
1620
|
+
const closer = raw.timelineItems?.nodes?.[0]?.closer;
|
|
1621
|
+
const c = closer ?? null;
|
|
1622
|
+
if (!isPrCloser(c)) {
|
|
1623
|
+
needsFallback.push(n);
|
|
1624
|
+
continue;
|
|
1625
|
+
}
|
|
1626
|
+
const bodyHas = PROVENANCE_PATTERN.test(c.body ?? "");
|
|
1627
|
+
const commentHas = c.comments.nodes.some((x) => PROVENANCE_PATTERN.test(x.body));
|
|
1628
|
+
result.set(n, bodyHas || commentHas);
|
|
1629
|
+
}
|
|
1630
|
+
if (needsFallback.length > 0) {
|
|
1631
|
+
const fallback = await fetchProvenanceViaCrossReferences(needsFallback, owner, repo, token);
|
|
1632
|
+
for (const [n, found] of fallback)
|
|
1633
|
+
result.set(n, found);
|
|
1634
|
+
}
|
|
1635
|
+
return result;
|
|
1636
|
+
}
|
|
1412
1637
|
// ../../packages/aeg-forge-state/src/github-token.ts
|
|
1413
1638
|
import { execFile as execFile2 } from "node:child_process";
|
|
1414
1639
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -1638,6 +1863,84 @@ function describeError(err) {
|
|
|
1638
1863
|
return err;
|
|
1639
1864
|
return "unknown error";
|
|
1640
1865
|
}
|
|
1866
|
+
// ../../packages/aeg-forge-state/src/prior-tranche-archival.ts
|
|
1867
|
+
function defaultPriorTrancheArchivalDeps() {
|
|
1868
|
+
let facts = new Map;
|
|
1869
|
+
return {
|
|
1870
|
+
activeTrancheSlugs: async (excludeSlug, repo) => {
|
|
1871
|
+
const index = await indexTrancheMilestonesAsync(repo.owner, repo.repo);
|
|
1872
|
+
facts = index.facts;
|
|
1873
|
+
return index.active.map((m) => m.slug).filter((slug) => slug !== excludeSlug);
|
|
1874
|
+
},
|
|
1875
|
+
deriveTranche: (slug, repo) => deriveTrancheFromForge(repo.owner, repo.repo, slug, facts.get(slug)),
|
|
1876
|
+
openIssues: async (slug, repo) => (await fetchTrancheIssuesAsync(repo.owner, repo.repo, slug)).filter((issue) => issue.state === "OPEN").map((issue) => ({ number: issue.number }))
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
function reason(err) {
|
|
1880
|
+
return err instanceof Error ? err.message.split(`
|
|
1881
|
+
`)[0] ?? "failed" : String(err);
|
|
1882
|
+
}
|
|
1883
|
+
async function resolvePriorTrancheArchival(projects, excludeSlug, repo, deps = defaultPriorTrancheArchivalDeps()) {
|
|
1884
|
+
if (projects.length === 0)
|
|
1885
|
+
return { facts: [], infraFailure: null };
|
|
1886
|
+
let candidates;
|
|
1887
|
+
try {
|
|
1888
|
+
candidates = await deps.activeTrancheSlugs(excludeSlug, repo);
|
|
1889
|
+
} catch (err) {
|
|
1890
|
+
return {
|
|
1891
|
+
facts: [],
|
|
1892
|
+
infraFailure: `severity:infra — could not read the active tranches (${reason(err)}); whether a prior tranche is archived is unknown.`
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
const facts = [];
|
|
1896
|
+
const unreadable = [];
|
|
1897
|
+
const derived = new Map;
|
|
1898
|
+
const derive = (slug) => {
|
|
1899
|
+
let p = derived.get(slug);
|
|
1900
|
+
if (!p) {
|
|
1901
|
+
p = deps.deriveTranche(slug, repo);
|
|
1902
|
+
derived.set(slug, p);
|
|
1903
|
+
}
|
|
1904
|
+
return p;
|
|
1905
|
+
};
|
|
1906
|
+
for (const project of projects) {
|
|
1907
|
+
let found = null;
|
|
1908
|
+
let unknown = false;
|
|
1909
|
+
for (const slug of candidates) {
|
|
1910
|
+
let candidateTranche;
|
|
1911
|
+
try {
|
|
1912
|
+
candidateTranche = await derive(slug);
|
|
1913
|
+
} catch {
|
|
1914
|
+
unknown = true;
|
|
1915
|
+
unreadable.push(`the tasks of tranche \`${slug}\` (project \`${project}\`)`);
|
|
1916
|
+
break;
|
|
1917
|
+
}
|
|
1918
|
+
if (!candidateTranche.tasks.some((t) => t.projects.includes(project)))
|
|
1919
|
+
continue;
|
|
1920
|
+
let openIssues;
|
|
1921
|
+
try {
|
|
1922
|
+
openIssues = await deps.openIssues(slug, repo);
|
|
1923
|
+
} catch {
|
|
1924
|
+
openIssues = null;
|
|
1925
|
+
}
|
|
1926
|
+
if (openIssues === null) {
|
|
1927
|
+
unknown = true;
|
|
1928
|
+
unreadable.push(`the open Issues of tranche \`${slug}\` (project \`${project}\`)`);
|
|
1929
|
+
break;
|
|
1930
|
+
}
|
|
1931
|
+
if (openIssues.length === 0) {
|
|
1932
|
+
found = { project, priorTrancheSlug: slug, archived: false };
|
|
1933
|
+
break;
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
if (!unknown)
|
|
1937
|
+
facts.push(found ?? { project, priorTrancheSlug: null, archived: false });
|
|
1938
|
+
}
|
|
1939
|
+
return {
|
|
1940
|
+
facts,
|
|
1941
|
+
infraFailure: unreadable.length === 0 ? null : `severity:infra — could not read ${unreadable.join(", ")}; whether a prior tranche is archived is unknown.`
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1641
1944
|
// ../../packages/aeg-forge-state/src/fetch-open-issues.ts
|
|
1642
1945
|
async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
|
|
1643
1946
|
const result = new Map;
|
|
@@ -1712,6 +2015,10 @@ function buildQuery(issueNumbers) {
|
|
|
1712
2015
|
}
|
|
1713
2016
|
}`;
|
|
1714
2017
|
}
|
|
2018
|
+
// ../../packages/aeg-forge-state/src/list-issue-milestones.ts
|
|
2019
|
+
function issueMilestonesFromIssues(issues) {
|
|
2020
|
+
return issues.filter((i) => i.state === "OPEN").map((i) => ({ issue: i.number, milestoneTitle: i.milestone?.title ?? null }));
|
|
2021
|
+
}
|
|
1715
2022
|
// ../../packages/aeg-forge-state/src/resolve-repo.ts
|
|
1716
2023
|
import { execFile as execFile3 } from "node:child_process";
|
|
1717
2024
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -1774,7 +2081,8 @@ var ANCHOR_FIELDS = [
|
|
|
1774
2081
|
"PREMISE",
|
|
1775
2082
|
"TEST-PLAN",
|
|
1776
2083
|
"EVIDENCE",
|
|
1777
|
-
"BEYOND-SURFACE"
|
|
2084
|
+
"BEYOND-SURFACE",
|
|
2085
|
+
"LIVE"
|
|
1778
2086
|
];
|
|
1779
2087
|
function anchoredRegionBounds(body, field) {
|
|
1780
2088
|
const masked = maskCode(body);
|
|
@@ -1975,7 +2283,6 @@ var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
|
1975
2283
|
// ../../packages/aeg-core/src/waiver-label.ts
|
|
1976
2284
|
var WAIVER_LABEL = label("waiver-docs");
|
|
1977
2285
|
var WAIVER_LABEL_REVIEW = label("waiver-review");
|
|
1978
|
-
var PRINCIPAL_ALLOWLIST = ["daniboomerang"];
|
|
1979
2286
|
function isPrincipal(login, principalAllowlist) {
|
|
1980
2287
|
if (login === null)
|
|
1981
2288
|
return false;
|
|
@@ -1994,6 +2301,14 @@ var RULING_ORDINAL_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Ruling ordinal:\s*(\d+)(
|
|
|
1994
2301
|
var BRIEF_HASH_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Brief hash:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1995
2302
|
var POLICY_DIGEST_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Policy digest:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1996
2303
|
var BASE_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged base:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
|
|
2304
|
+
var MANIFEST_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Manifest version:\s*(\d+)\s*$/im;
|
|
2305
|
+
var PAUSE_BOUND_RULING_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Pause-bound ruling:\s*(?:(\S+)\|(\S+)\|([0-9a-f]{64})|\(none\))\s*$/im;
|
|
2306
|
+
function extractPauseBoundRuling(comment) {
|
|
2307
|
+
const m = comment.match(PAUSE_BOUND_RULING_PATTERN);
|
|
2308
|
+
if (!m)
|
|
2309
|
+
return;
|
|
2310
|
+
return m[1] ? { rulingId: m[1], pauseId: m[2], contentDigest: m[3] } : null;
|
|
2311
|
+
}
|
|
1997
2312
|
function firstFiveLines(comment) {
|
|
1998
2313
|
return comment.split(`
|
|
1999
2314
|
`).slice(0, 5).join(`
|
|
@@ -2087,6 +2402,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2087
2402
|
danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
|
|
2088
2403
|
};
|
|
2089
2404
|
}
|
|
2405
|
+
const versionMatch = latest.match(MANIFEST_VERSION_PATTERN);
|
|
2406
|
+
const pauseBoundRuling = extractPauseBoundRuling(latest);
|
|
2090
2407
|
return {
|
|
2091
2408
|
value: m[1].toUpperCase().replace(/[_-]/g, " "),
|
|
2092
2409
|
headSha: extractHeadSha(latest),
|
|
@@ -2095,6 +2412,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2095
2412
|
briefHash: extractBriefHash(latest),
|
|
2096
2413
|
policyDigest: extractPolicyDigest(latest),
|
|
2097
2414
|
baseSha: extractBaseSha(latest),
|
|
2415
|
+
...versionMatch ? { manifestVersion: Number.parseInt(versionMatch[1], 10) } : {},
|
|
2416
|
+
...pauseBoundRuling === undefined ? {} : { pauseBoundRuling },
|
|
2098
2417
|
findingSeverities: extractFindingSeverities(latest),
|
|
2099
2418
|
danglingNote: null
|
|
2100
2419
|
};
|
|
@@ -2105,6 +2424,16 @@ function extractCodeReviewVerdict(comments) {
|
|
|
2105
2424
|
function extractSecurityReviewVerdict(comments) {
|
|
2106
2425
|
return extractVerdict(comments, /^[ \t]*(?:\*{1,3}|_{1,3})?VERDICT:\s*(PASS|FAIL)(?![A-Za-z0-9])/im, "security-review");
|
|
2107
2426
|
}
|
|
2427
|
+
|
|
2428
|
+
// ../../packages/aeg-core/src/review-status.ts
|
|
2429
|
+
var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-(\d+)\s*-->/i;
|
|
2430
|
+
function parseDeveloperRoundMarker(body) {
|
|
2431
|
+
const m = body.match(DEVELOPER_ROUND_MARKER);
|
|
2432
|
+
if (!m)
|
|
2433
|
+
return null;
|
|
2434
|
+
const n = Number(m[1]);
|
|
2435
|
+
return Number.isFinite(n) ? n : null;
|
|
2436
|
+
}
|
|
2108
2437
|
// ../../packages/aeg-core/src/report-tokens.ts
|
|
2109
2438
|
var DASH_LOOKALIKES = {
|
|
2110
2439
|
"-": "‑",
|
|
@@ -2800,14 +3129,14 @@ function checkTestPlan(prBody) {
|
|
|
2800
3129
|
const region = located.found ? located.section : prBody;
|
|
2801
3130
|
if (TEST_PLAN_UNIT_TESTS_ONLY_RE.test(region))
|
|
2802
3131
|
return { status: "pass", errors: [] };
|
|
2803
|
-
if (/\*\*\[(?:agent|principal)\]\*\*/.test(region))
|
|
3132
|
+
if (/\*\*\[(?:agent|principal|live)\]\*\*/.test(region))
|
|
2804
3133
|
return { status: "pass", errors: [] };
|
|
2805
3134
|
if (located.found && extractFencedBlocks(region).length > 0)
|
|
2806
3135
|
return { status: "pass", errors: [] };
|
|
2807
3136
|
return {
|
|
2808
3137
|
status: "fail",
|
|
2809
3138
|
errors: [
|
|
2810
|
-
"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
|
|
3139
|
+
"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."
|
|
2811
3140
|
]
|
|
2812
3141
|
};
|
|
2813
3142
|
}
|
|
@@ -3429,6 +3758,375 @@ function checkPrReportDensity(prBody) {
|
|
|
3429
3758
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3430
3759
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3431
3760
|
}
|
|
3761
|
+
// ../../packages/aeg-core/src/prose-rules.ts
|
|
3762
|
+
var RETIRED_GLOBAL_EXEMPTIONS = [
|
|
3763
|
+
"docs/decisions-legacy.md",
|
|
3764
|
+
"apps/herald-ai/docs/",
|
|
3765
|
+
"apps/vada-ai/docs/",
|
|
3766
|
+
"aeg-root/tranches/completed/",
|
|
3767
|
+
"packages/aeg-core/src/docs/published-prose",
|
|
3768
|
+
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
3769
|
+
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
3770
|
+
"/fixtures/",
|
|
3771
|
+
"/node_modules/",
|
|
3772
|
+
"/.next/",
|
|
3773
|
+
"/.turbo/"
|
|
3774
|
+
];
|
|
3775
|
+
var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
|
|
3776
|
+
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
3777
|
+
var RETIRED_PATTERN_EXEMPTIONS = {
|
|
3778
|
+
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
3779
|
+
[String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
|
|
3780
|
+
"docs-index.md",
|
|
3781
|
+
"apps/vada-ai/specs/legacy/README.md",
|
|
3782
|
+
"apps/vada-ai/specs/vada-product-spec.md",
|
|
3783
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3784
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3785
|
+
],
|
|
3786
|
+
"decisions-legacy": [
|
|
3787
|
+
"packages/aeg-core/src/file-classify.ts",
|
|
3788
|
+
"packages/aeg-core/src/file-classify.test.ts",
|
|
3789
|
+
"packages/aeg-core/src/pr-tier.test.ts",
|
|
3790
|
+
"docs-index.md",
|
|
3791
|
+
".claude/skills/database/SKILL.md",
|
|
3792
|
+
".claude/skills/vada-architecture/SKILL.md",
|
|
3793
|
+
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
3794
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3795
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3796
|
+
],
|
|
3797
|
+
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
3798
|
+
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
3799
|
+
};
|
|
3800
|
+
var retiredPatterns = [
|
|
3801
|
+
String.raw`\bD-[0-9]{3}\b`,
|
|
3802
|
+
"D-(###|NNN|nnn|xxx)",
|
|
3803
|
+
"decision (entry|logged)",
|
|
3804
|
+
"decision-log entry",
|
|
3805
|
+
"decision log entry",
|
|
3806
|
+
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
3807
|
+
"decision-log",
|
|
3808
|
+
"decision entr",
|
|
3809
|
+
"decisions? (are |is )?logged",
|
|
3810
|
+
"log entries",
|
|
3811
|
+
String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
|
|
3812
|
+
"decisions-legacy",
|
|
3813
|
+
"CONTRADICTION",
|
|
3814
|
+
"assumes Tier 3",
|
|
3815
|
+
"Lock: ?YES",
|
|
3816
|
+
"Lock: ?NO",
|
|
3817
|
+
"lock approvals?",
|
|
3818
|
+
"approves locks",
|
|
3819
|
+
"Conforms to lock",
|
|
3820
|
+
"Challenges lock",
|
|
3821
|
+
"checkDecisionNumbersFresh",
|
|
3822
|
+
String.raw`roles/team-leader\.md`,
|
|
3823
|
+
String.raw`\(,`,
|
|
3824
|
+
String.raw`,\)`,
|
|
3825
|
+
String.raw`\(\.\)`,
|
|
3826
|
+
...PLAN_ON_DISK_PATTERNS
|
|
3827
|
+
];
|
|
3828
|
+
var published = [
|
|
3829
|
+
["decision-id", "a decision id", /\bD-\d{3,}\b/],
|
|
3830
|
+
["section-ref", "a section reference", /§/],
|
|
3831
|
+
["forge-number", "a forge number", /#\d+/],
|
|
3832
|
+
["retired-name", "the retired public name", /\bAEG\b/],
|
|
3833
|
+
["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
|
|
3834
|
+
[
|
|
3835
|
+
"label-vocabulary",
|
|
3836
|
+
"forge label vocabulary",
|
|
3837
|
+
/(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
|
|
3838
|
+
],
|
|
3839
|
+
["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
|
|
3840
|
+
["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
|
|
3841
|
+
[
|
|
3842
|
+
"internal-path",
|
|
3843
|
+
"a repo-internal file",
|
|
3844
|
+
/(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
|
|
3845
|
+
]
|
|
3846
|
+
];
|
|
3847
|
+
var DEFAULT_PROSE_RULES = [
|
|
3848
|
+
{
|
|
3849
|
+
id: "forge-number",
|
|
3850
|
+
group: "reader-resolvable",
|
|
3851
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3852
|
+
patterns: { prose: /#[0-9]{2,4}/g },
|
|
3853
|
+
flags: ["global"],
|
|
3854
|
+
message: "a forge number",
|
|
3855
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3856
|
+
exemptions: []
|
|
3857
|
+
},
|
|
3858
|
+
{
|
|
3859
|
+
id: "tranche-slug",
|
|
3860
|
+
group: "reader-resolvable",
|
|
3861
|
+
scopes: ["ships", "reader-facing", "product", "spec"],
|
|
3862
|
+
patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
|
|
3863
|
+
flags: ["global"],
|
|
3864
|
+
message: "an internal tranche slug",
|
|
3865
|
+
severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
|
|
3866
|
+
exemptions: []
|
|
3867
|
+
},
|
|
3868
|
+
{
|
|
3869
|
+
id: "task-number",
|
|
3870
|
+
group: "reader-resolvable",
|
|
3871
|
+
scopes: ["spec"],
|
|
3872
|
+
patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
|
|
3873
|
+
flags: ["global", "ignore-case"],
|
|
3874
|
+
message: "a task number",
|
|
3875
|
+
severity: { spec: "error" },
|
|
3876
|
+
exemptions: []
|
|
3877
|
+
},
|
|
3878
|
+
{
|
|
3879
|
+
id: "source-comment-tranche-slug",
|
|
3880
|
+
group: "reader-resolvable",
|
|
3881
|
+
scopes: ["source-comment"],
|
|
3882
|
+
patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
|
|
3883
|
+
flags: ["global"],
|
|
3884
|
+
message: "a tranche-slug citation",
|
|
3885
|
+
severity: { "source-comment": "warning" },
|
|
3886
|
+
exemptions: []
|
|
3887
|
+
},
|
|
3888
|
+
{
|
|
3889
|
+
id: "source-comment-forge-number",
|
|
3890
|
+
group: "reader-resolvable",
|
|
3891
|
+
scopes: ["source-comment"],
|
|
3892
|
+
patterns: { comment: /#[0-9]{2,}/g },
|
|
3893
|
+
flags: ["global"],
|
|
3894
|
+
message: "a forge-number citation",
|
|
3895
|
+
severity: { "source-comment": "warning" },
|
|
3896
|
+
exemptions: []
|
|
3897
|
+
},
|
|
3898
|
+
{
|
|
3899
|
+
id: "legacy-batch-name",
|
|
3900
|
+
group: "reader-resolvable",
|
|
3901
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3902
|
+
patterns: {},
|
|
3903
|
+
flags: ["built-in"],
|
|
3904
|
+
message: "an internal tranche slug",
|
|
3905
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3906
|
+
exemptions: [],
|
|
3907
|
+
builtIn: true
|
|
3908
|
+
},
|
|
3909
|
+
{
|
|
3910
|
+
id: "coined-term",
|
|
3911
|
+
group: "reader-resolvable",
|
|
3912
|
+
scopes: ["ships", "reader-facing"],
|
|
3913
|
+
patterns: {},
|
|
3914
|
+
flags: ["built-in"],
|
|
3915
|
+
message: "uses coined term without defining it inline or linking the glossary",
|
|
3916
|
+
severity: { ships: "warning", "reader-facing": "warning" },
|
|
3917
|
+
exemptions: [],
|
|
3918
|
+
builtIn: true
|
|
3919
|
+
},
|
|
3920
|
+
...retiredPatterns.map((pattern, index) => ({
|
|
3921
|
+
id: `retired-vocabulary-${index + 1}`,
|
|
3922
|
+
group: "retired-vocabulary",
|
|
3923
|
+
scopes: ["repository"],
|
|
3924
|
+
patterns: { repository: pattern },
|
|
3925
|
+
flags: [],
|
|
3926
|
+
message: "retired vocabulary",
|
|
3927
|
+
severity: { repository: "error" },
|
|
3928
|
+
exemptions: RETIRED_GLOBAL_EXEMPTIONS,
|
|
3929
|
+
patternExemptions: RETIRED_PATTERN_EXEMPTIONS
|
|
3930
|
+
})),
|
|
3931
|
+
...published.map(([id, message, pattern]) => ({
|
|
3932
|
+
id,
|
|
3933
|
+
group: "published-prose",
|
|
3934
|
+
scopes: ["published"],
|
|
3935
|
+
patterns: { published: pattern },
|
|
3936
|
+
flags: [],
|
|
3937
|
+
message,
|
|
3938
|
+
severity: { published: "error" },
|
|
3939
|
+
exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
|
|
3940
|
+
}))
|
|
3941
|
+
];
|
|
3942
|
+
var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
|
|
3943
|
+
var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
|
|
3944
|
+
var RETIRED_SCOPES = ["repository"];
|
|
3945
|
+
var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
|
|
3946
|
+
function groupOfScope(scope) {
|
|
3947
|
+
if (RESOLVABLE_SCOPES.includes(scope))
|
|
3948
|
+
return "reader-resolvable";
|
|
3949
|
+
if (RETIRED_SCOPES.includes(scope))
|
|
3950
|
+
return "retired-vocabulary";
|
|
3951
|
+
return;
|
|
3952
|
+
}
|
|
3953
|
+
var CONFIGURED_PROSE_FLAGS = ["i", "u"];
|
|
3954
|
+
var CONFIGURED_PATTERN_MAX_LENGTH = 200;
|
|
3955
|
+
var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
|
|
3956
|
+
function allowedScopesFor(rule) {
|
|
3957
|
+
if (rule.builtIn)
|
|
3958
|
+
return rule.scopes;
|
|
3959
|
+
return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
|
|
3960
|
+
}
|
|
3961
|
+
function normalizeRepoPath(entry) {
|
|
3962
|
+
let out = entry.replace(/\\/g, "/");
|
|
3963
|
+
while (out.startsWith("./"))
|
|
3964
|
+
out = out.slice(2);
|
|
3965
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3966
|
+
while (out.endsWith("/"))
|
|
3967
|
+
out = out.slice(0, -1);
|
|
3968
|
+
return out;
|
|
3969
|
+
}
|
|
3970
|
+
function isConfiguredExempt(path, exempt, repoRoot) {
|
|
3971
|
+
if (exempt.length === 0)
|
|
3972
|
+
return false;
|
|
3973
|
+
const root = repoRoot === undefined ? undefined : normalizeRepoPath(repoRoot);
|
|
3974
|
+
let rel = normalizeRepoPath(path);
|
|
3975
|
+
if (root && rel.startsWith(`${root}/`))
|
|
3976
|
+
rel = rel.slice(root.length + 1);
|
|
3977
|
+
return exempt.some((entry) => {
|
|
3978
|
+
const e = normalizeRepoPath(entry);
|
|
3979
|
+
return rel === e || rel.startsWith(`${e}/`);
|
|
3980
|
+
});
|
|
3981
|
+
}
|
|
3982
|
+
function ruleReads(set, rule, path) {
|
|
3983
|
+
return !isConfiguredExempt(path, set.exempt, set.repoRoot) && !isConfiguredExempt(path, rule.exempt, set.repoRoot);
|
|
3984
|
+
}
|
|
3985
|
+
var RESOLVABLE_RUN_ORDER = [
|
|
3986
|
+
"forge-number",
|
|
3987
|
+
"tranche-slug",
|
|
3988
|
+
"legacy-batch-name",
|
|
3989
|
+
"task-number",
|
|
3990
|
+
"source-comment-tranche-slug",
|
|
3991
|
+
"source-comment-forge-number",
|
|
3992
|
+
"coined-term"
|
|
3993
|
+
];
|
|
3994
|
+
var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
|
|
3995
|
+
function scopeDefaultSeverity(scope, sourceCommentSeverity) {
|
|
3996
|
+
if (scope === "source-comment")
|
|
3997
|
+
return sourceCommentSeverity ?? "warning";
|
|
3998
|
+
if (scope === "repository")
|
|
3999
|
+
return "error";
|
|
4000
|
+
return "warning";
|
|
4001
|
+
}
|
|
4002
|
+
function applySeverity(scopes, base, setting) {
|
|
4003
|
+
const out = {};
|
|
4004
|
+
for (const scope of scopes) {
|
|
4005
|
+
const configured = typeof setting === "string" ? setting : setting?.[scope];
|
|
4006
|
+
const value = configured ?? base[scope];
|
|
4007
|
+
if (value !== undefined)
|
|
4008
|
+
out[scope] = value;
|
|
4009
|
+
}
|
|
4010
|
+
return out;
|
|
4011
|
+
}
|
|
4012
|
+
function defaultPatternFor(rule) {
|
|
4013
|
+
const cache = new Map;
|
|
4014
|
+
return (scope) => {
|
|
4015
|
+
if (cache.has(scope))
|
|
4016
|
+
return cache.get(scope) ?? null;
|
|
4017
|
+
const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
|
|
4018
|
+
const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
|
|
4019
|
+
cache.set(scope, compiled);
|
|
4020
|
+
return compiled;
|
|
4021
|
+
};
|
|
4022
|
+
}
|
|
4023
|
+
function customPatternFor(rule, global) {
|
|
4024
|
+
const cache = new Map;
|
|
4025
|
+
return (scope) => {
|
|
4026
|
+
if (cache.has(scope))
|
|
4027
|
+
return cache.get(scope) ?? null;
|
|
4028
|
+
const source = rule.patterns?.[scope] ?? rule.pattern;
|
|
4029
|
+
const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
|
|
4030
|
+
cache.set(scope, compiled);
|
|
4031
|
+
return compiled;
|
|
4032
|
+
};
|
|
4033
|
+
}
|
|
4034
|
+
function resolveProseRules(config = undefined, options = {}) {
|
|
4035
|
+
const rules = [];
|
|
4036
|
+
const defaults = config?.defaults ?? {};
|
|
4037
|
+
for (const rule of CONFIGURABLE_DEFAULT_RULES) {
|
|
4038
|
+
const override = defaults[rule.id];
|
|
4039
|
+
if (override === "off")
|
|
4040
|
+
continue;
|
|
4041
|
+
const group = rule.group;
|
|
4042
|
+
const scopes = override?.scopes ?? rule.scopes;
|
|
4043
|
+
const base = {};
|
|
4044
|
+
for (const scope of scopes) {
|
|
4045
|
+
base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4046
|
+
}
|
|
4047
|
+
rules.push({
|
|
4048
|
+
id: rule.id,
|
|
4049
|
+
group,
|
|
4050
|
+
custom: false,
|
|
4051
|
+
builtIn: rule.builtIn === true,
|
|
4052
|
+
scopes,
|
|
4053
|
+
message: rule.message,
|
|
4054
|
+
severity: applySeverity(scopes, base, override?.severity),
|
|
4055
|
+
exempt: override?.exempt ?? [],
|
|
4056
|
+
substringExempt: rule.exemptions,
|
|
4057
|
+
reportGroup: REPORT_GROUPS[rule.id],
|
|
4058
|
+
patternFor: defaultPatternFor(rule)
|
|
4059
|
+
});
|
|
4060
|
+
}
|
|
4061
|
+
for (const rule of config?.custom ?? []) {
|
|
4062
|
+
const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
|
|
4063
|
+
const base = {};
|
|
4064
|
+
for (const scope of rule.scopes)
|
|
4065
|
+
base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4066
|
+
rules.push({
|
|
4067
|
+
id: rule.id,
|
|
4068
|
+
group,
|
|
4069
|
+
custom: true,
|
|
4070
|
+
builtIn: false,
|
|
4071
|
+
scopes: rule.scopes,
|
|
4072
|
+
message: rule.means,
|
|
4073
|
+
severity: applySeverity(rule.scopes, base, rule.severity),
|
|
4074
|
+
exempt: rule.exempt ?? [],
|
|
4075
|
+
substringExempt: [],
|
|
4076
|
+
patternFor: customPatternFor(rule, group === "reader-resolvable")
|
|
4077
|
+
});
|
|
4078
|
+
}
|
|
4079
|
+
if (options.decisionRecordsPath !== undefined)
|
|
4080
|
+
rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
|
|
4081
|
+
const order = (rule) => {
|
|
4082
|
+
const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
|
|
4083
|
+
return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
|
|
4084
|
+
};
|
|
4085
|
+
const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
|
|
4086
|
+
const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
|
|
4087
|
+
return {
|
|
4088
|
+
rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
|
|
4089
|
+
exempt: config?.exempt ?? [],
|
|
4090
|
+
repoRoot: options.repoRoot
|
|
4091
|
+
};
|
|
4092
|
+
}
|
|
4093
|
+
function rulesOfGroup(set, group) {
|
|
4094
|
+
return set.rules.filter((rule) => rule.group === group);
|
|
4095
|
+
}
|
|
4096
|
+
function rulesInScope(set, scope) {
|
|
4097
|
+
return set.rules.filter((rule) => rule.scopes.includes(scope));
|
|
4098
|
+
}
|
|
4099
|
+
var DEFAULT_PROSE_RULE_SET = resolveProseRules();
|
|
4100
|
+
var DECISION_RECORD_CITATION_ID = "decision-record-citation";
|
|
4101
|
+
var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
|
|
4102
|
+
var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
|
|
4103
|
+
function escapeRegExp(text) {
|
|
4104
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4105
|
+
}
|
|
4106
|
+
function decisionRecordCitationPattern(decisionRecordsPath) {
|
|
4107
|
+
const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
|
|
4108
|
+
return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
|
|
4109
|
+
}
|
|
4110
|
+
function decisionRecordCitationRule(decisionRecordsPath) {
|
|
4111
|
+
const folder = normalizeRepoPath(decisionRecordsPath);
|
|
4112
|
+
const pattern = decisionRecordCitationPattern(folder);
|
|
4113
|
+
const severity = {};
|
|
4114
|
+
for (const scope of DECISION_RECORD_CITATION_SCOPES)
|
|
4115
|
+
severity[scope] = "error";
|
|
4116
|
+
return {
|
|
4117
|
+
id: DECISION_RECORD_CITATION_ID,
|
|
4118
|
+
group: "reader-resolvable",
|
|
4119
|
+
custom: false,
|
|
4120
|
+
builtIn: false,
|
|
4121
|
+
scopes: DECISION_RECORD_CITATION_SCOPES,
|
|
4122
|
+
message: DECISION_RECORD_CITATION_MESSAGE,
|
|
4123
|
+
severity,
|
|
4124
|
+
exempt: [folder],
|
|
4125
|
+
substringExempt: [],
|
|
4126
|
+
patternFor: () => pattern
|
|
4127
|
+
};
|
|
4128
|
+
}
|
|
4129
|
+
|
|
3432
4130
|
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3433
4131
|
var PRODUCT_SLUG_SCOPE = [
|
|
3434
4132
|
"apps/cli/src",
|
|
@@ -3440,8 +4138,8 @@ var PRODUCT_SLUG_SCOPE = [
|
|
|
3440
4138
|
function isUnderOrEqual(path, prefix) {
|
|
3441
4139
|
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3442
4140
|
}
|
|
3443
|
-
function isProductScopeFile(path) {
|
|
3444
|
-
return
|
|
4141
|
+
function isProductScopeFile(path, productPaths) {
|
|
4142
|
+
return productPaths.some((prefix) => isUnderOrEqual(path, normalizeRepoPath(prefix)));
|
|
3445
4143
|
}
|
|
3446
4144
|
var SHIPS_PREFIX = "aeg-root/";
|
|
3447
4145
|
function shipsArchivePrefix(shipsPrefix) {
|
|
@@ -3449,13 +4147,7 @@ function shipsArchivePrefix(shipsPrefix) {
|
|
|
3449
4147
|
}
|
|
3450
4148
|
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3451
4149
|
function normalizeSpecPath(entry) {
|
|
3452
|
-
|
|
3453
|
-
while (out.startsWith("./"))
|
|
3454
|
-
out = out.slice(2);
|
|
3455
|
-
out = out.replace(/\/{2,}/g, "/");
|
|
3456
|
-
while (out.endsWith("/"))
|
|
3457
|
-
out = out.slice(0, -1);
|
|
3458
|
-
return out;
|
|
4150
|
+
return normalizeRepoPath(entry);
|
|
3459
4151
|
}
|
|
3460
4152
|
function isSpecFile2(path, specPaths) {
|
|
3461
4153
|
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
@@ -3467,7 +4159,7 @@ function isSpecFile2(path, specPaths) {
|
|
|
3467
4159
|
function isClaudeMdFile(path) {
|
|
3468
4160
|
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3469
4161
|
}
|
|
3470
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4162
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS, productPaths = PRODUCT_SLUG_SCOPE) {
|
|
3471
4163
|
if (path.startsWith(shipsPrefix)) {
|
|
3472
4164
|
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3473
4165
|
}
|
|
@@ -3478,7 +4170,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
|
|
|
3478
4170
|
return "internal";
|
|
3479
4171
|
if (isSpecFile2(path, specPaths))
|
|
3480
4172
|
return "spec";
|
|
3481
|
-
if (isProductScopeFile(path))
|
|
4173
|
+
if (isProductScopeFile(path, productPaths))
|
|
3482
4174
|
return "product";
|
|
3483
4175
|
return null;
|
|
3484
4176
|
}
|
|
@@ -3503,9 +4195,16 @@ function lineAt(content, index) {
|
|
|
3503
4195
|
}
|
|
3504
4196
|
return line;
|
|
3505
4197
|
}
|
|
3506
|
-
var
|
|
3507
|
-
var
|
|
3508
|
-
|
|
4198
|
+
var readerRules = rulesForGroup("reader-resolvable");
|
|
4199
|
+
var readerPattern = (id, scope = "prose") => {
|
|
4200
|
+
const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
|
|
4201
|
+
if (!(pattern instanceof RegExp))
|
|
4202
|
+
throw new Error(`default prose rule ${id} has no ${scope} pattern`);
|
|
4203
|
+
return pattern;
|
|
4204
|
+
};
|
|
4205
|
+
var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
|
|
4206
|
+
var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
|
|
4207
|
+
var TASK_NUMBER_PATTERN = readerPattern("task-number");
|
|
3509
4208
|
function legacySlugPattern(legacySlugs) {
|
|
3510
4209
|
if (legacySlugs.length === 0)
|
|
3511
4210
|
return null;
|
|
@@ -3515,48 +4214,61 @@ function legacySlugPattern(legacySlugs) {
|
|
|
3515
4214
|
function specGrandfatherPaths(specGrandfather) {
|
|
3516
4215
|
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
|
|
3517
4216
|
}
|
|
3518
|
-
|
|
4217
|
+
var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
|
|
4218
|
+
function referenceRulesFor(set, cls) {
|
|
4219
|
+
return rulesInScope(set, cls).filter((rule) => rule.group === "reader-resolvable" && rule.id !== "coined-term");
|
|
4220
|
+
}
|
|
4221
|
+
function citations(pattern, text, group) {
|
|
4222
|
+
const out = [];
|
|
4223
|
+
const re = pattern.global ? pattern : new RegExp(pattern.source, `${pattern.flags}g`);
|
|
4224
|
+
re.lastIndex = 0;
|
|
4225
|
+
let match = re.exec(text);
|
|
4226
|
+
while (match !== null) {
|
|
4227
|
+
if (match[0] === "") {
|
|
4228
|
+
re.lastIndex++;
|
|
4229
|
+
} else {
|
|
4230
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4231
|
+
out.push({ cited, index: match.index + match[0].indexOf(cited) });
|
|
4232
|
+
}
|
|
4233
|
+
match = re.exec(text);
|
|
4234
|
+
}
|
|
4235
|
+
re.lastIndex = 0;
|
|
4236
|
+
return out;
|
|
4237
|
+
}
|
|
4238
|
+
function customMessage(rule, cited) {
|
|
4239
|
+
return `${rule.id}: ${rule.message} ("${cited}")`;
|
|
4240
|
+
}
|
|
4241
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
4242
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4243
|
+
const productPaths = options.productPaths ?? PRODUCT_SLUG_SCOPE;
|
|
3519
4244
|
const findings = [];
|
|
3520
4245
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3521
4246
|
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
|
|
3522
4247
|
const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
|
|
3523
|
-
const patterns = [
|
|
3524
|
-
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3525
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3526
|
-
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3527
|
-
];
|
|
3528
|
-
const productPatterns = [
|
|
3529
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3530
|
-
];
|
|
3531
|
-
const specPatterns = [
|
|
3532
|
-
...patterns,
|
|
3533
|
-
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3534
|
-
];
|
|
3535
4248
|
for (const file of files) {
|
|
3536
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3537
|
-
if (!cls || cls
|
|
3538
|
-
continue;
|
|
3539
|
-
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
4249
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths, productPaths);
|
|
4250
|
+
if (!cls || !REFERENCE_CLASSES.has(cls))
|
|
3540
4251
|
continue;
|
|
3541
4252
|
if (cls === "spec" && grandfatheredWhole.has(file.path))
|
|
3542
4253
|
continue;
|
|
3543
|
-
const blocking = cls === "product" || cls === "spec";
|
|
3544
4254
|
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3545
|
-
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3546
4255
|
const fileFindings = [];
|
|
3547
|
-
for (const
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
4256
|
+
for (const rule of referenceRulesFor(set, cls)) {
|
|
4257
|
+
if (!ruleReads(set, rule, file.path))
|
|
4258
|
+
continue;
|
|
4259
|
+
const pattern = !rule.custom && rule.id === "legacy-batch-name" ? legacyPattern : rule.patternFor(cls);
|
|
4260
|
+
if (!pattern)
|
|
4261
|
+
continue;
|
|
4262
|
+
const blocking = rule.severity[cls] === "error";
|
|
4263
|
+
const what = cls === "product" ? `${rule.message} in product code` : rule.message;
|
|
4264
|
+
for (const { cited, index } of citations(pattern, scrubbed, rule.custom ? undefined : rule.reportGroup)) {
|
|
3553
4265
|
fileFindings.push({
|
|
3554
4266
|
file: file.path,
|
|
3555
|
-
line: lineAt(scrubbed,
|
|
3556
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3557
|
-
blocking
|
|
4267
|
+
line: lineAt(scrubbed, index),
|
|
4268
|
+
message: rule.custom ? customMessage(rule, cited) : `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4269
|
+
blocking,
|
|
4270
|
+
rule: rule.id
|
|
3558
4271
|
});
|
|
3559
|
-
match = pattern.exec(scrubbed);
|
|
3560
4272
|
}
|
|
3561
4273
|
}
|
|
3562
4274
|
const limit = cls === "spec" ? limits.get(file.path) : undefined;
|
|
@@ -3597,11 +4309,17 @@ function definesOrLinksGlossary(content, term) {
|
|
|
3597
4309
|
return true;
|
|
3598
4310
|
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3599
4311
|
}
|
|
3600
|
-
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4312
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, options = {}) {
|
|
3601
4313
|
const findings = [];
|
|
4314
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4315
|
+
const rule = set.rules.find((r) => !r.custom && r.id === "coined-term");
|
|
4316
|
+
if (!rule)
|
|
4317
|
+
return findings;
|
|
3602
4318
|
for (const file of files) {
|
|
3603
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3604
|
-
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
4319
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, DEFAULT_SPEC_PATHS, options.productPaths);
|
|
4320
|
+
if (!cls || !SWEPT_CLASSES.has(cls) || !rule.scopes.includes(cls))
|
|
4321
|
+
continue;
|
|
4322
|
+
if (!ruleReads(set, rule, file.path))
|
|
3605
4323
|
continue;
|
|
3606
4324
|
const scrubbed = stripNonProse(file.path, file.content);
|
|
3607
4325
|
for (const term of glossaryTerms) {
|
|
@@ -3614,14 +4332,15 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
|
|
|
3614
4332
|
file: file.path,
|
|
3615
4333
|
line,
|
|
3616
4334
|
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3617
|
-
blocking:
|
|
4335
|
+
blocking: rule.severity[cls] === "error",
|
|
4336
|
+
rule: rule.id
|
|
3618
4337
|
});
|
|
3619
4338
|
}
|
|
3620
4339
|
}
|
|
3621
4340
|
return findings;
|
|
3622
4341
|
}
|
|
3623
|
-
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN =
|
|
3624
|
-
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN =
|
|
4342
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
|
|
4343
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
|
|
3625
4344
|
function extractComments(path, content) {
|
|
3626
4345
|
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3627
4346
|
return content.replace(/[^\n]/g, "");
|
|
@@ -3718,39 +4437,40 @@ function extractComments(path, content) {
|
|
|
3718
4437
|
}
|
|
3719
4438
|
return out;
|
|
3720
4439
|
}
|
|
3721
|
-
function checkSourceComments(files, allowlist = []) {
|
|
4440
|
+
function checkSourceComments(files, allowlist = [], options = {}) {
|
|
3722
4441
|
const findings = [];
|
|
3723
4442
|
const allowed = new Set(allowlist);
|
|
3724
|
-
const
|
|
3725
|
-
|
|
3726
|
-
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3727
|
-
];
|
|
4443
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4444
|
+
const rules = rulesInScope(set, "source-comment").filter((rule) => rule.group === "reader-resolvable");
|
|
3728
4445
|
for (const file of files) {
|
|
3729
4446
|
if (!file.path.endsWith(".ts"))
|
|
3730
4447
|
continue;
|
|
3731
4448
|
if (allowed.has(file.path))
|
|
3732
4449
|
continue;
|
|
3733
4450
|
const comments = extractComments(file.path, file.content);
|
|
3734
|
-
for (const
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
4451
|
+
for (const rule of rules) {
|
|
4452
|
+
if (!ruleReads(set, rule, file.path))
|
|
4453
|
+
continue;
|
|
4454
|
+
const pattern = rule.patternFor("source-comment");
|
|
4455
|
+
if (!pattern)
|
|
4456
|
+
continue;
|
|
4457
|
+
for (const { cited, index } of citations(pattern, comments)) {
|
|
3738
4458
|
findings.push({
|
|
3739
4459
|
file: file.path,
|
|
3740
|
-
line: lineAt(comments,
|
|
3741
|
-
message: `comment cites ${
|
|
3742
|
-
blocking:
|
|
4460
|
+
line: lineAt(comments, index),
|
|
4461
|
+
message: rule.custom ? customMessage(rule, cited) : `comment cites ${rule.message} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4462
|
+
blocking: rule.severity["source-comment"] === "error",
|
|
4463
|
+
rule: rule.id
|
|
3743
4464
|
});
|
|
3744
|
-
match = pattern.exec(comments);
|
|
3745
4465
|
}
|
|
3746
4466
|
}
|
|
3747
4467
|
}
|
|
3748
4468
|
return findings;
|
|
3749
4469
|
}
|
|
3750
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4470
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
3751
4471
|
return [
|
|
3752
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3753
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4472
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths, options),
|
|
4473
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix, options)
|
|
3754
4474
|
];
|
|
3755
4475
|
}
|
|
3756
4476
|
function parseGlossaryTerms(glossaryContent) {
|
|
@@ -3953,6 +4673,17 @@ function checkDocClaims(files, fileReader) {
|
|
|
3953
4673
|
};
|
|
3954
4674
|
}
|
|
3955
4675
|
|
|
4676
|
+
// ../../packages/aeg-core/src/protected-paths.ts
|
|
4677
|
+
import { posix as posixPath } from "node:path";
|
|
4678
|
+
var PROTECTED_ADMIN_PATHS = ["vinaya.config.json", ".vinaya/doc-owners", ".github/", "aeg-root/"];
|
|
4679
|
+
function normalizeTouchedPath(path) {
|
|
4680
|
+
return posixPath.resolve("/", path.replace(/\\/g, "/")).replace(/^\/+/, "");
|
|
4681
|
+
}
|
|
4682
|
+
function isProtectedAdminPath(path) {
|
|
4683
|
+
const normalized = normalizeTouchedPath(path);
|
|
4684
|
+
return PROTECTED_ADMIN_PATHS.some((prefix) => normalized === prefix || normalized.startsWith(prefix));
|
|
4685
|
+
}
|
|
4686
|
+
|
|
3956
4687
|
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3957
4688
|
function hasRationaleField(body, labelPattern) {
|
|
3958
4689
|
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
@@ -4072,13 +4803,20 @@ function globCoversPath(glob, path) {
|
|
|
4072
4803
|
return !p.includes("/");
|
|
4073
4804
|
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
4074
4805
|
}
|
|
4806
|
+
function surfaceEntryResolves(entry, resolvesToFile, pinnedFiles) {
|
|
4807
|
+
if (resolvesToFile(entry))
|
|
4808
|
+
return true;
|
|
4809
|
+
const directory = entry.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
4810
|
+
return pinnedFiles.some((path) => path.startsWith(`${directory}/`));
|
|
4811
|
+
}
|
|
4075
4812
|
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
4076
4813
|
const surface = parseIssueSurface(body);
|
|
4077
4814
|
if (!surface.ok)
|
|
4078
4815
|
return { status: "pass", errors: [] };
|
|
4816
|
+
const pinnedFiles = boundaryPinnedFiles(body);
|
|
4079
4817
|
const errors = [];
|
|
4080
4818
|
for (const glob of surface.value.in) {
|
|
4081
|
-
if (!
|
|
4819
|
+
if (!surfaceEntryResolves(glob, resolvesToFile, pinnedFiles)) {
|
|
4082
4820
|
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.`);
|
|
4083
4821
|
}
|
|
4084
4822
|
}
|
|
@@ -4108,6 +4846,14 @@ function recordedBeyondSurfacePaths(body) {
|
|
|
4108
4846
|
return paths;
|
|
4109
4847
|
}
|
|
4110
4848
|
function checkSurfaceScope(changedFiles, surface, recorded) {
|
|
4849
|
+
for (const path of changedFiles) {
|
|
4850
|
+
if (!isProtectedAdminPath(path))
|
|
4851
|
+
continue;
|
|
4852
|
+
const normalized = normalizeTouchedPath(path);
|
|
4853
|
+
if (!surface.in.some((glob) => globCoversPath(glob, normalized))) {
|
|
4854
|
+
return { ok: false, violation: { path, reason: "protected" } };
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4111
4857
|
const listed = new Set(recorded);
|
|
4112
4858
|
const violation = beyondSurfacePaths(changedFiles, surface).find((entry) => !listed.has(entry.path));
|
|
4113
4859
|
return violation ? { ok: false, violation } : { ok: true };
|
|
@@ -4163,12 +4909,22 @@ function checkPartsCiteDefinedObjectives(body) {
|
|
|
4163
4909
|
}
|
|
4164
4910
|
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4165
4911
|
}
|
|
4912
|
+
var ISSUE_LIVE_LINE_RE = /^-\s*\*{2}\[live\]\*{2}(.*)$/gim;
|
|
4913
|
+
function liveCommand(text) {
|
|
4914
|
+
const trimmed = text.trim();
|
|
4915
|
+
const span = /^(`+)(.+)\1$/.exec(trimmed);
|
|
4916
|
+
return span ? span[2].trim() : trimmed;
|
|
4917
|
+
}
|
|
4918
|
+
function liveItemsIn(region) {
|
|
4919
|
+
return [...region.matchAll(ISSUE_LIVE_LINE_RE)].map((m) => liveCommand(m[1] ?? "")).filter(Boolean);
|
|
4920
|
+
}
|
|
4921
|
+
function parseLiveTestPlanItems(body) {
|
|
4922
|
+
const located = locateTestPlanSection(body);
|
|
4923
|
+
return located.found ? liveItemsIn(located.section) : [];
|
|
4924
|
+
}
|
|
4166
4925
|
function isTaskIssueLabelSet(labels) {
|
|
4167
4926
|
return hasLabel("tranche", labels);
|
|
4168
4927
|
}
|
|
4169
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
4170
|
-
return { status: "pass", errors: [] };
|
|
4171
|
-
}
|
|
4172
4928
|
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4173
4929
|
if (!isTaskIssueLabelSet(labels))
|
|
4174
4930
|
return { status: "pass", errors: [] };
|
|
@@ -4184,6 +4940,7 @@ function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTi
|
|
|
4184
4940
|
};
|
|
4185
4941
|
}
|
|
4186
4942
|
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4943
|
+
var PATH_TEXT = (body) => stripCode(body, { inlineSpans: "keep" });
|
|
4187
4944
|
function isControlCodePoint(codePoint) {
|
|
4188
4945
|
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4189
4946
|
}
|
|
@@ -4244,8 +5001,14 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
|
4244
5001
|
}
|
|
4245
5002
|
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4246
5003
|
}
|
|
5004
|
+
function rationaleFieldText(text, labelPattern) {
|
|
5005
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})[^\\n]*\\n?([\\s\\S]*?)(?=\\n\\s*(?:\\*\\*[A-Z]|#{1,4}\\s)|(?![\\s\\S]))`, "im");
|
|
5006
|
+
const m = re.exec(text);
|
|
5007
|
+
return m ? m[0] : "";
|
|
5008
|
+
}
|
|
4247
5009
|
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;
|
|
4248
5010
|
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
5011
|
+
var RATIONALE_PATH_RE_GLOBAL = /`([\w.@-]+(?:\/[\w.@-]+)+)`/g;
|
|
4249
5012
|
function normalizeEdgeId(s) {
|
|
4250
5013
|
const qualified = splitSlugQualifiedEdge(s);
|
|
4251
5014
|
return (qualified ? qualified.bareId : s).replace(/^#/, "").trim();
|
|
@@ -4253,6 +5016,15 @@ function normalizeEdgeId(s) {
|
|
|
4253
5016
|
function edgesNameEachOther(a, b) {
|
|
4254
5017
|
return a.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(b.ref)) || b.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(a.ref));
|
|
4255
5018
|
}
|
|
5019
|
+
var BOUNDARY_OUT_RE = /\bOut\s*:\s*([\s\S]*)$/im;
|
|
5020
|
+
function boundaryOutText(body) {
|
|
5021
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5022
|
+
const m = BOUNDARY_OUT_RE.exec(boundary);
|
|
5023
|
+
return m ? m[1] : "";
|
|
5024
|
+
}
|
|
5025
|
+
function namedPathsIn(text) {
|
|
5026
|
+
return [...new Set([...text.matchAll(RATIONALE_PATH_RE_GLOBAL)].map((m) => m[1]))].filter((p) => !/^https?:\/\//i.test(p));
|
|
5027
|
+
}
|
|
4256
5028
|
var FILE_EXTENSIONS = new Set([
|
|
4257
5029
|
"ts",
|
|
4258
5030
|
"tsx",
|
|
@@ -4274,6 +5046,11 @@ var FILE_EXTENSIONS = new Set([
|
|
|
4274
5046
|
"html",
|
|
4275
5047
|
"css"
|
|
4276
5048
|
]);
|
|
5049
|
+
function boundaryPinnedFiles(body) {
|
|
5050
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5051
|
+
const excluded = new Set(namedPathsIn(boundaryOutText(body)));
|
|
5052
|
+
return namedPathsIn(boundary).filter((p) => looksLikeFilePath(p) && !excluded.has(p));
|
|
5053
|
+
}
|
|
4277
5054
|
var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
|
|
4278
5055
|
var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
|
|
4279
5056
|
|
|
@@ -4298,7 +5075,7 @@ function isGrandfathered(isoDate) {
|
|
|
4298
5075
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4299
5076
|
}
|
|
4300
5077
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4301
|
-
function checkA1(entries, principalAllowlist
|
|
5078
|
+
function checkA1(entries, principalAllowlist) {
|
|
4302
5079
|
const failures = [];
|
|
4303
5080
|
for (const e of entries) {
|
|
4304
5081
|
if (!e.facts)
|
|
@@ -4328,6 +5105,37 @@ function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
|
4328
5105
|
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4329
5106
|
};
|
|
4330
5107
|
}
|
|
5108
|
+
function checkA2(entries, hasProvenanceByKey) {
|
|
5109
|
+
const failures = [];
|
|
5110
|
+
for (const e of entries) {
|
|
5111
|
+
if (!e.facts)
|
|
5112
|
+
continue;
|
|
5113
|
+
if (e.facts.issueState !== "closed" || e.facts.prState !== "merged")
|
|
5114
|
+
continue;
|
|
5115
|
+
const key = `${e.trancheSlug}/${e.task.id}`;
|
|
5116
|
+
const hasProvenance = hasProvenanceByKey.get(key);
|
|
5117
|
+
if (hasProvenance === undefined)
|
|
5118
|
+
continue;
|
|
5119
|
+
if (!hasProvenance) {
|
|
5120
|
+
failures.push({
|
|
5121
|
+
code: "archived-without-provenance",
|
|
5122
|
+
issue: e.task.issue,
|
|
5123
|
+
tranche: e.trancheSlug,
|
|
5124
|
+
task: e.task.id,
|
|
5125
|
+
reason: "Closing PR has no `### AEG provenance` comment (Archivist close-out missing)",
|
|
5126
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
5127
|
+
});
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
5131
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
5132
|
+
return {
|
|
5133
|
+
check: "A2",
|
|
5134
|
+
status,
|
|
5135
|
+
failures,
|
|
5136
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
5137
|
+
};
|
|
5138
|
+
}
|
|
4331
5139
|
function checkA3(entries) {
|
|
4332
5140
|
const failures = [];
|
|
4333
5141
|
for (const e of entries) {
|
|
@@ -4543,6 +5351,33 @@ function checkL1(files, entriesBySlug) {
|
|
|
4543
5351
|
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4544
5352
|
};
|
|
4545
5353
|
}
|
|
5354
|
+
function checkL2(files, entriesBySlug) {
|
|
5355
|
+
const failures = [];
|
|
5356
|
+
for (const f of files) {
|
|
5357
|
+
if (!f.archived)
|
|
5358
|
+
continue;
|
|
5359
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
5360
|
+
for (const e of entries) {
|
|
5361
|
+
if (!e.facts)
|
|
5362
|
+
continue;
|
|
5363
|
+
if (e.facts.issueState === "open") {
|
|
5364
|
+
failures.push({
|
|
5365
|
+
code: "premature-archive",
|
|
5366
|
+
issue: e.task.issue,
|
|
5367
|
+
tranche: f.slug,
|
|
5368
|
+
task: e.task.id,
|
|
5369
|
+
reason: `Archived tranche has open task-Issue #${e.task.issue ?? "?"} (premature archive)`
|
|
5370
|
+
});
|
|
5371
|
+
}
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
return {
|
|
5375
|
+
check: "L2",
|
|
5376
|
+
status: "info",
|
|
5377
|
+
failures,
|
|
5378
|
+
note: failures.length > 0 ? `${failures.length} archived tranche(s) with an open task-Issue — investigate (advisory)` : undefined
|
|
5379
|
+
};
|
|
5380
|
+
}
|
|
4546
5381
|
function checkL3(files) {
|
|
4547
5382
|
const active = files.filter((f) => !f.archived);
|
|
4548
5383
|
return {
|
|
@@ -4552,6 +5387,51 @@ function checkL3(files) {
|
|
|
4552
5387
|
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4553
5388
|
};
|
|
4554
5389
|
}
|
|
5390
|
+
function checkL4(activeTrancheSlugs, issueMilestones) {
|
|
5391
|
+
const activeSet = new Set(activeTrancheSlugs);
|
|
5392
|
+
const failures = [];
|
|
5393
|
+
for (const f of issueMilestones) {
|
|
5394
|
+
if (!activeSet.has(f.tranche))
|
|
5395
|
+
continue;
|
|
5396
|
+
if (f.milestoneTitle === f.tranche)
|
|
5397
|
+
continue;
|
|
5398
|
+
failures.push({
|
|
5399
|
+
code: "milestone-drift",
|
|
5400
|
+
issue: f.issue,
|
|
5401
|
+
tranche: f.tranche,
|
|
5402
|
+
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`
|
|
5403
|
+
});
|
|
5404
|
+
}
|
|
5405
|
+
return {
|
|
5406
|
+
check: "L4",
|
|
5407
|
+
status: "info",
|
|
5408
|
+
failures,
|
|
5409
|
+
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
|
|
5410
|
+
};
|
|
5411
|
+
}
|
|
5412
|
+
function checkL5(activeTrancheSlugs, entriesBySlug) {
|
|
5413
|
+
const failures = [];
|
|
5414
|
+
for (const slug of activeTrancheSlugs) {
|
|
5415
|
+
const entries = entriesBySlug.get(slug) ?? [];
|
|
5416
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
5417
|
+
if (withFacts.length === 0)
|
|
5418
|
+
continue;
|
|
5419
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
5420
|
+
if (allClosed) {
|
|
5421
|
+
failures.push({
|
|
5422
|
+
code: "tranche-not-archived",
|
|
5423
|
+
tranche: slug,
|
|
5424
|
+
reason: "Every task Issue is closed but the tranche is not recorded as complete — archive it"
|
|
5425
|
+
});
|
|
5426
|
+
}
|
|
5427
|
+
}
|
|
5428
|
+
return {
|
|
5429
|
+
check: "L5",
|
|
5430
|
+
status: failures.length > 0 ? "fail" : "pass",
|
|
5431
|
+
failures,
|
|
5432
|
+
note: failures.length > 0 ? `${failures.length} tranche(s) whose task Issues are all closed but were never archived` : undefined
|
|
5433
|
+
};
|
|
5434
|
+
}
|
|
4555
5435
|
function extractClosesReferences(prBody) {
|
|
4556
5436
|
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4557
5437
|
const stripped = stripCode(prBody);
|
|
@@ -4647,6 +5527,58 @@ function extractIssue(body) {
|
|
|
4647
5527
|
}
|
|
4648
5528
|
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4649
5529
|
import { createHash as createHash4 } from "node:crypto";
|
|
5530
|
+
|
|
5531
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
5532
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
5533
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
5534
|
+
let best = 0;
|
|
5535
|
+
for (const c of comments) {
|
|
5536
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5537
|
+
continue;
|
|
5538
|
+
const firstLine = (c.body.split(`
|
|
5539
|
+
`)[0] ?? "").trim();
|
|
5540
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
5541
|
+
if (!m)
|
|
5542
|
+
continue;
|
|
5543
|
+
const k = Number.parseInt(m[1], 10);
|
|
5544
|
+
if (k > best)
|
|
5545
|
+
best = k;
|
|
5546
|
+
}
|
|
5547
|
+
return best;
|
|
5548
|
+
}
|
|
5549
|
+
function parseRulingIdentity(rulingId) {
|
|
5550
|
+
const m = /^(issue-)?(\d+)-(\d+)$/.exec(rulingId);
|
|
5551
|
+
if (!m)
|
|
5552
|
+
return null;
|
|
5553
|
+
const ref = Number.parseInt(m[2], 10);
|
|
5554
|
+
const ordinal = Number.parseInt(m[3], 10);
|
|
5555
|
+
if (ref <= 0 || ordinal <= 0)
|
|
5556
|
+
return null;
|
|
5557
|
+
return { target: m[1] ? "issue" : "pr", ref, ordinal };
|
|
5558
|
+
}
|
|
5559
|
+
function principalRulingTextById(comments, allowlist, rulingId) {
|
|
5560
|
+
const identity = parseRulingIdentity(rulingId);
|
|
5561
|
+
if (identity === null)
|
|
5562
|
+
return null;
|
|
5563
|
+
const matches = comments.filter((c) => {
|
|
5564
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5565
|
+
return false;
|
|
5566
|
+
const m = RULING_MARKER_ORDINAL.exec((c.body.split(`
|
|
5567
|
+
`)[0] ?? "").trim());
|
|
5568
|
+
return m !== null && Number.parseInt(m[1], 10) === identity.ordinal;
|
|
5569
|
+
});
|
|
5570
|
+
if (matches.length !== 1)
|
|
5571
|
+
return null;
|
|
5572
|
+
const body = matches[0].body;
|
|
5573
|
+
const idx = body.indexOf(`
|
|
5574
|
+
`);
|
|
5575
|
+
return idx === -1 ? "" : body.slice(idx + 1).trim();
|
|
5576
|
+
}
|
|
5577
|
+
|
|
5578
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
5579
|
+
function pauseBoundRulingDigest(rulingText) {
|
|
5580
|
+
return createHash4("sha256").update(rulingText).digest("hex");
|
|
5581
|
+
}
|
|
4650
5582
|
function briefHash(brief) {
|
|
4651
5583
|
return createHash4("sha256").update(`${brief}
|
|
4652
5584
|
`).digest("hex");
|
|
@@ -4707,14 +5639,19 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4707
5639
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4708
5640
|
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4709
5641
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
5642
|
+
const legacyCurrent = current.manifestVersion === undefined;
|
|
5643
|
+
const manifestVersion = legacyCurrent ? echoed.manifestVersion === undefined || echoed.manifestVersion === null : echoed.manifestVersion === current.manifestVersion;
|
|
5644
|
+
const pauseBoundRuling = legacyCurrent ? true : Object.hasOwn(echoed, "pauseBoundRuling") && JSON.stringify(echoed.pauseBoundRuling) === JSON.stringify(current.pauseBoundRuling);
|
|
4710
5645
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4711
5646
|
return {
|
|
4712
|
-
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
5647
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && pauseBoundRuling && manifestVersion && policyDigestBound,
|
|
4713
5648
|
head,
|
|
4714
5649
|
base,
|
|
4715
5650
|
briefHash: briefHashBound,
|
|
4716
5651
|
objectivesVersion,
|
|
4717
5652
|
rulingOrdinal,
|
|
5653
|
+
pauseBoundRuling,
|
|
5654
|
+
manifestVersion,
|
|
4718
5655
|
policyDigest: policyDigestBound
|
|
4719
5656
|
};
|
|
4720
5657
|
}
|
|
@@ -4730,7 +5667,7 @@ function renderGateDeferred(deferred) {
|
|
|
4730
5667
|
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4731
5668
|
}
|
|
4732
5669
|
function checkReviewGate(input) {
|
|
4733
|
-
const principalAllowlist = input
|
|
5670
|
+
const { principalAllowlist } = input;
|
|
4734
5671
|
const waived = isWaiverLabelActorVerified({
|
|
4735
5672
|
label: WAIVER_LABEL_REVIEW,
|
|
4736
5673
|
labels: input.labels,
|
|
@@ -4769,27 +5706,33 @@ function checkReviewGate(input) {
|
|
|
4769
5706
|
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4770
5707
|
const securityClean = securityTextClean && securityPolicyClean;
|
|
4771
5708
|
const currentManifest = {
|
|
5709
|
+
...input.manifestVersion === undefined ? {} : { manifestVersion: input.manifestVersion },
|
|
4772
5710
|
headSha: input.headSha,
|
|
4773
5711
|
baseSha: input.baseSha ?? null,
|
|
4774
5712
|
briefHash: input.briefHash ?? null,
|
|
4775
5713
|
objectivesVersion: input.objectivesVersion,
|
|
4776
5714
|
rulingOrdinal: input.rulingOrdinal,
|
|
5715
|
+
pauseBoundRuling: input.pauseBoundRuling ?? null,
|
|
4777
5716
|
policyDigest: policyDigest(policy)
|
|
4778
5717
|
};
|
|
4779
5718
|
const codeReviewEchoed = {
|
|
5719
|
+
manifestVersion: codeReview.manifestVersion,
|
|
4780
5720
|
headSha: codeReview.headSha,
|
|
4781
5721
|
baseSha: codeReview.baseSha,
|
|
4782
5722
|
briefHash: codeReview.briefHash,
|
|
4783
5723
|
objectivesVersion: codeReview.objectivesVersion,
|
|
4784
5724
|
rulingOrdinal: codeReview.rulingOrdinal,
|
|
5725
|
+
pauseBoundRuling: codeReview.pauseBoundRuling,
|
|
4785
5726
|
policyDigest: codeReview.policyDigest
|
|
4786
5727
|
};
|
|
4787
5728
|
const securityEchoed = {
|
|
5729
|
+
manifestVersion: security.manifestVersion,
|
|
4788
5730
|
headSha: security.headSha,
|
|
4789
5731
|
baseSha: security.baseSha,
|
|
4790
5732
|
briefHash: security.briefHash,
|
|
4791
5733
|
objectivesVersion: security.objectivesVersion,
|
|
4792
5734
|
rulingOrdinal: security.rulingOrdinal,
|
|
5735
|
+
pauseBoundRuling: security.pauseBoundRuling,
|
|
4793
5736
|
policyDigest: security.policyDigest
|
|
4794
5737
|
};
|
|
4795
5738
|
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
@@ -4828,6 +5771,10 @@ function checkReviewGate(input) {
|
|
|
4828
5771
|
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"}`);
|
|
4829
5772
|
} else if (!codeReviewBinding.policyDigest) {
|
|
4830
5773
|
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}`);
|
|
5774
|
+
} else if (!codeReviewBinding.manifestVersion) {
|
|
5775
|
+
problems.push(`the newest code-review verdict echoes manifest version ${codeReview.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5776
|
+
} else if (!codeReviewBinding.pauseBoundRuling) {
|
|
5777
|
+
problems.push(`the newest code-review verdict echoes pauseBoundRuling ${renderBinding(codeReview.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4831
5778
|
}
|
|
4832
5779
|
if (!securityTextClean) {
|
|
4833
5780
|
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
@@ -4845,6 +5792,10 @@ function checkReviewGate(input) {
|
|
|
4845
5792
|
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"}`);
|
|
4846
5793
|
} else if (!securityBinding.policyDigest) {
|
|
4847
5794
|
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}`);
|
|
5795
|
+
} else if (!securityBinding.manifestVersion) {
|
|
5796
|
+
problems.push(`the newest security-review verdict echoes manifest version ${security.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5797
|
+
} else if (!securityBinding.pauseBoundRuling) {
|
|
5798
|
+
problems.push(`the newest security-review verdict echoes pauseBoundRuling ${renderBinding(security.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4848
5799
|
}
|
|
4849
5800
|
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4850
5801
|
return {
|
|
@@ -4853,29 +5804,16 @@ function checkReviewGate(input) {
|
|
|
4853
5804
|
waived: false
|
|
4854
5805
|
};
|
|
4855
5806
|
}
|
|
5807
|
+
function renderBinding(binding) {
|
|
5808
|
+
if (binding === undefined)
|
|
5809
|
+
return "(absent)";
|
|
5810
|
+
return binding === null ? "(none)" : `${binding.rulingId}|${binding.pauseId}|${binding.contentDigest}`;
|
|
5811
|
+
}
|
|
4856
5812
|
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4857
5813
|
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4858
5814
|
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4859
5815
|
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4860
5816
|
}
|
|
4861
|
-
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4862
|
-
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4863
|
-
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4864
|
-
let best = 0;
|
|
4865
|
-
for (const c of comments) {
|
|
4866
|
-
if (!isPrincipal(c.author, allowlist))
|
|
4867
|
-
continue;
|
|
4868
|
-
const firstLine = (c.body.split(`
|
|
4869
|
-
`)[0] ?? "").trim();
|
|
4870
|
-
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4871
|
-
if (!m)
|
|
4872
|
-
continue;
|
|
4873
|
-
const k = Number.parseInt(m[1], 10);
|
|
4874
|
-
if (k > best)
|
|
4875
|
-
best = k;
|
|
4876
|
-
}
|
|
4877
|
-
return best;
|
|
4878
|
-
}
|
|
4879
5817
|
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4880
5818
|
function splitRow(line) {
|
|
4881
5819
|
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
@@ -5027,7 +5965,6 @@ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
|
5027
5965
|
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
5028
5966
|
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
5029
5967
|
"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)',
|
|
5030
|
-
"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)`,
|
|
5031
5968
|
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
5032
5969
|
};
|
|
5033
5970
|
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
@@ -5251,72 +6188,10 @@ function compareToBaseline(current, baseline) {
|
|
|
5251
6188
|
};
|
|
5252
6189
|
}
|
|
5253
6190
|
// ../../packages/aeg-core/src/retired-vocabulary.ts
|
|
5254
|
-
var
|
|
5255
|
-
var RETIRED_PATTERNS =
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
"decision (entry|logged)",
|
|
5259
|
-
"decision-log entry",
|
|
5260
|
-
"decision log entry",
|
|
5261
|
-
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
5262
|
-
"decision-log",
|
|
5263
|
-
"decision entr",
|
|
5264
|
-
"decisions? (are |is )?logged",
|
|
5265
|
-
"log entries",
|
|
5266
|
-
String.raw`decisions\.md`,
|
|
5267
|
-
"decisions-legacy",
|
|
5268
|
-
"CONTRADICTION",
|
|
5269
|
-
"assumes Tier 3",
|
|
5270
|
-
"Lock: ?YES",
|
|
5271
|
-
"Lock: ?NO",
|
|
5272
|
-
"lock approvals?",
|
|
5273
|
-
"approves locks",
|
|
5274
|
-
"Conforms to lock",
|
|
5275
|
-
"Challenges lock",
|
|
5276
|
-
"checkDecisionNumbersFresh",
|
|
5277
|
-
String.raw`roles/team-leader\.md`,
|
|
5278
|
-
String.raw`\(,`,
|
|
5279
|
-
String.raw`,\)`,
|
|
5280
|
-
String.raw`\(\.\)`,
|
|
5281
|
-
...PLAN_ON_DISK_PATTERNS
|
|
5282
|
-
];
|
|
5283
|
-
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
5284
|
-
var RETIRED_EXEMPT_SUBSTRINGS = [
|
|
5285
|
-
"docs/decisions-legacy.md",
|
|
5286
|
-
"apps/herald-ai/docs/",
|
|
5287
|
-
"apps/vada-ai/docs/",
|
|
5288
|
-
"aeg-root/tranches/completed/",
|
|
5289
|
-
"packages/aeg-core/src/docs/published-prose",
|
|
5290
|
-
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
5291
|
-
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
5292
|
-
"/fixtures/",
|
|
5293
|
-
"/node_modules/",
|
|
5294
|
-
"/.next/",
|
|
5295
|
-
"/.turbo/"
|
|
5296
|
-
];
|
|
5297
|
-
var PATTERN_EXEMPT = {
|
|
5298
|
-
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
5299
|
-
[String.raw`decisions\.md`]: [
|
|
5300
|
-
"docs-index.md",
|
|
5301
|
-
"apps/vada-ai/specs/legacy/README.md",
|
|
5302
|
-
"apps/vada-ai/specs/vada-product-spec.md",
|
|
5303
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5304
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5305
|
-
],
|
|
5306
|
-
"decisions-legacy": [
|
|
5307
|
-
"packages/aeg-core/src/file-classify.ts",
|
|
5308
|
-
"packages/aeg-core/src/file-classify.test.ts",
|
|
5309
|
-
"packages/aeg-core/src/pr-tier.test.ts",
|
|
5310
|
-
"docs-index.md",
|
|
5311
|
-
".claude/skills/database/SKILL.md",
|
|
5312
|
-
".claude/skills/vada-architecture/SKILL.md",
|
|
5313
|
-
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
5314
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5315
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5316
|
-
],
|
|
5317
|
-
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
5318
|
-
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
5319
|
-
};
|
|
6191
|
+
var retiredRules = rulesForGroup("retired-vocabulary");
|
|
6192
|
+
var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
|
|
6193
|
+
var PATTERN_EXEMPT = RETIRED_PATTERN_EXEMPTIONS;
|
|
6194
|
+
var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
|
|
5320
6195
|
function lineNumbers(content, pattern) {
|
|
5321
6196
|
const out = [];
|
|
5322
6197
|
const lines = content.split(`
|
|
@@ -5327,22 +6202,29 @@ function lineNumbers(content, pattern) {
|
|
|
5327
6202
|
}
|
|
5328
6203
|
return out;
|
|
5329
6204
|
}
|
|
5330
|
-
function scanRetiredVocabulary(files) {
|
|
6205
|
+
function scanRetiredVocabulary(files, rules = DEFAULT_PROSE_RULE_SET) {
|
|
5331
6206
|
const findings = [];
|
|
6207
|
+
const retired = rulesOfGroup(rules, "retired-vocabulary");
|
|
5332
6208
|
for (const file of files) {
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
6209
|
+
for (const rule of retired) {
|
|
6210
|
+
if (rule.substringExempt.some((e) => file.path.includes(e)))
|
|
6211
|
+
continue;
|
|
6212
|
+
if (!ruleReads(rules, rule, file.path))
|
|
6213
|
+
continue;
|
|
6214
|
+
const re = rule.patternFor("repository");
|
|
6215
|
+
if (!re)
|
|
6216
|
+
continue;
|
|
6217
|
+
const pattern = rule.custom ? re.source : DEFAULT_PATTERN_OF.get(rule.id) ?? re.source;
|
|
6218
|
+
if (!rule.custom && (PATTERN_EXEMPT[pattern] ?? []).some((e) => file.path.includes(e)))
|
|
5338
6219
|
continue;
|
|
5339
|
-
const re = new RegExp(pattern);
|
|
5340
6220
|
for (const line of lineNumbers(file.content, re)) {
|
|
5341
6221
|
findings.push({
|
|
5342
6222
|
file: file.path,
|
|
5343
6223
|
line,
|
|
5344
6224
|
pattern,
|
|
5345
|
-
message: `claims a retired AEG mechanism is still live (matches /${pattern}/)
|
|
6225
|
+
message: rule.custom ? `${rule.id}: ${rule.message} (matches /${pattern}/)` : `claims a retired AEG mechanism is still live (matches /${pattern}/)`,
|
|
6226
|
+
rule: rule.id,
|
|
6227
|
+
blocking: rule.severity.repository === "error"
|
|
5346
6228
|
});
|
|
5347
6229
|
}
|
|
5348
6230
|
}
|
|
@@ -5366,7 +6248,7 @@ function isSelfDependency(dep, task, issue) {
|
|
|
5366
6248
|
function checkDispatchReadiness(input) {
|
|
5367
6249
|
const { trancheSlug, task } = input;
|
|
5368
6250
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
5369
|
-
const principalAllowlist = input
|
|
6251
|
+
const { principalAllowlist } = input;
|
|
5370
6252
|
const blockerDetails = [];
|
|
5371
6253
|
const push = (blockerClass, message) => {
|
|
5372
6254
|
blockerDetails.push({ class: blockerClass, message });
|
|
@@ -5458,6 +6340,16 @@ function pushesAnyBranchRef(pushRefs) {
|
|
|
5458
6340
|
return pushRefs.split(`
|
|
5459
6341
|
`).map((line) => line.trim()).filter((line) => line.length > 0).some((line) => line.split(/\s+/)[2]?.startsWith("refs/heads/") === true);
|
|
5460
6342
|
}
|
|
6343
|
+
function resolveDefaultBranch(facts) {
|
|
6344
|
+
const { originHead, hasOriginMain, hasOriginMaster } = facts;
|
|
6345
|
+
if (originHead !== null && originHead !== "")
|
|
6346
|
+
return originHead;
|
|
6347
|
+
if (hasOriginMain)
|
|
6348
|
+
return "main";
|
|
6349
|
+
if (hasOriginMaster)
|
|
6350
|
+
return "master";
|
|
6351
|
+
return null;
|
|
6352
|
+
}
|
|
5461
6353
|
function checkMainBranchRefusal(facts) {
|
|
5462
6354
|
const { currentSymbolicBranch, defaultBranch, pushRefs = null } = facts;
|
|
5463
6355
|
if (currentSymbolicBranch === null)
|
|
@@ -5718,54 +6610,61 @@ function checkFirstPushDispatchGate(input) {
|
|
|
5718
6610
|
reason: `verify-dispatch reports READY TO DISPATCH for \`${branch}\`.`
|
|
5719
6611
|
};
|
|
5720
6612
|
}
|
|
5721
|
-
// ../../packages/aeg-core/src/
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
6613
|
+
// ../../packages/aeg-core/src/live-record.ts
|
|
6614
|
+
var RECORD_LINE_RE = /^-\s*\[([ xX])\]\s*\*\*\[live\]\*\*\s+(`+) ?(.+?) ?\2(?!`)\s+—\s+(passed|failed|unverified)\s+at\s+`([^`]+)`/;
|
|
6615
|
+
function liveMarkers(body) {
|
|
6616
|
+
const masked = maskCode(body);
|
|
6617
|
+
return [...masked.matchAll(/<!--\s*AEG:LIVE:(?:START|END)\s*-->/g)].map((m) => ({
|
|
6618
|
+
start: m.index,
|
|
6619
|
+
end: m.index + m[0].length
|
|
6620
|
+
}));
|
|
6621
|
+
}
|
|
6622
|
+
var AMBIGUOUS_RECORD_LINE = {
|
|
6623
|
+
line: "- [ ] **[live]** the pull request body carries more than one `AEG:LIVE` marker pair, so the driver's record cannot be told apart",
|
|
6624
|
+
ticked: false,
|
|
6625
|
+
command: "",
|
|
6626
|
+
outcome: "failed",
|
|
6627
|
+
head: ""
|
|
6628
|
+
};
|
|
6629
|
+
function readLiveRecord(body) {
|
|
6630
|
+
const markers = liveMarkers(body).length;
|
|
6631
|
+
if (markers === 0)
|
|
6632
|
+
return [];
|
|
6633
|
+
if (markers !== 2)
|
|
6634
|
+
return [AMBIGUOUS_RECORD_LINE];
|
|
6635
|
+
const region = anchoredRegion(body, "LIVE");
|
|
6636
|
+
if (region === null)
|
|
6637
|
+
return [];
|
|
6638
|
+
const lines = [];
|
|
6639
|
+
for (const raw of region.split(`
|
|
6640
|
+
`)) {
|
|
6641
|
+
const line = raw.trim();
|
|
6642
|
+
const m = RECORD_LINE_RE.exec(line);
|
|
6643
|
+
if (!m)
|
|
6644
|
+
continue;
|
|
6645
|
+
lines.push({
|
|
6646
|
+
line,
|
|
6647
|
+
ticked: m[1].toLowerCase() === "x",
|
|
6648
|
+
command: m[3],
|
|
6649
|
+
outcome: m[4],
|
|
6650
|
+
head: m[5]
|
|
6651
|
+
});
|
|
5759
6652
|
}
|
|
5760
|
-
return
|
|
5761
|
-
action: "assign",
|
|
5762
|
-
issue,
|
|
5763
|
-
login,
|
|
5764
|
-
reason: `First push of \`${branch}\` — assigning Issue #${issue} to @${login} (the authenticated pusher).`
|
|
5765
|
-
};
|
|
6653
|
+
return lines;
|
|
5766
6654
|
}
|
|
5767
6655
|
// ../../packages/aeg-core/src/test-plan-gate.ts
|
|
5768
|
-
function
|
|
6656
|
+
function gradedLiveLines(record, live) {
|
|
6657
|
+
if (live === undefined)
|
|
6658
|
+
return record.map((entry) => entry.line);
|
|
6659
|
+
const commands = new Set(live.liveCommands);
|
|
6660
|
+
const others = record.filter((entry) => !commands.has(entry.command)).map((entry) => entry.line);
|
|
6661
|
+
const graded = live.liveCommands.map((command) => {
|
|
6662
|
+
const atHead = record.filter((entry) => entry.command === command && entry.head === live.head);
|
|
6663
|
+
return (atHead.find((entry) => entry.ticked) ?? atHead[0])?.line ?? `- [ ] **[live]** \`${command}\` — no passed run recorded at \`${live.head || "an unknown head"}\``;
|
|
6664
|
+
});
|
|
6665
|
+
return [...others, ...graded];
|
|
6666
|
+
}
|
|
6667
|
+
function evaluateTestPlanGate(body, branch, live) {
|
|
5769
6668
|
if (!body) {
|
|
5770
6669
|
return {
|
|
5771
6670
|
verdict: "pass",
|
|
@@ -5776,7 +6675,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5776
6675
|
};
|
|
5777
6676
|
}
|
|
5778
6677
|
const located = locateTestPlanSection(body);
|
|
5779
|
-
|
|
6678
|
+
const liveLines = gradedLiveLines(readLiveRecord(body), live);
|
|
6679
|
+
const liveUnticked = liveLines.some((line) => /^[-*]\s+\[\s\]/.test(line));
|
|
6680
|
+
if (!located.found && !liveUnticked) {
|
|
5780
6681
|
if (parseTaskBranchIdentity(branch) !== null) {
|
|
5781
6682
|
return {
|
|
5782
6683
|
verdict: "fail",
|
|
@@ -5796,15 +6697,18 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5796
6697
|
]
|
|
5797
6698
|
};
|
|
5798
6699
|
}
|
|
5799
|
-
const section = located.section;
|
|
5800
|
-
if (/unit-tests-only/i.test(section)) {
|
|
6700
|
+
const section = located.found ? located.section : "";
|
|
6701
|
+
if (/unit-tests-only/i.test(section) && !liveUnticked) {
|
|
5801
6702
|
return {
|
|
5802
6703
|
verdict: "pass",
|
|
5803
6704
|
messages: ["Test Plan: unit-tests-only — pure-logic brief, CI unit-tests are the proof.", "PASS."]
|
|
5804
6705
|
};
|
|
5805
6706
|
}
|
|
5806
|
-
const checkboxLines =
|
|
5807
|
-
|
|
6707
|
+
const checkboxLines = [
|
|
6708
|
+
...section.split(`
|
|
6709
|
+
`).map((line) => line.trimStart()).filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line)),
|
|
6710
|
+
...liveLines
|
|
6711
|
+
];
|
|
5808
6712
|
if (checkboxLines.length === 0) {
|
|
5809
6713
|
return {
|
|
5810
6714
|
verdict: "pass",
|
|
@@ -5821,7 +6725,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5821
6725
|
messages.push("", "FAIL — the following [principal] Test Plan items are unticked:");
|
|
5822
6726
|
for (const line of unchecked)
|
|
5823
6727
|
messages.push(` ${line}`);
|
|
5824
|
-
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.",
|
|
6728
|
+
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 ? [
|
|
6729
|
+
"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."
|
|
6730
|
+
] : [], "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.");
|
|
5825
6731
|
return { verdict: "fail", messages };
|
|
5826
6732
|
}
|
|
5827
6733
|
messages.push("All [principal] Test Plan items ticked — runtime verification complete.", "PASS.");
|
|
@@ -6010,9 +6916,11 @@ var LineageSchema = z3.object({
|
|
|
6010
6916
|
parent: z3.string().nullable()
|
|
6011
6917
|
}).strict();
|
|
6012
6918
|
var InputVersionsSchema = z3.object({
|
|
6919
|
+
manifest_version: z3.literal(2).nullable().optional(),
|
|
6013
6920
|
objectives_version: z3.string().nullable(),
|
|
6014
6921
|
brief_hash: z3.string().nullable(),
|
|
6015
6922
|
ruling_ordinal: z3.number().int().nullable(),
|
|
6923
|
+
pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
|
|
6016
6924
|
policy_digest: z3.string().nullable()
|
|
6017
6925
|
}).strict();
|
|
6018
6926
|
var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
@@ -6560,17 +7468,19 @@ function buildHeader(input) {
|
|
|
6560
7468
|
parent: lineageFieldFromEnv(input.env.parent)
|
|
6561
7469
|
},
|
|
6562
7470
|
input_versions: {
|
|
7471
|
+
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
6563
7472
|
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
6564
7473
|
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
6565
7474
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
7475
|
+
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
6566
7476
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
6567
7477
|
},
|
|
6568
7478
|
provenance: provenanceFor(input),
|
|
6569
7479
|
work: {
|
|
6570
7480
|
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
6571
7481
|
repo: input.repo,
|
|
6572
|
-
change: null,
|
|
6573
|
-
revision: null
|
|
7482
|
+
change: pr === undefined ? null : String(pr),
|
|
7483
|
+
revision: input.revision ?? null
|
|
6574
7484
|
},
|
|
6575
7485
|
flow: {
|
|
6576
7486
|
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
@@ -6758,6 +7668,12 @@ var ManifestRecordSchema = z4.object({
|
|
|
6758
7668
|
briefHash: z4.string().min(1).nullable(),
|
|
6759
7669
|
objectivesVersion: z4.string().min(1).nullable(),
|
|
6760
7670
|
rulingOrdinal: epochNumber,
|
|
7671
|
+
manifestVersion: z4.literal(2).optional(),
|
|
7672
|
+
pauseBoundRuling: z4.object({
|
|
7673
|
+
rulingId: z4.string().min(1),
|
|
7674
|
+
pauseId: z4.string().min(1),
|
|
7675
|
+
contentDigest: z4.string().min(1)
|
|
7676
|
+
}).strict().nullable().optional(),
|
|
6761
7677
|
policyDigest: z4.string().min(1),
|
|
6762
7678
|
recordedAt: isoTimestamp
|
|
6763
7679
|
}).strict();
|
|
@@ -6779,7 +7695,11 @@ var LoopStateRecordSchema = z4.object({
|
|
|
6779
7695
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6780
7696
|
repeatMemory: z4.object({
|
|
6781
7697
|
blockingFindings: z4.array(z4.string()),
|
|
6782
|
-
lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
|
|
7698
|
+
lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
|
|
7699
|
+
}).strict().optional(),
|
|
7700
|
+
developerHandoff: z4.object({
|
|
7701
|
+
findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
|
|
7702
|
+
failingChecks: z4.array(z4.string().min(1))
|
|
6783
7703
|
}).strict().optional(),
|
|
6784
7704
|
publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
6785
7705
|
taskStartedAt: isoTimestamp.optional(),
|
|
@@ -6878,6 +7798,7 @@ var REGISTRY = [
|
|
|
6878
7798
|
{
|
|
6879
7799
|
name: "brief-shape",
|
|
6880
7800
|
validates: "body",
|
|
7801
|
+
requiresOpenPr: true,
|
|
6881
7802
|
run: bin("check-brief-shape"),
|
|
6882
7803
|
scope: "diff",
|
|
6883
7804
|
timeoutMs: 15000,
|
|
@@ -6886,7 +7807,9 @@ var REGISTRY = [
|
|
|
6886
7807
|
BRANCH: { optional: true },
|
|
6887
7808
|
PR_NUMBER: { optional: true },
|
|
6888
7809
|
GITHUB_TOKEN: { optional: true },
|
|
6889
|
-
GH_TOKEN: { optional: true }
|
|
7810
|
+
GH_TOKEN: { optional: true },
|
|
7811
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
7812
|
+
GITHUB_ACTIONS: { optional: true }
|
|
6890
7813
|
}
|
|
6891
7814
|
},
|
|
6892
7815
|
0
|
|
@@ -6895,6 +7818,7 @@ var REGISTRY = [
|
|
|
6895
7818
|
{
|
|
6896
7819
|
name: "pr-report-density",
|
|
6897
7820
|
validates: "body",
|
|
7821
|
+
requiresOpenPr: true,
|
|
6898
7822
|
run: bin("check-pr-report-density"),
|
|
6899
7823
|
scope: "diff",
|
|
6900
7824
|
timeoutMs: 15000,
|
|
@@ -6920,7 +7844,9 @@ var REGISTRY = [
|
|
|
6920
7844
|
PR_NUMBER: { optional: true },
|
|
6921
7845
|
GITHUB_REPOSITORY: { optional: true },
|
|
6922
7846
|
GITHUB_TOKEN: { optional: true },
|
|
6923
|
-
GH_TOKEN: { optional: true }
|
|
7847
|
+
GH_TOKEN: { optional: true },
|
|
7848
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
7849
|
+
GITHUB_ACTIONS: { optional: true }
|
|
6924
7850
|
}
|
|
6925
7851
|
},
|
|
6926
7852
|
0
|
|
@@ -6944,6 +7870,7 @@ var REGISTRY = [
|
|
|
6944
7870
|
{
|
|
6945
7871
|
name: "pr-premise-reassert",
|
|
6946
7872
|
validates: "body",
|
|
7873
|
+
requiresOpenPr: true,
|
|
6947
7874
|
run: bin("check-pr-premise-reassert"),
|
|
6948
7875
|
scope: "diff",
|
|
6949
7876
|
timeoutMs: 15000,
|
|
@@ -6964,7 +7891,9 @@ var REGISTRY = [
|
|
|
6964
7891
|
BRANCH: { optional: true },
|
|
6965
7892
|
GITHUB_TOKEN: { optional: true },
|
|
6966
7893
|
GH_TOKEN: { optional: true },
|
|
6967
|
-
PREMISE_FILE: { optional: true }
|
|
7894
|
+
PREMISE_FILE: { optional: true },
|
|
7895
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
7896
|
+
GITHUB_ACTIONS: { optional: true }
|
|
6968
7897
|
}
|
|
6969
7898
|
},
|
|
6970
7899
|
0
|
|
@@ -7016,7 +7945,9 @@ var REGISTRY = [
|
|
|
7016
7945
|
PR_BODY: { optional: true },
|
|
7017
7946
|
PR_BODY_FILE: { optional: true },
|
|
7018
7947
|
GITHUB_TOKEN: { optional: true },
|
|
7019
|
-
GH_TOKEN: { optional: true }
|
|
7948
|
+
GH_TOKEN: { optional: true },
|
|
7949
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
7950
|
+
GITHUB_ACTIONS: { optional: true }
|
|
7020
7951
|
}
|
|
7021
7952
|
},
|
|
7022
7953
|
1
|
|
@@ -7032,7 +7963,13 @@ var REGISTRY = [
|
|
|
7032
7963
|
principalOwed: true,
|
|
7033
7964
|
env: {
|
|
7034
7965
|
PR_BODY: { optional: true },
|
|
7035
|
-
BRANCH: { optional: true }
|
|
7966
|
+
BRANCH: { optional: true },
|
|
7967
|
+
PULL_REQUEST_HEAD_SHA: { optional: true },
|
|
7968
|
+
GITHUB_REPOSITORY: { optional: true },
|
|
7969
|
+
GITHUB_TOKEN: { optional: true },
|
|
7970
|
+
GH_TOKEN: { optional: true },
|
|
7971
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
7972
|
+
GITHUB_ACTIONS: { optional: true }
|
|
7036
7973
|
}
|
|
7037
7974
|
},
|
|
7038
7975
|
1
|
|
@@ -7048,8 +7985,14 @@ var REGISTRY = [
|
|
|
7048
7985
|
ownWorkflow: true,
|
|
7049
7986
|
env: {
|
|
7050
7987
|
PR_BODY: { optional: true },
|
|
7051
|
-
BRANCH: { optional: true }
|
|
7052
|
-
|
|
7988
|
+
BRANCH: { optional: true },
|
|
7989
|
+
PULL_REQUEST_HEAD_SHA: { optional: true },
|
|
7990
|
+
GITHUB_REPOSITORY: { optional: true },
|
|
7991
|
+
GITHUB_TOKEN: { optional: true },
|
|
7992
|
+
GH_TOKEN: { optional: true },
|
|
7993
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
7994
|
+
GITHUB_ACTIONS: { optional: true }
|
|
7995
|
+
}
|
|
7053
7996
|
},
|
|
7054
7997
|
1
|
|
7055
7998
|
],
|
|
@@ -7067,7 +8010,9 @@ var REGISTRY = [
|
|
|
7067
8010
|
PR_NUMBER: { optional: true },
|
|
7068
8011
|
GITHUB_REPOSITORY: { optional: true },
|
|
7069
8012
|
GITHUB_TOKEN: { optional: true },
|
|
7070
|
-
GH_TOKEN: { optional: true }
|
|
8013
|
+
GH_TOKEN: { optional: true },
|
|
8014
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
8015
|
+
GITHUB_ACTIONS: { optional: true }
|
|
7071
8016
|
}
|
|
7072
8017
|
},
|
|
7073
8018
|
1
|
|
@@ -7107,7 +8052,9 @@ var REGISTRY = [
|
|
|
7107
8052
|
PR_NUMBER: { optional: true },
|
|
7108
8053
|
GITHUB_REPOSITORY: { optional: true },
|
|
7109
8054
|
GITHUB_TOKEN: { optional: true },
|
|
7110
|
-
GH_TOKEN: { optional: true }
|
|
8055
|
+
GH_TOKEN: { optional: true },
|
|
8056
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
8057
|
+
GITHUB_ACTIONS: { optional: true }
|
|
7111
8058
|
}
|
|
7112
8059
|
},
|
|
7113
8060
|
1
|
|
@@ -7160,12 +8107,15 @@ var REGISTRY = [
|
|
|
7160
8107
|
{
|
|
7161
8108
|
name: "doc-coverage-push",
|
|
7162
8109
|
validates: "body",
|
|
8110
|
+
advisory: true,
|
|
7163
8111
|
run: bin("check-doc-coverage-push"),
|
|
7164
8112
|
scope: "diff",
|
|
7165
8113
|
timeoutMs: 15000,
|
|
7166
8114
|
env: {
|
|
7167
8115
|
OVERRIDE_DOCS: { optional: true },
|
|
7168
8116
|
BASE_SHA: { optional: true },
|
|
8117
|
+
GIT_INDEX_FILE: { optional: true },
|
|
8118
|
+
VINAYA_COMMIT_HOOK: { optional: true },
|
|
7169
8119
|
PR_BODY: { optional: true },
|
|
7170
8120
|
PR_BODY_FILE: { optional: true },
|
|
7171
8121
|
PR_LABELS: { optional: true },
|
|
@@ -7177,21 +8127,6 @@ var REGISTRY = [
|
|
|
7177
8127
|
},
|
|
7178
8128
|
0
|
|
7179
8129
|
],
|
|
7180
|
-
[
|
|
7181
|
-
{
|
|
7182
|
-
name: "issue-assignment",
|
|
7183
|
-
run: bin("check-issue-assignment"),
|
|
7184
|
-
scope: "full",
|
|
7185
|
-
timeoutMs: 30000,
|
|
7186
|
-
env: {
|
|
7187
|
-
AEG_REPO: { optional: true },
|
|
7188
|
-
BRANCH: { optional: true },
|
|
7189
|
-
GITHUB_TOKEN: { optional: true },
|
|
7190
|
-
GH_TOKEN: { optional: true }
|
|
7191
|
-
}
|
|
7192
|
-
},
|
|
7193
|
-
0
|
|
7194
|
-
],
|
|
7195
8130
|
[
|
|
7196
8131
|
{
|
|
7197
8132
|
name: "evidence-fresh",
|
|
@@ -7205,7 +8140,9 @@ var REGISTRY = [
|
|
|
7205
8140
|
PR_BODY: { optional: true },
|
|
7206
8141
|
BASE_SHA: { optional: true },
|
|
7207
8142
|
GITHUB_TOKEN: { optional: true },
|
|
7208
|
-
GH_TOKEN: { optional: true }
|
|
8143
|
+
GH_TOKEN: { optional: true },
|
|
8144
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
8145
|
+
GITHUB_ACTIONS: { optional: true }
|
|
7209
8146
|
}
|
|
7210
8147
|
},
|
|
7211
8148
|
1
|
|
@@ -7216,7 +8153,11 @@ var REGISTRY = [
|
|
|
7216
8153
|
run: bin("check-reader-resolvable-prose"),
|
|
7217
8154
|
scope: "full",
|
|
7218
8155
|
timeoutMs: 30000,
|
|
7219
|
-
env: {
|
|
8156
|
+
env: {
|
|
8157
|
+
BASE_SHA: { optional: true },
|
|
8158
|
+
GIT_INDEX_FILE: { optional: true },
|
|
8159
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
8160
|
+
},
|
|
7220
8161
|
include: [
|
|
7221
8162
|
"aeg-root/**/*.md",
|
|
7222
8163
|
"apps/cli/src/**",
|
|
@@ -7234,7 +8175,11 @@ var REGISTRY = [
|
|
|
7234
8175
|
run: bin("check-retired-vocabulary"),
|
|
7235
8176
|
scope: "full",
|
|
7236
8177
|
timeoutMs: 30000,
|
|
7237
|
-
env: {
|
|
8178
|
+
env: {
|
|
8179
|
+
BASE_SHA: { optional: true },
|
|
8180
|
+
GIT_INDEX_FILE: { optional: true },
|
|
8181
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
8182
|
+
},
|
|
7238
8183
|
include: ["aeg-root/**/*.md"]
|
|
7239
8184
|
},
|
|
7240
8185
|
0
|
|
@@ -7242,10 +8187,15 @@ var REGISTRY = [
|
|
|
7242
8187
|
[
|
|
7243
8188
|
{
|
|
7244
8189
|
name: "doctrine-portability",
|
|
8190
|
+
advisory: true,
|
|
7245
8191
|
run: bin("check-doctrine-portability"),
|
|
7246
8192
|
scope: "full",
|
|
7247
8193
|
timeoutMs: 30000,
|
|
7248
|
-
env: {
|
|
8194
|
+
env: {
|
|
8195
|
+
BASE_SHA: { optional: true },
|
|
8196
|
+
GIT_INDEX_FILE: { optional: true },
|
|
8197
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
8198
|
+
},
|
|
7249
8199
|
include: ["aeg-root/**/*.md"]
|
|
7250
8200
|
},
|
|
7251
8201
|
0
|
|
@@ -7278,7 +8228,11 @@ var REGISTRY = [
|
|
|
7278
8228
|
run: bin("check-exec-bits"),
|
|
7279
8229
|
scope: "diff",
|
|
7280
8230
|
timeoutMs: 30000,
|
|
7281
|
-
env: {
|
|
8231
|
+
env: {
|
|
8232
|
+
BASE_SHA: { optional: true },
|
|
8233
|
+
GIT_INDEX_FILE: { optional: true },
|
|
8234
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
8235
|
+
}
|
|
7282
8236
|
},
|
|
7283
8237
|
0
|
|
7284
8238
|
],
|
|
@@ -7288,17 +8242,26 @@ var REGISTRY = [
|
|
|
7288
8242
|
run: bin("check-ci-shard-coverage"),
|
|
7289
8243
|
scope: "diff",
|
|
7290
8244
|
timeoutMs: 15000,
|
|
7291
|
-
env: {
|
|
8245
|
+
env: {
|
|
8246
|
+
BASE_SHA: { optional: true },
|
|
8247
|
+
GIT_INDEX_FILE: { optional: true },
|
|
8248
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
8249
|
+
}
|
|
7292
8250
|
},
|
|
7293
8251
|
0
|
|
7294
8252
|
],
|
|
7295
8253
|
[
|
|
7296
8254
|
{
|
|
7297
8255
|
name: "workspace-escape",
|
|
8256
|
+
advisory: true,
|
|
7298
8257
|
run: bin("check-workspace-escape"),
|
|
7299
8258
|
scope: "full",
|
|
7300
8259
|
timeoutMs: 30000,
|
|
7301
|
-
env: {
|
|
8260
|
+
env: {
|
|
8261
|
+
BASE_SHA: { optional: true },
|
|
8262
|
+
GIT_INDEX_FILE: { optional: true },
|
|
8263
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
8264
|
+
},
|
|
7302
8265
|
include: ["aeg-root/**/*.md"]
|
|
7303
8266
|
},
|
|
7304
8267
|
0
|
|
@@ -7309,17 +8272,23 @@ var REGISTRY = [
|
|
|
7309
8272
|
run: bin("check-changeset-coverage"),
|
|
7310
8273
|
scope: "diff",
|
|
7311
8274
|
timeoutMs: 15000,
|
|
7312
|
-
env: {
|
|
8275
|
+
env: {
|
|
8276
|
+
BASE_SHA: { optional: true },
|
|
8277
|
+
GIT_INDEX_FILE: { optional: true },
|
|
8278
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
8279
|
+
}
|
|
7313
8280
|
},
|
|
7314
8281
|
0
|
|
7315
8282
|
],
|
|
7316
8283
|
[
|
|
7317
8284
|
{
|
|
7318
8285
|
name: "quoted-command",
|
|
8286
|
+
advisory: true,
|
|
7319
8287
|
run: bin("check-quoted-command"),
|
|
7320
|
-
scope: "
|
|
8288
|
+
scope: "full",
|
|
7321
8289
|
timeoutMs: 15000,
|
|
7322
|
-
env: {}
|
|
8290
|
+
env: {},
|
|
8291
|
+
include: ["aeg-root/**/*.md"]
|
|
7323
8292
|
},
|
|
7324
8293
|
0
|
|
7325
8294
|
],
|
|
@@ -7327,7 +8296,7 @@ var REGISTRY = [
|
|
|
7327
8296
|
{
|
|
7328
8297
|
name: "main-branch-refusal",
|
|
7329
8298
|
run: bin("check-main-branch-refusal"),
|
|
7330
|
-
scope: "
|
|
8299
|
+
scope: "diff",
|
|
7331
8300
|
timeoutMs: 15000,
|
|
7332
8301
|
env: { VINAYA_PUSH_REFS: { optional: true } }
|
|
7333
8302
|
},
|
|
@@ -7394,18 +8363,6 @@ var REGISTRY = [
|
|
|
7394
8363
|
},
|
|
7395
8364
|
1
|
|
7396
8365
|
],
|
|
7397
|
-
[
|
|
7398
|
-
{
|
|
7399
|
-
name: "issue-tranche-label",
|
|
7400
|
-
run: bin("check-issue-tranche-label"),
|
|
7401
|
-
validates: "issue",
|
|
7402
|
-
scope: "full",
|
|
7403
|
-
ownWorkflow: true,
|
|
7404
|
-
timeoutMs: 15000,
|
|
7405
|
-
env: { ISSUE_BODY: { optional: true }, ISSUE_LABELS: { optional: true } }
|
|
7406
|
-
},
|
|
7407
|
-
1
|
|
7408
|
-
],
|
|
7409
8366
|
[
|
|
7410
8367
|
{
|
|
7411
8368
|
name: "issue-milestone-attach",
|
|
@@ -7455,29 +8412,320 @@ import { promisify as promisify4 } from "node:util";
|
|
|
7455
8412
|
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
7456
8413
|
import { homedir } from "node:os";
|
|
7457
8414
|
import { dirname as dirname2, isAbsolute, join as join3, resolve } from "node:path";
|
|
7458
|
-
import { z as
|
|
8415
|
+
import { z as z6 } from "zod";
|
|
8416
|
+
|
|
8417
|
+
// src/checks/contract.ts
|
|
8418
|
+
var CHECK_SCHEMA_VERSION = 1;
|
|
8419
|
+
function emitCheckError(error) {
|
|
8420
|
+
process.stderr.write(`${JSON.stringify(error)}
|
|
8421
|
+
`);
|
|
8422
|
+
}
|
|
7459
8423
|
|
|
7460
8424
|
// src/lib/agent-vendors.ts
|
|
7461
8425
|
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
7462
8426
|
|
|
8427
|
+
// src/lib/prose-rules-config.ts
|
|
8428
|
+
import safeRegex from "safe-regex2";
|
|
8429
|
+
import { z as z5 } from "zod";
|
|
8430
|
+
var SEVERITIES = ["error", "warning"];
|
|
8431
|
+
var OVERRIDE_KEYS = ["scopes", "severity", "exempt"];
|
|
8432
|
+
var FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
|
|
8433
|
+
var CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
|
|
8434
|
+
var DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
|
|
8435
|
+
function isPlainObject3(value) {
|
|
8436
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8437
|
+
}
|
|
8438
|
+
function outsideRepositoryReason(entry) {
|
|
8439
|
+
if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
|
|
8440
|
+
return "must be a repository-relative path, not an absolute one";
|
|
8441
|
+
if (entry.split(/[\\/]/).includes(".."))
|
|
8442
|
+
return "must stay inside the repository — no `..` segment";
|
|
8443
|
+
return null;
|
|
8444
|
+
}
|
|
8445
|
+
var RepoRelativePathSchema = z5.string().min(1).superRefine((entry, ctx) => {
|
|
8446
|
+
const reason = outsideRepositoryReason(entry);
|
|
8447
|
+
if (reason)
|
|
8448
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, message: reason });
|
|
8449
|
+
});
|
|
8450
|
+
function pathListIssues(value, path, issues) {
|
|
8451
|
+
if (!Array.isArray(value)) {
|
|
8452
|
+
issues.push({ path, message: "must be a list of repository-relative paths" });
|
|
8453
|
+
return;
|
|
8454
|
+
}
|
|
8455
|
+
value.forEach((entry, index) => {
|
|
8456
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
8457
|
+
issues.push({ path: [...path, index], message: "must be a non-empty repository-relative path" });
|
|
8458
|
+
return;
|
|
8459
|
+
}
|
|
8460
|
+
const reason = outsideRepositoryReason(entry);
|
|
8461
|
+
if (reason)
|
|
8462
|
+
issues.push({ path: [...path, index], message: reason });
|
|
8463
|
+
});
|
|
8464
|
+
}
|
|
8465
|
+
function scopeListIssues(value, path, allowed, issues) {
|
|
8466
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
8467
|
+
issues.push({ path, message: "must name at least one scope" });
|
|
8468
|
+
return null;
|
|
8469
|
+
}
|
|
8470
|
+
const scopes = [];
|
|
8471
|
+
value.forEach((scope, index) => {
|
|
8472
|
+
if (typeof scope !== "string" || !CONFIGURABLE_PROSE_SCOPES.includes(scope)) {
|
|
8473
|
+
issues.push({
|
|
8474
|
+
path: [...path, index],
|
|
8475
|
+
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(", ")}`
|
|
8476
|
+
});
|
|
8477
|
+
return;
|
|
8478
|
+
}
|
|
8479
|
+
if (!allowed.includes(scope)) {
|
|
8480
|
+
issues.push({
|
|
8481
|
+
path: [...path, index],
|
|
8482
|
+
message: `scope "${scope}" is not one this rule can run in — it can run in: ${allowed.join(", ")}`
|
|
8483
|
+
});
|
|
8484
|
+
return;
|
|
8485
|
+
}
|
|
8486
|
+
scopes.push(scope);
|
|
8487
|
+
});
|
|
8488
|
+
return scopes;
|
|
8489
|
+
}
|
|
8490
|
+
function severityIssues(value, path, scopes, issues) {
|
|
8491
|
+
if (typeof value === "string") {
|
|
8492
|
+
if (!SEVERITIES.includes(value)) {
|
|
8493
|
+
issues.push({ path, message: `unknown severity ${JSON.stringify(value)} — use "error" or "warning"` });
|
|
8494
|
+
}
|
|
8495
|
+
return;
|
|
8496
|
+
}
|
|
8497
|
+
if (!isPlainObject3(value)) {
|
|
8498
|
+
issues.push({ path, message: 'must be "error", "warning", or a map from scope to one of them' });
|
|
8499
|
+
return;
|
|
8500
|
+
}
|
|
8501
|
+
for (const [scope, severity] of Object.entries(value)) {
|
|
8502
|
+
if (!scopes.includes(scope)) {
|
|
8503
|
+
issues.push({ path: [...path, scope], message: `names scope "${scope}", which this rule's scopes do not cover` });
|
|
8504
|
+
}
|
|
8505
|
+
if (typeof severity !== "string" || !SEVERITIES.includes(severity)) {
|
|
8506
|
+
issues.push({
|
|
8507
|
+
path: [...path, scope],
|
|
8508
|
+
message: `unknown severity ${JSON.stringify(severity)} — use "error" or "warning"`
|
|
8509
|
+
});
|
|
8510
|
+
}
|
|
8511
|
+
}
|
|
8512
|
+
}
|
|
8513
|
+
function patternIssues(source, flags, path, issues) {
|
|
8514
|
+
if (typeof source !== "string" || source.length === 0) {
|
|
8515
|
+
issues.push({ path, message: "must be a non-empty regular expression" });
|
|
8516
|
+
return;
|
|
8517
|
+
}
|
|
8518
|
+
if (source.length > CONFIGURED_PATTERN_MAX_LENGTH) {
|
|
8519
|
+
issues.push({
|
|
8520
|
+
path,
|
|
8521
|
+
message: `is ${source.length} characters, over the ${CONFIGURED_PATTERN_MAX_LENGTH}-character limit for a configured pattern`
|
|
8522
|
+
});
|
|
8523
|
+
return;
|
|
8524
|
+
}
|
|
8525
|
+
try {
|
|
8526
|
+
new RegExp(source, flags);
|
|
8527
|
+
} catch (err) {
|
|
8528
|
+
issues.push({ path, message: `does not compile: ${err.message}` });
|
|
8529
|
+
return;
|
|
8530
|
+
}
|
|
8531
|
+
if (!safeRegex(source, { limit: Number.MAX_SAFE_INTEGER })) {
|
|
8532
|
+
issues.push({
|
|
8533
|
+
path,
|
|
8534
|
+
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."
|
|
8535
|
+
});
|
|
8536
|
+
}
|
|
8537
|
+
}
|
|
8538
|
+
function flagIssues(value, path, issues) {
|
|
8539
|
+
if (value === undefined)
|
|
8540
|
+
return "";
|
|
8541
|
+
if (typeof value !== "string") {
|
|
8542
|
+
issues.push({ path, message: 'must be a string of flags, e.g. "i"' });
|
|
8543
|
+
return "";
|
|
8544
|
+
}
|
|
8545
|
+
const seen = new Set;
|
|
8546
|
+
for (const flag of value) {
|
|
8547
|
+
if (!CONFIGURED_PROSE_FLAGS.includes(flag)) {
|
|
8548
|
+
issues.push({
|
|
8549
|
+
path,
|
|
8550
|
+
message: `unknown flag ${JSON.stringify(flag)} — only ${CONFIGURED_PROSE_FLAGS.map((f) => `"${f}"`).join(" and ")} are allowed`
|
|
8551
|
+
});
|
|
8552
|
+
return "";
|
|
8553
|
+
}
|
|
8554
|
+
if (seen.has(flag)) {
|
|
8555
|
+
issues.push({ path, message: `repeats the flag "${flag}"` });
|
|
8556
|
+
return "";
|
|
8557
|
+
}
|
|
8558
|
+
seen.add(flag);
|
|
8559
|
+
}
|
|
8560
|
+
return value;
|
|
8561
|
+
}
|
|
8562
|
+
function defaultsIssues(value, issues) {
|
|
8563
|
+
const base = ["defaults"];
|
|
8564
|
+
if (!isPlainObject3(value)) {
|
|
8565
|
+
issues.push({ path: base, message: 'must map a default rule id to "off" or an override' });
|
|
8566
|
+
return;
|
|
8567
|
+
}
|
|
8568
|
+
for (const [id, override] of Object.entries(value)) {
|
|
8569
|
+
const path = [...base, id];
|
|
8570
|
+
const rule = CONFIGURABLE_DEFAULT_RULES.find((candidate) => candidate.id === id);
|
|
8571
|
+
if (!rule) {
|
|
8572
|
+
issues.push({
|
|
8573
|
+
path,
|
|
8574
|
+
message: `unknown default rule id "${id}" — \`vinaya check --plan\` lists the rules each prose check runs`
|
|
8575
|
+
});
|
|
8576
|
+
continue;
|
|
8577
|
+
}
|
|
8578
|
+
if (override === "off")
|
|
8579
|
+
continue;
|
|
8580
|
+
if (!isPlainObject3(override)) {
|
|
8581
|
+
issues.push({ path, message: 'must be "off" or an object with any of scopes, severity, exempt' });
|
|
8582
|
+
continue;
|
|
8583
|
+
}
|
|
8584
|
+
for (const key of Object.keys(override)) {
|
|
8585
|
+
if (OVERRIDE_KEYS.includes(key))
|
|
8586
|
+
continue;
|
|
8587
|
+
issues.push({
|
|
8588
|
+
path: [...path, key],
|
|
8589
|
+
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`
|
|
8590
|
+
});
|
|
8591
|
+
}
|
|
8592
|
+
const scopes = override.scopes === undefined ? [...rule.scopes] : scopeListIssues(override.scopes, [...path, "scopes"], allowedScopesFor(rule), issues);
|
|
8593
|
+
if (override.severity !== undefined && scopes)
|
|
8594
|
+
severityIssues(override.severity, [...path, "severity"], scopes, issues);
|
|
8595
|
+
if (override.exempt !== undefined)
|
|
8596
|
+
pathListIssues(override.exempt, [...path, "exempt"], issues);
|
|
8597
|
+
}
|
|
8598
|
+
}
|
|
8599
|
+
function customIssues(value, issues) {
|
|
8600
|
+
if (!Array.isArray(value)) {
|
|
8601
|
+
issues.push({ path: ["custom"], message: "must be a list of rules" });
|
|
8602
|
+
return;
|
|
8603
|
+
}
|
|
8604
|
+
const ids = new Set;
|
|
8605
|
+
value.forEach((rule, index) => {
|
|
8606
|
+
const path = ["custom", index];
|
|
8607
|
+
if (!isPlainObject3(rule)) {
|
|
8608
|
+
issues.push({ path, message: "must be a rule object" });
|
|
8609
|
+
return;
|
|
8610
|
+
}
|
|
8611
|
+
for (const key of Object.keys(rule)) {
|
|
8612
|
+
if (!CUSTOM_KEYS.includes(key)) {
|
|
8613
|
+
issues.push({ path: [...path, key], message: `unknown key "${key}" — a rule takes ${CUSTOM_KEYS.join(", ")}` });
|
|
8614
|
+
}
|
|
8615
|
+
}
|
|
8616
|
+
if (typeof rule.id !== "string" || rule.id.length === 0) {
|
|
8617
|
+
issues.push({ path: [...path, "id"], message: "a custom rule needs an id" });
|
|
8618
|
+
} else if (DEFAULT_IDS.has(rule.id)) {
|
|
8619
|
+
issues.push({
|
|
8620
|
+
path: [...path, "id"],
|
|
8621
|
+
message: `"${rule.id}" is a default rule id — a custom rule needs its own id; retune the default under proseGates.rules.defaults instead`
|
|
8622
|
+
});
|
|
8623
|
+
} else if (ids.has(rule.id)) {
|
|
8624
|
+
issues.push({ path: [...path, "id"], message: `"${rule.id}" is used by an earlier custom rule` });
|
|
8625
|
+
} else {
|
|
8626
|
+
ids.add(rule.id);
|
|
8627
|
+
}
|
|
8628
|
+
if (typeof rule.means !== "string" || rule.means.trim().length === 0) {
|
|
8629
|
+
issues.push({ path: [...path, "means"], message: "a custom rule needs a message (`means`)" });
|
|
8630
|
+
}
|
|
8631
|
+
let scopes = null;
|
|
8632
|
+
if (rule.scopes === undefined) {
|
|
8633
|
+
issues.push({ path: [...path, "scopes"], message: "a custom rule needs at least one scope (`scopes`)" });
|
|
8634
|
+
} else {
|
|
8635
|
+
scopes = scopeListIssues(rule.scopes, [...path, "scopes"], CONFIGURABLE_PROSE_SCOPES, issues);
|
|
8636
|
+
}
|
|
8637
|
+
if (scopes && new Set(scopes.map(groupOfScope)).size > 1) {
|
|
8638
|
+
issues.push({
|
|
8639
|
+
path: [...path, "scopes"],
|
|
8640
|
+
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'
|
|
8641
|
+
});
|
|
8642
|
+
}
|
|
8643
|
+
const flags = flagIssues(rule.flags, [...path, "flags"], issues);
|
|
8644
|
+
if (rule.pattern === undefined && rule.patterns === undefined) {
|
|
8645
|
+
issues.push({
|
|
8646
|
+
path: [...path, "pattern"],
|
|
8647
|
+
message: "a custom rule needs a `pattern` or a per-scope `patterns` map"
|
|
8648
|
+
});
|
|
8649
|
+
}
|
|
8650
|
+
if (rule.pattern !== undefined)
|
|
8651
|
+
patternIssues(rule.pattern, flags, [...path, "pattern"], issues);
|
|
8652
|
+
if (rule.patterns !== undefined) {
|
|
8653
|
+
if (!isPlainObject3(rule.patterns)) {
|
|
8654
|
+
issues.push({ path: [...path, "patterns"], message: "must map a scope to a regular expression" });
|
|
8655
|
+
} else {
|
|
8656
|
+
for (const [scope, source] of Object.entries(rule.patterns)) {
|
|
8657
|
+
if (scopes && !scopes.includes(scope)) {
|
|
8658
|
+
issues.push({
|
|
8659
|
+
path: [...path, "patterns", scope],
|
|
8660
|
+
message: `names scope "${scope}", which this rule's scopes do not cover`
|
|
8661
|
+
});
|
|
8662
|
+
continue;
|
|
8663
|
+
}
|
|
8664
|
+
patternIssues(source, flags, [...path, "patterns", scope], issues);
|
|
8665
|
+
}
|
|
8666
|
+
if (rule.pattern === undefined && scopes) {
|
|
8667
|
+
for (const scope of scopes) {
|
|
8668
|
+
if (!(scope in rule.patterns)) {
|
|
8669
|
+
issues.push({
|
|
8670
|
+
path: [...path, "patterns"],
|
|
8671
|
+
message: `has no pattern for scope "${scope}" — add one, or a \`pattern\` every other scope uses`
|
|
8672
|
+
});
|
|
8673
|
+
}
|
|
8674
|
+
}
|
|
8675
|
+
}
|
|
8676
|
+
}
|
|
8677
|
+
}
|
|
8678
|
+
if (rule.severity !== undefined && scopes)
|
|
8679
|
+
severityIssues(rule.severity, [...path, "severity"], scopes, issues);
|
|
8680
|
+
if (rule.exempt !== undefined)
|
|
8681
|
+
pathListIssues(rule.exempt, [...path, "exempt"], issues);
|
|
8682
|
+
});
|
|
8683
|
+
}
|
|
8684
|
+
function proseRulesIssues(value) {
|
|
8685
|
+
const issues = [];
|
|
8686
|
+
if (!isPlainObject3(value))
|
|
8687
|
+
return [{ path: [], message: "must be an object with any of exempt, defaults, custom" }];
|
|
8688
|
+
for (const key of Object.keys(value)) {
|
|
8689
|
+
if (!["exempt", "defaults", "custom"].includes(key)) {
|
|
8690
|
+
issues.push({ path: [key], message: `unknown key "${key}" — proseGates.rules takes exempt, defaults and custom` });
|
|
8691
|
+
}
|
|
8692
|
+
}
|
|
8693
|
+
if (value.exempt !== undefined)
|
|
8694
|
+
pathListIssues(value.exempt, ["exempt"], issues);
|
|
8695
|
+
if (value.defaults !== undefined)
|
|
8696
|
+
defaultsIssues(value.defaults, issues);
|
|
8697
|
+
if (value.custom !== undefined)
|
|
8698
|
+
customIssues(value.custom, issues);
|
|
8699
|
+
return issues;
|
|
8700
|
+
}
|
|
8701
|
+
var ProseRulesSchema = z5.unknown().superRefine((value, ctx) => {
|
|
8702
|
+
for (const issue of proseRulesIssues(value)) {
|
|
8703
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: issue.path, message: issue.message });
|
|
8704
|
+
}
|
|
8705
|
+
}).transform((value) => value);
|
|
8706
|
+
var PublishedProseSchema = z5.object({
|
|
8707
|
+
allow: z5.array(z5.string().min(1)).optional()
|
|
8708
|
+
}).strict();
|
|
8709
|
+
|
|
7463
8710
|
// src/lib/config.ts
|
|
7464
|
-
var EnvEntrySchema =
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
8711
|
+
var EnvEntrySchema = z6.union([
|
|
8712
|
+
z6.literal(true),
|
|
8713
|
+
z6.object({ optional: z6.literal(true) }),
|
|
8714
|
+
z6.object({ anyOf: z6.array(z6.string()).min(2) }),
|
|
8715
|
+
z6.string()
|
|
7469
8716
|
]);
|
|
7470
|
-
var CheckEntrySchema =
|
|
7471
|
-
run:
|
|
7472
|
-
scope:
|
|
7473
|
-
include:
|
|
7474
|
-
args:
|
|
7475
|
-
timeoutMs:
|
|
7476
|
-
env:
|
|
7477
|
-
requiresOpenPr:
|
|
7478
|
-
ownWorkflow:
|
|
7479
|
-
principalOwed:
|
|
7480
|
-
validates:
|
|
8717
|
+
var CheckEntrySchema = z6.object({
|
|
8718
|
+
run: z6.string(),
|
|
8719
|
+
scope: z6.enum(["diff", "full"]),
|
|
8720
|
+
include: z6.array(z6.string()).optional(),
|
|
8721
|
+
args: z6.array(z6.string()).optional(),
|
|
8722
|
+
timeoutMs: z6.number().optional(),
|
|
8723
|
+
env: z6.record(z6.string(), EnvEntrySchema).optional(),
|
|
8724
|
+
requiresOpenPr: z6.boolean().optional(),
|
|
8725
|
+
ownWorkflow: z6.boolean().optional(),
|
|
8726
|
+
principalOwed: z6.literal(true).optional(),
|
|
8727
|
+
validates: z6.enum(["body", "issue"]).optional(),
|
|
8728
|
+
advisory: z6.literal(true).optional()
|
|
7481
8729
|
}).superRefine((entry, ctx) => {
|
|
7482
8730
|
if (!entry.env)
|
|
7483
8731
|
return;
|
|
@@ -7487,22 +8735,22 @@ var CheckEntrySchema = z5.object({
|
|
|
7487
8735
|
const members = value.anyOf;
|
|
7488
8736
|
if (new Set(members).size !== members.length) {
|
|
7489
8737
|
ctx.addIssue({
|
|
7490
|
-
code:
|
|
8738
|
+
code: z6.ZodIssueCode.custom,
|
|
7491
8739
|
message: `env.${key}.anyOf has duplicate members`,
|
|
7492
8740
|
path: ["env", key, "anyOf"]
|
|
7493
8741
|
});
|
|
7494
8742
|
}
|
|
7495
8743
|
if (!members.includes(key)) {
|
|
7496
8744
|
ctx.addIssue({
|
|
7497
|
-
code:
|
|
8745
|
+
code: z6.ZodIssueCode.custom,
|
|
7498
8746
|
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
7499
8747
|
path: ["env", key, "anyOf"]
|
|
7500
8748
|
});
|
|
7501
8749
|
}
|
|
7502
8750
|
}
|
|
7503
8751
|
});
|
|
7504
|
-
var RoleEntrySchema =
|
|
7505
|
-
contract:
|
|
8752
|
+
var RoleEntrySchema = z6.object({
|
|
8753
|
+
contract: z6.string().refine((p) => p.includes("/"), {
|
|
7506
8754
|
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
7507
8755
|
})
|
|
7508
8756
|
});
|
|
@@ -7526,17 +8774,17 @@ var BRIEF_BUILTINS = [
|
|
|
7526
8774
|
"briefSections",
|
|
7527
8775
|
"milestoneShape"
|
|
7528
8776
|
];
|
|
7529
|
-
var BriefSectionSchema =
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
8777
|
+
var BriefSectionSchema = z6.union([
|
|
8778
|
+
z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
|
|
8779
|
+
z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
|
|
8780
|
+
z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
|
|
8781
|
+
z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
|
|
7534
8782
|
]);
|
|
7535
|
-
var BriefSchemaSchema =
|
|
7536
|
-
pr:
|
|
7537
|
-
issue:
|
|
7538
|
-
milestone:
|
|
7539
|
-
ack:
|
|
8783
|
+
var BriefSchemaSchema = z6.object({
|
|
8784
|
+
pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8785
|
+
issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8786
|
+
milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8787
|
+
ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
|
|
7540
8788
|
});
|
|
7541
8789
|
function isSafeRepoRelPath(p) {
|
|
7542
8790
|
if (p.length === 0)
|
|
@@ -7545,7 +8793,7 @@ function isSafeRepoRelPath(p) {
|
|
|
7545
8793
|
return false;
|
|
7546
8794
|
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
7547
8795
|
}
|
|
7548
|
-
var SafeRepoRelPath =
|
|
8796
|
+
var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
|
|
7549
8797
|
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
7550
8798
|
});
|
|
7551
8799
|
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
@@ -7555,22 +8803,22 @@ function isCanonicalHookBlockPath(p) {
|
|
|
7555
8803
|
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
7556
8804
|
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
7557
8805
|
});
|
|
7558
|
-
var ManagedBlockRecordSchema =
|
|
8806
|
+
var ManagedBlockRecordSchema = z6.object({
|
|
7559
8807
|
path: ManagedHookBlockPath,
|
|
7560
|
-
marker:
|
|
7561
|
-
comment:
|
|
8808
|
+
marker: z6.string(),
|
|
8809
|
+
comment: z6.enum(["hash", "html"])
|
|
7562
8810
|
});
|
|
7563
|
-
var ManagedManifestSchema =
|
|
7564
|
-
version:
|
|
7565
|
-
files:
|
|
7566
|
-
blocks:
|
|
7567
|
-
labels:
|
|
7568
|
-
agents:
|
|
8811
|
+
var ManagedManifestSchema = z6.object({
|
|
8812
|
+
version: z6.number().int().positive(),
|
|
8813
|
+
files: z6.array(SafeRepoRelPath),
|
|
8814
|
+
blocks: z6.array(ManagedBlockRecordSchema),
|
|
8815
|
+
labels: z6.array(z6.string()),
|
|
8816
|
+
agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
|
|
7569
8817
|
});
|
|
7570
|
-
var ProjectEntrySchema =
|
|
7571
|
-
name:
|
|
7572
|
-
description:
|
|
7573
|
-
path:
|
|
8818
|
+
var ProjectEntrySchema = z6.object({
|
|
8819
|
+
name: z6.string().min(1),
|
|
8820
|
+
description: z6.string().min(1).optional(),
|
|
8821
|
+
path: z6.string().min(1).optional()
|
|
7574
8822
|
});
|
|
7575
8823
|
function parseTokensCollectDeclaration(value) {
|
|
7576
8824
|
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
@@ -7581,90 +8829,90 @@ function parseTokensCollectDeclaration(value) {
|
|
|
7581
8829
|
return null;
|
|
7582
8830
|
return { interpreter, script };
|
|
7583
8831
|
}
|
|
7584
|
-
var
|
|
7585
|
-
rings:
|
|
7586
|
-
ring1_forgeWriteInterception:
|
|
7587
|
-
ring2_asyncAudits:
|
|
8832
|
+
var VinayaConfigObjectSchema = z6.object({
|
|
8833
|
+
rings: z6.object({
|
|
8834
|
+
ring1_forgeWriteInterception: z6.boolean(),
|
|
8835
|
+
ring2_asyncAudits: z6.boolean()
|
|
7588
8836
|
}).optional(),
|
|
7589
|
-
checks:
|
|
7590
|
-
roles:
|
|
8837
|
+
checks: z6.record(z6.string(), CheckEntrySchema).optional(),
|
|
8838
|
+
roles: z6.record(z6.string(), RoleEntrySchema).optional(),
|
|
7591
8839
|
briefSchema: BriefSchemaSchema.optional(),
|
|
7592
8840
|
managed: ManagedManifestSchema.optional(),
|
|
7593
|
-
principals:
|
|
7594
|
-
releaseActor:
|
|
7595
|
-
ci:
|
|
7596
|
-
tokens:
|
|
7597
|
-
collect:
|
|
8841
|
+
principals: z6.array(z6.string()).min(1).optional(),
|
|
8842
|
+
releaseActor: z6.string().min(1).optional(),
|
|
8843
|
+
ci: z6.object({ setup: z6.string().min(1) }).optional(),
|
|
8844
|
+
tokens: z6.object({
|
|
8845
|
+
collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
7598
8846
|
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
7599
8847
|
})
|
|
7600
8848
|
}).optional(),
|
|
7601
|
-
blastRadius:
|
|
7602
|
-
proseGates:
|
|
7603
|
-
doctrineRoot:
|
|
7604
|
-
readerFacingPrefix:
|
|
7605
|
-
readerFacingSuffix:
|
|
7606
|
-
legacySlugDir:
|
|
7607
|
-
sourceComments:
|
|
7608
|
-
globs:
|
|
7609
|
-
allowlist:
|
|
7610
|
-
severity:
|
|
8849
|
+
blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
|
|
8850
|
+
proseGates: z6.object({
|
|
8851
|
+
doctrineRoot: z6.string().min(1).optional(),
|
|
8852
|
+
readerFacingPrefix: z6.string().min(1).optional(),
|
|
8853
|
+
readerFacingSuffix: z6.string().min(1).optional(),
|
|
8854
|
+
legacySlugDir: z6.string().min(1).optional(),
|
|
8855
|
+
sourceComments: z6.object({
|
|
8856
|
+
globs: z6.array(z6.string().min(1)).optional(),
|
|
8857
|
+
allowlist: z6.array(z6.string().min(1)).optional(),
|
|
8858
|
+
severity: z6.enum(["warning", "error"]).optional()
|
|
7611
8859
|
}).optional(),
|
|
7612
|
-
specGrandfather:
|
|
7613
|
-
specPaths:
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
})).optional()
|
|
8860
|
+
specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
|
|
8861
|
+
specPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8862
|
+
productPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8863
|
+
published: PublishedProseSchema.optional(),
|
|
8864
|
+
rules: ProseRulesSchema.optional()
|
|
7618
8865
|
}).optional(),
|
|
7619
|
-
projects:
|
|
7620
|
-
dispatch:
|
|
7621
|
-
timeoutMs:
|
|
7622
|
-
|
|
7623
|
-
|
|
8866
|
+
projects: z6.array(ProjectEntrySchema).optional(),
|
|
8867
|
+
dispatch: z6.object({
|
|
8868
|
+
timeoutMs: z6.number().int().positive().optional(),
|
|
8869
|
+
reviewerTimeoutMs: z6.number().int().positive().optional(),
|
|
8870
|
+
killGraceMs: z6.number().int().positive().optional(),
|
|
8871
|
+
agent: z6.enum(["claude", "codex"]).optional()
|
|
7624
8872
|
}).optional(),
|
|
7625
|
-
reviewPolicy:
|
|
7626
|
-
codeReviewThreshold:
|
|
7627
|
-
securityThreshold:
|
|
7628
|
-
maxRounds:
|
|
7629
|
-
maxTaskMinutes:
|
|
8873
|
+
reviewPolicy: z6.object({
|
|
8874
|
+
codeReviewThreshold: z6.string().min(1).optional(),
|
|
8875
|
+
securityThreshold: z6.string().min(1).optional(),
|
|
8876
|
+
maxRounds: z6.number().optional(),
|
|
8877
|
+
maxTaskMinutes: z6.number().optional()
|
|
7630
8878
|
}).optional(),
|
|
7631
|
-
securityScan:
|
|
7632
|
-
command:
|
|
8879
|
+
securityScan: z6.object({
|
|
8880
|
+
command: z6.array(z6.string().min(1)).min(1)
|
|
7633
8881
|
}).optional(),
|
|
7634
|
-
gateCutovers:
|
|
7635
|
-
objectivesSinceIssue:
|
|
7636
|
-
briefSectionsSinceIssue:
|
|
7637
|
-
documentationSinceIssue:
|
|
7638
|
-
briefRulesSincePr:
|
|
7639
|
-
agentBoxesRefusedSincePr:
|
|
8882
|
+
gateCutovers: z6.object({
|
|
8883
|
+
objectivesSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8884
|
+
briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8885
|
+
documentationSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8886
|
+
briefRulesSincePr: z6.number().int().nonnegative().optional(),
|
|
8887
|
+
agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
|
|
7640
8888
|
}).optional(),
|
|
7641
|
-
planning:
|
|
7642
|
-
collisionThreshold:
|
|
8889
|
+
planning: z6.object({
|
|
8890
|
+
collisionThreshold: z6.number().int().nonnegative().optional()
|
|
7643
8891
|
}).optional(),
|
|
7644
|
-
prePush:
|
|
7645
|
-
alwaysRun:
|
|
8892
|
+
prePush: z6.object({
|
|
8893
|
+
alwaysRun: z6.array(z6.string()).optional()
|
|
7646
8894
|
}).optional(),
|
|
7647
|
-
report:
|
|
7648
|
-
commandTimeoutMs:
|
|
8895
|
+
report: z6.object({
|
|
8896
|
+
commandTimeoutMs: z6.number().int().positive().optional()
|
|
7649
8897
|
}).superRefine((report, ctx) => {
|
|
7650
8898
|
const commandTimeoutMs = report.commandTimeoutMs;
|
|
7651
8899
|
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
7652
8900
|
ctx.addIssue({
|
|
7653
|
-
code:
|
|
8901
|
+
code: z6.ZodIssueCode.custom,
|
|
7654
8902
|
path: ["commandTimeoutMs"],
|
|
7655
8903
|
message: "must be at most 3600000 (1 hour)"
|
|
7656
8904
|
});
|
|
7657
8905
|
}
|
|
7658
8906
|
}).optional(),
|
|
7659
|
-
logPublish:
|
|
8907
|
+
logPublish: z6.unknown().refine((v) => v === undefined, {
|
|
7660
8908
|
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
7661
8909
|
}),
|
|
7662
|
-
runtimeDir:
|
|
7663
|
-
logs:
|
|
7664
|
-
folder:
|
|
7665
|
-
url:
|
|
7666
|
-
headers:
|
|
7667
|
-
readHeaders:
|
|
8910
|
+
runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
8911
|
+
logs: z6.object({
|
|
8912
|
+
folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
8913
|
+
url: z6.string().url().optional(),
|
|
8914
|
+
headers: z6.record(z6.string()).optional(),
|
|
8915
|
+
readHeaders: z6.record(z6.string()).optional(),
|
|
7668
8916
|
events: CustomEventDeclarationsSchema.optional()
|
|
7669
8917
|
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
7670
8918
|
message: "logs: set at most one of folder/url"
|
|
@@ -7672,8 +8920,33 @@ var VinayaConfigSchema = z5.object({
|
|
|
7672
8920
|
message: "logs: headers requires url"
|
|
7673
8921
|
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
7674
8922
|
message: "logs: readHeaders requires url"
|
|
7675
|
-
}).optional()
|
|
8923
|
+
}).optional(),
|
|
8924
|
+
decisionRecords: z6.object({
|
|
8925
|
+
path: RepoRelativePathSchema
|
|
8926
|
+
}).strict().optional()
|
|
8927
|
+
});
|
|
8928
|
+
function decisionRecordsPathIssue(path, doctrineRoot) {
|
|
8929
|
+
const reason = outsideRepositoryReason(path);
|
|
8930
|
+
if (reason)
|
|
8931
|
+
return reason;
|
|
8932
|
+
const folder = normalizeSpecPath(path);
|
|
8933
|
+
if (folder === "" || folder === ".")
|
|
8934
|
+
return "must name a folder, not the repository root";
|
|
8935
|
+
const root = normalizeSpecPath(doctrineRoot ?? "aeg-root");
|
|
8936
|
+
if (folder === root || folder.startsWith(`${root}/`)) {
|
|
8937
|
+
return `must be outside the doctrine tree "${root}" — decision records belong to this repository, not to the doctrine it ships`;
|
|
8938
|
+
}
|
|
8939
|
+
return null;
|
|
8940
|
+
}
|
|
8941
|
+
var VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
|
|
8942
|
+
const path = config.decisionRecords?.path;
|
|
8943
|
+
if (path === undefined || outsideRepositoryReason(path))
|
|
8944
|
+
return;
|
|
8945
|
+
const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
|
|
8946
|
+
if (issue)
|
|
8947
|
+
ctx.addIssue({ code: z6.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
|
|
7676
8948
|
});
|
|
8949
|
+
var VinayaConfigShape = VinayaConfigObjectSchema.shape;
|
|
7677
8950
|
var GLOBAL_VINAYA_HOME = join3(homedir(), ".vinaya");
|
|
7678
8951
|
var GLOBAL_CONFIG_PATH = join3(GLOBAL_VINAYA_HOME, "config.json");
|
|
7679
8952
|
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
@@ -7754,9 +9027,6 @@ function stripGlobalOnlyKeys(config, path) {
|
|
|
7754
9027
|
}
|
|
7755
9028
|
return result;
|
|
7756
9029
|
}
|
|
7757
|
-
function resolvePrincipalAllowlist(config) {
|
|
7758
|
-
return config?.principals ?? PRINCIPAL_ALLOWLIST;
|
|
7759
|
-
}
|
|
7760
9030
|
function resolveReleaseActor(config) {
|
|
7761
9031
|
return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
|
|
7762
9032
|
}
|
|
@@ -7892,13 +9162,14 @@ function readTrustAnchorConfigAtRef(ref) {
|
|
|
7892
9162
|
});
|
|
7893
9163
|
return Buffer.from(raw, "utf-8").toString("base64");
|
|
7894
9164
|
}
|
|
9165
|
+
var NO_TRUST_ANCHOR_REPO_MESSAGE = "could not resolve repo identity for the trust-anchor read";
|
|
7895
9166
|
function ghFetchTrustAnchorConfig() {
|
|
7896
9167
|
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
7897
9168
|
if (probeRef)
|
|
7898
9169
|
return readTrustAnchorConfigAtRef(probeRef);
|
|
7899
9170
|
const repo = trustAnchorRepo();
|
|
7900
9171
|
if (!repo)
|
|
7901
|
-
throw new Error(
|
|
9172
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7902
9173
|
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
7903
9174
|
encoding: "utf-8",
|
|
7904
9175
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -7915,7 +9186,7 @@ async function ghFetchTrustAnchorConfigAsync() {
|
|
|
7915
9186
|
}
|
|
7916
9187
|
const repo = await trustAnchorRepoAsync();
|
|
7917
9188
|
if (!repo)
|
|
7918
|
-
throw new Error(
|
|
9189
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7919
9190
|
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
7920
9191
|
return stdout;
|
|
7921
9192
|
}
|
|
@@ -7941,6 +9212,47 @@ function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
|
7941
9212
|
}
|
|
7942
9213
|
return parseTrustAnchorContent(base64);
|
|
7943
9214
|
}
|
|
9215
|
+
class PrincipalsUnresolvedError extends Error {
|
|
9216
|
+
kind;
|
|
9217
|
+
constructor(kind, message) {
|
|
9218
|
+
super(message);
|
|
9219
|
+
this.name = "PrincipalsUnresolvedError";
|
|
9220
|
+
this.kind = kind;
|
|
9221
|
+
}
|
|
9222
|
+
}
|
|
9223
|
+
var PRINCIPALS_FIX = 'add "principals": [...] to vinaya.config.json on the default branch';
|
|
9224
|
+
function fetchFailureReason(err) {
|
|
9225
|
+
const stderr = err?.stderr;
|
|
9226
|
+
const text = (typeof stderr === "string" ? stderr : stderr?.toString() ?? "").trim();
|
|
9227
|
+
return text.split(`
|
|
9228
|
+
`)[0]?.trim() || firstLine(err);
|
|
9229
|
+
}
|
|
9230
|
+
function principalsNotConfigured(why) {
|
|
9231
|
+
return new PrincipalsUnresolvedError("not-configured", `no Principal is configured (${why}) — ${PRINCIPALS_FIX}.`);
|
|
9232
|
+
}
|
|
9233
|
+
function resolveTrustedPrincipals(fetcher = ghFetchTrustAnchorConfig) {
|
|
9234
|
+
let content;
|
|
9235
|
+
try {
|
|
9236
|
+
content = fetcher();
|
|
9237
|
+
} catch (err) {
|
|
9238
|
+
if (err?.message === NO_TRUST_ANCHOR_REPO_MESSAGE) {
|
|
9239
|
+
throw principalsNotConfigured("no repository resolves for the read");
|
|
9240
|
+
}
|
|
9241
|
+
if (isMissingFileError(err))
|
|
9242
|
+
throw principalsNotConfigured("the default branch has no vinaya.config.json");
|
|
9243
|
+
throw new PrincipalsUnresolvedError("read-failed", `could not read "principals" from vinaya.config.json on the default branch: ${fetchFailureReason(err)}`);
|
|
9244
|
+
}
|
|
9245
|
+
const unusable = { why: "" };
|
|
9246
|
+
const config = parseTrustAnchorContent(content, (why) => {
|
|
9247
|
+
unusable.why = why;
|
|
9248
|
+
});
|
|
9249
|
+
if (config === null) {
|
|
9250
|
+
throw principalsNotConfigured(`vinaya.config.json on the default branch ${unusable.why ? `is unusable: ${unusable.why}` : "is empty"}`);
|
|
9251
|
+
}
|
|
9252
|
+
if (!config.principals)
|
|
9253
|
+
throw principalsNotConfigured('vinaya.config.json on the default branch sets no "principals"');
|
|
9254
|
+
return config.principals;
|
|
9255
|
+
}
|
|
7944
9256
|
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
7945
9257
|
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
7946
9258
|
let base64;
|
|
@@ -7980,12 +9292,67 @@ function loadConfig() {
|
|
|
7980
9292
|
const path = configPath();
|
|
7981
9293
|
if (!path)
|
|
7982
9294
|
return null;
|
|
9295
|
+
let text;
|
|
7983
9296
|
try {
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
9297
|
+
text = readFileSync2(path, "utf-8");
|
|
9298
|
+
} catch (err) {
|
|
9299
|
+
reportInvalidConfigOnce(path, `unreadable: ${err.message}`);
|
|
9300
|
+
return null;
|
|
9301
|
+
}
|
|
9302
|
+
let raw;
|
|
9303
|
+
try {
|
|
9304
|
+
raw = JSON.parse(text);
|
|
9305
|
+
} catch (err) {
|
|
9306
|
+
reportInvalidConfigOnce(path, `invalid JSON: ${err.message}`);
|
|
9307
|
+
return null;
|
|
9308
|
+
}
|
|
9309
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
9310
|
+
if (!parsed.success) {
|
|
9311
|
+
reportInvalidConfigOnce(path, schemaIssueDetail(parsed.error));
|
|
7987
9312
|
return null;
|
|
7988
9313
|
}
|
|
9314
|
+
return stripGlobalOnlyKeys(parsed.data, path);
|
|
9315
|
+
}
|
|
9316
|
+
function schemaIssueDetail(error) {
|
|
9317
|
+
return error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
|
|
9318
|
+
}
|
|
9319
|
+
var emittedInvalidConfigReports = new Set;
|
|
9320
|
+
function reportInvalidConfigOnce(path, detail) {
|
|
9321
|
+
const key = `${path}
|
|
9322
|
+
${detail}`;
|
|
9323
|
+
if (emittedInvalidConfigReports.has(key))
|
|
9324
|
+
return;
|
|
9325
|
+
emittedInvalidConfigReports.add(key);
|
|
9326
|
+
const message = `${path} is not a valid Vinaya configuration (${detail}) — falling back to built-in defaults.`;
|
|
9327
|
+
const checkName = process.env.VINAYA_CHECK_NAME;
|
|
9328
|
+
if (checkName) {
|
|
9329
|
+
emitCheckError({
|
|
9330
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
9331
|
+
check: checkName,
|
|
9332
|
+
severity: "warning",
|
|
9333
|
+
message,
|
|
9334
|
+
agent_recovery_prompt: `Fix the failing keys in ${path} (${detail}) so the file parses and satisfies the configuration schema, then re-run.`,
|
|
9335
|
+
file: path
|
|
9336
|
+
});
|
|
9337
|
+
return;
|
|
9338
|
+
}
|
|
9339
|
+
console.error(`⚠ ${message}`);
|
|
9340
|
+
}
|
|
9341
|
+
function loadConfigChecked() {
|
|
9342
|
+
const path = configPath();
|
|
9343
|
+
if (!path)
|
|
9344
|
+
return { ok: true, config: null };
|
|
9345
|
+
let raw;
|
|
9346
|
+
try {
|
|
9347
|
+
raw = JSON.parse(readFileSync2(path, "utf-8"));
|
|
9348
|
+
} catch (err) {
|
|
9349
|
+
return { ok: false, path, error: `invalid JSON: ${err.message}` };
|
|
9350
|
+
}
|
|
9351
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
9352
|
+
if (!parsed.success) {
|
|
9353
|
+
return { ok: false, path, error: schemaIssueDetail(parsed.error) };
|
|
9354
|
+
}
|
|
9355
|
+
return { ok: true, config: stripGlobalOnlyKeys(parsed.data, path) };
|
|
7989
9356
|
}
|
|
7990
9357
|
var TOKENS_COLLECT_TRUST_PATH = join3(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
7991
9358
|
|
|
@@ -9132,6 +10499,8 @@ function createLogSink(overrides = {}) {
|
|
|
9132
10499
|
branchIssue,
|
|
9133
10500
|
eventId: randomUUID2(),
|
|
9134
10501
|
processId,
|
|
10502
|
+
revision: headSha,
|
|
10503
|
+
provenance: deps.provenance,
|
|
9135
10504
|
inputVersions: deps.inputVersions()
|
|
9136
10505
|
});
|
|
9137
10506
|
const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
|
|
@@ -9222,13 +10591,6 @@ function createLogSink(overrides = {}) {
|
|
|
9222
10591
|
}
|
|
9223
10592
|
var defaultSink = createLogSink();
|
|
9224
10593
|
|
|
9225
|
-
// src/checks/contract.ts
|
|
9226
|
-
var CHECK_SCHEMA_VERSION = 1;
|
|
9227
|
-
function emitCheckError(error) {
|
|
9228
|
-
process.stderr.write(`${JSON.stringify(error)}
|
|
9229
|
-
`);
|
|
9230
|
-
}
|
|
9231
|
-
|
|
9232
10594
|
// src/checks/runner.ts
|
|
9233
10595
|
var activeChecks = new Map;
|
|
9234
10596
|
|
|
@@ -9309,6 +10671,117 @@ function summaryLineIndex(maskedRegion) {
|
|
|
9309
10671
|
|
|
9310
10672
|
// src/lib/forge-read.ts
|
|
9311
10673
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
10674
|
+
|
|
10675
|
+
// src/lib/forge-snapshot.ts
|
|
10676
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
10677
|
+
import { join as join7 } from "node:path";
|
|
10678
|
+
var FORGE_SNAPSHOT_DIR_ENV = "VINAYA_FORGE_SNAPSHOT_DIR";
|
|
10679
|
+
var PULL_FILE = "pull.json";
|
|
10680
|
+
var PULL_COMMENTS_FILE = "pull-comments.json";
|
|
10681
|
+
var ISSUE_FILE = "issue.json";
|
|
10682
|
+
var ISSUE_COMMENTS_FILE = "issue-comments.json";
|
|
10683
|
+
function forgeSnapshotDir(env = process.env) {
|
|
10684
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
10685
|
+
return null;
|
|
10686
|
+
const dir = env[FORGE_SNAPSHOT_DIR_ENV];
|
|
10687
|
+
return dir ? dir : null;
|
|
10688
|
+
}
|
|
10689
|
+
|
|
10690
|
+
class ForgeSnapshotIncompleteError extends Error {
|
|
10691
|
+
constructor(dir, file) {
|
|
10692
|
+
super(`the forge snapshot ${dir} has no ${file} — the pull request read that writes it did not complete, so this check refuses to read the forge in its place.`);
|
|
10693
|
+
this.name = "ForgeSnapshotIncompleteError";
|
|
10694
|
+
}
|
|
10695
|
+
}
|
|
10696
|
+
|
|
10697
|
+
class ForgeSnapshotIssueNotFoundError extends Error {
|
|
10698
|
+
constructor(issue) {
|
|
10699
|
+
super(`Issue #${issue} did not resolve (HTTP 404) when this run's forge snapshot was read.`);
|
|
10700
|
+
this.name = "ForgeSnapshotIssueNotFoundError";
|
|
10701
|
+
}
|
|
10702
|
+
}
|
|
10703
|
+
function readSnapshotFile(dir, file) {
|
|
10704
|
+
let text;
|
|
10705
|
+
try {
|
|
10706
|
+
text = readFileSync6(join7(dir, file), "utf8");
|
|
10707
|
+
} catch {
|
|
10708
|
+
throw new ForgeSnapshotIncompleteError(dir, file);
|
|
10709
|
+
}
|
|
10710
|
+
return JSON.parse(text);
|
|
10711
|
+
}
|
|
10712
|
+
function readComments(dir, file, number) {
|
|
10713
|
+
const parsed = readSnapshotFile(dir, file);
|
|
10714
|
+
if (parsed.number !== number)
|
|
10715
|
+
throw new ForgeSnapshotIncompleteError(dir, `${file} for #${number}`);
|
|
10716
|
+
return parsed.comments;
|
|
10717
|
+
}
|
|
10718
|
+
function snapshotPullRequest(number, env = process.env) {
|
|
10719
|
+
const dir = forgeSnapshotDir(env);
|
|
10720
|
+
if (dir === null)
|
|
10721
|
+
return null;
|
|
10722
|
+
const pull = readSnapshotFile(dir, PULL_FILE);
|
|
10723
|
+
return pull.number === number ? pull : null;
|
|
10724
|
+
}
|
|
10725
|
+
function snapshotIssue(number, env = process.env) {
|
|
10726
|
+
const dir = forgeSnapshotDir(env);
|
|
10727
|
+
if (dir === null)
|
|
10728
|
+
return null;
|
|
10729
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
10730
|
+
if (issue.number !== number)
|
|
10731
|
+
return null;
|
|
10732
|
+
if ("notFound" in issue)
|
|
10733
|
+
throw new ForgeSnapshotIssueNotFoundError(number);
|
|
10734
|
+
return issue;
|
|
10735
|
+
}
|
|
10736
|
+
function snapshotComments(number, env = process.env) {
|
|
10737
|
+
const dir = forgeSnapshotDir(env);
|
|
10738
|
+
if (dir === null)
|
|
10739
|
+
return null;
|
|
10740
|
+
if (snapshotPullRequest(number, env) !== null)
|
|
10741
|
+
return readComments(dir, PULL_COMMENTS_FILE, number);
|
|
10742
|
+
if (snapshotIssue(number, env) !== null)
|
|
10743
|
+
return readComments(dir, ISSUE_COMMENTS_FILE, number);
|
|
10744
|
+
return null;
|
|
10745
|
+
}
|
|
10746
|
+
function snapshotBody(number, env = process.env) {
|
|
10747
|
+
const pull = snapshotPullRequest(number, env);
|
|
10748
|
+
if (pull !== null)
|
|
10749
|
+
return pull.body;
|
|
10750
|
+
return snapshotIssue(number, env)?.body ?? null;
|
|
10751
|
+
}
|
|
10752
|
+
function incompleteForgeSnapshot(env = process.env) {
|
|
10753
|
+
const dir = forgeSnapshotDir(env);
|
|
10754
|
+
if (dir === null)
|
|
10755
|
+
return null;
|
|
10756
|
+
for (const file of [PULL_FILE, PULL_COMMENTS_FILE, ISSUE_FILE]) {
|
|
10757
|
+
if (!existsSync6(join7(dir, file)))
|
|
10758
|
+
return new ForgeSnapshotIncompleteError(dir, file).message;
|
|
10759
|
+
}
|
|
10760
|
+
try {
|
|
10761
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
10762
|
+
if (typeof issue.number === "number" && !("notFound" in issue) && !existsSync6(join7(dir, ISSUE_COMMENTS_FILE))) {
|
|
10763
|
+
return new ForgeSnapshotIncompleteError(dir, ISSUE_COMMENTS_FILE).message;
|
|
10764
|
+
}
|
|
10765
|
+
} catch (err) {
|
|
10766
|
+
return `the forge snapshot ${dir} has an unreadable ${ISSUE_FILE}: ${err.message}`;
|
|
10767
|
+
}
|
|
10768
|
+
return null;
|
|
10769
|
+
}
|
|
10770
|
+
function exitOnIncompleteForgeSnapshot(checkName, env = process.env) {
|
|
10771
|
+
const reason = incompleteForgeSnapshot(env);
|
|
10772
|
+
if (reason === null)
|
|
10773
|
+
return;
|
|
10774
|
+
emitCheckError({
|
|
10775
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
10776
|
+
check: checkName,
|
|
10777
|
+
severity: "error",
|
|
10778
|
+
message: `${checkName}: ${reason}`,
|
|
10779
|
+
agent_recovery_prompt: `Re-run the whole workflow run so its pull request read step writes the snapshot again (its own log names the failed read), then let \`vinaya check ${checkName}\` re-run.`
|
|
10780
|
+
});
|
|
10781
|
+
process.exit(1);
|
|
10782
|
+
}
|
|
10783
|
+
|
|
10784
|
+
// src/lib/forge-read.ts
|
|
9312
10785
|
var FORGE_READ_CEILING_BYTES = 64 * 1024 * 1024;
|
|
9313
10786
|
var PAGE_SIZE = 100;
|
|
9314
10787
|
var ghRunner = (args, maxBuffer) => execFileSync4("gh", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], maxBuffer });
|
|
@@ -9331,7 +10804,7 @@ function isForgeReadOversize(err) {
|
|
|
9331
10804
|
function isBufferOverflow(err) {
|
|
9332
10805
|
return err?.code === "ENOBUFS";
|
|
9333
10806
|
}
|
|
9334
|
-
function
|
|
10807
|
+
function runBounded(runner, args, subject, usedBytes) {
|
|
9335
10808
|
const remaining = FORGE_READ_CEILING_BYTES - usedBytes;
|
|
9336
10809
|
let out;
|
|
9337
10810
|
try {
|
|
@@ -9346,31 +10819,40 @@ function run2(runner, args, subject, usedBytes) {
|
|
|
9346
10819
|
throw new ForgeReadOversizeError(subject, usedBytes + size);
|
|
9347
10820
|
return out;
|
|
9348
10821
|
}
|
|
9349
|
-
function
|
|
9350
|
-
const
|
|
9351
|
-
const comments = [];
|
|
10822
|
+
function readRestCommentRows(number, subjectLabel = `Issue ${number}`, runner = ghRunner) {
|
|
10823
|
+
const rows = [];
|
|
9352
10824
|
let used = 0;
|
|
9353
10825
|
for (let page = 1;; page++) {
|
|
9354
|
-
const out =
|
|
10826
|
+
const out = runBounded(runner, ["api", `repos/{owner}/{repo}/issues/${number}/comments?per_page=${PAGE_SIZE}&page=${page}`], subjectLabel, used);
|
|
9355
10827
|
used += Buffer.byteLength(out, "utf8");
|
|
9356
|
-
const
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
url: r.html_url ?? "",
|
|
9361
|
-
author: r.user?.login ? { login: r.user.login } : null
|
|
9362
|
-
});
|
|
9363
|
-
}
|
|
9364
|
-
if (rows.length < PAGE_SIZE)
|
|
9365
|
-
return comments;
|
|
10828
|
+
const pageRows = JSON.parse(out);
|
|
10829
|
+
rows.push(...pageRows);
|
|
10830
|
+
if (pageRows.length < PAGE_SIZE)
|
|
10831
|
+
return rows;
|
|
9366
10832
|
}
|
|
9367
10833
|
}
|
|
10834
|
+
function readIssueComments(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
10835
|
+
const number = resolveNumber(issue, subjectLabel, runner);
|
|
10836
|
+
const fromSnapshot = snapshotComments(number);
|
|
10837
|
+
if (fromSnapshot !== null)
|
|
10838
|
+
return fromSnapshot;
|
|
10839
|
+
return readRestCommentRows(number, subjectLabel, runner).map((r) => ({
|
|
10840
|
+
body: r.body ?? "",
|
|
10841
|
+
url: r.html_url ?? "",
|
|
10842
|
+
author: r.user?.login ? { login: r.user.login } : null
|
|
10843
|
+
}));
|
|
10844
|
+
}
|
|
9368
10845
|
function readIssueBody(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
9369
|
-
|
|
10846
|
+
if (forgeSnapshotDir() !== null) {
|
|
10847
|
+
const fromSnapshot = snapshotBody(resolveNumber(issue, subjectLabel, runner));
|
|
10848
|
+
if (fromSnapshot !== null)
|
|
10849
|
+
return fromSnapshot;
|
|
10850
|
+
}
|
|
10851
|
+
const out = runBounded(runner, ["issue", "view", String(issue), "--json", "body"], subjectLabel, 0);
|
|
9370
10852
|
return JSON.parse(out).body ?? "";
|
|
9371
10853
|
}
|
|
9372
10854
|
function readIssueFields(issue, fields, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
9373
|
-
return JSON.parse(
|
|
10855
|
+
return JSON.parse(runBounded(runner, ["issue", "view", String(issue), "--json", fields], subjectLabel, 0));
|
|
9374
10856
|
}
|
|
9375
10857
|
function resolveNumber(issue, subjectLabel, runner) {
|
|
9376
10858
|
if (typeof issue === "number")
|
|
@@ -9381,9 +10863,9 @@ function resolveNumber(issue, subjectLabel, runner) {
|
|
|
9381
10863
|
}
|
|
9382
10864
|
|
|
9383
10865
|
// src/lib/brief-assembly.ts
|
|
9384
|
-
import { execFileSync as
|
|
9385
|
-
import { existsSync as
|
|
9386
|
-
import { join as
|
|
10866
|
+
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
10867
|
+
import { existsSync as existsSync8, readFileSync as readFileSync8, readdirSync as readdirSync2 } from "node:fs";
|
|
10868
|
+
import { join as join9 } from "node:path";
|
|
9387
10869
|
|
|
9388
10870
|
// ../../packages/sources/src/commands.ts
|
|
9389
10871
|
var COMMANDS = [
|
|
@@ -9499,6 +10981,16 @@ var COMMANDS = [
|
|
|
9499
10981
|
],
|
|
9500
10982
|
status: "shipped"
|
|
9501
10983
|
},
|
|
10984
|
+
{
|
|
10985
|
+
name: "new adr",
|
|
10986
|
+
needs: [],
|
|
10987
|
+
description: "Write the next numbered decision record into the folder decisionRecords.path names",
|
|
10988
|
+
details: [
|
|
10989
|
+
"`vinaya new adr <title>` writes `<decisionRecords.path>/NNNN-<kebab-title>.md` from the shipped decision-record template (`vinaya doctrine --template decision-record`), with status Proposed and today's date, and adds a row for it to the folder's `README.md` index page, creating that page on the first record. Numbers start at `0001` and are one past the highest number any file in the folder or any row of the index carries, so a number is never reused, even after its file is removed.",
|
|
10990
|
+
"Refuses, naming the key, while `decisionRecords.path` is unset: decision records are opt-in. The same key switches on the `decision-record-citation` writing rule — see `decisionRecords.path` in the configuration reference."
|
|
10991
|
+
],
|
|
10992
|
+
status: "shipped"
|
|
10993
|
+
},
|
|
9502
10994
|
{
|
|
9503
10995
|
name: "brief render",
|
|
9504
10996
|
needs: ["forge", "default-branch"],
|
|
@@ -9517,9 +11009,7 @@ var COMMANDS = [
|
|
|
9517
11009
|
name: "task dispatch",
|
|
9518
11010
|
needs: ["forge", "operator-seat"],
|
|
9519
11011
|
description: "Deprecated — render, pin, and post the brief on the Issue as the frozen original; start the developer",
|
|
9520
|
-
flags: [
|
|
9521
|
-
{ flag: "--agent <claude|codex|gemini>", description: "Start the developer through dispatchRole once posted" }
|
|
9522
|
-
],
|
|
11012
|
+
flags: [{ flag: "--agent <claude|codex>", description: "Start the developer through dispatchRole once posted" }],
|
|
9523
11013
|
details: [
|
|
9524
11014
|
"Renders the brief from the Issue and the tree (the same assembly `brief render` uses) and posts it once as an Issue comment whose first line is `<!-- aeg:brief:v1 -->` and whose second line is `Brief hash: <sha256>` — the hash covers only the body below those two lines, so any reader recomputes it. Refuses outright, naming the existing comment's URL, when a `v1` comment already exists on the Issue — the brief is frozen by design, never overwritten or silently reissued.",
|
|
9525
11015
|
"With `--agent`, starts the Developer through `dispatchRole` when `apps/cli/src/lib/dispatch.ts` exports it; otherwise prints the rendered brief and the manual dispatch instruction and exits `0` — a soft dependency, never a hard block.",
|
|
@@ -9544,7 +11034,7 @@ var COMMANDS = [
|
|
|
9544
11034
|
description: "One command from a planned Issue to a reviewed pull request — exactly one developer started",
|
|
9545
11035
|
flags: [
|
|
9546
11036
|
{
|
|
9547
|
-
flag: "--agent <claude|codex
|
|
11037
|
+
flag: "--agent <claude|codex>",
|
|
9548
11038
|
description: "Vendor for the developer and both reviewers this run dispatches"
|
|
9549
11039
|
},
|
|
9550
11040
|
{
|
|
@@ -9719,6 +11209,22 @@ var COMMANDS = [
|
|
|
9719
11209
|
],
|
|
9720
11210
|
status: "shipped"
|
|
9721
11211
|
},
|
|
11212
|
+
{
|
|
11213
|
+
name: "pr snapshot",
|
|
11214
|
+
needs: ["forge"],
|
|
11215
|
+
description: "CI plumbing: write a run's forge snapshot of the pull request and its task Issue, read over REST",
|
|
11216
|
+
flags: [
|
|
11217
|
+
{
|
|
11218
|
+
flag: "--dir",
|
|
11219
|
+
description: "The snapshot directory; its `raw/` holds the REST pull request and comment pages the read step wrote"
|
|
11220
|
+
}
|
|
11221
|
+
],
|
|
11222
|
+
details: [
|
|
11223
|
+
"Run by the generated workflows' read step, never by hand. Maps the REST pull request and its comments to the shape `gh pr view --json` prints, resolves the task Issue from the body's `Closes #N`, and reads that Issue and its comments over REST — never GraphQL.",
|
|
11224
|
+
"A check reads the snapshot only when `GITHUB_ACTIONS` is `true` and the step running it sets `VINAYA_FORGE_SNAPSHOT_DIR`; anywhere else every read goes to the forge as before. Exits 1, naming what it could not read and both token budgets, on a failed read; 2 on a usage error."
|
|
11225
|
+
],
|
|
11226
|
+
status: "shipped"
|
|
11227
|
+
},
|
|
9722
11228
|
{
|
|
9723
11229
|
name: "issue create",
|
|
9724
11230
|
needs: ["forge"],
|
|
@@ -9839,14 +11345,14 @@ var COMMANDS = [
|
|
|
9839
11345
|
{
|
|
9840
11346
|
name: "milestone close",
|
|
9841
11347
|
needs: ["forge"],
|
|
9842
|
-
description: "Close a tranche's Milestone after verifying every labeled Issue is
|
|
11348
|
+
description: "Close a tranche's Milestone after verifying every labeled Issue is attached and every tranche it declares is complete",
|
|
9843
11349
|
flags: [
|
|
9844
11350
|
{ flag: "--slug", description: "The tranche whose Milestone is being closed" },
|
|
9845
11351
|
{ flag: "--validate-only", description: "Run every gate and report PASS without closing the Milestone" },
|
|
9846
11352
|
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
9847
11353
|
],
|
|
9848
11354
|
details: [
|
|
9849
|
-
"Resolves the target Milestone the same legacy-or-intent-declared way Issue create auto-attach does, then refuses to close on any mismatch between the label's Issues and the Milestone's natively attached Issues — naming each unattached or foreign Issue and its repair path (`gh issue edit <n> --milestone <title>`, or `vinaya milestone adopt`) — before the PATCH ever reaches the forge."
|
|
11355
|
+
"Resolves the target Milestone the same legacy-or-intent-declared way Issue create auto-attach does, then refuses to close on any mismatch between the label's Issues and the Milestone's natively attached Issues — naming each unattached or foreign Issue and its repair path (`gh issue edit <n> --milestone <title>`, or `vinaya milestone adopt`) — before the PATCH ever reaches the forge. It also holds the Milestone open while a tranche its `### Tranche intents` section declares is not complete — naming each unfinished tranche and its lifecycle — or while that section carries no readable tranche line; a Milestone with no such section closes on attachment alone. `--validate-only` refuses with the same reasons."
|
|
9850
11356
|
],
|
|
9851
11357
|
status: "shipped"
|
|
9852
11358
|
},
|
|
@@ -10135,7 +11641,7 @@ var COMMANDS = [
|
|
|
10135
11641
|
}
|
|
10136
11642
|
],
|
|
10137
11643
|
details: [
|
|
10138
|
-
"Refuses unless HEAD is the default branch, the working tree is clean, HEAD equals `origin/<default>` (after `git fetch origin`), HEAD's commit subject starts with `Chore(release): Version packages` (unless `--allow-any-commit`), and `npm whoami` exits `0`
|
|
11644
|
+
"Refuses unless HEAD is the default branch, the working tree is clean, HEAD equals `origin/<default>` (after `git fetch origin`), HEAD's commit subject starts with `Chore(release): Version packages` (unless `--allow-any-commit`), and `npm whoami` exits `0`. Before any plan step, including under `--dry-run`, every package in `.changeset/config.json` fixed groups must have an unpublished working-tree version. Exact-version registry queries refuse with every already-published package and version; workspace read failures and registry errors other than E404 also refuse with their reason. E404 for a missing package or version counts as unpublished.",
|
|
10139
11645
|
"Then streams `bun install --frozen-lockfile`, `bun run build`, `bun run changeset:publish`, and `git push origin --tags` — a real push, so the repo's own generated pre-push hook sees it exactly as any other push would. After it, prints `npm view <pkg> version` for every tag now on HEAD, noting registry lag on `@attalabs/vinaya` (observed ~20 minutes) when it still shows the previous version.",
|
|
10140
11646
|
'This is the one procedure named in `apps/cli/specs/self-hosting.md`, "How the published version is produced" — publishing itself stays manual and human-triggered; this command only removes the hand-typed four-step recipe.'
|
|
10141
11647
|
],
|
|
@@ -10144,11 +11650,11 @@ var COMMANDS = [
|
|
|
10144
11650
|
{
|
|
10145
11651
|
name: "dispatch",
|
|
10146
11652
|
needs: ["operator-seat"],
|
|
10147
|
-
description: "Start a role's headless agent session (claude/codex
|
|
11653
|
+
description: "Start a role's headless agent session (claude/codex) with attribution set on its environment, recording the outcome through the Vinaya Log",
|
|
10148
11654
|
flags: [
|
|
10149
11655
|
{
|
|
10150
11656
|
flag: "--agent",
|
|
10151
|
-
description: "Vendor to start: `claude
|
|
11657
|
+
description: "Vendor to start: `claude` or `codex` (falls back to `dispatch.agent` in config)"
|
|
10152
11658
|
},
|
|
10153
11659
|
{ flag: "--prompt-file", description: "Path to the prompt text sent to the agent (never on argv)" },
|
|
10154
11660
|
{ flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
|
|
@@ -10165,9 +11671,9 @@ var COMMANDS = [
|
|
|
10165
11671
|
],
|
|
10166
11672
|
details: [
|
|
10167
11673
|
"Sets `VINAYA_RUN_ID`/`VINAYA_ROLE`/`VINAYA_TASK`/`VINAYA_ROUND` on the child only — never on this process's own environment — and refuses by name, before any spawn attempt, when the named vendor binary is absent from `PATH` or present but not executable.",
|
|
10168
|
-
"Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, or `
|
|
11674
|
+
"Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, `refused`, or `usage_limit`) through the Vinaya Log's one `dispatch` family writer, `dispatchRole`. A wall-time ceiling (`dispatch.timeoutMs` in config, default one hour) sends `SIGTERM` then, after a grace window, `SIGKILL`.",
|
|
10169
11675
|
"Runs no flush of its own after the dispatch returns: every log line `dispatchRole` emits reaches its configured `logs` destination live, as it is emitted, so there is nothing left to ship in a trailing step. `--task`/`--pr` are attribution only, and remain mutually exclusive.",
|
|
10170
|
-
"A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude
|
|
11676
|
+
"A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude: `session_id`; codex: `thread_id`), parsed from its stdout, `null` on any failure. Passing that value as `--resume <id>` on a later call swaps in that vendor's own resume invocation (`claude -p -r <id> ...`; `codex exec resume <id> ...`) in place of its first-dispatch args."
|
|
10171
11677
|
],
|
|
10172
11678
|
status: "shipped"
|
|
10173
11679
|
},
|
|
@@ -10178,7 +11684,7 @@ var COMMANDS = [
|
|
|
10178
11684
|
flags: [
|
|
10179
11685
|
{ flag: "--task <n>", description: "This task's Issue number — its frozen `aeg:brief:v1` comment is the brief" },
|
|
10180
11686
|
{
|
|
10181
|
-
flag: "--agent <claude|codex
|
|
11687
|
+
flag: "--agent <claude|codex>",
|
|
10182
11688
|
description: "Vendor for every dispatch this loop makes (falls back to `dispatch.agent` in config)"
|
|
10183
11689
|
},
|
|
10184
11690
|
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
@@ -10257,22 +11763,72 @@ function createForgeSource(config) {
|
|
|
10257
11763
|
};
|
|
10258
11764
|
}
|
|
10259
11765
|
// ../../packages/sources/src/select-source.ts
|
|
10260
|
-
import { z as
|
|
10261
|
-
var StateSourceConfigSchema =
|
|
10262
|
-
|
|
10263
|
-
|
|
11766
|
+
import { z as z7 } from "zod";
|
|
11767
|
+
var StateSourceConfigSchema = z7.discriminatedUnion("kind", [
|
|
11768
|
+
z7.object({ kind: z7.literal("forge"), owner: z7.string(), repo: z7.string() }),
|
|
11769
|
+
z7.object({ kind: z7.literal("file"), root: z7.string().optional() })
|
|
10264
11770
|
]);
|
|
10265
11771
|
// src/checks/edge-resolve.ts
|
|
11772
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
11773
|
+
|
|
11774
|
+
// src/lib/github-rate-limit.ts
|
|
10266
11775
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
11776
|
+
var GITHUB_RATE_LIMIT_WORDING = /api rate limit (?:already )?exceeded|secondary rate limit|rate limit exceeded/i;
|
|
11777
|
+
var SECONDARY_RATE_LIMIT_WORDING = /secondary rate limit/i;
|
|
11778
|
+
function isGithubRateLimitError(text) {
|
|
11779
|
+
return GITHUB_RATE_LIMIT_WORDING.test(text);
|
|
11780
|
+
}
|
|
11781
|
+
function rateLimitBudget(errorText) {
|
|
11782
|
+
return errorText.trimStart().startsWith("GraphQL:") ? "GraphQL" : "REST";
|
|
11783
|
+
}
|
|
11784
|
+
var defaultReader = () => execFileSync5("gh", ["api", "rate_limit"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
11785
|
+
function readRateLimitReset(budget, read = defaultReader) {
|
|
11786
|
+
let parsed;
|
|
11787
|
+
try {
|
|
11788
|
+
parsed = JSON.parse(read());
|
|
11789
|
+
} catch {
|
|
11790
|
+
return null;
|
|
11791
|
+
}
|
|
11792
|
+
const resources = parsed.resources;
|
|
11793
|
+
const entry = resources?.[budget === "GraphQL" ? "graphql" : "core"];
|
|
11794
|
+
if (!entry || typeof entry.reset !== "number" || !Number.isFinite(entry.reset) || entry.reset <= 0)
|
|
11795
|
+
return null;
|
|
11796
|
+
if (typeof entry.remaining === "number" && entry.remaining > 0)
|
|
11797
|
+
return null;
|
|
11798
|
+
return entry.reset;
|
|
11799
|
+
}
|
|
11800
|
+
function formatResetUtc(epochSeconds) {
|
|
11801
|
+
const d = new Date(epochSeconds * 1000);
|
|
11802
|
+
const hh = String(d.getUTCHours()).padStart(2, "0");
|
|
11803
|
+
const mm = String(d.getUTCMinutes()).padStart(2, "0");
|
|
11804
|
+
return `${hh}:${mm} UTC`;
|
|
11805
|
+
}
|
|
11806
|
+
function rateLimitMessage(errorText, read = defaultReader) {
|
|
11807
|
+
const budget = rateLimitBudget(errorText);
|
|
11808
|
+
const reset = SECONDARY_RATE_LIMIT_WORDING.test(errorText) ? null : readRateLimitReset(budget, read);
|
|
11809
|
+
const when = reset === null ? "resets in a few minutes" : `resets at ${formatResetUtc(reset)}`;
|
|
11810
|
+
return `GitHub rate limit (${budget}), ${when}`;
|
|
11811
|
+
}
|
|
11812
|
+
function execErrorText(err) {
|
|
11813
|
+
const e = err;
|
|
11814
|
+
const stderr = e?.stderr === undefined || e.stderr === null ? "" : String(e.stderr);
|
|
11815
|
+
const message = typeof e?.message === "string" ? e.message : "";
|
|
11816
|
+
return stderr.trim() !== "" ? `${stderr}
|
|
11817
|
+
${message}` : message;
|
|
11818
|
+
}
|
|
11819
|
+
|
|
11820
|
+
// src/checks/edge-resolve.ts
|
|
10267
11821
|
var DIRECT_ISSUE_REF = /#(\d+)/;
|
|
10268
11822
|
var issueCache = new Map;
|
|
11823
|
+
var ISSUE_NOT_FOUND = /could not resolve to an issue/i;
|
|
10269
11824
|
function fetchIssueState(num, repo) {
|
|
10270
11825
|
const key = `${repo.owner}/${repo.repo}#${num}`;
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
11826
|
+
const cached = issueCache.get(key);
|
|
11827
|
+
if (cached)
|
|
11828
|
+
return cached;
|
|
11829
|
+
let out;
|
|
10274
11830
|
try {
|
|
10275
|
-
const raw =
|
|
11831
|
+
const raw = execFileSync6("gh", [
|
|
10276
11832
|
"issue",
|
|
10277
11833
|
"view",
|
|
10278
11834
|
String(num),
|
|
@@ -10281,9 +11837,9 @@ function fetchIssueState(num, repo) {
|
|
|
10281
11837
|
"--json",
|
|
10282
11838
|
"state,stateReason,closedByPullRequestsReferences"
|
|
10283
11839
|
], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
10284
|
-
out = JSON.parse(raw);
|
|
10285
|
-
} catch {
|
|
10286
|
-
out = null;
|
|
11840
|
+
out = { json: JSON.parse(raw), readFailed: false };
|
|
11841
|
+
} catch (err) {
|
|
11842
|
+
out = { json: null, readFailed: !ISSUE_NOT_FOUND.test(execErrorText(err)) };
|
|
10287
11843
|
}
|
|
10288
11844
|
issueCache.set(key, out);
|
|
10289
11845
|
return out;
|
|
@@ -10303,7 +11859,7 @@ var defaultResolveSiblingTranche = async (slug, repo) => {
|
|
|
10303
11859
|
};
|
|
10304
11860
|
};
|
|
10305
11861
|
var siblingTrancheCache = new Map;
|
|
10306
|
-
function edgeFromIssueJson(num, json) {
|
|
11862
|
+
function edgeFromIssueJson(num, json, readFailed = false) {
|
|
10307
11863
|
if (json === null) {
|
|
10308
11864
|
return {
|
|
10309
11865
|
issue: num,
|
|
@@ -10312,7 +11868,8 @@ function edgeFromIssueJson(num, json) {
|
|
|
10312
11868
|
issueState: null,
|
|
10313
11869
|
stateReason: null,
|
|
10314
11870
|
closedByActor: null,
|
|
10315
|
-
resolved: true
|
|
11871
|
+
resolved: true,
|
|
11872
|
+
...readFailed ? { readFailed: true } : {}
|
|
10316
11873
|
};
|
|
10317
11874
|
}
|
|
10318
11875
|
const state = json.state === "CLOSED" ? "closed" : json.state === "OPEN" ? "open" : null;
|
|
@@ -10345,7 +11902,8 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
10345
11902
|
const direct = id.match(DIRECT_ISSUE_REF);
|
|
10346
11903
|
if (direct) {
|
|
10347
11904
|
const num = Number(direct[1]);
|
|
10348
|
-
|
|
11905
|
+
const read = fetchIssueState(num, repo);
|
|
11906
|
+
return edgeFromIssueJson(num, read.json, read.readFailed);
|
|
10349
11907
|
}
|
|
10350
11908
|
const qualified = splitSlugQualifiedEdge(id);
|
|
10351
11909
|
if (qualified) {
|
|
@@ -10379,17 +11937,36 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
10379
11937
|
resolved: false
|
|
10380
11938
|
};
|
|
10381
11939
|
}
|
|
11940
|
+
function dependsOnFactFromEdge(id, r) {
|
|
11941
|
+
return {
|
|
11942
|
+
id,
|
|
11943
|
+
issue: r.issue,
|
|
11944
|
+
merged: r.merged,
|
|
11945
|
+
resolved: r.resolved,
|
|
11946
|
+
issueState: r.issueState,
|
|
11947
|
+
stateReason: r.stateReason,
|
|
11948
|
+
closedByActor: r.closedByActor,
|
|
11949
|
+
...r.readFailed ? { readFailed: true } : {}
|
|
11950
|
+
};
|
|
11951
|
+
}
|
|
10382
11952
|
|
|
10383
11953
|
// src/commands/doctrine.ts
|
|
10384
|
-
import { execFileSync as
|
|
10385
|
-
import { existsSync as
|
|
10386
|
-
import { dirname as dirname7, join as
|
|
11954
|
+
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
11955
|
+
import { existsSync as existsSync7, readdirSync, readFileSync as readFileSync7 } from "node:fs";
|
|
11956
|
+
import { dirname as dirname7, join as join8, sep as sep2 } from "node:path";
|
|
10387
11957
|
import matter4 from "gray-matter";
|
|
10388
11958
|
|
|
10389
11959
|
// ../../packages/aeg-core/src/docs/parse-doc.ts
|
|
10390
11960
|
import matter2 from "gray-matter";
|
|
10391
11961
|
// ../../packages/aeg-core/src/docs/surfaced-manifest.ts
|
|
10392
11962
|
var NO_MODEL_BACKED_PATHS = new Set;
|
|
11963
|
+
// ../../packages/aeg-core/src/docs/published-prose.ts
|
|
11964
|
+
var ALLOWED_MECHANICS = rulesForGroup("published-prose")[0]?.exemptions ?? [];
|
|
11965
|
+
var PROSE_RULES = rulesForGroup("published-prose").map((rule) => ({
|
|
11966
|
+
id: rule.id,
|
|
11967
|
+
what: rule.message,
|
|
11968
|
+
pattern: rule.patterns.published
|
|
11969
|
+
}));
|
|
10393
11970
|
// src/roles/contract.ts
|
|
10394
11971
|
import matter3 from "gray-matter";
|
|
10395
11972
|
|
|
@@ -10400,7 +11977,7 @@ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.c
|
|
|
10400
11977
|
}
|
|
10401
11978
|
function gitToplevel(cwd) {
|
|
10402
11979
|
try {
|
|
10403
|
-
return
|
|
11980
|
+
return execFileSync7("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
10404
11981
|
encoding: "utf8",
|
|
10405
11982
|
stdio: ["ignore", "pipe", "pipe"]
|
|
10406
11983
|
}).trim();
|
|
@@ -10411,25 +11988,25 @@ function gitToplevel(cwd) {
|
|
|
10411
11988
|
function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
10412
11989
|
const toplevel = gitToplevel(cwd);
|
|
10413
11990
|
if (toplevel !== null) {
|
|
10414
|
-
const treeRoot =
|
|
10415
|
-
if (
|
|
11991
|
+
const treeRoot = join8(toplevel, "aeg-root");
|
|
11992
|
+
if (existsSync7(join8(treeRoot, "roles")))
|
|
10416
11993
|
return { root: treeRoot, source: "tree" };
|
|
10417
11994
|
}
|
|
10418
11995
|
const fromSource = !pkg.split(sep2).includes("node_modules");
|
|
10419
|
-
const bundleRoot = fromSource ?
|
|
11996
|
+
const bundleRoot = fromSource ? join8(dirname7(dirname7(pkg)), "aeg-root") : join8(pkg, "aeg-root");
|
|
10420
11997
|
return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
|
|
10421
11998
|
}
|
|
10422
11999
|
function hasDoctrineEntry(root) {
|
|
10423
|
-
return
|
|
12000
|
+
return existsSync7(join8(root, ...ENTRY_SEGMENTS));
|
|
10424
12001
|
}
|
|
10425
12002
|
|
|
10426
12003
|
// src/lib/brief-assembly.ts
|
|
10427
12004
|
var PACKAGE_ROOT = packageRoot(import.meta.url);
|
|
10428
|
-
var PACKAGED_TEMPLATE_PATH =
|
|
10429
|
-
var TEMPLATE_PATH =
|
|
12005
|
+
var PACKAGED_TEMPLATE_PATH = join9(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
|
|
12006
|
+
var TEMPLATE_PATH = existsSync8(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join9(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
10430
12007
|
function git(args) {
|
|
10431
12008
|
try {
|
|
10432
|
-
return
|
|
12009
|
+
return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
10433
12010
|
} catch {
|
|
10434
12011
|
return "";
|
|
10435
12012
|
}
|
|
@@ -10476,20 +12053,20 @@ function agentCommandText(line) {
|
|
|
10476
12053
|
}
|
|
10477
12054
|
var AGENT_COMMAND_MAX_BUFFER_BYTES = 32 * 1024 * 1024;
|
|
10478
12055
|
// src/lib/patch-id.ts
|
|
10479
|
-
import { execFileSync as
|
|
12056
|
+
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
10480
12057
|
function patchIdAt(base, sha) {
|
|
10481
12058
|
try {
|
|
10482
|
-
|
|
12059
|
+
execFileSync9("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
|
|
10483
12060
|
} catch {}
|
|
10484
12061
|
try {
|
|
10485
|
-
const diff =
|
|
12062
|
+
const diff = execFileSync9("git", ["diff", `origin/${base}...${sha}`], {
|
|
10486
12063
|
encoding: "utf8",
|
|
10487
12064
|
maxBuffer: 64 * 1024 * 1024,
|
|
10488
12065
|
stdio: ["ignore", "pipe", "pipe"]
|
|
10489
12066
|
});
|
|
10490
12067
|
if (diff === "")
|
|
10491
12068
|
return null;
|
|
10492
|
-
const out =
|
|
12069
|
+
const out = execFileSync9("git", ["patch-id", "--stable"], {
|
|
10493
12070
|
input: diff,
|
|
10494
12071
|
encoding: "utf8",
|
|
10495
12072
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -10597,25 +12174,58 @@ function compareEvidenceBlock(resolved, resolvedHead, actualNumstat, expectedGro
|
|
|
10597
12174
|
return errors.length > 0 ? { status: "fail", errors } : { status: "pass" };
|
|
10598
12175
|
}
|
|
10599
12176
|
|
|
12177
|
+
// src/checks/principals-refusal.ts
|
|
12178
|
+
function principalsUnresolvedCheckError(check, err, severity) {
|
|
12179
|
+
const recovery = err.kind === "not-configured" ? `This repository names no Principal, so nobody's verdict, waiver or Issue close can be trusted. Ask a Principal to ${PRINCIPALS_FIX} (a list of GitHub logins), then re-run \`vinaya check ${check}\`.` : severity === "error" ? `The Principal list could not be read from the forge, so this trust decision cannot be made. Confirm \`gh auth status\` passes (in CI, that the job's token is not empty) and the forge is reachable, then re-run \`vinaya check ${check}\`.` : `The Principal list could not be read from the forge, so the part of this check that needs it was not evaluated — the rest still ran. Confirm \`gh auth status\` passes and the forge is reachable, then re-run \`vinaya check ${check}\`.`;
|
|
12180
|
+
return {
|
|
12181
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
12182
|
+
check,
|
|
12183
|
+
severity,
|
|
12184
|
+
message: `${check}: ${err.message}`,
|
|
12185
|
+
agent_recovery_prompt: recovery
|
|
12186
|
+
};
|
|
12187
|
+
}
|
|
12188
|
+
function refuseUnresolvedPrincipals(check, err) {
|
|
12189
|
+
if (!(err instanceof PrincipalsUnresolvedError))
|
|
12190
|
+
throw err;
|
|
12191
|
+
emitCheckError(principalsUnresolvedCheckError(check, err, "error"));
|
|
12192
|
+
process.exit(1);
|
|
12193
|
+
}
|
|
12194
|
+
function warnOnUnreadPrincipals(check, err) {
|
|
12195
|
+
if (err instanceof PrincipalsUnresolvedError && err.kind === "read-failed") {
|
|
12196
|
+
emitCheckError(principalsUnresolvedCheckError(check, err, "warning"));
|
|
12197
|
+
return;
|
|
12198
|
+
}
|
|
12199
|
+
refuseUnresolvedPrincipals(check, err);
|
|
12200
|
+
}
|
|
12201
|
+
|
|
10600
12202
|
// src/checks/bin/check-evidence-fresh.ts
|
|
10601
|
-
var
|
|
12203
|
+
var DEVELOPER_ROUND_MARKER2 = /<!--\s*aeg:developer:round-\d+\s*-->/i;
|
|
10602
12204
|
function fetchHasPriorDeveloperRound(prNumber) {
|
|
12205
|
+
let allowlist;
|
|
10603
12206
|
try {
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
const
|
|
10610
|
-
return
|
|
12207
|
+
allowlist = resolveTrustedPrincipals();
|
|
12208
|
+
} catch (err) {
|
|
12209
|
+
refuseUnresolvedPrincipals(CHECK_NAME, err);
|
|
12210
|
+
}
|
|
12211
|
+
try {
|
|
12212
|
+
const comments = snapshotComments(prNumber) ?? fetchPrComments(prNumber);
|
|
12213
|
+
return comments.some((c) => DEVELOPER_ROUND_MARKER2.test(c.body ?? "") && isPrincipal(c.author?.login ?? null, allowlist));
|
|
10611
12214
|
} catch {
|
|
10612
12215
|
return true;
|
|
10613
12216
|
}
|
|
10614
12217
|
}
|
|
12218
|
+
function fetchPrComments(prNumber) {
|
|
12219
|
+
const out = execFileSync10("gh", ["pr", "view", String(prNumber), "--json", "comments"], {
|
|
12220
|
+
encoding: "utf8",
|
|
12221
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
12222
|
+
});
|
|
12223
|
+
return JSON.parse(out).comments ?? [];
|
|
12224
|
+
}
|
|
10615
12225
|
var CHECK_NAME = "evidence-fresh";
|
|
10616
12226
|
function git2(args) {
|
|
10617
12227
|
try {
|
|
10618
|
-
return
|
|
12228
|
+
return execFileSync10("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
10619
12229
|
} catch {
|
|
10620
12230
|
return "";
|
|
10621
12231
|
}
|
|
@@ -10634,7 +12244,7 @@ class GitCommandError2 extends Error {
|
|
|
10634
12244
|
}
|
|
10635
12245
|
function gitStrict(args) {
|
|
10636
12246
|
try {
|
|
10637
|
-
return
|
|
12247
|
+
return execFileSync10("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
10638
12248
|
} catch (err) {
|
|
10639
12249
|
const stderr = err.stderr;
|
|
10640
12250
|
throw new GitCommandError2(args, String(stderr ?? err.message).trim() || "non-zero exit");
|
|
@@ -10651,8 +12261,12 @@ function resolveMergeBase(head) {
|
|
|
10651
12261
|
throw new UnresolvableMergeBaseError2(tried);
|
|
10652
12262
|
}
|
|
10653
12263
|
function fetchPrRefs(prNumber) {
|
|
12264
|
+
const fromSnapshot = snapshotPullRequest(prNumber);
|
|
12265
|
+
if (fromSnapshot !== null) {
|
|
12266
|
+
return fromSnapshot.headRefOid && fromSnapshot.baseRefName ? { head: fromSnapshot.headRefOid, base: fromSnapshot.baseRefName } : null;
|
|
12267
|
+
}
|
|
10654
12268
|
try {
|
|
10655
|
-
const out =
|
|
12269
|
+
const out = execFileSync10("gh", ["pr", "view", String(prNumber), "--json", "headRefOid,baseRefName"], {
|
|
10656
12270
|
encoding: "utf8",
|
|
10657
12271
|
stdio: ["ignore", "pipe", "pipe"]
|
|
10658
12272
|
});
|
|
@@ -10665,6 +12279,7 @@ function fetchPrRefs(prNumber) {
|
|
|
10665
12279
|
}
|
|
10666
12280
|
}
|
|
10667
12281
|
function main() {
|
|
12282
|
+
exitOnIncompleteForgeSnapshot(CHECK_NAME);
|
|
10668
12283
|
const body = process.env.PR_BODY ?? "";
|
|
10669
12284
|
if (!body) {
|
|
10670
12285
|
process.exit(0);
|