@attalabs/vinaya 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/aeg-root/contracts/planner-developer.md +1 -1
- package/aeg-root/enforcement.md +22 -22
- package/aeg-root/process.md +1 -1
- package/aeg-root/roles/archivist.md +1 -1
- package/aeg-root/roles/developer/reference.md +4 -1
- package/aeg-root/roles/developer.md +1 -1
- package/aeg-root/roles/planner/reference.md +18 -5
- package/aeg-root/roles/principal.md +1 -1
- package/aeg-root/roles/reviewer.md +3 -3
- package/aeg-root/roles/security.md +4 -4
- package/aeg-root/roles/tranche-archivist.md +2 -2
- package/aeg-root/skills/aeg/SKILL.md +1 -1
- package/aeg-root/state-machine.md +8 -13
- package/aeg-root/templates/brief-template.md +4 -1
- package/aeg-root/templates/decision-record-template.md +38 -0
- package/aeg-root/templates/issue-rationale-template.md +1 -1
- package/aeg-root/tranche-model.md +1 -1
- package/dist/checks/bin/check-body-bare-digits.js +1867 -347
- package/dist/checks/bin/check-branch-topology.js +1181 -237
- package/dist/checks/bin/check-brief-shape.js +1911 -433
- package/dist/checks/bin/check-changeset-coverage.js +2144 -517
- package/dist/checks/bin/check-ci-shard-coverage.js +12133 -11
- package/dist/checks/bin/check-closes-n.js +1181 -237
- package/dist/checks/bin/check-coherence.js +1785 -1126
- package/dist/checks/bin/check-dead-branch-push.js +1154 -225
- package/dist/checks/bin/check-dispatch-readiness.js +2068 -436
- package/dist/checks/bin/check-doc-claims.js +2104 -231
- package/dist/checks/bin/check-doc-coverage-push.js +2181 -515
- package/dist/checks/bin/check-doc-coverage.js +2181 -519
- package/dist/checks/bin/check-doctrine-no-procedures.js +1668 -345
- package/dist/checks/bin/check-doctrine-portability.js +2143 -516
- package/dist/checks/bin/check-evidence-fresh.js +2080 -465
- package/dist/checks/bin/check-exec-bits.js +2130 -503
- package/dist/checks/bin/check-first-push-dispatch.js +1845 -371
- package/dist/checks/bin/check-issue-assignment.js +712 -170
- package/dist/checks/bin/check-issue-milestone-attach.js +1145 -225
- package/dist/checks/bin/check-issue-objectives-numbering.js +1661 -338
- package/dist/checks/bin/check-issue-parts-coverage.js +1145 -225
- package/dist/checks/bin/check-issue-surface-globs.js +1787 -369
- package/dist/checks/bin/check-issue-title-grammar.js +1145 -225
- package/dist/checks/bin/check-issue-tranche-label.js +702 -170
- package/dist/checks/bin/check-main-branch-refusal.js +1157 -227
- package/dist/checks/bin/check-no-disk-state.js +1145 -225
- package/dist/checks/bin/check-pr-premise-reassert.js +1661 -338
- package/dist/checks/bin/check-pr-report-density.js +1145 -225
- package/dist/checks/bin/check-principal-test-plan-wait.js +2379 -249
- package/dist/checks/bin/check-quoted-command.js +2128 -501
- package/dist/checks/bin/check-reader-resolvable-prose.js +2170 -517
- package/dist/checks/bin/check-registry-gates.js +1228 -272
- package/dist/checks/bin/check-retired-vocabulary.js +2153 -507
- package/dist/checks/bin/check-review-gate.js +1932 -350
- package/dist/checks/bin/check-single-plan-pr.js +1208 -229
- package/dist/checks/bin/check-surface-scope.js +1414 -244
- package/dist/checks/bin/check-test-plan.js +2381 -252
- package/dist/checks/bin/check-token-collection-wired.js +1145 -225
- package/dist/checks/bin/check-workspace-escape.js +2141 -514
- package/dist/checks/bin/verify-coherence.js +493 -86
- package/dist/checks/bin/verify-dispatch.js +512 -132
- package/dist/checks/bin/verify-docs.js +549 -124
- package/dist/index.js +22702 -17900
- package/dist/lib/pre-push-cache-test-run.js +1026 -233
- package/dist/lib/pre-push-select-tests.js +922 -173
- package/package.json +12 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +13 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +55 -26
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +12 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +22 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/entry-point.ts +27 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +2 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +19 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +593 -55
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +6 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +19 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +32 -13
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0sxadt2._.js +13 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +57 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1ug9syi._.js → [root-of-the-server]__1wzfiav._.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{06_55xbp7rcbi.js → 1p3vr9qts86_b.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2brkwv169ygep.js → 21tunzmxjvm2a.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{33rszkngkuoko.js → 38kom-9c-oi65.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +0 -57
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +0 -13
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → Y3oaZSTSP9PivUuJvxK1W}/_ssgManifest.js +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-doc-coverage-push.ts
|
|
4
|
-
import { execFileSync as
|
|
5
|
-
import { existsSync as
|
|
4
|
+
import { execFileSync as execFileSync10 } from "node:child_process";
|
|
5
|
+
import { existsSync as existsSync9, readFileSync as readFileSync9 } from "node:fs";
|
|
6
6
|
|
|
7
7
|
// ../../packages/aeg-core/src/entry-point.ts
|
|
8
8
|
import { realpathSync } from "node:fs";
|
|
@@ -43,7 +43,6 @@ var GATE_AUDIENCE = {
|
|
|
43
43
|
};
|
|
44
44
|
var NON_GATE_BINS = [
|
|
45
45
|
"archive-task",
|
|
46
|
-
"assign-task-issue",
|
|
47
46
|
"dead-branch-audit",
|
|
48
47
|
"eval-agent-compliance",
|
|
49
48
|
"open-issue",
|
|
@@ -306,6 +305,25 @@ async function runAsync(args) {
|
|
|
306
305
|
function ghApiGet(path) {
|
|
307
306
|
return JSON.parse(run(["api", path]));
|
|
308
307
|
}
|
|
308
|
+
var MAX_PER_PAGE = 100;
|
|
309
|
+
var MAX_PAGES = 100;
|
|
310
|
+
async function ghApiGetAllPagesAsync(pathWithoutPage, opts) {
|
|
311
|
+
const [base = pathWithoutPage, query = ""] = pathWithoutPage.split("?");
|
|
312
|
+
const params = new URLSearchParams(query);
|
|
313
|
+
params.set("per_page", String(MAX_PER_PAGE));
|
|
314
|
+
const all = [];
|
|
315
|
+
for (let page = 1;page <= MAX_PAGES; page++) {
|
|
316
|
+
params.set("page", String(page));
|
|
317
|
+
const args = ["api", `${base}?${params.toString()}`];
|
|
318
|
+
if (opts?.jq)
|
|
319
|
+
args.push("-q", opts.jq);
|
|
320
|
+
const batch = JSON.parse(await runAsync(args));
|
|
321
|
+
all.push(...batch);
|
|
322
|
+
if (batch.length < MAX_PER_PAGE)
|
|
323
|
+
return all;
|
|
324
|
+
}
|
|
325
|
+
throw new Error(`ghApiGetAllPagesAsync: "${pathWithoutPage}" did not terminate within ${MAX_PAGES} pages (${MAX_PAGES * MAX_PER_PAGE} items) — refusing to keep walking.`);
|
|
326
|
+
}
|
|
309
327
|
function issueListByLabelArgs(owner, repo, label) {
|
|
310
328
|
return [
|
|
311
329
|
"issue",
|
|
@@ -717,6 +735,10 @@ function intentGoalForSlug(description, slug) {
|
|
|
717
735
|
function matchesLegacyMilestone(milestones, slug) {
|
|
718
736
|
return milestones.find((m) => m.title === slug) ?? null;
|
|
719
737
|
}
|
|
738
|
+
var TRANCHE_SLUG_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*-v\d+$/;
|
|
739
|
+
function slugShapedTitles(milestones) {
|
|
740
|
+
return milestones.map((m) => m.title).filter((t) => TRANCHE_SLUG_SHAPE.test(t));
|
|
741
|
+
}
|
|
720
742
|
function factsFromLegacyMilestone(milestone) {
|
|
721
743
|
return {
|
|
722
744
|
goal: milestone.description ?? "",
|
|
@@ -750,6 +772,90 @@ function findMilestoneForSlug(owner, repo, slug) {
|
|
|
750
772
|
return resolveLegacyFacts(legacy, issues);
|
|
751
773
|
return { goal: goalFromMilestones(milestones, slug), lifecycle: lifecycleFromIssues(issues) };
|
|
752
774
|
}
|
|
775
|
+
function trancheSlugsFromLabels(labels) {
|
|
776
|
+
const slugs = [];
|
|
777
|
+
for (const l of labels) {
|
|
778
|
+
const slug = trancheSlugOf(l.name);
|
|
779
|
+
if (slug !== null)
|
|
780
|
+
slugs.push(slug);
|
|
781
|
+
}
|
|
782
|
+
return slugs;
|
|
783
|
+
}
|
|
784
|
+
async function indexTrancheMilestonesAsync(owner, repo) {
|
|
785
|
+
const [milestones, labels] = await Promise.all([
|
|
786
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
787
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`)
|
|
788
|
+
]);
|
|
789
|
+
const active = [];
|
|
790
|
+
const archived = [];
|
|
791
|
+
const facts = new Map;
|
|
792
|
+
const legacySlugs = new Set(slugShapedTitles(milestones));
|
|
793
|
+
const legacyMilestoneBySlug = new Map(milestones.filter((m) => legacySlugs.has(m.title)).map((m) => [m.title, m]));
|
|
794
|
+
const newPathSlugs = trancheSlugsFromLabels(labels).filter((slug) => !legacySlugs.has(slug));
|
|
795
|
+
const uniqueNewPathSlugs = [...new Set(newPathSlugs)];
|
|
796
|
+
const uniqueLegacySlugs = [...legacySlugs];
|
|
797
|
+
const [legacyIssuesBySlug, newPathIssuesBySlug] = await Promise.all([
|
|
798
|
+
Promise.all(uniqueLegacySlugs.map((slug) => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))),
|
|
799
|
+
Promise.all(uniqueNewPathSlugs.map((slug) => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))))
|
|
800
|
+
]);
|
|
801
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
802
|
+
const m = legacyMilestoneBySlug.get(slug);
|
|
803
|
+
if (!m)
|
|
804
|
+
return;
|
|
805
|
+
const ref = { slug, goal: m.description ?? "" };
|
|
806
|
+
const f = resolveLegacyFacts(m, legacyIssuesBySlug[i] ?? []);
|
|
807
|
+
if (f.lifecycle === "complete")
|
|
808
|
+
archived.push(ref);
|
|
809
|
+
else if (f.lifecycle === "active")
|
|
810
|
+
active.push(ref);
|
|
811
|
+
facts.set(slug, f);
|
|
812
|
+
});
|
|
813
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
814
|
+
const issues = newPathIssuesBySlug[i] ?? [];
|
|
815
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
816
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
817
|
+
const f = { goal, lifecycle };
|
|
818
|
+
facts.set(slug, f);
|
|
819
|
+
if (lifecycle === "active")
|
|
820
|
+
active.push({ slug, goal });
|
|
821
|
+
else if (lifecycle === "complete")
|
|
822
|
+
archived.push({ slug, goal });
|
|
823
|
+
});
|
|
824
|
+
return { active, archived, facts, legacySlugs };
|
|
825
|
+
}
|
|
826
|
+
async function indexTrancheMilestonesForSlugAsync(owner, repo, slug) {
|
|
827
|
+
const [milestones, labels, issues] = await Promise.all([
|
|
828
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
829
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`),
|
|
830
|
+
ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))
|
|
831
|
+
]);
|
|
832
|
+
const active = [];
|
|
833
|
+
const archived = [];
|
|
834
|
+
const facts = new Map;
|
|
835
|
+
const legacySlugs = new Set;
|
|
836
|
+
const legacyMilestone = slugShapedTitles(milestones).includes(slug) ? matchesLegacyMilestone(milestones, slug) : null;
|
|
837
|
+
if (legacyMilestone) {
|
|
838
|
+
legacySlugs.add(slug);
|
|
839
|
+
const ref = { slug, goal: legacyMilestone.description ?? "" };
|
|
840
|
+
const f = resolveLegacyFacts(legacyMilestone, issues);
|
|
841
|
+
if (f.lifecycle === "complete")
|
|
842
|
+
archived.push(ref);
|
|
843
|
+
else if (f.lifecycle === "active")
|
|
844
|
+
active.push(ref);
|
|
845
|
+
facts.set(slug, f);
|
|
846
|
+
} else if (trancheSlugsFromLabels(labels).includes(slug)) {
|
|
847
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
848
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
849
|
+
facts.set(slug, { goal, lifecycle });
|
|
850
|
+
if (lifecycle === "active")
|
|
851
|
+
active.push({ slug, goal });
|
|
852
|
+
else if (lifecycle === "complete")
|
|
853
|
+
archived.push({ slug, goal });
|
|
854
|
+
}
|
|
855
|
+
const openLegacyTitles = new Set(slugShapedTitles(milestones.filter((m) => m.state === "open")));
|
|
856
|
+
const otherOpenLegacySlugs = [...openLegacyTitles].filter((t) => t !== slug);
|
|
857
|
+
return { active, archived, facts, legacySlugs, otherOpenLegacySlugs };
|
|
858
|
+
}
|
|
753
859
|
|
|
754
860
|
// ../../packages/aeg-forge-state/src/derive-from-forge.ts
|
|
755
861
|
function trancheFromIssues(slug, issues, known) {
|
|
@@ -1410,6 +1516,125 @@ var graphql2 = withDefaults3(request, {
|
|
|
1410
1516
|
method: "POST",
|
|
1411
1517
|
url: "/graphql"
|
|
1412
1518
|
});
|
|
1519
|
+
|
|
1520
|
+
// ../../packages/aeg-forge-state/src/fetch-provenance.ts
|
|
1521
|
+
var PROVENANCE_PATTERN = /^###\s+AEG provenance\b/im;
|
|
1522
|
+
function provenanceMatchesIssue(text, issueNum) {
|
|
1523
|
+
if (!PROVENANCE_PATTERN.test(text))
|
|
1524
|
+
return false;
|
|
1525
|
+
const m = text.match(/^-\s*Issue:\s*#(\d+)/im);
|
|
1526
|
+
return m !== null && Number(m[1]) === issueNum;
|
|
1527
|
+
}
|
|
1528
|
+
function isPrCloser(closer) {
|
|
1529
|
+
return closer !== null && typeof closer.number === "number";
|
|
1530
|
+
}
|
|
1531
|
+
async function fetchProvenanceViaCrossReferences(issueNums, owner, repo, token) {
|
|
1532
|
+
const result = new Map;
|
|
1533
|
+
if (issueNums.length === 0)
|
|
1534
|
+
return result;
|
|
1535
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1536
|
+
const perIssue = issueNums.map((n) => `
|
|
1537
|
+
i_${n}: issue(number: ${n}) {
|
|
1538
|
+
timelineItems(first: 50, itemTypes: [CROSS_REFERENCED_EVENT]) {
|
|
1539
|
+
nodes {
|
|
1540
|
+
... on CrossReferencedEvent {
|
|
1541
|
+
source {
|
|
1542
|
+
... on PullRequest {
|
|
1543
|
+
number
|
|
1544
|
+
body
|
|
1545
|
+
comments(first: 50) { nodes { body } }
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
}`).join("");
|
|
1552
|
+
const query = `query ProvenanceCrossRef($owner: String!, $repo: String!) {
|
|
1553
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1554
|
+
}
|
|
1555
|
+
}`;
|
|
1556
|
+
let response;
|
|
1557
|
+
try {
|
|
1558
|
+
response = await client(query, { owner, repo });
|
|
1559
|
+
} catch {
|
|
1560
|
+
return result;
|
|
1561
|
+
}
|
|
1562
|
+
if (!response.repository)
|
|
1563
|
+
return result;
|
|
1564
|
+
for (const n of issueNums) {
|
|
1565
|
+
const raw = response.repository[`i_${n}`];
|
|
1566
|
+
const nodes = raw?.timelineItems?.nodes ?? [];
|
|
1567
|
+
const found = nodes.some(({ source }) => {
|
|
1568
|
+
if (!source || typeof source.number !== "number")
|
|
1569
|
+
return false;
|
|
1570
|
+
const pr = source;
|
|
1571
|
+
if (provenanceMatchesIssue(pr.body ?? "", n))
|
|
1572
|
+
return true;
|
|
1573
|
+
return pr.comments.nodes.some((c) => provenanceMatchesIssue(c.body, n));
|
|
1574
|
+
});
|
|
1575
|
+
result.set(n, found);
|
|
1576
|
+
}
|
|
1577
|
+
return result;
|
|
1578
|
+
}
|
|
1579
|
+
async function fetchProvenance(issueNums, owner, repo, token) {
|
|
1580
|
+
const result = new Map;
|
|
1581
|
+
if (issueNums.length === 0)
|
|
1582
|
+
return result;
|
|
1583
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1584
|
+
const perIssue = issueNums.map((n) => `
|
|
1585
|
+
i_${n}: issue(number: ${n}) {
|
|
1586
|
+
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1587
|
+
nodes {
|
|
1588
|
+
... on ClosedEvent {
|
|
1589
|
+
closer {
|
|
1590
|
+
... on PullRequest {
|
|
1591
|
+
number
|
|
1592
|
+
body
|
|
1593
|
+
comments(first: 50) {
|
|
1594
|
+
nodes { body }
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
}`).join("");
|
|
1602
|
+
const query = `query Provenance($owner: String!, $repo: String!) {
|
|
1603
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1604
|
+
}
|
|
1605
|
+
}`;
|
|
1606
|
+
let response;
|
|
1607
|
+
try {
|
|
1608
|
+
response = await client(query, { owner, repo });
|
|
1609
|
+
} catch {
|
|
1610
|
+
return result;
|
|
1611
|
+
}
|
|
1612
|
+
if (!response.repository)
|
|
1613
|
+
return result;
|
|
1614
|
+
const needsFallback = [];
|
|
1615
|
+
for (const n of issueNums) {
|
|
1616
|
+
const raw = response.repository[`i_${n}`];
|
|
1617
|
+
if (!raw) {
|
|
1618
|
+
result.set(n, false);
|
|
1619
|
+
continue;
|
|
1620
|
+
}
|
|
1621
|
+
const closer = raw.timelineItems?.nodes?.[0]?.closer;
|
|
1622
|
+
const c = closer ?? null;
|
|
1623
|
+
if (!isPrCloser(c)) {
|
|
1624
|
+
needsFallback.push(n);
|
|
1625
|
+
continue;
|
|
1626
|
+
}
|
|
1627
|
+
const bodyHas = PROVENANCE_PATTERN.test(c.body ?? "");
|
|
1628
|
+
const commentHas = c.comments.nodes.some((x) => PROVENANCE_PATTERN.test(x.body));
|
|
1629
|
+
result.set(n, bodyHas || commentHas);
|
|
1630
|
+
}
|
|
1631
|
+
if (needsFallback.length > 0) {
|
|
1632
|
+
const fallback = await fetchProvenanceViaCrossReferences(needsFallback, owner, repo, token);
|
|
1633
|
+
for (const [n, found] of fallback)
|
|
1634
|
+
result.set(n, found);
|
|
1635
|
+
}
|
|
1636
|
+
return result;
|
|
1637
|
+
}
|
|
1413
1638
|
// ../../packages/aeg-forge-state/src/github-token.ts
|
|
1414
1639
|
import { execFile as execFile2 } from "node:child_process";
|
|
1415
1640
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -1639,6 +1864,84 @@ function describeError(err) {
|
|
|
1639
1864
|
return err;
|
|
1640
1865
|
return "unknown error";
|
|
1641
1866
|
}
|
|
1867
|
+
// ../../packages/aeg-forge-state/src/prior-tranche-archival.ts
|
|
1868
|
+
function defaultPriorTrancheArchivalDeps() {
|
|
1869
|
+
let facts = new Map;
|
|
1870
|
+
return {
|
|
1871
|
+
activeTrancheSlugs: async (excludeSlug, repo) => {
|
|
1872
|
+
const index = await indexTrancheMilestonesAsync(repo.owner, repo.repo);
|
|
1873
|
+
facts = index.facts;
|
|
1874
|
+
return index.active.map((m) => m.slug).filter((slug) => slug !== excludeSlug);
|
|
1875
|
+
},
|
|
1876
|
+
deriveTranche: (slug, repo) => deriveTrancheFromForge(repo.owner, repo.repo, slug, facts.get(slug)),
|
|
1877
|
+
openIssues: async (slug, repo) => (await fetchTrancheIssuesAsync(repo.owner, repo.repo, slug)).filter((issue) => issue.state === "OPEN").map((issue) => ({ number: issue.number }))
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
function reason(err) {
|
|
1881
|
+
return err instanceof Error ? err.message.split(`
|
|
1882
|
+
`)[0] ?? "failed" : String(err);
|
|
1883
|
+
}
|
|
1884
|
+
async function resolvePriorTrancheArchival(projects, excludeSlug, repo, deps = defaultPriorTrancheArchivalDeps()) {
|
|
1885
|
+
if (projects.length === 0)
|
|
1886
|
+
return { facts: [], infraFailure: null };
|
|
1887
|
+
let candidates;
|
|
1888
|
+
try {
|
|
1889
|
+
candidates = await deps.activeTrancheSlugs(excludeSlug, repo);
|
|
1890
|
+
} catch (err) {
|
|
1891
|
+
return {
|
|
1892
|
+
facts: [],
|
|
1893
|
+
infraFailure: `severity:infra — could not read the active tranches (${reason(err)}); whether a prior tranche is archived is unknown.`
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
const facts = [];
|
|
1897
|
+
const unreadable = [];
|
|
1898
|
+
const derived = new Map;
|
|
1899
|
+
const derive = (slug) => {
|
|
1900
|
+
let p = derived.get(slug);
|
|
1901
|
+
if (!p) {
|
|
1902
|
+
p = deps.deriveTranche(slug, repo);
|
|
1903
|
+
derived.set(slug, p);
|
|
1904
|
+
}
|
|
1905
|
+
return p;
|
|
1906
|
+
};
|
|
1907
|
+
for (const project of projects) {
|
|
1908
|
+
let found = null;
|
|
1909
|
+
let unknown = false;
|
|
1910
|
+
for (const slug of candidates) {
|
|
1911
|
+
let candidateTranche;
|
|
1912
|
+
try {
|
|
1913
|
+
candidateTranche = await derive(slug);
|
|
1914
|
+
} catch {
|
|
1915
|
+
unknown = true;
|
|
1916
|
+
unreadable.push(`the tasks of tranche \`${slug}\` (project \`${project}\`)`);
|
|
1917
|
+
break;
|
|
1918
|
+
}
|
|
1919
|
+
if (!candidateTranche.tasks.some((t) => t.projects.includes(project)))
|
|
1920
|
+
continue;
|
|
1921
|
+
let openIssues;
|
|
1922
|
+
try {
|
|
1923
|
+
openIssues = await deps.openIssues(slug, repo);
|
|
1924
|
+
} catch {
|
|
1925
|
+
openIssues = null;
|
|
1926
|
+
}
|
|
1927
|
+
if (openIssues === null) {
|
|
1928
|
+
unknown = true;
|
|
1929
|
+
unreadable.push(`the open Issues of tranche \`${slug}\` (project \`${project}\`)`);
|
|
1930
|
+
break;
|
|
1931
|
+
}
|
|
1932
|
+
if (openIssues.length === 0) {
|
|
1933
|
+
found = { project, priorTrancheSlug: slug, archived: false };
|
|
1934
|
+
break;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
if (!unknown)
|
|
1938
|
+
facts.push(found ?? { project, priorTrancheSlug: null, archived: false });
|
|
1939
|
+
}
|
|
1940
|
+
return {
|
|
1941
|
+
facts,
|
|
1942
|
+
infraFailure: unreadable.length === 0 ? null : `severity:infra — could not read ${unreadable.join(", ")}; whether a prior tranche is archived is unknown.`
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1642
1945
|
// ../../packages/aeg-forge-state/src/fetch-open-issues.ts
|
|
1643
1946
|
async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
|
|
1644
1947
|
const result = new Map;
|
|
@@ -1713,6 +2016,10 @@ function buildQuery(issueNumbers) {
|
|
|
1713
2016
|
}
|
|
1714
2017
|
}`;
|
|
1715
2018
|
}
|
|
2019
|
+
// ../../packages/aeg-forge-state/src/list-issue-milestones.ts
|
|
2020
|
+
function issueMilestonesFromIssues(issues) {
|
|
2021
|
+
return issues.filter((i) => i.state === "OPEN").map((i) => ({ issue: i.number, milestoneTitle: i.milestone?.title ?? null }));
|
|
2022
|
+
}
|
|
1716
2023
|
// ../../packages/aeg-forge-state/src/resolve-repo.ts
|
|
1717
2024
|
import { execFile as execFile3 } from "node:child_process";
|
|
1718
2025
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -1775,7 +2082,8 @@ var ANCHOR_FIELDS = [
|
|
|
1775
2082
|
"PREMISE",
|
|
1776
2083
|
"TEST-PLAN",
|
|
1777
2084
|
"EVIDENCE",
|
|
1778
|
-
"BEYOND-SURFACE"
|
|
2085
|
+
"BEYOND-SURFACE",
|
|
2086
|
+
"LIVE"
|
|
1779
2087
|
];
|
|
1780
2088
|
function anchoredRegionBounds(body, field) {
|
|
1781
2089
|
const masked = maskCode(body);
|
|
@@ -1976,7 +2284,6 @@ var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
|
1976
2284
|
// ../../packages/aeg-core/src/waiver-label.ts
|
|
1977
2285
|
var WAIVER_LABEL = label("waiver-docs");
|
|
1978
2286
|
var WAIVER_LABEL_REVIEW = label("waiver-review");
|
|
1979
|
-
var PRINCIPAL_ALLOWLIST = ["daniboomerang"];
|
|
1980
2287
|
function isPrincipal(login, principalAllowlist) {
|
|
1981
2288
|
if (login === null)
|
|
1982
2289
|
return false;
|
|
@@ -1995,6 +2302,14 @@ var RULING_ORDINAL_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Ruling ordinal:\s*(\d+)(
|
|
|
1995
2302
|
var BRIEF_HASH_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Brief hash:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1996
2303
|
var POLICY_DIGEST_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Policy digest:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1997
2304
|
var BASE_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged base:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
|
|
2305
|
+
var MANIFEST_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Manifest version:\s*(\d+)\s*$/im;
|
|
2306
|
+
var PAUSE_BOUND_RULING_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Pause-bound ruling:\s*(?:(\S+)\|(\S+)\|([0-9a-f]{64})|\(none\))\s*$/im;
|
|
2307
|
+
function extractPauseBoundRuling(comment) {
|
|
2308
|
+
const m = comment.match(PAUSE_BOUND_RULING_PATTERN);
|
|
2309
|
+
if (!m)
|
|
2310
|
+
return;
|
|
2311
|
+
return m[1] ? { rulingId: m[1], pauseId: m[2], contentDigest: m[3] } : null;
|
|
2312
|
+
}
|
|
1998
2313
|
function firstFiveLines(comment) {
|
|
1999
2314
|
return comment.split(`
|
|
2000
2315
|
`).slice(0, 5).join(`
|
|
@@ -2088,6 +2403,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2088
2403
|
danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
|
|
2089
2404
|
};
|
|
2090
2405
|
}
|
|
2406
|
+
const versionMatch = latest.match(MANIFEST_VERSION_PATTERN);
|
|
2407
|
+
const pauseBoundRuling = extractPauseBoundRuling(latest);
|
|
2091
2408
|
return {
|
|
2092
2409
|
value: m[1].toUpperCase().replace(/[_-]/g, " "),
|
|
2093
2410
|
headSha: extractHeadSha(latest),
|
|
@@ -2096,6 +2413,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2096
2413
|
briefHash: extractBriefHash(latest),
|
|
2097
2414
|
policyDigest: extractPolicyDigest(latest),
|
|
2098
2415
|
baseSha: extractBaseSha(latest),
|
|
2416
|
+
...versionMatch ? { manifestVersion: Number.parseInt(versionMatch[1], 10) } : {},
|
|
2417
|
+
...pauseBoundRuling === undefined ? {} : { pauseBoundRuling },
|
|
2099
2418
|
findingSeverities: extractFindingSeverities(latest),
|
|
2100
2419
|
danglingNote: null
|
|
2101
2420
|
};
|
|
@@ -2106,6 +2425,16 @@ function extractCodeReviewVerdict(comments) {
|
|
|
2106
2425
|
function extractSecurityReviewVerdict(comments) {
|
|
2107
2426
|
return extractVerdict(comments, /^[ \t]*(?:\*{1,3}|_{1,3})?VERDICT:\s*(PASS|FAIL)(?![A-Za-z0-9])/im, "security-review");
|
|
2108
2427
|
}
|
|
2428
|
+
|
|
2429
|
+
// ../../packages/aeg-core/src/review-status.ts
|
|
2430
|
+
var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-(\d+)\s*-->/i;
|
|
2431
|
+
function parseDeveloperRoundMarker(body) {
|
|
2432
|
+
const m = body.match(DEVELOPER_ROUND_MARKER);
|
|
2433
|
+
if (!m)
|
|
2434
|
+
return null;
|
|
2435
|
+
const n = Number(m[1]);
|
|
2436
|
+
return Number.isFinite(n) ? n : null;
|
|
2437
|
+
}
|
|
2109
2438
|
// ../../packages/aeg-core/src/report-tokens.ts
|
|
2110
2439
|
var DASH_LOOKALIKES = {
|
|
2111
2440
|
"-": "‑",
|
|
@@ -2801,14 +3130,14 @@ function checkTestPlan(prBody) {
|
|
|
2801
3130
|
const region = located.found ? located.section : prBody;
|
|
2802
3131
|
if (TEST_PLAN_UNIT_TESTS_ONLY_RE.test(region))
|
|
2803
3132
|
return { status: "pass", errors: [] };
|
|
2804
|
-
if (/\*\*\[(?:agent|principal)\]\*\*/.test(region))
|
|
3133
|
+
if (/\*\*\[(?:agent|principal|live)\]\*\*/.test(region))
|
|
2805
3134
|
return { status: "pass", errors: [] };
|
|
2806
3135
|
if (located.found && extractFencedBlocks(region).length > 0)
|
|
2807
3136
|
return { status: "pass", errors: [] };
|
|
2808
3137
|
return {
|
|
2809
3138
|
status: "fail",
|
|
2810
3139
|
errors: [
|
|
2811
|
-
"brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`-tagged
|
|
3140
|
+
"brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`/`**[live]**`-tagged item."
|
|
2812
3141
|
]
|
|
2813
3142
|
};
|
|
2814
3143
|
}
|
|
@@ -3430,6 +3759,375 @@ function checkPrReportDensity(prBody) {
|
|
|
3430
3759
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3431
3760
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3432
3761
|
}
|
|
3762
|
+
// ../../packages/aeg-core/src/prose-rules.ts
|
|
3763
|
+
var RETIRED_GLOBAL_EXEMPTIONS = [
|
|
3764
|
+
"docs/decisions-legacy.md",
|
|
3765
|
+
"apps/herald-ai/docs/",
|
|
3766
|
+
"apps/vada-ai/docs/",
|
|
3767
|
+
"aeg-root/tranches/completed/",
|
|
3768
|
+
"packages/aeg-core/src/docs/published-prose",
|
|
3769
|
+
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
3770
|
+
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
3771
|
+
"/fixtures/",
|
|
3772
|
+
"/node_modules/",
|
|
3773
|
+
"/.next/",
|
|
3774
|
+
"/.turbo/"
|
|
3775
|
+
];
|
|
3776
|
+
var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
|
|
3777
|
+
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
3778
|
+
var RETIRED_PATTERN_EXEMPTIONS = {
|
|
3779
|
+
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
3780
|
+
[String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
|
|
3781
|
+
"docs-index.md",
|
|
3782
|
+
"apps/vada-ai/specs/legacy/README.md",
|
|
3783
|
+
"apps/vada-ai/specs/vada-product-spec.md",
|
|
3784
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3785
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3786
|
+
],
|
|
3787
|
+
"decisions-legacy": [
|
|
3788
|
+
"packages/aeg-core/src/file-classify.ts",
|
|
3789
|
+
"packages/aeg-core/src/file-classify.test.ts",
|
|
3790
|
+
"packages/aeg-core/src/pr-tier.test.ts",
|
|
3791
|
+
"docs-index.md",
|
|
3792
|
+
".claude/skills/database/SKILL.md",
|
|
3793
|
+
".claude/skills/vada-architecture/SKILL.md",
|
|
3794
|
+
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
3795
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3796
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3797
|
+
],
|
|
3798
|
+
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
3799
|
+
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
3800
|
+
};
|
|
3801
|
+
var retiredPatterns = [
|
|
3802
|
+
String.raw`\bD-[0-9]{3}\b`,
|
|
3803
|
+
"D-(###|NNN|nnn|xxx)",
|
|
3804
|
+
"decision (entry|logged)",
|
|
3805
|
+
"decision-log entry",
|
|
3806
|
+
"decision log entry",
|
|
3807
|
+
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
3808
|
+
"decision-log",
|
|
3809
|
+
"decision entr",
|
|
3810
|
+
"decisions? (are |is )?logged",
|
|
3811
|
+
"log entries",
|
|
3812
|
+
String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
|
|
3813
|
+
"decisions-legacy",
|
|
3814
|
+
"CONTRADICTION",
|
|
3815
|
+
"assumes Tier 3",
|
|
3816
|
+
"Lock: ?YES",
|
|
3817
|
+
"Lock: ?NO",
|
|
3818
|
+
"lock approvals?",
|
|
3819
|
+
"approves locks",
|
|
3820
|
+
"Conforms to lock",
|
|
3821
|
+
"Challenges lock",
|
|
3822
|
+
"checkDecisionNumbersFresh",
|
|
3823
|
+
String.raw`roles/team-leader\.md`,
|
|
3824
|
+
String.raw`\(,`,
|
|
3825
|
+
String.raw`,\)`,
|
|
3826
|
+
String.raw`\(\.\)`,
|
|
3827
|
+
...PLAN_ON_DISK_PATTERNS
|
|
3828
|
+
];
|
|
3829
|
+
var published = [
|
|
3830
|
+
["decision-id", "a decision id", /\bD-\d{3,}\b/],
|
|
3831
|
+
["section-ref", "a section reference", /§/],
|
|
3832
|
+
["forge-number", "a forge number", /#\d+/],
|
|
3833
|
+
["retired-name", "the retired public name", /\bAEG\b/],
|
|
3834
|
+
["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
|
|
3835
|
+
[
|
|
3836
|
+
"label-vocabulary",
|
|
3837
|
+
"forge label vocabulary",
|
|
3838
|
+
/(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
|
|
3839
|
+
],
|
|
3840
|
+
["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
|
|
3841
|
+
["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
|
|
3842
|
+
[
|
|
3843
|
+
"internal-path",
|
|
3844
|
+
"a repo-internal file",
|
|
3845
|
+
/(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
|
|
3846
|
+
]
|
|
3847
|
+
];
|
|
3848
|
+
var DEFAULT_PROSE_RULES = [
|
|
3849
|
+
{
|
|
3850
|
+
id: "forge-number",
|
|
3851
|
+
group: "reader-resolvable",
|
|
3852
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3853
|
+
patterns: { prose: /#[0-9]{2,4}/g },
|
|
3854
|
+
flags: ["global"],
|
|
3855
|
+
message: "a forge number",
|
|
3856
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3857
|
+
exemptions: []
|
|
3858
|
+
},
|
|
3859
|
+
{
|
|
3860
|
+
id: "tranche-slug",
|
|
3861
|
+
group: "reader-resolvable",
|
|
3862
|
+
scopes: ["ships", "reader-facing", "product", "spec"],
|
|
3863
|
+
patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
|
|
3864
|
+
flags: ["global"],
|
|
3865
|
+
message: "an internal tranche slug",
|
|
3866
|
+
severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
|
|
3867
|
+
exemptions: []
|
|
3868
|
+
},
|
|
3869
|
+
{
|
|
3870
|
+
id: "task-number",
|
|
3871
|
+
group: "reader-resolvable",
|
|
3872
|
+
scopes: ["spec"],
|
|
3873
|
+
patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
|
|
3874
|
+
flags: ["global", "ignore-case"],
|
|
3875
|
+
message: "a task number",
|
|
3876
|
+
severity: { spec: "error" },
|
|
3877
|
+
exemptions: []
|
|
3878
|
+
},
|
|
3879
|
+
{
|
|
3880
|
+
id: "source-comment-tranche-slug",
|
|
3881
|
+
group: "reader-resolvable",
|
|
3882
|
+
scopes: ["source-comment"],
|
|
3883
|
+
patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
|
|
3884
|
+
flags: ["global"],
|
|
3885
|
+
message: "a tranche-slug citation",
|
|
3886
|
+
severity: { "source-comment": "warning" },
|
|
3887
|
+
exemptions: []
|
|
3888
|
+
},
|
|
3889
|
+
{
|
|
3890
|
+
id: "source-comment-forge-number",
|
|
3891
|
+
group: "reader-resolvable",
|
|
3892
|
+
scopes: ["source-comment"],
|
|
3893
|
+
patterns: { comment: /#[0-9]{2,}/g },
|
|
3894
|
+
flags: ["global"],
|
|
3895
|
+
message: "a forge-number citation",
|
|
3896
|
+
severity: { "source-comment": "warning" },
|
|
3897
|
+
exemptions: []
|
|
3898
|
+
},
|
|
3899
|
+
{
|
|
3900
|
+
id: "legacy-batch-name",
|
|
3901
|
+
group: "reader-resolvable",
|
|
3902
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3903
|
+
patterns: {},
|
|
3904
|
+
flags: ["built-in"],
|
|
3905
|
+
message: "an internal tranche slug",
|
|
3906
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3907
|
+
exemptions: [],
|
|
3908
|
+
builtIn: true
|
|
3909
|
+
},
|
|
3910
|
+
{
|
|
3911
|
+
id: "coined-term",
|
|
3912
|
+
group: "reader-resolvable",
|
|
3913
|
+
scopes: ["ships", "reader-facing"],
|
|
3914
|
+
patterns: {},
|
|
3915
|
+
flags: ["built-in"],
|
|
3916
|
+
message: "uses coined term without defining it inline or linking the glossary",
|
|
3917
|
+
severity: { ships: "warning", "reader-facing": "warning" },
|
|
3918
|
+
exemptions: [],
|
|
3919
|
+
builtIn: true
|
|
3920
|
+
},
|
|
3921
|
+
...retiredPatterns.map((pattern, index) => ({
|
|
3922
|
+
id: `retired-vocabulary-${index + 1}`,
|
|
3923
|
+
group: "retired-vocabulary",
|
|
3924
|
+
scopes: ["repository"],
|
|
3925
|
+
patterns: { repository: pattern },
|
|
3926
|
+
flags: [],
|
|
3927
|
+
message: "retired vocabulary",
|
|
3928
|
+
severity: { repository: "error" },
|
|
3929
|
+
exemptions: RETIRED_GLOBAL_EXEMPTIONS,
|
|
3930
|
+
patternExemptions: RETIRED_PATTERN_EXEMPTIONS
|
|
3931
|
+
})),
|
|
3932
|
+
...published.map(([id, message, pattern]) => ({
|
|
3933
|
+
id,
|
|
3934
|
+
group: "published-prose",
|
|
3935
|
+
scopes: ["published"],
|
|
3936
|
+
patterns: { published: pattern },
|
|
3937
|
+
flags: [],
|
|
3938
|
+
message,
|
|
3939
|
+
severity: { published: "error" },
|
|
3940
|
+
exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
|
|
3941
|
+
}))
|
|
3942
|
+
];
|
|
3943
|
+
var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
|
|
3944
|
+
var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
|
|
3945
|
+
var RETIRED_SCOPES = ["repository"];
|
|
3946
|
+
var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
|
|
3947
|
+
function groupOfScope(scope) {
|
|
3948
|
+
if (RESOLVABLE_SCOPES.includes(scope))
|
|
3949
|
+
return "reader-resolvable";
|
|
3950
|
+
if (RETIRED_SCOPES.includes(scope))
|
|
3951
|
+
return "retired-vocabulary";
|
|
3952
|
+
return;
|
|
3953
|
+
}
|
|
3954
|
+
var CONFIGURED_PROSE_FLAGS = ["i", "u"];
|
|
3955
|
+
var CONFIGURED_PATTERN_MAX_LENGTH = 200;
|
|
3956
|
+
var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
|
|
3957
|
+
function allowedScopesFor(rule) {
|
|
3958
|
+
if (rule.builtIn)
|
|
3959
|
+
return rule.scopes;
|
|
3960
|
+
return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
|
|
3961
|
+
}
|
|
3962
|
+
function normalizeRepoPath(entry) {
|
|
3963
|
+
let out = entry.replace(/\\/g, "/");
|
|
3964
|
+
while (out.startsWith("./"))
|
|
3965
|
+
out = out.slice(2);
|
|
3966
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3967
|
+
while (out.endsWith("/"))
|
|
3968
|
+
out = out.slice(0, -1);
|
|
3969
|
+
return out;
|
|
3970
|
+
}
|
|
3971
|
+
function isConfiguredExempt(path, exempt, repoRoot) {
|
|
3972
|
+
if (exempt.length === 0)
|
|
3973
|
+
return false;
|
|
3974
|
+
const root = repoRoot === undefined ? undefined : normalizeRepoPath(repoRoot);
|
|
3975
|
+
let rel = normalizeRepoPath(path);
|
|
3976
|
+
if (root && rel.startsWith(`${root}/`))
|
|
3977
|
+
rel = rel.slice(root.length + 1);
|
|
3978
|
+
return exempt.some((entry) => {
|
|
3979
|
+
const e = normalizeRepoPath(entry);
|
|
3980
|
+
return rel === e || rel.startsWith(`${e}/`);
|
|
3981
|
+
});
|
|
3982
|
+
}
|
|
3983
|
+
function ruleReads(set, rule, path) {
|
|
3984
|
+
return !isConfiguredExempt(path, set.exempt, set.repoRoot) && !isConfiguredExempt(path, rule.exempt, set.repoRoot);
|
|
3985
|
+
}
|
|
3986
|
+
var RESOLVABLE_RUN_ORDER = [
|
|
3987
|
+
"forge-number",
|
|
3988
|
+
"tranche-slug",
|
|
3989
|
+
"legacy-batch-name",
|
|
3990
|
+
"task-number",
|
|
3991
|
+
"source-comment-tranche-slug",
|
|
3992
|
+
"source-comment-forge-number",
|
|
3993
|
+
"coined-term"
|
|
3994
|
+
];
|
|
3995
|
+
var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
|
|
3996
|
+
function scopeDefaultSeverity(scope, sourceCommentSeverity) {
|
|
3997
|
+
if (scope === "source-comment")
|
|
3998
|
+
return sourceCommentSeverity ?? "warning";
|
|
3999
|
+
if (scope === "repository")
|
|
4000
|
+
return "error";
|
|
4001
|
+
return "warning";
|
|
4002
|
+
}
|
|
4003
|
+
function applySeverity(scopes, base, setting) {
|
|
4004
|
+
const out = {};
|
|
4005
|
+
for (const scope of scopes) {
|
|
4006
|
+
const configured = typeof setting === "string" ? setting : setting?.[scope];
|
|
4007
|
+
const value = configured ?? base[scope];
|
|
4008
|
+
if (value !== undefined)
|
|
4009
|
+
out[scope] = value;
|
|
4010
|
+
}
|
|
4011
|
+
return out;
|
|
4012
|
+
}
|
|
4013
|
+
function defaultPatternFor(rule) {
|
|
4014
|
+
const cache = new Map;
|
|
4015
|
+
return (scope) => {
|
|
4016
|
+
if (cache.has(scope))
|
|
4017
|
+
return cache.get(scope) ?? null;
|
|
4018
|
+
const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
|
|
4019
|
+
const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
|
|
4020
|
+
cache.set(scope, compiled);
|
|
4021
|
+
return compiled;
|
|
4022
|
+
};
|
|
4023
|
+
}
|
|
4024
|
+
function customPatternFor(rule, global) {
|
|
4025
|
+
const cache = new Map;
|
|
4026
|
+
return (scope) => {
|
|
4027
|
+
if (cache.has(scope))
|
|
4028
|
+
return cache.get(scope) ?? null;
|
|
4029
|
+
const source = rule.patterns?.[scope] ?? rule.pattern;
|
|
4030
|
+
const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
|
|
4031
|
+
cache.set(scope, compiled);
|
|
4032
|
+
return compiled;
|
|
4033
|
+
};
|
|
4034
|
+
}
|
|
4035
|
+
function resolveProseRules(config = undefined, options = {}) {
|
|
4036
|
+
const rules = [];
|
|
4037
|
+
const defaults = config?.defaults ?? {};
|
|
4038
|
+
for (const rule of CONFIGURABLE_DEFAULT_RULES) {
|
|
4039
|
+
const override = defaults[rule.id];
|
|
4040
|
+
if (override === "off")
|
|
4041
|
+
continue;
|
|
4042
|
+
const group = rule.group;
|
|
4043
|
+
const scopes = override?.scopes ?? rule.scopes;
|
|
4044
|
+
const base = {};
|
|
4045
|
+
for (const scope of scopes) {
|
|
4046
|
+
base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4047
|
+
}
|
|
4048
|
+
rules.push({
|
|
4049
|
+
id: rule.id,
|
|
4050
|
+
group,
|
|
4051
|
+
custom: false,
|
|
4052
|
+
builtIn: rule.builtIn === true,
|
|
4053
|
+
scopes,
|
|
4054
|
+
message: rule.message,
|
|
4055
|
+
severity: applySeverity(scopes, base, override?.severity),
|
|
4056
|
+
exempt: override?.exempt ?? [],
|
|
4057
|
+
substringExempt: rule.exemptions,
|
|
4058
|
+
reportGroup: REPORT_GROUPS[rule.id],
|
|
4059
|
+
patternFor: defaultPatternFor(rule)
|
|
4060
|
+
});
|
|
4061
|
+
}
|
|
4062
|
+
for (const rule of config?.custom ?? []) {
|
|
4063
|
+
const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
|
|
4064
|
+
const base = {};
|
|
4065
|
+
for (const scope of rule.scopes)
|
|
4066
|
+
base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4067
|
+
rules.push({
|
|
4068
|
+
id: rule.id,
|
|
4069
|
+
group,
|
|
4070
|
+
custom: true,
|
|
4071
|
+
builtIn: false,
|
|
4072
|
+
scopes: rule.scopes,
|
|
4073
|
+
message: rule.means,
|
|
4074
|
+
severity: applySeverity(rule.scopes, base, rule.severity),
|
|
4075
|
+
exempt: rule.exempt ?? [],
|
|
4076
|
+
substringExempt: [],
|
|
4077
|
+
patternFor: customPatternFor(rule, group === "reader-resolvable")
|
|
4078
|
+
});
|
|
4079
|
+
}
|
|
4080
|
+
if (options.decisionRecordsPath !== undefined)
|
|
4081
|
+
rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
|
|
4082
|
+
const order = (rule) => {
|
|
4083
|
+
const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
|
|
4084
|
+
return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
|
|
4085
|
+
};
|
|
4086
|
+
const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
|
|
4087
|
+
const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
|
|
4088
|
+
return {
|
|
4089
|
+
rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
|
|
4090
|
+
exempt: config?.exempt ?? [],
|
|
4091
|
+
repoRoot: options.repoRoot
|
|
4092
|
+
};
|
|
4093
|
+
}
|
|
4094
|
+
function rulesOfGroup(set, group) {
|
|
4095
|
+
return set.rules.filter((rule) => rule.group === group);
|
|
4096
|
+
}
|
|
4097
|
+
function rulesInScope(set, scope) {
|
|
4098
|
+
return set.rules.filter((rule) => rule.scopes.includes(scope));
|
|
4099
|
+
}
|
|
4100
|
+
var DEFAULT_PROSE_RULE_SET = resolveProseRules();
|
|
4101
|
+
var DECISION_RECORD_CITATION_ID = "decision-record-citation";
|
|
4102
|
+
var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
|
|
4103
|
+
var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
|
|
4104
|
+
function escapeRegExp(text) {
|
|
4105
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4106
|
+
}
|
|
4107
|
+
function decisionRecordCitationPattern(decisionRecordsPath) {
|
|
4108
|
+
const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
|
|
4109
|
+
return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
|
|
4110
|
+
}
|
|
4111
|
+
function decisionRecordCitationRule(decisionRecordsPath) {
|
|
4112
|
+
const folder = normalizeRepoPath(decisionRecordsPath);
|
|
4113
|
+
const pattern = decisionRecordCitationPattern(folder);
|
|
4114
|
+
const severity = {};
|
|
4115
|
+
for (const scope of DECISION_RECORD_CITATION_SCOPES)
|
|
4116
|
+
severity[scope] = "error";
|
|
4117
|
+
return {
|
|
4118
|
+
id: DECISION_RECORD_CITATION_ID,
|
|
4119
|
+
group: "reader-resolvable",
|
|
4120
|
+
custom: false,
|
|
4121
|
+
builtIn: false,
|
|
4122
|
+
scopes: DECISION_RECORD_CITATION_SCOPES,
|
|
4123
|
+
message: DECISION_RECORD_CITATION_MESSAGE,
|
|
4124
|
+
severity,
|
|
4125
|
+
exempt: [folder],
|
|
4126
|
+
substringExempt: [],
|
|
4127
|
+
patternFor: () => pattern
|
|
4128
|
+
};
|
|
4129
|
+
}
|
|
4130
|
+
|
|
3433
4131
|
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3434
4132
|
var PRODUCT_SLUG_SCOPE = [
|
|
3435
4133
|
"apps/cli/src",
|
|
@@ -3441,8 +4139,8 @@ var PRODUCT_SLUG_SCOPE = [
|
|
|
3441
4139
|
function isUnderOrEqual(path, prefix) {
|
|
3442
4140
|
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3443
4141
|
}
|
|
3444
|
-
function isProductScopeFile(path) {
|
|
3445
|
-
return
|
|
4142
|
+
function isProductScopeFile(path, productPaths) {
|
|
4143
|
+
return productPaths.some((prefix) => isUnderOrEqual(path, normalizeRepoPath(prefix)));
|
|
3446
4144
|
}
|
|
3447
4145
|
var SHIPS_PREFIX = "aeg-root/";
|
|
3448
4146
|
function shipsArchivePrefix(shipsPrefix) {
|
|
@@ -3450,13 +4148,7 @@ function shipsArchivePrefix(shipsPrefix) {
|
|
|
3450
4148
|
}
|
|
3451
4149
|
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3452
4150
|
function normalizeSpecPath(entry) {
|
|
3453
|
-
|
|
3454
|
-
while (out.startsWith("./"))
|
|
3455
|
-
out = out.slice(2);
|
|
3456
|
-
out = out.replace(/\/{2,}/g, "/");
|
|
3457
|
-
while (out.endsWith("/"))
|
|
3458
|
-
out = out.slice(0, -1);
|
|
3459
|
-
return out;
|
|
4151
|
+
return normalizeRepoPath(entry);
|
|
3460
4152
|
}
|
|
3461
4153
|
function isSpecFile2(path, specPaths) {
|
|
3462
4154
|
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
@@ -3468,7 +4160,7 @@ function isSpecFile2(path, specPaths) {
|
|
|
3468
4160
|
function isClaudeMdFile(path) {
|
|
3469
4161
|
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3470
4162
|
}
|
|
3471
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4163
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS, productPaths = PRODUCT_SLUG_SCOPE) {
|
|
3472
4164
|
if (path.startsWith(shipsPrefix)) {
|
|
3473
4165
|
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3474
4166
|
}
|
|
@@ -3479,7 +4171,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
|
|
|
3479
4171
|
return "internal";
|
|
3480
4172
|
if (isSpecFile2(path, specPaths))
|
|
3481
4173
|
return "spec";
|
|
3482
|
-
if (isProductScopeFile(path))
|
|
4174
|
+
if (isProductScopeFile(path, productPaths))
|
|
3483
4175
|
return "product";
|
|
3484
4176
|
return null;
|
|
3485
4177
|
}
|
|
@@ -3504,9 +4196,16 @@ function lineAt(content, index) {
|
|
|
3504
4196
|
}
|
|
3505
4197
|
return line;
|
|
3506
4198
|
}
|
|
3507
|
-
var
|
|
3508
|
-
var
|
|
3509
|
-
|
|
4199
|
+
var readerRules = rulesForGroup("reader-resolvable");
|
|
4200
|
+
var readerPattern = (id, scope = "prose") => {
|
|
4201
|
+
const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
|
|
4202
|
+
if (!(pattern instanceof RegExp))
|
|
4203
|
+
throw new Error(`default prose rule ${id} has no ${scope} pattern`);
|
|
4204
|
+
return pattern;
|
|
4205
|
+
};
|
|
4206
|
+
var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
|
|
4207
|
+
var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
|
|
4208
|
+
var TASK_NUMBER_PATTERN = readerPattern("task-number");
|
|
3510
4209
|
function legacySlugPattern(legacySlugs) {
|
|
3511
4210
|
if (legacySlugs.length === 0)
|
|
3512
4211
|
return null;
|
|
@@ -3516,48 +4215,61 @@ function legacySlugPattern(legacySlugs) {
|
|
|
3516
4215
|
function specGrandfatherPaths(specGrandfather) {
|
|
3517
4216
|
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
|
|
3518
4217
|
}
|
|
3519
|
-
|
|
4218
|
+
var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
|
|
4219
|
+
function referenceRulesFor(set, cls) {
|
|
4220
|
+
return rulesInScope(set, cls).filter((rule) => rule.group === "reader-resolvable" && rule.id !== "coined-term");
|
|
4221
|
+
}
|
|
4222
|
+
function citations(pattern, text, group) {
|
|
4223
|
+
const out = [];
|
|
4224
|
+
const re = pattern.global ? pattern : new RegExp(pattern.source, `${pattern.flags}g`);
|
|
4225
|
+
re.lastIndex = 0;
|
|
4226
|
+
let match = re.exec(text);
|
|
4227
|
+
while (match !== null) {
|
|
4228
|
+
if (match[0] === "") {
|
|
4229
|
+
re.lastIndex++;
|
|
4230
|
+
} else {
|
|
4231
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4232
|
+
out.push({ cited, index: match.index + match[0].indexOf(cited) });
|
|
4233
|
+
}
|
|
4234
|
+
match = re.exec(text);
|
|
4235
|
+
}
|
|
4236
|
+
re.lastIndex = 0;
|
|
4237
|
+
return out;
|
|
4238
|
+
}
|
|
4239
|
+
function customMessage(rule, cited) {
|
|
4240
|
+
return `${rule.id}: ${rule.message} ("${cited}")`;
|
|
4241
|
+
}
|
|
4242
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
4243
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4244
|
+
const productPaths = options.productPaths ?? PRODUCT_SLUG_SCOPE;
|
|
3520
4245
|
const findings = [];
|
|
3521
4246
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3522
4247
|
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
|
|
3523
4248
|
const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
|
|
3524
|
-
const patterns = [
|
|
3525
|
-
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3526
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3527
|
-
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3528
|
-
];
|
|
3529
|
-
const productPatterns = [
|
|
3530
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3531
|
-
];
|
|
3532
|
-
const specPatterns = [
|
|
3533
|
-
...patterns,
|
|
3534
|
-
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3535
|
-
];
|
|
3536
4249
|
for (const file of files) {
|
|
3537
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3538
|
-
if (!cls || cls
|
|
3539
|
-
continue;
|
|
3540
|
-
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
4250
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths, productPaths);
|
|
4251
|
+
if (!cls || !REFERENCE_CLASSES.has(cls))
|
|
3541
4252
|
continue;
|
|
3542
4253
|
if (cls === "spec" && grandfatheredWhole.has(file.path))
|
|
3543
4254
|
continue;
|
|
3544
|
-
const blocking = cls === "product" || cls === "spec";
|
|
3545
4255
|
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3546
|
-
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3547
4256
|
const fileFindings = [];
|
|
3548
|
-
for (const
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
4257
|
+
for (const rule of referenceRulesFor(set, cls)) {
|
|
4258
|
+
if (!ruleReads(set, rule, file.path))
|
|
4259
|
+
continue;
|
|
4260
|
+
const pattern = !rule.custom && rule.id === "legacy-batch-name" ? legacyPattern : rule.patternFor(cls);
|
|
4261
|
+
if (!pattern)
|
|
4262
|
+
continue;
|
|
4263
|
+
const blocking = rule.severity[cls] === "error";
|
|
4264
|
+
const what = cls === "product" ? `${rule.message} in product code` : rule.message;
|
|
4265
|
+
for (const { cited, index } of citations(pattern, scrubbed, rule.custom ? undefined : rule.reportGroup)) {
|
|
3554
4266
|
fileFindings.push({
|
|
3555
4267
|
file: file.path,
|
|
3556
|
-
line: lineAt(scrubbed,
|
|
3557
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3558
|
-
blocking
|
|
4268
|
+
line: lineAt(scrubbed, index),
|
|
4269
|
+
message: rule.custom ? customMessage(rule, cited) : `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4270
|
+
blocking,
|
|
4271
|
+
rule: rule.id
|
|
3559
4272
|
});
|
|
3560
|
-
match = pattern.exec(scrubbed);
|
|
3561
4273
|
}
|
|
3562
4274
|
}
|
|
3563
4275
|
const limit = cls === "spec" ? limits.get(file.path) : undefined;
|
|
@@ -3598,11 +4310,17 @@ function definesOrLinksGlossary(content, term) {
|
|
|
3598
4310
|
return true;
|
|
3599
4311
|
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3600
4312
|
}
|
|
3601
|
-
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4313
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, options = {}) {
|
|
3602
4314
|
const findings = [];
|
|
4315
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4316
|
+
const rule = set.rules.find((r) => !r.custom && r.id === "coined-term");
|
|
4317
|
+
if (!rule)
|
|
4318
|
+
return findings;
|
|
3603
4319
|
for (const file of files) {
|
|
3604
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3605
|
-
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
4320
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, DEFAULT_SPEC_PATHS, options.productPaths);
|
|
4321
|
+
if (!cls || !SWEPT_CLASSES.has(cls) || !rule.scopes.includes(cls))
|
|
4322
|
+
continue;
|
|
4323
|
+
if (!ruleReads(set, rule, file.path))
|
|
3606
4324
|
continue;
|
|
3607
4325
|
const scrubbed = stripNonProse(file.path, file.content);
|
|
3608
4326
|
for (const term of glossaryTerms) {
|
|
@@ -3615,14 +4333,15 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
|
|
|
3615
4333
|
file: file.path,
|
|
3616
4334
|
line,
|
|
3617
4335
|
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3618
|
-
blocking:
|
|
4336
|
+
blocking: rule.severity[cls] === "error",
|
|
4337
|
+
rule: rule.id
|
|
3619
4338
|
});
|
|
3620
4339
|
}
|
|
3621
4340
|
}
|
|
3622
4341
|
return findings;
|
|
3623
4342
|
}
|
|
3624
|
-
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN =
|
|
3625
|
-
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN =
|
|
4343
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
|
|
4344
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
|
|
3626
4345
|
function extractComments(path, content) {
|
|
3627
4346
|
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3628
4347
|
return content.replace(/[^\n]/g, "");
|
|
@@ -3719,39 +4438,40 @@ function extractComments(path, content) {
|
|
|
3719
4438
|
}
|
|
3720
4439
|
return out;
|
|
3721
4440
|
}
|
|
3722
|
-
function checkSourceComments(files, allowlist = []) {
|
|
4441
|
+
function checkSourceComments(files, allowlist = [], options = {}) {
|
|
3723
4442
|
const findings = [];
|
|
3724
4443
|
const allowed = new Set(allowlist);
|
|
3725
|
-
const
|
|
3726
|
-
|
|
3727
|
-
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3728
|
-
];
|
|
4444
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4445
|
+
const rules = rulesInScope(set, "source-comment").filter((rule) => rule.group === "reader-resolvable");
|
|
3729
4446
|
for (const file of files) {
|
|
3730
4447
|
if (!file.path.endsWith(".ts"))
|
|
3731
4448
|
continue;
|
|
3732
4449
|
if (allowed.has(file.path))
|
|
3733
4450
|
continue;
|
|
3734
4451
|
const comments = extractComments(file.path, file.content);
|
|
3735
|
-
for (const
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
4452
|
+
for (const rule of rules) {
|
|
4453
|
+
if (!ruleReads(set, rule, file.path))
|
|
4454
|
+
continue;
|
|
4455
|
+
const pattern = rule.patternFor("source-comment");
|
|
4456
|
+
if (!pattern)
|
|
4457
|
+
continue;
|
|
4458
|
+
for (const { cited, index } of citations(pattern, comments)) {
|
|
3739
4459
|
findings.push({
|
|
3740
4460
|
file: file.path,
|
|
3741
|
-
line: lineAt(comments,
|
|
3742
|
-
message: `comment cites ${
|
|
3743
|
-
blocking:
|
|
4461
|
+
line: lineAt(comments, index),
|
|
4462
|
+
message: rule.custom ? customMessage(rule, cited) : `comment cites ${rule.message} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4463
|
+
blocking: rule.severity["source-comment"] === "error",
|
|
4464
|
+
rule: rule.id
|
|
3744
4465
|
});
|
|
3745
|
-
match = pattern.exec(comments);
|
|
3746
4466
|
}
|
|
3747
4467
|
}
|
|
3748
4468
|
}
|
|
3749
4469
|
return findings;
|
|
3750
4470
|
}
|
|
3751
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4471
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
3752
4472
|
return [
|
|
3753
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3754
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4473
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths, options),
|
|
4474
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix, options)
|
|
3755
4475
|
];
|
|
3756
4476
|
}
|
|
3757
4477
|
function parseGlossaryTerms(glossaryContent) {
|
|
@@ -3954,6 +4674,17 @@ function checkDocClaims(files, fileReader) {
|
|
|
3954
4674
|
};
|
|
3955
4675
|
}
|
|
3956
4676
|
|
|
4677
|
+
// ../../packages/aeg-core/src/protected-paths.ts
|
|
4678
|
+
import { posix as posixPath } from "node:path";
|
|
4679
|
+
var PROTECTED_ADMIN_PATHS = ["vinaya.config.json", ".vinaya/doc-owners", ".github/", "aeg-root/"];
|
|
4680
|
+
function normalizeTouchedPath(path) {
|
|
4681
|
+
return posixPath.resolve("/", path.replace(/\\/g, "/")).replace(/^\/+/, "");
|
|
4682
|
+
}
|
|
4683
|
+
function isProtectedAdminPath(path) {
|
|
4684
|
+
const normalized = normalizeTouchedPath(path);
|
|
4685
|
+
return PROTECTED_ADMIN_PATHS.some((prefix) => normalized === prefix || normalized.startsWith(prefix));
|
|
4686
|
+
}
|
|
4687
|
+
|
|
3957
4688
|
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3958
4689
|
function hasRationaleField(body, labelPattern) {
|
|
3959
4690
|
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
@@ -4073,13 +4804,20 @@ function globCoversPath(glob, path) {
|
|
|
4073
4804
|
return !p.includes("/");
|
|
4074
4805
|
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
4075
4806
|
}
|
|
4807
|
+
function surfaceEntryResolves(entry, resolvesToFile, pinnedFiles) {
|
|
4808
|
+
if (resolvesToFile(entry))
|
|
4809
|
+
return true;
|
|
4810
|
+
const directory = entry.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
4811
|
+
return pinnedFiles.some((path) => path.startsWith(`${directory}/`));
|
|
4812
|
+
}
|
|
4076
4813
|
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
4077
4814
|
const surface = parseIssueSurface(body);
|
|
4078
4815
|
if (!surface.ok)
|
|
4079
4816
|
return { status: "pass", errors: [] };
|
|
4817
|
+
const pinnedFiles = boundaryPinnedFiles(body);
|
|
4080
4818
|
const errors = [];
|
|
4081
4819
|
for (const glob of surface.value.in) {
|
|
4082
|
-
if (!
|
|
4820
|
+
if (!surfaceEntryResolves(glob, resolvesToFile, pinnedFiles)) {
|
|
4083
4821
|
errors.push(`issue-validation Surface: \`${glob}\` in \`## Surface\`'s \`in:\` list matches no tracked file — a Surface that cannot resolve cannot render a brief's file list.`);
|
|
4084
4822
|
}
|
|
4085
4823
|
}
|
|
@@ -4109,6 +4847,14 @@ function recordedBeyondSurfacePaths(body) {
|
|
|
4109
4847
|
return paths;
|
|
4110
4848
|
}
|
|
4111
4849
|
function checkSurfaceScope(changedFiles, surface, recorded) {
|
|
4850
|
+
for (const path of changedFiles) {
|
|
4851
|
+
if (!isProtectedAdminPath(path))
|
|
4852
|
+
continue;
|
|
4853
|
+
const normalized = normalizeTouchedPath(path);
|
|
4854
|
+
if (!surface.in.some((glob) => globCoversPath(glob, normalized))) {
|
|
4855
|
+
return { ok: false, violation: { path, reason: "protected" } };
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4112
4858
|
const listed = new Set(recorded);
|
|
4113
4859
|
const violation = beyondSurfacePaths(changedFiles, surface).find((entry) => !listed.has(entry.path));
|
|
4114
4860
|
return violation ? { ok: false, violation } : { ok: true };
|
|
@@ -4164,12 +4910,22 @@ function checkPartsCiteDefinedObjectives(body) {
|
|
|
4164
4910
|
}
|
|
4165
4911
|
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4166
4912
|
}
|
|
4913
|
+
var ISSUE_LIVE_LINE_RE = /^-\s*\*{2}\[live\]\*{2}(.*)$/gim;
|
|
4914
|
+
function liveCommand(text) {
|
|
4915
|
+
const trimmed = text.trim();
|
|
4916
|
+
const span = /^(`+)(.+)\1$/.exec(trimmed);
|
|
4917
|
+
return span ? span[2].trim() : trimmed;
|
|
4918
|
+
}
|
|
4919
|
+
function liveItemsIn(region) {
|
|
4920
|
+
return [...region.matchAll(ISSUE_LIVE_LINE_RE)].map((m) => liveCommand(m[1] ?? "")).filter(Boolean);
|
|
4921
|
+
}
|
|
4922
|
+
function parseLiveTestPlanItems(body) {
|
|
4923
|
+
const located = locateTestPlanSection(body);
|
|
4924
|
+
return located.found ? liveItemsIn(located.section) : [];
|
|
4925
|
+
}
|
|
4167
4926
|
function isTaskIssueLabelSet(labels) {
|
|
4168
4927
|
return hasLabel("tranche", labels);
|
|
4169
4928
|
}
|
|
4170
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
4171
|
-
return { status: "pass", errors: [] };
|
|
4172
|
-
}
|
|
4173
4929
|
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4174
4930
|
if (!isTaskIssueLabelSet(labels))
|
|
4175
4931
|
return { status: "pass", errors: [] };
|
|
@@ -4185,6 +4941,7 @@ function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTi
|
|
|
4185
4941
|
};
|
|
4186
4942
|
}
|
|
4187
4943
|
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4944
|
+
var PATH_TEXT = (body) => stripCode(body, { inlineSpans: "keep" });
|
|
4188
4945
|
function isControlCodePoint(codePoint) {
|
|
4189
4946
|
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4190
4947
|
}
|
|
@@ -4245,8 +5002,14 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
|
4245
5002
|
}
|
|
4246
5003
|
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4247
5004
|
}
|
|
5005
|
+
function rationaleFieldText(text, labelPattern) {
|
|
5006
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})[^\\n]*\\n?([\\s\\S]*?)(?=\\n\\s*(?:\\*\\*[A-Z]|#{1,4}\\s)|(?![\\s\\S]))`, "im");
|
|
5007
|
+
const m = re.exec(text);
|
|
5008
|
+
return m ? m[0] : "";
|
|
5009
|
+
}
|
|
4248
5010
|
var DOC_PATH_RE = /(?:(?:aeg-root|apps|packages|specs|docs|tools|\.claude|\.github)\/[\w./@-]*\.(?:md|mdx)|\.claude\/(?:skills|rules)\/[\w./-]+|\b(?:docs-index|decisions|projects|state-machine|enforcement|process|README|CLAUDE)\.md\b|\b[\w-]+-(?:spec|decisions|backlog)\.md\b)/i;
|
|
4249
5011
|
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
5012
|
+
var RATIONALE_PATH_RE_GLOBAL = /`([\w.@-]+(?:\/[\w.@-]+)+)`/g;
|
|
4250
5013
|
function normalizeEdgeId(s) {
|
|
4251
5014
|
const qualified = splitSlugQualifiedEdge(s);
|
|
4252
5015
|
return (qualified ? qualified.bareId : s).replace(/^#/, "").trim();
|
|
@@ -4254,6 +5017,15 @@ function normalizeEdgeId(s) {
|
|
|
4254
5017
|
function edgesNameEachOther(a, b) {
|
|
4255
5018
|
return a.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(b.ref)) || b.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(a.ref));
|
|
4256
5019
|
}
|
|
5020
|
+
var BOUNDARY_OUT_RE = /\bOut\s*:\s*([\s\S]*)$/im;
|
|
5021
|
+
function boundaryOutText(body) {
|
|
5022
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5023
|
+
const m = BOUNDARY_OUT_RE.exec(boundary);
|
|
5024
|
+
return m ? m[1] : "";
|
|
5025
|
+
}
|
|
5026
|
+
function namedPathsIn(text) {
|
|
5027
|
+
return [...new Set([...text.matchAll(RATIONALE_PATH_RE_GLOBAL)].map((m) => m[1]))].filter((p) => !/^https?:\/\//i.test(p));
|
|
5028
|
+
}
|
|
4257
5029
|
var FILE_EXTENSIONS = new Set([
|
|
4258
5030
|
"ts",
|
|
4259
5031
|
"tsx",
|
|
@@ -4275,6 +5047,11 @@ var FILE_EXTENSIONS = new Set([
|
|
|
4275
5047
|
"html",
|
|
4276
5048
|
"css"
|
|
4277
5049
|
]);
|
|
5050
|
+
function boundaryPinnedFiles(body) {
|
|
5051
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5052
|
+
const excluded = new Set(namedPathsIn(boundaryOutText(body)));
|
|
5053
|
+
return namedPathsIn(boundary).filter((p) => looksLikeFilePath(p) && !excluded.has(p));
|
|
5054
|
+
}
|
|
4278
5055
|
var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
|
|
4279
5056
|
var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
|
|
4280
5057
|
|
|
@@ -4299,7 +5076,7 @@ function isGrandfathered(isoDate) {
|
|
|
4299
5076
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4300
5077
|
}
|
|
4301
5078
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4302
|
-
function checkA1(entries, principalAllowlist
|
|
5079
|
+
function checkA1(entries, principalAllowlist) {
|
|
4303
5080
|
const failures = [];
|
|
4304
5081
|
for (const e of entries) {
|
|
4305
5082
|
if (!e.facts)
|
|
@@ -4329,6 +5106,37 @@ function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
|
4329
5106
|
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4330
5107
|
};
|
|
4331
5108
|
}
|
|
5109
|
+
function checkA2(entries, hasProvenanceByKey) {
|
|
5110
|
+
const failures = [];
|
|
5111
|
+
for (const e of entries) {
|
|
5112
|
+
if (!e.facts)
|
|
5113
|
+
continue;
|
|
5114
|
+
if (e.facts.issueState !== "closed" || e.facts.prState !== "merged")
|
|
5115
|
+
continue;
|
|
5116
|
+
const key = `${e.trancheSlug}/${e.task.id}`;
|
|
5117
|
+
const hasProvenance = hasProvenanceByKey.get(key);
|
|
5118
|
+
if (hasProvenance === undefined)
|
|
5119
|
+
continue;
|
|
5120
|
+
if (!hasProvenance) {
|
|
5121
|
+
failures.push({
|
|
5122
|
+
code: "archived-without-provenance",
|
|
5123
|
+
issue: e.task.issue,
|
|
5124
|
+
tranche: e.trancheSlug,
|
|
5125
|
+
task: e.task.id,
|
|
5126
|
+
reason: "Closing PR has no `### AEG provenance` comment (Archivist close-out missing)",
|
|
5127
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
5128
|
+
});
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
5132
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
5133
|
+
return {
|
|
5134
|
+
check: "A2",
|
|
5135
|
+
status,
|
|
5136
|
+
failures,
|
|
5137
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
5138
|
+
};
|
|
5139
|
+
}
|
|
4332
5140
|
function checkA3(entries) {
|
|
4333
5141
|
const failures = [];
|
|
4334
5142
|
for (const e of entries) {
|
|
@@ -4544,6 +5352,33 @@ function checkL1(files, entriesBySlug) {
|
|
|
4544
5352
|
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4545
5353
|
};
|
|
4546
5354
|
}
|
|
5355
|
+
function checkL2(files, entriesBySlug) {
|
|
5356
|
+
const failures = [];
|
|
5357
|
+
for (const f of files) {
|
|
5358
|
+
if (!f.archived)
|
|
5359
|
+
continue;
|
|
5360
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
5361
|
+
for (const e of entries) {
|
|
5362
|
+
if (!e.facts)
|
|
5363
|
+
continue;
|
|
5364
|
+
if (e.facts.issueState === "open") {
|
|
5365
|
+
failures.push({
|
|
5366
|
+
code: "premature-archive",
|
|
5367
|
+
issue: e.task.issue,
|
|
5368
|
+
tranche: f.slug,
|
|
5369
|
+
task: e.task.id,
|
|
5370
|
+
reason: `Archived tranche has open task-Issue #${e.task.issue ?? "?"} (premature archive)`
|
|
5371
|
+
});
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
return {
|
|
5376
|
+
check: "L2",
|
|
5377
|
+
status: "info",
|
|
5378
|
+
failures,
|
|
5379
|
+
note: failures.length > 0 ? `${failures.length} archived tranche(s) with an open task-Issue — investigate (advisory)` : undefined
|
|
5380
|
+
};
|
|
5381
|
+
}
|
|
4547
5382
|
function checkL3(files) {
|
|
4548
5383
|
const active = files.filter((f) => !f.archived);
|
|
4549
5384
|
return {
|
|
@@ -4553,6 +5388,51 @@ function checkL3(files) {
|
|
|
4553
5388
|
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4554
5389
|
};
|
|
4555
5390
|
}
|
|
5391
|
+
function checkL4(activeTrancheSlugs, issueMilestones) {
|
|
5392
|
+
const activeSet = new Set(activeTrancheSlugs);
|
|
5393
|
+
const failures = [];
|
|
5394
|
+
for (const f of issueMilestones) {
|
|
5395
|
+
if (!activeSet.has(f.tranche))
|
|
5396
|
+
continue;
|
|
5397
|
+
if (f.milestoneTitle === f.tranche)
|
|
5398
|
+
continue;
|
|
5399
|
+
failures.push({
|
|
5400
|
+
code: "milestone-drift",
|
|
5401
|
+
issue: f.issue,
|
|
5402
|
+
tranche: f.tranche,
|
|
5403
|
+
reason: f.milestoneTitle === null ? `Issue #${f.issue} carries ${trancheLabel(f.tranche)} (active) but has no GitHub-native milestone attached` : `Issue #${f.issue} carries ${trancheLabel(f.tranche)} (active) but is attached to Milestone "${f.milestoneTitle}" instead`
|
|
5404
|
+
});
|
|
5405
|
+
}
|
|
5406
|
+
return {
|
|
5407
|
+
check: "L4",
|
|
5408
|
+
status: "info",
|
|
5409
|
+
failures,
|
|
5410
|
+
note: failures.length > 0 ? `${failures.length} open task-Issue(s) in an active tranche whose GitHub-native milestone doesn't match their ${label("tranche")}<slug> label (cosmetic drift, advisory)` : undefined
|
|
5411
|
+
};
|
|
5412
|
+
}
|
|
5413
|
+
function checkL5(activeTrancheSlugs, entriesBySlug) {
|
|
5414
|
+
const failures = [];
|
|
5415
|
+
for (const slug of activeTrancheSlugs) {
|
|
5416
|
+
const entries = entriesBySlug.get(slug) ?? [];
|
|
5417
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
5418
|
+
if (withFacts.length === 0)
|
|
5419
|
+
continue;
|
|
5420
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
5421
|
+
if (allClosed) {
|
|
5422
|
+
failures.push({
|
|
5423
|
+
code: "tranche-not-archived",
|
|
5424
|
+
tranche: slug,
|
|
5425
|
+
reason: "Every task Issue is closed but the tranche is not recorded as complete — archive it"
|
|
5426
|
+
});
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
return {
|
|
5430
|
+
check: "L5",
|
|
5431
|
+
status: failures.length > 0 ? "fail" : "pass",
|
|
5432
|
+
failures,
|
|
5433
|
+
note: failures.length > 0 ? `${failures.length} tranche(s) whose task Issues are all closed but were never archived` : undefined
|
|
5434
|
+
};
|
|
5435
|
+
}
|
|
4556
5436
|
function extractClosesReferences(prBody) {
|
|
4557
5437
|
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4558
5438
|
const stripped = stripCode(prBody);
|
|
@@ -4648,6 +5528,58 @@ function extractIssue(body) {
|
|
|
4648
5528
|
}
|
|
4649
5529
|
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4650
5530
|
import { createHash as createHash4 } from "node:crypto";
|
|
5531
|
+
|
|
5532
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
5533
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
5534
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
5535
|
+
let best = 0;
|
|
5536
|
+
for (const c of comments) {
|
|
5537
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5538
|
+
continue;
|
|
5539
|
+
const firstLine = (c.body.split(`
|
|
5540
|
+
`)[0] ?? "").trim();
|
|
5541
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
5542
|
+
if (!m)
|
|
5543
|
+
continue;
|
|
5544
|
+
const k = Number.parseInt(m[1], 10);
|
|
5545
|
+
if (k > best)
|
|
5546
|
+
best = k;
|
|
5547
|
+
}
|
|
5548
|
+
return best;
|
|
5549
|
+
}
|
|
5550
|
+
function parseRulingIdentity(rulingId) {
|
|
5551
|
+
const m = /^(issue-)?(\d+)-(\d+)$/.exec(rulingId);
|
|
5552
|
+
if (!m)
|
|
5553
|
+
return null;
|
|
5554
|
+
const ref = Number.parseInt(m[2], 10);
|
|
5555
|
+
const ordinal = Number.parseInt(m[3], 10);
|
|
5556
|
+
if (ref <= 0 || ordinal <= 0)
|
|
5557
|
+
return null;
|
|
5558
|
+
return { target: m[1] ? "issue" : "pr", ref, ordinal };
|
|
5559
|
+
}
|
|
5560
|
+
function principalRulingTextById(comments, allowlist, rulingId) {
|
|
5561
|
+
const identity = parseRulingIdentity(rulingId);
|
|
5562
|
+
if (identity === null)
|
|
5563
|
+
return null;
|
|
5564
|
+
const matches = comments.filter((c) => {
|
|
5565
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5566
|
+
return false;
|
|
5567
|
+
const m = RULING_MARKER_ORDINAL.exec((c.body.split(`
|
|
5568
|
+
`)[0] ?? "").trim());
|
|
5569
|
+
return m !== null && Number.parseInt(m[1], 10) === identity.ordinal;
|
|
5570
|
+
});
|
|
5571
|
+
if (matches.length !== 1)
|
|
5572
|
+
return null;
|
|
5573
|
+
const body = matches[0].body;
|
|
5574
|
+
const idx = body.indexOf(`
|
|
5575
|
+
`);
|
|
5576
|
+
return idx === -1 ? "" : body.slice(idx + 1).trim();
|
|
5577
|
+
}
|
|
5578
|
+
|
|
5579
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
5580
|
+
function pauseBoundRulingDigest(rulingText) {
|
|
5581
|
+
return createHash4("sha256").update(rulingText).digest("hex");
|
|
5582
|
+
}
|
|
4651
5583
|
function briefHash(brief) {
|
|
4652
5584
|
return createHash4("sha256").update(`${brief}
|
|
4653
5585
|
`).digest("hex");
|
|
@@ -4708,14 +5640,19 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4708
5640
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4709
5641
|
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4710
5642
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
5643
|
+
const legacyCurrent = current.manifestVersion === undefined;
|
|
5644
|
+
const manifestVersion = legacyCurrent ? echoed.manifestVersion === undefined || echoed.manifestVersion === null : echoed.manifestVersion === current.manifestVersion;
|
|
5645
|
+
const pauseBoundRuling = legacyCurrent ? true : Object.hasOwn(echoed, "pauseBoundRuling") && JSON.stringify(echoed.pauseBoundRuling) === JSON.stringify(current.pauseBoundRuling);
|
|
4711
5646
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4712
5647
|
return {
|
|
4713
|
-
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
5648
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && pauseBoundRuling && manifestVersion && policyDigestBound,
|
|
4714
5649
|
head,
|
|
4715
5650
|
base,
|
|
4716
5651
|
briefHash: briefHashBound,
|
|
4717
5652
|
objectivesVersion,
|
|
4718
5653
|
rulingOrdinal,
|
|
5654
|
+
pauseBoundRuling,
|
|
5655
|
+
manifestVersion,
|
|
4719
5656
|
policyDigest: policyDigestBound
|
|
4720
5657
|
};
|
|
4721
5658
|
}
|
|
@@ -4731,7 +5668,7 @@ function renderGateDeferred(deferred) {
|
|
|
4731
5668
|
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4732
5669
|
}
|
|
4733
5670
|
function checkReviewGate(input) {
|
|
4734
|
-
const principalAllowlist = input
|
|
5671
|
+
const { principalAllowlist } = input;
|
|
4735
5672
|
const waived = isWaiverLabelActorVerified({
|
|
4736
5673
|
label: WAIVER_LABEL_REVIEW,
|
|
4737
5674
|
labels: input.labels,
|
|
@@ -4770,27 +5707,33 @@ function checkReviewGate(input) {
|
|
|
4770
5707
|
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4771
5708
|
const securityClean = securityTextClean && securityPolicyClean;
|
|
4772
5709
|
const currentManifest = {
|
|
5710
|
+
...input.manifestVersion === undefined ? {} : { manifestVersion: input.manifestVersion },
|
|
4773
5711
|
headSha: input.headSha,
|
|
4774
5712
|
baseSha: input.baseSha ?? null,
|
|
4775
5713
|
briefHash: input.briefHash ?? null,
|
|
4776
5714
|
objectivesVersion: input.objectivesVersion,
|
|
4777
5715
|
rulingOrdinal: input.rulingOrdinal,
|
|
5716
|
+
pauseBoundRuling: input.pauseBoundRuling ?? null,
|
|
4778
5717
|
policyDigest: policyDigest(policy)
|
|
4779
5718
|
};
|
|
4780
5719
|
const codeReviewEchoed = {
|
|
5720
|
+
manifestVersion: codeReview.manifestVersion,
|
|
4781
5721
|
headSha: codeReview.headSha,
|
|
4782
5722
|
baseSha: codeReview.baseSha,
|
|
4783
5723
|
briefHash: codeReview.briefHash,
|
|
4784
5724
|
objectivesVersion: codeReview.objectivesVersion,
|
|
4785
5725
|
rulingOrdinal: codeReview.rulingOrdinal,
|
|
5726
|
+
pauseBoundRuling: codeReview.pauseBoundRuling,
|
|
4786
5727
|
policyDigest: codeReview.policyDigest
|
|
4787
5728
|
};
|
|
4788
5729
|
const securityEchoed = {
|
|
5730
|
+
manifestVersion: security.manifestVersion,
|
|
4789
5731
|
headSha: security.headSha,
|
|
4790
5732
|
baseSha: security.baseSha,
|
|
4791
5733
|
briefHash: security.briefHash,
|
|
4792
5734
|
objectivesVersion: security.objectivesVersion,
|
|
4793
5735
|
rulingOrdinal: security.rulingOrdinal,
|
|
5736
|
+
pauseBoundRuling: security.pauseBoundRuling,
|
|
4794
5737
|
policyDigest: security.policyDigest
|
|
4795
5738
|
};
|
|
4796
5739
|
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
@@ -4829,6 +5772,10 @@ function checkReviewGate(input) {
|
|
|
4829
5772
|
problems.push(`the newest code-review verdict was cast against brief hash ${codeReview.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
|
|
4830
5773
|
} else if (!codeReviewBinding.policyDigest) {
|
|
4831
5774
|
problems.push(`the newest code-review verdict was cast against review policy digest ${codeReview.policyDigest ?? "none"}, this repository's current policy digest is ${currentManifest.policyDigest}`);
|
|
5775
|
+
} else if (!codeReviewBinding.manifestVersion) {
|
|
5776
|
+
problems.push(`the newest code-review verdict echoes manifest version ${codeReview.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5777
|
+
} else if (!codeReviewBinding.pauseBoundRuling) {
|
|
5778
|
+
problems.push(`the newest code-review verdict echoes pauseBoundRuling ${renderBinding(codeReview.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4832
5779
|
}
|
|
4833
5780
|
if (!securityTextClean) {
|
|
4834
5781
|
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
@@ -4846,6 +5793,10 @@ function checkReviewGate(input) {
|
|
|
4846
5793
|
problems.push(`the newest security-review verdict was cast against brief hash ${security.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
|
|
4847
5794
|
} else if (!securityBinding.policyDigest) {
|
|
4848
5795
|
problems.push(`the newest security-review verdict was cast against review policy digest ${security.policyDigest ?? "none"}, this repository's current policy digest is ${currentManifest.policyDigest}`);
|
|
5796
|
+
} else if (!securityBinding.manifestVersion) {
|
|
5797
|
+
problems.push(`the newest security-review verdict echoes manifest version ${security.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5798
|
+
} else if (!securityBinding.pauseBoundRuling) {
|
|
5799
|
+
problems.push(`the newest security-review verdict echoes pauseBoundRuling ${renderBinding(security.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4849
5800
|
}
|
|
4850
5801
|
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4851
5802
|
return {
|
|
@@ -4854,29 +5805,16 @@ function checkReviewGate(input) {
|
|
|
4854
5805
|
waived: false
|
|
4855
5806
|
};
|
|
4856
5807
|
}
|
|
5808
|
+
function renderBinding(binding) {
|
|
5809
|
+
if (binding === undefined)
|
|
5810
|
+
return "(absent)";
|
|
5811
|
+
return binding === null ? "(none)" : `${binding.rulingId}|${binding.pauseId}|${binding.contentDigest}`;
|
|
5812
|
+
}
|
|
4857
5813
|
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4858
5814
|
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4859
5815
|
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4860
5816
|
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4861
5817
|
}
|
|
4862
|
-
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4863
|
-
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4864
|
-
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4865
|
-
let best = 0;
|
|
4866
|
-
for (const c of comments) {
|
|
4867
|
-
if (!isPrincipal(c.author, allowlist))
|
|
4868
|
-
continue;
|
|
4869
|
-
const firstLine = (c.body.split(`
|
|
4870
|
-
`)[0] ?? "").trim();
|
|
4871
|
-
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4872
|
-
if (!m)
|
|
4873
|
-
continue;
|
|
4874
|
-
const k = Number.parseInt(m[1], 10);
|
|
4875
|
-
if (k > best)
|
|
4876
|
-
best = k;
|
|
4877
|
-
}
|
|
4878
|
-
return best;
|
|
4879
|
-
}
|
|
4880
5818
|
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4881
5819
|
function splitRow(line) {
|
|
4882
5820
|
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
@@ -5028,7 +5966,6 @@ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
|
5028
5966
|
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
5029
5967
|
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
5030
5968
|
"apps/cli/src/checks/bin/check-dead-branch-push.ts": 'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
|
|
5031
|
-
"apps/cli/src/checks/bin/check-issue-assignment.ts": `Ring 0 "A task branch's first push (Issue self-assignment)" (implementation: assign-task-issue.ts)`,
|
|
5032
5969
|
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
5033
5970
|
};
|
|
5034
5971
|
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
@@ -5252,72 +6189,10 @@ function compareToBaseline(current, baseline) {
|
|
|
5252
6189
|
};
|
|
5253
6190
|
}
|
|
5254
6191
|
// ../../packages/aeg-core/src/retired-vocabulary.ts
|
|
5255
|
-
var
|
|
5256
|
-
var RETIRED_PATTERNS =
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
"decision (entry|logged)",
|
|
5260
|
-
"decision-log entry",
|
|
5261
|
-
"decision log entry",
|
|
5262
|
-
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
5263
|
-
"decision-log",
|
|
5264
|
-
"decision entr",
|
|
5265
|
-
"decisions? (are |is )?logged",
|
|
5266
|
-
"log entries",
|
|
5267
|
-
String.raw`decisions\.md`,
|
|
5268
|
-
"decisions-legacy",
|
|
5269
|
-
"CONTRADICTION",
|
|
5270
|
-
"assumes Tier 3",
|
|
5271
|
-
"Lock: ?YES",
|
|
5272
|
-
"Lock: ?NO",
|
|
5273
|
-
"lock approvals?",
|
|
5274
|
-
"approves locks",
|
|
5275
|
-
"Conforms to lock",
|
|
5276
|
-
"Challenges lock",
|
|
5277
|
-
"checkDecisionNumbersFresh",
|
|
5278
|
-
String.raw`roles/team-leader\.md`,
|
|
5279
|
-
String.raw`\(,`,
|
|
5280
|
-
String.raw`,\)`,
|
|
5281
|
-
String.raw`\(\.\)`,
|
|
5282
|
-
...PLAN_ON_DISK_PATTERNS
|
|
5283
|
-
];
|
|
5284
|
-
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
5285
|
-
var RETIRED_EXEMPT_SUBSTRINGS = [
|
|
5286
|
-
"docs/decisions-legacy.md",
|
|
5287
|
-
"apps/herald-ai/docs/",
|
|
5288
|
-
"apps/vada-ai/docs/",
|
|
5289
|
-
"aeg-root/tranches/completed/",
|
|
5290
|
-
"packages/aeg-core/src/docs/published-prose",
|
|
5291
|
-
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
5292
|
-
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
5293
|
-
"/fixtures/",
|
|
5294
|
-
"/node_modules/",
|
|
5295
|
-
"/.next/",
|
|
5296
|
-
"/.turbo/"
|
|
5297
|
-
];
|
|
5298
|
-
var PATTERN_EXEMPT = {
|
|
5299
|
-
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
5300
|
-
[String.raw`decisions\.md`]: [
|
|
5301
|
-
"docs-index.md",
|
|
5302
|
-
"apps/vada-ai/specs/legacy/README.md",
|
|
5303
|
-
"apps/vada-ai/specs/vada-product-spec.md",
|
|
5304
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5305
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5306
|
-
],
|
|
5307
|
-
"decisions-legacy": [
|
|
5308
|
-
"packages/aeg-core/src/file-classify.ts",
|
|
5309
|
-
"packages/aeg-core/src/file-classify.test.ts",
|
|
5310
|
-
"packages/aeg-core/src/pr-tier.test.ts",
|
|
5311
|
-
"docs-index.md",
|
|
5312
|
-
".claude/skills/database/SKILL.md",
|
|
5313
|
-
".claude/skills/vada-architecture/SKILL.md",
|
|
5314
|
-
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
5315
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5316
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5317
|
-
],
|
|
5318
|
-
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
5319
|
-
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
5320
|
-
};
|
|
6192
|
+
var retiredRules = rulesForGroup("retired-vocabulary");
|
|
6193
|
+
var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
|
|
6194
|
+
var PATTERN_EXEMPT = RETIRED_PATTERN_EXEMPTIONS;
|
|
6195
|
+
var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
|
|
5321
6196
|
function lineNumbers(content, pattern) {
|
|
5322
6197
|
const out = [];
|
|
5323
6198
|
const lines = content.split(`
|
|
@@ -5328,22 +6203,29 @@ function lineNumbers(content, pattern) {
|
|
|
5328
6203
|
}
|
|
5329
6204
|
return out;
|
|
5330
6205
|
}
|
|
5331
|
-
function scanRetiredVocabulary(files) {
|
|
6206
|
+
function scanRetiredVocabulary(files, rules = DEFAULT_PROSE_RULE_SET) {
|
|
5332
6207
|
const findings = [];
|
|
6208
|
+
const retired = rulesOfGroup(rules, "retired-vocabulary");
|
|
5333
6209
|
for (const file of files) {
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
6210
|
+
for (const rule of retired) {
|
|
6211
|
+
if (rule.substringExempt.some((e) => file.path.includes(e)))
|
|
6212
|
+
continue;
|
|
6213
|
+
if (!ruleReads(rules, rule, file.path))
|
|
6214
|
+
continue;
|
|
6215
|
+
const re = rule.patternFor("repository");
|
|
6216
|
+
if (!re)
|
|
6217
|
+
continue;
|
|
6218
|
+
const pattern = rule.custom ? re.source : DEFAULT_PATTERN_OF.get(rule.id) ?? re.source;
|
|
6219
|
+
if (!rule.custom && (PATTERN_EXEMPT[pattern] ?? []).some((e) => file.path.includes(e)))
|
|
5339
6220
|
continue;
|
|
5340
|
-
const re = new RegExp(pattern);
|
|
5341
6221
|
for (const line of lineNumbers(file.content, re)) {
|
|
5342
6222
|
findings.push({
|
|
5343
6223
|
file: file.path,
|
|
5344
6224
|
line,
|
|
5345
6225
|
pattern,
|
|
5346
|
-
message: `claims a retired AEG mechanism is still live (matches /${pattern}/)
|
|
6226
|
+
message: rule.custom ? `${rule.id}: ${rule.message} (matches /${pattern}/)` : `claims a retired AEG mechanism is still live (matches /${pattern}/)`,
|
|
6227
|
+
rule: rule.id,
|
|
6228
|
+
blocking: rule.severity.repository === "error"
|
|
5347
6229
|
});
|
|
5348
6230
|
}
|
|
5349
6231
|
}
|
|
@@ -5367,7 +6249,7 @@ function isSelfDependency(dep, task, issue) {
|
|
|
5367
6249
|
function checkDispatchReadiness(input) {
|
|
5368
6250
|
const { trancheSlug, task } = input;
|
|
5369
6251
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
5370
|
-
const principalAllowlist = input
|
|
6252
|
+
const { principalAllowlist } = input;
|
|
5371
6253
|
const blockerDetails = [];
|
|
5372
6254
|
const push = (blockerClass, message) => {
|
|
5373
6255
|
blockerDetails.push({ class: blockerClass, message });
|
|
@@ -5459,6 +6341,16 @@ function pushesAnyBranchRef(pushRefs) {
|
|
|
5459
6341
|
return pushRefs.split(`
|
|
5460
6342
|
`).map((line) => line.trim()).filter((line) => line.length > 0).some((line) => line.split(/\s+/)[2]?.startsWith("refs/heads/") === true);
|
|
5461
6343
|
}
|
|
6344
|
+
function resolveDefaultBranch(facts) {
|
|
6345
|
+
const { originHead, hasOriginMain, hasOriginMaster } = facts;
|
|
6346
|
+
if (originHead !== null && originHead !== "")
|
|
6347
|
+
return originHead;
|
|
6348
|
+
if (hasOriginMain)
|
|
6349
|
+
return "main";
|
|
6350
|
+
if (hasOriginMaster)
|
|
6351
|
+
return "master";
|
|
6352
|
+
return null;
|
|
6353
|
+
}
|
|
5462
6354
|
function checkMainBranchRefusal(facts) {
|
|
5463
6355
|
const { currentSymbolicBranch, defaultBranch, pushRefs = null } = facts;
|
|
5464
6356
|
if (currentSymbolicBranch === null)
|
|
@@ -5719,54 +6611,61 @@ function checkFirstPushDispatchGate(input) {
|
|
|
5719
6611
|
reason: `verify-dispatch reports READY TO DISPATCH for \`${branch}\`.`
|
|
5720
6612
|
};
|
|
5721
6613
|
}
|
|
5722
|
-
// ../../packages/aeg-core/src/
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
6614
|
+
// ../../packages/aeg-core/src/live-record.ts
|
|
6615
|
+
var RECORD_LINE_RE = /^-\s*\[([ xX])\]\s*\*\*\[live\]\*\*\s+(`+) ?(.+?) ?\2(?!`)\s+—\s+(passed|failed|unverified)\s+at\s+`([^`]+)`/;
|
|
6616
|
+
function liveMarkers(body) {
|
|
6617
|
+
const masked = maskCode(body);
|
|
6618
|
+
return [...masked.matchAll(/<!--\s*AEG:LIVE:(?:START|END)\s*-->/g)].map((m) => ({
|
|
6619
|
+
start: m.index,
|
|
6620
|
+
end: m.index + m[0].length
|
|
6621
|
+
}));
|
|
6622
|
+
}
|
|
6623
|
+
var AMBIGUOUS_RECORD_LINE = {
|
|
6624
|
+
line: "- [ ] **[live]** the pull request body carries more than one `AEG:LIVE` marker pair, so the driver's record cannot be told apart",
|
|
6625
|
+
ticked: false,
|
|
6626
|
+
command: "",
|
|
6627
|
+
outcome: "failed",
|
|
6628
|
+
head: ""
|
|
6629
|
+
};
|
|
6630
|
+
function readLiveRecord(body) {
|
|
6631
|
+
const markers = liveMarkers(body).length;
|
|
6632
|
+
if (markers === 0)
|
|
6633
|
+
return [];
|
|
6634
|
+
if (markers !== 2)
|
|
6635
|
+
return [AMBIGUOUS_RECORD_LINE];
|
|
6636
|
+
const region = anchoredRegion(body, "LIVE");
|
|
6637
|
+
if (region === null)
|
|
6638
|
+
return [];
|
|
6639
|
+
const lines = [];
|
|
6640
|
+
for (const raw of region.split(`
|
|
6641
|
+
`)) {
|
|
6642
|
+
const line = raw.trim();
|
|
6643
|
+
const m = RECORD_LINE_RE.exec(line);
|
|
6644
|
+
if (!m)
|
|
6645
|
+
continue;
|
|
6646
|
+
lines.push({
|
|
6647
|
+
line,
|
|
6648
|
+
ticked: m[1].toLowerCase() === "x",
|
|
6649
|
+
command: m[3],
|
|
6650
|
+
outcome: m[4],
|
|
6651
|
+
head: m[5]
|
|
6652
|
+
});
|
|
5760
6653
|
}
|
|
5761
|
-
return
|
|
5762
|
-
action: "assign",
|
|
5763
|
-
issue,
|
|
5764
|
-
login,
|
|
5765
|
-
reason: `First push of \`${branch}\` — assigning Issue #${issue} to @${login} (the authenticated pusher).`
|
|
5766
|
-
};
|
|
6654
|
+
return lines;
|
|
5767
6655
|
}
|
|
5768
6656
|
// ../../packages/aeg-core/src/test-plan-gate.ts
|
|
5769
|
-
function
|
|
6657
|
+
function gradedLiveLines(record, live) {
|
|
6658
|
+
if (live === undefined)
|
|
6659
|
+
return record.map((entry) => entry.line);
|
|
6660
|
+
const commands = new Set(live.liveCommands);
|
|
6661
|
+
const others = record.filter((entry) => !commands.has(entry.command)).map((entry) => entry.line);
|
|
6662
|
+
const graded = live.liveCommands.map((command) => {
|
|
6663
|
+
const atHead = record.filter((entry) => entry.command === command && entry.head === live.head);
|
|
6664
|
+
return (atHead.find((entry) => entry.ticked) ?? atHead[0])?.line ?? `- [ ] **[live]** \`${command}\` — no passed run recorded at \`${live.head || "an unknown head"}\``;
|
|
6665
|
+
});
|
|
6666
|
+
return [...others, ...graded];
|
|
6667
|
+
}
|
|
6668
|
+
function evaluateTestPlanGate(body, branch, live) {
|
|
5770
6669
|
if (!body) {
|
|
5771
6670
|
return {
|
|
5772
6671
|
verdict: "pass",
|
|
@@ -5777,7 +6676,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5777
6676
|
};
|
|
5778
6677
|
}
|
|
5779
6678
|
const located = locateTestPlanSection(body);
|
|
5780
|
-
|
|
6679
|
+
const liveLines = gradedLiveLines(readLiveRecord(body), live);
|
|
6680
|
+
const liveUnticked = liveLines.some((line) => /^[-*]\s+\[\s\]/.test(line));
|
|
6681
|
+
if (!located.found && !liveUnticked) {
|
|
5781
6682
|
if (parseTaskBranchIdentity(branch) !== null) {
|
|
5782
6683
|
return {
|
|
5783
6684
|
verdict: "fail",
|
|
@@ -5797,15 +6698,18 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5797
6698
|
]
|
|
5798
6699
|
};
|
|
5799
6700
|
}
|
|
5800
|
-
const section = located.section;
|
|
5801
|
-
if (/unit-tests-only/i.test(section)) {
|
|
6701
|
+
const section = located.found ? located.section : "";
|
|
6702
|
+
if (/unit-tests-only/i.test(section) && !liveUnticked) {
|
|
5802
6703
|
return {
|
|
5803
6704
|
verdict: "pass",
|
|
5804
6705
|
messages: ["Test Plan: unit-tests-only — pure-logic brief, CI unit-tests are the proof.", "PASS."]
|
|
5805
6706
|
};
|
|
5806
6707
|
}
|
|
5807
|
-
const checkboxLines =
|
|
5808
|
-
|
|
6708
|
+
const checkboxLines = [
|
|
6709
|
+
...section.split(`
|
|
6710
|
+
`).map((line) => line.trimStart()).filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line)),
|
|
6711
|
+
...liveLines
|
|
6712
|
+
];
|
|
5809
6713
|
if (checkboxLines.length === 0) {
|
|
5810
6714
|
return {
|
|
5811
6715
|
verdict: "pass",
|
|
@@ -5822,7 +6726,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5822
6726
|
messages.push("", "FAIL — the following [principal] Test Plan items are unticked:");
|
|
5823
6727
|
for (const line of unchecked)
|
|
5824
6728
|
messages.push(` ${line}`);
|
|
5825
|
-
messages.push("", "Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.", "The Principal runs the item in a real signed-in browser and ticks the box.",
|
|
6729
|
+
messages.push("", "Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.", "The Principal runs the item in a real signed-in browser and ticks the box.", ...liveUnticked ? [
|
|
6730
|
+
"An unticked [live] line is a live run that failed or that the review loop could not verify on its host: a later head re-runs it, or the Principal runs it and ticks the box."
|
|
6731
|
+
] : [], "Note: editing the PR body does not retrigger most workflows. If your PR body changes do not surface here, push an empty commit to re-run.");
|
|
5826
6732
|
return { verdict: "fail", messages };
|
|
5827
6733
|
}
|
|
5828
6734
|
messages.push("All [principal] Test Plan items ticked — runtime verification complete.", "PASS.");
|
|
@@ -6011,9 +6917,11 @@ var LineageSchema = z3.object({
|
|
|
6011
6917
|
parent: z3.string().nullable()
|
|
6012
6918
|
}).strict();
|
|
6013
6919
|
var InputVersionsSchema = z3.object({
|
|
6920
|
+
manifest_version: z3.literal(2).nullable().optional(),
|
|
6014
6921
|
objectives_version: z3.string().nullable(),
|
|
6015
6922
|
brief_hash: z3.string().nullable(),
|
|
6016
6923
|
ruling_ordinal: z3.number().int().nullable(),
|
|
6924
|
+
pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
|
|
6017
6925
|
policy_digest: z3.string().nullable()
|
|
6018
6926
|
}).strict();
|
|
6019
6927
|
var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
@@ -6561,17 +7469,19 @@ function buildHeader(input) {
|
|
|
6561
7469
|
parent: lineageFieldFromEnv(input.env.parent)
|
|
6562
7470
|
},
|
|
6563
7471
|
input_versions: {
|
|
7472
|
+
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
6564
7473
|
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
6565
7474
|
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
6566
7475
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
7476
|
+
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
6567
7477
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
6568
7478
|
},
|
|
6569
7479
|
provenance: provenanceFor(input),
|
|
6570
7480
|
work: {
|
|
6571
7481
|
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
6572
7482
|
repo: input.repo,
|
|
6573
|
-
change: null,
|
|
6574
|
-
revision: null
|
|
7483
|
+
change: pr === undefined ? null : String(pr),
|
|
7484
|
+
revision: input.revision ?? null
|
|
6575
7485
|
},
|
|
6576
7486
|
flow: {
|
|
6577
7487
|
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
@@ -6759,6 +7669,12 @@ var ManifestRecordSchema = z4.object({
|
|
|
6759
7669
|
briefHash: z4.string().min(1).nullable(),
|
|
6760
7670
|
objectivesVersion: z4.string().min(1).nullable(),
|
|
6761
7671
|
rulingOrdinal: epochNumber,
|
|
7672
|
+
manifestVersion: z4.literal(2).optional(),
|
|
7673
|
+
pauseBoundRuling: z4.object({
|
|
7674
|
+
rulingId: z4.string().min(1),
|
|
7675
|
+
pauseId: z4.string().min(1),
|
|
7676
|
+
contentDigest: z4.string().min(1)
|
|
7677
|
+
}).strict().nullable().optional(),
|
|
6762
7678
|
policyDigest: z4.string().min(1),
|
|
6763
7679
|
recordedAt: isoTimestamp
|
|
6764
7680
|
}).strict();
|
|
@@ -6780,7 +7696,11 @@ var LoopStateRecordSchema = z4.object({
|
|
|
6780
7696
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6781
7697
|
repeatMemory: z4.object({
|
|
6782
7698
|
blockingFindings: z4.array(z4.string()),
|
|
6783
|
-
lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
|
|
7699
|
+
lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
|
|
7700
|
+
}).strict().optional(),
|
|
7701
|
+
developerHandoff: z4.object({
|
|
7702
|
+
findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
|
|
7703
|
+
failingChecks: z4.array(z4.string().min(1))
|
|
6784
7704
|
}).strict().optional(),
|
|
6785
7705
|
publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
6786
7706
|
taskStartedAt: isoTimestamp.optional(),
|
|
@@ -6838,8 +7758,8 @@ var ResolutionRecordSchema = z4.object({
|
|
|
6838
7758
|
// ../../packages/aeg-core/src/control-store/local.ts
|
|
6839
7759
|
var CONTROL_AREA_DIRNAME = "control";
|
|
6840
7760
|
// src/lib/diff-evidence.ts
|
|
6841
|
-
import { execFileSync as
|
|
6842
|
-
import { join as
|
|
7761
|
+
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
7762
|
+
import { join as join10, relative as relative2, resolve as resolve2 } from "node:path";
|
|
6843
7763
|
|
|
6844
7764
|
// src/lib/config.ts
|
|
6845
7765
|
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
@@ -6847,30 +7767,321 @@ import { promisify as promisify4 } from "node:util";
|
|
|
6847
7767
|
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
6848
7768
|
import { homedir } from "node:os";
|
|
6849
7769
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
6850
|
-
import { z as
|
|
7770
|
+
import { z as z6 } from "zod";
|
|
7771
|
+
|
|
7772
|
+
// src/checks/contract.ts
|
|
7773
|
+
var CHECK_SCHEMA_VERSION = 1;
|
|
7774
|
+
function emitCheckError(error) {
|
|
7775
|
+
process.stderr.write(`${JSON.stringify(error)}
|
|
7776
|
+
`);
|
|
7777
|
+
}
|
|
6851
7778
|
|
|
6852
7779
|
// src/lib/agent-vendors.ts
|
|
6853
7780
|
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
6854
7781
|
|
|
6855
|
-
// src/lib/config.ts
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
]
|
|
6862
|
-
var
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
7782
|
+
// src/lib/prose-rules-config.ts
|
|
7783
|
+
import safeRegex from "safe-regex2";
|
|
7784
|
+
import { z as z5 } from "zod";
|
|
7785
|
+
var SEVERITIES = ["error", "warning"];
|
|
7786
|
+
var OVERRIDE_KEYS = ["scopes", "severity", "exempt"];
|
|
7787
|
+
var FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
|
|
7788
|
+
var CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
|
|
7789
|
+
var DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
|
|
7790
|
+
function isPlainObject3(value) {
|
|
7791
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7792
|
+
}
|
|
7793
|
+
function outsideRepositoryReason(entry) {
|
|
7794
|
+
if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
|
|
7795
|
+
return "must be a repository-relative path, not an absolute one";
|
|
7796
|
+
if (entry.split(/[\\/]/).includes(".."))
|
|
7797
|
+
return "must stay inside the repository — no `..` segment";
|
|
7798
|
+
return null;
|
|
7799
|
+
}
|
|
7800
|
+
var RepoRelativePathSchema = z5.string().min(1).superRefine((entry, ctx) => {
|
|
7801
|
+
const reason = outsideRepositoryReason(entry);
|
|
7802
|
+
if (reason)
|
|
7803
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, message: reason });
|
|
7804
|
+
});
|
|
7805
|
+
function pathListIssues(value, path, issues) {
|
|
7806
|
+
if (!Array.isArray(value)) {
|
|
7807
|
+
issues.push({ path, message: "must be a list of repository-relative paths" });
|
|
7808
|
+
return;
|
|
7809
|
+
}
|
|
7810
|
+
value.forEach((entry, index) => {
|
|
7811
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
7812
|
+
issues.push({ path: [...path, index], message: "must be a non-empty repository-relative path" });
|
|
7813
|
+
return;
|
|
7814
|
+
}
|
|
7815
|
+
const reason = outsideRepositoryReason(entry);
|
|
7816
|
+
if (reason)
|
|
7817
|
+
issues.push({ path: [...path, index], message: reason });
|
|
7818
|
+
});
|
|
7819
|
+
}
|
|
7820
|
+
function scopeListIssues(value, path, allowed, issues) {
|
|
7821
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
7822
|
+
issues.push({ path, message: "must name at least one scope" });
|
|
7823
|
+
return null;
|
|
7824
|
+
}
|
|
7825
|
+
const scopes = [];
|
|
7826
|
+
value.forEach((scope, index) => {
|
|
7827
|
+
if (typeof scope !== "string" || !CONFIGURABLE_PROSE_SCOPES.includes(scope)) {
|
|
7828
|
+
issues.push({
|
|
7829
|
+
path: [...path, index],
|
|
7830
|
+
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(", ")}`
|
|
7831
|
+
});
|
|
7832
|
+
return;
|
|
7833
|
+
}
|
|
7834
|
+
if (!allowed.includes(scope)) {
|
|
7835
|
+
issues.push({
|
|
7836
|
+
path: [...path, index],
|
|
7837
|
+
message: `scope "${scope}" is not one this rule can run in — it can run in: ${allowed.join(", ")}`
|
|
7838
|
+
});
|
|
7839
|
+
return;
|
|
7840
|
+
}
|
|
7841
|
+
scopes.push(scope);
|
|
7842
|
+
});
|
|
7843
|
+
return scopes;
|
|
7844
|
+
}
|
|
7845
|
+
function severityIssues(value, path, scopes, issues) {
|
|
7846
|
+
if (typeof value === "string") {
|
|
7847
|
+
if (!SEVERITIES.includes(value)) {
|
|
7848
|
+
issues.push({ path, message: `unknown severity ${JSON.stringify(value)} — use "error" or "warning"` });
|
|
7849
|
+
}
|
|
7850
|
+
return;
|
|
7851
|
+
}
|
|
7852
|
+
if (!isPlainObject3(value)) {
|
|
7853
|
+
issues.push({ path, message: 'must be "error", "warning", or a map from scope to one of them' });
|
|
7854
|
+
return;
|
|
7855
|
+
}
|
|
7856
|
+
for (const [scope, severity] of Object.entries(value)) {
|
|
7857
|
+
if (!scopes.includes(scope)) {
|
|
7858
|
+
issues.push({ path: [...path, scope], message: `names scope "${scope}", which this rule's scopes do not cover` });
|
|
7859
|
+
}
|
|
7860
|
+
if (typeof severity !== "string" || !SEVERITIES.includes(severity)) {
|
|
7861
|
+
issues.push({
|
|
7862
|
+
path: [...path, scope],
|
|
7863
|
+
message: `unknown severity ${JSON.stringify(severity)} — use "error" or "warning"`
|
|
7864
|
+
});
|
|
7865
|
+
}
|
|
7866
|
+
}
|
|
7867
|
+
}
|
|
7868
|
+
function patternIssues(source, flags, path, issues) {
|
|
7869
|
+
if (typeof source !== "string" || source.length === 0) {
|
|
7870
|
+
issues.push({ path, message: "must be a non-empty regular expression" });
|
|
7871
|
+
return;
|
|
7872
|
+
}
|
|
7873
|
+
if (source.length > CONFIGURED_PATTERN_MAX_LENGTH) {
|
|
7874
|
+
issues.push({
|
|
7875
|
+
path,
|
|
7876
|
+
message: `is ${source.length} characters, over the ${CONFIGURED_PATTERN_MAX_LENGTH}-character limit for a configured pattern`
|
|
7877
|
+
});
|
|
7878
|
+
return;
|
|
7879
|
+
}
|
|
7880
|
+
try {
|
|
7881
|
+
new RegExp(source, flags);
|
|
7882
|
+
} catch (err) {
|
|
7883
|
+
issues.push({ path, message: `does not compile: ${err.message}` });
|
|
7884
|
+
return;
|
|
7885
|
+
}
|
|
7886
|
+
if (!safeRegex(source, { limit: Number.MAX_SAFE_INTEGER })) {
|
|
7887
|
+
issues.push({
|
|
7888
|
+
path,
|
|
7889
|
+
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."
|
|
7890
|
+
});
|
|
7891
|
+
}
|
|
7892
|
+
}
|
|
7893
|
+
function flagIssues(value, path, issues) {
|
|
7894
|
+
if (value === undefined)
|
|
7895
|
+
return "";
|
|
7896
|
+
if (typeof value !== "string") {
|
|
7897
|
+
issues.push({ path, message: 'must be a string of flags, e.g. "i"' });
|
|
7898
|
+
return "";
|
|
7899
|
+
}
|
|
7900
|
+
const seen = new Set;
|
|
7901
|
+
for (const flag of value) {
|
|
7902
|
+
if (!CONFIGURED_PROSE_FLAGS.includes(flag)) {
|
|
7903
|
+
issues.push({
|
|
7904
|
+
path,
|
|
7905
|
+
message: `unknown flag ${JSON.stringify(flag)} — only ${CONFIGURED_PROSE_FLAGS.map((f) => `"${f}"`).join(" and ")} are allowed`
|
|
7906
|
+
});
|
|
7907
|
+
return "";
|
|
7908
|
+
}
|
|
7909
|
+
if (seen.has(flag)) {
|
|
7910
|
+
issues.push({ path, message: `repeats the flag "${flag}"` });
|
|
7911
|
+
return "";
|
|
7912
|
+
}
|
|
7913
|
+
seen.add(flag);
|
|
7914
|
+
}
|
|
7915
|
+
return value;
|
|
7916
|
+
}
|
|
7917
|
+
function defaultsIssues(value, issues) {
|
|
7918
|
+
const base = ["defaults"];
|
|
7919
|
+
if (!isPlainObject3(value)) {
|
|
7920
|
+
issues.push({ path: base, message: 'must map a default rule id to "off" or an override' });
|
|
7921
|
+
return;
|
|
7922
|
+
}
|
|
7923
|
+
for (const [id, override] of Object.entries(value)) {
|
|
7924
|
+
const path = [...base, id];
|
|
7925
|
+
const rule = CONFIGURABLE_DEFAULT_RULES.find((candidate) => candidate.id === id);
|
|
7926
|
+
if (!rule) {
|
|
7927
|
+
issues.push({
|
|
7928
|
+
path,
|
|
7929
|
+
message: `unknown default rule id "${id}" — \`vinaya check --plan\` lists the rules each prose check runs`
|
|
7930
|
+
});
|
|
7931
|
+
continue;
|
|
7932
|
+
}
|
|
7933
|
+
if (override === "off")
|
|
7934
|
+
continue;
|
|
7935
|
+
if (!isPlainObject3(override)) {
|
|
7936
|
+
issues.push({ path, message: 'must be "off" or an object with any of scopes, severity, exempt' });
|
|
7937
|
+
continue;
|
|
7938
|
+
}
|
|
7939
|
+
for (const key of Object.keys(override)) {
|
|
7940
|
+
if (OVERRIDE_KEYS.includes(key))
|
|
7941
|
+
continue;
|
|
7942
|
+
issues.push({
|
|
7943
|
+
path: [...path, key],
|
|
7944
|
+
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`
|
|
7945
|
+
});
|
|
7946
|
+
}
|
|
7947
|
+
const scopes = override.scopes === undefined ? [...rule.scopes] : scopeListIssues(override.scopes, [...path, "scopes"], allowedScopesFor(rule), issues);
|
|
7948
|
+
if (override.severity !== undefined && scopes)
|
|
7949
|
+
severityIssues(override.severity, [...path, "severity"], scopes, issues);
|
|
7950
|
+
if (override.exempt !== undefined)
|
|
7951
|
+
pathListIssues(override.exempt, [...path, "exempt"], issues);
|
|
7952
|
+
}
|
|
7953
|
+
}
|
|
7954
|
+
function customIssues(value, issues) {
|
|
7955
|
+
if (!Array.isArray(value)) {
|
|
7956
|
+
issues.push({ path: ["custom"], message: "must be a list of rules" });
|
|
7957
|
+
return;
|
|
7958
|
+
}
|
|
7959
|
+
const ids = new Set;
|
|
7960
|
+
value.forEach((rule, index) => {
|
|
7961
|
+
const path = ["custom", index];
|
|
7962
|
+
if (!isPlainObject3(rule)) {
|
|
7963
|
+
issues.push({ path, message: "must be a rule object" });
|
|
7964
|
+
return;
|
|
7965
|
+
}
|
|
7966
|
+
for (const key of Object.keys(rule)) {
|
|
7967
|
+
if (!CUSTOM_KEYS.includes(key)) {
|
|
7968
|
+
issues.push({ path: [...path, key], message: `unknown key "${key}" — a rule takes ${CUSTOM_KEYS.join(", ")}` });
|
|
7969
|
+
}
|
|
7970
|
+
}
|
|
7971
|
+
if (typeof rule.id !== "string" || rule.id.length === 0) {
|
|
7972
|
+
issues.push({ path: [...path, "id"], message: "a custom rule needs an id" });
|
|
7973
|
+
} else if (DEFAULT_IDS.has(rule.id)) {
|
|
7974
|
+
issues.push({
|
|
7975
|
+
path: [...path, "id"],
|
|
7976
|
+
message: `"${rule.id}" is a default rule id — a custom rule needs its own id; retune the default under proseGates.rules.defaults instead`
|
|
7977
|
+
});
|
|
7978
|
+
} else if (ids.has(rule.id)) {
|
|
7979
|
+
issues.push({ path: [...path, "id"], message: `"${rule.id}" is used by an earlier custom rule` });
|
|
7980
|
+
} else {
|
|
7981
|
+
ids.add(rule.id);
|
|
7982
|
+
}
|
|
7983
|
+
if (typeof rule.means !== "string" || rule.means.trim().length === 0) {
|
|
7984
|
+
issues.push({ path: [...path, "means"], message: "a custom rule needs a message (`means`)" });
|
|
7985
|
+
}
|
|
7986
|
+
let scopes = null;
|
|
7987
|
+
if (rule.scopes === undefined) {
|
|
7988
|
+
issues.push({ path: [...path, "scopes"], message: "a custom rule needs at least one scope (`scopes`)" });
|
|
7989
|
+
} else {
|
|
7990
|
+
scopes = scopeListIssues(rule.scopes, [...path, "scopes"], CONFIGURABLE_PROSE_SCOPES, issues);
|
|
7991
|
+
}
|
|
7992
|
+
if (scopes && new Set(scopes.map(groupOfScope)).size > 1) {
|
|
7993
|
+
issues.push({
|
|
7994
|
+
path: [...path, "scopes"],
|
|
7995
|
+
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'
|
|
7996
|
+
});
|
|
7997
|
+
}
|
|
7998
|
+
const flags = flagIssues(rule.flags, [...path, "flags"], issues);
|
|
7999
|
+
if (rule.pattern === undefined && rule.patterns === undefined) {
|
|
8000
|
+
issues.push({
|
|
8001
|
+
path: [...path, "pattern"],
|
|
8002
|
+
message: "a custom rule needs a `pattern` or a per-scope `patterns` map"
|
|
8003
|
+
});
|
|
8004
|
+
}
|
|
8005
|
+
if (rule.pattern !== undefined)
|
|
8006
|
+
patternIssues(rule.pattern, flags, [...path, "pattern"], issues);
|
|
8007
|
+
if (rule.patterns !== undefined) {
|
|
8008
|
+
if (!isPlainObject3(rule.patterns)) {
|
|
8009
|
+
issues.push({ path: [...path, "patterns"], message: "must map a scope to a regular expression" });
|
|
8010
|
+
} else {
|
|
8011
|
+
for (const [scope, source] of Object.entries(rule.patterns)) {
|
|
8012
|
+
if (scopes && !scopes.includes(scope)) {
|
|
8013
|
+
issues.push({
|
|
8014
|
+
path: [...path, "patterns", scope],
|
|
8015
|
+
message: `names scope "${scope}", which this rule's scopes do not cover`
|
|
8016
|
+
});
|
|
8017
|
+
continue;
|
|
8018
|
+
}
|
|
8019
|
+
patternIssues(source, flags, [...path, "patterns", scope], issues);
|
|
8020
|
+
}
|
|
8021
|
+
if (rule.pattern === undefined && scopes) {
|
|
8022
|
+
for (const scope of scopes) {
|
|
8023
|
+
if (!(scope in rule.patterns)) {
|
|
8024
|
+
issues.push({
|
|
8025
|
+
path: [...path, "patterns"],
|
|
8026
|
+
message: `has no pattern for scope "${scope}" — add one, or a \`pattern\` every other scope uses`
|
|
8027
|
+
});
|
|
8028
|
+
}
|
|
8029
|
+
}
|
|
8030
|
+
}
|
|
8031
|
+
}
|
|
8032
|
+
}
|
|
8033
|
+
if (rule.severity !== undefined && scopes)
|
|
8034
|
+
severityIssues(rule.severity, [...path, "severity"], scopes, issues);
|
|
8035
|
+
if (rule.exempt !== undefined)
|
|
8036
|
+
pathListIssues(rule.exempt, [...path, "exempt"], issues);
|
|
8037
|
+
});
|
|
8038
|
+
}
|
|
8039
|
+
function proseRulesIssues(value) {
|
|
8040
|
+
const issues = [];
|
|
8041
|
+
if (!isPlainObject3(value))
|
|
8042
|
+
return [{ path: [], message: "must be an object with any of exempt, defaults, custom" }];
|
|
8043
|
+
for (const key of Object.keys(value)) {
|
|
8044
|
+
if (!["exempt", "defaults", "custom"].includes(key)) {
|
|
8045
|
+
issues.push({ path: [key], message: `unknown key "${key}" — proseGates.rules takes exempt, defaults and custom` });
|
|
8046
|
+
}
|
|
8047
|
+
}
|
|
8048
|
+
if (value.exempt !== undefined)
|
|
8049
|
+
pathListIssues(value.exempt, ["exempt"], issues);
|
|
8050
|
+
if (value.defaults !== undefined)
|
|
8051
|
+
defaultsIssues(value.defaults, issues);
|
|
8052
|
+
if (value.custom !== undefined)
|
|
8053
|
+
customIssues(value.custom, issues);
|
|
8054
|
+
return issues;
|
|
8055
|
+
}
|
|
8056
|
+
var ProseRulesSchema = z5.unknown().superRefine((value, ctx) => {
|
|
8057
|
+
for (const issue of proseRulesIssues(value)) {
|
|
8058
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: issue.path, message: issue.message });
|
|
8059
|
+
}
|
|
8060
|
+
}).transform((value) => value);
|
|
8061
|
+
var PublishedProseSchema = z5.object({
|
|
8062
|
+
allow: z5.array(z5.string().min(1)).optional()
|
|
8063
|
+
}).strict();
|
|
8064
|
+
|
|
8065
|
+
// src/lib/config.ts
|
|
8066
|
+
var EnvEntrySchema = z6.union([
|
|
8067
|
+
z6.literal(true),
|
|
8068
|
+
z6.object({ optional: z6.literal(true) }),
|
|
8069
|
+
z6.object({ anyOf: z6.array(z6.string()).min(2) }),
|
|
8070
|
+
z6.string()
|
|
8071
|
+
]);
|
|
8072
|
+
var CheckEntrySchema = z6.object({
|
|
8073
|
+
run: z6.string(),
|
|
8074
|
+
scope: z6.enum(["diff", "full"]),
|
|
8075
|
+
include: z6.array(z6.string()).optional(),
|
|
8076
|
+
args: z6.array(z6.string()).optional(),
|
|
8077
|
+
timeoutMs: z6.number().optional(),
|
|
8078
|
+
env: z6.record(z6.string(), EnvEntrySchema).optional(),
|
|
8079
|
+
requiresOpenPr: z6.boolean().optional(),
|
|
8080
|
+
ownWorkflow: z6.boolean().optional(),
|
|
8081
|
+
principalOwed: z6.literal(true).optional(),
|
|
8082
|
+
validates: z6.enum(["body", "issue"]).optional(),
|
|
8083
|
+
advisory: z6.literal(true).optional()
|
|
8084
|
+
}).superRefine((entry, ctx) => {
|
|
6874
8085
|
if (!entry.env)
|
|
6875
8086
|
return;
|
|
6876
8087
|
for (const [key, value] of Object.entries(entry.env)) {
|
|
@@ -6879,22 +8090,22 @@ var CheckEntrySchema = z5.object({
|
|
|
6879
8090
|
const members = value.anyOf;
|
|
6880
8091
|
if (new Set(members).size !== members.length) {
|
|
6881
8092
|
ctx.addIssue({
|
|
6882
|
-
code:
|
|
8093
|
+
code: z6.ZodIssueCode.custom,
|
|
6883
8094
|
message: `env.${key}.anyOf has duplicate members`,
|
|
6884
8095
|
path: ["env", key, "anyOf"]
|
|
6885
8096
|
});
|
|
6886
8097
|
}
|
|
6887
8098
|
if (!members.includes(key)) {
|
|
6888
8099
|
ctx.addIssue({
|
|
6889
|
-
code:
|
|
8100
|
+
code: z6.ZodIssueCode.custom,
|
|
6890
8101
|
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
6891
8102
|
path: ["env", key, "anyOf"]
|
|
6892
8103
|
});
|
|
6893
8104
|
}
|
|
6894
8105
|
}
|
|
6895
8106
|
});
|
|
6896
|
-
var RoleEntrySchema =
|
|
6897
|
-
contract:
|
|
8107
|
+
var RoleEntrySchema = z6.object({
|
|
8108
|
+
contract: z6.string().refine((p) => p.includes("/"), {
|
|
6898
8109
|
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
6899
8110
|
})
|
|
6900
8111
|
});
|
|
@@ -6918,17 +8129,17 @@ var BRIEF_BUILTINS = [
|
|
|
6918
8129
|
"briefSections",
|
|
6919
8130
|
"milestoneShape"
|
|
6920
8131
|
];
|
|
6921
|
-
var BriefSectionSchema =
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
8132
|
+
var BriefSectionSchema = z6.union([
|
|
8133
|
+
z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
|
|
8134
|
+
z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
|
|
8135
|
+
z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
|
|
8136
|
+
z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
|
|
6926
8137
|
]);
|
|
6927
|
-
var BriefSchemaSchema =
|
|
6928
|
-
pr:
|
|
6929
|
-
issue:
|
|
6930
|
-
milestone:
|
|
6931
|
-
ack:
|
|
8138
|
+
var BriefSchemaSchema = z6.object({
|
|
8139
|
+
pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8140
|
+
issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8141
|
+
milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8142
|
+
ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
|
|
6932
8143
|
});
|
|
6933
8144
|
function isSafeRepoRelPath(p) {
|
|
6934
8145
|
if (p.length === 0)
|
|
@@ -6937,7 +8148,7 @@ function isSafeRepoRelPath(p) {
|
|
|
6937
8148
|
return false;
|
|
6938
8149
|
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
6939
8150
|
}
|
|
6940
|
-
var SafeRepoRelPath =
|
|
8151
|
+
var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
|
|
6941
8152
|
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
6942
8153
|
});
|
|
6943
8154
|
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
@@ -6947,22 +8158,22 @@ function isCanonicalHookBlockPath(p) {
|
|
|
6947
8158
|
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
6948
8159
|
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
6949
8160
|
});
|
|
6950
|
-
var ManagedBlockRecordSchema =
|
|
8161
|
+
var ManagedBlockRecordSchema = z6.object({
|
|
6951
8162
|
path: ManagedHookBlockPath,
|
|
6952
|
-
marker:
|
|
6953
|
-
comment:
|
|
8163
|
+
marker: z6.string(),
|
|
8164
|
+
comment: z6.enum(["hash", "html"])
|
|
6954
8165
|
});
|
|
6955
|
-
var ManagedManifestSchema =
|
|
6956
|
-
version:
|
|
6957
|
-
files:
|
|
6958
|
-
blocks:
|
|
6959
|
-
labels:
|
|
6960
|
-
agents:
|
|
8166
|
+
var ManagedManifestSchema = z6.object({
|
|
8167
|
+
version: z6.number().int().positive(),
|
|
8168
|
+
files: z6.array(SafeRepoRelPath),
|
|
8169
|
+
blocks: z6.array(ManagedBlockRecordSchema),
|
|
8170
|
+
labels: z6.array(z6.string()),
|
|
8171
|
+
agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
|
|
6961
8172
|
});
|
|
6962
|
-
var ProjectEntrySchema =
|
|
6963
|
-
name:
|
|
6964
|
-
description:
|
|
6965
|
-
path:
|
|
8173
|
+
var ProjectEntrySchema = z6.object({
|
|
8174
|
+
name: z6.string().min(1),
|
|
8175
|
+
description: z6.string().min(1).optional(),
|
|
8176
|
+
path: z6.string().min(1).optional()
|
|
6966
8177
|
});
|
|
6967
8178
|
function parseTokensCollectDeclaration(value) {
|
|
6968
8179
|
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
@@ -6973,90 +8184,90 @@ function parseTokensCollectDeclaration(value) {
|
|
|
6973
8184
|
return null;
|
|
6974
8185
|
return { interpreter, script };
|
|
6975
8186
|
}
|
|
6976
|
-
var
|
|
6977
|
-
rings:
|
|
6978
|
-
ring1_forgeWriteInterception:
|
|
6979
|
-
ring2_asyncAudits:
|
|
8187
|
+
var VinayaConfigObjectSchema = z6.object({
|
|
8188
|
+
rings: z6.object({
|
|
8189
|
+
ring1_forgeWriteInterception: z6.boolean(),
|
|
8190
|
+
ring2_asyncAudits: z6.boolean()
|
|
6980
8191
|
}).optional(),
|
|
6981
|
-
checks:
|
|
6982
|
-
roles:
|
|
8192
|
+
checks: z6.record(z6.string(), CheckEntrySchema).optional(),
|
|
8193
|
+
roles: z6.record(z6.string(), RoleEntrySchema).optional(),
|
|
6983
8194
|
briefSchema: BriefSchemaSchema.optional(),
|
|
6984
8195
|
managed: ManagedManifestSchema.optional(),
|
|
6985
|
-
principals:
|
|
6986
|
-
releaseActor:
|
|
6987
|
-
ci:
|
|
6988
|
-
tokens:
|
|
6989
|
-
collect:
|
|
8196
|
+
principals: z6.array(z6.string()).min(1).optional(),
|
|
8197
|
+
releaseActor: z6.string().min(1).optional(),
|
|
8198
|
+
ci: z6.object({ setup: z6.string().min(1) }).optional(),
|
|
8199
|
+
tokens: z6.object({
|
|
8200
|
+
collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
6990
8201
|
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
6991
8202
|
})
|
|
6992
8203
|
}).optional(),
|
|
6993
|
-
blastRadius:
|
|
6994
|
-
proseGates:
|
|
6995
|
-
doctrineRoot:
|
|
6996
|
-
readerFacingPrefix:
|
|
6997
|
-
readerFacingSuffix:
|
|
6998
|
-
legacySlugDir:
|
|
6999
|
-
sourceComments:
|
|
7000
|
-
globs:
|
|
7001
|
-
allowlist:
|
|
7002
|
-
severity:
|
|
8204
|
+
blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
|
|
8205
|
+
proseGates: z6.object({
|
|
8206
|
+
doctrineRoot: z6.string().min(1).optional(),
|
|
8207
|
+
readerFacingPrefix: z6.string().min(1).optional(),
|
|
8208
|
+
readerFacingSuffix: z6.string().min(1).optional(),
|
|
8209
|
+
legacySlugDir: z6.string().min(1).optional(),
|
|
8210
|
+
sourceComments: z6.object({
|
|
8211
|
+
globs: z6.array(z6.string().min(1)).optional(),
|
|
8212
|
+
allowlist: z6.array(z6.string().min(1)).optional(),
|
|
8213
|
+
severity: z6.enum(["warning", "error"]).optional()
|
|
7003
8214
|
}).optional(),
|
|
7004
|
-
specGrandfather:
|
|
7005
|
-
specPaths:
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
})).optional()
|
|
8215
|
+
specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
|
|
8216
|
+
specPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8217
|
+
productPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8218
|
+
published: PublishedProseSchema.optional(),
|
|
8219
|
+
rules: ProseRulesSchema.optional()
|
|
7010
8220
|
}).optional(),
|
|
7011
|
-
projects:
|
|
7012
|
-
dispatch:
|
|
7013
|
-
timeoutMs:
|
|
7014
|
-
|
|
7015
|
-
|
|
8221
|
+
projects: z6.array(ProjectEntrySchema).optional(),
|
|
8222
|
+
dispatch: z6.object({
|
|
8223
|
+
timeoutMs: z6.number().int().positive().optional(),
|
|
8224
|
+
reviewerTimeoutMs: z6.number().int().positive().optional(),
|
|
8225
|
+
killGraceMs: z6.number().int().positive().optional(),
|
|
8226
|
+
agent: z6.enum(["claude", "codex"]).optional()
|
|
7016
8227
|
}).optional(),
|
|
7017
|
-
reviewPolicy:
|
|
7018
|
-
codeReviewThreshold:
|
|
7019
|
-
securityThreshold:
|
|
7020
|
-
maxRounds:
|
|
7021
|
-
maxTaskMinutes:
|
|
8228
|
+
reviewPolicy: z6.object({
|
|
8229
|
+
codeReviewThreshold: z6.string().min(1).optional(),
|
|
8230
|
+
securityThreshold: z6.string().min(1).optional(),
|
|
8231
|
+
maxRounds: z6.number().optional(),
|
|
8232
|
+
maxTaskMinutes: z6.number().optional()
|
|
7022
8233
|
}).optional(),
|
|
7023
|
-
securityScan:
|
|
7024
|
-
command:
|
|
8234
|
+
securityScan: z6.object({
|
|
8235
|
+
command: z6.array(z6.string().min(1)).min(1)
|
|
7025
8236
|
}).optional(),
|
|
7026
|
-
gateCutovers:
|
|
7027
|
-
objectivesSinceIssue:
|
|
7028
|
-
briefSectionsSinceIssue:
|
|
7029
|
-
documentationSinceIssue:
|
|
7030
|
-
briefRulesSincePr:
|
|
7031
|
-
agentBoxesRefusedSincePr:
|
|
8237
|
+
gateCutovers: z6.object({
|
|
8238
|
+
objectivesSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8239
|
+
briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8240
|
+
documentationSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8241
|
+
briefRulesSincePr: z6.number().int().nonnegative().optional(),
|
|
8242
|
+
agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
|
|
7032
8243
|
}).optional(),
|
|
7033
|
-
planning:
|
|
7034
|
-
collisionThreshold:
|
|
8244
|
+
planning: z6.object({
|
|
8245
|
+
collisionThreshold: z6.number().int().nonnegative().optional()
|
|
7035
8246
|
}).optional(),
|
|
7036
|
-
prePush:
|
|
7037
|
-
alwaysRun:
|
|
8247
|
+
prePush: z6.object({
|
|
8248
|
+
alwaysRun: z6.array(z6.string()).optional()
|
|
7038
8249
|
}).optional(),
|
|
7039
|
-
report:
|
|
7040
|
-
commandTimeoutMs:
|
|
8250
|
+
report: z6.object({
|
|
8251
|
+
commandTimeoutMs: z6.number().int().positive().optional()
|
|
7041
8252
|
}).superRefine((report, ctx) => {
|
|
7042
8253
|
const commandTimeoutMs = report.commandTimeoutMs;
|
|
7043
8254
|
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
7044
8255
|
ctx.addIssue({
|
|
7045
|
-
code:
|
|
8256
|
+
code: z6.ZodIssueCode.custom,
|
|
7046
8257
|
path: ["commandTimeoutMs"],
|
|
7047
8258
|
message: "must be at most 3600000 (1 hour)"
|
|
7048
8259
|
});
|
|
7049
8260
|
}
|
|
7050
8261
|
}).optional(),
|
|
7051
|
-
logPublish:
|
|
8262
|
+
logPublish: z6.unknown().refine((v) => v === undefined, {
|
|
7052
8263
|
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
7053
8264
|
}),
|
|
7054
|
-
runtimeDir:
|
|
7055
|
-
logs:
|
|
7056
|
-
folder:
|
|
7057
|
-
url:
|
|
7058
|
-
headers:
|
|
7059
|
-
readHeaders:
|
|
8265
|
+
runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
8266
|
+
logs: z6.object({
|
|
8267
|
+
folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
8268
|
+
url: z6.string().url().optional(),
|
|
8269
|
+
headers: z6.record(z6.string()).optional(),
|
|
8270
|
+
readHeaders: z6.record(z6.string()).optional(),
|
|
7060
8271
|
events: CustomEventDeclarationsSchema.optional()
|
|
7061
8272
|
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
7062
8273
|
message: "logs: set at most one of folder/url"
|
|
@@ -7064,8 +8275,33 @@ var VinayaConfigSchema = z5.object({
|
|
|
7064
8275
|
message: "logs: headers requires url"
|
|
7065
8276
|
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
7066
8277
|
message: "logs: readHeaders requires url"
|
|
7067
|
-
}).optional()
|
|
8278
|
+
}).optional(),
|
|
8279
|
+
decisionRecords: z6.object({
|
|
8280
|
+
path: RepoRelativePathSchema
|
|
8281
|
+
}).strict().optional()
|
|
7068
8282
|
});
|
|
8283
|
+
function decisionRecordsPathIssue(path, doctrineRoot) {
|
|
8284
|
+
const reason = outsideRepositoryReason(path);
|
|
8285
|
+
if (reason)
|
|
8286
|
+
return reason;
|
|
8287
|
+
const folder = normalizeSpecPath(path);
|
|
8288
|
+
if (folder === "" || folder === ".")
|
|
8289
|
+
return "must name a folder, not the repository root";
|
|
8290
|
+
const root = normalizeSpecPath(doctrineRoot ?? "aeg-root");
|
|
8291
|
+
if (folder === root || folder.startsWith(`${root}/`)) {
|
|
8292
|
+
return `must be outside the doctrine tree "${root}" — decision records belong to this repository, not to the doctrine it ships`;
|
|
8293
|
+
}
|
|
8294
|
+
return null;
|
|
8295
|
+
}
|
|
8296
|
+
var VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
|
|
8297
|
+
const path = config.decisionRecords?.path;
|
|
8298
|
+
if (path === undefined || outsideRepositoryReason(path))
|
|
8299
|
+
return;
|
|
8300
|
+
const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
|
|
8301
|
+
if (issue)
|
|
8302
|
+
ctx.addIssue({ code: z6.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
|
|
8303
|
+
});
|
|
8304
|
+
var VinayaConfigShape = VinayaConfigObjectSchema.shape;
|
|
7069
8305
|
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
7070
8306
|
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
7071
8307
|
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
@@ -7146,9 +8382,6 @@ function stripGlobalOnlyKeys(config, path) {
|
|
|
7146
8382
|
}
|
|
7147
8383
|
return result;
|
|
7148
8384
|
}
|
|
7149
|
-
function resolvePrincipalAllowlist(config) {
|
|
7150
|
-
return config?.principals ?? PRINCIPAL_ALLOWLIST;
|
|
7151
|
-
}
|
|
7152
8385
|
function resolveReleaseActor(config) {
|
|
7153
8386
|
return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
|
|
7154
8387
|
}
|
|
@@ -7284,13 +8517,14 @@ function readTrustAnchorConfigAtRef(ref) {
|
|
|
7284
8517
|
});
|
|
7285
8518
|
return Buffer.from(raw, "utf-8").toString("base64");
|
|
7286
8519
|
}
|
|
8520
|
+
var NO_TRUST_ANCHOR_REPO_MESSAGE = "could not resolve repo identity for the trust-anchor read";
|
|
7287
8521
|
function ghFetchTrustAnchorConfig() {
|
|
7288
8522
|
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
7289
8523
|
if (probeRef)
|
|
7290
8524
|
return readTrustAnchorConfigAtRef(probeRef);
|
|
7291
8525
|
const repo = trustAnchorRepo();
|
|
7292
8526
|
if (!repo)
|
|
7293
|
-
throw new Error(
|
|
8527
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7294
8528
|
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
7295
8529
|
encoding: "utf-8",
|
|
7296
8530
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -7307,7 +8541,7 @@ async function ghFetchTrustAnchorConfigAsync() {
|
|
|
7307
8541
|
}
|
|
7308
8542
|
const repo = await trustAnchorRepoAsync();
|
|
7309
8543
|
if (!repo)
|
|
7310
|
-
throw new Error(
|
|
8544
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7311
8545
|
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
7312
8546
|
return stdout;
|
|
7313
8547
|
}
|
|
@@ -7333,6 +8567,47 @@ function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
|
7333
8567
|
}
|
|
7334
8568
|
return parseTrustAnchorContent(base64);
|
|
7335
8569
|
}
|
|
8570
|
+
class PrincipalsUnresolvedError extends Error {
|
|
8571
|
+
kind;
|
|
8572
|
+
constructor(kind, message) {
|
|
8573
|
+
super(message);
|
|
8574
|
+
this.name = "PrincipalsUnresolvedError";
|
|
8575
|
+
this.kind = kind;
|
|
8576
|
+
}
|
|
8577
|
+
}
|
|
8578
|
+
var PRINCIPALS_FIX = 'add "principals": [...] to vinaya.config.json on the default branch';
|
|
8579
|
+
function fetchFailureReason(err) {
|
|
8580
|
+
const stderr = err?.stderr;
|
|
8581
|
+
const text = (typeof stderr === "string" ? stderr : stderr?.toString() ?? "").trim();
|
|
8582
|
+
return text.split(`
|
|
8583
|
+
`)[0]?.trim() || firstLine(err);
|
|
8584
|
+
}
|
|
8585
|
+
function principalsNotConfigured(why) {
|
|
8586
|
+
return new PrincipalsUnresolvedError("not-configured", `no Principal is configured (${why}) — ${PRINCIPALS_FIX}.`);
|
|
8587
|
+
}
|
|
8588
|
+
function resolveTrustedPrincipals(fetcher = ghFetchTrustAnchorConfig) {
|
|
8589
|
+
let content;
|
|
8590
|
+
try {
|
|
8591
|
+
content = fetcher();
|
|
8592
|
+
} catch (err) {
|
|
8593
|
+
if (err?.message === NO_TRUST_ANCHOR_REPO_MESSAGE) {
|
|
8594
|
+
throw principalsNotConfigured("no repository resolves for the read");
|
|
8595
|
+
}
|
|
8596
|
+
if (isMissingFileError(err))
|
|
8597
|
+
throw principalsNotConfigured("the default branch has no vinaya.config.json");
|
|
8598
|
+
throw new PrincipalsUnresolvedError("read-failed", `could not read "principals" from vinaya.config.json on the default branch: ${fetchFailureReason(err)}`);
|
|
8599
|
+
}
|
|
8600
|
+
const unusable = { why: "" };
|
|
8601
|
+
const config = parseTrustAnchorContent(content, (why) => {
|
|
8602
|
+
unusable.why = why;
|
|
8603
|
+
});
|
|
8604
|
+
if (config === null) {
|
|
8605
|
+
throw principalsNotConfigured(`vinaya.config.json on the default branch ${unusable.why ? `is unusable: ${unusable.why}` : "is empty"}`);
|
|
8606
|
+
}
|
|
8607
|
+
if (!config.principals)
|
|
8608
|
+
throw principalsNotConfigured('vinaya.config.json on the default branch sets no "principals"');
|
|
8609
|
+
return config.principals;
|
|
8610
|
+
}
|
|
7336
8611
|
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
7337
8612
|
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
7338
8613
|
let base64;
|
|
@@ -7372,17 +8647,183 @@ function loadConfig() {
|
|
|
7372
8647
|
const path = configPath();
|
|
7373
8648
|
if (!path)
|
|
7374
8649
|
return null;
|
|
8650
|
+
let text;
|
|
7375
8651
|
try {
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
8652
|
+
text = readFileSync2(path, "utf-8");
|
|
8653
|
+
} catch (err) {
|
|
8654
|
+
reportInvalidConfigOnce(path, `unreadable: ${err.message}`);
|
|
8655
|
+
return null;
|
|
8656
|
+
}
|
|
8657
|
+
let raw;
|
|
8658
|
+
try {
|
|
8659
|
+
raw = JSON.parse(text);
|
|
8660
|
+
} catch (err) {
|
|
8661
|
+
reportInvalidConfigOnce(path, `invalid JSON: ${err.message}`);
|
|
8662
|
+
return null;
|
|
8663
|
+
}
|
|
8664
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8665
|
+
if (!parsed.success) {
|
|
8666
|
+
reportInvalidConfigOnce(path, schemaIssueDetail(parsed.error));
|
|
7379
8667
|
return null;
|
|
7380
8668
|
}
|
|
8669
|
+
return stripGlobalOnlyKeys(parsed.data, path);
|
|
8670
|
+
}
|
|
8671
|
+
function schemaIssueDetail(error) {
|
|
8672
|
+
return error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
|
|
8673
|
+
}
|
|
8674
|
+
var emittedInvalidConfigReports = new Set;
|
|
8675
|
+
function reportInvalidConfigOnce(path, detail) {
|
|
8676
|
+
const key = `${path}
|
|
8677
|
+
${detail}`;
|
|
8678
|
+
if (emittedInvalidConfigReports.has(key))
|
|
8679
|
+
return;
|
|
8680
|
+
emittedInvalidConfigReports.add(key);
|
|
8681
|
+
const message = `${path} is not a valid Vinaya configuration (${detail}) — falling back to built-in defaults.`;
|
|
8682
|
+
const checkName = process.env.VINAYA_CHECK_NAME;
|
|
8683
|
+
if (checkName) {
|
|
8684
|
+
emitCheckError({
|
|
8685
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8686
|
+
check: checkName,
|
|
8687
|
+
severity: "warning",
|
|
8688
|
+
message,
|
|
8689
|
+
agent_recovery_prompt: `Fix the failing keys in ${path} (${detail}) so the file parses and satisfies the configuration schema, then re-run.`,
|
|
8690
|
+
file: path
|
|
8691
|
+
});
|
|
8692
|
+
return;
|
|
8693
|
+
}
|
|
8694
|
+
console.error(`⚠ ${message}`);
|
|
8695
|
+
}
|
|
8696
|
+
function loadConfigChecked() {
|
|
8697
|
+
const path = configPath();
|
|
8698
|
+
if (!path)
|
|
8699
|
+
return { ok: true, config: null };
|
|
8700
|
+
let raw;
|
|
8701
|
+
try {
|
|
8702
|
+
raw = JSON.parse(readFileSync2(path, "utf-8"));
|
|
8703
|
+
} catch (err) {
|
|
8704
|
+
return { ok: false, path, error: `invalid JSON: ${err.message}` };
|
|
8705
|
+
}
|
|
8706
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8707
|
+
if (!parsed.success) {
|
|
8708
|
+
return { ok: false, path, error: schemaIssueDetail(parsed.error) };
|
|
8709
|
+
}
|
|
8710
|
+
return { ok: true, config: stripGlobalOnlyKeys(parsed.data, path) };
|
|
7381
8711
|
}
|
|
7382
8712
|
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
7383
8713
|
|
|
7384
8714
|
// src/lib/forge-read.ts
|
|
7385
8715
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
8716
|
+
|
|
8717
|
+
// src/lib/forge-snapshot.ts
|
|
8718
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
8719
|
+
import { join as join2 } from "node:path";
|
|
8720
|
+
var FORGE_SNAPSHOT_DIR_ENV = "VINAYA_FORGE_SNAPSHOT_DIR";
|
|
8721
|
+
var PULL_FILE = "pull.json";
|
|
8722
|
+
var PULL_COMMENTS_FILE = "pull-comments.json";
|
|
8723
|
+
var ISSUE_FILE = "issue.json";
|
|
8724
|
+
var ISSUE_COMMENTS_FILE = "issue-comments.json";
|
|
8725
|
+
function forgeSnapshotDir(env = process.env) {
|
|
8726
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
8727
|
+
return null;
|
|
8728
|
+
const dir = env[FORGE_SNAPSHOT_DIR_ENV];
|
|
8729
|
+
return dir ? dir : null;
|
|
8730
|
+
}
|
|
8731
|
+
|
|
8732
|
+
class ForgeSnapshotIncompleteError extends Error {
|
|
8733
|
+
constructor(dir, file) {
|
|
8734
|
+
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.`);
|
|
8735
|
+
this.name = "ForgeSnapshotIncompleteError";
|
|
8736
|
+
}
|
|
8737
|
+
}
|
|
8738
|
+
|
|
8739
|
+
class ForgeSnapshotIssueNotFoundError extends Error {
|
|
8740
|
+
constructor(issue) {
|
|
8741
|
+
super(`Issue #${issue} did not resolve (HTTP 404) when this run's forge snapshot was read.`);
|
|
8742
|
+
this.name = "ForgeSnapshotIssueNotFoundError";
|
|
8743
|
+
}
|
|
8744
|
+
}
|
|
8745
|
+
function readSnapshotFile(dir, file) {
|
|
8746
|
+
let text;
|
|
8747
|
+
try {
|
|
8748
|
+
text = readFileSync3(join2(dir, file), "utf8");
|
|
8749
|
+
} catch {
|
|
8750
|
+
throw new ForgeSnapshotIncompleteError(dir, file);
|
|
8751
|
+
}
|
|
8752
|
+
return JSON.parse(text);
|
|
8753
|
+
}
|
|
8754
|
+
function readComments(dir, file, number) {
|
|
8755
|
+
const parsed = readSnapshotFile(dir, file);
|
|
8756
|
+
if (parsed.number !== number)
|
|
8757
|
+
throw new ForgeSnapshotIncompleteError(dir, `${file} for #${number}`);
|
|
8758
|
+
return parsed.comments;
|
|
8759
|
+
}
|
|
8760
|
+
function snapshotPullRequest(number, env = process.env) {
|
|
8761
|
+
const dir = forgeSnapshotDir(env);
|
|
8762
|
+
if (dir === null)
|
|
8763
|
+
return null;
|
|
8764
|
+
const pull = readSnapshotFile(dir, PULL_FILE);
|
|
8765
|
+
return pull.number === number ? pull : null;
|
|
8766
|
+
}
|
|
8767
|
+
function snapshotIssue(number, env = process.env) {
|
|
8768
|
+
const dir = forgeSnapshotDir(env);
|
|
8769
|
+
if (dir === null)
|
|
8770
|
+
return null;
|
|
8771
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
8772
|
+
if (issue.number !== number)
|
|
8773
|
+
return null;
|
|
8774
|
+
if ("notFound" in issue)
|
|
8775
|
+
throw new ForgeSnapshotIssueNotFoundError(number);
|
|
8776
|
+
return issue;
|
|
8777
|
+
}
|
|
8778
|
+
function snapshotComments(number, env = process.env) {
|
|
8779
|
+
const dir = forgeSnapshotDir(env);
|
|
8780
|
+
if (dir === null)
|
|
8781
|
+
return null;
|
|
8782
|
+
if (snapshotPullRequest(number, env) !== null)
|
|
8783
|
+
return readComments(dir, PULL_COMMENTS_FILE, number);
|
|
8784
|
+
if (snapshotIssue(number, env) !== null)
|
|
8785
|
+
return readComments(dir, ISSUE_COMMENTS_FILE, number);
|
|
8786
|
+
return null;
|
|
8787
|
+
}
|
|
8788
|
+
function snapshotBody(number, env = process.env) {
|
|
8789
|
+
const pull = snapshotPullRequest(number, env);
|
|
8790
|
+
if (pull !== null)
|
|
8791
|
+
return pull.body;
|
|
8792
|
+
return snapshotIssue(number, env)?.body ?? null;
|
|
8793
|
+
}
|
|
8794
|
+
function incompleteForgeSnapshot(env = process.env) {
|
|
8795
|
+
const dir = forgeSnapshotDir(env);
|
|
8796
|
+
if (dir === null)
|
|
8797
|
+
return null;
|
|
8798
|
+
for (const file of [PULL_FILE, PULL_COMMENTS_FILE, ISSUE_FILE]) {
|
|
8799
|
+
if (!existsSync2(join2(dir, file)))
|
|
8800
|
+
return new ForgeSnapshotIncompleteError(dir, file).message;
|
|
8801
|
+
}
|
|
8802
|
+
try {
|
|
8803
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
8804
|
+
if (typeof issue.number === "number" && !("notFound" in issue) && !existsSync2(join2(dir, ISSUE_COMMENTS_FILE))) {
|
|
8805
|
+
return new ForgeSnapshotIncompleteError(dir, ISSUE_COMMENTS_FILE).message;
|
|
8806
|
+
}
|
|
8807
|
+
} catch (err) {
|
|
8808
|
+
return `the forge snapshot ${dir} has an unreadable ${ISSUE_FILE}: ${err.message}`;
|
|
8809
|
+
}
|
|
8810
|
+
return null;
|
|
8811
|
+
}
|
|
8812
|
+
function exitOnIncompleteForgeSnapshot(checkName, env = process.env) {
|
|
8813
|
+
const reason = incompleteForgeSnapshot(env);
|
|
8814
|
+
if (reason === null)
|
|
8815
|
+
return;
|
|
8816
|
+
emitCheckError({
|
|
8817
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8818
|
+
check: checkName,
|
|
8819
|
+
severity: "error",
|
|
8820
|
+
message: `${checkName}: ${reason}`,
|
|
8821
|
+
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.`
|
|
8822
|
+
});
|
|
8823
|
+
process.exit(1);
|
|
8824
|
+
}
|
|
8825
|
+
|
|
8826
|
+
// src/lib/forge-read.ts
|
|
7386
8827
|
var FORGE_READ_CEILING_BYTES = 64 * 1024 * 1024;
|
|
7387
8828
|
var PAGE_SIZE = 100;
|
|
7388
8829
|
var ghRunner = (args, maxBuffer) => execFileSync3("gh", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], maxBuffer });
|
|
@@ -7405,7 +8846,7 @@ function isForgeReadOversize(err) {
|
|
|
7405
8846
|
function isBufferOverflow(err) {
|
|
7406
8847
|
return err?.code === "ENOBUFS";
|
|
7407
8848
|
}
|
|
7408
|
-
function
|
|
8849
|
+
function runBounded(runner, args, subject, usedBytes) {
|
|
7409
8850
|
const remaining = FORGE_READ_CEILING_BYTES - usedBytes;
|
|
7410
8851
|
let out;
|
|
7411
8852
|
try {
|
|
@@ -7420,31 +8861,40 @@ function run2(runner, args, subject, usedBytes) {
|
|
|
7420
8861
|
throw new ForgeReadOversizeError(subject, usedBytes + size);
|
|
7421
8862
|
return out;
|
|
7422
8863
|
}
|
|
7423
|
-
function
|
|
7424
|
-
const
|
|
7425
|
-
const comments = [];
|
|
8864
|
+
function readRestCommentRows(number, subjectLabel = `Issue ${number}`, runner = ghRunner) {
|
|
8865
|
+
const rows = [];
|
|
7426
8866
|
let used = 0;
|
|
7427
8867
|
for (let page = 1;; page++) {
|
|
7428
|
-
const out =
|
|
8868
|
+
const out = runBounded(runner, ["api", `repos/{owner}/{repo}/issues/${number}/comments?per_page=${PAGE_SIZE}&page=${page}`], subjectLabel, used);
|
|
7429
8869
|
used += Buffer.byteLength(out, "utf8");
|
|
7430
|
-
const
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
url: r.html_url ?? "",
|
|
7435
|
-
author: r.user?.login ? { login: r.user.login } : null
|
|
7436
|
-
});
|
|
7437
|
-
}
|
|
7438
|
-
if (rows.length < PAGE_SIZE)
|
|
7439
|
-
return comments;
|
|
8870
|
+
const pageRows = JSON.parse(out);
|
|
8871
|
+
rows.push(...pageRows);
|
|
8872
|
+
if (pageRows.length < PAGE_SIZE)
|
|
8873
|
+
return rows;
|
|
7440
8874
|
}
|
|
7441
8875
|
}
|
|
8876
|
+
function readIssueComments(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
8877
|
+
const number = resolveNumber(issue, subjectLabel, runner);
|
|
8878
|
+
const fromSnapshot = snapshotComments(number);
|
|
8879
|
+
if (fromSnapshot !== null)
|
|
8880
|
+
return fromSnapshot;
|
|
8881
|
+
return readRestCommentRows(number, subjectLabel, runner).map((r) => ({
|
|
8882
|
+
body: r.body ?? "",
|
|
8883
|
+
url: r.html_url ?? "",
|
|
8884
|
+
author: r.user?.login ? { login: r.user.login } : null
|
|
8885
|
+
}));
|
|
8886
|
+
}
|
|
7442
8887
|
function readIssueBody(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
7443
|
-
|
|
8888
|
+
if (forgeSnapshotDir() !== null) {
|
|
8889
|
+
const fromSnapshot = snapshotBody(resolveNumber(issue, subjectLabel, runner));
|
|
8890
|
+
if (fromSnapshot !== null)
|
|
8891
|
+
return fromSnapshot;
|
|
8892
|
+
}
|
|
8893
|
+
const out = runBounded(runner, ["issue", "view", String(issue), "--json", "body"], subjectLabel, 0);
|
|
7444
8894
|
return JSON.parse(out).body ?? "";
|
|
7445
8895
|
}
|
|
7446
8896
|
function readIssueFields(issue, fields, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
7447
|
-
return JSON.parse(
|
|
8897
|
+
return JSON.parse(runBounded(runner, ["issue", "view", String(issue), "--json", fields], subjectLabel, 0));
|
|
7448
8898
|
}
|
|
7449
8899
|
function resolveNumber(issue, subjectLabel, runner) {
|
|
7450
8900
|
if (typeof issue === "number")
|
|
@@ -7455,9 +8905,9 @@ function resolveNumber(issue, subjectLabel, runner) {
|
|
|
7455
8905
|
}
|
|
7456
8906
|
|
|
7457
8907
|
// src/lib/brief-assembly.ts
|
|
7458
|
-
import { execFileSync as
|
|
7459
|
-
import { existsSync as
|
|
7460
|
-
import { join as
|
|
8908
|
+
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
8909
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, readdirSync as readdirSync2 } from "node:fs";
|
|
8910
|
+
import { join as join5 } from "node:path";
|
|
7461
8911
|
|
|
7462
8912
|
// ../../packages/sources/src/commands.ts
|
|
7463
8913
|
var COMMANDS = [
|
|
@@ -7573,6 +9023,16 @@ var COMMANDS = [
|
|
|
7573
9023
|
],
|
|
7574
9024
|
status: "shipped"
|
|
7575
9025
|
},
|
|
9026
|
+
{
|
|
9027
|
+
name: "new adr",
|
|
9028
|
+
needs: [],
|
|
9029
|
+
description: "Write the next numbered decision record into the folder decisionRecords.path names",
|
|
9030
|
+
details: [
|
|
9031
|
+
"`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.",
|
|
9032
|
+
"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."
|
|
9033
|
+
],
|
|
9034
|
+
status: "shipped"
|
|
9035
|
+
},
|
|
7576
9036
|
{
|
|
7577
9037
|
name: "brief render",
|
|
7578
9038
|
needs: ["forge", "default-branch"],
|
|
@@ -7591,9 +9051,7 @@ var COMMANDS = [
|
|
|
7591
9051
|
name: "task dispatch",
|
|
7592
9052
|
needs: ["forge", "operator-seat"],
|
|
7593
9053
|
description: "Deprecated — render, pin, and post the brief on the Issue as the frozen original; start the developer",
|
|
7594
|
-
flags: [
|
|
7595
|
-
{ flag: "--agent <claude|codex|gemini>", description: "Start the developer through dispatchRole once posted" }
|
|
7596
|
-
],
|
|
9054
|
+
flags: [{ flag: "--agent <claude|codex>", description: "Start the developer through dispatchRole once posted" }],
|
|
7597
9055
|
details: [
|
|
7598
9056
|
"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.",
|
|
7599
9057
|
"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.",
|
|
@@ -7618,7 +9076,7 @@ var COMMANDS = [
|
|
|
7618
9076
|
description: "One command from a planned Issue to a reviewed pull request — exactly one developer started",
|
|
7619
9077
|
flags: [
|
|
7620
9078
|
{
|
|
7621
|
-
flag: "--agent <claude|codex
|
|
9079
|
+
flag: "--agent <claude|codex>",
|
|
7622
9080
|
description: "Vendor for the developer and both reviewers this run dispatches"
|
|
7623
9081
|
},
|
|
7624
9082
|
{
|
|
@@ -7793,6 +9251,22 @@ var COMMANDS = [
|
|
|
7793
9251
|
],
|
|
7794
9252
|
status: "shipped"
|
|
7795
9253
|
},
|
|
9254
|
+
{
|
|
9255
|
+
name: "pr snapshot",
|
|
9256
|
+
needs: ["forge"],
|
|
9257
|
+
description: "CI plumbing: write a run's forge snapshot of the pull request and its task Issue, read over REST",
|
|
9258
|
+
flags: [
|
|
9259
|
+
{
|
|
9260
|
+
flag: "--dir",
|
|
9261
|
+
description: "The snapshot directory; its `raw/` holds the REST pull request and comment pages the read step wrote"
|
|
9262
|
+
}
|
|
9263
|
+
],
|
|
9264
|
+
details: [
|
|
9265
|
+
"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.",
|
|
9266
|
+
"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."
|
|
9267
|
+
],
|
|
9268
|
+
status: "shipped"
|
|
9269
|
+
},
|
|
7796
9270
|
{
|
|
7797
9271
|
name: "issue create",
|
|
7798
9272
|
needs: ["forge"],
|
|
@@ -7913,14 +9387,14 @@ var COMMANDS = [
|
|
|
7913
9387
|
{
|
|
7914
9388
|
name: "milestone close",
|
|
7915
9389
|
needs: ["forge"],
|
|
7916
|
-
description: "Close a tranche's Milestone after verifying every labeled Issue is
|
|
9390
|
+
description: "Close a tranche's Milestone after verifying every labeled Issue is attached and every tranche it declares is complete",
|
|
7917
9391
|
flags: [
|
|
7918
9392
|
{ flag: "--slug", description: "The tranche whose Milestone is being closed" },
|
|
7919
9393
|
{ flag: "--validate-only", description: "Run every gate and report PASS without closing the Milestone" },
|
|
7920
9394
|
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
7921
9395
|
],
|
|
7922
9396
|
details: [
|
|
7923
|
-
"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."
|
|
9397
|
+
"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."
|
|
7924
9398
|
],
|
|
7925
9399
|
status: "shipped"
|
|
7926
9400
|
},
|
|
@@ -8209,7 +9683,7 @@ var COMMANDS = [
|
|
|
8209
9683
|
}
|
|
8210
9684
|
],
|
|
8211
9685
|
details: [
|
|
8212
|
-
"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`
|
|
9686
|
+
"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.",
|
|
8213
9687
|
"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.",
|
|
8214
9688
|
'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.'
|
|
8215
9689
|
],
|
|
@@ -8218,11 +9692,11 @@ var COMMANDS = [
|
|
|
8218
9692
|
{
|
|
8219
9693
|
name: "dispatch",
|
|
8220
9694
|
needs: ["operator-seat"],
|
|
8221
|
-
description: "Start a role's headless agent session (claude/codex
|
|
9695
|
+
description: "Start a role's headless agent session (claude/codex) with attribution set on its environment, recording the outcome through the Vinaya Log",
|
|
8222
9696
|
flags: [
|
|
8223
9697
|
{
|
|
8224
9698
|
flag: "--agent",
|
|
8225
|
-
description: "Vendor to start: `claude
|
|
9699
|
+
description: "Vendor to start: `claude` or `codex` (falls back to `dispatch.agent` in config)"
|
|
8226
9700
|
},
|
|
8227
9701
|
{ flag: "--prompt-file", description: "Path to the prompt text sent to the agent (never on argv)" },
|
|
8228
9702
|
{ flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
|
|
@@ -8239,9 +9713,9 @@ var COMMANDS = [
|
|
|
8239
9713
|
],
|
|
8240
9714
|
details: [
|
|
8241
9715
|
"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.",
|
|
8242
|
-
"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 `
|
|
9716
|
+
"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`.",
|
|
8243
9717
|
"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.",
|
|
8244
|
-
"A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude
|
|
9718
|
+
"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."
|
|
8245
9719
|
],
|
|
8246
9720
|
status: "shipped"
|
|
8247
9721
|
},
|
|
@@ -8252,7 +9726,7 @@ var COMMANDS = [
|
|
|
8252
9726
|
flags: [
|
|
8253
9727
|
{ flag: "--task <n>", description: "This task's Issue number — its frozen `aeg:brief:v1` comment is the brief" },
|
|
8254
9728
|
{
|
|
8255
|
-
flag: "--agent <claude|codex
|
|
9729
|
+
flag: "--agent <claude|codex>",
|
|
8256
9730
|
description: "Vendor for every dispatch this loop makes (falls back to `dispatch.agent` in config)"
|
|
8257
9731
|
},
|
|
8258
9732
|
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
@@ -8331,22 +9805,72 @@ function createForgeSource(config) {
|
|
|
8331
9805
|
};
|
|
8332
9806
|
}
|
|
8333
9807
|
// ../../packages/sources/src/select-source.ts
|
|
8334
|
-
import { z as
|
|
8335
|
-
var StateSourceConfigSchema =
|
|
8336
|
-
|
|
8337
|
-
|
|
9808
|
+
import { z as z7 } from "zod";
|
|
9809
|
+
var StateSourceConfigSchema = z7.discriminatedUnion("kind", [
|
|
9810
|
+
z7.object({ kind: z7.literal("forge"), owner: z7.string(), repo: z7.string() }),
|
|
9811
|
+
z7.object({ kind: z7.literal("file"), root: z7.string().optional() })
|
|
8338
9812
|
]);
|
|
8339
9813
|
// src/checks/edge-resolve.ts
|
|
9814
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
9815
|
+
|
|
9816
|
+
// src/lib/github-rate-limit.ts
|
|
8340
9817
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
9818
|
+
var GITHUB_RATE_LIMIT_WORDING = /api rate limit (?:already )?exceeded|secondary rate limit|rate limit exceeded/i;
|
|
9819
|
+
var SECONDARY_RATE_LIMIT_WORDING = /secondary rate limit/i;
|
|
9820
|
+
function isGithubRateLimitError(text) {
|
|
9821
|
+
return GITHUB_RATE_LIMIT_WORDING.test(text);
|
|
9822
|
+
}
|
|
9823
|
+
function rateLimitBudget(errorText) {
|
|
9824
|
+
return errorText.trimStart().startsWith("GraphQL:") ? "GraphQL" : "REST";
|
|
9825
|
+
}
|
|
9826
|
+
var defaultReader = () => execFileSync4("gh", ["api", "rate_limit"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
9827
|
+
function readRateLimitReset(budget, read = defaultReader) {
|
|
9828
|
+
let parsed;
|
|
9829
|
+
try {
|
|
9830
|
+
parsed = JSON.parse(read());
|
|
9831
|
+
} catch {
|
|
9832
|
+
return null;
|
|
9833
|
+
}
|
|
9834
|
+
const resources = parsed.resources;
|
|
9835
|
+
const entry = resources?.[budget === "GraphQL" ? "graphql" : "core"];
|
|
9836
|
+
if (!entry || typeof entry.reset !== "number" || !Number.isFinite(entry.reset) || entry.reset <= 0)
|
|
9837
|
+
return null;
|
|
9838
|
+
if (typeof entry.remaining === "number" && entry.remaining > 0)
|
|
9839
|
+
return null;
|
|
9840
|
+
return entry.reset;
|
|
9841
|
+
}
|
|
9842
|
+
function formatResetUtc(epochSeconds) {
|
|
9843
|
+
const d = new Date(epochSeconds * 1000);
|
|
9844
|
+
const hh = String(d.getUTCHours()).padStart(2, "0");
|
|
9845
|
+
const mm = String(d.getUTCMinutes()).padStart(2, "0");
|
|
9846
|
+
return `${hh}:${mm} UTC`;
|
|
9847
|
+
}
|
|
9848
|
+
function rateLimitMessage(errorText, read = defaultReader) {
|
|
9849
|
+
const budget = rateLimitBudget(errorText);
|
|
9850
|
+
const reset = SECONDARY_RATE_LIMIT_WORDING.test(errorText) ? null : readRateLimitReset(budget, read);
|
|
9851
|
+
const when = reset === null ? "resets in a few minutes" : `resets at ${formatResetUtc(reset)}`;
|
|
9852
|
+
return `GitHub rate limit (${budget}), ${when}`;
|
|
9853
|
+
}
|
|
9854
|
+
function execErrorText(err) {
|
|
9855
|
+
const e = err;
|
|
9856
|
+
const stderr = e?.stderr === undefined || e.stderr === null ? "" : String(e.stderr);
|
|
9857
|
+
const message = typeof e?.message === "string" ? e.message : "";
|
|
9858
|
+
return stderr.trim() !== "" ? `${stderr}
|
|
9859
|
+
${message}` : message;
|
|
9860
|
+
}
|
|
9861
|
+
|
|
9862
|
+
// src/checks/edge-resolve.ts
|
|
8341
9863
|
var DIRECT_ISSUE_REF = /#(\d+)/;
|
|
8342
9864
|
var issueCache = new Map;
|
|
9865
|
+
var ISSUE_NOT_FOUND = /could not resolve to an issue/i;
|
|
8343
9866
|
function fetchIssueState(num, repo) {
|
|
8344
9867
|
const key = `${repo.owner}/${repo.repo}#${num}`;
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
9868
|
+
const cached = issueCache.get(key);
|
|
9869
|
+
if (cached)
|
|
9870
|
+
return cached;
|
|
9871
|
+
let out;
|
|
8348
9872
|
try {
|
|
8349
|
-
const raw =
|
|
9873
|
+
const raw = execFileSync5("gh", [
|
|
8350
9874
|
"issue",
|
|
8351
9875
|
"view",
|
|
8352
9876
|
String(num),
|
|
@@ -8355,9 +9879,9 @@ function fetchIssueState(num, repo) {
|
|
|
8355
9879
|
"--json",
|
|
8356
9880
|
"state,stateReason,closedByPullRequestsReferences"
|
|
8357
9881
|
], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
8358
|
-
out = JSON.parse(raw);
|
|
8359
|
-
} catch {
|
|
8360
|
-
out = null;
|
|
9882
|
+
out = { json: JSON.parse(raw), readFailed: false };
|
|
9883
|
+
} catch (err) {
|
|
9884
|
+
out = { json: null, readFailed: !ISSUE_NOT_FOUND.test(execErrorText(err)) };
|
|
8361
9885
|
}
|
|
8362
9886
|
issueCache.set(key, out);
|
|
8363
9887
|
return out;
|
|
@@ -8377,7 +9901,7 @@ var defaultResolveSiblingTranche = async (slug, repo) => {
|
|
|
8377
9901
|
};
|
|
8378
9902
|
};
|
|
8379
9903
|
var siblingTrancheCache = new Map;
|
|
8380
|
-
function edgeFromIssueJson(num, json) {
|
|
9904
|
+
function edgeFromIssueJson(num, json, readFailed = false) {
|
|
8381
9905
|
if (json === null) {
|
|
8382
9906
|
return {
|
|
8383
9907
|
issue: num,
|
|
@@ -8386,7 +9910,8 @@ function edgeFromIssueJson(num, json) {
|
|
|
8386
9910
|
issueState: null,
|
|
8387
9911
|
stateReason: null,
|
|
8388
9912
|
closedByActor: null,
|
|
8389
|
-
resolved: true
|
|
9913
|
+
resolved: true,
|
|
9914
|
+
...readFailed ? { readFailed: true } : {}
|
|
8390
9915
|
};
|
|
8391
9916
|
}
|
|
8392
9917
|
const state = json.state === "CLOSED" ? "closed" : json.state === "OPEN" ? "open" : null;
|
|
@@ -8419,7 +9944,8 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
8419
9944
|
const direct = id.match(DIRECT_ISSUE_REF);
|
|
8420
9945
|
if (direct) {
|
|
8421
9946
|
const num = Number(direct[1]);
|
|
8422
|
-
|
|
9947
|
+
const read = fetchIssueState(num, repo);
|
|
9948
|
+
return edgeFromIssueJson(num, read.json, read.readFailed);
|
|
8423
9949
|
}
|
|
8424
9950
|
const qualified = splitSlugQualifiedEdge(id);
|
|
8425
9951
|
if (qualified) {
|
|
@@ -8453,15 +9979,27 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
8453
9979
|
resolved: false
|
|
8454
9980
|
};
|
|
8455
9981
|
}
|
|
9982
|
+
function dependsOnFactFromEdge(id, r) {
|
|
9983
|
+
return {
|
|
9984
|
+
id,
|
|
9985
|
+
issue: r.issue,
|
|
9986
|
+
merged: r.merged,
|
|
9987
|
+
resolved: r.resolved,
|
|
9988
|
+
issueState: r.issueState,
|
|
9989
|
+
stateReason: r.stateReason,
|
|
9990
|
+
closedByActor: r.closedByActor,
|
|
9991
|
+
...r.readFailed ? { readFailed: true } : {}
|
|
9992
|
+
};
|
|
9993
|
+
}
|
|
8456
9994
|
|
|
8457
9995
|
// src/lib/package-root.ts
|
|
8458
|
-
import { existsSync as
|
|
8459
|
-
import { dirname as dirname2, join as
|
|
9996
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
9997
|
+
import { dirname as dirname2, join as join3 } from "node:path";
|
|
8460
9998
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8461
9999
|
function packageRoot(moduleUrl) {
|
|
8462
10000
|
let dir = dirname2(fileURLToPath2(moduleUrl));
|
|
8463
|
-
while (!
|
|
8464
|
-
if (
|
|
10001
|
+
while (!existsSync3(join3(dir, "package.json"))) {
|
|
10002
|
+
if (existsSync3(join3(dir, ".git")))
|
|
8465
10003
|
break;
|
|
8466
10004
|
const parent = dirname2(dir);
|
|
8467
10005
|
if (parent === dir)
|
|
@@ -8472,15 +10010,22 @@ function packageRoot(moduleUrl) {
|
|
|
8472
10010
|
}
|
|
8473
10011
|
|
|
8474
10012
|
// src/commands/doctrine.ts
|
|
8475
|
-
import { execFileSync as
|
|
8476
|
-
import { existsSync as
|
|
8477
|
-
import { dirname as dirname3, join as
|
|
10013
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
10014
|
+
import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync4 } from "node:fs";
|
|
10015
|
+
import { dirname as dirname3, join as join4, sep } from "node:path";
|
|
8478
10016
|
import matter4 from "gray-matter";
|
|
8479
10017
|
|
|
8480
10018
|
// ../../packages/aeg-core/src/docs/parse-doc.ts
|
|
8481
10019
|
import matter2 from "gray-matter";
|
|
8482
10020
|
// ../../packages/aeg-core/src/docs/surfaced-manifest.ts
|
|
8483
10021
|
var NO_MODEL_BACKED_PATHS = new Set;
|
|
10022
|
+
// ../../packages/aeg-core/src/docs/published-prose.ts
|
|
10023
|
+
var ALLOWED_MECHANICS = rulesForGroup("published-prose")[0]?.exemptions ?? [];
|
|
10024
|
+
var PROSE_RULES = rulesForGroup("published-prose").map((rule) => ({
|
|
10025
|
+
id: rule.id,
|
|
10026
|
+
what: rule.message,
|
|
10027
|
+
pattern: rule.patterns.published
|
|
10028
|
+
}));
|
|
8484
10029
|
// src/roles/contract.ts
|
|
8485
10030
|
import matter3 from "gray-matter";
|
|
8486
10031
|
|
|
@@ -8491,7 +10036,7 @@ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.c
|
|
|
8491
10036
|
}
|
|
8492
10037
|
function gitToplevel(cwd) {
|
|
8493
10038
|
try {
|
|
8494
|
-
return
|
|
10039
|
+
return execFileSync6("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
8495
10040
|
encoding: "utf8",
|
|
8496
10041
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8497
10042
|
}).trim();
|
|
@@ -8502,25 +10047,25 @@ function gitToplevel(cwd) {
|
|
|
8502
10047
|
function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
8503
10048
|
const toplevel = gitToplevel(cwd);
|
|
8504
10049
|
if (toplevel !== null) {
|
|
8505
|
-
const treeRoot =
|
|
8506
|
-
if (
|
|
10050
|
+
const treeRoot = join4(toplevel, "aeg-root");
|
|
10051
|
+
if (existsSync4(join4(treeRoot, "roles")))
|
|
8507
10052
|
return { root: treeRoot, source: "tree" };
|
|
8508
10053
|
}
|
|
8509
10054
|
const fromSource = !pkg.split(sep).includes("node_modules");
|
|
8510
|
-
const bundleRoot = fromSource ?
|
|
10055
|
+
const bundleRoot = fromSource ? join4(dirname3(dirname3(pkg)), "aeg-root") : join4(pkg, "aeg-root");
|
|
8511
10056
|
return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
|
|
8512
10057
|
}
|
|
8513
10058
|
function hasDoctrineEntry(root) {
|
|
8514
|
-
return
|
|
10059
|
+
return existsSync4(join4(root, ...ENTRY_SEGMENTS));
|
|
8515
10060
|
}
|
|
8516
10061
|
|
|
8517
10062
|
// src/lib/brief-assembly.ts
|
|
8518
10063
|
var PACKAGE_ROOT = packageRoot(import.meta.url);
|
|
8519
|
-
var PACKAGED_TEMPLATE_PATH =
|
|
8520
|
-
var TEMPLATE_PATH =
|
|
10064
|
+
var PACKAGED_TEMPLATE_PATH = join5(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
|
|
10065
|
+
var TEMPLATE_PATH = existsSync5(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join5(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
8521
10066
|
function git(args) {
|
|
8522
10067
|
try {
|
|
8523
|
-
return
|
|
10068
|
+
return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
8524
10069
|
} catch {
|
|
8525
10070
|
return "";
|
|
8526
10071
|
}
|
|
@@ -8533,24 +10078,25 @@ function expandGlob(glob) {
|
|
|
8533
10078
|
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
8534
10079
|
|
|
8535
10080
|
// src/checks/registry.ts
|
|
8536
|
-
import { join as
|
|
10081
|
+
import { join as join6, relative, sep as sep2 } from "node:path";
|
|
8537
10082
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
8538
10083
|
function resolveCheckBin(packageDir, moduleUrl) {
|
|
8539
10084
|
const fromPackage = relative(packageDir, fileURLToPath3(moduleUrl));
|
|
8540
10085
|
const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep2}`);
|
|
8541
|
-
return bundled ? { dir:
|
|
10086
|
+
return bundled ? { dir: join6(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join6(packageDir, "src", "checks", "bin"), ext: ".ts" };
|
|
8542
10087
|
}
|
|
8543
10088
|
var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
|
|
8544
10089
|
var BIN_DIR = CHECK_BIN.dir;
|
|
8545
10090
|
var BIN_EXT = CHECK_BIN.ext;
|
|
8546
10091
|
function bin(name) {
|
|
8547
|
-
return
|
|
10092
|
+
return join6(BIN_DIR, `${name}${BIN_EXT}`);
|
|
8548
10093
|
}
|
|
8549
10094
|
var REGISTRY = [
|
|
8550
10095
|
[
|
|
8551
10096
|
{
|
|
8552
10097
|
name: "brief-shape",
|
|
8553
10098
|
validates: "body",
|
|
10099
|
+
requiresOpenPr: true,
|
|
8554
10100
|
run: bin("check-brief-shape"),
|
|
8555
10101
|
scope: "diff",
|
|
8556
10102
|
timeoutMs: 15000,
|
|
@@ -8559,7 +10105,9 @@ var REGISTRY = [
|
|
|
8559
10105
|
BRANCH: { optional: true },
|
|
8560
10106
|
PR_NUMBER: { optional: true },
|
|
8561
10107
|
GITHUB_TOKEN: { optional: true },
|
|
8562
|
-
GH_TOKEN: { optional: true }
|
|
10108
|
+
GH_TOKEN: { optional: true },
|
|
10109
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10110
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8563
10111
|
}
|
|
8564
10112
|
},
|
|
8565
10113
|
0
|
|
@@ -8568,6 +10116,7 @@ var REGISTRY = [
|
|
|
8568
10116
|
{
|
|
8569
10117
|
name: "pr-report-density",
|
|
8570
10118
|
validates: "body",
|
|
10119
|
+
requiresOpenPr: true,
|
|
8571
10120
|
run: bin("check-pr-report-density"),
|
|
8572
10121
|
scope: "diff",
|
|
8573
10122
|
timeoutMs: 15000,
|
|
@@ -8593,7 +10142,9 @@ var REGISTRY = [
|
|
|
8593
10142
|
PR_NUMBER: { optional: true },
|
|
8594
10143
|
GITHUB_REPOSITORY: { optional: true },
|
|
8595
10144
|
GITHUB_TOKEN: { optional: true },
|
|
8596
|
-
GH_TOKEN: { optional: true }
|
|
10145
|
+
GH_TOKEN: { optional: true },
|
|
10146
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10147
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8597
10148
|
}
|
|
8598
10149
|
},
|
|
8599
10150
|
0
|
|
@@ -8617,6 +10168,7 @@ var REGISTRY = [
|
|
|
8617
10168
|
{
|
|
8618
10169
|
name: "pr-premise-reassert",
|
|
8619
10170
|
validates: "body",
|
|
10171
|
+
requiresOpenPr: true,
|
|
8620
10172
|
run: bin("check-pr-premise-reassert"),
|
|
8621
10173
|
scope: "diff",
|
|
8622
10174
|
timeoutMs: 15000,
|
|
@@ -8637,7 +10189,9 @@ var REGISTRY = [
|
|
|
8637
10189
|
BRANCH: { optional: true },
|
|
8638
10190
|
GITHUB_TOKEN: { optional: true },
|
|
8639
10191
|
GH_TOKEN: { optional: true },
|
|
8640
|
-
PREMISE_FILE: { optional: true }
|
|
10192
|
+
PREMISE_FILE: { optional: true },
|
|
10193
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10194
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8641
10195
|
}
|
|
8642
10196
|
},
|
|
8643
10197
|
0
|
|
@@ -8689,7 +10243,9 @@ var REGISTRY = [
|
|
|
8689
10243
|
PR_BODY: { optional: true },
|
|
8690
10244
|
PR_BODY_FILE: { optional: true },
|
|
8691
10245
|
GITHUB_TOKEN: { optional: true },
|
|
8692
|
-
GH_TOKEN: { optional: true }
|
|
10246
|
+
GH_TOKEN: { optional: true },
|
|
10247
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10248
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8693
10249
|
}
|
|
8694
10250
|
},
|
|
8695
10251
|
1
|
|
@@ -8705,7 +10261,13 @@ var REGISTRY = [
|
|
|
8705
10261
|
principalOwed: true,
|
|
8706
10262
|
env: {
|
|
8707
10263
|
PR_BODY: { optional: true },
|
|
8708
|
-
BRANCH: { optional: true }
|
|
10264
|
+
BRANCH: { optional: true },
|
|
10265
|
+
PULL_REQUEST_HEAD_SHA: { optional: true },
|
|
10266
|
+
GITHUB_REPOSITORY: { optional: true },
|
|
10267
|
+
GITHUB_TOKEN: { optional: true },
|
|
10268
|
+
GH_TOKEN: { optional: true },
|
|
10269
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10270
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8709
10271
|
}
|
|
8710
10272
|
},
|
|
8711
10273
|
1
|
|
@@ -8721,7 +10283,13 @@ var REGISTRY = [
|
|
|
8721
10283
|
ownWorkflow: true,
|
|
8722
10284
|
env: {
|
|
8723
10285
|
PR_BODY: { optional: true },
|
|
8724
|
-
BRANCH: { optional: true }
|
|
10286
|
+
BRANCH: { optional: true },
|
|
10287
|
+
PULL_REQUEST_HEAD_SHA: { optional: true },
|
|
10288
|
+
GITHUB_REPOSITORY: { optional: true },
|
|
10289
|
+
GITHUB_TOKEN: { optional: true },
|
|
10290
|
+
GH_TOKEN: { optional: true },
|
|
10291
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10292
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8725
10293
|
}
|
|
8726
10294
|
},
|
|
8727
10295
|
1
|
|
@@ -8740,7 +10308,9 @@ var REGISTRY = [
|
|
|
8740
10308
|
PR_NUMBER: { optional: true },
|
|
8741
10309
|
GITHUB_REPOSITORY: { optional: true },
|
|
8742
10310
|
GITHUB_TOKEN: { optional: true },
|
|
8743
|
-
GH_TOKEN: { optional: true }
|
|
10311
|
+
GH_TOKEN: { optional: true },
|
|
10312
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10313
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8744
10314
|
}
|
|
8745
10315
|
},
|
|
8746
10316
|
1
|
|
@@ -8780,7 +10350,9 @@ var REGISTRY = [
|
|
|
8780
10350
|
PR_NUMBER: { optional: true },
|
|
8781
10351
|
GITHUB_REPOSITORY: { optional: true },
|
|
8782
10352
|
GITHUB_TOKEN: { optional: true },
|
|
8783
|
-
GH_TOKEN: { optional: true }
|
|
10353
|
+
GH_TOKEN: { optional: true },
|
|
10354
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10355
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8784
10356
|
}
|
|
8785
10357
|
},
|
|
8786
10358
|
1
|
|
@@ -8833,12 +10405,15 @@ var REGISTRY = [
|
|
|
8833
10405
|
{
|
|
8834
10406
|
name: "doc-coverage-push",
|
|
8835
10407
|
validates: "body",
|
|
10408
|
+
advisory: true,
|
|
8836
10409
|
run: bin("check-doc-coverage-push"),
|
|
8837
10410
|
scope: "diff",
|
|
8838
10411
|
timeoutMs: 15000,
|
|
8839
10412
|
env: {
|
|
8840
10413
|
OVERRIDE_DOCS: { optional: true },
|
|
8841
10414
|
BASE_SHA: { optional: true },
|
|
10415
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10416
|
+
VINAYA_COMMIT_HOOK: { optional: true },
|
|
8842
10417
|
PR_BODY: { optional: true },
|
|
8843
10418
|
PR_BODY_FILE: { optional: true },
|
|
8844
10419
|
PR_LABELS: { optional: true },
|
|
@@ -8850,21 +10425,6 @@ var REGISTRY = [
|
|
|
8850
10425
|
},
|
|
8851
10426
|
0
|
|
8852
10427
|
],
|
|
8853
|
-
[
|
|
8854
|
-
{
|
|
8855
|
-
name: "issue-assignment",
|
|
8856
|
-
run: bin("check-issue-assignment"),
|
|
8857
|
-
scope: "full",
|
|
8858
|
-
timeoutMs: 30000,
|
|
8859
|
-
env: {
|
|
8860
|
-
AEG_REPO: { optional: true },
|
|
8861
|
-
BRANCH: { optional: true },
|
|
8862
|
-
GITHUB_TOKEN: { optional: true },
|
|
8863
|
-
GH_TOKEN: { optional: true }
|
|
8864
|
-
}
|
|
8865
|
-
},
|
|
8866
|
-
0
|
|
8867
|
-
],
|
|
8868
10428
|
[
|
|
8869
10429
|
{
|
|
8870
10430
|
name: "evidence-fresh",
|
|
@@ -8878,7 +10438,9 @@ var REGISTRY = [
|
|
|
8878
10438
|
PR_BODY: { optional: true },
|
|
8879
10439
|
BASE_SHA: { optional: true },
|
|
8880
10440
|
GITHUB_TOKEN: { optional: true },
|
|
8881
|
-
GH_TOKEN: { optional: true }
|
|
10441
|
+
GH_TOKEN: { optional: true },
|
|
10442
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10443
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8882
10444
|
}
|
|
8883
10445
|
},
|
|
8884
10446
|
1
|
|
@@ -8889,7 +10451,11 @@ var REGISTRY = [
|
|
|
8889
10451
|
run: bin("check-reader-resolvable-prose"),
|
|
8890
10452
|
scope: "full",
|
|
8891
10453
|
timeoutMs: 30000,
|
|
8892
|
-
env: {
|
|
10454
|
+
env: {
|
|
10455
|
+
BASE_SHA: { optional: true },
|
|
10456
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10457
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10458
|
+
},
|
|
8893
10459
|
include: [
|
|
8894
10460
|
"aeg-root/**/*.md",
|
|
8895
10461
|
"apps/cli/src/**",
|
|
@@ -8907,7 +10473,11 @@ var REGISTRY = [
|
|
|
8907
10473
|
run: bin("check-retired-vocabulary"),
|
|
8908
10474
|
scope: "full",
|
|
8909
10475
|
timeoutMs: 30000,
|
|
8910
|
-
env: {
|
|
10476
|
+
env: {
|
|
10477
|
+
BASE_SHA: { optional: true },
|
|
10478
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10479
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10480
|
+
},
|
|
8911
10481
|
include: ["aeg-root/**/*.md"]
|
|
8912
10482
|
},
|
|
8913
10483
|
0
|
|
@@ -8915,10 +10485,15 @@ var REGISTRY = [
|
|
|
8915
10485
|
[
|
|
8916
10486
|
{
|
|
8917
10487
|
name: "doctrine-portability",
|
|
10488
|
+
advisory: true,
|
|
8918
10489
|
run: bin("check-doctrine-portability"),
|
|
8919
10490
|
scope: "full",
|
|
8920
10491
|
timeoutMs: 30000,
|
|
8921
|
-
env: {
|
|
10492
|
+
env: {
|
|
10493
|
+
BASE_SHA: { optional: true },
|
|
10494
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10495
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10496
|
+
},
|
|
8922
10497
|
include: ["aeg-root/**/*.md"]
|
|
8923
10498
|
},
|
|
8924
10499
|
0
|
|
@@ -8951,7 +10526,11 @@ var REGISTRY = [
|
|
|
8951
10526
|
run: bin("check-exec-bits"),
|
|
8952
10527
|
scope: "diff",
|
|
8953
10528
|
timeoutMs: 30000,
|
|
8954
|
-
env: {
|
|
10529
|
+
env: {
|
|
10530
|
+
BASE_SHA: { optional: true },
|
|
10531
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10532
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10533
|
+
}
|
|
8955
10534
|
},
|
|
8956
10535
|
0
|
|
8957
10536
|
],
|
|
@@ -8961,17 +10540,26 @@ var REGISTRY = [
|
|
|
8961
10540
|
run: bin("check-ci-shard-coverage"),
|
|
8962
10541
|
scope: "diff",
|
|
8963
10542
|
timeoutMs: 15000,
|
|
8964
|
-
env: {
|
|
10543
|
+
env: {
|
|
10544
|
+
BASE_SHA: { optional: true },
|
|
10545
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10546
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10547
|
+
}
|
|
8965
10548
|
},
|
|
8966
10549
|
0
|
|
8967
10550
|
],
|
|
8968
10551
|
[
|
|
8969
10552
|
{
|
|
8970
10553
|
name: "workspace-escape",
|
|
10554
|
+
advisory: true,
|
|
8971
10555
|
run: bin("check-workspace-escape"),
|
|
8972
10556
|
scope: "full",
|
|
8973
10557
|
timeoutMs: 30000,
|
|
8974
|
-
env: {
|
|
10558
|
+
env: {
|
|
10559
|
+
BASE_SHA: { optional: true },
|
|
10560
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10561
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10562
|
+
},
|
|
8975
10563
|
include: ["aeg-root/**/*.md"]
|
|
8976
10564
|
},
|
|
8977
10565
|
0
|
|
@@ -8982,17 +10570,23 @@ var REGISTRY = [
|
|
|
8982
10570
|
run: bin("check-changeset-coverage"),
|
|
8983
10571
|
scope: "diff",
|
|
8984
10572
|
timeoutMs: 15000,
|
|
8985
|
-
env: {
|
|
10573
|
+
env: {
|
|
10574
|
+
BASE_SHA: { optional: true },
|
|
10575
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10576
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10577
|
+
}
|
|
8986
10578
|
},
|
|
8987
10579
|
0
|
|
8988
10580
|
],
|
|
8989
10581
|
[
|
|
8990
10582
|
{
|
|
8991
10583
|
name: "quoted-command",
|
|
10584
|
+
advisory: true,
|
|
8992
10585
|
run: bin("check-quoted-command"),
|
|
8993
|
-
scope: "
|
|
10586
|
+
scope: "full",
|
|
8994
10587
|
timeoutMs: 15000,
|
|
8995
|
-
env: {}
|
|
10588
|
+
env: {},
|
|
10589
|
+
include: ["aeg-root/**/*.md"]
|
|
8996
10590
|
},
|
|
8997
10591
|
0
|
|
8998
10592
|
],
|
|
@@ -9000,7 +10594,7 @@ var REGISTRY = [
|
|
|
9000
10594
|
{
|
|
9001
10595
|
name: "main-branch-refusal",
|
|
9002
10596
|
run: bin("check-main-branch-refusal"),
|
|
9003
|
-
scope: "
|
|
10597
|
+
scope: "diff",
|
|
9004
10598
|
timeoutMs: 15000,
|
|
9005
10599
|
env: { VINAYA_PUSH_REFS: { optional: true } }
|
|
9006
10600
|
},
|
|
@@ -9067,18 +10661,6 @@ var REGISTRY = [
|
|
|
9067
10661
|
},
|
|
9068
10662
|
1
|
|
9069
10663
|
],
|
|
9070
|
-
[
|
|
9071
|
-
{
|
|
9072
|
-
name: "issue-tranche-label",
|
|
9073
|
-
run: bin("check-issue-tranche-label"),
|
|
9074
|
-
validates: "issue",
|
|
9075
|
-
scope: "full",
|
|
9076
|
-
ownWorkflow: true,
|
|
9077
|
-
timeoutMs: 15000,
|
|
9078
|
-
env: { ISSUE_BODY: { optional: true }, ISSUE_LABELS: { optional: true } }
|
|
9079
|
-
},
|
|
9080
|
-
1
|
|
9081
|
-
],
|
|
9082
10664
|
[
|
|
9083
10665
|
{
|
|
9084
10666
|
name: "issue-milestone-attach",
|
|
@@ -9108,24 +10690,24 @@ import {
|
|
|
9108
10690
|
appendFileSync,
|
|
9109
10691
|
closeSync as closeSync4,
|
|
9110
10692
|
constants as fsConstants4,
|
|
9111
|
-
existsSync as
|
|
10693
|
+
existsSync as existsSync8,
|
|
9112
10694
|
fstatSync as fstatSync3,
|
|
9113
10695
|
mkdirSync as mkdirSync4,
|
|
9114
10696
|
lstatSync as lstatSync2,
|
|
9115
10697
|
openSync as openSync4,
|
|
9116
|
-
readFileSync as
|
|
10698
|
+
readFileSync as readFileSync8,
|
|
9117
10699
|
renameSync as renameSync2,
|
|
9118
|
-
writeFileSync as
|
|
10700
|
+
writeFileSync as writeFileSync4,
|
|
9119
10701
|
writeSync as writeSync3
|
|
9120
10702
|
} from "node:fs";
|
|
9121
10703
|
import { hostname as osHostname, homedir as homedir3 } from "node:os";
|
|
9122
|
-
import { dirname as dirname7, join as
|
|
10704
|
+
import { dirname as dirname7, join as join9 } from "node:path";
|
|
9123
10705
|
import { promisify as promisify5 } from "node:util";
|
|
9124
10706
|
|
|
9125
10707
|
// src/lib/run-paths.ts
|
|
9126
|
-
import { execFileSync as
|
|
9127
|
-
import { chmodSync, existsSync as
|
|
9128
|
-
import { dirname as dirname4, join as
|
|
10708
|
+
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
10709
|
+
import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync3 } from "node:fs";
|
|
10710
|
+
import { dirname as dirname4, join as join7, resolve as resolvePath } from "node:path";
|
|
9129
10711
|
var TASKS_EXECUTION_DIRNAME = "tasks-execution";
|
|
9130
10712
|
var RUN_AREA_DIRNAMES = {
|
|
9131
10713
|
control: CONTROL_AREA_DIRNAME,
|
|
@@ -9144,7 +10726,7 @@ function repoSegment(repo) {
|
|
|
9144
10726
|
return `${repo.owner}-${repo.repo}`;
|
|
9145
10727
|
}
|
|
9146
10728
|
function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
|
|
9147
|
-
return
|
|
10729
|
+
return join7(home, "runtime", repoSegment(repo));
|
|
9148
10730
|
}
|
|
9149
10731
|
function resolveRuntimeDir(input) {
|
|
9150
10732
|
const local = resolveRuntimeDirSetting(input.localConfig);
|
|
@@ -9165,27 +10747,27 @@ function isInsideRepo(candidate, repoRoot) {
|
|
|
9165
10747
|
return target === root || target.startsWith(`${root}/`);
|
|
9166
10748
|
}
|
|
9167
10749
|
function runPath(runtimeDir, scope, location) {
|
|
9168
|
-
const dir =
|
|
10750
|
+
const dir = join7(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
|
|
9169
10751
|
switch (location.area) {
|
|
9170
10752
|
case "task":
|
|
9171
|
-
return location.file ?
|
|
10753
|
+
return location.file ? join7(dir, location.file) : dir;
|
|
9172
10754
|
case "control": {
|
|
9173
|
-
const controlDir =
|
|
9174
|
-
return location.file ?
|
|
10755
|
+
const controlDir = join7(dir, RUN_AREA_DIRNAMES.control);
|
|
10756
|
+
return location.file ? join7(controlDir, location.file) : controlDir;
|
|
9175
10757
|
}
|
|
9176
10758
|
case "rounds":
|
|
9177
|
-
return
|
|
10759
|
+
return join7(dir, RUN_AREA_DIRNAMES.rounds);
|
|
9178
10760
|
case "round": {
|
|
9179
|
-
const roundDir =
|
|
9180
|
-
return location.file ?
|
|
10761
|
+
const roundDir = join7(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
|
|
10762
|
+
return location.file ? join7(roundDir, location.file) : roundDir;
|
|
9181
10763
|
}
|
|
9182
10764
|
case "developer": {
|
|
9183
|
-
const developerDir =
|
|
9184
|
-
return location.file ?
|
|
10765
|
+
const developerDir = join7(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
|
|
10766
|
+
return location.file ? join7(developerDir, location.file) : developerDir;
|
|
9185
10767
|
}
|
|
9186
10768
|
default: {
|
|
9187
|
-
const areaDir =
|
|
9188
|
-
return location.file ?
|
|
10769
|
+
const areaDir = join7(dir, RUN_AREA_DIRNAMES[location.area]);
|
|
10770
|
+
return location.file ? join7(areaDir, location.file) : areaDir;
|
|
9189
10771
|
}
|
|
9190
10772
|
}
|
|
9191
10773
|
}
|
|
@@ -9254,7 +10836,7 @@ function repoRootSync(start = process.cwd()) {
|
|
|
9254
10836
|
return null;
|
|
9255
10837
|
}
|
|
9256
10838
|
for (;; ) {
|
|
9257
|
-
if (
|
|
10839
|
+
if (existsSync6(join7(dir, ".git")))
|
|
9258
10840
|
return dir;
|
|
9259
10841
|
const parent = dirname4(dir);
|
|
9260
10842
|
if (parent === dir)
|
|
@@ -9271,7 +10853,7 @@ function resolveRepoSync() {
|
|
|
9271
10853
|
}
|
|
9272
10854
|
let url;
|
|
9273
10855
|
try {
|
|
9274
|
-
url =
|
|
10856
|
+
url = execFileSync8("git", ["remote", "get-url", "origin"], {
|
|
9275
10857
|
encoding: "utf-8",
|
|
9276
10858
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9277
10859
|
}).trim();
|
|
@@ -9298,11 +10880,11 @@ function runtimeDirForThisRepo() {
|
|
|
9298
10880
|
import {
|
|
9299
10881
|
closeSync as closeSync2,
|
|
9300
10882
|
constants as fsConstants2,
|
|
9301
|
-
existsSync as
|
|
10883
|
+
existsSync as existsSync7,
|
|
9302
10884
|
fstatSync as fstatSync2,
|
|
9303
10885
|
mkdirSync as mkdirSync2,
|
|
9304
10886
|
openSync as openSync2,
|
|
9305
|
-
readFileSync as
|
|
10887
|
+
readFileSync as readFileSync6,
|
|
9306
10888
|
readSync,
|
|
9307
10889
|
statSync,
|
|
9308
10890
|
writeSync
|
|
@@ -9339,17 +10921,17 @@ import {
|
|
|
9339
10921
|
mkdirSync as mkdirSync3,
|
|
9340
10922
|
openSync as openSync3,
|
|
9341
10923
|
linkSync,
|
|
9342
|
-
readFileSync as
|
|
10924
|
+
readFileSync as readFileSync7,
|
|
9343
10925
|
renameSync,
|
|
9344
10926
|
statSync as statSync2,
|
|
9345
10927
|
unlinkSync,
|
|
9346
10928
|
utimesSync,
|
|
9347
|
-
writeFileSync as
|
|
10929
|
+
writeFileSync as writeFileSync3,
|
|
9348
10930
|
writeSync as writeSync2
|
|
9349
10931
|
} from "node:fs";
|
|
9350
10932
|
import { randomUUID } from "node:crypto";
|
|
9351
10933
|
import { homedir as homedir2 } from "node:os";
|
|
9352
|
-
import { dirname as dirname6, join as
|
|
10934
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
9353
10935
|
var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
|
|
9354
10936
|
var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
|
|
9355
10937
|
var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
@@ -9430,7 +11012,7 @@ function acquireDrainLock(lockPath) {
|
|
|
9430
11012
|
function renewDrainLock(lockPath, token) {
|
|
9431
11013
|
let holder;
|
|
9432
11014
|
try {
|
|
9433
|
-
holder =
|
|
11015
|
+
holder = readFileSync7(lockPath, "utf8").trim();
|
|
9434
11016
|
} catch (err) {
|
|
9435
11017
|
if (!isEnoent(err))
|
|
9436
11018
|
throw err;
|
|
@@ -9450,7 +11032,7 @@ function renewDrainLock(lockPath, token) {
|
|
|
9450
11032
|
}
|
|
9451
11033
|
function releaseDrainLock(lockPath, token) {
|
|
9452
11034
|
try {
|
|
9453
|
-
const holder =
|
|
11035
|
+
const holder = readFileSync7(lockPath, "utf8").trim();
|
|
9454
11036
|
if (holder !== token)
|
|
9455
11037
|
return;
|
|
9456
11038
|
unlinkSync(lockPath);
|
|
@@ -9500,8 +11082,8 @@ function queueLines(buf) {
|
|
|
9500
11082
|
return lines;
|
|
9501
11083
|
}
|
|
9502
11084
|
function removeQueueHead(path, cut) {
|
|
9503
|
-
const remaining =
|
|
9504
|
-
|
|
11085
|
+
const remaining = readFileSync7(path);
|
|
11086
|
+
writeFileSync3(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
|
|
9505
11087
|
}
|
|
9506
11088
|
function queueBucketSize(path) {
|
|
9507
11089
|
let lstat;
|
|
@@ -9521,7 +11103,7 @@ function queueBucketSize(path) {
|
|
|
9521
11103
|
function readQueueFile(path) {
|
|
9522
11104
|
if (queueBucketSize(path) === null)
|
|
9523
11105
|
return null;
|
|
9524
|
-
return
|
|
11106
|
+
return readFileSync7(path);
|
|
9525
11107
|
}
|
|
9526
11108
|
function rejectLine(rejectedPath, reason, status, identity, raw) {
|
|
9527
11109
|
const record = JSON.stringify({
|
|
@@ -9636,7 +11218,7 @@ async function drainRenamedAside(args, livePath, source) {
|
|
|
9636
11218
|
async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
|
|
9637
11219
|
const resolved = await resolveRepo();
|
|
9638
11220
|
const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
|
|
9639
|
-
const outboxRoot = () =>
|
|
11221
|
+
const outboxRoot = () => join8(GLOBAL_VINAYA_HOME, "outbox");
|
|
9640
11222
|
const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
|
|
9641
11223
|
const lockPath = `${path}.flush-lock`;
|
|
9642
11224
|
const lockToken = acquireDrainLock(lockPath);
|
|
@@ -9773,7 +11355,7 @@ async function defaultResolveLogDestination(repo, env) {
|
|
|
9773
11355
|
trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
|
|
9774
11356
|
unattended,
|
|
9775
11357
|
env,
|
|
9776
|
-
defaultFolder:
|
|
11358
|
+
defaultFolder: join9(await runtimeDirForRepoAsync(repo), "logs"),
|
|
9777
11359
|
repoRoot
|
|
9778
11360
|
});
|
|
9779
11361
|
}
|
|
@@ -9789,7 +11371,7 @@ function unresolvedLogDestination(env) {
|
|
|
9789
11371
|
const unattended = isUnattendedProcess(process.env);
|
|
9790
11372
|
const repoRoot = repoRootSync();
|
|
9791
11373
|
const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
|
|
9792
|
-
const defaultFolder =
|
|
11374
|
+
const defaultFolder = join9(runtimeDir, "logs");
|
|
9793
11375
|
const resolved = resolveLogDestinationFrom({
|
|
9794
11376
|
localConfig,
|
|
9795
11377
|
trustAnchorConfig: null,
|
|
@@ -9802,7 +11384,7 @@ function unresolvedLogDestination(env) {
|
|
|
9802
11384
|
}
|
|
9803
11385
|
function folderFallbackStatePath(repo, stateRoot = GLOBAL_VINAYA_HOME) {
|
|
9804
11386
|
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
9805
|
-
return
|
|
11387
|
+
return join9(stateRoot, "fallback", `${dirName}.json`);
|
|
9806
11388
|
}
|
|
9807
11389
|
function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot = GLOBAL_VINAYA_HOME) {
|
|
9808
11390
|
const message = describeFolderFallback(reason);
|
|
@@ -9818,7 +11400,7 @@ function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot =
|
|
|
9818
11400
|
};
|
|
9819
11401
|
const path = folderFallbackStatePath(repo, stateRoot);
|
|
9820
11402
|
mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
|
|
9821
|
-
|
|
11403
|
+
writeFileSync4(path, `${JSON.stringify(record)}
|
|
9822
11404
|
`, { mode: 384 });
|
|
9823
11405
|
} catch {}
|
|
9824
11406
|
}
|
|
@@ -9833,7 +11415,7 @@ async function resolveDoctrine(cwd, vinayaVersion) {
|
|
|
9833
11415
|
} catch (err) {
|
|
9834
11416
|
return isEnoent2(err) ? "unknown" : vinayaVersion;
|
|
9835
11417
|
}
|
|
9836
|
-
if (!
|
|
11418
|
+
if (!existsSync8(join9(toplevel, "aeg-root", "roles")))
|
|
9837
11419
|
return vinayaVersion;
|
|
9838
11420
|
try {
|
|
9839
11421
|
const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
|
|
@@ -9934,7 +11516,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
|
|
|
9934
11516
|
}
|
|
9935
11517
|
function readVinayaVersion() {
|
|
9936
11518
|
try {
|
|
9937
|
-
const pkg = JSON.parse(
|
|
11519
|
+
const pkg = JSON.parse(readFileSync8(join9(packageRoot(import.meta.url), "package.json"), "utf8"));
|
|
9938
11520
|
return pkg.version ?? "unknown";
|
|
9939
11521
|
} catch {
|
|
9940
11522
|
return "unknown";
|
|
@@ -9952,7 +11534,7 @@ function safeRepoSlug(repo) {
|
|
|
9952
11534
|
function outboxPathFor(deps, repo, issue) {
|
|
9953
11535
|
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
9954
11536
|
const fileName = `${issue ?? "none"}.ndjson`;
|
|
9955
|
-
return
|
|
11537
|
+
return join9(deps.outboxRoot(), dirName, fileName);
|
|
9956
11538
|
}
|
|
9957
11539
|
function hostFromEnv(env) {
|
|
9958
11540
|
if (env.GITHUB_ACTIONS)
|
|
@@ -10007,7 +11589,7 @@ async function resolveHeadSha(cwd) {
|
|
|
10007
11589
|
}
|
|
10008
11590
|
function defaultDeps() {
|
|
10009
11591
|
return {
|
|
10010
|
-
outboxRoot: () =>
|
|
11592
|
+
outboxRoot: () => join9(GLOBAL_VINAYA_HOME, "outbox"),
|
|
10011
11593
|
home: () => homedir3(),
|
|
10012
11594
|
hostname: () => osHostname(),
|
|
10013
11595
|
cwd: () => process.cwd(),
|
|
@@ -10052,7 +11634,7 @@ function appendHardenedLine(path, line) {
|
|
|
10052
11634
|
function reportRotationOverflow(backupPath, warn) {
|
|
10053
11635
|
let raw;
|
|
10054
11636
|
try {
|
|
10055
|
-
raw =
|
|
11637
|
+
raw = readFileSync8(backupPath, "utf8");
|
|
10056
11638
|
} catch {
|
|
10057
11639
|
return;
|
|
10058
11640
|
}
|
|
@@ -10265,12 +11847,14 @@ function createLogSink(overrides = {}) {
|
|
|
10265
11847
|
branchIssue,
|
|
10266
11848
|
eventId: randomUUID2(),
|
|
10267
11849
|
processId,
|
|
11850
|
+
revision: headSha,
|
|
11851
|
+
provenance: deps.provenance,
|
|
10268
11852
|
inputVersions: deps.inputVersions()
|
|
10269
11853
|
});
|
|
10270
11854
|
const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
|
|
10271
11855
|
if (destination.kind === "folder" && destination.fallbackReason && !folderFallbackRecorded) {
|
|
10272
11856
|
folderFallbackRecorded = true;
|
|
10273
|
-
recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname7(destination.folder),
|
|
11857
|
+
recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname7(destination.folder), join9(deps.home(), ".vinaya"));
|
|
10274
11858
|
}
|
|
10275
11859
|
const full = { ...e, ...header };
|
|
10276
11860
|
const parsed = LogEventSchema.safeParse(full);
|
|
@@ -10355,13 +11939,6 @@ function createLogSink(overrides = {}) {
|
|
|
10355
11939
|
}
|
|
10356
11940
|
var defaultSink = createLogSink();
|
|
10357
11941
|
|
|
10358
|
-
// src/checks/contract.ts
|
|
10359
|
-
var CHECK_SCHEMA_VERSION = 1;
|
|
10360
|
-
function emitCheckError(error) {
|
|
10361
|
-
process.stderr.write(`${JSON.stringify(error)}
|
|
10362
|
-
`);
|
|
10363
|
-
}
|
|
10364
|
-
|
|
10365
11942
|
// src/checks/runner.ts
|
|
10366
11943
|
var activeChecks = new Map;
|
|
10367
11944
|
|
|
@@ -10402,20 +11979,40 @@ function parseChangedLineRanges(diffOutput) {
|
|
|
10402
11979
|
|
|
10403
11980
|
// src/lib/diff-evidence.ts
|
|
10404
11981
|
function fileDiffAgainst(ref, path) {
|
|
10405
|
-
let
|
|
11982
|
+
let committed;
|
|
10406
11983
|
try {
|
|
10407
|
-
|
|
11984
|
+
committed = execFileSync9("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
10408
11985
|
encoding: "utf8",
|
|
10409
11986
|
stdio: ["ignore", "pipe", "pipe"]
|
|
10410
11987
|
}).trim();
|
|
10411
11988
|
} catch {
|
|
10412
11989
|
return null;
|
|
10413
11990
|
}
|
|
11991
|
+
const staged = stagedDiff(["--", path]);
|
|
11992
|
+
if (staged === null)
|
|
11993
|
+
return null;
|
|
11994
|
+
const out = [committed, staged].filter(Boolean).join(`
|
|
11995
|
+
`);
|
|
10414
11996
|
return out === "" ? null : out;
|
|
10415
11997
|
}
|
|
11998
|
+
function readsStagedDiff() {
|
|
11999
|
+
return process.env.VINAYA_COMMIT_HOOK === "1" && Boolean(process.env.GIT_INDEX_FILE);
|
|
12000
|
+
}
|
|
12001
|
+
function stagedDiff(args) {
|
|
12002
|
+
if (!readsStagedDiff())
|
|
12003
|
+
return "";
|
|
12004
|
+
try {
|
|
12005
|
+
return execFileSync9("git", ["diff", "--cached", ...args], {
|
|
12006
|
+
encoding: "utf8",
|
|
12007
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
12008
|
+
}).trim();
|
|
12009
|
+
} catch {
|
|
12010
|
+
return null;
|
|
12011
|
+
}
|
|
12012
|
+
}
|
|
10416
12013
|
function revParse(ref) {
|
|
10417
12014
|
try {
|
|
10418
|
-
return
|
|
12015
|
+
return execFileSync9("git", ["rev-parse", "--verify", ref], {
|
|
10419
12016
|
encoding: "utf8",
|
|
10420
12017
|
stdio: ["ignore", "pipe", "pipe"]
|
|
10421
12018
|
}).trim();
|
|
@@ -10425,7 +12022,7 @@ function revParse(ref) {
|
|
|
10425
12022
|
}
|
|
10426
12023
|
function repoRoot() {
|
|
10427
12024
|
try {
|
|
10428
|
-
return
|
|
12025
|
+
return execFileSync9("git", ["rev-parse", "--show-toplevel"], {
|
|
10429
12026
|
encoding: "utf8",
|
|
10430
12027
|
stdio: ["ignore", "pipe", "pipe"]
|
|
10431
12028
|
}).trim();
|
|
@@ -10436,7 +12033,7 @@ function repoRoot() {
|
|
|
10436
12033
|
function changedFiles(base) {
|
|
10437
12034
|
let out;
|
|
10438
12035
|
try {
|
|
10439
|
-
out =
|
|
12036
|
+
out = execFileSync9("git", ["diff", "--name-only", `${base}...HEAD`], {
|
|
10440
12037
|
encoding: "utf8",
|
|
10441
12038
|
stdio: ["ignore", "pipe", "pipe"]
|
|
10442
12039
|
}).trim();
|
|
@@ -10446,6 +12043,13 @@ function changedFiles(base) {
|
|
|
10446
12043
|
return out === "" ? [] : out.split(`
|
|
10447
12044
|
`).map((s) => s.trim()).filter(Boolean);
|
|
10448
12045
|
}
|
|
12046
|
+
function stagedChangedFiles() {
|
|
12047
|
+
const out = stagedDiff(["--name-only"]);
|
|
12048
|
+
if (out === null)
|
|
12049
|
+
return null;
|
|
12050
|
+
return out === "" ? [] : out.split(`
|
|
12051
|
+
`).map((s) => s.trim()).filter(Boolean);
|
|
12052
|
+
}
|
|
10449
12053
|
function resolveChangedFiles(base = process.env.BASE_SHA || "origin/main") {
|
|
10450
12054
|
return resolveDiff(base)?.files ?? null;
|
|
10451
12055
|
}
|
|
@@ -10461,7 +12065,30 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
|
|
|
10461
12065
|
const relPaths = changedFiles(ref);
|
|
10462
12066
|
if (relPaths === null)
|
|
10463
12067
|
continue;
|
|
10464
|
-
|
|
12068
|
+
const stagedPaths = stagedChangedFiles();
|
|
12069
|
+
if (stagedPaths === null)
|
|
12070
|
+
return null;
|
|
12071
|
+
const paths = [...new Set([...relPaths, ...stagedPaths])];
|
|
12072
|
+
return { base: ref, root, files: paths.map((p) => join10(root, p)) };
|
|
12073
|
+
}
|
|
12074
|
+
return null;
|
|
12075
|
+
}
|
|
12076
|
+
function resolveAddedFiles(base = process.env.BASE_SHA || "origin/main") {
|
|
12077
|
+
if (repoRoot() === null)
|
|
12078
|
+
return null;
|
|
12079
|
+
const head = revParse("HEAD");
|
|
12080
|
+
for (const ref of new Set([base, "origin/main", "main"])) {
|
|
12081
|
+
const resolved = revParse(ref);
|
|
12082
|
+
if (resolved === null || resolved === head)
|
|
12083
|
+
continue;
|
|
12084
|
+
try {
|
|
12085
|
+
const out = execFileSync9("git", ["diff", "--name-only", "--diff-filter=A", `${ref}...HEAD`], {
|
|
12086
|
+
encoding: "utf8",
|
|
12087
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
12088
|
+
}).trim();
|
|
12089
|
+
return out === "" ? [] : out.split(`
|
|
12090
|
+
`).map((p) => p.trim()).filter(Boolean);
|
|
12091
|
+
} catch {}
|
|
10465
12092
|
}
|
|
10466
12093
|
return null;
|
|
10467
12094
|
}
|
|
@@ -10492,11 +12119,36 @@ function findingsInThisDiff(findings) {
|
|
|
10492
12119
|
});
|
|
10493
12120
|
}
|
|
10494
12121
|
|
|
12122
|
+
// src/checks/principals-refusal.ts
|
|
12123
|
+
function principalsUnresolvedCheckError(check, err, severity) {
|
|
12124
|
+
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}\`.`;
|
|
12125
|
+
return {
|
|
12126
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
12127
|
+
check,
|
|
12128
|
+
severity,
|
|
12129
|
+
message: `${check}: ${err.message}`,
|
|
12130
|
+
agent_recovery_prompt: recovery
|
|
12131
|
+
};
|
|
12132
|
+
}
|
|
12133
|
+
function refuseUnresolvedPrincipals(check, err) {
|
|
12134
|
+
if (!(err instanceof PrincipalsUnresolvedError))
|
|
12135
|
+
throw err;
|
|
12136
|
+
emitCheckError(principalsUnresolvedCheckError(check, err, "error"));
|
|
12137
|
+
process.exit(1);
|
|
12138
|
+
}
|
|
12139
|
+
function warnOnUnreadPrincipals(check, err) {
|
|
12140
|
+
if (err instanceof PrincipalsUnresolvedError && err.kind === "read-failed") {
|
|
12141
|
+
emitCheckError(principalsUnresolvedCheckError(check, err, "warning"));
|
|
12142
|
+
return;
|
|
12143
|
+
}
|
|
12144
|
+
refuseUnresolvedPrincipals(check, err);
|
|
12145
|
+
}
|
|
12146
|
+
|
|
10495
12147
|
// src/checks/bin/check-doc-coverage-push.ts
|
|
10496
12148
|
var CHECK_NAME = "doc-coverage-push";
|
|
10497
12149
|
function git2(args) {
|
|
10498
12150
|
try {
|
|
10499
|
-
return
|
|
12151
|
+
return execFileSync10("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
10500
12152
|
} catch {
|
|
10501
12153
|
return "";
|
|
10502
12154
|
}
|
|
@@ -10505,12 +12157,18 @@ function changedFiles2(base) {
|
|
|
10505
12157
|
return git2(["diff", "--name-only", `${base}...HEAD`]).split(`
|
|
10506
12158
|
`).map((s) => s.trim()).filter(Boolean);
|
|
10507
12159
|
}
|
|
12160
|
+
function stagedChangedFiles2() {
|
|
12161
|
+
if (process.env.VINAYA_COMMIT_HOOK !== "1" || !process.env.GIT_INDEX_FILE)
|
|
12162
|
+
return [];
|
|
12163
|
+
return git2(["diff", "--cached", "--name-only"]).split(`
|
|
12164
|
+
`).map((s) => s.trim()).filter(Boolean);
|
|
12165
|
+
}
|
|
10508
12166
|
function resolvePrBody() {
|
|
10509
12167
|
if (process.env.PR_BODY)
|
|
10510
12168
|
return process.env.PR_BODY;
|
|
10511
12169
|
if (process.env.PR_BODY_FILE) {
|
|
10512
12170
|
try {
|
|
10513
|
-
return
|
|
12171
|
+
return readFileSync9(process.env.PR_BODY_FILE, "utf8");
|
|
10514
12172
|
} catch {
|
|
10515
12173
|
return "";
|
|
10516
12174
|
}
|
|
@@ -10521,11 +12179,18 @@ function waiverActiveFromEnv() {
|
|
|
10521
12179
|
const labels = (process.env.PR_LABELS || "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
10522
12180
|
if (!labels.includes(WAIVER_LABEL))
|
|
10523
12181
|
return false;
|
|
12182
|
+
let principalAllowlist;
|
|
12183
|
+
try {
|
|
12184
|
+
principalAllowlist = resolveTrustedPrincipals();
|
|
12185
|
+
} catch (err) {
|
|
12186
|
+
warnOnUnreadPrincipals(CHECK_NAME, err);
|
|
12187
|
+
return false;
|
|
12188
|
+
}
|
|
10524
12189
|
return isWaiverLabelActorVerified({
|
|
10525
12190
|
label: WAIVER_LABEL,
|
|
10526
12191
|
labels,
|
|
10527
12192
|
labelActor: process.env.WAIVER_LABEL_ACTOR || null,
|
|
10528
|
-
principalAllowlist
|
|
12193
|
+
principalAllowlist
|
|
10529
12194
|
});
|
|
10530
12195
|
}
|
|
10531
12196
|
function main() {
|
|
@@ -10543,10 +12208,11 @@ function main() {
|
|
|
10543
12208
|
ref = "main";
|
|
10544
12209
|
changed = changedFiles2(ref);
|
|
10545
12210
|
}
|
|
12211
|
+
changed = [...new Set([...changed, ...stagedChangedFiles2()])];
|
|
10546
12212
|
if (changed.length === 0)
|
|
10547
12213
|
process.exit(0);
|
|
10548
|
-
const content =
|
|
10549
|
-
const result = evaluateC5(changed, content, resolvePrBody(),
|
|
12214
|
+
const content = existsSync9(DOC_OWNERS_PATH) ? readFileSync9(DOC_OWNERS_PATH, "utf8") : null;
|
|
12215
|
+
const result = evaluateC5(changed, content, resolvePrBody(), existsSync9, waiverActiveFromEnv(), (p) => fileDiffAgainst(ref, p));
|
|
10550
12216
|
for (const message of result.errors) {
|
|
10551
12217
|
emitCheckError({
|
|
10552
12218
|
schema: CHECK_SCHEMA_VERSION,
|