@attalabs/vinaya 0.39.0 → 0.41.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/developer-reviewer.md +2 -2
- package/aeg-root/contracts/planner-developer.md +5 -5
- package/aeg-root/enforcement.md +22 -22
- package/aeg-root/process.md +4 -4
- package/aeg-root/roles/archivist.md +1 -1
- package/aeg-root/roles/developer/reference.md +7 -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 +10 -15
- package/aeg-root/templates/brief-template.md +5 -2
- 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 +1974 -354
- package/dist/checks/bin/check-branch-topology.js +1296 -243
- package/dist/checks/bin/check-brief-shape.js +2038 -460
- package/dist/checks/bin/check-changeset-coverage.js +2411 -564
- package/dist/checks/bin/check-ci-shard-coverage.js +12391 -15
- package/dist/checks/bin/check-closes-n.js +1296 -243
- package/dist/checks/bin/check-coherence.js +1914 -1155
- package/dist/checks/bin/check-dead-branch-push.js +1242 -230
- package/dist/checks/bin/check-dispatch-readiness.js +2222 -460
- package/dist/checks/bin/check-doc-claims.js +2233 -260
- package/dist/checks/bin/check-doc-coverage-push.js +2436 -550
- package/dist/checks/bin/check-doc-coverage.js +2434 -552
- package/dist/checks/bin/check-doctrine-no-procedures.js +1776 -353
- package/dist/checks/bin/check-doctrine-portability.js +2408 -561
- package/dist/checks/bin/check-evidence-fresh.js +2370 -508
- package/dist/checks/bin/check-exec-bits.js +2407 -560
- package/dist/checks/bin/check-first-push-dispatch.js +1984 -380
- package/dist/checks/bin/check-issue-assignment.js +712 -170
- package/dist/checks/bin/check-issue-milestone-attach.js +1233 -230
- package/dist/checks/bin/check-issue-objectives-numbering.js +1769 -346
- package/dist/checks/bin/check-issue-parts-coverage.js +1233 -230
- package/dist/checks/bin/check-issue-surface-globs.js +1926 -378
- package/dist/checks/bin/check-issue-title-grammar.js +1233 -230
- package/dist/checks/bin/check-issue-tranche-label.js +702 -170
- package/dist/checks/bin/check-main-branch-refusal.js +1245 -232
- package/dist/checks/bin/check-no-disk-state.js +1233 -230
- package/dist/checks/bin/check-pr-premise-reassert.js +1769 -346
- package/dist/checks/bin/check-pr-report-density.js +1233 -230
- package/dist/checks/bin/check-principal-test-plan-wait.js +2489 -259
- package/dist/checks/bin/check-quoted-command.js +2391 -544
- package/dist/checks/bin/check-reader-resolvable-prose.js +2437 -564
- package/dist/checks/bin/check-registry-gates.js +1380 -296
- package/dist/checks/bin/check-retired-vocabulary.js +2416 -550
- package/dist/checks/bin/check-review-gate.js +2073 -371
- package/dist/checks/bin/check-single-plan-pr.js +1297 -235
- package/dist/checks/bin/check-surface-scope.js +1531 -252
- package/dist/checks/bin/check-test-plan.js +2487 -258
- package/dist/checks/bin/check-token-collection-wired.js +1233 -230
- package/dist/checks/bin/check-workspace-escape.js +2408 -561
- package/dist/checks/bin/verify-coherence.js +597 -97
- package/dist/checks/bin/verify-dispatch.js +632 -152
- package/dist/checks/bin/verify-docs.js +642 -132
- package/dist/index.js +25948 -16630
- package/dist/lib/pre-push-cache-test-run.js +1813 -297
- package/dist/lib/pre-push-changed-files.js +65 -19
- package/dist/lib/pre-push-mode.js +466 -0
- package/dist/lib/pre-push-progress-dir.js +4205 -0
- package/dist/lib/pre-push-record-tests.js +446 -0
- package/dist/lib/pre-push-select-tests.js +2353 -632
- package/dist/lib/push-progress-observer.js +4213 -0
- package/package.json +22 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +17 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +73 -30
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +3 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +88 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +34 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +26 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +7 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +29 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +35 -18
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +70 -45
- 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 +3 -5
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +96 -9
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +24 -54
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +809 -106
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/live-record.ts +179 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +8 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +2 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema-digest.ts +225 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +7 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +23 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +6 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/principals-config.ts +44 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/prose-rules.ts +532 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/protected-paths.ts +31 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +157 -80
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +8 -12
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +53 -93
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +46 -17
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +85 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +32 -13
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +46 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +2 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +63 -8
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +24 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +0 -1
- 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]__1ug9syi._.js → [root-of-the-server]__1d4eth3._.js} +1 -1
- 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]__1snpgaw._.js +3 -3
- 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/_08onyya._.js +2 -2
- 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 +3 -3
- 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/{33rszkngkuoko.js → 0x7u6si-ai179.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{06_55xbp7rcbi.js → 2fu7mfsj4oima.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2brkwv169ygep.js → 34b4ruddunn3q.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 → 2ZARxTwpuRew8-SvYsRdU}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_ssgManifest.js +0 -0
|
@@ -43,7 +43,6 @@ var GATE_AUDIENCE = {
|
|
|
43
43
|
};
|
|
44
44
|
var NON_GATE_BINS = [
|
|
45
45
|
"archive-task",
|
|
46
|
-
"assign-task-issue",
|
|
47
46
|
"dead-branch-audit",
|
|
48
47
|
"eval-agent-compliance",
|
|
49
48
|
"open-issue",
|
|
@@ -306,6 +305,25 @@ async function runAsync(args) {
|
|
|
306
305
|
function ghApiGet(path) {
|
|
307
306
|
return JSON.parse(run(["api", path]));
|
|
308
307
|
}
|
|
308
|
+
var MAX_PER_PAGE = 100;
|
|
309
|
+
var MAX_PAGES = 100;
|
|
310
|
+
async function ghApiGetAllPagesAsync(pathWithoutPage, opts) {
|
|
311
|
+
const [base = pathWithoutPage, query = ""] = pathWithoutPage.split("?");
|
|
312
|
+
const params = new URLSearchParams(query);
|
|
313
|
+
params.set("per_page", String(MAX_PER_PAGE));
|
|
314
|
+
const all = [];
|
|
315
|
+
for (let page = 1;page <= MAX_PAGES; page++) {
|
|
316
|
+
params.set("page", String(page));
|
|
317
|
+
const args = ["api", `${base}?${params.toString()}`];
|
|
318
|
+
if (opts?.jq)
|
|
319
|
+
args.push("-q", opts.jq);
|
|
320
|
+
const batch = JSON.parse(await runAsync(args));
|
|
321
|
+
all.push(...batch);
|
|
322
|
+
if (batch.length < MAX_PER_PAGE)
|
|
323
|
+
return all;
|
|
324
|
+
}
|
|
325
|
+
throw new Error(`ghApiGetAllPagesAsync: "${pathWithoutPage}" did not terminate within ${MAX_PAGES} pages (${MAX_PAGES * MAX_PER_PAGE} items) — refusing to keep walking.`);
|
|
326
|
+
}
|
|
309
327
|
function issueListByLabelArgs(owner, repo, label) {
|
|
310
328
|
return [
|
|
311
329
|
"issue",
|
|
@@ -717,6 +735,10 @@ function intentGoalForSlug(description, slug) {
|
|
|
717
735
|
function matchesLegacyMilestone(milestones, slug) {
|
|
718
736
|
return milestones.find((m) => m.title === slug) ?? null;
|
|
719
737
|
}
|
|
738
|
+
var TRANCHE_SLUG_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*-v\d+$/;
|
|
739
|
+
function slugShapedTitles(milestones) {
|
|
740
|
+
return milestones.map((m) => m.title).filter((t) => TRANCHE_SLUG_SHAPE.test(t));
|
|
741
|
+
}
|
|
720
742
|
function factsFromLegacyMilestone(milestone) {
|
|
721
743
|
return {
|
|
722
744
|
goal: milestone.description ?? "",
|
|
@@ -750,6 +772,105 @@ 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, options = {}) {
|
|
785
|
+
const read = (fetch) => options.retryFailedReads ? retryOnce(fetch) : fetch();
|
|
786
|
+
const [milestones, labels] = await Promise.all([
|
|
787
|
+
read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`)),
|
|
788
|
+
read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`))
|
|
789
|
+
]);
|
|
790
|
+
const active = [];
|
|
791
|
+
const archived = [];
|
|
792
|
+
const facts = new Map;
|
|
793
|
+
const legacySlugs = new Set(slugShapedTitles(milestones));
|
|
794
|
+
const legacyMilestoneBySlug = new Map(milestones.filter((m) => legacySlugs.has(m.title)).map((m) => [m.title, m]));
|
|
795
|
+
const newPathSlugs = trancheSlugsFromLabels(labels).filter((slug) => !legacySlugs.has(slug));
|
|
796
|
+
const uniqueNewPathSlugs = [...new Set(newPathSlugs)];
|
|
797
|
+
const uniqueLegacySlugs = [...legacySlugs];
|
|
798
|
+
const [legacyIssuesBySlug, newPathIssuesBySlug] = await Promise.all([
|
|
799
|
+
Promise.all(uniqueLegacySlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))))),
|
|
800
|
+
Promise.all(uniqueNewPathSlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))))
|
|
801
|
+
]);
|
|
802
|
+
const issuesBySlug = new Map;
|
|
803
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
804
|
+
issuesBySlug.set(slug, legacyIssuesBySlug[i] ?? []);
|
|
805
|
+
});
|
|
806
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
807
|
+
issuesBySlug.set(slug, newPathIssuesBySlug[i] ?? []);
|
|
808
|
+
});
|
|
809
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
810
|
+
const m = legacyMilestoneBySlug.get(slug);
|
|
811
|
+
if (!m)
|
|
812
|
+
return;
|
|
813
|
+
const ref = { slug, goal: m.description ?? "" };
|
|
814
|
+
const f = resolveLegacyFacts(m, legacyIssuesBySlug[i] ?? []);
|
|
815
|
+
if (f.lifecycle === "complete")
|
|
816
|
+
archived.push(ref);
|
|
817
|
+
else if (f.lifecycle === "active")
|
|
818
|
+
active.push(ref);
|
|
819
|
+
facts.set(slug, f);
|
|
820
|
+
});
|
|
821
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
822
|
+
const issues = newPathIssuesBySlug[i] ?? [];
|
|
823
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
824
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
825
|
+
const f = { goal, lifecycle };
|
|
826
|
+
facts.set(slug, f);
|
|
827
|
+
if (lifecycle === "active")
|
|
828
|
+
active.push({ slug, goal });
|
|
829
|
+
else if (lifecycle === "complete")
|
|
830
|
+
archived.push({ slug, goal });
|
|
831
|
+
});
|
|
832
|
+
return { active, archived, facts, legacySlugs, issuesBySlug };
|
|
833
|
+
}
|
|
834
|
+
async function retryOnce(fetch) {
|
|
835
|
+
try {
|
|
836
|
+
return await fetch();
|
|
837
|
+
} catch {
|
|
838
|
+
return fetch();
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
async function indexTrancheMilestonesForSlugAsync(owner, repo, slug) {
|
|
842
|
+
const [milestones, labels, issues] = await Promise.all([
|
|
843
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
844
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`),
|
|
845
|
+
ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))
|
|
846
|
+
]);
|
|
847
|
+
const active = [];
|
|
848
|
+
const archived = [];
|
|
849
|
+
const facts = new Map;
|
|
850
|
+
const legacySlugs = new Set;
|
|
851
|
+
const legacyMilestone = slugShapedTitles(milestones).includes(slug) ? matchesLegacyMilestone(milestones, slug) : null;
|
|
852
|
+
if (legacyMilestone) {
|
|
853
|
+
legacySlugs.add(slug);
|
|
854
|
+
const ref = { slug, goal: legacyMilestone.description ?? "" };
|
|
855
|
+
const f = resolveLegacyFacts(legacyMilestone, issues);
|
|
856
|
+
if (f.lifecycle === "complete")
|
|
857
|
+
archived.push(ref);
|
|
858
|
+
else if (f.lifecycle === "active")
|
|
859
|
+
active.push(ref);
|
|
860
|
+
facts.set(slug, f);
|
|
861
|
+
} else if (trancheSlugsFromLabels(labels).includes(slug)) {
|
|
862
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
863
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
864
|
+
facts.set(slug, { goal, lifecycle });
|
|
865
|
+
if (lifecycle === "active")
|
|
866
|
+
active.push({ slug, goal });
|
|
867
|
+
else if (lifecycle === "complete")
|
|
868
|
+
archived.push({ slug, goal });
|
|
869
|
+
}
|
|
870
|
+
const openLegacyTitles = new Set(slugShapedTitles(milestones.filter((m) => m.state === "open")));
|
|
871
|
+
const otherOpenLegacySlugs = [...openLegacyTitles].filter((t) => t !== slug);
|
|
872
|
+
return { active, archived, facts, legacySlugs, otherOpenLegacySlugs };
|
|
873
|
+
}
|
|
753
874
|
|
|
754
875
|
// ../../packages/aeg-forge-state/src/derive-from-forge.ts
|
|
755
876
|
function trancheFromIssues(slug, issues, known) {
|
|
@@ -1410,6 +1531,125 @@ var graphql2 = withDefaults3(request, {
|
|
|
1410
1531
|
method: "POST",
|
|
1411
1532
|
url: "/graphql"
|
|
1412
1533
|
});
|
|
1534
|
+
|
|
1535
|
+
// ../../packages/aeg-forge-state/src/fetch-provenance.ts
|
|
1536
|
+
var PROVENANCE_PATTERN = /^###\s+AEG provenance\b/im;
|
|
1537
|
+
function provenanceMatchesIssue(text, issueNum) {
|
|
1538
|
+
if (!PROVENANCE_PATTERN.test(text))
|
|
1539
|
+
return false;
|
|
1540
|
+
const m = text.match(/^-\s*Issue:\s*#(\d+)/im);
|
|
1541
|
+
return m !== null && Number(m[1]) === issueNum;
|
|
1542
|
+
}
|
|
1543
|
+
function isPrCloser(closer) {
|
|
1544
|
+
return closer !== null && typeof closer.number === "number";
|
|
1545
|
+
}
|
|
1546
|
+
async function fetchProvenanceViaCrossReferences(issueNums, owner, repo, token) {
|
|
1547
|
+
const result = new Map;
|
|
1548
|
+
if (issueNums.length === 0)
|
|
1549
|
+
return result;
|
|
1550
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1551
|
+
const perIssue = issueNums.map((n) => `
|
|
1552
|
+
i_${n}: issue(number: ${n}) {
|
|
1553
|
+
timelineItems(first: 50, itemTypes: [CROSS_REFERENCED_EVENT]) {
|
|
1554
|
+
nodes {
|
|
1555
|
+
... on CrossReferencedEvent {
|
|
1556
|
+
source {
|
|
1557
|
+
... on PullRequest {
|
|
1558
|
+
number
|
|
1559
|
+
body
|
|
1560
|
+
comments(first: 50) { nodes { body } }
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}`).join("");
|
|
1567
|
+
const query = `query ProvenanceCrossRef($owner: String!, $repo: String!) {
|
|
1568
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1569
|
+
}
|
|
1570
|
+
}`;
|
|
1571
|
+
let response;
|
|
1572
|
+
try {
|
|
1573
|
+
response = await client(query, { owner, repo });
|
|
1574
|
+
} catch {
|
|
1575
|
+
return result;
|
|
1576
|
+
}
|
|
1577
|
+
if (!response.repository)
|
|
1578
|
+
return result;
|
|
1579
|
+
for (const n of issueNums) {
|
|
1580
|
+
const raw = response.repository[`i_${n}`];
|
|
1581
|
+
const nodes = raw?.timelineItems?.nodes ?? [];
|
|
1582
|
+
const found = nodes.some(({ source }) => {
|
|
1583
|
+
if (!source || typeof source.number !== "number")
|
|
1584
|
+
return false;
|
|
1585
|
+
const pr = source;
|
|
1586
|
+
if (provenanceMatchesIssue(pr.body ?? "", n))
|
|
1587
|
+
return true;
|
|
1588
|
+
return pr.comments.nodes.some((c) => provenanceMatchesIssue(c.body, n));
|
|
1589
|
+
});
|
|
1590
|
+
result.set(n, found);
|
|
1591
|
+
}
|
|
1592
|
+
return result;
|
|
1593
|
+
}
|
|
1594
|
+
async function fetchProvenance(issueNums, owner, repo, token) {
|
|
1595
|
+
const result = new Map;
|
|
1596
|
+
if (issueNums.length === 0)
|
|
1597
|
+
return result;
|
|
1598
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1599
|
+
const perIssue = issueNums.map((n) => `
|
|
1600
|
+
i_${n}: issue(number: ${n}) {
|
|
1601
|
+
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1602
|
+
nodes {
|
|
1603
|
+
... on ClosedEvent {
|
|
1604
|
+
closer {
|
|
1605
|
+
... on PullRequest {
|
|
1606
|
+
number
|
|
1607
|
+
body
|
|
1608
|
+
comments(first: 50) {
|
|
1609
|
+
nodes { body }
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}`).join("");
|
|
1617
|
+
const query = `query Provenance($owner: String!, $repo: String!) {
|
|
1618
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1619
|
+
}
|
|
1620
|
+
}`;
|
|
1621
|
+
let response;
|
|
1622
|
+
try {
|
|
1623
|
+
response = await client(query, { owner, repo });
|
|
1624
|
+
} catch {
|
|
1625
|
+
return result;
|
|
1626
|
+
}
|
|
1627
|
+
if (!response.repository)
|
|
1628
|
+
return result;
|
|
1629
|
+
const needsFallback = [];
|
|
1630
|
+
for (const n of issueNums) {
|
|
1631
|
+
const raw = response.repository[`i_${n}`];
|
|
1632
|
+
if (!raw) {
|
|
1633
|
+
result.set(n, false);
|
|
1634
|
+
continue;
|
|
1635
|
+
}
|
|
1636
|
+
const closer = raw.timelineItems?.nodes?.[0]?.closer;
|
|
1637
|
+
const c = closer ?? null;
|
|
1638
|
+
if (!isPrCloser(c)) {
|
|
1639
|
+
needsFallback.push(n);
|
|
1640
|
+
continue;
|
|
1641
|
+
}
|
|
1642
|
+
const bodyHas = PROVENANCE_PATTERN.test(c.body ?? "");
|
|
1643
|
+
const commentHas = c.comments.nodes.some((x) => PROVENANCE_PATTERN.test(x.body));
|
|
1644
|
+
result.set(n, bodyHas || commentHas);
|
|
1645
|
+
}
|
|
1646
|
+
if (needsFallback.length > 0) {
|
|
1647
|
+
const fallback = await fetchProvenanceViaCrossReferences(needsFallback, owner, repo, token);
|
|
1648
|
+
for (const [n, found] of fallback)
|
|
1649
|
+
result.set(n, found);
|
|
1650
|
+
}
|
|
1651
|
+
return result;
|
|
1652
|
+
}
|
|
1413
1653
|
// ../../packages/aeg-forge-state/src/github-token.ts
|
|
1414
1654
|
import { execFile as execFile2 } from "node:child_process";
|
|
1415
1655
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -1639,6 +1879,52 @@ function describeError(err) {
|
|
|
1639
1879
|
return err;
|
|
1640
1880
|
return "unknown error";
|
|
1641
1881
|
}
|
|
1882
|
+
// ../../packages/aeg-forge-state/src/prior-tranche-archival.ts
|
|
1883
|
+
function defaultPriorTrancheArchivalDeps() {
|
|
1884
|
+
return {
|
|
1885
|
+
activeTranches: async (excludeSlug, repo) => {
|
|
1886
|
+
const index = await indexTrancheMilestonesAsync(repo.owner, repo.repo, { retryFailedReads: true });
|
|
1887
|
+
return index.active.filter((m) => m.slug !== excludeSlug).map((m) => {
|
|
1888
|
+
const issues = index.issuesBySlug?.get(m.slug);
|
|
1889
|
+
if (!issues)
|
|
1890
|
+
throw new Error(`the Milestone index holds no Issue list for tranche \`${m.slug}\``);
|
|
1891
|
+
return { slug: m.slug, issues };
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
function reason(err) {
|
|
1897
|
+
return err instanceof Error ? err.message.split(`
|
|
1898
|
+
`)[0] ?? "failed" : String(err);
|
|
1899
|
+
}
|
|
1900
|
+
async function resolvePriorTrancheArchival(projects, excludeSlug, repo, deps = defaultPriorTrancheArchivalDeps()) {
|
|
1901
|
+
if (projects.length === 0)
|
|
1902
|
+
return { facts: [], infraFailure: null };
|
|
1903
|
+
let candidates;
|
|
1904
|
+
try {
|
|
1905
|
+
candidates = await deps.activeTranches(excludeSlug, repo);
|
|
1906
|
+
} catch (err) {
|
|
1907
|
+
return {
|
|
1908
|
+
facts: [],
|
|
1909
|
+
infraFailure: `severity:infra — could not read the active tranches (${reason(err)}); whether a prior tranche is archived is unknown.`
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
const tasksBySlug = new Map(candidates.map((c) => [c.slug, tasksFromIssues(c.issues)]));
|
|
1913
|
+
const facts = [];
|
|
1914
|
+
for (const project of projects) {
|
|
1915
|
+
let found = null;
|
|
1916
|
+
for (const { slug, issues } of candidates) {
|
|
1917
|
+
if (!(tasksBySlug.get(slug) ?? []).some((t) => t.projects.includes(project)))
|
|
1918
|
+
continue;
|
|
1919
|
+
if (!issues.some((issue) => issue.state === "OPEN")) {
|
|
1920
|
+
found = { project, priorTrancheSlug: slug, archived: false };
|
|
1921
|
+
break;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
facts.push(found ?? { project, priorTrancheSlug: null, archived: false });
|
|
1925
|
+
}
|
|
1926
|
+
return { facts, infraFailure: null };
|
|
1927
|
+
}
|
|
1642
1928
|
// ../../packages/aeg-forge-state/src/fetch-open-issues.ts
|
|
1643
1929
|
async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
|
|
1644
1930
|
const result = new Map;
|
|
@@ -1713,6 +1999,10 @@ function buildQuery(issueNumbers) {
|
|
|
1713
1999
|
}
|
|
1714
2000
|
}`;
|
|
1715
2001
|
}
|
|
2002
|
+
// ../../packages/aeg-forge-state/src/list-issue-milestones.ts
|
|
2003
|
+
function issueMilestonesFromIssues(issues) {
|
|
2004
|
+
return issues.filter((i) => i.state === "OPEN").map((i) => ({ issue: i.number, milestoneTitle: i.milestone?.title ?? null }));
|
|
2005
|
+
}
|
|
1716
2006
|
// ../../packages/aeg-forge-state/src/resolve-repo.ts
|
|
1717
2007
|
import { execFile as execFile3 } from "node:child_process";
|
|
1718
2008
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -1775,7 +2065,8 @@ var ANCHOR_FIELDS = [
|
|
|
1775
2065
|
"PREMISE",
|
|
1776
2066
|
"TEST-PLAN",
|
|
1777
2067
|
"EVIDENCE",
|
|
1778
|
-
"BEYOND-SURFACE"
|
|
2068
|
+
"BEYOND-SURFACE",
|
|
2069
|
+
"LIVE"
|
|
1779
2070
|
];
|
|
1780
2071
|
function anchoredRegionBounds(body, field) {
|
|
1781
2072
|
const masked = maskCode(body);
|
|
@@ -1976,7 +2267,6 @@ var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
|
1976
2267
|
// ../../packages/aeg-core/src/waiver-label.ts
|
|
1977
2268
|
var WAIVER_LABEL = label("waiver-docs");
|
|
1978
2269
|
var WAIVER_LABEL_REVIEW = label("waiver-review");
|
|
1979
|
-
var PRINCIPAL_ALLOWLIST = ["daniboomerang"];
|
|
1980
2270
|
function isPrincipal(login, principalAllowlist) {
|
|
1981
2271
|
if (login === null)
|
|
1982
2272
|
return false;
|
|
@@ -1995,6 +2285,14 @@ var RULING_ORDINAL_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Ruling ordinal:\s*(\d+)(
|
|
|
1995
2285
|
var BRIEF_HASH_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Brief hash:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1996
2286
|
var POLICY_DIGEST_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Policy digest:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1997
2287
|
var BASE_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged base:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
|
|
2288
|
+
var MANIFEST_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Manifest version:\s*(\d+)\s*$/im;
|
|
2289
|
+
var PAUSE_BOUND_RULING_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Pause-bound ruling:\s*(?:(\S+)\|(\S+)\|([0-9a-f]{64})|\(none\))\s*$/im;
|
|
2290
|
+
function extractPauseBoundRuling(comment) {
|
|
2291
|
+
const m = comment.match(PAUSE_BOUND_RULING_PATTERN);
|
|
2292
|
+
if (!m)
|
|
2293
|
+
return;
|
|
2294
|
+
return m[1] ? { rulingId: m[1], pauseId: m[2], contentDigest: m[3] } : null;
|
|
2295
|
+
}
|
|
1998
2296
|
function firstFiveLines(comment) {
|
|
1999
2297
|
return comment.split(`
|
|
2000
2298
|
`).slice(0, 5).join(`
|
|
@@ -2088,6 +2386,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2088
2386
|
danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
|
|
2089
2387
|
};
|
|
2090
2388
|
}
|
|
2389
|
+
const versionMatch = latest.match(MANIFEST_VERSION_PATTERN);
|
|
2390
|
+
const pauseBoundRuling = extractPauseBoundRuling(latest);
|
|
2091
2391
|
return {
|
|
2092
2392
|
value: m[1].toUpperCase().replace(/[_-]/g, " "),
|
|
2093
2393
|
headSha: extractHeadSha(latest),
|
|
@@ -2096,6 +2396,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2096
2396
|
briefHash: extractBriefHash(latest),
|
|
2097
2397
|
policyDigest: extractPolicyDigest(latest),
|
|
2098
2398
|
baseSha: extractBaseSha(latest),
|
|
2399
|
+
...versionMatch ? { manifestVersion: Number.parseInt(versionMatch[1], 10) } : {},
|
|
2400
|
+
...pauseBoundRuling === undefined ? {} : { pauseBoundRuling },
|
|
2099
2401
|
findingSeverities: extractFindingSeverities(latest),
|
|
2100
2402
|
danglingNote: null
|
|
2101
2403
|
};
|
|
@@ -2106,6 +2408,16 @@ function extractCodeReviewVerdict(comments) {
|
|
|
2106
2408
|
function extractSecurityReviewVerdict(comments) {
|
|
2107
2409
|
return extractVerdict(comments, /^[ \t]*(?:\*{1,3}|_{1,3})?VERDICT:\s*(PASS|FAIL)(?![A-Za-z0-9])/im, "security-review");
|
|
2108
2410
|
}
|
|
2411
|
+
|
|
2412
|
+
// ../../packages/aeg-core/src/review-status.ts
|
|
2413
|
+
var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-(\d+)\s*-->/i;
|
|
2414
|
+
function parseDeveloperRoundMarker(body) {
|
|
2415
|
+
const m = body.match(DEVELOPER_ROUND_MARKER);
|
|
2416
|
+
if (!m)
|
|
2417
|
+
return null;
|
|
2418
|
+
const n = Number(m[1]);
|
|
2419
|
+
return Number.isFinite(n) ? n : null;
|
|
2420
|
+
}
|
|
2109
2421
|
// ../../packages/aeg-core/src/report-tokens.ts
|
|
2110
2422
|
var DASH_LOOKALIKES = {
|
|
2111
2423
|
"-": "‑",
|
|
@@ -2437,11 +2749,13 @@ var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
|
|
|
2437
2749
|
var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
|
|
2438
2750
|
var DEFAULT_MAX_ROUNDS = 3;
|
|
2439
2751
|
var DEFAULT_MAX_TASK_MINUTES = 180;
|
|
2752
|
+
var DEFAULT_READY_PUSH_TIMEOUT_MINUTES = 20;
|
|
2440
2753
|
var DEFAULT_REVIEW_POLICY = {
|
|
2441
2754
|
codeReviewThreshold: "BLOCKER",
|
|
2442
2755
|
securityThreshold: "HIGH",
|
|
2443
2756
|
maxRounds: DEFAULT_MAX_ROUNDS,
|
|
2444
|
-
maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
|
|
2757
|
+
maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES,
|
|
2758
|
+
readyPushTimeoutMinutes: DEFAULT_READY_PUSH_TIMEOUT_MINUTES
|
|
2445
2759
|
};
|
|
2446
2760
|
var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
|
|
2447
2761
|
var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
|
|
@@ -2801,14 +3115,14 @@ function checkTestPlan(prBody) {
|
|
|
2801
3115
|
const region = located.found ? located.section : prBody;
|
|
2802
3116
|
if (TEST_PLAN_UNIT_TESTS_ONLY_RE.test(region))
|
|
2803
3117
|
return { status: "pass", errors: [] };
|
|
2804
|
-
if (/\*\*\[(?:agent|principal)\]\*\*/.test(region))
|
|
3118
|
+
if (/\*\*\[(?:agent|principal|live)\]\*\*/.test(region))
|
|
2805
3119
|
return { status: "pass", errors: [] };
|
|
2806
3120
|
if (located.found && extractFencedBlocks(region).length > 0)
|
|
2807
3121
|
return { status: "pass", errors: [] };
|
|
2808
3122
|
return {
|
|
2809
3123
|
status: "fail",
|
|
2810
3124
|
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
|
|
3125
|
+
"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
3126
|
]
|
|
2813
3127
|
};
|
|
2814
3128
|
}
|
|
@@ -3430,6 +3744,375 @@ function checkPrReportDensity(prBody) {
|
|
|
3430
3744
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3431
3745
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3432
3746
|
}
|
|
3747
|
+
// ../../packages/aeg-core/src/prose-rules.ts
|
|
3748
|
+
var RETIRED_GLOBAL_EXEMPTIONS = [
|
|
3749
|
+
"docs/decisions-legacy.md",
|
|
3750
|
+
"apps/herald-ai/docs/",
|
|
3751
|
+
"apps/vada-ai/docs/",
|
|
3752
|
+
"aeg-root/tranches/completed/",
|
|
3753
|
+
"packages/aeg-core/src/docs/published-prose",
|
|
3754
|
+
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
3755
|
+
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
3756
|
+
"/fixtures/",
|
|
3757
|
+
"/node_modules/",
|
|
3758
|
+
"/.next/",
|
|
3759
|
+
"/.turbo/"
|
|
3760
|
+
];
|
|
3761
|
+
var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
|
|
3762
|
+
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
3763
|
+
var RETIRED_PATTERN_EXEMPTIONS = {
|
|
3764
|
+
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
3765
|
+
[String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
|
|
3766
|
+
"docs-index.md",
|
|
3767
|
+
"apps/vada-ai/specs/legacy/README.md",
|
|
3768
|
+
"apps/vada-ai/specs/vada-product-spec.md",
|
|
3769
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3770
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3771
|
+
],
|
|
3772
|
+
"decisions-legacy": [
|
|
3773
|
+
"packages/aeg-core/src/file-classify.ts",
|
|
3774
|
+
"packages/aeg-core/src/file-classify.test.ts",
|
|
3775
|
+
"packages/aeg-core/src/pr-tier.test.ts",
|
|
3776
|
+
"docs-index.md",
|
|
3777
|
+
".claude/skills/database/SKILL.md",
|
|
3778
|
+
".claude/skills/vada-architecture/SKILL.md",
|
|
3779
|
+
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
3780
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3781
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3782
|
+
],
|
|
3783
|
+
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
3784
|
+
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
3785
|
+
};
|
|
3786
|
+
var retiredPatterns = [
|
|
3787
|
+
String.raw`\bD-[0-9]{3}\b`,
|
|
3788
|
+
"D-(###|NNN|nnn|xxx)",
|
|
3789
|
+
"decision (entry|logged)",
|
|
3790
|
+
"decision-log entry",
|
|
3791
|
+
"decision log entry",
|
|
3792
|
+
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
3793
|
+
"decision-log",
|
|
3794
|
+
"decision entr",
|
|
3795
|
+
"decisions? (are |is )?logged",
|
|
3796
|
+
"log entries",
|
|
3797
|
+
String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
|
|
3798
|
+
"decisions-legacy",
|
|
3799
|
+
"CONTRADICTION",
|
|
3800
|
+
"assumes Tier 3",
|
|
3801
|
+
"Lock: ?YES",
|
|
3802
|
+
"Lock: ?NO",
|
|
3803
|
+
"lock approvals?",
|
|
3804
|
+
"approves locks",
|
|
3805
|
+
"Conforms to lock",
|
|
3806
|
+
"Challenges lock",
|
|
3807
|
+
"checkDecisionNumbersFresh",
|
|
3808
|
+
String.raw`roles/team-leader\.md`,
|
|
3809
|
+
String.raw`\(,`,
|
|
3810
|
+
String.raw`,\)`,
|
|
3811
|
+
String.raw`\(\.\)`,
|
|
3812
|
+
...PLAN_ON_DISK_PATTERNS
|
|
3813
|
+
];
|
|
3814
|
+
var published = [
|
|
3815
|
+
["decision-id", "a decision id", /\bD-\d{3,}\b/],
|
|
3816
|
+
["section-ref", "a section reference", /§/],
|
|
3817
|
+
["forge-number", "a forge number", /#\d+/],
|
|
3818
|
+
["retired-name", "the retired public name", /\bAEG\b/],
|
|
3819
|
+
["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
|
|
3820
|
+
[
|
|
3821
|
+
"label-vocabulary",
|
|
3822
|
+
"forge label vocabulary",
|
|
3823
|
+
/(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
|
|
3824
|
+
],
|
|
3825
|
+
["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
|
|
3826
|
+
["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
|
|
3827
|
+
[
|
|
3828
|
+
"internal-path",
|
|
3829
|
+
"a repo-internal file",
|
|
3830
|
+
/(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
|
|
3831
|
+
]
|
|
3832
|
+
];
|
|
3833
|
+
var DEFAULT_PROSE_RULES = [
|
|
3834
|
+
{
|
|
3835
|
+
id: "forge-number",
|
|
3836
|
+
group: "reader-resolvable",
|
|
3837
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3838
|
+
patterns: { prose: /#[0-9]{2,4}/g },
|
|
3839
|
+
flags: ["global"],
|
|
3840
|
+
message: "a forge number",
|
|
3841
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3842
|
+
exemptions: []
|
|
3843
|
+
},
|
|
3844
|
+
{
|
|
3845
|
+
id: "tranche-slug",
|
|
3846
|
+
group: "reader-resolvable",
|
|
3847
|
+
scopes: ["ships", "reader-facing", "product", "spec"],
|
|
3848
|
+
patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
|
|
3849
|
+
flags: ["global"],
|
|
3850
|
+
message: "an internal tranche slug",
|
|
3851
|
+
severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
|
|
3852
|
+
exemptions: []
|
|
3853
|
+
},
|
|
3854
|
+
{
|
|
3855
|
+
id: "task-number",
|
|
3856
|
+
group: "reader-resolvable",
|
|
3857
|
+
scopes: ["spec"],
|
|
3858
|
+
patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
|
|
3859
|
+
flags: ["global", "ignore-case"],
|
|
3860
|
+
message: "a task number",
|
|
3861
|
+
severity: { spec: "error" },
|
|
3862
|
+
exemptions: []
|
|
3863
|
+
},
|
|
3864
|
+
{
|
|
3865
|
+
id: "source-comment-tranche-slug",
|
|
3866
|
+
group: "reader-resolvable",
|
|
3867
|
+
scopes: ["source-comment"],
|
|
3868
|
+
patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
|
|
3869
|
+
flags: ["global"],
|
|
3870
|
+
message: "a tranche-slug citation",
|
|
3871
|
+
severity: { "source-comment": "warning" },
|
|
3872
|
+
exemptions: []
|
|
3873
|
+
},
|
|
3874
|
+
{
|
|
3875
|
+
id: "source-comment-forge-number",
|
|
3876
|
+
group: "reader-resolvable",
|
|
3877
|
+
scopes: ["source-comment"],
|
|
3878
|
+
patterns: { comment: /#[0-9]{2,}/g },
|
|
3879
|
+
flags: ["global"],
|
|
3880
|
+
message: "a forge-number citation",
|
|
3881
|
+
severity: { "source-comment": "warning" },
|
|
3882
|
+
exemptions: []
|
|
3883
|
+
},
|
|
3884
|
+
{
|
|
3885
|
+
id: "legacy-batch-name",
|
|
3886
|
+
group: "reader-resolvable",
|
|
3887
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3888
|
+
patterns: {},
|
|
3889
|
+
flags: ["built-in"],
|
|
3890
|
+
message: "an internal tranche slug",
|
|
3891
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3892
|
+
exemptions: [],
|
|
3893
|
+
builtIn: true
|
|
3894
|
+
},
|
|
3895
|
+
{
|
|
3896
|
+
id: "coined-term",
|
|
3897
|
+
group: "reader-resolvable",
|
|
3898
|
+
scopes: ["ships", "reader-facing"],
|
|
3899
|
+
patterns: {},
|
|
3900
|
+
flags: ["built-in"],
|
|
3901
|
+
message: "uses coined term without defining it inline or linking the glossary",
|
|
3902
|
+
severity: { ships: "warning", "reader-facing": "warning" },
|
|
3903
|
+
exemptions: [],
|
|
3904
|
+
builtIn: true
|
|
3905
|
+
},
|
|
3906
|
+
...retiredPatterns.map((pattern, index) => ({
|
|
3907
|
+
id: `retired-vocabulary-${index + 1}`,
|
|
3908
|
+
group: "retired-vocabulary",
|
|
3909
|
+
scopes: ["repository"],
|
|
3910
|
+
patterns: { repository: pattern },
|
|
3911
|
+
flags: [],
|
|
3912
|
+
message: "retired vocabulary",
|
|
3913
|
+
severity: { repository: "error" },
|
|
3914
|
+
exemptions: RETIRED_GLOBAL_EXEMPTIONS,
|
|
3915
|
+
patternExemptions: RETIRED_PATTERN_EXEMPTIONS
|
|
3916
|
+
})),
|
|
3917
|
+
...published.map(([id, message, pattern]) => ({
|
|
3918
|
+
id,
|
|
3919
|
+
group: "published-prose",
|
|
3920
|
+
scopes: ["published"],
|
|
3921
|
+
patterns: { published: pattern },
|
|
3922
|
+
flags: [],
|
|
3923
|
+
message,
|
|
3924
|
+
severity: { published: "error" },
|
|
3925
|
+
exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
|
|
3926
|
+
}))
|
|
3927
|
+
];
|
|
3928
|
+
var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
|
|
3929
|
+
var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
|
|
3930
|
+
var RETIRED_SCOPES = ["repository"];
|
|
3931
|
+
var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
|
|
3932
|
+
function groupOfScope(scope) {
|
|
3933
|
+
if (RESOLVABLE_SCOPES.includes(scope))
|
|
3934
|
+
return "reader-resolvable";
|
|
3935
|
+
if (RETIRED_SCOPES.includes(scope))
|
|
3936
|
+
return "retired-vocabulary";
|
|
3937
|
+
return;
|
|
3938
|
+
}
|
|
3939
|
+
var CONFIGURED_PROSE_FLAGS = ["i", "u"];
|
|
3940
|
+
var CONFIGURED_PATTERN_MAX_LENGTH = 200;
|
|
3941
|
+
var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
|
|
3942
|
+
function allowedScopesFor(rule) {
|
|
3943
|
+
if (rule.builtIn)
|
|
3944
|
+
return rule.scopes;
|
|
3945
|
+
return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
|
|
3946
|
+
}
|
|
3947
|
+
function normalizeRepoPath(entry) {
|
|
3948
|
+
let out = entry.replace(/\\/g, "/");
|
|
3949
|
+
while (out.startsWith("./"))
|
|
3950
|
+
out = out.slice(2);
|
|
3951
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3952
|
+
while (out.endsWith("/"))
|
|
3953
|
+
out = out.slice(0, -1);
|
|
3954
|
+
return out;
|
|
3955
|
+
}
|
|
3956
|
+
function isConfiguredExempt(path, exempt, repoRoot) {
|
|
3957
|
+
if (exempt.length === 0)
|
|
3958
|
+
return false;
|
|
3959
|
+
const root = repoRoot === undefined ? undefined : normalizeRepoPath(repoRoot);
|
|
3960
|
+
let rel = normalizeRepoPath(path);
|
|
3961
|
+
if (root && rel.startsWith(`${root}/`))
|
|
3962
|
+
rel = rel.slice(root.length + 1);
|
|
3963
|
+
return exempt.some((entry) => {
|
|
3964
|
+
const e = normalizeRepoPath(entry);
|
|
3965
|
+
return rel === e || rel.startsWith(`${e}/`);
|
|
3966
|
+
});
|
|
3967
|
+
}
|
|
3968
|
+
function ruleReads(set, rule, path) {
|
|
3969
|
+
return !isConfiguredExempt(path, set.exempt, set.repoRoot) && !isConfiguredExempt(path, rule.exempt, set.repoRoot);
|
|
3970
|
+
}
|
|
3971
|
+
var RESOLVABLE_RUN_ORDER = [
|
|
3972
|
+
"forge-number",
|
|
3973
|
+
"tranche-slug",
|
|
3974
|
+
"legacy-batch-name",
|
|
3975
|
+
"task-number",
|
|
3976
|
+
"source-comment-tranche-slug",
|
|
3977
|
+
"source-comment-forge-number",
|
|
3978
|
+
"coined-term"
|
|
3979
|
+
];
|
|
3980
|
+
var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
|
|
3981
|
+
function scopeDefaultSeverity(scope, sourceCommentSeverity) {
|
|
3982
|
+
if (scope === "source-comment")
|
|
3983
|
+
return sourceCommentSeverity ?? "warning";
|
|
3984
|
+
if (scope === "repository")
|
|
3985
|
+
return "error";
|
|
3986
|
+
return "warning";
|
|
3987
|
+
}
|
|
3988
|
+
function applySeverity(scopes, base, setting) {
|
|
3989
|
+
const out = {};
|
|
3990
|
+
for (const scope of scopes) {
|
|
3991
|
+
const configured = typeof setting === "string" ? setting : setting?.[scope];
|
|
3992
|
+
const value = configured ?? base[scope];
|
|
3993
|
+
if (value !== undefined)
|
|
3994
|
+
out[scope] = value;
|
|
3995
|
+
}
|
|
3996
|
+
return out;
|
|
3997
|
+
}
|
|
3998
|
+
function defaultPatternFor(rule) {
|
|
3999
|
+
const cache = new Map;
|
|
4000
|
+
return (scope) => {
|
|
4001
|
+
if (cache.has(scope))
|
|
4002
|
+
return cache.get(scope) ?? null;
|
|
4003
|
+
const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
|
|
4004
|
+
const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
|
|
4005
|
+
cache.set(scope, compiled);
|
|
4006
|
+
return compiled;
|
|
4007
|
+
};
|
|
4008
|
+
}
|
|
4009
|
+
function customPatternFor(rule, global) {
|
|
4010
|
+
const cache = new Map;
|
|
4011
|
+
return (scope) => {
|
|
4012
|
+
if (cache.has(scope))
|
|
4013
|
+
return cache.get(scope) ?? null;
|
|
4014
|
+
const source = rule.patterns?.[scope] ?? rule.pattern;
|
|
4015
|
+
const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
|
|
4016
|
+
cache.set(scope, compiled);
|
|
4017
|
+
return compiled;
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
function resolveProseRules(config = undefined, options = {}) {
|
|
4021
|
+
const rules = [];
|
|
4022
|
+
const defaults = config?.defaults ?? {};
|
|
4023
|
+
for (const rule of CONFIGURABLE_DEFAULT_RULES) {
|
|
4024
|
+
const override = defaults[rule.id];
|
|
4025
|
+
if (override === "off")
|
|
4026
|
+
continue;
|
|
4027
|
+
const group = rule.group;
|
|
4028
|
+
const scopes = override?.scopes ?? rule.scopes;
|
|
4029
|
+
const base = {};
|
|
4030
|
+
for (const scope of scopes) {
|
|
4031
|
+
base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4032
|
+
}
|
|
4033
|
+
rules.push({
|
|
4034
|
+
id: rule.id,
|
|
4035
|
+
group,
|
|
4036
|
+
custom: false,
|
|
4037
|
+
builtIn: rule.builtIn === true,
|
|
4038
|
+
scopes,
|
|
4039
|
+
message: rule.message,
|
|
4040
|
+
severity: applySeverity(scopes, base, override?.severity),
|
|
4041
|
+
exempt: override?.exempt ?? [],
|
|
4042
|
+
substringExempt: rule.exemptions,
|
|
4043
|
+
reportGroup: REPORT_GROUPS[rule.id],
|
|
4044
|
+
patternFor: defaultPatternFor(rule)
|
|
4045
|
+
});
|
|
4046
|
+
}
|
|
4047
|
+
for (const rule of config?.custom ?? []) {
|
|
4048
|
+
const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
|
|
4049
|
+
const base = {};
|
|
4050
|
+
for (const scope of rule.scopes)
|
|
4051
|
+
base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4052
|
+
rules.push({
|
|
4053
|
+
id: rule.id,
|
|
4054
|
+
group,
|
|
4055
|
+
custom: true,
|
|
4056
|
+
builtIn: false,
|
|
4057
|
+
scopes: rule.scopes,
|
|
4058
|
+
message: rule.means,
|
|
4059
|
+
severity: applySeverity(rule.scopes, base, rule.severity),
|
|
4060
|
+
exempt: rule.exempt ?? [],
|
|
4061
|
+
substringExempt: [],
|
|
4062
|
+
patternFor: customPatternFor(rule, group === "reader-resolvable")
|
|
4063
|
+
});
|
|
4064
|
+
}
|
|
4065
|
+
if (options.decisionRecordsPath !== undefined)
|
|
4066
|
+
rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
|
|
4067
|
+
const order = (rule) => {
|
|
4068
|
+
const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
|
|
4069
|
+
return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
|
|
4070
|
+
};
|
|
4071
|
+
const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
|
|
4072
|
+
const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
|
|
4073
|
+
return {
|
|
4074
|
+
rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
|
|
4075
|
+
exempt: config?.exempt ?? [],
|
|
4076
|
+
repoRoot: options.repoRoot
|
|
4077
|
+
};
|
|
4078
|
+
}
|
|
4079
|
+
function rulesOfGroup(set, group) {
|
|
4080
|
+
return set.rules.filter((rule) => rule.group === group);
|
|
4081
|
+
}
|
|
4082
|
+
function rulesInScope(set, scope) {
|
|
4083
|
+
return set.rules.filter((rule) => rule.scopes.includes(scope));
|
|
4084
|
+
}
|
|
4085
|
+
var DEFAULT_PROSE_RULE_SET = resolveProseRules();
|
|
4086
|
+
var DECISION_RECORD_CITATION_ID = "decision-record-citation";
|
|
4087
|
+
var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
|
|
4088
|
+
var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
|
|
4089
|
+
function escapeRegExp(text) {
|
|
4090
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4091
|
+
}
|
|
4092
|
+
function decisionRecordCitationPattern(decisionRecordsPath) {
|
|
4093
|
+
const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
|
|
4094
|
+
return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
|
|
4095
|
+
}
|
|
4096
|
+
function decisionRecordCitationRule(decisionRecordsPath) {
|
|
4097
|
+
const folder = normalizeRepoPath(decisionRecordsPath);
|
|
4098
|
+
const pattern = decisionRecordCitationPattern(folder);
|
|
4099
|
+
const severity = {};
|
|
4100
|
+
for (const scope of DECISION_RECORD_CITATION_SCOPES)
|
|
4101
|
+
severity[scope] = "error";
|
|
4102
|
+
return {
|
|
4103
|
+
id: DECISION_RECORD_CITATION_ID,
|
|
4104
|
+
group: "reader-resolvable",
|
|
4105
|
+
custom: false,
|
|
4106
|
+
builtIn: false,
|
|
4107
|
+
scopes: DECISION_RECORD_CITATION_SCOPES,
|
|
4108
|
+
message: DECISION_RECORD_CITATION_MESSAGE,
|
|
4109
|
+
severity,
|
|
4110
|
+
exempt: [folder],
|
|
4111
|
+
substringExempt: [],
|
|
4112
|
+
patternFor: () => pattern
|
|
4113
|
+
};
|
|
4114
|
+
}
|
|
4115
|
+
|
|
3433
4116
|
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3434
4117
|
var PRODUCT_SLUG_SCOPE = [
|
|
3435
4118
|
"apps/cli/src",
|
|
@@ -3441,8 +4124,8 @@ var PRODUCT_SLUG_SCOPE = [
|
|
|
3441
4124
|
function isUnderOrEqual(path, prefix) {
|
|
3442
4125
|
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3443
4126
|
}
|
|
3444
|
-
function isProductScopeFile(path) {
|
|
3445
|
-
return
|
|
4127
|
+
function isProductScopeFile(path, productPaths) {
|
|
4128
|
+
return productPaths.some((prefix) => isUnderOrEqual(path, normalizeRepoPath(prefix)));
|
|
3446
4129
|
}
|
|
3447
4130
|
var SHIPS_PREFIX = "aeg-root/";
|
|
3448
4131
|
function shipsArchivePrefix(shipsPrefix) {
|
|
@@ -3450,13 +4133,7 @@ function shipsArchivePrefix(shipsPrefix) {
|
|
|
3450
4133
|
}
|
|
3451
4134
|
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3452
4135
|
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;
|
|
4136
|
+
return normalizeRepoPath(entry);
|
|
3460
4137
|
}
|
|
3461
4138
|
function isSpecFile2(path, specPaths) {
|
|
3462
4139
|
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
@@ -3468,7 +4145,7 @@ function isSpecFile2(path, specPaths) {
|
|
|
3468
4145
|
function isClaudeMdFile(path) {
|
|
3469
4146
|
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3470
4147
|
}
|
|
3471
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4148
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS, productPaths = PRODUCT_SLUG_SCOPE) {
|
|
3472
4149
|
if (path.startsWith(shipsPrefix)) {
|
|
3473
4150
|
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3474
4151
|
}
|
|
@@ -3479,7 +4156,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
|
|
|
3479
4156
|
return "internal";
|
|
3480
4157
|
if (isSpecFile2(path, specPaths))
|
|
3481
4158
|
return "spec";
|
|
3482
|
-
if (isProductScopeFile(path))
|
|
4159
|
+
if (isProductScopeFile(path, productPaths))
|
|
3483
4160
|
return "product";
|
|
3484
4161
|
return null;
|
|
3485
4162
|
}
|
|
@@ -3504,9 +4181,16 @@ function lineAt(content, index) {
|
|
|
3504
4181
|
}
|
|
3505
4182
|
return line;
|
|
3506
4183
|
}
|
|
3507
|
-
var
|
|
3508
|
-
var
|
|
3509
|
-
|
|
4184
|
+
var readerRules = rulesForGroup("reader-resolvable");
|
|
4185
|
+
var readerPattern = (id, scope = "prose") => {
|
|
4186
|
+
const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
|
|
4187
|
+
if (!(pattern instanceof RegExp))
|
|
4188
|
+
throw new Error(`default prose rule ${id} has no ${scope} pattern`);
|
|
4189
|
+
return pattern;
|
|
4190
|
+
};
|
|
4191
|
+
var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
|
|
4192
|
+
var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
|
|
4193
|
+
var TASK_NUMBER_PATTERN = readerPattern("task-number");
|
|
3510
4194
|
function legacySlugPattern(legacySlugs) {
|
|
3511
4195
|
if (legacySlugs.length === 0)
|
|
3512
4196
|
return null;
|
|
@@ -3516,48 +4200,61 @@ function legacySlugPattern(legacySlugs) {
|
|
|
3516
4200
|
function specGrandfatherPaths(specGrandfather) {
|
|
3517
4201
|
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
|
|
3518
4202
|
}
|
|
3519
|
-
|
|
4203
|
+
var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
|
|
4204
|
+
function referenceRulesFor(set, cls) {
|
|
4205
|
+
return rulesInScope(set, cls).filter((rule) => rule.group === "reader-resolvable" && rule.id !== "coined-term");
|
|
4206
|
+
}
|
|
4207
|
+
function citations(pattern, text, group) {
|
|
4208
|
+
const out = [];
|
|
4209
|
+
const re = pattern.global ? pattern : new RegExp(pattern.source, `${pattern.flags}g`);
|
|
4210
|
+
re.lastIndex = 0;
|
|
4211
|
+
let match = re.exec(text);
|
|
4212
|
+
while (match !== null) {
|
|
4213
|
+
if (match[0] === "") {
|
|
4214
|
+
re.lastIndex++;
|
|
4215
|
+
} else {
|
|
4216
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4217
|
+
out.push({ cited, index: match.index + match[0].indexOf(cited) });
|
|
4218
|
+
}
|
|
4219
|
+
match = re.exec(text);
|
|
4220
|
+
}
|
|
4221
|
+
re.lastIndex = 0;
|
|
4222
|
+
return out;
|
|
4223
|
+
}
|
|
4224
|
+
function customMessage(rule, cited) {
|
|
4225
|
+
return `${rule.id}: ${rule.message} ("${cited}")`;
|
|
4226
|
+
}
|
|
4227
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
4228
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4229
|
+
const productPaths = options.productPaths ?? PRODUCT_SLUG_SCOPE;
|
|
3520
4230
|
const findings = [];
|
|
3521
4231
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3522
4232
|
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
|
|
3523
4233
|
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
4234
|
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))
|
|
4235
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths, productPaths);
|
|
4236
|
+
if (!cls || !REFERENCE_CLASSES.has(cls))
|
|
3541
4237
|
continue;
|
|
3542
4238
|
if (cls === "spec" && grandfatheredWhole.has(file.path))
|
|
3543
4239
|
continue;
|
|
3544
|
-
const blocking = cls === "product" || cls === "spec";
|
|
3545
4240
|
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
4241
|
const fileFindings = [];
|
|
3548
|
-
for (const
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
4242
|
+
for (const rule of referenceRulesFor(set, cls)) {
|
|
4243
|
+
if (!ruleReads(set, rule, file.path))
|
|
4244
|
+
continue;
|
|
4245
|
+
const pattern = !rule.custom && rule.id === "legacy-batch-name" ? legacyPattern : rule.patternFor(cls);
|
|
4246
|
+
if (!pattern)
|
|
4247
|
+
continue;
|
|
4248
|
+
const blocking = rule.severity[cls] === "error";
|
|
4249
|
+
const what = cls === "product" ? `${rule.message} in product code` : rule.message;
|
|
4250
|
+
for (const { cited, index } of citations(pattern, scrubbed, rule.custom ? undefined : rule.reportGroup)) {
|
|
3554
4251
|
fileFindings.push({
|
|
3555
4252
|
file: file.path,
|
|
3556
|
-
line: lineAt(scrubbed,
|
|
3557
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3558
|
-
blocking
|
|
4253
|
+
line: lineAt(scrubbed, index),
|
|
4254
|
+
message: rule.custom ? customMessage(rule, cited) : `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4255
|
+
blocking,
|
|
4256
|
+
rule: rule.id
|
|
3559
4257
|
});
|
|
3560
|
-
match = pattern.exec(scrubbed);
|
|
3561
4258
|
}
|
|
3562
4259
|
}
|
|
3563
4260
|
const limit = cls === "spec" ? limits.get(file.path) : undefined;
|
|
@@ -3598,11 +4295,17 @@ function definesOrLinksGlossary(content, term) {
|
|
|
3598
4295
|
return true;
|
|
3599
4296
|
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3600
4297
|
}
|
|
3601
|
-
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4298
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, options = {}) {
|
|
3602
4299
|
const findings = [];
|
|
4300
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4301
|
+
const rule = set.rules.find((r) => !r.custom && r.id === "coined-term");
|
|
4302
|
+
if (!rule)
|
|
4303
|
+
return findings;
|
|
3603
4304
|
for (const file of files) {
|
|
3604
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3605
|
-
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
4305
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, DEFAULT_SPEC_PATHS, options.productPaths);
|
|
4306
|
+
if (!cls || !SWEPT_CLASSES.has(cls) || !rule.scopes.includes(cls))
|
|
4307
|
+
continue;
|
|
4308
|
+
if (!ruleReads(set, rule, file.path))
|
|
3606
4309
|
continue;
|
|
3607
4310
|
const scrubbed = stripNonProse(file.path, file.content);
|
|
3608
4311
|
for (const term of glossaryTerms) {
|
|
@@ -3615,14 +4318,15 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
|
|
|
3615
4318
|
file: file.path,
|
|
3616
4319
|
line,
|
|
3617
4320
|
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3618
|
-
blocking:
|
|
4321
|
+
blocking: rule.severity[cls] === "error",
|
|
4322
|
+
rule: rule.id
|
|
3619
4323
|
});
|
|
3620
4324
|
}
|
|
3621
4325
|
}
|
|
3622
4326
|
return findings;
|
|
3623
4327
|
}
|
|
3624
|
-
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN =
|
|
3625
|
-
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN =
|
|
4328
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
|
|
4329
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
|
|
3626
4330
|
function extractComments(path, content) {
|
|
3627
4331
|
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3628
4332
|
return content.replace(/[^\n]/g, "");
|
|
@@ -3719,39 +4423,40 @@ function extractComments(path, content) {
|
|
|
3719
4423
|
}
|
|
3720
4424
|
return out;
|
|
3721
4425
|
}
|
|
3722
|
-
function checkSourceComments(files, allowlist = []) {
|
|
4426
|
+
function checkSourceComments(files, allowlist = [], options = {}) {
|
|
3723
4427
|
const findings = [];
|
|
3724
4428
|
const allowed = new Set(allowlist);
|
|
3725
|
-
const
|
|
3726
|
-
|
|
3727
|
-
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3728
|
-
];
|
|
4429
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4430
|
+
const rules = rulesInScope(set, "source-comment").filter((rule) => rule.group === "reader-resolvable");
|
|
3729
4431
|
for (const file of files) {
|
|
3730
4432
|
if (!file.path.endsWith(".ts"))
|
|
3731
4433
|
continue;
|
|
3732
4434
|
if (allowed.has(file.path))
|
|
3733
4435
|
continue;
|
|
3734
4436
|
const comments = extractComments(file.path, file.content);
|
|
3735
|
-
for (const
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
4437
|
+
for (const rule of rules) {
|
|
4438
|
+
if (!ruleReads(set, rule, file.path))
|
|
4439
|
+
continue;
|
|
4440
|
+
const pattern = rule.patternFor("source-comment");
|
|
4441
|
+
if (!pattern)
|
|
4442
|
+
continue;
|
|
4443
|
+
for (const { cited, index } of citations(pattern, comments)) {
|
|
3739
4444
|
findings.push({
|
|
3740
4445
|
file: file.path,
|
|
3741
|
-
line: lineAt(comments,
|
|
3742
|
-
message: `comment cites ${
|
|
3743
|
-
blocking:
|
|
4446
|
+
line: lineAt(comments, index),
|
|
4447
|
+
message: rule.custom ? customMessage(rule, cited) : `comment cites ${rule.message} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4448
|
+
blocking: rule.severity["source-comment"] === "error",
|
|
4449
|
+
rule: rule.id
|
|
3744
4450
|
});
|
|
3745
|
-
match = pattern.exec(comments);
|
|
3746
4451
|
}
|
|
3747
4452
|
}
|
|
3748
4453
|
}
|
|
3749
4454
|
return findings;
|
|
3750
4455
|
}
|
|
3751
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4456
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
3752
4457
|
return [
|
|
3753
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3754
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4458
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths, options),
|
|
4459
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix, options)
|
|
3755
4460
|
];
|
|
3756
4461
|
}
|
|
3757
4462
|
function parseGlossaryTerms(glossaryContent) {
|
|
@@ -3954,6 +4659,17 @@ function checkDocClaims(files, fileReader) {
|
|
|
3954
4659
|
};
|
|
3955
4660
|
}
|
|
3956
4661
|
|
|
4662
|
+
// ../../packages/aeg-core/src/protected-paths.ts
|
|
4663
|
+
import { posix as posixPath } from "node:path";
|
|
4664
|
+
var PROTECTED_ADMIN_PATHS = ["vinaya.config.json", ".vinaya/doc-owners", ".github/", "aeg-root/"];
|
|
4665
|
+
function normalizeTouchedPath(path) {
|
|
4666
|
+
return posixPath.resolve("/", path.replace(/\\/g, "/")).replace(/^\/+/, "");
|
|
4667
|
+
}
|
|
4668
|
+
function isProtectedAdminPath(path) {
|
|
4669
|
+
const normalized = normalizeTouchedPath(path);
|
|
4670
|
+
return PROTECTED_ADMIN_PATHS.some((prefix) => normalized === prefix || normalized.startsWith(prefix));
|
|
4671
|
+
}
|
|
4672
|
+
|
|
3957
4673
|
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3958
4674
|
function hasRationaleField(body, labelPattern) {
|
|
3959
4675
|
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
@@ -4073,13 +4789,20 @@ function globCoversPath(glob, path) {
|
|
|
4073
4789
|
return !p.includes("/");
|
|
4074
4790
|
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
4075
4791
|
}
|
|
4792
|
+
function surfaceEntryResolves(entry, resolvesToFile, pinnedFiles) {
|
|
4793
|
+
if (resolvesToFile(entry))
|
|
4794
|
+
return true;
|
|
4795
|
+
const directory = entry.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
4796
|
+
return pinnedFiles.some((path) => path.startsWith(`${directory}/`));
|
|
4797
|
+
}
|
|
4076
4798
|
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
4077
4799
|
const surface = parseIssueSurface(body);
|
|
4078
4800
|
if (!surface.ok)
|
|
4079
4801
|
return { status: "pass", errors: [] };
|
|
4802
|
+
const pinnedFiles = boundaryPinnedFiles(body);
|
|
4080
4803
|
const errors = [];
|
|
4081
4804
|
for (const glob of surface.value.in) {
|
|
4082
|
-
if (!
|
|
4805
|
+
if (!surfaceEntryResolves(glob, resolvesToFile, pinnedFiles)) {
|
|
4083
4806
|
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
4807
|
}
|
|
4085
4808
|
}
|
|
@@ -4109,6 +4832,14 @@ function recordedBeyondSurfacePaths(body) {
|
|
|
4109
4832
|
return paths;
|
|
4110
4833
|
}
|
|
4111
4834
|
function checkSurfaceScope(changedFiles, surface, recorded) {
|
|
4835
|
+
for (const path of changedFiles) {
|
|
4836
|
+
if (!isProtectedAdminPath(path))
|
|
4837
|
+
continue;
|
|
4838
|
+
const normalized = normalizeTouchedPath(path);
|
|
4839
|
+
if (!surface.in.some((glob) => globCoversPath(glob, normalized))) {
|
|
4840
|
+
return { ok: false, violation: { path, reason: "protected" } };
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4112
4843
|
const listed = new Set(recorded);
|
|
4113
4844
|
const violation = beyondSurfacePaths(changedFiles, surface).find((entry) => !listed.has(entry.path));
|
|
4114
4845
|
return violation ? { ok: false, violation } : { ok: true };
|
|
@@ -4164,12 +4895,22 @@ function checkPartsCiteDefinedObjectives(body) {
|
|
|
4164
4895
|
}
|
|
4165
4896
|
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4166
4897
|
}
|
|
4898
|
+
var ISSUE_LIVE_LINE_RE = /^-\s*\*{2}\[live\]\*{2}(.*)$/gim;
|
|
4899
|
+
function liveCommand(text) {
|
|
4900
|
+
const trimmed = text.trim();
|
|
4901
|
+
const span = /^(`+)(.+)\1$/.exec(trimmed);
|
|
4902
|
+
return span ? span[2].trim() : trimmed;
|
|
4903
|
+
}
|
|
4904
|
+
function liveItemsIn(region) {
|
|
4905
|
+
return [...region.matchAll(ISSUE_LIVE_LINE_RE)].map((m) => liveCommand(m[1] ?? "")).filter(Boolean);
|
|
4906
|
+
}
|
|
4907
|
+
function parseLiveTestPlanItems(body) {
|
|
4908
|
+
const located = locateTestPlanSection(body);
|
|
4909
|
+
return located.found ? liveItemsIn(located.section) : [];
|
|
4910
|
+
}
|
|
4167
4911
|
function isTaskIssueLabelSet(labels) {
|
|
4168
4912
|
return hasLabel("tranche", labels);
|
|
4169
4913
|
}
|
|
4170
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
4171
|
-
return { status: "pass", errors: [] };
|
|
4172
|
-
}
|
|
4173
4914
|
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4174
4915
|
if (!isTaskIssueLabelSet(labels))
|
|
4175
4916
|
return { status: "pass", errors: [] };
|
|
@@ -4185,6 +4926,7 @@ function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTi
|
|
|
4185
4926
|
};
|
|
4186
4927
|
}
|
|
4187
4928
|
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4929
|
+
var PATH_TEXT = (body) => stripCode(body, { inlineSpans: "keep" });
|
|
4188
4930
|
function isControlCodePoint(codePoint) {
|
|
4189
4931
|
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4190
4932
|
}
|
|
@@ -4245,8 +4987,14 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
|
4245
4987
|
}
|
|
4246
4988
|
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4247
4989
|
}
|
|
4990
|
+
function rationaleFieldText(text, labelPattern) {
|
|
4991
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})[^\\n]*\\n?([\\s\\S]*?)(?=\\n\\s*(?:\\*\\*[A-Z]|#{1,4}\\s)|(?![\\s\\S]))`, "im");
|
|
4992
|
+
const m = re.exec(text);
|
|
4993
|
+
return m ? m[0] : "";
|
|
4994
|
+
}
|
|
4248
4995
|
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
4996
|
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
4997
|
+
var RATIONALE_PATH_RE_GLOBAL = /`([\w.@-]+(?:\/[\w.@-]+)+)`/g;
|
|
4250
4998
|
function normalizeEdgeId(s) {
|
|
4251
4999
|
const qualified = splitSlugQualifiedEdge(s);
|
|
4252
5000
|
return (qualified ? qualified.bareId : s).replace(/^#/, "").trim();
|
|
@@ -4254,6 +5002,15 @@ function normalizeEdgeId(s) {
|
|
|
4254
5002
|
function edgesNameEachOther(a, b) {
|
|
4255
5003
|
return a.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(b.ref)) || b.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(a.ref));
|
|
4256
5004
|
}
|
|
5005
|
+
var BOUNDARY_OUT_RE = /\bOut\s*:\s*([\s\S]*)$/im;
|
|
5006
|
+
function boundaryOutText(body) {
|
|
5007
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5008
|
+
const m = BOUNDARY_OUT_RE.exec(boundary);
|
|
5009
|
+
return m ? m[1] : "";
|
|
5010
|
+
}
|
|
5011
|
+
function namedPathsIn(text) {
|
|
5012
|
+
return [...new Set([...text.matchAll(RATIONALE_PATH_RE_GLOBAL)].map((m) => m[1]))].filter((p) => !/^https?:\/\//i.test(p));
|
|
5013
|
+
}
|
|
4257
5014
|
var FILE_EXTENSIONS = new Set([
|
|
4258
5015
|
"ts",
|
|
4259
5016
|
"tsx",
|
|
@@ -4275,6 +5032,11 @@ var FILE_EXTENSIONS = new Set([
|
|
|
4275
5032
|
"html",
|
|
4276
5033
|
"css"
|
|
4277
5034
|
]);
|
|
5035
|
+
function boundaryPinnedFiles(body) {
|
|
5036
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5037
|
+
const excluded = new Set(namedPathsIn(boundaryOutText(body)));
|
|
5038
|
+
return namedPathsIn(boundary).filter((p) => looksLikeFilePath(p) && !excluded.has(p));
|
|
5039
|
+
}
|
|
4278
5040
|
var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
|
|
4279
5041
|
var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
|
|
4280
5042
|
|
|
@@ -4299,7 +5061,7 @@ function isGrandfathered(isoDate) {
|
|
|
4299
5061
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4300
5062
|
}
|
|
4301
5063
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4302
|
-
function checkA1(entries, principalAllowlist
|
|
5064
|
+
function checkA1(entries, principalAllowlist) {
|
|
4303
5065
|
const failures = [];
|
|
4304
5066
|
for (const e of entries) {
|
|
4305
5067
|
if (!e.facts)
|
|
@@ -4329,6 +5091,37 @@ function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
|
4329
5091
|
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4330
5092
|
};
|
|
4331
5093
|
}
|
|
5094
|
+
function checkA2(entries, hasProvenanceByKey) {
|
|
5095
|
+
const failures = [];
|
|
5096
|
+
for (const e of entries) {
|
|
5097
|
+
if (!e.facts)
|
|
5098
|
+
continue;
|
|
5099
|
+
if (e.facts.issueState !== "closed" || e.facts.prState !== "merged")
|
|
5100
|
+
continue;
|
|
5101
|
+
const key = `${e.trancheSlug}/${e.task.id}`;
|
|
5102
|
+
const hasProvenance = hasProvenanceByKey.get(key);
|
|
5103
|
+
if (hasProvenance === undefined)
|
|
5104
|
+
continue;
|
|
5105
|
+
if (!hasProvenance) {
|
|
5106
|
+
failures.push({
|
|
5107
|
+
code: "archived-without-provenance",
|
|
5108
|
+
issue: e.task.issue,
|
|
5109
|
+
tranche: e.trancheSlug,
|
|
5110
|
+
task: e.task.id,
|
|
5111
|
+
reason: "Closing PR has no `### AEG provenance` comment (Archivist close-out missing)",
|
|
5112
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
5113
|
+
});
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
5117
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
5118
|
+
return {
|
|
5119
|
+
check: "A2",
|
|
5120
|
+
status,
|
|
5121
|
+
failures,
|
|
5122
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
5123
|
+
};
|
|
5124
|
+
}
|
|
4332
5125
|
function checkA3(entries) {
|
|
4333
5126
|
const failures = [];
|
|
4334
5127
|
for (const e of entries) {
|
|
@@ -4544,6 +5337,33 @@ function checkL1(files, entriesBySlug) {
|
|
|
4544
5337
|
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4545
5338
|
};
|
|
4546
5339
|
}
|
|
5340
|
+
function checkL2(files, entriesBySlug) {
|
|
5341
|
+
const failures = [];
|
|
5342
|
+
for (const f of files) {
|
|
5343
|
+
if (!f.archived)
|
|
5344
|
+
continue;
|
|
5345
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
5346
|
+
for (const e of entries) {
|
|
5347
|
+
if (!e.facts)
|
|
5348
|
+
continue;
|
|
5349
|
+
if (e.facts.issueState === "open") {
|
|
5350
|
+
failures.push({
|
|
5351
|
+
code: "premature-archive",
|
|
5352
|
+
issue: e.task.issue,
|
|
5353
|
+
tranche: f.slug,
|
|
5354
|
+
task: e.task.id,
|
|
5355
|
+
reason: `Archived tranche has open task-Issue #${e.task.issue ?? "?"} (premature archive)`
|
|
5356
|
+
});
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
}
|
|
5360
|
+
return {
|
|
5361
|
+
check: "L2",
|
|
5362
|
+
status: "info",
|
|
5363
|
+
failures,
|
|
5364
|
+
note: failures.length > 0 ? `${failures.length} archived tranche(s) with an open task-Issue — investigate (advisory)` : undefined
|
|
5365
|
+
};
|
|
5366
|
+
}
|
|
4547
5367
|
function checkL3(files) {
|
|
4548
5368
|
const active = files.filter((f) => !f.archived);
|
|
4549
5369
|
return {
|
|
@@ -4553,6 +5373,51 @@ function checkL3(files) {
|
|
|
4553
5373
|
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4554
5374
|
};
|
|
4555
5375
|
}
|
|
5376
|
+
function checkL4(activeTrancheSlugs, issueMilestones) {
|
|
5377
|
+
const activeSet = new Set(activeTrancheSlugs);
|
|
5378
|
+
const failures = [];
|
|
5379
|
+
for (const f of issueMilestones) {
|
|
5380
|
+
if (!activeSet.has(f.tranche))
|
|
5381
|
+
continue;
|
|
5382
|
+
if (f.milestoneTitle === f.tranche)
|
|
5383
|
+
continue;
|
|
5384
|
+
failures.push({
|
|
5385
|
+
code: "milestone-drift",
|
|
5386
|
+
issue: f.issue,
|
|
5387
|
+
tranche: f.tranche,
|
|
5388
|
+
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`
|
|
5389
|
+
});
|
|
5390
|
+
}
|
|
5391
|
+
return {
|
|
5392
|
+
check: "L4",
|
|
5393
|
+
status: "info",
|
|
5394
|
+
failures,
|
|
5395
|
+
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
|
|
5396
|
+
};
|
|
5397
|
+
}
|
|
5398
|
+
function checkL5(activeTrancheSlugs, entriesBySlug) {
|
|
5399
|
+
const failures = [];
|
|
5400
|
+
for (const slug of activeTrancheSlugs) {
|
|
5401
|
+
const entries = entriesBySlug.get(slug) ?? [];
|
|
5402
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
5403
|
+
if (withFacts.length === 0)
|
|
5404
|
+
continue;
|
|
5405
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
5406
|
+
if (allClosed) {
|
|
5407
|
+
failures.push({
|
|
5408
|
+
code: "tranche-not-archived",
|
|
5409
|
+
tranche: slug,
|
|
5410
|
+
reason: "Every task Issue is closed but the tranche is not recorded as complete — archive it"
|
|
5411
|
+
});
|
|
5412
|
+
}
|
|
5413
|
+
}
|
|
5414
|
+
return {
|
|
5415
|
+
check: "L5",
|
|
5416
|
+
status: failures.length > 0 ? "fail" : "pass",
|
|
5417
|
+
failures,
|
|
5418
|
+
note: failures.length > 0 ? `${failures.length} tranche(s) whose task Issues are all closed but were never archived` : undefined
|
|
5419
|
+
};
|
|
5420
|
+
}
|
|
4556
5421
|
function extractClosesReferences(prBody) {
|
|
4557
5422
|
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4558
5423
|
const stripped = stripCode(prBody);
|
|
@@ -4648,6 +5513,58 @@ function extractIssue(body) {
|
|
|
4648
5513
|
}
|
|
4649
5514
|
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4650
5515
|
import { createHash as createHash4 } from "node:crypto";
|
|
5516
|
+
|
|
5517
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
5518
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
5519
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
5520
|
+
let best = 0;
|
|
5521
|
+
for (const c of comments) {
|
|
5522
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5523
|
+
continue;
|
|
5524
|
+
const firstLine = (c.body.split(`
|
|
5525
|
+
`)[0] ?? "").trim();
|
|
5526
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
5527
|
+
if (!m)
|
|
5528
|
+
continue;
|
|
5529
|
+
const k = Number.parseInt(m[1], 10);
|
|
5530
|
+
if (k > best)
|
|
5531
|
+
best = k;
|
|
5532
|
+
}
|
|
5533
|
+
return best;
|
|
5534
|
+
}
|
|
5535
|
+
function parseRulingIdentity(rulingId) {
|
|
5536
|
+
const m = /^(issue-)?(\d+)-(\d+)$/.exec(rulingId);
|
|
5537
|
+
if (!m)
|
|
5538
|
+
return null;
|
|
5539
|
+
const ref = Number.parseInt(m[2], 10);
|
|
5540
|
+
const ordinal = Number.parseInt(m[3], 10);
|
|
5541
|
+
if (ref <= 0 || ordinal <= 0)
|
|
5542
|
+
return null;
|
|
5543
|
+
return { target: m[1] ? "issue" : "pr", ref, ordinal };
|
|
5544
|
+
}
|
|
5545
|
+
function principalRulingTextById(comments, allowlist, rulingId) {
|
|
5546
|
+
const identity = parseRulingIdentity(rulingId);
|
|
5547
|
+
if (identity === null)
|
|
5548
|
+
return null;
|
|
5549
|
+
const matches = comments.filter((c) => {
|
|
5550
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5551
|
+
return false;
|
|
5552
|
+
const m = RULING_MARKER_ORDINAL.exec((c.body.split(`
|
|
5553
|
+
`)[0] ?? "").trim());
|
|
5554
|
+
return m !== null && Number.parseInt(m[1], 10) === identity.ordinal;
|
|
5555
|
+
});
|
|
5556
|
+
if (matches.length !== 1)
|
|
5557
|
+
return null;
|
|
5558
|
+
const body = matches[0].body;
|
|
5559
|
+
const idx = body.indexOf(`
|
|
5560
|
+
`);
|
|
5561
|
+
return idx === -1 ? "" : body.slice(idx + 1).trim();
|
|
5562
|
+
}
|
|
5563
|
+
|
|
5564
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
5565
|
+
function pauseBoundRulingDigest(rulingText) {
|
|
5566
|
+
return createHash4("sha256").update(rulingText).digest("hex");
|
|
5567
|
+
}
|
|
4651
5568
|
function briefHash(brief) {
|
|
4652
5569
|
return createHash4("sha256").update(`${brief}
|
|
4653
5570
|
`).digest("hex");
|
|
@@ -4708,14 +5625,19 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4708
5625
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4709
5626
|
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4710
5627
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
5628
|
+
const legacyCurrent = current.manifestVersion === undefined;
|
|
5629
|
+
const manifestVersion = legacyCurrent ? echoed.manifestVersion === undefined || echoed.manifestVersion === null : echoed.manifestVersion === current.manifestVersion;
|
|
5630
|
+
const pauseBoundRuling = legacyCurrent ? true : Object.hasOwn(echoed, "pauseBoundRuling") && JSON.stringify(echoed.pauseBoundRuling) === JSON.stringify(current.pauseBoundRuling);
|
|
4711
5631
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4712
5632
|
return {
|
|
4713
|
-
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
5633
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && pauseBoundRuling && manifestVersion && policyDigestBound,
|
|
4714
5634
|
head,
|
|
4715
5635
|
base,
|
|
4716
5636
|
briefHash: briefHashBound,
|
|
4717
5637
|
objectivesVersion,
|
|
4718
5638
|
rulingOrdinal,
|
|
5639
|
+
pauseBoundRuling,
|
|
5640
|
+
manifestVersion,
|
|
4719
5641
|
policyDigest: policyDigestBound
|
|
4720
5642
|
};
|
|
4721
5643
|
}
|
|
@@ -4731,7 +5653,7 @@ function renderGateDeferred(deferred) {
|
|
|
4731
5653
|
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4732
5654
|
}
|
|
4733
5655
|
function checkReviewGate(input) {
|
|
4734
|
-
const principalAllowlist = input
|
|
5656
|
+
const { principalAllowlist } = input;
|
|
4735
5657
|
const waived = isWaiverLabelActorVerified({
|
|
4736
5658
|
label: WAIVER_LABEL_REVIEW,
|
|
4737
5659
|
labels: input.labels,
|
|
@@ -4770,27 +5692,33 @@ function checkReviewGate(input) {
|
|
|
4770
5692
|
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4771
5693
|
const securityClean = securityTextClean && securityPolicyClean;
|
|
4772
5694
|
const currentManifest = {
|
|
5695
|
+
...input.manifestVersion === undefined ? {} : { manifestVersion: input.manifestVersion },
|
|
4773
5696
|
headSha: input.headSha,
|
|
4774
5697
|
baseSha: input.baseSha ?? null,
|
|
4775
5698
|
briefHash: input.briefHash ?? null,
|
|
4776
5699
|
objectivesVersion: input.objectivesVersion,
|
|
4777
5700
|
rulingOrdinal: input.rulingOrdinal,
|
|
5701
|
+
pauseBoundRuling: input.pauseBoundRuling ?? null,
|
|
4778
5702
|
policyDigest: policyDigest(policy)
|
|
4779
5703
|
};
|
|
4780
5704
|
const codeReviewEchoed = {
|
|
5705
|
+
manifestVersion: codeReview.manifestVersion,
|
|
4781
5706
|
headSha: codeReview.headSha,
|
|
4782
5707
|
baseSha: codeReview.baseSha,
|
|
4783
5708
|
briefHash: codeReview.briefHash,
|
|
4784
5709
|
objectivesVersion: codeReview.objectivesVersion,
|
|
4785
5710
|
rulingOrdinal: codeReview.rulingOrdinal,
|
|
5711
|
+
pauseBoundRuling: codeReview.pauseBoundRuling,
|
|
4786
5712
|
policyDigest: codeReview.policyDigest
|
|
4787
5713
|
};
|
|
4788
5714
|
const securityEchoed = {
|
|
5715
|
+
manifestVersion: security.manifestVersion,
|
|
4789
5716
|
headSha: security.headSha,
|
|
4790
5717
|
baseSha: security.baseSha,
|
|
4791
5718
|
briefHash: security.briefHash,
|
|
4792
5719
|
objectivesVersion: security.objectivesVersion,
|
|
4793
5720
|
rulingOrdinal: security.rulingOrdinal,
|
|
5721
|
+
pauseBoundRuling: security.pauseBoundRuling,
|
|
4794
5722
|
policyDigest: security.policyDigest
|
|
4795
5723
|
};
|
|
4796
5724
|
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
@@ -4829,6 +5757,10 @@ function checkReviewGate(input) {
|
|
|
4829
5757
|
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
5758
|
} else if (!codeReviewBinding.policyDigest) {
|
|
4831
5759
|
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}`);
|
|
5760
|
+
} else if (!codeReviewBinding.manifestVersion) {
|
|
5761
|
+
problems.push(`the newest code-review verdict echoes manifest version ${codeReview.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5762
|
+
} else if (!codeReviewBinding.pauseBoundRuling) {
|
|
5763
|
+
problems.push(`the newest code-review verdict echoes pauseBoundRuling ${renderBinding(codeReview.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4832
5764
|
}
|
|
4833
5765
|
if (!securityTextClean) {
|
|
4834
5766
|
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
@@ -4846,6 +5778,10 @@ function checkReviewGate(input) {
|
|
|
4846
5778
|
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
5779
|
} else if (!securityBinding.policyDigest) {
|
|
4848
5780
|
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}`);
|
|
5781
|
+
} else if (!securityBinding.manifestVersion) {
|
|
5782
|
+
problems.push(`the newest security-review verdict echoes manifest version ${security.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5783
|
+
} else if (!securityBinding.pauseBoundRuling) {
|
|
5784
|
+
problems.push(`the newest security-review verdict echoes pauseBoundRuling ${renderBinding(security.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4849
5785
|
}
|
|
4850
5786
|
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4851
5787
|
return {
|
|
@@ -4854,29 +5790,16 @@ function checkReviewGate(input) {
|
|
|
4854
5790
|
waived: false
|
|
4855
5791
|
};
|
|
4856
5792
|
}
|
|
5793
|
+
function renderBinding(binding) {
|
|
5794
|
+
if (binding === undefined)
|
|
5795
|
+
return "(absent)";
|
|
5796
|
+
return binding === null ? "(none)" : `${binding.rulingId}|${binding.pauseId}|${binding.contentDigest}`;
|
|
5797
|
+
}
|
|
4857
5798
|
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4858
5799
|
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4859
5800
|
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4860
5801
|
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4861
5802
|
}
|
|
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
5803
|
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4881
5804
|
function splitRow(line) {
|
|
4882
5805
|
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
@@ -5028,7 +5951,6 @@ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
|
5028
5951
|
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
5029
5952
|
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
5030
5953
|
"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
5954
|
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
5033
5955
|
};
|
|
5034
5956
|
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
@@ -5252,72 +6174,10 @@ function compareToBaseline(current, baseline) {
|
|
|
5252
6174
|
};
|
|
5253
6175
|
}
|
|
5254
6176
|
// ../../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
|
-
};
|
|
6177
|
+
var retiredRules = rulesForGroup("retired-vocabulary");
|
|
6178
|
+
var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
|
|
6179
|
+
var PATTERN_EXEMPT = RETIRED_PATTERN_EXEMPTIONS;
|
|
6180
|
+
var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
|
|
5321
6181
|
function lineNumbers(content, pattern) {
|
|
5322
6182
|
const out = [];
|
|
5323
6183
|
const lines = content.split(`
|
|
@@ -5328,22 +6188,29 @@ function lineNumbers(content, pattern) {
|
|
|
5328
6188
|
}
|
|
5329
6189
|
return out;
|
|
5330
6190
|
}
|
|
5331
|
-
function scanRetiredVocabulary(files) {
|
|
6191
|
+
function scanRetiredVocabulary(files, rules = DEFAULT_PROSE_RULE_SET) {
|
|
5332
6192
|
const findings = [];
|
|
6193
|
+
const retired = rulesOfGroup(rules, "retired-vocabulary");
|
|
5333
6194
|
for (const file of files) {
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
6195
|
+
for (const rule of retired) {
|
|
6196
|
+
if (rule.substringExempt.some((e) => file.path.includes(e)))
|
|
6197
|
+
continue;
|
|
6198
|
+
if (!ruleReads(rules, rule, file.path))
|
|
6199
|
+
continue;
|
|
6200
|
+
const re = rule.patternFor("repository");
|
|
6201
|
+
if (!re)
|
|
6202
|
+
continue;
|
|
6203
|
+
const pattern = rule.custom ? re.source : DEFAULT_PATTERN_OF.get(rule.id) ?? re.source;
|
|
6204
|
+
if (!rule.custom && (PATTERN_EXEMPT[pattern] ?? []).some((e) => file.path.includes(e)))
|
|
5339
6205
|
continue;
|
|
5340
|
-
const re = new RegExp(pattern);
|
|
5341
6206
|
for (const line of lineNumbers(file.content, re)) {
|
|
5342
6207
|
findings.push({
|
|
5343
6208
|
file: file.path,
|
|
5344
6209
|
line,
|
|
5345
6210
|
pattern,
|
|
5346
|
-
message: `claims a retired AEG mechanism is still live (matches /${pattern}/)
|
|
6211
|
+
message: rule.custom ? `${rule.id}: ${rule.message} (matches /${pattern}/)` : `claims a retired AEG mechanism is still live (matches /${pattern}/)`,
|
|
6212
|
+
rule: rule.id,
|
|
6213
|
+
blocking: rule.severity.repository === "error"
|
|
5347
6214
|
});
|
|
5348
6215
|
}
|
|
5349
6216
|
}
|
|
@@ -5367,7 +6234,7 @@ function isSelfDependency(dep, task, issue) {
|
|
|
5367
6234
|
function checkDispatchReadiness(input) {
|
|
5368
6235
|
const { trancheSlug, task } = input;
|
|
5369
6236
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
5370
|
-
const principalAllowlist = input
|
|
6237
|
+
const { principalAllowlist } = input;
|
|
5371
6238
|
const blockerDetails = [];
|
|
5372
6239
|
const push = (blockerClass, message) => {
|
|
5373
6240
|
blockerDetails.push({ class: blockerClass, message });
|
|
@@ -5459,6 +6326,16 @@ function pushesAnyBranchRef(pushRefs) {
|
|
|
5459
6326
|
return pushRefs.split(`
|
|
5460
6327
|
`).map((line) => line.trim()).filter((line) => line.length > 0).some((line) => line.split(/\s+/)[2]?.startsWith("refs/heads/") === true);
|
|
5461
6328
|
}
|
|
6329
|
+
function resolveDefaultBranch(facts) {
|
|
6330
|
+
const { originHead, hasOriginMain, hasOriginMaster } = facts;
|
|
6331
|
+
if (originHead !== null && originHead !== "")
|
|
6332
|
+
return originHead;
|
|
6333
|
+
if (hasOriginMain)
|
|
6334
|
+
return "main";
|
|
6335
|
+
if (hasOriginMaster)
|
|
6336
|
+
return "master";
|
|
6337
|
+
return null;
|
|
6338
|
+
}
|
|
5462
6339
|
function checkMainBranchRefusal(facts) {
|
|
5463
6340
|
const { currentSymbolicBranch, defaultBranch, pushRefs = null } = facts;
|
|
5464
6341
|
if (currentSymbolicBranch === null)
|
|
@@ -5719,54 +6596,61 @@ function checkFirstPushDispatchGate(input) {
|
|
|
5719
6596
|
reason: `verify-dispatch reports READY TO DISPATCH for \`${branch}\`.`
|
|
5720
6597
|
};
|
|
5721
6598
|
}
|
|
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
|
-
|
|
6599
|
+
// ../../packages/aeg-core/src/live-record.ts
|
|
6600
|
+
var RECORD_LINE_RE = /^-\s*\[([ xX])\]\s*\*\*\[live\]\*\*\s+(`+) ?(.+?) ?\2(?!`)\s+—\s+(passed|failed|unverified)\s+at\s+`([^`]+)`/;
|
|
6601
|
+
function liveMarkers(body) {
|
|
6602
|
+
const masked = maskCode(body);
|
|
6603
|
+
return [...masked.matchAll(/<!--\s*AEG:LIVE:(?:START|END)\s*-->/g)].map((m) => ({
|
|
6604
|
+
start: m.index,
|
|
6605
|
+
end: m.index + m[0].length
|
|
6606
|
+
}));
|
|
6607
|
+
}
|
|
6608
|
+
var AMBIGUOUS_RECORD_LINE = {
|
|
6609
|
+
line: "- [ ] **[live]** the pull request body carries more than one `AEG:LIVE` marker pair, so the driver's record cannot be told apart",
|
|
6610
|
+
ticked: false,
|
|
6611
|
+
command: "",
|
|
6612
|
+
outcome: "failed",
|
|
6613
|
+
head: ""
|
|
6614
|
+
};
|
|
6615
|
+
function readLiveRecord(body) {
|
|
6616
|
+
const markers = liveMarkers(body).length;
|
|
6617
|
+
if (markers === 0)
|
|
6618
|
+
return [];
|
|
6619
|
+
if (markers !== 2)
|
|
6620
|
+
return [AMBIGUOUS_RECORD_LINE];
|
|
6621
|
+
const region = anchoredRegion(body, "LIVE");
|
|
6622
|
+
if (region === null)
|
|
6623
|
+
return [];
|
|
6624
|
+
const lines = [];
|
|
6625
|
+
for (const raw of region.split(`
|
|
6626
|
+
`)) {
|
|
6627
|
+
const line = raw.trim();
|
|
6628
|
+
const m = RECORD_LINE_RE.exec(line);
|
|
6629
|
+
if (!m)
|
|
6630
|
+
continue;
|
|
6631
|
+
lines.push({
|
|
6632
|
+
line,
|
|
6633
|
+
ticked: m[1].toLowerCase() === "x",
|
|
6634
|
+
command: m[3],
|
|
6635
|
+
outcome: m[4],
|
|
6636
|
+
head: m[5]
|
|
6637
|
+
});
|
|
5760
6638
|
}
|
|
5761
|
-
return
|
|
5762
|
-
action: "assign",
|
|
5763
|
-
issue,
|
|
5764
|
-
login,
|
|
5765
|
-
reason: `First push of \`${branch}\` — assigning Issue #${issue} to @${login} (the authenticated pusher).`
|
|
5766
|
-
};
|
|
6639
|
+
return lines;
|
|
5767
6640
|
}
|
|
5768
6641
|
// ../../packages/aeg-core/src/test-plan-gate.ts
|
|
5769
|
-
function
|
|
6642
|
+
function gradedLiveLines(record, live) {
|
|
6643
|
+
if (live === undefined)
|
|
6644
|
+
return record.map((entry) => entry.line);
|
|
6645
|
+
const commands = new Set(live.liveCommands);
|
|
6646
|
+
const others = record.filter((entry) => !commands.has(entry.command)).map((entry) => entry.line);
|
|
6647
|
+
const graded = live.liveCommands.map((command) => {
|
|
6648
|
+
const atHead = record.filter((entry) => entry.command === command && entry.head === live.head);
|
|
6649
|
+
return (atHead.find((entry) => entry.ticked) ?? atHead[0])?.line ?? `- [ ] **[live]** \`${command}\` — no passed run recorded at \`${live.head || "an unknown head"}\``;
|
|
6650
|
+
});
|
|
6651
|
+
return [...others, ...graded];
|
|
6652
|
+
}
|
|
6653
|
+
function evaluateTestPlanGate(body, branch, live) {
|
|
5770
6654
|
if (!body) {
|
|
5771
6655
|
return {
|
|
5772
6656
|
verdict: "pass",
|
|
@@ -5777,7 +6661,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5777
6661
|
};
|
|
5778
6662
|
}
|
|
5779
6663
|
const located = locateTestPlanSection(body);
|
|
5780
|
-
|
|
6664
|
+
const liveLines = gradedLiveLines(readLiveRecord(body), live);
|
|
6665
|
+
const liveUnticked = liveLines.some((line) => /^[-*]\s+\[\s\]/.test(line));
|
|
6666
|
+
if (!located.found && !liveUnticked) {
|
|
5781
6667
|
if (parseTaskBranchIdentity(branch) !== null) {
|
|
5782
6668
|
return {
|
|
5783
6669
|
verdict: "fail",
|
|
@@ -5797,15 +6683,18 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5797
6683
|
]
|
|
5798
6684
|
};
|
|
5799
6685
|
}
|
|
5800
|
-
const section = located.section;
|
|
5801
|
-
if (/unit-tests-only/i.test(section)) {
|
|
6686
|
+
const section = located.found ? located.section : "";
|
|
6687
|
+
if (/unit-tests-only/i.test(section) && !liveUnticked) {
|
|
5802
6688
|
return {
|
|
5803
6689
|
verdict: "pass",
|
|
5804
6690
|
messages: ["Test Plan: unit-tests-only — pure-logic brief, CI unit-tests are the proof.", "PASS."]
|
|
5805
6691
|
};
|
|
5806
6692
|
}
|
|
5807
|
-
const checkboxLines =
|
|
5808
|
-
|
|
6693
|
+
const checkboxLines = [
|
|
6694
|
+
...section.split(`
|
|
6695
|
+
`).map((line) => line.trimStart()).filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line)),
|
|
6696
|
+
...liveLines
|
|
6697
|
+
];
|
|
5809
6698
|
if (checkboxLines.length === 0) {
|
|
5810
6699
|
return {
|
|
5811
6700
|
verdict: "pass",
|
|
@@ -5822,7 +6711,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5822
6711
|
messages.push("", "FAIL — the following [principal] Test Plan items are unticked:");
|
|
5823
6712
|
for (const line of unchecked)
|
|
5824
6713
|
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.",
|
|
6714
|
+
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 ? [
|
|
6715
|
+
"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."
|
|
6716
|
+
] : [], "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
6717
|
return { verdict: "fail", messages };
|
|
5827
6718
|
}
|
|
5828
6719
|
messages.push("All [principal] Test Plan items ticked — runtime verification complete.", "PASS.");
|
|
@@ -6011,9 +6902,11 @@ var LineageSchema = z3.object({
|
|
|
6011
6902
|
parent: z3.string().nullable()
|
|
6012
6903
|
}).strict();
|
|
6013
6904
|
var InputVersionsSchema = z3.object({
|
|
6905
|
+
manifest_version: z3.literal(2).nullable().optional(),
|
|
6014
6906
|
objectives_version: z3.string().nullable(),
|
|
6015
6907
|
brief_hash: z3.string().nullable(),
|
|
6016
6908
|
ruling_ordinal: z3.number().int().nullable(),
|
|
6909
|
+
pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
|
|
6017
6910
|
policy_digest: z3.string().nullable()
|
|
6018
6911
|
}).strict();
|
|
6019
6912
|
var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
@@ -6051,7 +6944,17 @@ var HeaderMetaV3Schema = z3.object({
|
|
|
6051
6944
|
runtime: z3.string().nullable(),
|
|
6052
6945
|
source: z3.string().nullable()
|
|
6053
6946
|
}).strict();
|
|
6054
|
-
var
|
|
6947
|
+
var HeaderMetaV4Schema = HeaderMetaV3Schema.extend({
|
|
6948
|
+
schema: z3.literal(4),
|
|
6949
|
+
process: z3.object({ id: z3.string(), version: z3.string().nullable(), digest: z3.string().nullable() }).strict(),
|
|
6950
|
+
runner: z3.object({ id: z3.string(), version: z3.string().nullable() }).strict()
|
|
6951
|
+
}).strict();
|
|
6952
|
+
var HeaderMetaSchema = z3.discriminatedUnion("schema", [
|
|
6953
|
+
HeaderMetaV1Schema,
|
|
6954
|
+
HeaderMetaV2Schema,
|
|
6955
|
+
HeaderMetaV3Schema,
|
|
6956
|
+
HeaderMetaV4Schema
|
|
6957
|
+
]);
|
|
6055
6958
|
var SubjectSchema = z3.object({
|
|
6056
6959
|
issue: z3.number().int().nullable(),
|
|
6057
6960
|
pr: z3.number().int().optional(),
|
|
@@ -6271,6 +7174,75 @@ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
|
|
|
6271
7174
|
round: z3.number().int(),
|
|
6272
7175
|
phase: z3.string()
|
|
6273
7176
|
}).strict(),
|
|
7177
|
+
z3.object({
|
|
7178
|
+
...loopShared,
|
|
7179
|
+
event: z3.literal("conflict_reentry"),
|
|
7180
|
+
task: z3.number().int(),
|
|
7181
|
+
pr: z3.number().int().positive(),
|
|
7182
|
+
attempt: z3.number().int().positive(),
|
|
7183
|
+
bound: z3.number().int().positive()
|
|
7184
|
+
}).strict(),
|
|
7185
|
+
z3.object({
|
|
7186
|
+
...loopShared,
|
|
7187
|
+
event: z3.literal("storage_push"),
|
|
7188
|
+
round: z3.number().int(),
|
|
7189
|
+
branch: z3.string(),
|
|
7190
|
+
head: z3.string()
|
|
7191
|
+
}).strict(),
|
|
7192
|
+
z3.object({
|
|
7193
|
+
...loopShared,
|
|
7194
|
+
event: z3.literal("local_checks_run"),
|
|
7195
|
+
round: z3.number().int(),
|
|
7196
|
+
head: z3.string().nullable(),
|
|
7197
|
+
passed: z3.boolean(),
|
|
7198
|
+
wall_ms: z3.number().nonnegative()
|
|
7199
|
+
}).strict(),
|
|
7200
|
+
z3.object({
|
|
7201
|
+
...loopShared,
|
|
7202
|
+
event: z3.literal("ready_push"),
|
|
7203
|
+
round: z3.number().int(),
|
|
7204
|
+
head: z3.string(),
|
|
7205
|
+
outcome: z3.enum(["passed", "refused"]),
|
|
7206
|
+
selected: z3.number().int().nonnegative(),
|
|
7207
|
+
failed: z3.number().int().nonnegative(),
|
|
7208
|
+
rerun: z3.boolean(),
|
|
7209
|
+
wall_ms: z3.number().nonnegative()
|
|
7210
|
+
}).strict(),
|
|
7211
|
+
z3.object({
|
|
7212
|
+
...loopShared,
|
|
7213
|
+
event: z3.literal("failed_tests_rerun"),
|
|
7214
|
+
round: z3.number().int(),
|
|
7215
|
+
head: z3.string(),
|
|
7216
|
+
rerun_of: z3.string(),
|
|
7217
|
+
failed_files: z3.number().int().nonnegative(),
|
|
7218
|
+
affected_files: z3.number().int().nonnegative(),
|
|
7219
|
+
full_count: z3.number().int().nonnegative()
|
|
7220
|
+
}).strict(),
|
|
7221
|
+
z3.object({
|
|
7222
|
+
...loopShared,
|
|
7223
|
+
event: z3.literal("pr_opened"),
|
|
7224
|
+
round: z3.number().int(),
|
|
7225
|
+
pr: z3.number().int().positive(),
|
|
7226
|
+
head: z3.string()
|
|
7227
|
+
}).strict(),
|
|
7228
|
+
z3.object({
|
|
7229
|
+
...loopShared,
|
|
7230
|
+
event: z3.literal("ci_result_read"),
|
|
7231
|
+
round: z3.number().int(),
|
|
7232
|
+
pr: z3.number().int().positive(),
|
|
7233
|
+
head: z3.string(),
|
|
7234
|
+
conclusion: z3.enum(["green", "red", "pending", "skipped"]),
|
|
7235
|
+
failing_checks: z3.array(z3.string()),
|
|
7236
|
+
wait_ms: z3.number().nonnegative()
|
|
7237
|
+
}).strict(),
|
|
7238
|
+
z3.object({
|
|
7239
|
+
...loopShared,
|
|
7240
|
+
event: z3.literal("phase_time"),
|
|
7241
|
+
round: z3.number().int(),
|
|
7242
|
+
phase: z3.enum(["developer", "local_checks", "review", "push", "ci", "other"]),
|
|
7243
|
+
step: z3.string(),
|
|
7244
|
+
wall_ms: z3.number().nonnegative()
|
|
7245
|
+
}).strict(),
|
|
6274
7246
|
z3.object({
|
|
6275
7247
|
...loopShared,
|
|
6276
7248
|
event: z3.literal("driver_exited"),
|
|
@@ -6458,7 +7430,7 @@ var EffectEventSchema = z3.discriminatedUnion("event", [
|
|
|
6458
7430
|
]);
|
|
6459
7431
|
var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
|
|
6460
7432
|
var customShared = {
|
|
6461
|
-
meta:
|
|
7433
|
+
meta: HeaderMetaSchema,
|
|
6462
7434
|
subject: SubjectSchema,
|
|
6463
7435
|
kind: z3.literal("custom"),
|
|
6464
7436
|
...envelopeTail
|
|
@@ -6543,7 +7515,7 @@ function buildHeader(input) {
|
|
|
6543
7515
|
const issue = subject.issue;
|
|
6544
7516
|
return {
|
|
6545
7517
|
meta: {
|
|
6546
|
-
schema:
|
|
7518
|
+
schema: 4,
|
|
6547
7519
|
ts: input.now.toISOString(),
|
|
6548
7520
|
run_id: input.runId,
|
|
6549
7521
|
seq: input.seq,
|
|
@@ -6561,23 +7533,34 @@ function buildHeader(input) {
|
|
|
6561
7533
|
parent: lineageFieldFromEnv(input.env.parent)
|
|
6562
7534
|
},
|
|
6563
7535
|
input_versions: {
|
|
7536
|
+
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
6564
7537
|
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
6565
7538
|
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
6566
7539
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
7540
|
+
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
6567
7541
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
6568
7542
|
},
|
|
6569
7543
|
provenance: provenanceFor(input),
|
|
6570
7544
|
work: {
|
|
6571
7545
|
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
6572
7546
|
repo: input.repo,
|
|
6573
|
-
change: null,
|
|
6574
|
-
revision: null
|
|
7547
|
+
change: pr === undefined ? null : String(pr),
|
|
7548
|
+
revision: input.revision ?? null
|
|
6575
7549
|
},
|
|
6576
7550
|
flow: {
|
|
6577
7551
|
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
6578
7552
|
version: lineageFieldFromEnv(input.env.flowVersion)
|
|
6579
7553
|
},
|
|
6580
7554
|
runtime: lineageFieldFromEnv(input.env.runtime),
|
|
7555
|
+
process: {
|
|
7556
|
+
id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
|
|
7557
|
+
version: lineageFieldFromEnv(input.env.processVersion),
|
|
7558
|
+
digest: lineageFieldFromEnv(input.env.processDigest)
|
|
7559
|
+
},
|
|
7560
|
+
runner: {
|
|
7561
|
+
id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
|
|
7562
|
+
version: lineageFieldFromEnv(input.env.runnerVersion)
|
|
7563
|
+
},
|
|
6581
7564
|
source: lineageFieldFromEnv(input.env.source)
|
|
6582
7565
|
},
|
|
6583
7566
|
subject
|
|
@@ -6621,7 +7604,7 @@ function redact(value, home) {
|
|
|
6621
7604
|
return value;
|
|
6622
7605
|
}
|
|
6623
7606
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6624
|
-
var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
|
|
7607
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2, 3, 4];
|
|
6625
7608
|
function metaOf(obj) {
|
|
6626
7609
|
if (obj === null || typeof obj !== "object")
|
|
6627
7610
|
return null;
|
|
@@ -6759,6 +7742,12 @@ var ManifestRecordSchema = z4.object({
|
|
|
6759
7742
|
briefHash: z4.string().min(1).nullable(),
|
|
6760
7743
|
objectivesVersion: z4.string().min(1).nullable(),
|
|
6761
7744
|
rulingOrdinal: epochNumber,
|
|
7745
|
+
manifestVersion: z4.literal(2).optional(),
|
|
7746
|
+
pauseBoundRuling: z4.object({
|
|
7747
|
+
rulingId: z4.string().min(1),
|
|
7748
|
+
pauseId: z4.string().min(1),
|
|
7749
|
+
contentDigest: z4.string().min(1)
|
|
7750
|
+
}).strict().nullable().optional(),
|
|
6762
7751
|
policyDigest: z4.string().min(1),
|
|
6763
7752
|
recordedAt: isoTimestamp
|
|
6764
7753
|
}).strict();
|
|
@@ -6780,7 +7769,11 @@ var LoopStateRecordSchema = z4.object({
|
|
|
6780
7769
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6781
7770
|
repeatMemory: z4.object({
|
|
6782
7771
|
blockingFindings: z4.array(z4.string()),
|
|
6783
|
-
lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
|
|
7772
|
+
lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
|
|
7773
|
+
}).strict().optional(),
|
|
7774
|
+
developerHandoff: z4.object({
|
|
7775
|
+
findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
|
|
7776
|
+
failingChecks: z4.array(z4.string().min(1))
|
|
6784
7777
|
}).strict().optional(),
|
|
6785
7778
|
publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
6786
7779
|
taskStartedAt: isoTimestamp.optional(),
|
|
@@ -6835,37 +7828,338 @@ var ResolutionRecordSchema = z4.object({
|
|
|
6835
7828
|
authenticatedFrom: z4.string().min(1),
|
|
6836
7829
|
consumedAt: isoTimestamp
|
|
6837
7830
|
}).strict();
|
|
7831
|
+
var ExecutionRoundMirrorRecordSchema = z4.object({
|
|
7832
|
+
version: z4.literal(1),
|
|
7833
|
+
kind: z4.literal("execution_round"),
|
|
7834
|
+
task: taskId,
|
|
7835
|
+
repository: z4.string().min(1),
|
|
7836
|
+
threadId: z4.string().min(1),
|
|
7837
|
+
checkpointId: z4.string().min(1),
|
|
7838
|
+
round: z4.number().int().positive(),
|
|
7839
|
+
recordedAt: isoTimestamp
|
|
7840
|
+
}).strict();
|
|
6838
7841
|
// ../../packages/aeg-core/src/control-store/local.ts
|
|
6839
7842
|
var CONTROL_AREA_DIRNAME = "control";
|
|
6840
7843
|
// src/lib/config.ts
|
|
6841
7844
|
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
6842
7845
|
import { promisify as promisify4 } from "node:util";
|
|
6843
|
-
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
7846
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
6844
7847
|
import { homedir } from "node:os";
|
|
6845
|
-
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
6846
|
-
import { z as
|
|
7848
|
+
import { basename as basename3, dirname, isAbsolute, join, resolve } from "node:path";
|
|
7849
|
+
import { z as z6 } from "zod";
|
|
7850
|
+
|
|
7851
|
+
// src/checks/contract.ts
|
|
7852
|
+
var CHECK_SCHEMA_VERSION = 1;
|
|
7853
|
+
function emitCheckError(error) {
|
|
7854
|
+
process.stderr.write(`${JSON.stringify(error)}
|
|
7855
|
+
`);
|
|
7856
|
+
}
|
|
6847
7857
|
|
|
6848
7858
|
// src/lib/agent-vendors.ts
|
|
6849
7859
|
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
6850
7860
|
|
|
7861
|
+
// src/lib/prose-rules-config.ts
|
|
7862
|
+
import safeRegex from "safe-regex2";
|
|
7863
|
+
import { z as z5 } from "zod";
|
|
7864
|
+
var SEVERITIES = ["error", "warning"];
|
|
7865
|
+
var OVERRIDE_KEYS = ["scopes", "severity", "exempt"];
|
|
7866
|
+
var FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
|
|
7867
|
+
var CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
|
|
7868
|
+
var DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
|
|
7869
|
+
function isPlainObject3(value) {
|
|
7870
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7871
|
+
}
|
|
7872
|
+
function outsideRepositoryReason(entry) {
|
|
7873
|
+
if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
|
|
7874
|
+
return "must be a repository-relative path, not an absolute one";
|
|
7875
|
+
if (entry.split(/[\\/]/).includes(".."))
|
|
7876
|
+
return "must stay inside the repository — no `..` segment";
|
|
7877
|
+
return null;
|
|
7878
|
+
}
|
|
7879
|
+
var RepoRelativePathSchema = z5.string().min(1).superRefine((entry, ctx) => {
|
|
7880
|
+
const reason = outsideRepositoryReason(entry);
|
|
7881
|
+
if (reason)
|
|
7882
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, message: reason });
|
|
7883
|
+
});
|
|
7884
|
+
function pathListIssues(value, path, issues) {
|
|
7885
|
+
if (!Array.isArray(value)) {
|
|
7886
|
+
issues.push({ path, message: "must be a list of repository-relative paths" });
|
|
7887
|
+
return;
|
|
7888
|
+
}
|
|
7889
|
+
value.forEach((entry, index) => {
|
|
7890
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
7891
|
+
issues.push({ path: [...path, index], message: "must be a non-empty repository-relative path" });
|
|
7892
|
+
return;
|
|
7893
|
+
}
|
|
7894
|
+
const reason = outsideRepositoryReason(entry);
|
|
7895
|
+
if (reason)
|
|
7896
|
+
issues.push({ path: [...path, index], message: reason });
|
|
7897
|
+
});
|
|
7898
|
+
}
|
|
7899
|
+
function scopeListIssues(value, path, allowed, issues) {
|
|
7900
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
7901
|
+
issues.push({ path, message: "must name at least one scope" });
|
|
7902
|
+
return null;
|
|
7903
|
+
}
|
|
7904
|
+
const scopes = [];
|
|
7905
|
+
value.forEach((scope, index) => {
|
|
7906
|
+
if (typeof scope !== "string" || !CONFIGURABLE_PROSE_SCOPES.includes(scope)) {
|
|
7907
|
+
issues.push({
|
|
7908
|
+
path: [...path, index],
|
|
7909
|
+
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(", ")}`
|
|
7910
|
+
});
|
|
7911
|
+
return;
|
|
7912
|
+
}
|
|
7913
|
+
if (!allowed.includes(scope)) {
|
|
7914
|
+
issues.push({
|
|
7915
|
+
path: [...path, index],
|
|
7916
|
+
message: `scope "${scope}" is not one this rule can run in — it can run in: ${allowed.join(", ")}`
|
|
7917
|
+
});
|
|
7918
|
+
return;
|
|
7919
|
+
}
|
|
7920
|
+
scopes.push(scope);
|
|
7921
|
+
});
|
|
7922
|
+
return scopes;
|
|
7923
|
+
}
|
|
7924
|
+
function severityIssues(value, path, scopes, issues) {
|
|
7925
|
+
if (typeof value === "string") {
|
|
7926
|
+
if (!SEVERITIES.includes(value)) {
|
|
7927
|
+
issues.push({ path, message: `unknown severity ${JSON.stringify(value)} — use "error" or "warning"` });
|
|
7928
|
+
}
|
|
7929
|
+
return;
|
|
7930
|
+
}
|
|
7931
|
+
if (!isPlainObject3(value)) {
|
|
7932
|
+
issues.push({ path, message: 'must be "error", "warning", or a map from scope to one of them' });
|
|
7933
|
+
return;
|
|
7934
|
+
}
|
|
7935
|
+
for (const [scope, severity] of Object.entries(value)) {
|
|
7936
|
+
if (!scopes.includes(scope)) {
|
|
7937
|
+
issues.push({ path: [...path, scope], message: `names scope "${scope}", which this rule's scopes do not cover` });
|
|
7938
|
+
}
|
|
7939
|
+
if (typeof severity !== "string" || !SEVERITIES.includes(severity)) {
|
|
7940
|
+
issues.push({
|
|
7941
|
+
path: [...path, scope],
|
|
7942
|
+
message: `unknown severity ${JSON.stringify(severity)} — use "error" or "warning"`
|
|
7943
|
+
});
|
|
7944
|
+
}
|
|
7945
|
+
}
|
|
7946
|
+
}
|
|
7947
|
+
function patternIssues(source, flags, path, issues) {
|
|
7948
|
+
if (typeof source !== "string" || source.length === 0) {
|
|
7949
|
+
issues.push({ path, message: "must be a non-empty regular expression" });
|
|
7950
|
+
return;
|
|
7951
|
+
}
|
|
7952
|
+
if (source.length > CONFIGURED_PATTERN_MAX_LENGTH) {
|
|
7953
|
+
issues.push({
|
|
7954
|
+
path,
|
|
7955
|
+
message: `is ${source.length} characters, over the ${CONFIGURED_PATTERN_MAX_LENGTH}-character limit for a configured pattern`
|
|
7956
|
+
});
|
|
7957
|
+
return;
|
|
7958
|
+
}
|
|
7959
|
+
try {
|
|
7960
|
+
new RegExp(source, flags);
|
|
7961
|
+
} catch (err) {
|
|
7962
|
+
issues.push({ path, message: `does not compile: ${err.message}` });
|
|
7963
|
+
return;
|
|
7964
|
+
}
|
|
7965
|
+
if (!safeRegex(source, { limit: Number.MAX_SAFE_INTEGER })) {
|
|
7966
|
+
issues.push({
|
|
7967
|
+
path,
|
|
7968
|
+
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."
|
|
7969
|
+
});
|
|
7970
|
+
}
|
|
7971
|
+
}
|
|
7972
|
+
function flagIssues(value, path, issues) {
|
|
7973
|
+
if (value === undefined)
|
|
7974
|
+
return "";
|
|
7975
|
+
if (typeof value !== "string") {
|
|
7976
|
+
issues.push({ path, message: 'must be a string of flags, e.g. "i"' });
|
|
7977
|
+
return "";
|
|
7978
|
+
}
|
|
7979
|
+
const seen = new Set;
|
|
7980
|
+
for (const flag of value) {
|
|
7981
|
+
if (!CONFIGURED_PROSE_FLAGS.includes(flag)) {
|
|
7982
|
+
issues.push({
|
|
7983
|
+
path,
|
|
7984
|
+
message: `unknown flag ${JSON.stringify(flag)} — only ${CONFIGURED_PROSE_FLAGS.map((f) => `"${f}"`).join(" and ")} are allowed`
|
|
7985
|
+
});
|
|
7986
|
+
return "";
|
|
7987
|
+
}
|
|
7988
|
+
if (seen.has(flag)) {
|
|
7989
|
+
issues.push({ path, message: `repeats the flag "${flag}"` });
|
|
7990
|
+
return "";
|
|
7991
|
+
}
|
|
7992
|
+
seen.add(flag);
|
|
7993
|
+
}
|
|
7994
|
+
return value;
|
|
7995
|
+
}
|
|
7996
|
+
function defaultsIssues(value, issues) {
|
|
7997
|
+
const base = ["defaults"];
|
|
7998
|
+
if (!isPlainObject3(value)) {
|
|
7999
|
+
issues.push({ path: base, message: 'must map a default rule id to "off" or an override' });
|
|
8000
|
+
return;
|
|
8001
|
+
}
|
|
8002
|
+
for (const [id, override] of Object.entries(value)) {
|
|
8003
|
+
const path = [...base, id];
|
|
8004
|
+
const rule = CONFIGURABLE_DEFAULT_RULES.find((candidate) => candidate.id === id);
|
|
8005
|
+
if (!rule) {
|
|
8006
|
+
issues.push({
|
|
8007
|
+
path,
|
|
8008
|
+
message: `unknown default rule id "${id}" — \`vinaya check --plan\` lists the rules each prose check runs`
|
|
8009
|
+
});
|
|
8010
|
+
continue;
|
|
8011
|
+
}
|
|
8012
|
+
if (override === "off")
|
|
8013
|
+
continue;
|
|
8014
|
+
if (!isPlainObject3(override)) {
|
|
8015
|
+
issues.push({ path, message: 'must be "off" or an object with any of scopes, severity, exempt' });
|
|
8016
|
+
continue;
|
|
8017
|
+
}
|
|
8018
|
+
for (const key of Object.keys(override)) {
|
|
8019
|
+
if (OVERRIDE_KEYS.includes(key))
|
|
8020
|
+
continue;
|
|
8021
|
+
issues.push({
|
|
8022
|
+
path: [...path, key],
|
|
8023
|
+
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`
|
|
8024
|
+
});
|
|
8025
|
+
}
|
|
8026
|
+
const scopes = override.scopes === undefined ? [...rule.scopes] : scopeListIssues(override.scopes, [...path, "scopes"], allowedScopesFor(rule), issues);
|
|
8027
|
+
if (override.severity !== undefined && scopes)
|
|
8028
|
+
severityIssues(override.severity, [...path, "severity"], scopes, issues);
|
|
8029
|
+
if (override.exempt !== undefined)
|
|
8030
|
+
pathListIssues(override.exempt, [...path, "exempt"], issues);
|
|
8031
|
+
}
|
|
8032
|
+
}
|
|
8033
|
+
function customIssues(value, issues) {
|
|
8034
|
+
if (!Array.isArray(value)) {
|
|
8035
|
+
issues.push({ path: ["custom"], message: "must be a list of rules" });
|
|
8036
|
+
return;
|
|
8037
|
+
}
|
|
8038
|
+
const ids = new Set;
|
|
8039
|
+
value.forEach((rule, index) => {
|
|
8040
|
+
const path = ["custom", index];
|
|
8041
|
+
if (!isPlainObject3(rule)) {
|
|
8042
|
+
issues.push({ path, message: "must be a rule object" });
|
|
8043
|
+
return;
|
|
8044
|
+
}
|
|
8045
|
+
for (const key of Object.keys(rule)) {
|
|
8046
|
+
if (!CUSTOM_KEYS.includes(key)) {
|
|
8047
|
+
issues.push({ path: [...path, key], message: `unknown key "${key}" — a rule takes ${CUSTOM_KEYS.join(", ")}` });
|
|
8048
|
+
}
|
|
8049
|
+
}
|
|
8050
|
+
if (typeof rule.id !== "string" || rule.id.length === 0) {
|
|
8051
|
+
issues.push({ path: [...path, "id"], message: "a custom rule needs an id" });
|
|
8052
|
+
} else if (DEFAULT_IDS.has(rule.id)) {
|
|
8053
|
+
issues.push({
|
|
8054
|
+
path: [...path, "id"],
|
|
8055
|
+
message: `"${rule.id}" is a default rule id — a custom rule needs its own id; retune the default under proseGates.rules.defaults instead`
|
|
8056
|
+
});
|
|
8057
|
+
} else if (ids.has(rule.id)) {
|
|
8058
|
+
issues.push({ path: [...path, "id"], message: `"${rule.id}" is used by an earlier custom rule` });
|
|
8059
|
+
} else {
|
|
8060
|
+
ids.add(rule.id);
|
|
8061
|
+
}
|
|
8062
|
+
if (typeof rule.means !== "string" || rule.means.trim().length === 0) {
|
|
8063
|
+
issues.push({ path: [...path, "means"], message: "a custom rule needs a message (`means`)" });
|
|
8064
|
+
}
|
|
8065
|
+
let scopes = null;
|
|
8066
|
+
if (rule.scopes === undefined) {
|
|
8067
|
+
issues.push({ path: [...path, "scopes"], message: "a custom rule needs at least one scope (`scopes`)" });
|
|
8068
|
+
} else {
|
|
8069
|
+
scopes = scopeListIssues(rule.scopes, [...path, "scopes"], CONFIGURABLE_PROSE_SCOPES, issues);
|
|
8070
|
+
}
|
|
8071
|
+
if (scopes && new Set(scopes.map(groupOfScope)).size > 1) {
|
|
8072
|
+
issues.push({
|
|
8073
|
+
path: [...path, "scopes"],
|
|
8074
|
+
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'
|
|
8075
|
+
});
|
|
8076
|
+
}
|
|
8077
|
+
const flags = flagIssues(rule.flags, [...path, "flags"], issues);
|
|
8078
|
+
if (rule.pattern === undefined && rule.patterns === undefined) {
|
|
8079
|
+
issues.push({
|
|
8080
|
+
path: [...path, "pattern"],
|
|
8081
|
+
message: "a custom rule needs a `pattern` or a per-scope `patterns` map"
|
|
8082
|
+
});
|
|
8083
|
+
}
|
|
8084
|
+
if (rule.pattern !== undefined)
|
|
8085
|
+
patternIssues(rule.pattern, flags, [...path, "pattern"], issues);
|
|
8086
|
+
if (rule.patterns !== undefined) {
|
|
8087
|
+
if (!isPlainObject3(rule.patterns)) {
|
|
8088
|
+
issues.push({ path: [...path, "patterns"], message: "must map a scope to a regular expression" });
|
|
8089
|
+
} else {
|
|
8090
|
+
for (const [scope, source] of Object.entries(rule.patterns)) {
|
|
8091
|
+
if (scopes && !scopes.includes(scope)) {
|
|
8092
|
+
issues.push({
|
|
8093
|
+
path: [...path, "patterns", scope],
|
|
8094
|
+
message: `names scope "${scope}", which this rule's scopes do not cover`
|
|
8095
|
+
});
|
|
8096
|
+
continue;
|
|
8097
|
+
}
|
|
8098
|
+
patternIssues(source, flags, [...path, "patterns", scope], issues);
|
|
8099
|
+
}
|
|
8100
|
+
if (rule.pattern === undefined && scopes) {
|
|
8101
|
+
for (const scope of scopes) {
|
|
8102
|
+
if (!(scope in rule.patterns)) {
|
|
8103
|
+
issues.push({
|
|
8104
|
+
path: [...path, "patterns"],
|
|
8105
|
+
message: `has no pattern for scope "${scope}" — add one, or a \`pattern\` every other scope uses`
|
|
8106
|
+
});
|
|
8107
|
+
}
|
|
8108
|
+
}
|
|
8109
|
+
}
|
|
8110
|
+
}
|
|
8111
|
+
}
|
|
8112
|
+
if (rule.severity !== undefined && scopes)
|
|
8113
|
+
severityIssues(rule.severity, [...path, "severity"], scopes, issues);
|
|
8114
|
+
if (rule.exempt !== undefined)
|
|
8115
|
+
pathListIssues(rule.exempt, [...path, "exempt"], issues);
|
|
8116
|
+
});
|
|
8117
|
+
}
|
|
8118
|
+
function proseRulesIssues(value) {
|
|
8119
|
+
const issues = [];
|
|
8120
|
+
if (!isPlainObject3(value))
|
|
8121
|
+
return [{ path: [], message: "must be an object with any of exempt, defaults, custom" }];
|
|
8122
|
+
for (const key of Object.keys(value)) {
|
|
8123
|
+
if (!["exempt", "defaults", "custom"].includes(key)) {
|
|
8124
|
+
issues.push({ path: [key], message: `unknown key "${key}" — proseGates.rules takes exempt, defaults and custom` });
|
|
8125
|
+
}
|
|
8126
|
+
}
|
|
8127
|
+
if (value.exempt !== undefined)
|
|
8128
|
+
pathListIssues(value.exempt, ["exempt"], issues);
|
|
8129
|
+
if (value.defaults !== undefined)
|
|
8130
|
+
defaultsIssues(value.defaults, issues);
|
|
8131
|
+
if (value.custom !== undefined)
|
|
8132
|
+
customIssues(value.custom, issues);
|
|
8133
|
+
return issues;
|
|
8134
|
+
}
|
|
8135
|
+
var ProseRulesSchema = z5.unknown().superRefine((value, ctx) => {
|
|
8136
|
+
for (const issue of proseRulesIssues(value)) {
|
|
8137
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: issue.path, message: issue.message });
|
|
8138
|
+
}
|
|
8139
|
+
}).transform((value) => value);
|
|
8140
|
+
var PublishedProseSchema = z5.object({
|
|
8141
|
+
allow: z5.array(z5.string().min(1)).optional()
|
|
8142
|
+
}).strict();
|
|
8143
|
+
|
|
6851
8144
|
// src/lib/config.ts
|
|
6852
|
-
var EnvEntrySchema =
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
8145
|
+
var EnvEntrySchema = z6.union([
|
|
8146
|
+
z6.literal(true),
|
|
8147
|
+
z6.object({ optional: z6.literal(true) }),
|
|
8148
|
+
z6.object({ anyOf: z6.array(z6.string()).min(2) }),
|
|
8149
|
+
z6.string()
|
|
6857
8150
|
]);
|
|
6858
|
-
var CheckEntrySchema =
|
|
6859
|
-
run:
|
|
6860
|
-
scope:
|
|
6861
|
-
include:
|
|
6862
|
-
args:
|
|
6863
|
-
timeoutMs:
|
|
6864
|
-
env:
|
|
6865
|
-
requiresOpenPr:
|
|
6866
|
-
ownWorkflow:
|
|
6867
|
-
principalOwed:
|
|
6868
|
-
validates:
|
|
8151
|
+
var CheckEntrySchema = z6.object({
|
|
8152
|
+
run: z6.string(),
|
|
8153
|
+
scope: z6.enum(["diff", "full"]),
|
|
8154
|
+
include: z6.array(z6.string()).optional(),
|
|
8155
|
+
args: z6.array(z6.string()).optional(),
|
|
8156
|
+
timeoutMs: z6.number().optional(),
|
|
8157
|
+
env: z6.record(z6.string(), EnvEntrySchema).optional(),
|
|
8158
|
+
requiresOpenPr: z6.boolean().optional(),
|
|
8159
|
+
ownWorkflow: z6.boolean().optional(),
|
|
8160
|
+
principalOwed: z6.literal(true).optional(),
|
|
8161
|
+
validates: z6.enum(["body", "issue"]).optional(),
|
|
8162
|
+
advisory: z6.literal(true).optional()
|
|
6869
8163
|
}).superRefine((entry, ctx) => {
|
|
6870
8164
|
if (!entry.env)
|
|
6871
8165
|
return;
|
|
@@ -6875,22 +8169,22 @@ var CheckEntrySchema = z5.object({
|
|
|
6875
8169
|
const members = value.anyOf;
|
|
6876
8170
|
if (new Set(members).size !== members.length) {
|
|
6877
8171
|
ctx.addIssue({
|
|
6878
|
-
code:
|
|
8172
|
+
code: z6.ZodIssueCode.custom,
|
|
6879
8173
|
message: `env.${key}.anyOf has duplicate members`,
|
|
6880
8174
|
path: ["env", key, "anyOf"]
|
|
6881
8175
|
});
|
|
6882
8176
|
}
|
|
6883
8177
|
if (!members.includes(key)) {
|
|
6884
8178
|
ctx.addIssue({
|
|
6885
|
-
code:
|
|
8179
|
+
code: z6.ZodIssueCode.custom,
|
|
6886
8180
|
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
6887
8181
|
path: ["env", key, "anyOf"]
|
|
6888
8182
|
});
|
|
6889
8183
|
}
|
|
6890
8184
|
}
|
|
6891
8185
|
});
|
|
6892
|
-
var RoleEntrySchema =
|
|
6893
|
-
contract:
|
|
8186
|
+
var RoleEntrySchema = z6.object({
|
|
8187
|
+
contract: z6.string().refine((p) => p.includes("/"), {
|
|
6894
8188
|
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
6895
8189
|
})
|
|
6896
8190
|
});
|
|
@@ -6914,17 +8208,17 @@ var BRIEF_BUILTINS = [
|
|
|
6914
8208
|
"briefSections",
|
|
6915
8209
|
"milestoneShape"
|
|
6916
8210
|
];
|
|
6917
|
-
var BriefSectionSchema =
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
8211
|
+
var BriefSectionSchema = z6.union([
|
|
8212
|
+
z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
|
|
8213
|
+
z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
|
|
8214
|
+
z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
|
|
8215
|
+
z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
|
|
6922
8216
|
]);
|
|
6923
|
-
var BriefSchemaSchema =
|
|
6924
|
-
pr:
|
|
6925
|
-
issue:
|
|
6926
|
-
milestone:
|
|
6927
|
-
ack:
|
|
8217
|
+
var BriefSchemaSchema = z6.object({
|
|
8218
|
+
pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8219
|
+
issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8220
|
+
milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8221
|
+
ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
|
|
6928
8222
|
});
|
|
6929
8223
|
function isSafeRepoRelPath(p) {
|
|
6930
8224
|
if (p.length === 0)
|
|
@@ -6933,7 +8227,7 @@ function isSafeRepoRelPath(p) {
|
|
|
6933
8227
|
return false;
|
|
6934
8228
|
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
6935
8229
|
}
|
|
6936
|
-
var SafeRepoRelPath =
|
|
8230
|
+
var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
|
|
6937
8231
|
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
6938
8232
|
});
|
|
6939
8233
|
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
@@ -6943,22 +8237,22 @@ function isCanonicalHookBlockPath(p) {
|
|
|
6943
8237
|
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
6944
8238
|
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
6945
8239
|
});
|
|
6946
|
-
var ManagedBlockRecordSchema =
|
|
8240
|
+
var ManagedBlockRecordSchema = z6.object({
|
|
6947
8241
|
path: ManagedHookBlockPath,
|
|
6948
|
-
marker:
|
|
6949
|
-
comment:
|
|
8242
|
+
marker: z6.string(),
|
|
8243
|
+
comment: z6.enum(["hash", "html"])
|
|
6950
8244
|
});
|
|
6951
|
-
var ManagedManifestSchema =
|
|
6952
|
-
version:
|
|
6953
|
-
files:
|
|
6954
|
-
blocks:
|
|
6955
|
-
labels:
|
|
6956
|
-
agents:
|
|
8245
|
+
var ManagedManifestSchema = z6.object({
|
|
8246
|
+
version: z6.number().int().positive(),
|
|
8247
|
+
files: z6.array(SafeRepoRelPath),
|
|
8248
|
+
blocks: z6.array(ManagedBlockRecordSchema),
|
|
8249
|
+
labels: z6.array(z6.string()),
|
|
8250
|
+
agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
|
|
6957
8251
|
});
|
|
6958
|
-
var ProjectEntrySchema =
|
|
6959
|
-
name:
|
|
6960
|
-
description:
|
|
6961
|
-
path:
|
|
8252
|
+
var ProjectEntrySchema = z6.object({
|
|
8253
|
+
name: z6.string().min(1),
|
|
8254
|
+
description: z6.string().min(1).optional(),
|
|
8255
|
+
path: z6.string().min(1).optional()
|
|
6962
8256
|
});
|
|
6963
8257
|
function parseTokensCollectDeclaration(value) {
|
|
6964
8258
|
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
@@ -6969,90 +8263,101 @@ function parseTokensCollectDeclaration(value) {
|
|
|
6969
8263
|
return null;
|
|
6970
8264
|
return { interpreter, script };
|
|
6971
8265
|
}
|
|
6972
|
-
var
|
|
6973
|
-
rings:
|
|
6974
|
-
ring1_forgeWriteInterception:
|
|
6975
|
-
ring2_asyncAudits:
|
|
8266
|
+
var VinayaConfigObjectSchema = z6.object({
|
|
8267
|
+
rings: z6.object({
|
|
8268
|
+
ring1_forgeWriteInterception: z6.boolean(),
|
|
8269
|
+
ring2_asyncAudits: z6.boolean()
|
|
6976
8270
|
}).optional(),
|
|
6977
|
-
checks:
|
|
6978
|
-
roles:
|
|
8271
|
+
checks: z6.record(z6.string(), CheckEntrySchema).optional(),
|
|
8272
|
+
roles: z6.record(z6.string(), RoleEntrySchema).optional(),
|
|
6979
8273
|
briefSchema: BriefSchemaSchema.optional(),
|
|
6980
8274
|
managed: ManagedManifestSchema.optional(),
|
|
6981
|
-
principals:
|
|
6982
|
-
releaseActor:
|
|
6983
|
-
ci:
|
|
6984
|
-
tokens:
|
|
6985
|
-
collect:
|
|
8275
|
+
principals: z6.array(z6.string()).min(1).optional(),
|
|
8276
|
+
releaseActor: z6.string().min(1).optional(),
|
|
8277
|
+
ci: z6.object({ setup: z6.string().min(1) }).optional(),
|
|
8278
|
+
tokens: z6.object({
|
|
8279
|
+
collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
6986
8280
|
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
6987
8281
|
})
|
|
6988
8282
|
}).optional(),
|
|
6989
|
-
blastRadius:
|
|
6990
|
-
proseGates:
|
|
6991
|
-
doctrineRoot:
|
|
6992
|
-
readerFacingPrefix:
|
|
6993
|
-
readerFacingSuffix:
|
|
6994
|
-
legacySlugDir:
|
|
6995
|
-
sourceComments:
|
|
6996
|
-
globs:
|
|
6997
|
-
allowlist:
|
|
6998
|
-
severity:
|
|
8283
|
+
blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
|
|
8284
|
+
proseGates: z6.object({
|
|
8285
|
+
doctrineRoot: z6.string().min(1).optional(),
|
|
8286
|
+
readerFacingPrefix: z6.string().min(1).optional(),
|
|
8287
|
+
readerFacingSuffix: z6.string().min(1).optional(),
|
|
8288
|
+
legacySlugDir: z6.string().min(1).optional(),
|
|
8289
|
+
sourceComments: z6.object({
|
|
8290
|
+
globs: z6.array(z6.string().min(1)).optional(),
|
|
8291
|
+
allowlist: z6.array(z6.string().min(1)).optional(),
|
|
8292
|
+
severity: z6.enum(["warning", "error"]).optional()
|
|
6999
8293
|
}).optional(),
|
|
7000
|
-
specGrandfather:
|
|
7001
|
-
specPaths:
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
})).optional()
|
|
8294
|
+
specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
|
|
8295
|
+
specPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8296
|
+
productPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8297
|
+
published: PublishedProseSchema.optional(),
|
|
8298
|
+
rules: ProseRulesSchema.optional()
|
|
7006
8299
|
}).optional(),
|
|
7007
|
-
projects:
|
|
7008
|
-
dispatch:
|
|
7009
|
-
timeoutMs:
|
|
7010
|
-
|
|
7011
|
-
|
|
8300
|
+
projects: z6.array(ProjectEntrySchema).optional(),
|
|
8301
|
+
dispatch: z6.object({
|
|
8302
|
+
timeoutMs: z6.number().int().positive().optional(),
|
|
8303
|
+
reviewerTimeoutMs: z6.number().int().positive().optional(),
|
|
8304
|
+
killGraceMs: z6.number().int().positive().optional(),
|
|
8305
|
+
agent: z6.enum(["claude", "codex"]).optional()
|
|
7012
8306
|
}).optional(),
|
|
7013
|
-
reviewPolicy:
|
|
7014
|
-
codeReviewThreshold:
|
|
7015
|
-
securityThreshold:
|
|
7016
|
-
maxRounds:
|
|
7017
|
-
maxTaskMinutes:
|
|
8307
|
+
reviewPolicy: z6.object({
|
|
8308
|
+
codeReviewThreshold: z6.string().min(1).optional(),
|
|
8309
|
+
securityThreshold: z6.string().min(1).optional(),
|
|
8310
|
+
maxRounds: z6.number().optional(),
|
|
8311
|
+
maxTaskMinutes: z6.number().optional(),
|
|
8312
|
+
readyPushTimeoutMinutes: z6.number().optional()
|
|
7018
8313
|
}).optional(),
|
|
7019
|
-
securityScan:
|
|
7020
|
-
command:
|
|
8314
|
+
securityScan: z6.object({
|
|
8315
|
+
command: z6.array(z6.string().min(1)).min(1)
|
|
7021
8316
|
}).optional(),
|
|
7022
|
-
gateCutovers:
|
|
7023
|
-
objectivesSinceIssue:
|
|
7024
|
-
briefSectionsSinceIssue:
|
|
7025
|
-
documentationSinceIssue:
|
|
7026
|
-
briefRulesSincePr:
|
|
7027
|
-
agentBoxesRefusedSincePr:
|
|
8317
|
+
gateCutovers: z6.object({
|
|
8318
|
+
objectivesSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8319
|
+
briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8320
|
+
documentationSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8321
|
+
briefRulesSincePr: z6.number().int().nonnegative().optional(),
|
|
8322
|
+
agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
|
|
7028
8323
|
}).optional(),
|
|
7029
|
-
planning:
|
|
7030
|
-
collisionThreshold:
|
|
8324
|
+
planning: z6.object({
|
|
8325
|
+
collisionThreshold: z6.number().int().nonnegative().optional()
|
|
7031
8326
|
}).optional(),
|
|
7032
|
-
prePush:
|
|
7033
|
-
alwaysRun:
|
|
8327
|
+
prePush: z6.object({
|
|
8328
|
+
alwaysRun: z6.array(z6.string()).optional(),
|
|
8329
|
+
readyTests: z6.object({
|
|
8330
|
+
mode: z6.literal("ci"),
|
|
8331
|
+
workflow: z6.literal(".github/workflows/ci.yml"),
|
|
8332
|
+
check: z6.literal("Vinaya CI")
|
|
8333
|
+
}).strict().optional(),
|
|
8334
|
+
requiredCi: z6.object({
|
|
8335
|
+
workflow: z6.literal(".github/workflows/ci.yml"),
|
|
8336
|
+
check: z6.literal("Vinaya CI")
|
|
8337
|
+
}).strict().optional()
|
|
7034
8338
|
}).optional(),
|
|
7035
|
-
report:
|
|
7036
|
-
commandTimeoutMs:
|
|
8339
|
+
report: z6.object({
|
|
8340
|
+
commandTimeoutMs: z6.number().int().positive().optional()
|
|
7037
8341
|
}).superRefine((report, ctx) => {
|
|
7038
8342
|
const commandTimeoutMs = report.commandTimeoutMs;
|
|
7039
8343
|
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
7040
8344
|
ctx.addIssue({
|
|
7041
|
-
code:
|
|
8345
|
+
code: z6.ZodIssueCode.custom,
|
|
7042
8346
|
path: ["commandTimeoutMs"],
|
|
7043
8347
|
message: "must be at most 3600000 (1 hour)"
|
|
7044
8348
|
});
|
|
7045
8349
|
}
|
|
7046
8350
|
}).optional(),
|
|
7047
|
-
logPublish:
|
|
8351
|
+
logPublish: z6.unknown().refine((v) => v === undefined, {
|
|
7048
8352
|
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
7049
8353
|
}),
|
|
7050
|
-
runtimeDir:
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
8354
|
+
runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
8355
|
+
runner: z6.enum(["standalone", "atta-engine"]).optional(),
|
|
8356
|
+
logs: z6.object({
|
|
8357
|
+
folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
8358
|
+
url: z6.string().url().optional(),
|
|
8359
|
+
headers: z6.record(z6.string()).optional(),
|
|
8360
|
+
readHeaders: z6.record(z6.string()).optional(),
|
|
7056
8361
|
events: CustomEventDeclarationsSchema.optional()
|
|
7057
8362
|
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
7058
8363
|
message: "logs: set at most one of folder/url"
|
|
@@ -7060,8 +8365,33 @@ var VinayaConfigSchema = z5.object({
|
|
|
7060
8365
|
message: "logs: headers requires url"
|
|
7061
8366
|
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
7062
8367
|
message: "logs: readHeaders requires url"
|
|
7063
|
-
}).optional()
|
|
8368
|
+
}).or(z6.literal(false)).optional(),
|
|
8369
|
+
decisionRecords: z6.object({
|
|
8370
|
+
path: RepoRelativePathSchema
|
|
8371
|
+
}).strict().optional()
|
|
8372
|
+
});
|
|
8373
|
+
function decisionRecordsPathIssue(path, doctrineRoot) {
|
|
8374
|
+
const reason = outsideRepositoryReason(path);
|
|
8375
|
+
if (reason)
|
|
8376
|
+
return reason;
|
|
8377
|
+
const folder = normalizeSpecPath(path);
|
|
8378
|
+
if (folder === "" || folder === ".")
|
|
8379
|
+
return "must name a folder, not the repository root";
|
|
8380
|
+
const root = normalizeSpecPath(doctrineRoot ?? "aeg-root");
|
|
8381
|
+
if (folder === root || folder.startsWith(`${root}/`)) {
|
|
8382
|
+
return `must be outside the doctrine tree "${root}" — decision records belong to this repository, not to the doctrine it ships`;
|
|
8383
|
+
}
|
|
8384
|
+
return null;
|
|
8385
|
+
}
|
|
8386
|
+
var VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
|
|
8387
|
+
const path = config.decisionRecords?.path;
|
|
8388
|
+
if (path === undefined || outsideRepositoryReason(path))
|
|
8389
|
+
return;
|
|
8390
|
+
const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
|
|
8391
|
+
if (issue)
|
|
8392
|
+
ctx.addIssue({ code: z6.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
|
|
7064
8393
|
});
|
|
8394
|
+
var VinayaConfigShape = VinayaConfigObjectSchema.shape;
|
|
7065
8395
|
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
7066
8396
|
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
7067
8397
|
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
@@ -7142,9 +8472,6 @@ function stripGlobalOnlyKeys(config, path) {
|
|
|
7142
8472
|
}
|
|
7143
8473
|
return result;
|
|
7144
8474
|
}
|
|
7145
|
-
function resolvePrincipalAllowlist(config) {
|
|
7146
|
-
return config?.principals ?? PRINCIPAL_ALLOWLIST;
|
|
7147
|
-
}
|
|
7148
8475
|
function resolveReleaseActor(config) {
|
|
7149
8476
|
return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
|
|
7150
8477
|
}
|
|
@@ -7168,13 +8495,19 @@ function resolveReviewPolicy(config) {
|
|
|
7168
8495
|
if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
|
|
7169
8496
|
throw new Error(`vinaya.config.json: reviewPolicy.maxTaskMinutes "${maxTaskMinutes}" is not a non-negative integer (0 turns the budget off) — fix the config, this never falls back to a default.`);
|
|
7170
8497
|
}
|
|
8498
|
+
const readyPushTimeoutMinutes = raw.readyPushTimeoutMinutes ?? DEFAULT_READY_PUSH_TIMEOUT_MINUTES;
|
|
8499
|
+
if (!Number.isInteger(readyPushTimeoutMinutes) || readyPushTimeoutMinutes < 1) {
|
|
8500
|
+
throw new Error(`vinaya.config.json: reviewPolicy.readyPushTimeoutMinutes "${readyPushTimeoutMinutes}" is not a positive integer — fix the config, this never falls back to a default.`);
|
|
8501
|
+
}
|
|
7171
8502
|
return {
|
|
7172
8503
|
codeReviewThreshold,
|
|
7173
8504
|
securityThreshold,
|
|
7174
8505
|
maxRounds,
|
|
7175
|
-
maxTaskMinutes
|
|
8506
|
+
maxTaskMinutes,
|
|
8507
|
+
readyPushTimeoutMinutes
|
|
7176
8508
|
};
|
|
7177
8509
|
}
|
|
8510
|
+
var emittedLocalOverrideWarnings = new Set;
|
|
7178
8511
|
function resolveGateCutovers(config) {
|
|
7179
8512
|
const raw = config?.gateCutovers;
|
|
7180
8513
|
if (!raw)
|
|
@@ -7280,13 +8613,14 @@ function readTrustAnchorConfigAtRef(ref) {
|
|
|
7280
8613
|
});
|
|
7281
8614
|
return Buffer.from(raw, "utf-8").toString("base64");
|
|
7282
8615
|
}
|
|
8616
|
+
var NO_TRUST_ANCHOR_REPO_MESSAGE = "could not resolve repo identity for the trust-anchor read";
|
|
7283
8617
|
function ghFetchTrustAnchorConfig() {
|
|
7284
8618
|
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
7285
8619
|
if (probeRef)
|
|
7286
8620
|
return readTrustAnchorConfigAtRef(probeRef);
|
|
7287
8621
|
const repo = trustAnchorRepo();
|
|
7288
8622
|
if (!repo)
|
|
7289
|
-
throw new Error(
|
|
8623
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7290
8624
|
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
7291
8625
|
encoding: "utf-8",
|
|
7292
8626
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -7303,7 +8637,7 @@ async function ghFetchTrustAnchorConfigAsync() {
|
|
|
7303
8637
|
}
|
|
7304
8638
|
const repo = await trustAnchorRepoAsync();
|
|
7305
8639
|
if (!repo)
|
|
7306
|
-
throw new Error(
|
|
8640
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7307
8641
|
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
7308
8642
|
return stdout;
|
|
7309
8643
|
}
|
|
@@ -7329,6 +8663,47 @@ function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
|
7329
8663
|
}
|
|
7330
8664
|
return parseTrustAnchorContent(base64);
|
|
7331
8665
|
}
|
|
8666
|
+
class PrincipalsUnresolvedError extends Error {
|
|
8667
|
+
kind;
|
|
8668
|
+
constructor(kind, message) {
|
|
8669
|
+
super(message);
|
|
8670
|
+
this.name = "PrincipalsUnresolvedError";
|
|
8671
|
+
this.kind = kind;
|
|
8672
|
+
}
|
|
8673
|
+
}
|
|
8674
|
+
var PRINCIPALS_FIX = 'add "principals": [...] to vinaya.config.json on the default branch';
|
|
8675
|
+
function fetchFailureReason(err) {
|
|
8676
|
+
const stderr = err?.stderr;
|
|
8677
|
+
const text = (typeof stderr === "string" ? stderr : stderr?.toString() ?? "").trim();
|
|
8678
|
+
return text.split(`
|
|
8679
|
+
`)[0]?.trim() || firstLine(err);
|
|
8680
|
+
}
|
|
8681
|
+
function principalsNotConfigured(why) {
|
|
8682
|
+
return new PrincipalsUnresolvedError("not-configured", `no Principal is configured (${why}) — ${PRINCIPALS_FIX}.`);
|
|
8683
|
+
}
|
|
8684
|
+
function resolveTrustedPrincipals(fetcher = ghFetchTrustAnchorConfig) {
|
|
8685
|
+
let content;
|
|
8686
|
+
try {
|
|
8687
|
+
content = fetcher();
|
|
8688
|
+
} catch (err) {
|
|
8689
|
+
if (err?.message === NO_TRUST_ANCHOR_REPO_MESSAGE) {
|
|
8690
|
+
throw principalsNotConfigured("no repository resolves for the read");
|
|
8691
|
+
}
|
|
8692
|
+
if (isMissingFileError(err))
|
|
8693
|
+
throw principalsNotConfigured("the default branch has no vinaya.config.json");
|
|
8694
|
+
throw new PrincipalsUnresolvedError("read-failed", `could not read "principals" from vinaya.config.json on the default branch: ${fetchFailureReason(err)}`);
|
|
8695
|
+
}
|
|
8696
|
+
const unusable = { why: "" };
|
|
8697
|
+
const config = parseTrustAnchorContent(content, (why) => {
|
|
8698
|
+
unusable.why = why;
|
|
8699
|
+
});
|
|
8700
|
+
if (config === null) {
|
|
8701
|
+
throw principalsNotConfigured(`vinaya.config.json on the default branch ${unusable.why ? `is unusable: ${unusable.why}` : "is empty"}`);
|
|
8702
|
+
}
|
|
8703
|
+
if (!config.principals)
|
|
8704
|
+
throw principalsNotConfigured('vinaya.config.json on the default branch sets no "principals"');
|
|
8705
|
+
return config.principals;
|
|
8706
|
+
}
|
|
7332
8707
|
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
7333
8708
|
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
7334
8709
|
let base64;
|
|
@@ -7368,21 +8743,69 @@ function loadConfig() {
|
|
|
7368
8743
|
const path = configPath();
|
|
7369
8744
|
if (!path)
|
|
7370
8745
|
return null;
|
|
8746
|
+
let text;
|
|
7371
8747
|
try {
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
8748
|
+
text = readFileSync2(path, "utf-8");
|
|
8749
|
+
} catch (err) {
|
|
8750
|
+
reportInvalidConfigOnce(path, `unreadable: ${err.message}`);
|
|
8751
|
+
return null;
|
|
8752
|
+
}
|
|
8753
|
+
let raw;
|
|
8754
|
+
try {
|
|
8755
|
+
raw = JSON.parse(text);
|
|
8756
|
+
} catch (err) {
|
|
8757
|
+
reportInvalidConfigOnce(path, `invalid JSON: ${err.message}`);
|
|
8758
|
+
return null;
|
|
8759
|
+
}
|
|
8760
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8761
|
+
if (!parsed.success) {
|
|
8762
|
+
reportInvalidConfigOnce(path, schemaIssueDetail(parsed.error));
|
|
7375
8763
|
return null;
|
|
7376
8764
|
}
|
|
8765
|
+
return stripGlobalOnlyKeys(parsed.data, path);
|
|
7377
8766
|
}
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
// src/checks/contract.ts
|
|
7381
|
-
var CHECK_SCHEMA_VERSION = 1;
|
|
7382
|
-
function emitCheckError(error) {
|
|
7383
|
-
process.stderr.write(`${JSON.stringify(error)}
|
|
7384
|
-
`);
|
|
8767
|
+
function schemaIssueDetail(error) {
|
|
8768
|
+
return error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
|
|
7385
8769
|
}
|
|
8770
|
+
var emittedInvalidConfigReports = new Set;
|
|
8771
|
+
function reportInvalidConfigOnce(path, detail) {
|
|
8772
|
+
const key = `${path}
|
|
8773
|
+
${detail}`;
|
|
8774
|
+
if (emittedInvalidConfigReports.has(key))
|
|
8775
|
+
return;
|
|
8776
|
+
emittedInvalidConfigReports.add(key);
|
|
8777
|
+
const message = `${path} is not a valid Vinaya configuration (${detail}) — falling back to built-in defaults.`;
|
|
8778
|
+
const checkName = process.env.VINAYA_CHECK_NAME;
|
|
8779
|
+
if (checkName) {
|
|
8780
|
+
emitCheckError({
|
|
8781
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8782
|
+
check: checkName,
|
|
8783
|
+
severity: "warning",
|
|
8784
|
+
message,
|
|
8785
|
+
agent_recovery_prompt: `Fix the failing keys in ${path} (${detail}) so the file parses and satisfies the configuration schema, then re-run.`,
|
|
8786
|
+
file: path
|
|
8787
|
+
});
|
|
8788
|
+
return;
|
|
8789
|
+
}
|
|
8790
|
+
console.error(`⚠ ${message}`);
|
|
8791
|
+
}
|
|
8792
|
+
function loadConfigChecked() {
|
|
8793
|
+
const path = configPath();
|
|
8794
|
+
if (!path)
|
|
8795
|
+
return { ok: true, config: null };
|
|
8796
|
+
let raw;
|
|
8797
|
+
try {
|
|
8798
|
+
raw = JSON.parse(readFileSync2(path, "utf-8"));
|
|
8799
|
+
} catch (err) {
|
|
8800
|
+
return { ok: false, path, error: `invalid JSON: ${err.message}` };
|
|
8801
|
+
}
|
|
8802
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8803
|
+
if (!parsed.success) {
|
|
8804
|
+
return { ok: false, path, error: schemaIssueDetail(parsed.error) };
|
|
8805
|
+
}
|
|
8806
|
+
return { ok: true, config: stripGlobalOnlyKeys(parsed.data, path) };
|
|
8807
|
+
}
|
|
8808
|
+
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
7386
8809
|
|
|
7387
8810
|
// src/checks/bin/check-doctrine-no-procedures.ts
|
|
7388
8811
|
var CHECK_NAME = "doctrine-no-procedures";
|