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