@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,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-brief-shape.ts
|
|
4
|
-
import { readdirSync, readFileSync as
|
|
4
|
+
import { readdirSync, readFileSync as readFileSync4 } from "node:fs";
|
|
5
5
|
|
|
6
6
|
// ../../packages/aeg-core/src/entry-point.ts
|
|
7
7
|
import { realpathSync } from "node:fs";
|
|
@@ -42,7 +42,6 @@ var GATE_AUDIENCE = {
|
|
|
42
42
|
};
|
|
43
43
|
var NON_GATE_BINS = [
|
|
44
44
|
"archive-task",
|
|
45
|
-
"assign-task-issue",
|
|
46
45
|
"dead-branch-audit",
|
|
47
46
|
"eval-agent-compliance",
|
|
48
47
|
"open-issue",
|
|
@@ -305,6 +304,25 @@ async function runAsync(args) {
|
|
|
305
304
|
function ghApiGet(path) {
|
|
306
305
|
return JSON.parse(run(["api", path]));
|
|
307
306
|
}
|
|
307
|
+
var MAX_PER_PAGE = 100;
|
|
308
|
+
var MAX_PAGES = 100;
|
|
309
|
+
async function ghApiGetAllPagesAsync(pathWithoutPage, opts) {
|
|
310
|
+
const [base = pathWithoutPage, query = ""] = pathWithoutPage.split("?");
|
|
311
|
+
const params = new URLSearchParams(query);
|
|
312
|
+
params.set("per_page", String(MAX_PER_PAGE));
|
|
313
|
+
const all = [];
|
|
314
|
+
for (let page = 1;page <= MAX_PAGES; page++) {
|
|
315
|
+
params.set("page", String(page));
|
|
316
|
+
const args = ["api", `${base}?${params.toString()}`];
|
|
317
|
+
if (opts?.jq)
|
|
318
|
+
args.push("-q", opts.jq);
|
|
319
|
+
const batch = JSON.parse(await runAsync(args));
|
|
320
|
+
all.push(...batch);
|
|
321
|
+
if (batch.length < MAX_PER_PAGE)
|
|
322
|
+
return all;
|
|
323
|
+
}
|
|
324
|
+
throw new Error(`ghApiGetAllPagesAsync: "${pathWithoutPage}" did not terminate within ${MAX_PAGES} pages (${MAX_PAGES * MAX_PER_PAGE} items) — refusing to keep walking.`);
|
|
325
|
+
}
|
|
308
326
|
function issueListByLabelArgs(owner, repo, label) {
|
|
309
327
|
return [
|
|
310
328
|
"issue",
|
|
@@ -716,6 +734,10 @@ function intentGoalForSlug(description, slug) {
|
|
|
716
734
|
function matchesLegacyMilestone(milestones, slug) {
|
|
717
735
|
return milestones.find((m) => m.title === slug) ?? null;
|
|
718
736
|
}
|
|
737
|
+
var TRANCHE_SLUG_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*-v\d+$/;
|
|
738
|
+
function slugShapedTitles(milestones) {
|
|
739
|
+
return milestones.map((m) => m.title).filter((t) => TRANCHE_SLUG_SHAPE.test(t));
|
|
740
|
+
}
|
|
719
741
|
function factsFromLegacyMilestone(milestone) {
|
|
720
742
|
return {
|
|
721
743
|
goal: milestone.description ?? "",
|
|
@@ -749,6 +771,105 @@ function findMilestoneForSlug(owner, repo, slug) {
|
|
|
749
771
|
return resolveLegacyFacts(legacy, issues);
|
|
750
772
|
return { goal: goalFromMilestones(milestones, slug), lifecycle: lifecycleFromIssues(issues) };
|
|
751
773
|
}
|
|
774
|
+
function trancheSlugsFromLabels(labels) {
|
|
775
|
+
const slugs = [];
|
|
776
|
+
for (const l of labels) {
|
|
777
|
+
const slug = trancheSlugOf(l.name);
|
|
778
|
+
if (slug !== null)
|
|
779
|
+
slugs.push(slug);
|
|
780
|
+
}
|
|
781
|
+
return slugs;
|
|
782
|
+
}
|
|
783
|
+
async function indexTrancheMilestonesAsync(owner, repo, options = {}) {
|
|
784
|
+
const read = (fetch) => options.retryFailedReads ? retryOnce(fetch) : fetch();
|
|
785
|
+
const [milestones, labels] = await Promise.all([
|
|
786
|
+
read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`)),
|
|
787
|
+
read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`))
|
|
788
|
+
]);
|
|
789
|
+
const active = [];
|
|
790
|
+
const archived = [];
|
|
791
|
+
const facts = new Map;
|
|
792
|
+
const legacySlugs = new Set(slugShapedTitles(milestones));
|
|
793
|
+
const legacyMilestoneBySlug = new Map(milestones.filter((m) => legacySlugs.has(m.title)).map((m) => [m.title, m]));
|
|
794
|
+
const newPathSlugs = trancheSlugsFromLabels(labels).filter((slug) => !legacySlugs.has(slug));
|
|
795
|
+
const uniqueNewPathSlugs = [...new Set(newPathSlugs)];
|
|
796
|
+
const uniqueLegacySlugs = [...legacySlugs];
|
|
797
|
+
const [legacyIssuesBySlug, newPathIssuesBySlug] = await Promise.all([
|
|
798
|
+
Promise.all(uniqueLegacySlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))))),
|
|
799
|
+
Promise.all(uniqueNewPathSlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))))
|
|
800
|
+
]);
|
|
801
|
+
const issuesBySlug = new Map;
|
|
802
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
803
|
+
issuesBySlug.set(slug, legacyIssuesBySlug[i] ?? []);
|
|
804
|
+
});
|
|
805
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
806
|
+
issuesBySlug.set(slug, newPathIssuesBySlug[i] ?? []);
|
|
807
|
+
});
|
|
808
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
809
|
+
const m = legacyMilestoneBySlug.get(slug);
|
|
810
|
+
if (!m)
|
|
811
|
+
return;
|
|
812
|
+
const ref = { slug, goal: m.description ?? "" };
|
|
813
|
+
const f = resolveLegacyFacts(m, legacyIssuesBySlug[i] ?? []);
|
|
814
|
+
if (f.lifecycle === "complete")
|
|
815
|
+
archived.push(ref);
|
|
816
|
+
else if (f.lifecycle === "active")
|
|
817
|
+
active.push(ref);
|
|
818
|
+
facts.set(slug, f);
|
|
819
|
+
});
|
|
820
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
821
|
+
const issues = newPathIssuesBySlug[i] ?? [];
|
|
822
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
823
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
824
|
+
const f = { goal, lifecycle };
|
|
825
|
+
facts.set(slug, f);
|
|
826
|
+
if (lifecycle === "active")
|
|
827
|
+
active.push({ slug, goal });
|
|
828
|
+
else if (lifecycle === "complete")
|
|
829
|
+
archived.push({ slug, goal });
|
|
830
|
+
});
|
|
831
|
+
return { active, archived, facts, legacySlugs, issuesBySlug };
|
|
832
|
+
}
|
|
833
|
+
async function retryOnce(fetch) {
|
|
834
|
+
try {
|
|
835
|
+
return await fetch();
|
|
836
|
+
} catch {
|
|
837
|
+
return fetch();
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
async function indexTrancheMilestonesForSlugAsync(owner, repo, slug) {
|
|
841
|
+
const [milestones, labels, issues] = await Promise.all([
|
|
842
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
843
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`),
|
|
844
|
+
ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))
|
|
845
|
+
]);
|
|
846
|
+
const active = [];
|
|
847
|
+
const archived = [];
|
|
848
|
+
const facts = new Map;
|
|
849
|
+
const legacySlugs = new Set;
|
|
850
|
+
const legacyMilestone = slugShapedTitles(milestones).includes(slug) ? matchesLegacyMilestone(milestones, slug) : null;
|
|
851
|
+
if (legacyMilestone) {
|
|
852
|
+
legacySlugs.add(slug);
|
|
853
|
+
const ref = { slug, goal: legacyMilestone.description ?? "" };
|
|
854
|
+
const f = resolveLegacyFacts(legacyMilestone, issues);
|
|
855
|
+
if (f.lifecycle === "complete")
|
|
856
|
+
archived.push(ref);
|
|
857
|
+
else if (f.lifecycle === "active")
|
|
858
|
+
active.push(ref);
|
|
859
|
+
facts.set(slug, f);
|
|
860
|
+
} else if (trancheSlugsFromLabels(labels).includes(slug)) {
|
|
861
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
862
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
863
|
+
facts.set(slug, { goal, lifecycle });
|
|
864
|
+
if (lifecycle === "active")
|
|
865
|
+
active.push({ slug, goal });
|
|
866
|
+
else if (lifecycle === "complete")
|
|
867
|
+
archived.push({ slug, goal });
|
|
868
|
+
}
|
|
869
|
+
const openLegacyTitles = new Set(slugShapedTitles(milestones.filter((m) => m.state === "open")));
|
|
870
|
+
const otherOpenLegacySlugs = [...openLegacyTitles].filter((t) => t !== slug);
|
|
871
|
+
return { active, archived, facts, legacySlugs, otherOpenLegacySlugs };
|
|
872
|
+
}
|
|
752
873
|
|
|
753
874
|
// ../../packages/aeg-forge-state/src/derive-from-forge.ts
|
|
754
875
|
function trancheFromIssues(slug, issues, known) {
|
|
@@ -1409,6 +1530,125 @@ var graphql2 = withDefaults3(request, {
|
|
|
1409
1530
|
method: "POST",
|
|
1410
1531
|
url: "/graphql"
|
|
1411
1532
|
});
|
|
1533
|
+
|
|
1534
|
+
// ../../packages/aeg-forge-state/src/fetch-provenance.ts
|
|
1535
|
+
var PROVENANCE_PATTERN = /^###\s+AEG provenance\b/im;
|
|
1536
|
+
function provenanceMatchesIssue(text, issueNum) {
|
|
1537
|
+
if (!PROVENANCE_PATTERN.test(text))
|
|
1538
|
+
return false;
|
|
1539
|
+
const m = text.match(/^-\s*Issue:\s*#(\d+)/im);
|
|
1540
|
+
return m !== null && Number(m[1]) === issueNum;
|
|
1541
|
+
}
|
|
1542
|
+
function isPrCloser(closer) {
|
|
1543
|
+
return closer !== null && typeof closer.number === "number";
|
|
1544
|
+
}
|
|
1545
|
+
async function fetchProvenanceViaCrossReferences(issueNums, owner, repo, token) {
|
|
1546
|
+
const result = new Map;
|
|
1547
|
+
if (issueNums.length === 0)
|
|
1548
|
+
return result;
|
|
1549
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1550
|
+
const perIssue = issueNums.map((n) => `
|
|
1551
|
+
i_${n}: issue(number: ${n}) {
|
|
1552
|
+
timelineItems(first: 50, itemTypes: [CROSS_REFERENCED_EVENT]) {
|
|
1553
|
+
nodes {
|
|
1554
|
+
... on CrossReferencedEvent {
|
|
1555
|
+
source {
|
|
1556
|
+
... on PullRequest {
|
|
1557
|
+
number
|
|
1558
|
+
body
|
|
1559
|
+
comments(first: 50) { nodes { body } }
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
}`).join("");
|
|
1566
|
+
const query = `query ProvenanceCrossRef($owner: String!, $repo: String!) {
|
|
1567
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1568
|
+
}
|
|
1569
|
+
}`;
|
|
1570
|
+
let response;
|
|
1571
|
+
try {
|
|
1572
|
+
response = await client(query, { owner, repo });
|
|
1573
|
+
} catch {
|
|
1574
|
+
return result;
|
|
1575
|
+
}
|
|
1576
|
+
if (!response.repository)
|
|
1577
|
+
return result;
|
|
1578
|
+
for (const n of issueNums) {
|
|
1579
|
+
const raw = response.repository[`i_${n}`];
|
|
1580
|
+
const nodes = raw?.timelineItems?.nodes ?? [];
|
|
1581
|
+
const found = nodes.some(({ source }) => {
|
|
1582
|
+
if (!source || typeof source.number !== "number")
|
|
1583
|
+
return false;
|
|
1584
|
+
const pr = source;
|
|
1585
|
+
if (provenanceMatchesIssue(pr.body ?? "", n))
|
|
1586
|
+
return true;
|
|
1587
|
+
return pr.comments.nodes.some((c) => provenanceMatchesIssue(c.body, n));
|
|
1588
|
+
});
|
|
1589
|
+
result.set(n, found);
|
|
1590
|
+
}
|
|
1591
|
+
return result;
|
|
1592
|
+
}
|
|
1593
|
+
async function fetchProvenance(issueNums, owner, repo, token) {
|
|
1594
|
+
const result = new Map;
|
|
1595
|
+
if (issueNums.length === 0)
|
|
1596
|
+
return result;
|
|
1597
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1598
|
+
const perIssue = issueNums.map((n) => `
|
|
1599
|
+
i_${n}: issue(number: ${n}) {
|
|
1600
|
+
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1601
|
+
nodes {
|
|
1602
|
+
... on ClosedEvent {
|
|
1603
|
+
closer {
|
|
1604
|
+
... on PullRequest {
|
|
1605
|
+
number
|
|
1606
|
+
body
|
|
1607
|
+
comments(first: 50) {
|
|
1608
|
+
nodes { body }
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}`).join("");
|
|
1616
|
+
const query = `query Provenance($owner: String!, $repo: String!) {
|
|
1617
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1618
|
+
}
|
|
1619
|
+
}`;
|
|
1620
|
+
let response;
|
|
1621
|
+
try {
|
|
1622
|
+
response = await client(query, { owner, repo });
|
|
1623
|
+
} catch {
|
|
1624
|
+
return result;
|
|
1625
|
+
}
|
|
1626
|
+
if (!response.repository)
|
|
1627
|
+
return result;
|
|
1628
|
+
const needsFallback = [];
|
|
1629
|
+
for (const n of issueNums) {
|
|
1630
|
+
const raw = response.repository[`i_${n}`];
|
|
1631
|
+
if (!raw) {
|
|
1632
|
+
result.set(n, false);
|
|
1633
|
+
continue;
|
|
1634
|
+
}
|
|
1635
|
+
const closer = raw.timelineItems?.nodes?.[0]?.closer;
|
|
1636
|
+
const c = closer ?? null;
|
|
1637
|
+
if (!isPrCloser(c)) {
|
|
1638
|
+
needsFallback.push(n);
|
|
1639
|
+
continue;
|
|
1640
|
+
}
|
|
1641
|
+
const bodyHas = PROVENANCE_PATTERN.test(c.body ?? "");
|
|
1642
|
+
const commentHas = c.comments.nodes.some((x) => PROVENANCE_PATTERN.test(x.body));
|
|
1643
|
+
result.set(n, bodyHas || commentHas);
|
|
1644
|
+
}
|
|
1645
|
+
if (needsFallback.length > 0) {
|
|
1646
|
+
const fallback = await fetchProvenanceViaCrossReferences(needsFallback, owner, repo, token);
|
|
1647
|
+
for (const [n, found] of fallback)
|
|
1648
|
+
result.set(n, found);
|
|
1649
|
+
}
|
|
1650
|
+
return result;
|
|
1651
|
+
}
|
|
1412
1652
|
// ../../packages/aeg-forge-state/src/github-token.ts
|
|
1413
1653
|
import { execFile as execFile2 } from "node:child_process";
|
|
1414
1654
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -1638,6 +1878,52 @@ function describeError(err) {
|
|
|
1638
1878
|
return err;
|
|
1639
1879
|
return "unknown error";
|
|
1640
1880
|
}
|
|
1881
|
+
// ../../packages/aeg-forge-state/src/prior-tranche-archival.ts
|
|
1882
|
+
function defaultPriorTrancheArchivalDeps() {
|
|
1883
|
+
return {
|
|
1884
|
+
activeTranches: async (excludeSlug, repo) => {
|
|
1885
|
+
const index = await indexTrancheMilestonesAsync(repo.owner, repo.repo, { retryFailedReads: true });
|
|
1886
|
+
return index.active.filter((m) => m.slug !== excludeSlug).map((m) => {
|
|
1887
|
+
const issues = index.issuesBySlug?.get(m.slug);
|
|
1888
|
+
if (!issues)
|
|
1889
|
+
throw new Error(`the Milestone index holds no Issue list for tranche \`${m.slug}\``);
|
|
1890
|
+
return { slug: m.slug, issues };
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
function reason(err) {
|
|
1896
|
+
return err instanceof Error ? err.message.split(`
|
|
1897
|
+
`)[0] ?? "failed" : String(err);
|
|
1898
|
+
}
|
|
1899
|
+
async function resolvePriorTrancheArchival(projects, excludeSlug, repo, deps = defaultPriorTrancheArchivalDeps()) {
|
|
1900
|
+
if (projects.length === 0)
|
|
1901
|
+
return { facts: [], infraFailure: null };
|
|
1902
|
+
let candidates;
|
|
1903
|
+
try {
|
|
1904
|
+
candidates = await deps.activeTranches(excludeSlug, repo);
|
|
1905
|
+
} catch (err) {
|
|
1906
|
+
return {
|
|
1907
|
+
facts: [],
|
|
1908
|
+
infraFailure: `severity:infra — could not read the active tranches (${reason(err)}); whether a prior tranche is archived is unknown.`
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
const tasksBySlug = new Map(candidates.map((c) => [c.slug, tasksFromIssues(c.issues)]));
|
|
1912
|
+
const facts = [];
|
|
1913
|
+
for (const project of projects) {
|
|
1914
|
+
let found = null;
|
|
1915
|
+
for (const { slug, issues } of candidates) {
|
|
1916
|
+
if (!(tasksBySlug.get(slug) ?? []).some((t) => t.projects.includes(project)))
|
|
1917
|
+
continue;
|
|
1918
|
+
if (!issues.some((issue) => issue.state === "OPEN")) {
|
|
1919
|
+
found = { project, priorTrancheSlug: slug, archived: false };
|
|
1920
|
+
break;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
facts.push(found ?? { project, priorTrancheSlug: null, archived: false });
|
|
1924
|
+
}
|
|
1925
|
+
return { facts, infraFailure: null };
|
|
1926
|
+
}
|
|
1641
1927
|
// ../../packages/aeg-forge-state/src/fetch-open-issues.ts
|
|
1642
1928
|
async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
|
|
1643
1929
|
const result = new Map;
|
|
@@ -1712,6 +1998,10 @@ function buildQuery(issueNumbers) {
|
|
|
1712
1998
|
}
|
|
1713
1999
|
}`;
|
|
1714
2000
|
}
|
|
2001
|
+
// ../../packages/aeg-forge-state/src/list-issue-milestones.ts
|
|
2002
|
+
function issueMilestonesFromIssues(issues) {
|
|
2003
|
+
return issues.filter((i) => i.state === "OPEN").map((i) => ({ issue: i.number, milestoneTitle: i.milestone?.title ?? null }));
|
|
2004
|
+
}
|
|
1715
2005
|
// ../../packages/aeg-forge-state/src/resolve-repo.ts
|
|
1716
2006
|
import { execFile as execFile3 } from "node:child_process";
|
|
1717
2007
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -1774,7 +2064,8 @@ var ANCHOR_FIELDS = [
|
|
|
1774
2064
|
"PREMISE",
|
|
1775
2065
|
"TEST-PLAN",
|
|
1776
2066
|
"EVIDENCE",
|
|
1777
|
-
"BEYOND-SURFACE"
|
|
2067
|
+
"BEYOND-SURFACE",
|
|
2068
|
+
"LIVE"
|
|
1778
2069
|
];
|
|
1779
2070
|
function anchoredRegionBounds(body, field) {
|
|
1780
2071
|
const masked = maskCode(body);
|
|
@@ -1975,7 +2266,6 @@ var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
|
1975
2266
|
// ../../packages/aeg-core/src/waiver-label.ts
|
|
1976
2267
|
var WAIVER_LABEL = label("waiver-docs");
|
|
1977
2268
|
var WAIVER_LABEL_REVIEW = label("waiver-review");
|
|
1978
|
-
var PRINCIPAL_ALLOWLIST = ["daniboomerang"];
|
|
1979
2269
|
function isPrincipal(login, principalAllowlist) {
|
|
1980
2270
|
if (login === null)
|
|
1981
2271
|
return false;
|
|
@@ -1994,6 +2284,14 @@ var RULING_ORDINAL_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Ruling ordinal:\s*(\d+)(
|
|
|
1994
2284
|
var BRIEF_HASH_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Brief hash:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1995
2285
|
var POLICY_DIGEST_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Policy digest:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1996
2286
|
var BASE_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged base:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
|
|
2287
|
+
var MANIFEST_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Manifest version:\s*(\d+)\s*$/im;
|
|
2288
|
+
var PAUSE_BOUND_RULING_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Pause-bound ruling:\s*(?:(\S+)\|(\S+)\|([0-9a-f]{64})|\(none\))\s*$/im;
|
|
2289
|
+
function extractPauseBoundRuling(comment) {
|
|
2290
|
+
const m = comment.match(PAUSE_BOUND_RULING_PATTERN);
|
|
2291
|
+
if (!m)
|
|
2292
|
+
return;
|
|
2293
|
+
return m[1] ? { rulingId: m[1], pauseId: m[2], contentDigest: m[3] } : null;
|
|
2294
|
+
}
|
|
1997
2295
|
function firstFiveLines(comment) {
|
|
1998
2296
|
return comment.split(`
|
|
1999
2297
|
`).slice(0, 5).join(`
|
|
@@ -2087,6 +2385,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2087
2385
|
danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
|
|
2088
2386
|
};
|
|
2089
2387
|
}
|
|
2388
|
+
const versionMatch = latest.match(MANIFEST_VERSION_PATTERN);
|
|
2389
|
+
const pauseBoundRuling = extractPauseBoundRuling(latest);
|
|
2090
2390
|
return {
|
|
2091
2391
|
value: m[1].toUpperCase().replace(/[_-]/g, " "),
|
|
2092
2392
|
headSha: extractHeadSha(latest),
|
|
@@ -2095,6 +2395,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2095
2395
|
briefHash: extractBriefHash(latest),
|
|
2096
2396
|
policyDigest: extractPolicyDigest(latest),
|
|
2097
2397
|
baseSha: extractBaseSha(latest),
|
|
2398
|
+
...versionMatch ? { manifestVersion: Number.parseInt(versionMatch[1], 10) } : {},
|
|
2399
|
+
...pauseBoundRuling === undefined ? {} : { pauseBoundRuling },
|
|
2098
2400
|
findingSeverities: extractFindingSeverities(latest),
|
|
2099
2401
|
danglingNote: null
|
|
2100
2402
|
};
|
|
@@ -2105,6 +2407,16 @@ function extractCodeReviewVerdict(comments) {
|
|
|
2105
2407
|
function extractSecurityReviewVerdict(comments) {
|
|
2106
2408
|
return extractVerdict(comments, /^[ \t]*(?:\*{1,3}|_{1,3})?VERDICT:\s*(PASS|FAIL)(?![A-Za-z0-9])/im, "security-review");
|
|
2107
2409
|
}
|
|
2410
|
+
|
|
2411
|
+
// ../../packages/aeg-core/src/review-status.ts
|
|
2412
|
+
var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-(\d+)\s*-->/i;
|
|
2413
|
+
function parseDeveloperRoundMarker(body) {
|
|
2414
|
+
const m = body.match(DEVELOPER_ROUND_MARKER);
|
|
2415
|
+
if (!m)
|
|
2416
|
+
return null;
|
|
2417
|
+
const n = Number(m[1]);
|
|
2418
|
+
return Number.isFinite(n) ? n : null;
|
|
2419
|
+
}
|
|
2108
2420
|
// ../../packages/aeg-core/src/report-tokens.ts
|
|
2109
2421
|
var DASH_LOOKALIKES = {
|
|
2110
2422
|
"-": "‑",
|
|
@@ -2436,11 +2748,13 @@ var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
|
|
|
2436
2748
|
var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
|
|
2437
2749
|
var DEFAULT_MAX_ROUNDS = 3;
|
|
2438
2750
|
var DEFAULT_MAX_TASK_MINUTES = 180;
|
|
2751
|
+
var DEFAULT_READY_PUSH_TIMEOUT_MINUTES = 20;
|
|
2439
2752
|
var DEFAULT_REVIEW_POLICY = {
|
|
2440
2753
|
codeReviewThreshold: "BLOCKER",
|
|
2441
2754
|
securityThreshold: "HIGH",
|
|
2442
2755
|
maxRounds: DEFAULT_MAX_ROUNDS,
|
|
2443
|
-
maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
|
|
2756
|
+
maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES,
|
|
2757
|
+
readyPushTimeoutMinutes: DEFAULT_READY_PUSH_TIMEOUT_MINUTES
|
|
2444
2758
|
};
|
|
2445
2759
|
var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
|
|
2446
2760
|
var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
|
|
@@ -2800,14 +3114,14 @@ function checkTestPlan(prBody) {
|
|
|
2800
3114
|
const region = located.found ? located.section : prBody;
|
|
2801
3115
|
if (TEST_PLAN_UNIT_TESTS_ONLY_RE.test(region))
|
|
2802
3116
|
return { status: "pass", errors: [] };
|
|
2803
|
-
if (/\*\*\[(?:agent|principal)\]\*\*/.test(region))
|
|
3117
|
+
if (/\*\*\[(?:agent|principal|live)\]\*\*/.test(region))
|
|
2804
3118
|
return { status: "pass", errors: [] };
|
|
2805
3119
|
if (located.found && extractFencedBlocks(region).length > 0)
|
|
2806
3120
|
return { status: "pass", errors: [] };
|
|
2807
3121
|
return {
|
|
2808
3122
|
status: "fail",
|
|
2809
3123
|
errors: [
|
|
2810
|
-
"brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`-tagged
|
|
3124
|
+
"brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`/`**[live]**`-tagged item."
|
|
2811
3125
|
]
|
|
2812
3126
|
};
|
|
2813
3127
|
}
|
|
@@ -3429,6 +3743,375 @@ function checkPrReportDensity(prBody) {
|
|
|
3429
3743
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3430
3744
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3431
3745
|
}
|
|
3746
|
+
// ../../packages/aeg-core/src/prose-rules.ts
|
|
3747
|
+
var RETIRED_GLOBAL_EXEMPTIONS = [
|
|
3748
|
+
"docs/decisions-legacy.md",
|
|
3749
|
+
"apps/herald-ai/docs/",
|
|
3750
|
+
"apps/vada-ai/docs/",
|
|
3751
|
+
"aeg-root/tranches/completed/",
|
|
3752
|
+
"packages/aeg-core/src/docs/published-prose",
|
|
3753
|
+
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
3754
|
+
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
3755
|
+
"/fixtures/",
|
|
3756
|
+
"/node_modules/",
|
|
3757
|
+
"/.next/",
|
|
3758
|
+
"/.turbo/"
|
|
3759
|
+
];
|
|
3760
|
+
var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
|
|
3761
|
+
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
3762
|
+
var RETIRED_PATTERN_EXEMPTIONS = {
|
|
3763
|
+
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
3764
|
+
[String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
|
|
3765
|
+
"docs-index.md",
|
|
3766
|
+
"apps/vada-ai/specs/legacy/README.md",
|
|
3767
|
+
"apps/vada-ai/specs/vada-product-spec.md",
|
|
3768
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3769
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3770
|
+
],
|
|
3771
|
+
"decisions-legacy": [
|
|
3772
|
+
"packages/aeg-core/src/file-classify.ts",
|
|
3773
|
+
"packages/aeg-core/src/file-classify.test.ts",
|
|
3774
|
+
"packages/aeg-core/src/pr-tier.test.ts",
|
|
3775
|
+
"docs-index.md",
|
|
3776
|
+
".claude/skills/database/SKILL.md",
|
|
3777
|
+
".claude/skills/vada-architecture/SKILL.md",
|
|
3778
|
+
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
3779
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3780
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3781
|
+
],
|
|
3782
|
+
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
3783
|
+
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
3784
|
+
};
|
|
3785
|
+
var retiredPatterns = [
|
|
3786
|
+
String.raw`\bD-[0-9]{3}\b`,
|
|
3787
|
+
"D-(###|NNN|nnn|xxx)",
|
|
3788
|
+
"decision (entry|logged)",
|
|
3789
|
+
"decision-log entry",
|
|
3790
|
+
"decision log entry",
|
|
3791
|
+
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
3792
|
+
"decision-log",
|
|
3793
|
+
"decision entr",
|
|
3794
|
+
"decisions? (are |is )?logged",
|
|
3795
|
+
"log entries",
|
|
3796
|
+
String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
|
|
3797
|
+
"decisions-legacy",
|
|
3798
|
+
"CONTRADICTION",
|
|
3799
|
+
"assumes Tier 3",
|
|
3800
|
+
"Lock: ?YES",
|
|
3801
|
+
"Lock: ?NO",
|
|
3802
|
+
"lock approvals?",
|
|
3803
|
+
"approves locks",
|
|
3804
|
+
"Conforms to lock",
|
|
3805
|
+
"Challenges lock",
|
|
3806
|
+
"checkDecisionNumbersFresh",
|
|
3807
|
+
String.raw`roles/team-leader\.md`,
|
|
3808
|
+
String.raw`\(,`,
|
|
3809
|
+
String.raw`,\)`,
|
|
3810
|
+
String.raw`\(\.\)`,
|
|
3811
|
+
...PLAN_ON_DISK_PATTERNS
|
|
3812
|
+
];
|
|
3813
|
+
var published = [
|
|
3814
|
+
["decision-id", "a decision id", /\bD-\d{3,}\b/],
|
|
3815
|
+
["section-ref", "a section reference", /§/],
|
|
3816
|
+
["forge-number", "a forge number", /#\d+/],
|
|
3817
|
+
["retired-name", "the retired public name", /\bAEG\b/],
|
|
3818
|
+
["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
|
|
3819
|
+
[
|
|
3820
|
+
"label-vocabulary",
|
|
3821
|
+
"forge label vocabulary",
|
|
3822
|
+
/(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
|
|
3823
|
+
],
|
|
3824
|
+
["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
|
|
3825
|
+
["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
|
|
3826
|
+
[
|
|
3827
|
+
"internal-path",
|
|
3828
|
+
"a repo-internal file",
|
|
3829
|
+
/(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
|
|
3830
|
+
]
|
|
3831
|
+
];
|
|
3832
|
+
var DEFAULT_PROSE_RULES = [
|
|
3833
|
+
{
|
|
3834
|
+
id: "forge-number",
|
|
3835
|
+
group: "reader-resolvable",
|
|
3836
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3837
|
+
patterns: { prose: /#[0-9]{2,4}/g },
|
|
3838
|
+
flags: ["global"],
|
|
3839
|
+
message: "a forge number",
|
|
3840
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3841
|
+
exemptions: []
|
|
3842
|
+
},
|
|
3843
|
+
{
|
|
3844
|
+
id: "tranche-slug",
|
|
3845
|
+
group: "reader-resolvable",
|
|
3846
|
+
scopes: ["ships", "reader-facing", "product", "spec"],
|
|
3847
|
+
patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
|
|
3848
|
+
flags: ["global"],
|
|
3849
|
+
message: "an internal tranche slug",
|
|
3850
|
+
severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
|
|
3851
|
+
exemptions: []
|
|
3852
|
+
},
|
|
3853
|
+
{
|
|
3854
|
+
id: "task-number",
|
|
3855
|
+
group: "reader-resolvable",
|
|
3856
|
+
scopes: ["spec"],
|
|
3857
|
+
patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
|
|
3858
|
+
flags: ["global", "ignore-case"],
|
|
3859
|
+
message: "a task number",
|
|
3860
|
+
severity: { spec: "error" },
|
|
3861
|
+
exemptions: []
|
|
3862
|
+
},
|
|
3863
|
+
{
|
|
3864
|
+
id: "source-comment-tranche-slug",
|
|
3865
|
+
group: "reader-resolvable",
|
|
3866
|
+
scopes: ["source-comment"],
|
|
3867
|
+
patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
|
|
3868
|
+
flags: ["global"],
|
|
3869
|
+
message: "a tranche-slug citation",
|
|
3870
|
+
severity: { "source-comment": "warning" },
|
|
3871
|
+
exemptions: []
|
|
3872
|
+
},
|
|
3873
|
+
{
|
|
3874
|
+
id: "source-comment-forge-number",
|
|
3875
|
+
group: "reader-resolvable",
|
|
3876
|
+
scopes: ["source-comment"],
|
|
3877
|
+
patterns: { comment: /#[0-9]{2,}/g },
|
|
3878
|
+
flags: ["global"],
|
|
3879
|
+
message: "a forge-number citation",
|
|
3880
|
+
severity: { "source-comment": "warning" },
|
|
3881
|
+
exemptions: []
|
|
3882
|
+
},
|
|
3883
|
+
{
|
|
3884
|
+
id: "legacy-batch-name",
|
|
3885
|
+
group: "reader-resolvable",
|
|
3886
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3887
|
+
patterns: {},
|
|
3888
|
+
flags: ["built-in"],
|
|
3889
|
+
message: "an internal tranche slug",
|
|
3890
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3891
|
+
exemptions: [],
|
|
3892
|
+
builtIn: true
|
|
3893
|
+
},
|
|
3894
|
+
{
|
|
3895
|
+
id: "coined-term",
|
|
3896
|
+
group: "reader-resolvable",
|
|
3897
|
+
scopes: ["ships", "reader-facing"],
|
|
3898
|
+
patterns: {},
|
|
3899
|
+
flags: ["built-in"],
|
|
3900
|
+
message: "uses coined term without defining it inline or linking the glossary",
|
|
3901
|
+
severity: { ships: "warning", "reader-facing": "warning" },
|
|
3902
|
+
exemptions: [],
|
|
3903
|
+
builtIn: true
|
|
3904
|
+
},
|
|
3905
|
+
...retiredPatterns.map((pattern, index) => ({
|
|
3906
|
+
id: `retired-vocabulary-${index + 1}`,
|
|
3907
|
+
group: "retired-vocabulary",
|
|
3908
|
+
scopes: ["repository"],
|
|
3909
|
+
patterns: { repository: pattern },
|
|
3910
|
+
flags: [],
|
|
3911
|
+
message: "retired vocabulary",
|
|
3912
|
+
severity: { repository: "error" },
|
|
3913
|
+
exemptions: RETIRED_GLOBAL_EXEMPTIONS,
|
|
3914
|
+
patternExemptions: RETIRED_PATTERN_EXEMPTIONS
|
|
3915
|
+
})),
|
|
3916
|
+
...published.map(([id, message, pattern]) => ({
|
|
3917
|
+
id,
|
|
3918
|
+
group: "published-prose",
|
|
3919
|
+
scopes: ["published"],
|
|
3920
|
+
patterns: { published: pattern },
|
|
3921
|
+
flags: [],
|
|
3922
|
+
message,
|
|
3923
|
+
severity: { published: "error" },
|
|
3924
|
+
exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
|
|
3925
|
+
}))
|
|
3926
|
+
];
|
|
3927
|
+
var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
|
|
3928
|
+
var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
|
|
3929
|
+
var RETIRED_SCOPES = ["repository"];
|
|
3930
|
+
var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
|
|
3931
|
+
function groupOfScope(scope) {
|
|
3932
|
+
if (RESOLVABLE_SCOPES.includes(scope))
|
|
3933
|
+
return "reader-resolvable";
|
|
3934
|
+
if (RETIRED_SCOPES.includes(scope))
|
|
3935
|
+
return "retired-vocabulary";
|
|
3936
|
+
return;
|
|
3937
|
+
}
|
|
3938
|
+
var CONFIGURED_PROSE_FLAGS = ["i", "u"];
|
|
3939
|
+
var CONFIGURED_PATTERN_MAX_LENGTH = 200;
|
|
3940
|
+
var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
|
|
3941
|
+
function allowedScopesFor(rule) {
|
|
3942
|
+
if (rule.builtIn)
|
|
3943
|
+
return rule.scopes;
|
|
3944
|
+
return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
|
|
3945
|
+
}
|
|
3946
|
+
function normalizeRepoPath(entry) {
|
|
3947
|
+
let out = entry.replace(/\\/g, "/");
|
|
3948
|
+
while (out.startsWith("./"))
|
|
3949
|
+
out = out.slice(2);
|
|
3950
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3951
|
+
while (out.endsWith("/"))
|
|
3952
|
+
out = out.slice(0, -1);
|
|
3953
|
+
return out;
|
|
3954
|
+
}
|
|
3955
|
+
function isConfiguredExempt(path, exempt, repoRoot) {
|
|
3956
|
+
if (exempt.length === 0)
|
|
3957
|
+
return false;
|
|
3958
|
+
const root = repoRoot === undefined ? undefined : normalizeRepoPath(repoRoot);
|
|
3959
|
+
let rel = normalizeRepoPath(path);
|
|
3960
|
+
if (root && rel.startsWith(`${root}/`))
|
|
3961
|
+
rel = rel.slice(root.length + 1);
|
|
3962
|
+
return exempt.some((entry) => {
|
|
3963
|
+
const e = normalizeRepoPath(entry);
|
|
3964
|
+
return rel === e || rel.startsWith(`${e}/`);
|
|
3965
|
+
});
|
|
3966
|
+
}
|
|
3967
|
+
function ruleReads(set, rule, path) {
|
|
3968
|
+
return !isConfiguredExempt(path, set.exempt, set.repoRoot) && !isConfiguredExempt(path, rule.exempt, set.repoRoot);
|
|
3969
|
+
}
|
|
3970
|
+
var RESOLVABLE_RUN_ORDER = [
|
|
3971
|
+
"forge-number",
|
|
3972
|
+
"tranche-slug",
|
|
3973
|
+
"legacy-batch-name",
|
|
3974
|
+
"task-number",
|
|
3975
|
+
"source-comment-tranche-slug",
|
|
3976
|
+
"source-comment-forge-number",
|
|
3977
|
+
"coined-term"
|
|
3978
|
+
];
|
|
3979
|
+
var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
|
|
3980
|
+
function scopeDefaultSeverity(scope, sourceCommentSeverity) {
|
|
3981
|
+
if (scope === "source-comment")
|
|
3982
|
+
return sourceCommentSeverity ?? "warning";
|
|
3983
|
+
if (scope === "repository")
|
|
3984
|
+
return "error";
|
|
3985
|
+
return "warning";
|
|
3986
|
+
}
|
|
3987
|
+
function applySeverity(scopes, base, setting) {
|
|
3988
|
+
const out = {};
|
|
3989
|
+
for (const scope of scopes) {
|
|
3990
|
+
const configured = typeof setting === "string" ? setting : setting?.[scope];
|
|
3991
|
+
const value = configured ?? base[scope];
|
|
3992
|
+
if (value !== undefined)
|
|
3993
|
+
out[scope] = value;
|
|
3994
|
+
}
|
|
3995
|
+
return out;
|
|
3996
|
+
}
|
|
3997
|
+
function defaultPatternFor(rule) {
|
|
3998
|
+
const cache = new Map;
|
|
3999
|
+
return (scope) => {
|
|
4000
|
+
if (cache.has(scope))
|
|
4001
|
+
return cache.get(scope) ?? null;
|
|
4002
|
+
const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
|
|
4003
|
+
const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
|
|
4004
|
+
cache.set(scope, compiled);
|
|
4005
|
+
return compiled;
|
|
4006
|
+
};
|
|
4007
|
+
}
|
|
4008
|
+
function customPatternFor(rule, global) {
|
|
4009
|
+
const cache = new Map;
|
|
4010
|
+
return (scope) => {
|
|
4011
|
+
if (cache.has(scope))
|
|
4012
|
+
return cache.get(scope) ?? null;
|
|
4013
|
+
const source = rule.patterns?.[scope] ?? rule.pattern;
|
|
4014
|
+
const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
|
|
4015
|
+
cache.set(scope, compiled);
|
|
4016
|
+
return compiled;
|
|
4017
|
+
};
|
|
4018
|
+
}
|
|
4019
|
+
function resolveProseRules(config = undefined, options = {}) {
|
|
4020
|
+
const rules = [];
|
|
4021
|
+
const defaults = config?.defaults ?? {};
|
|
4022
|
+
for (const rule of CONFIGURABLE_DEFAULT_RULES) {
|
|
4023
|
+
const override = defaults[rule.id];
|
|
4024
|
+
if (override === "off")
|
|
4025
|
+
continue;
|
|
4026
|
+
const group = rule.group;
|
|
4027
|
+
const scopes = override?.scopes ?? rule.scopes;
|
|
4028
|
+
const base = {};
|
|
4029
|
+
for (const scope of scopes) {
|
|
4030
|
+
base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4031
|
+
}
|
|
4032
|
+
rules.push({
|
|
4033
|
+
id: rule.id,
|
|
4034
|
+
group,
|
|
4035
|
+
custom: false,
|
|
4036
|
+
builtIn: rule.builtIn === true,
|
|
4037
|
+
scopes,
|
|
4038
|
+
message: rule.message,
|
|
4039
|
+
severity: applySeverity(scopes, base, override?.severity),
|
|
4040
|
+
exempt: override?.exempt ?? [],
|
|
4041
|
+
substringExempt: rule.exemptions,
|
|
4042
|
+
reportGroup: REPORT_GROUPS[rule.id],
|
|
4043
|
+
patternFor: defaultPatternFor(rule)
|
|
4044
|
+
});
|
|
4045
|
+
}
|
|
4046
|
+
for (const rule of config?.custom ?? []) {
|
|
4047
|
+
const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
|
|
4048
|
+
const base = {};
|
|
4049
|
+
for (const scope of rule.scopes)
|
|
4050
|
+
base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4051
|
+
rules.push({
|
|
4052
|
+
id: rule.id,
|
|
4053
|
+
group,
|
|
4054
|
+
custom: true,
|
|
4055
|
+
builtIn: false,
|
|
4056
|
+
scopes: rule.scopes,
|
|
4057
|
+
message: rule.means,
|
|
4058
|
+
severity: applySeverity(rule.scopes, base, rule.severity),
|
|
4059
|
+
exempt: rule.exempt ?? [],
|
|
4060
|
+
substringExempt: [],
|
|
4061
|
+
patternFor: customPatternFor(rule, group === "reader-resolvable")
|
|
4062
|
+
});
|
|
4063
|
+
}
|
|
4064
|
+
if (options.decisionRecordsPath !== undefined)
|
|
4065
|
+
rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
|
|
4066
|
+
const order = (rule) => {
|
|
4067
|
+
const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
|
|
4068
|
+
return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
|
|
4069
|
+
};
|
|
4070
|
+
const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
|
|
4071
|
+
const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
|
|
4072
|
+
return {
|
|
4073
|
+
rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
|
|
4074
|
+
exempt: config?.exempt ?? [],
|
|
4075
|
+
repoRoot: options.repoRoot
|
|
4076
|
+
};
|
|
4077
|
+
}
|
|
4078
|
+
function rulesOfGroup(set, group) {
|
|
4079
|
+
return set.rules.filter((rule) => rule.group === group);
|
|
4080
|
+
}
|
|
4081
|
+
function rulesInScope(set, scope) {
|
|
4082
|
+
return set.rules.filter((rule) => rule.scopes.includes(scope));
|
|
4083
|
+
}
|
|
4084
|
+
var DEFAULT_PROSE_RULE_SET = resolveProseRules();
|
|
4085
|
+
var DECISION_RECORD_CITATION_ID = "decision-record-citation";
|
|
4086
|
+
var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
|
|
4087
|
+
var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
|
|
4088
|
+
function escapeRegExp(text) {
|
|
4089
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4090
|
+
}
|
|
4091
|
+
function decisionRecordCitationPattern(decisionRecordsPath) {
|
|
4092
|
+
const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
|
|
4093
|
+
return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
|
|
4094
|
+
}
|
|
4095
|
+
function decisionRecordCitationRule(decisionRecordsPath) {
|
|
4096
|
+
const folder = normalizeRepoPath(decisionRecordsPath);
|
|
4097
|
+
const pattern = decisionRecordCitationPattern(folder);
|
|
4098
|
+
const severity = {};
|
|
4099
|
+
for (const scope of DECISION_RECORD_CITATION_SCOPES)
|
|
4100
|
+
severity[scope] = "error";
|
|
4101
|
+
return {
|
|
4102
|
+
id: DECISION_RECORD_CITATION_ID,
|
|
4103
|
+
group: "reader-resolvable",
|
|
4104
|
+
custom: false,
|
|
4105
|
+
builtIn: false,
|
|
4106
|
+
scopes: DECISION_RECORD_CITATION_SCOPES,
|
|
4107
|
+
message: DECISION_RECORD_CITATION_MESSAGE,
|
|
4108
|
+
severity,
|
|
4109
|
+
exempt: [folder],
|
|
4110
|
+
substringExempt: [],
|
|
4111
|
+
patternFor: () => pattern
|
|
4112
|
+
};
|
|
4113
|
+
}
|
|
4114
|
+
|
|
3432
4115
|
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3433
4116
|
var PRODUCT_SLUG_SCOPE = [
|
|
3434
4117
|
"apps/cli/src",
|
|
@@ -3440,8 +4123,8 @@ var PRODUCT_SLUG_SCOPE = [
|
|
|
3440
4123
|
function isUnderOrEqual(path, prefix) {
|
|
3441
4124
|
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3442
4125
|
}
|
|
3443
|
-
function isProductScopeFile(path) {
|
|
3444
|
-
return
|
|
4126
|
+
function isProductScopeFile(path, productPaths) {
|
|
4127
|
+
return productPaths.some((prefix) => isUnderOrEqual(path, normalizeRepoPath(prefix)));
|
|
3445
4128
|
}
|
|
3446
4129
|
var SHIPS_PREFIX = "aeg-root/";
|
|
3447
4130
|
function shipsArchivePrefix(shipsPrefix) {
|
|
@@ -3449,13 +4132,7 @@ function shipsArchivePrefix(shipsPrefix) {
|
|
|
3449
4132
|
}
|
|
3450
4133
|
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3451
4134
|
function normalizeSpecPath(entry) {
|
|
3452
|
-
|
|
3453
|
-
while (out.startsWith("./"))
|
|
3454
|
-
out = out.slice(2);
|
|
3455
|
-
out = out.replace(/\/{2,}/g, "/");
|
|
3456
|
-
while (out.endsWith("/"))
|
|
3457
|
-
out = out.slice(0, -1);
|
|
3458
|
-
return out;
|
|
4135
|
+
return normalizeRepoPath(entry);
|
|
3459
4136
|
}
|
|
3460
4137
|
function isSpecFile2(path, specPaths) {
|
|
3461
4138
|
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
@@ -3467,7 +4144,7 @@ function isSpecFile2(path, specPaths) {
|
|
|
3467
4144
|
function isClaudeMdFile(path) {
|
|
3468
4145
|
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3469
4146
|
}
|
|
3470
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4147
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS, productPaths = PRODUCT_SLUG_SCOPE) {
|
|
3471
4148
|
if (path.startsWith(shipsPrefix)) {
|
|
3472
4149
|
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3473
4150
|
}
|
|
@@ -3478,7 +4155,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
|
|
|
3478
4155
|
return "internal";
|
|
3479
4156
|
if (isSpecFile2(path, specPaths))
|
|
3480
4157
|
return "spec";
|
|
3481
|
-
if (isProductScopeFile(path))
|
|
4158
|
+
if (isProductScopeFile(path, productPaths))
|
|
3482
4159
|
return "product";
|
|
3483
4160
|
return null;
|
|
3484
4161
|
}
|
|
@@ -3503,9 +4180,16 @@ function lineAt(content, index) {
|
|
|
3503
4180
|
}
|
|
3504
4181
|
return line;
|
|
3505
4182
|
}
|
|
3506
|
-
var
|
|
3507
|
-
var
|
|
3508
|
-
|
|
4183
|
+
var readerRules = rulesForGroup("reader-resolvable");
|
|
4184
|
+
var readerPattern = (id, scope = "prose") => {
|
|
4185
|
+
const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
|
|
4186
|
+
if (!(pattern instanceof RegExp))
|
|
4187
|
+
throw new Error(`default prose rule ${id} has no ${scope} pattern`);
|
|
4188
|
+
return pattern;
|
|
4189
|
+
};
|
|
4190
|
+
var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
|
|
4191
|
+
var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
|
|
4192
|
+
var TASK_NUMBER_PATTERN = readerPattern("task-number");
|
|
3509
4193
|
function legacySlugPattern(legacySlugs) {
|
|
3510
4194
|
if (legacySlugs.length === 0)
|
|
3511
4195
|
return null;
|
|
@@ -3515,48 +4199,61 @@ function legacySlugPattern(legacySlugs) {
|
|
|
3515
4199
|
function specGrandfatherPaths(specGrandfather) {
|
|
3516
4200
|
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
|
|
3517
4201
|
}
|
|
3518
|
-
|
|
4202
|
+
var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
|
|
4203
|
+
function referenceRulesFor(set, cls) {
|
|
4204
|
+
return rulesInScope(set, cls).filter((rule) => rule.group === "reader-resolvable" && rule.id !== "coined-term");
|
|
4205
|
+
}
|
|
4206
|
+
function citations(pattern, text, group) {
|
|
4207
|
+
const out = [];
|
|
4208
|
+
const re = pattern.global ? pattern : new RegExp(pattern.source, `${pattern.flags}g`);
|
|
4209
|
+
re.lastIndex = 0;
|
|
4210
|
+
let match = re.exec(text);
|
|
4211
|
+
while (match !== null) {
|
|
4212
|
+
if (match[0] === "") {
|
|
4213
|
+
re.lastIndex++;
|
|
4214
|
+
} else {
|
|
4215
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4216
|
+
out.push({ cited, index: match.index + match[0].indexOf(cited) });
|
|
4217
|
+
}
|
|
4218
|
+
match = re.exec(text);
|
|
4219
|
+
}
|
|
4220
|
+
re.lastIndex = 0;
|
|
4221
|
+
return out;
|
|
4222
|
+
}
|
|
4223
|
+
function customMessage(rule, cited) {
|
|
4224
|
+
return `${rule.id}: ${rule.message} ("${cited}")`;
|
|
4225
|
+
}
|
|
4226
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
4227
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4228
|
+
const productPaths = options.productPaths ?? PRODUCT_SLUG_SCOPE;
|
|
3519
4229
|
const findings = [];
|
|
3520
4230
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3521
4231
|
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
|
|
3522
4232
|
const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
|
|
3523
|
-
const patterns = [
|
|
3524
|
-
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3525
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3526
|
-
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3527
|
-
];
|
|
3528
|
-
const productPatterns = [
|
|
3529
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3530
|
-
];
|
|
3531
|
-
const specPatterns = [
|
|
3532
|
-
...patterns,
|
|
3533
|
-
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3534
|
-
];
|
|
3535
4233
|
for (const file of files) {
|
|
3536
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3537
|
-
if (!cls || cls
|
|
3538
|
-
continue;
|
|
3539
|
-
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
4234
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths, productPaths);
|
|
4235
|
+
if (!cls || !REFERENCE_CLASSES.has(cls))
|
|
3540
4236
|
continue;
|
|
3541
4237
|
if (cls === "spec" && grandfatheredWhole.has(file.path))
|
|
3542
4238
|
continue;
|
|
3543
|
-
const blocking = cls === "product" || cls === "spec";
|
|
3544
4239
|
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3545
|
-
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3546
4240
|
const fileFindings = [];
|
|
3547
|
-
for (const
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
4241
|
+
for (const rule of referenceRulesFor(set, cls)) {
|
|
4242
|
+
if (!ruleReads(set, rule, file.path))
|
|
4243
|
+
continue;
|
|
4244
|
+
const pattern = !rule.custom && rule.id === "legacy-batch-name" ? legacyPattern : rule.patternFor(cls);
|
|
4245
|
+
if (!pattern)
|
|
4246
|
+
continue;
|
|
4247
|
+
const blocking = rule.severity[cls] === "error";
|
|
4248
|
+
const what = cls === "product" ? `${rule.message} in product code` : rule.message;
|
|
4249
|
+
for (const { cited, index } of citations(pattern, scrubbed, rule.custom ? undefined : rule.reportGroup)) {
|
|
3553
4250
|
fileFindings.push({
|
|
3554
4251
|
file: file.path,
|
|
3555
|
-
line: lineAt(scrubbed,
|
|
3556
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3557
|
-
blocking
|
|
4252
|
+
line: lineAt(scrubbed, index),
|
|
4253
|
+
message: rule.custom ? customMessage(rule, cited) : `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4254
|
+
blocking,
|
|
4255
|
+
rule: rule.id
|
|
3558
4256
|
});
|
|
3559
|
-
match = pattern.exec(scrubbed);
|
|
3560
4257
|
}
|
|
3561
4258
|
}
|
|
3562
4259
|
const limit = cls === "spec" ? limits.get(file.path) : undefined;
|
|
@@ -3597,11 +4294,17 @@ function definesOrLinksGlossary(content, term) {
|
|
|
3597
4294
|
return true;
|
|
3598
4295
|
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3599
4296
|
}
|
|
3600
|
-
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4297
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, options = {}) {
|
|
3601
4298
|
const findings = [];
|
|
4299
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4300
|
+
const rule = set.rules.find((r) => !r.custom && r.id === "coined-term");
|
|
4301
|
+
if (!rule)
|
|
4302
|
+
return findings;
|
|
3602
4303
|
for (const file of files) {
|
|
3603
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3604
|
-
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
4304
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, DEFAULT_SPEC_PATHS, options.productPaths);
|
|
4305
|
+
if (!cls || !SWEPT_CLASSES.has(cls) || !rule.scopes.includes(cls))
|
|
4306
|
+
continue;
|
|
4307
|
+
if (!ruleReads(set, rule, file.path))
|
|
3605
4308
|
continue;
|
|
3606
4309
|
const scrubbed = stripNonProse(file.path, file.content);
|
|
3607
4310
|
for (const term of glossaryTerms) {
|
|
@@ -3614,14 +4317,15 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
|
|
|
3614
4317
|
file: file.path,
|
|
3615
4318
|
line,
|
|
3616
4319
|
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3617
|
-
blocking:
|
|
4320
|
+
blocking: rule.severity[cls] === "error",
|
|
4321
|
+
rule: rule.id
|
|
3618
4322
|
});
|
|
3619
4323
|
}
|
|
3620
4324
|
}
|
|
3621
4325
|
return findings;
|
|
3622
4326
|
}
|
|
3623
|
-
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN =
|
|
3624
|
-
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN =
|
|
4327
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
|
|
4328
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
|
|
3625
4329
|
function extractComments(path, content) {
|
|
3626
4330
|
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3627
4331
|
return content.replace(/[^\n]/g, "");
|
|
@@ -3718,39 +4422,40 @@ function extractComments(path, content) {
|
|
|
3718
4422
|
}
|
|
3719
4423
|
return out;
|
|
3720
4424
|
}
|
|
3721
|
-
function checkSourceComments(files, allowlist = []) {
|
|
4425
|
+
function checkSourceComments(files, allowlist = [], options = {}) {
|
|
3722
4426
|
const findings = [];
|
|
3723
4427
|
const allowed = new Set(allowlist);
|
|
3724
|
-
const
|
|
3725
|
-
|
|
3726
|
-
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3727
|
-
];
|
|
4428
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4429
|
+
const rules = rulesInScope(set, "source-comment").filter((rule) => rule.group === "reader-resolvable");
|
|
3728
4430
|
for (const file of files) {
|
|
3729
4431
|
if (!file.path.endsWith(".ts"))
|
|
3730
4432
|
continue;
|
|
3731
4433
|
if (allowed.has(file.path))
|
|
3732
4434
|
continue;
|
|
3733
4435
|
const comments = extractComments(file.path, file.content);
|
|
3734
|
-
for (const
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
4436
|
+
for (const rule of rules) {
|
|
4437
|
+
if (!ruleReads(set, rule, file.path))
|
|
4438
|
+
continue;
|
|
4439
|
+
const pattern = rule.patternFor("source-comment");
|
|
4440
|
+
if (!pattern)
|
|
4441
|
+
continue;
|
|
4442
|
+
for (const { cited, index } of citations(pattern, comments)) {
|
|
3738
4443
|
findings.push({
|
|
3739
4444
|
file: file.path,
|
|
3740
|
-
line: lineAt(comments,
|
|
3741
|
-
message: `comment cites ${
|
|
3742
|
-
blocking:
|
|
4445
|
+
line: lineAt(comments, index),
|
|
4446
|
+
message: rule.custom ? customMessage(rule, cited) : `comment cites ${rule.message} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4447
|
+
blocking: rule.severity["source-comment"] === "error",
|
|
4448
|
+
rule: rule.id
|
|
3743
4449
|
});
|
|
3744
|
-
match = pattern.exec(comments);
|
|
3745
4450
|
}
|
|
3746
4451
|
}
|
|
3747
4452
|
}
|
|
3748
4453
|
return findings;
|
|
3749
4454
|
}
|
|
3750
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4455
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
3751
4456
|
return [
|
|
3752
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3753
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4457
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths, options),
|
|
4458
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix, options)
|
|
3754
4459
|
];
|
|
3755
4460
|
}
|
|
3756
4461
|
function parseGlossaryTerms(glossaryContent) {
|
|
@@ -3953,6 +4658,17 @@ function checkDocClaims(files, fileReader) {
|
|
|
3953
4658
|
};
|
|
3954
4659
|
}
|
|
3955
4660
|
|
|
4661
|
+
// ../../packages/aeg-core/src/protected-paths.ts
|
|
4662
|
+
import { posix as posixPath } from "node:path";
|
|
4663
|
+
var PROTECTED_ADMIN_PATHS = ["vinaya.config.json", ".vinaya/doc-owners", ".github/", "aeg-root/"];
|
|
4664
|
+
function normalizeTouchedPath(path) {
|
|
4665
|
+
return posixPath.resolve("/", path.replace(/\\/g, "/")).replace(/^\/+/, "");
|
|
4666
|
+
}
|
|
4667
|
+
function isProtectedAdminPath(path) {
|
|
4668
|
+
const normalized = normalizeTouchedPath(path);
|
|
4669
|
+
return PROTECTED_ADMIN_PATHS.some((prefix) => normalized === prefix || normalized.startsWith(prefix));
|
|
4670
|
+
}
|
|
4671
|
+
|
|
3956
4672
|
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3957
4673
|
function hasRationaleField(body, labelPattern) {
|
|
3958
4674
|
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
@@ -4072,13 +4788,20 @@ function globCoversPath(glob, path) {
|
|
|
4072
4788
|
return !p.includes("/");
|
|
4073
4789
|
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
4074
4790
|
}
|
|
4791
|
+
function surfaceEntryResolves(entry, resolvesToFile, pinnedFiles) {
|
|
4792
|
+
if (resolvesToFile(entry))
|
|
4793
|
+
return true;
|
|
4794
|
+
const directory = entry.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
4795
|
+
return pinnedFiles.some((path) => path.startsWith(`${directory}/`));
|
|
4796
|
+
}
|
|
4075
4797
|
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
4076
4798
|
const surface = parseIssueSurface(body);
|
|
4077
4799
|
if (!surface.ok)
|
|
4078
4800
|
return { status: "pass", errors: [] };
|
|
4801
|
+
const pinnedFiles = boundaryPinnedFiles(body);
|
|
4079
4802
|
const errors = [];
|
|
4080
4803
|
for (const glob of surface.value.in) {
|
|
4081
|
-
if (!
|
|
4804
|
+
if (!surfaceEntryResolves(glob, resolvesToFile, pinnedFiles)) {
|
|
4082
4805
|
errors.push(`issue-validation Surface: \`${glob}\` in \`## Surface\`'s \`in:\` list matches no tracked file — a Surface that cannot resolve cannot render a brief's file list.`);
|
|
4083
4806
|
}
|
|
4084
4807
|
}
|
|
@@ -4108,6 +4831,14 @@ function recordedBeyondSurfacePaths(body) {
|
|
|
4108
4831
|
return paths;
|
|
4109
4832
|
}
|
|
4110
4833
|
function checkSurfaceScope(changedFiles, surface, recorded) {
|
|
4834
|
+
for (const path of changedFiles) {
|
|
4835
|
+
if (!isProtectedAdminPath(path))
|
|
4836
|
+
continue;
|
|
4837
|
+
const normalized = normalizeTouchedPath(path);
|
|
4838
|
+
if (!surface.in.some((glob) => globCoversPath(glob, normalized))) {
|
|
4839
|
+
return { ok: false, violation: { path, reason: "protected" } };
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4111
4842
|
const listed = new Set(recorded);
|
|
4112
4843
|
const violation = beyondSurfacePaths(changedFiles, surface).find((entry) => !listed.has(entry.path));
|
|
4113
4844
|
return violation ? { ok: false, violation } : { ok: true };
|
|
@@ -4163,12 +4894,22 @@ function checkPartsCiteDefinedObjectives(body) {
|
|
|
4163
4894
|
}
|
|
4164
4895
|
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4165
4896
|
}
|
|
4897
|
+
var ISSUE_LIVE_LINE_RE = /^-\s*\*{2}\[live\]\*{2}(.*)$/gim;
|
|
4898
|
+
function liveCommand(text) {
|
|
4899
|
+
const trimmed = text.trim();
|
|
4900
|
+
const span = /^(`+)(.+)\1$/.exec(trimmed);
|
|
4901
|
+
return span ? span[2].trim() : trimmed;
|
|
4902
|
+
}
|
|
4903
|
+
function liveItemsIn(region) {
|
|
4904
|
+
return [...region.matchAll(ISSUE_LIVE_LINE_RE)].map((m) => liveCommand(m[1] ?? "")).filter(Boolean);
|
|
4905
|
+
}
|
|
4906
|
+
function parseLiveTestPlanItems(body) {
|
|
4907
|
+
const located = locateTestPlanSection(body);
|
|
4908
|
+
return located.found ? liveItemsIn(located.section) : [];
|
|
4909
|
+
}
|
|
4166
4910
|
function isTaskIssueLabelSet(labels) {
|
|
4167
4911
|
return hasLabel("tranche", labels);
|
|
4168
4912
|
}
|
|
4169
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
4170
|
-
return { status: "pass", errors: [] };
|
|
4171
|
-
}
|
|
4172
4913
|
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4173
4914
|
if (!isTaskIssueLabelSet(labels))
|
|
4174
4915
|
return { status: "pass", errors: [] };
|
|
@@ -4184,6 +4925,7 @@ function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTi
|
|
|
4184
4925
|
};
|
|
4185
4926
|
}
|
|
4186
4927
|
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4928
|
+
var PATH_TEXT = (body) => stripCode(body, { inlineSpans: "keep" });
|
|
4187
4929
|
function isControlCodePoint(codePoint) {
|
|
4188
4930
|
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4189
4931
|
}
|
|
@@ -4244,8 +4986,14 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
|
4244
4986
|
}
|
|
4245
4987
|
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4246
4988
|
}
|
|
4989
|
+
function rationaleFieldText(text, labelPattern) {
|
|
4990
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})[^\\n]*\\n?([\\s\\S]*?)(?=\\n\\s*(?:\\*\\*[A-Z]|#{1,4}\\s)|(?![\\s\\S]))`, "im");
|
|
4991
|
+
const m = re.exec(text);
|
|
4992
|
+
return m ? m[0] : "";
|
|
4993
|
+
}
|
|
4247
4994
|
var DOC_PATH_RE = /(?:(?:aeg-root|apps|packages|specs|docs|tools|\.claude|\.github)\/[\w./@-]*\.(?:md|mdx)|\.claude\/(?:skills|rules)\/[\w./-]+|\b(?:docs-index|decisions|projects|state-machine|enforcement|process|README|CLAUDE)\.md\b|\b[\w-]+-(?:spec|decisions|backlog)\.md\b)/i;
|
|
4248
4995
|
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
4996
|
+
var RATIONALE_PATH_RE_GLOBAL = /`([\w.@-]+(?:\/[\w.@-]+)+)`/g;
|
|
4249
4997
|
function normalizeEdgeId(s) {
|
|
4250
4998
|
const qualified = splitSlugQualifiedEdge(s);
|
|
4251
4999
|
return (qualified ? qualified.bareId : s).replace(/^#/, "").trim();
|
|
@@ -4253,6 +5001,15 @@ function normalizeEdgeId(s) {
|
|
|
4253
5001
|
function edgesNameEachOther(a, b) {
|
|
4254
5002
|
return a.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(b.ref)) || b.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(a.ref));
|
|
4255
5003
|
}
|
|
5004
|
+
var BOUNDARY_OUT_RE = /\bOut\s*:\s*([\s\S]*)$/im;
|
|
5005
|
+
function boundaryOutText(body) {
|
|
5006
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5007
|
+
const m = BOUNDARY_OUT_RE.exec(boundary);
|
|
5008
|
+
return m ? m[1] : "";
|
|
5009
|
+
}
|
|
5010
|
+
function namedPathsIn(text) {
|
|
5011
|
+
return [...new Set([...text.matchAll(RATIONALE_PATH_RE_GLOBAL)].map((m) => m[1]))].filter((p) => !/^https?:\/\//i.test(p));
|
|
5012
|
+
}
|
|
4256
5013
|
var FILE_EXTENSIONS = new Set([
|
|
4257
5014
|
"ts",
|
|
4258
5015
|
"tsx",
|
|
@@ -4274,6 +5031,11 @@ var FILE_EXTENSIONS = new Set([
|
|
|
4274
5031
|
"html",
|
|
4275
5032
|
"css"
|
|
4276
5033
|
]);
|
|
5034
|
+
function boundaryPinnedFiles(body) {
|
|
5035
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5036
|
+
const excluded = new Set(namedPathsIn(boundaryOutText(body)));
|
|
5037
|
+
return namedPathsIn(boundary).filter((p) => looksLikeFilePath(p) && !excluded.has(p));
|
|
5038
|
+
}
|
|
4277
5039
|
var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
|
|
4278
5040
|
var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
|
|
4279
5041
|
|
|
@@ -4298,7 +5060,7 @@ function isGrandfathered(isoDate) {
|
|
|
4298
5060
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4299
5061
|
}
|
|
4300
5062
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4301
|
-
function checkA1(entries, principalAllowlist
|
|
5063
|
+
function checkA1(entries, principalAllowlist) {
|
|
4302
5064
|
const failures = [];
|
|
4303
5065
|
for (const e of entries) {
|
|
4304
5066
|
if (!e.facts)
|
|
@@ -4328,6 +5090,37 @@ function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
|
4328
5090
|
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4329
5091
|
};
|
|
4330
5092
|
}
|
|
5093
|
+
function checkA2(entries, hasProvenanceByKey) {
|
|
5094
|
+
const failures = [];
|
|
5095
|
+
for (const e of entries) {
|
|
5096
|
+
if (!e.facts)
|
|
5097
|
+
continue;
|
|
5098
|
+
if (e.facts.issueState !== "closed" || e.facts.prState !== "merged")
|
|
5099
|
+
continue;
|
|
5100
|
+
const key = `${e.trancheSlug}/${e.task.id}`;
|
|
5101
|
+
const hasProvenance = hasProvenanceByKey.get(key);
|
|
5102
|
+
if (hasProvenance === undefined)
|
|
5103
|
+
continue;
|
|
5104
|
+
if (!hasProvenance) {
|
|
5105
|
+
failures.push({
|
|
5106
|
+
code: "archived-without-provenance",
|
|
5107
|
+
issue: e.task.issue,
|
|
5108
|
+
tranche: e.trancheSlug,
|
|
5109
|
+
task: e.task.id,
|
|
5110
|
+
reason: "Closing PR has no `### AEG provenance` comment (Archivist close-out missing)",
|
|
5111
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
5112
|
+
});
|
|
5113
|
+
}
|
|
5114
|
+
}
|
|
5115
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
5116
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
5117
|
+
return {
|
|
5118
|
+
check: "A2",
|
|
5119
|
+
status,
|
|
5120
|
+
failures,
|
|
5121
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
5122
|
+
};
|
|
5123
|
+
}
|
|
4331
5124
|
function checkA3(entries) {
|
|
4332
5125
|
const failures = [];
|
|
4333
5126
|
for (const e of entries) {
|
|
@@ -4543,6 +5336,33 @@ function checkL1(files, entriesBySlug) {
|
|
|
4543
5336
|
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4544
5337
|
};
|
|
4545
5338
|
}
|
|
5339
|
+
function checkL2(files, entriesBySlug) {
|
|
5340
|
+
const failures = [];
|
|
5341
|
+
for (const f of files) {
|
|
5342
|
+
if (!f.archived)
|
|
5343
|
+
continue;
|
|
5344
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
5345
|
+
for (const e of entries) {
|
|
5346
|
+
if (!e.facts)
|
|
5347
|
+
continue;
|
|
5348
|
+
if (e.facts.issueState === "open") {
|
|
5349
|
+
failures.push({
|
|
5350
|
+
code: "premature-archive",
|
|
5351
|
+
issue: e.task.issue,
|
|
5352
|
+
tranche: f.slug,
|
|
5353
|
+
task: e.task.id,
|
|
5354
|
+
reason: `Archived tranche has open task-Issue #${e.task.issue ?? "?"} (premature archive)`
|
|
5355
|
+
});
|
|
5356
|
+
}
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
return {
|
|
5360
|
+
check: "L2",
|
|
5361
|
+
status: "info",
|
|
5362
|
+
failures,
|
|
5363
|
+
note: failures.length > 0 ? `${failures.length} archived tranche(s) with an open task-Issue — investigate (advisory)` : undefined
|
|
5364
|
+
};
|
|
5365
|
+
}
|
|
4546
5366
|
function checkL3(files) {
|
|
4547
5367
|
const active = files.filter((f) => !f.archived);
|
|
4548
5368
|
return {
|
|
@@ -4552,6 +5372,51 @@ function checkL3(files) {
|
|
|
4552
5372
|
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4553
5373
|
};
|
|
4554
5374
|
}
|
|
5375
|
+
function checkL4(activeTrancheSlugs, issueMilestones) {
|
|
5376
|
+
const activeSet = new Set(activeTrancheSlugs);
|
|
5377
|
+
const failures = [];
|
|
5378
|
+
for (const f of issueMilestones) {
|
|
5379
|
+
if (!activeSet.has(f.tranche))
|
|
5380
|
+
continue;
|
|
5381
|
+
if (f.milestoneTitle === f.tranche)
|
|
5382
|
+
continue;
|
|
5383
|
+
failures.push({
|
|
5384
|
+
code: "milestone-drift",
|
|
5385
|
+
issue: f.issue,
|
|
5386
|
+
tranche: f.tranche,
|
|
5387
|
+
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`
|
|
5388
|
+
});
|
|
5389
|
+
}
|
|
5390
|
+
return {
|
|
5391
|
+
check: "L4",
|
|
5392
|
+
status: "info",
|
|
5393
|
+
failures,
|
|
5394
|
+
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
|
|
5395
|
+
};
|
|
5396
|
+
}
|
|
5397
|
+
function checkL5(activeTrancheSlugs, entriesBySlug) {
|
|
5398
|
+
const failures = [];
|
|
5399
|
+
for (const slug of activeTrancheSlugs) {
|
|
5400
|
+
const entries = entriesBySlug.get(slug) ?? [];
|
|
5401
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
5402
|
+
if (withFacts.length === 0)
|
|
5403
|
+
continue;
|
|
5404
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
5405
|
+
if (allClosed) {
|
|
5406
|
+
failures.push({
|
|
5407
|
+
code: "tranche-not-archived",
|
|
5408
|
+
tranche: slug,
|
|
5409
|
+
reason: "Every task Issue is closed but the tranche is not recorded as complete — archive it"
|
|
5410
|
+
});
|
|
5411
|
+
}
|
|
5412
|
+
}
|
|
5413
|
+
return {
|
|
5414
|
+
check: "L5",
|
|
5415
|
+
status: failures.length > 0 ? "fail" : "pass",
|
|
5416
|
+
failures,
|
|
5417
|
+
note: failures.length > 0 ? `${failures.length} tranche(s) whose task Issues are all closed but were never archived` : undefined
|
|
5418
|
+
};
|
|
5419
|
+
}
|
|
4555
5420
|
function extractClosesReferences(prBody) {
|
|
4556
5421
|
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4557
5422
|
const stripped = stripCode(prBody);
|
|
@@ -4647,6 +5512,58 @@ function extractIssue(body) {
|
|
|
4647
5512
|
}
|
|
4648
5513
|
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4649
5514
|
import { createHash as createHash4 } from "node:crypto";
|
|
5515
|
+
|
|
5516
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
5517
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
5518
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
5519
|
+
let best = 0;
|
|
5520
|
+
for (const c of comments) {
|
|
5521
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5522
|
+
continue;
|
|
5523
|
+
const firstLine = (c.body.split(`
|
|
5524
|
+
`)[0] ?? "").trim();
|
|
5525
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
5526
|
+
if (!m)
|
|
5527
|
+
continue;
|
|
5528
|
+
const k = Number.parseInt(m[1], 10);
|
|
5529
|
+
if (k > best)
|
|
5530
|
+
best = k;
|
|
5531
|
+
}
|
|
5532
|
+
return best;
|
|
5533
|
+
}
|
|
5534
|
+
function parseRulingIdentity(rulingId) {
|
|
5535
|
+
const m = /^(issue-)?(\d+)-(\d+)$/.exec(rulingId);
|
|
5536
|
+
if (!m)
|
|
5537
|
+
return null;
|
|
5538
|
+
const ref = Number.parseInt(m[2], 10);
|
|
5539
|
+
const ordinal = Number.parseInt(m[3], 10);
|
|
5540
|
+
if (ref <= 0 || ordinal <= 0)
|
|
5541
|
+
return null;
|
|
5542
|
+
return { target: m[1] ? "issue" : "pr", ref, ordinal };
|
|
5543
|
+
}
|
|
5544
|
+
function principalRulingTextById(comments, allowlist, rulingId) {
|
|
5545
|
+
const identity = parseRulingIdentity(rulingId);
|
|
5546
|
+
if (identity === null)
|
|
5547
|
+
return null;
|
|
5548
|
+
const matches = comments.filter((c) => {
|
|
5549
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5550
|
+
return false;
|
|
5551
|
+
const m = RULING_MARKER_ORDINAL.exec((c.body.split(`
|
|
5552
|
+
`)[0] ?? "").trim());
|
|
5553
|
+
return m !== null && Number.parseInt(m[1], 10) === identity.ordinal;
|
|
5554
|
+
});
|
|
5555
|
+
if (matches.length !== 1)
|
|
5556
|
+
return null;
|
|
5557
|
+
const body = matches[0].body;
|
|
5558
|
+
const idx = body.indexOf(`
|
|
5559
|
+
`);
|
|
5560
|
+
return idx === -1 ? "" : body.slice(idx + 1).trim();
|
|
5561
|
+
}
|
|
5562
|
+
|
|
5563
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
5564
|
+
function pauseBoundRulingDigest(rulingText) {
|
|
5565
|
+
return createHash4("sha256").update(rulingText).digest("hex");
|
|
5566
|
+
}
|
|
4650
5567
|
function briefHash(brief) {
|
|
4651
5568
|
return createHash4("sha256").update(`${brief}
|
|
4652
5569
|
`).digest("hex");
|
|
@@ -4707,14 +5624,19 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4707
5624
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4708
5625
|
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4709
5626
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
5627
|
+
const legacyCurrent = current.manifestVersion === undefined;
|
|
5628
|
+
const manifestVersion = legacyCurrent ? echoed.manifestVersion === undefined || echoed.manifestVersion === null : echoed.manifestVersion === current.manifestVersion;
|
|
5629
|
+
const pauseBoundRuling = legacyCurrent ? true : Object.hasOwn(echoed, "pauseBoundRuling") && JSON.stringify(echoed.pauseBoundRuling) === JSON.stringify(current.pauseBoundRuling);
|
|
4710
5630
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4711
5631
|
return {
|
|
4712
|
-
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
5632
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && pauseBoundRuling && manifestVersion && policyDigestBound,
|
|
4713
5633
|
head,
|
|
4714
5634
|
base,
|
|
4715
5635
|
briefHash: briefHashBound,
|
|
4716
5636
|
objectivesVersion,
|
|
4717
5637
|
rulingOrdinal,
|
|
5638
|
+
pauseBoundRuling,
|
|
5639
|
+
manifestVersion,
|
|
4718
5640
|
policyDigest: policyDigestBound
|
|
4719
5641
|
};
|
|
4720
5642
|
}
|
|
@@ -4730,7 +5652,7 @@ function renderGateDeferred(deferred) {
|
|
|
4730
5652
|
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4731
5653
|
}
|
|
4732
5654
|
function checkReviewGate(input) {
|
|
4733
|
-
const principalAllowlist = input
|
|
5655
|
+
const { principalAllowlist } = input;
|
|
4734
5656
|
const waived = isWaiverLabelActorVerified({
|
|
4735
5657
|
label: WAIVER_LABEL_REVIEW,
|
|
4736
5658
|
labels: input.labels,
|
|
@@ -4769,27 +5691,33 @@ function checkReviewGate(input) {
|
|
|
4769
5691
|
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4770
5692
|
const securityClean = securityTextClean && securityPolicyClean;
|
|
4771
5693
|
const currentManifest = {
|
|
5694
|
+
...input.manifestVersion === undefined ? {} : { manifestVersion: input.manifestVersion },
|
|
4772
5695
|
headSha: input.headSha,
|
|
4773
5696
|
baseSha: input.baseSha ?? null,
|
|
4774
5697
|
briefHash: input.briefHash ?? null,
|
|
4775
5698
|
objectivesVersion: input.objectivesVersion,
|
|
4776
5699
|
rulingOrdinal: input.rulingOrdinal,
|
|
5700
|
+
pauseBoundRuling: input.pauseBoundRuling ?? null,
|
|
4777
5701
|
policyDigest: policyDigest(policy)
|
|
4778
5702
|
};
|
|
4779
5703
|
const codeReviewEchoed = {
|
|
5704
|
+
manifestVersion: codeReview.manifestVersion,
|
|
4780
5705
|
headSha: codeReview.headSha,
|
|
4781
5706
|
baseSha: codeReview.baseSha,
|
|
4782
5707
|
briefHash: codeReview.briefHash,
|
|
4783
5708
|
objectivesVersion: codeReview.objectivesVersion,
|
|
4784
5709
|
rulingOrdinal: codeReview.rulingOrdinal,
|
|
5710
|
+
pauseBoundRuling: codeReview.pauseBoundRuling,
|
|
4785
5711
|
policyDigest: codeReview.policyDigest
|
|
4786
5712
|
};
|
|
4787
5713
|
const securityEchoed = {
|
|
5714
|
+
manifestVersion: security.manifestVersion,
|
|
4788
5715
|
headSha: security.headSha,
|
|
4789
5716
|
baseSha: security.baseSha,
|
|
4790
5717
|
briefHash: security.briefHash,
|
|
4791
5718
|
objectivesVersion: security.objectivesVersion,
|
|
4792
5719
|
rulingOrdinal: security.rulingOrdinal,
|
|
5720
|
+
pauseBoundRuling: security.pauseBoundRuling,
|
|
4793
5721
|
policyDigest: security.policyDigest
|
|
4794
5722
|
};
|
|
4795
5723
|
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
@@ -4828,6 +5756,10 @@ function checkReviewGate(input) {
|
|
|
4828
5756
|
problems.push(`the newest code-review verdict was cast against brief hash ${codeReview.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
|
|
4829
5757
|
} else if (!codeReviewBinding.policyDigest) {
|
|
4830
5758
|
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}`);
|
|
5759
|
+
} else if (!codeReviewBinding.manifestVersion) {
|
|
5760
|
+
problems.push(`the newest code-review verdict echoes manifest version ${codeReview.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5761
|
+
} else if (!codeReviewBinding.pauseBoundRuling) {
|
|
5762
|
+
problems.push(`the newest code-review verdict echoes pauseBoundRuling ${renderBinding(codeReview.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4831
5763
|
}
|
|
4832
5764
|
if (!securityTextClean) {
|
|
4833
5765
|
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
@@ -4845,6 +5777,10 @@ function checkReviewGate(input) {
|
|
|
4845
5777
|
problems.push(`the newest security-review verdict was cast against brief hash ${security.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
|
|
4846
5778
|
} else if (!securityBinding.policyDigest) {
|
|
4847
5779
|
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}`);
|
|
5780
|
+
} else if (!securityBinding.manifestVersion) {
|
|
5781
|
+
problems.push(`the newest security-review verdict echoes manifest version ${security.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5782
|
+
} else if (!securityBinding.pauseBoundRuling) {
|
|
5783
|
+
problems.push(`the newest security-review verdict echoes pauseBoundRuling ${renderBinding(security.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4848
5784
|
}
|
|
4849
5785
|
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4850
5786
|
return {
|
|
@@ -4853,29 +5789,16 @@ function checkReviewGate(input) {
|
|
|
4853
5789
|
waived: false
|
|
4854
5790
|
};
|
|
4855
5791
|
}
|
|
5792
|
+
function renderBinding(binding) {
|
|
5793
|
+
if (binding === undefined)
|
|
5794
|
+
return "(absent)";
|
|
5795
|
+
return binding === null ? "(none)" : `${binding.rulingId}|${binding.pauseId}|${binding.contentDigest}`;
|
|
5796
|
+
}
|
|
4856
5797
|
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4857
5798
|
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4858
5799
|
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4859
5800
|
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4860
5801
|
}
|
|
4861
|
-
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4862
|
-
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4863
|
-
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4864
|
-
let best = 0;
|
|
4865
|
-
for (const c of comments) {
|
|
4866
|
-
if (!isPrincipal(c.author, allowlist))
|
|
4867
|
-
continue;
|
|
4868
|
-
const firstLine = (c.body.split(`
|
|
4869
|
-
`)[0] ?? "").trim();
|
|
4870
|
-
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4871
|
-
if (!m)
|
|
4872
|
-
continue;
|
|
4873
|
-
const k = Number.parseInt(m[1], 10);
|
|
4874
|
-
if (k > best)
|
|
4875
|
-
best = k;
|
|
4876
|
-
}
|
|
4877
|
-
return best;
|
|
4878
|
-
}
|
|
4879
5802
|
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4880
5803
|
function splitRow(line) {
|
|
4881
5804
|
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
@@ -5027,7 +5950,6 @@ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
|
5027
5950
|
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
5028
5951
|
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
5029
5952
|
"apps/cli/src/checks/bin/check-dead-branch-push.ts": 'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
|
|
5030
|
-
"apps/cli/src/checks/bin/check-issue-assignment.ts": `Ring 0 "A task branch's first push (Issue self-assignment)" (implementation: assign-task-issue.ts)`,
|
|
5031
5953
|
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
5032
5954
|
};
|
|
5033
5955
|
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
@@ -5251,72 +6173,10 @@ function compareToBaseline(current, baseline) {
|
|
|
5251
6173
|
};
|
|
5252
6174
|
}
|
|
5253
6175
|
// ../../packages/aeg-core/src/retired-vocabulary.ts
|
|
5254
|
-
var
|
|
5255
|
-
var RETIRED_PATTERNS =
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
"decision (entry|logged)",
|
|
5259
|
-
"decision-log entry",
|
|
5260
|
-
"decision log entry",
|
|
5261
|
-
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
5262
|
-
"decision-log",
|
|
5263
|
-
"decision entr",
|
|
5264
|
-
"decisions? (are |is )?logged",
|
|
5265
|
-
"log entries",
|
|
5266
|
-
String.raw`decisions\.md`,
|
|
5267
|
-
"decisions-legacy",
|
|
5268
|
-
"CONTRADICTION",
|
|
5269
|
-
"assumes Tier 3",
|
|
5270
|
-
"Lock: ?YES",
|
|
5271
|
-
"Lock: ?NO",
|
|
5272
|
-
"lock approvals?",
|
|
5273
|
-
"approves locks",
|
|
5274
|
-
"Conforms to lock",
|
|
5275
|
-
"Challenges lock",
|
|
5276
|
-
"checkDecisionNumbersFresh",
|
|
5277
|
-
String.raw`roles/team-leader\.md`,
|
|
5278
|
-
String.raw`\(,`,
|
|
5279
|
-
String.raw`,\)`,
|
|
5280
|
-
String.raw`\(\.\)`,
|
|
5281
|
-
...PLAN_ON_DISK_PATTERNS
|
|
5282
|
-
];
|
|
5283
|
-
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
5284
|
-
var RETIRED_EXEMPT_SUBSTRINGS = [
|
|
5285
|
-
"docs/decisions-legacy.md",
|
|
5286
|
-
"apps/herald-ai/docs/",
|
|
5287
|
-
"apps/vada-ai/docs/",
|
|
5288
|
-
"aeg-root/tranches/completed/",
|
|
5289
|
-
"packages/aeg-core/src/docs/published-prose",
|
|
5290
|
-
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
5291
|
-
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
5292
|
-
"/fixtures/",
|
|
5293
|
-
"/node_modules/",
|
|
5294
|
-
"/.next/",
|
|
5295
|
-
"/.turbo/"
|
|
5296
|
-
];
|
|
5297
|
-
var PATTERN_EXEMPT = {
|
|
5298
|
-
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
5299
|
-
[String.raw`decisions\.md`]: [
|
|
5300
|
-
"docs-index.md",
|
|
5301
|
-
"apps/vada-ai/specs/legacy/README.md",
|
|
5302
|
-
"apps/vada-ai/specs/vada-product-spec.md",
|
|
5303
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5304
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5305
|
-
],
|
|
5306
|
-
"decisions-legacy": [
|
|
5307
|
-
"packages/aeg-core/src/file-classify.ts",
|
|
5308
|
-
"packages/aeg-core/src/file-classify.test.ts",
|
|
5309
|
-
"packages/aeg-core/src/pr-tier.test.ts",
|
|
5310
|
-
"docs-index.md",
|
|
5311
|
-
".claude/skills/database/SKILL.md",
|
|
5312
|
-
".claude/skills/vada-architecture/SKILL.md",
|
|
5313
|
-
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
5314
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5315
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5316
|
-
],
|
|
5317
|
-
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
5318
|
-
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
5319
|
-
};
|
|
6176
|
+
var retiredRules = rulesForGroup("retired-vocabulary");
|
|
6177
|
+
var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
|
|
6178
|
+
var PATTERN_EXEMPT = RETIRED_PATTERN_EXEMPTIONS;
|
|
6179
|
+
var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
|
|
5320
6180
|
function lineNumbers(content, pattern) {
|
|
5321
6181
|
const out = [];
|
|
5322
6182
|
const lines = content.split(`
|
|
@@ -5327,22 +6187,29 @@ function lineNumbers(content, pattern) {
|
|
|
5327
6187
|
}
|
|
5328
6188
|
return out;
|
|
5329
6189
|
}
|
|
5330
|
-
function scanRetiredVocabulary(files) {
|
|
6190
|
+
function scanRetiredVocabulary(files, rules = DEFAULT_PROSE_RULE_SET) {
|
|
5331
6191
|
const findings = [];
|
|
6192
|
+
const retired = rulesOfGroup(rules, "retired-vocabulary");
|
|
5332
6193
|
for (const file of files) {
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
6194
|
+
for (const rule of retired) {
|
|
6195
|
+
if (rule.substringExempt.some((e) => file.path.includes(e)))
|
|
6196
|
+
continue;
|
|
6197
|
+
if (!ruleReads(rules, rule, file.path))
|
|
6198
|
+
continue;
|
|
6199
|
+
const re = rule.patternFor("repository");
|
|
6200
|
+
if (!re)
|
|
6201
|
+
continue;
|
|
6202
|
+
const pattern = rule.custom ? re.source : DEFAULT_PATTERN_OF.get(rule.id) ?? re.source;
|
|
6203
|
+
if (!rule.custom && (PATTERN_EXEMPT[pattern] ?? []).some((e) => file.path.includes(e)))
|
|
5338
6204
|
continue;
|
|
5339
|
-
const re = new RegExp(pattern);
|
|
5340
6205
|
for (const line of lineNumbers(file.content, re)) {
|
|
5341
6206
|
findings.push({
|
|
5342
6207
|
file: file.path,
|
|
5343
6208
|
line,
|
|
5344
6209
|
pattern,
|
|
5345
|
-
message: `claims a retired AEG mechanism is still live (matches /${pattern}/)
|
|
6210
|
+
message: rule.custom ? `${rule.id}: ${rule.message} (matches /${pattern}/)` : `claims a retired AEG mechanism is still live (matches /${pattern}/)`,
|
|
6211
|
+
rule: rule.id,
|
|
6212
|
+
blocking: rule.severity.repository === "error"
|
|
5346
6213
|
});
|
|
5347
6214
|
}
|
|
5348
6215
|
}
|
|
@@ -5366,7 +6233,7 @@ function isSelfDependency(dep, task, issue) {
|
|
|
5366
6233
|
function checkDispatchReadiness(input) {
|
|
5367
6234
|
const { trancheSlug, task } = input;
|
|
5368
6235
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
5369
|
-
const principalAllowlist = input
|
|
6236
|
+
const { principalAllowlist } = input;
|
|
5370
6237
|
const blockerDetails = [];
|
|
5371
6238
|
const push = (blockerClass, message) => {
|
|
5372
6239
|
blockerDetails.push({ class: blockerClass, message });
|
|
@@ -5458,6 +6325,16 @@ function pushesAnyBranchRef(pushRefs) {
|
|
|
5458
6325
|
return pushRefs.split(`
|
|
5459
6326
|
`).map((line) => line.trim()).filter((line) => line.length > 0).some((line) => line.split(/\s+/)[2]?.startsWith("refs/heads/") === true);
|
|
5460
6327
|
}
|
|
6328
|
+
function resolveDefaultBranch(facts) {
|
|
6329
|
+
const { originHead, hasOriginMain, hasOriginMaster } = facts;
|
|
6330
|
+
if (originHead !== null && originHead !== "")
|
|
6331
|
+
return originHead;
|
|
6332
|
+
if (hasOriginMain)
|
|
6333
|
+
return "main";
|
|
6334
|
+
if (hasOriginMaster)
|
|
6335
|
+
return "master";
|
|
6336
|
+
return null;
|
|
6337
|
+
}
|
|
5461
6338
|
function checkMainBranchRefusal(facts) {
|
|
5462
6339
|
const { currentSymbolicBranch, defaultBranch, pushRefs = null } = facts;
|
|
5463
6340
|
if (currentSymbolicBranch === null)
|
|
@@ -5718,54 +6595,61 @@ function checkFirstPushDispatchGate(input) {
|
|
|
5718
6595
|
reason: `verify-dispatch reports READY TO DISPATCH for \`${branch}\`.`
|
|
5719
6596
|
};
|
|
5720
6597
|
}
|
|
5721
|
-
// ../../packages/aeg-core/src/
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
6598
|
+
// ../../packages/aeg-core/src/live-record.ts
|
|
6599
|
+
var RECORD_LINE_RE = /^-\s*\[([ xX])\]\s*\*\*\[live\]\*\*\s+(`+) ?(.+?) ?\2(?!`)\s+—\s+(passed|failed|unverified)\s+at\s+`([^`]+)`/;
|
|
6600
|
+
function liveMarkers(body) {
|
|
6601
|
+
const masked = maskCode(body);
|
|
6602
|
+
return [...masked.matchAll(/<!--\s*AEG:LIVE:(?:START|END)\s*-->/g)].map((m) => ({
|
|
6603
|
+
start: m.index,
|
|
6604
|
+
end: m.index + m[0].length
|
|
6605
|
+
}));
|
|
6606
|
+
}
|
|
6607
|
+
var AMBIGUOUS_RECORD_LINE = {
|
|
6608
|
+
line: "- [ ] **[live]** the pull request body carries more than one `AEG:LIVE` marker pair, so the driver's record cannot be told apart",
|
|
6609
|
+
ticked: false,
|
|
6610
|
+
command: "",
|
|
6611
|
+
outcome: "failed",
|
|
6612
|
+
head: ""
|
|
6613
|
+
};
|
|
6614
|
+
function readLiveRecord(body) {
|
|
6615
|
+
const markers = liveMarkers(body).length;
|
|
6616
|
+
if (markers === 0)
|
|
6617
|
+
return [];
|
|
6618
|
+
if (markers !== 2)
|
|
6619
|
+
return [AMBIGUOUS_RECORD_LINE];
|
|
6620
|
+
const region = anchoredRegion(body, "LIVE");
|
|
6621
|
+
if (region === null)
|
|
6622
|
+
return [];
|
|
6623
|
+
const lines = [];
|
|
6624
|
+
for (const raw of region.split(`
|
|
6625
|
+
`)) {
|
|
6626
|
+
const line = raw.trim();
|
|
6627
|
+
const m = RECORD_LINE_RE.exec(line);
|
|
6628
|
+
if (!m)
|
|
6629
|
+
continue;
|
|
6630
|
+
lines.push({
|
|
6631
|
+
line,
|
|
6632
|
+
ticked: m[1].toLowerCase() === "x",
|
|
6633
|
+
command: m[3],
|
|
6634
|
+
outcome: m[4],
|
|
6635
|
+
head: m[5]
|
|
6636
|
+
});
|
|
5759
6637
|
}
|
|
5760
|
-
return
|
|
5761
|
-
action: "assign",
|
|
5762
|
-
issue,
|
|
5763
|
-
login,
|
|
5764
|
-
reason: `First push of \`${branch}\` — assigning Issue #${issue} to @${login} (the authenticated pusher).`
|
|
5765
|
-
};
|
|
6638
|
+
return lines;
|
|
5766
6639
|
}
|
|
5767
6640
|
// ../../packages/aeg-core/src/test-plan-gate.ts
|
|
5768
|
-
function
|
|
6641
|
+
function gradedLiveLines(record, live) {
|
|
6642
|
+
if (live === undefined)
|
|
6643
|
+
return record.map((entry) => entry.line);
|
|
6644
|
+
const commands = new Set(live.liveCommands);
|
|
6645
|
+
const others = record.filter((entry) => !commands.has(entry.command)).map((entry) => entry.line);
|
|
6646
|
+
const graded = live.liveCommands.map((command) => {
|
|
6647
|
+
const atHead = record.filter((entry) => entry.command === command && entry.head === live.head);
|
|
6648
|
+
return (atHead.find((entry) => entry.ticked) ?? atHead[0])?.line ?? `- [ ] **[live]** \`${command}\` — no passed run recorded at \`${live.head || "an unknown head"}\``;
|
|
6649
|
+
});
|
|
6650
|
+
return [...others, ...graded];
|
|
6651
|
+
}
|
|
6652
|
+
function evaluateTestPlanGate(body, branch, live) {
|
|
5769
6653
|
if (!body) {
|
|
5770
6654
|
return {
|
|
5771
6655
|
verdict: "pass",
|
|
@@ -5776,7 +6660,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5776
6660
|
};
|
|
5777
6661
|
}
|
|
5778
6662
|
const located = locateTestPlanSection(body);
|
|
5779
|
-
|
|
6663
|
+
const liveLines = gradedLiveLines(readLiveRecord(body), live);
|
|
6664
|
+
const liveUnticked = liveLines.some((line) => /^[-*]\s+\[\s\]/.test(line));
|
|
6665
|
+
if (!located.found && !liveUnticked) {
|
|
5780
6666
|
if (parseTaskBranchIdentity(branch) !== null) {
|
|
5781
6667
|
return {
|
|
5782
6668
|
verdict: "fail",
|
|
@@ -5796,15 +6682,18 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5796
6682
|
]
|
|
5797
6683
|
};
|
|
5798
6684
|
}
|
|
5799
|
-
const section = located.section;
|
|
5800
|
-
if (/unit-tests-only/i.test(section)) {
|
|
6685
|
+
const section = located.found ? located.section : "";
|
|
6686
|
+
if (/unit-tests-only/i.test(section) && !liveUnticked) {
|
|
5801
6687
|
return {
|
|
5802
6688
|
verdict: "pass",
|
|
5803
6689
|
messages: ["Test Plan: unit-tests-only — pure-logic brief, CI unit-tests are the proof.", "PASS."]
|
|
5804
6690
|
};
|
|
5805
6691
|
}
|
|
5806
|
-
const checkboxLines =
|
|
5807
|
-
|
|
6692
|
+
const checkboxLines = [
|
|
6693
|
+
...section.split(`
|
|
6694
|
+
`).map((line) => line.trimStart()).filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line)),
|
|
6695
|
+
...liveLines
|
|
6696
|
+
];
|
|
5808
6697
|
if (checkboxLines.length === 0) {
|
|
5809
6698
|
return {
|
|
5810
6699
|
verdict: "pass",
|
|
@@ -5821,7 +6710,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5821
6710
|
messages.push("", "FAIL — the following [principal] Test Plan items are unticked:");
|
|
5822
6711
|
for (const line of unchecked)
|
|
5823
6712
|
messages.push(` ${line}`);
|
|
5824
|
-
messages.push("", "Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.", "The Principal runs the item in a real signed-in browser and ticks the box.",
|
|
6713
|
+
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 ? [
|
|
6714
|
+
"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."
|
|
6715
|
+
] : [], "Note: editing the PR body does not retrigger most workflows. If your PR body changes do not surface here, push an empty commit to re-run.");
|
|
5825
6716
|
return { verdict: "fail", messages };
|
|
5826
6717
|
}
|
|
5827
6718
|
messages.push("All [principal] Test Plan items ticked — runtime verification complete.", "PASS.");
|
|
@@ -6010,9 +6901,11 @@ var LineageSchema = z3.object({
|
|
|
6010
6901
|
parent: z3.string().nullable()
|
|
6011
6902
|
}).strict();
|
|
6012
6903
|
var InputVersionsSchema = z3.object({
|
|
6904
|
+
manifest_version: z3.literal(2).nullable().optional(),
|
|
6013
6905
|
objectives_version: z3.string().nullable(),
|
|
6014
6906
|
brief_hash: z3.string().nullable(),
|
|
6015
6907
|
ruling_ordinal: z3.number().int().nullable(),
|
|
6908
|
+
pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
|
|
6016
6909
|
policy_digest: z3.string().nullable()
|
|
6017
6910
|
}).strict();
|
|
6018
6911
|
var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
@@ -6050,7 +6943,17 @@ var HeaderMetaV3Schema = z3.object({
|
|
|
6050
6943
|
runtime: z3.string().nullable(),
|
|
6051
6944
|
source: z3.string().nullable()
|
|
6052
6945
|
}).strict();
|
|
6053
|
-
var
|
|
6946
|
+
var HeaderMetaV4Schema = HeaderMetaV3Schema.extend({
|
|
6947
|
+
schema: z3.literal(4),
|
|
6948
|
+
process: z3.object({ id: z3.string(), version: z3.string().nullable(), digest: z3.string().nullable() }).strict(),
|
|
6949
|
+
runner: z3.object({ id: z3.string(), version: z3.string().nullable() }).strict()
|
|
6950
|
+
}).strict();
|
|
6951
|
+
var HeaderMetaSchema = z3.discriminatedUnion("schema", [
|
|
6952
|
+
HeaderMetaV1Schema,
|
|
6953
|
+
HeaderMetaV2Schema,
|
|
6954
|
+
HeaderMetaV3Schema,
|
|
6955
|
+
HeaderMetaV4Schema
|
|
6956
|
+
]);
|
|
6054
6957
|
var SubjectSchema = z3.object({
|
|
6055
6958
|
issue: z3.number().int().nullable(),
|
|
6056
6959
|
pr: z3.number().int().optional(),
|
|
@@ -6272,30 +7175,99 @@ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
|
|
|
6272
7175
|
}).strict(),
|
|
6273
7176
|
z3.object({
|
|
6274
7177
|
...loopShared,
|
|
6275
|
-
event: z3.literal("
|
|
7178
|
+
event: z3.literal("conflict_reentry"),
|
|
6276
7179
|
task: z3.number().int(),
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
7180
|
+
pr: z3.number().int().positive(),
|
|
7181
|
+
attempt: z3.number().int().positive(),
|
|
7182
|
+
bound: z3.number().int().positive()
|
|
7183
|
+
}).strict(),
|
|
7184
|
+
z3.object({
|
|
7185
|
+
...loopShared,
|
|
7186
|
+
event: z3.literal("storage_push"),
|
|
7187
|
+
round: z3.number().int(),
|
|
7188
|
+
branch: z3.string(),
|
|
7189
|
+
head: z3.string()
|
|
7190
|
+
}).strict(),
|
|
7191
|
+
z3.object({
|
|
7192
|
+
...loopShared,
|
|
7193
|
+
event: z3.literal("local_checks_run"),
|
|
7194
|
+
round: z3.number().int(),
|
|
7195
|
+
head: z3.string().nullable(),
|
|
7196
|
+
passed: z3.boolean(),
|
|
7197
|
+
wall_ms: z3.number().nonnegative()
|
|
7198
|
+
}).strict(),
|
|
7199
|
+
z3.object({
|
|
7200
|
+
...loopShared,
|
|
7201
|
+
event: z3.literal("ready_push"),
|
|
7202
|
+
round: z3.number().int(),
|
|
7203
|
+
head: z3.string(),
|
|
7204
|
+
outcome: z3.enum(["passed", "refused"]),
|
|
7205
|
+
selected: z3.number().int().nonnegative(),
|
|
7206
|
+
failed: z3.number().int().nonnegative(),
|
|
7207
|
+
rerun: z3.boolean(),
|
|
7208
|
+
wall_ms: z3.number().nonnegative()
|
|
7209
|
+
}).strict(),
|
|
7210
|
+
z3.object({
|
|
7211
|
+
...loopShared,
|
|
7212
|
+
event: z3.literal("failed_tests_rerun"),
|
|
7213
|
+
round: z3.number().int(),
|
|
7214
|
+
head: z3.string(),
|
|
7215
|
+
rerun_of: z3.string(),
|
|
7216
|
+
failed_files: z3.number().int().nonnegative(),
|
|
7217
|
+
affected_files: z3.number().int().nonnegative(),
|
|
7218
|
+
full_count: z3.number().int().nonnegative()
|
|
7219
|
+
}).strict(),
|
|
7220
|
+
z3.object({
|
|
7221
|
+
...loopShared,
|
|
7222
|
+
event: z3.literal("pr_opened"),
|
|
7223
|
+
round: z3.number().int(),
|
|
7224
|
+
pr: z3.number().int().positive(),
|
|
7225
|
+
head: z3.string()
|
|
7226
|
+
}).strict(),
|
|
7227
|
+
z3.object({
|
|
7228
|
+
...loopShared,
|
|
7229
|
+
event: z3.literal("ci_result_read"),
|
|
7230
|
+
round: z3.number().int(),
|
|
7231
|
+
pr: z3.number().int().positive(),
|
|
7232
|
+
head: z3.string(),
|
|
7233
|
+
conclusion: z3.enum(["green", "red", "pending", "skipped"]),
|
|
7234
|
+
failing_checks: z3.array(z3.string()),
|
|
7235
|
+
wait_ms: z3.number().nonnegative()
|
|
7236
|
+
}).strict(),
|
|
7237
|
+
z3.object({
|
|
7238
|
+
...loopShared,
|
|
7239
|
+
event: z3.literal("phase_time"),
|
|
7240
|
+
round: z3.number().int(),
|
|
7241
|
+
phase: z3.enum(["developer", "local_checks", "review", "push", "ci", "other"]),
|
|
7242
|
+
step: z3.string(),
|
|
7243
|
+
wall_ms: z3.number().nonnegative()
|
|
7244
|
+
}).strict(),
|
|
7245
|
+
z3.object({
|
|
7246
|
+
...loopShared,
|
|
7247
|
+
event: z3.literal("driver_exited"),
|
|
7248
|
+
task: z3.number().int(),
|
|
7249
|
+
reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
|
|
7250
|
+
last_decision: z3.string(),
|
|
7251
|
+
exit_code: z3.number().int().optional(),
|
|
7252
|
+
error_class: CodeTokenSchema.optional()
|
|
7253
|
+
}).strict()
|
|
7254
|
+
]);
|
|
7255
|
+
var ForgeOpSchema = z3.enum([
|
|
7256
|
+
"pr.create",
|
|
7257
|
+
"pr.comment",
|
|
7258
|
+
"pr.body.replace",
|
|
7259
|
+
"pr.refreeze",
|
|
7260
|
+
"issue.create",
|
|
7261
|
+
"issue.edit",
|
|
7262
|
+
"issue.comment",
|
|
7263
|
+
"milestone.create",
|
|
7264
|
+
"milestone.edit",
|
|
7265
|
+
"milestone.close",
|
|
7266
|
+
"label.add",
|
|
7267
|
+
"label.remove"
|
|
7268
|
+
]);
|
|
7269
|
+
var ForgeWriteTargetSchema = z3.object({
|
|
7270
|
+
issue: z3.number().int().optional(),
|
|
6299
7271
|
pr: z3.number().int().optional()
|
|
6300
7272
|
}).strict();
|
|
6301
7273
|
var forgeWriteShared = {
|
|
@@ -6457,7 +7429,7 @@ var EffectEventSchema = z3.discriminatedUnion("event", [
|
|
|
6457
7429
|
]);
|
|
6458
7430
|
var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
|
|
6459
7431
|
var customShared = {
|
|
6460
|
-
meta:
|
|
7432
|
+
meta: HeaderMetaSchema,
|
|
6461
7433
|
subject: SubjectSchema,
|
|
6462
7434
|
kind: z3.literal("custom"),
|
|
6463
7435
|
...envelopeTail
|
|
@@ -6542,7 +7514,7 @@ function buildHeader(input) {
|
|
|
6542
7514
|
const issue = subject.issue;
|
|
6543
7515
|
return {
|
|
6544
7516
|
meta: {
|
|
6545
|
-
schema:
|
|
7517
|
+
schema: 4,
|
|
6546
7518
|
ts: input.now.toISOString(),
|
|
6547
7519
|
run_id: input.runId,
|
|
6548
7520
|
seq: input.seq,
|
|
@@ -6560,23 +7532,34 @@ function buildHeader(input) {
|
|
|
6560
7532
|
parent: lineageFieldFromEnv(input.env.parent)
|
|
6561
7533
|
},
|
|
6562
7534
|
input_versions: {
|
|
7535
|
+
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
6563
7536
|
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
6564
7537
|
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
6565
7538
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
7539
|
+
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
6566
7540
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
6567
7541
|
},
|
|
6568
7542
|
provenance: provenanceFor(input),
|
|
6569
7543
|
work: {
|
|
6570
7544
|
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
6571
7545
|
repo: input.repo,
|
|
6572
|
-
change: null,
|
|
6573
|
-
revision: null
|
|
7546
|
+
change: pr === undefined ? null : String(pr),
|
|
7547
|
+
revision: input.revision ?? null
|
|
6574
7548
|
},
|
|
6575
7549
|
flow: {
|
|
6576
7550
|
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
6577
7551
|
version: lineageFieldFromEnv(input.env.flowVersion)
|
|
6578
7552
|
},
|
|
6579
7553
|
runtime: lineageFieldFromEnv(input.env.runtime),
|
|
7554
|
+
process: {
|
|
7555
|
+
id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
|
|
7556
|
+
version: lineageFieldFromEnv(input.env.processVersion),
|
|
7557
|
+
digest: lineageFieldFromEnv(input.env.processDigest)
|
|
7558
|
+
},
|
|
7559
|
+
runner: {
|
|
7560
|
+
id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
|
|
7561
|
+
version: lineageFieldFromEnv(input.env.runnerVersion)
|
|
7562
|
+
},
|
|
6580
7563
|
source: lineageFieldFromEnv(input.env.source)
|
|
6581
7564
|
},
|
|
6582
7565
|
subject
|
|
@@ -6620,7 +7603,7 @@ function redact(value, home) {
|
|
|
6620
7603
|
return value;
|
|
6621
7604
|
}
|
|
6622
7605
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6623
|
-
var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
|
|
7606
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2, 3, 4];
|
|
6624
7607
|
function metaOf(obj) {
|
|
6625
7608
|
if (obj === null || typeof obj !== "object")
|
|
6626
7609
|
return null;
|
|
@@ -6758,6 +7741,12 @@ var ManifestRecordSchema = z4.object({
|
|
|
6758
7741
|
briefHash: z4.string().min(1).nullable(),
|
|
6759
7742
|
objectivesVersion: z4.string().min(1).nullable(),
|
|
6760
7743
|
rulingOrdinal: epochNumber,
|
|
7744
|
+
manifestVersion: z4.literal(2).optional(),
|
|
7745
|
+
pauseBoundRuling: z4.object({
|
|
7746
|
+
rulingId: z4.string().min(1),
|
|
7747
|
+
pauseId: z4.string().min(1),
|
|
7748
|
+
contentDigest: z4.string().min(1)
|
|
7749
|
+
}).strict().nullable().optional(),
|
|
6761
7750
|
policyDigest: z4.string().min(1),
|
|
6762
7751
|
recordedAt: isoTimestamp
|
|
6763
7752
|
}).strict();
|
|
@@ -6779,7 +7768,11 @@ var LoopStateRecordSchema = z4.object({
|
|
|
6779
7768
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6780
7769
|
repeatMemory: z4.object({
|
|
6781
7770
|
blockingFindings: z4.array(z4.string()),
|
|
6782
|
-
lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
|
|
7771
|
+
lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
|
|
7772
|
+
}).strict().optional(),
|
|
7773
|
+
developerHandoff: z4.object({
|
|
7774
|
+
findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
|
|
7775
|
+
failingChecks: z4.array(z4.string().min(1))
|
|
6783
7776
|
}).strict().optional(),
|
|
6784
7777
|
publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
6785
7778
|
taskStartedAt: isoTimestamp.optional(),
|
|
@@ -6834,6 +7827,16 @@ var ResolutionRecordSchema = z4.object({
|
|
|
6834
7827
|
authenticatedFrom: z4.string().min(1),
|
|
6835
7828
|
consumedAt: isoTimestamp
|
|
6836
7829
|
}).strict();
|
|
7830
|
+
var ExecutionRoundMirrorRecordSchema = z4.object({
|
|
7831
|
+
version: z4.literal(1),
|
|
7832
|
+
kind: z4.literal("execution_round"),
|
|
7833
|
+
task: taskId,
|
|
7834
|
+
repository: z4.string().min(1),
|
|
7835
|
+
threadId: z4.string().min(1),
|
|
7836
|
+
checkpointId: z4.string().min(1),
|
|
7837
|
+
round: z4.number().int().positive(),
|
|
7838
|
+
recordedAt: isoTimestamp
|
|
7839
|
+
}).strict();
|
|
6837
7840
|
// ../../packages/aeg-core/src/control-store/local.ts
|
|
6838
7841
|
var CONTROL_AREA_DIRNAME = "control";
|
|
6839
7842
|
// src/checks/contract.ts
|
|
@@ -6843,108 +7846,319 @@ function emitCheckError(error) {
|
|
|
6843
7846
|
`);
|
|
6844
7847
|
}
|
|
6845
7848
|
|
|
6846
|
-
// src/lib/
|
|
6847
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
7849
|
+
// src/lib/config.ts
|
|
7850
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
7851
|
+
import { promisify as promisify4 } from "node:util";
|
|
7852
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
7853
|
+
import { homedir } from "node:os";
|
|
7854
|
+
import { basename as basename3, dirname, isAbsolute, join, resolve } from "node:path";
|
|
7855
|
+
import { z as z6 } from "zod";
|
|
6851
7856
|
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
7857
|
+
// src/lib/agent-vendors.ts
|
|
7858
|
+
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
7859
|
+
|
|
7860
|
+
// src/lib/prose-rules-config.ts
|
|
7861
|
+
import safeRegex from "safe-regex2";
|
|
7862
|
+
import { z as z5 } from "zod";
|
|
7863
|
+
var SEVERITIES = ["error", "warning"];
|
|
7864
|
+
var OVERRIDE_KEYS = ["scopes", "severity", "exempt"];
|
|
7865
|
+
var FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
|
|
7866
|
+
var CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
|
|
7867
|
+
var DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
|
|
7868
|
+
function isPlainObject3(value) {
|
|
7869
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7870
|
+
}
|
|
7871
|
+
function outsideRepositoryReason(entry) {
|
|
7872
|
+
if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
|
|
7873
|
+
return "must be a repository-relative path, not an absolute one";
|
|
7874
|
+
if (entry.split(/[\\/]/).includes(".."))
|
|
7875
|
+
return "must stay inside the repository — no `..` segment";
|
|
7876
|
+
return null;
|
|
7877
|
+
}
|
|
7878
|
+
var RepoRelativePathSchema = z5.string().min(1).superRefine((entry, ctx) => {
|
|
7879
|
+
const reason = outsideRepositoryReason(entry);
|
|
7880
|
+
if (reason)
|
|
7881
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, message: reason });
|
|
7882
|
+
});
|
|
7883
|
+
function pathListIssues(value, path, issues) {
|
|
7884
|
+
if (!Array.isArray(value)) {
|
|
7885
|
+
issues.push({ path, message: "must be a list of repository-relative paths" });
|
|
7886
|
+
return;
|
|
6862
7887
|
}
|
|
7888
|
+
value.forEach((entry, index) => {
|
|
7889
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
7890
|
+
issues.push({ path: [...path, index], message: "must be a non-empty repository-relative path" });
|
|
7891
|
+
return;
|
|
7892
|
+
}
|
|
7893
|
+
const reason = outsideRepositoryReason(entry);
|
|
7894
|
+
if (reason)
|
|
7895
|
+
issues.push({ path: [...path, index], message: reason });
|
|
7896
|
+
});
|
|
6863
7897
|
}
|
|
6864
|
-
function
|
|
6865
|
-
|
|
7898
|
+
function scopeListIssues(value, path, allowed, issues) {
|
|
7899
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
7900
|
+
issues.push({ path, message: "must name at least one scope" });
|
|
7901
|
+
return null;
|
|
7902
|
+
}
|
|
7903
|
+
const scopes = [];
|
|
7904
|
+
value.forEach((scope, index) => {
|
|
7905
|
+
if (typeof scope !== "string" || !CONFIGURABLE_PROSE_SCOPES.includes(scope)) {
|
|
7906
|
+
issues.push({
|
|
7907
|
+
path: [...path, index],
|
|
7908
|
+
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(", ")}`
|
|
7909
|
+
});
|
|
7910
|
+
return;
|
|
7911
|
+
}
|
|
7912
|
+
if (!allowed.includes(scope)) {
|
|
7913
|
+
issues.push({
|
|
7914
|
+
path: [...path, index],
|
|
7915
|
+
message: `scope "${scope}" is not one this rule can run in — it can run in: ${allowed.join(", ")}`
|
|
7916
|
+
});
|
|
7917
|
+
return;
|
|
7918
|
+
}
|
|
7919
|
+
scopes.push(scope);
|
|
7920
|
+
});
|
|
7921
|
+
return scopes;
|
|
6866
7922
|
}
|
|
6867
|
-
function
|
|
6868
|
-
|
|
7923
|
+
function severityIssues(value, path, scopes, issues) {
|
|
7924
|
+
if (typeof value === "string") {
|
|
7925
|
+
if (!SEVERITIES.includes(value)) {
|
|
7926
|
+
issues.push({ path, message: `unknown severity ${JSON.stringify(value)} — use "error" or "warning"` });
|
|
7927
|
+
}
|
|
7928
|
+
return;
|
|
7929
|
+
}
|
|
7930
|
+
if (!isPlainObject3(value)) {
|
|
7931
|
+
issues.push({ path, message: 'must be "error", "warning", or a map from scope to one of them' });
|
|
7932
|
+
return;
|
|
7933
|
+
}
|
|
7934
|
+
for (const [scope, severity] of Object.entries(value)) {
|
|
7935
|
+
if (!scopes.includes(scope)) {
|
|
7936
|
+
issues.push({ path: [...path, scope], message: `names scope "${scope}", which this rule's scopes do not cover` });
|
|
7937
|
+
}
|
|
7938
|
+
if (typeof severity !== "string" || !SEVERITIES.includes(severity)) {
|
|
7939
|
+
issues.push({
|
|
7940
|
+
path: [...path, scope],
|
|
7941
|
+
message: `unknown severity ${JSON.stringify(severity)} — use "error" or "warning"`
|
|
7942
|
+
});
|
|
7943
|
+
}
|
|
7944
|
+
}
|
|
6869
7945
|
}
|
|
6870
|
-
function
|
|
6871
|
-
|
|
6872
|
-
|
|
7946
|
+
function patternIssues(source, flags, path, issues) {
|
|
7947
|
+
if (typeof source !== "string" || source.length === 0) {
|
|
7948
|
+
issues.push({ path, message: "must be a non-empty regular expression" });
|
|
7949
|
+
return;
|
|
7950
|
+
}
|
|
7951
|
+
if (source.length > CONFIGURED_PATTERN_MAX_LENGTH) {
|
|
7952
|
+
issues.push({
|
|
7953
|
+
path,
|
|
7954
|
+
message: `is ${source.length} characters, over the ${CONFIGURED_PATTERN_MAX_LENGTH}-character limit for a configured pattern`
|
|
7955
|
+
});
|
|
7956
|
+
return;
|
|
7957
|
+
}
|
|
6873
7958
|
try {
|
|
6874
|
-
|
|
7959
|
+
new RegExp(source, flags);
|
|
6875
7960
|
} catch (err) {
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
7961
|
+
issues.push({ path, message: `does not compile: ${err.message}` });
|
|
7962
|
+
return;
|
|
7963
|
+
}
|
|
7964
|
+
if (!safeRegex(source, { limit: Number.MAX_SAFE_INTEGER })) {
|
|
7965
|
+
issues.push({
|
|
7966
|
+
path,
|
|
7967
|
+
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."
|
|
7968
|
+
});
|
|
6879
7969
|
}
|
|
6880
|
-
const size = Buffer.byteLength(out, "utf8");
|
|
6881
|
-
if (usedBytes + size > FORGE_READ_CEILING_BYTES)
|
|
6882
|
-
throw new ForgeReadOversizeError(subject, usedBytes + size);
|
|
6883
|
-
return out;
|
|
6884
7970
|
}
|
|
6885
|
-
function
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
7971
|
+
function flagIssues(value, path, issues) {
|
|
7972
|
+
if (value === undefined)
|
|
7973
|
+
return "";
|
|
7974
|
+
if (typeof value !== "string") {
|
|
7975
|
+
issues.push({ path, message: 'must be a string of flags, e.g. "i"' });
|
|
7976
|
+
return "";
|
|
7977
|
+
}
|
|
7978
|
+
const seen = new Set;
|
|
7979
|
+
for (const flag of value) {
|
|
7980
|
+
if (!CONFIGURED_PROSE_FLAGS.includes(flag)) {
|
|
7981
|
+
issues.push({
|
|
7982
|
+
path,
|
|
7983
|
+
message: `unknown flag ${JSON.stringify(flag)} — only ${CONFIGURED_PROSE_FLAGS.map((f) => `"${f}"`).join(" and ")} are allowed`
|
|
6898
7984
|
});
|
|
7985
|
+
return "";
|
|
7986
|
+
}
|
|
7987
|
+
if (seen.has(flag)) {
|
|
7988
|
+
issues.push({ path, message: `repeats the flag "${flag}"` });
|
|
7989
|
+
return "";
|
|
6899
7990
|
}
|
|
6900
|
-
|
|
6901
|
-
return comments;
|
|
7991
|
+
seen.add(flag);
|
|
6902
7992
|
}
|
|
7993
|
+
return value;
|
|
6903
7994
|
}
|
|
6904
|
-
function
|
|
6905
|
-
const
|
|
6906
|
-
|
|
6907
|
-
}
|
|
6908
|
-
|
|
6909
|
-
|
|
7995
|
+
function defaultsIssues(value, issues) {
|
|
7996
|
+
const base = ["defaults"];
|
|
7997
|
+
if (!isPlainObject3(value)) {
|
|
7998
|
+
issues.push({ path: base, message: 'must map a default rule id to "off" or an override' });
|
|
7999
|
+
return;
|
|
8000
|
+
}
|
|
8001
|
+
for (const [id, override] of Object.entries(value)) {
|
|
8002
|
+
const path = [...base, id];
|
|
8003
|
+
const rule = CONFIGURABLE_DEFAULT_RULES.find((candidate) => candidate.id === id);
|
|
8004
|
+
if (!rule) {
|
|
8005
|
+
issues.push({
|
|
8006
|
+
path,
|
|
8007
|
+
message: `unknown default rule id "${id}" — \`vinaya check --plan\` lists the rules each prose check runs`
|
|
8008
|
+
});
|
|
8009
|
+
continue;
|
|
8010
|
+
}
|
|
8011
|
+
if (override === "off")
|
|
8012
|
+
continue;
|
|
8013
|
+
if (!isPlainObject3(override)) {
|
|
8014
|
+
issues.push({ path, message: 'must be "off" or an object with any of scopes, severity, exempt' });
|
|
8015
|
+
continue;
|
|
8016
|
+
}
|
|
8017
|
+
for (const key of Object.keys(override)) {
|
|
8018
|
+
if (OVERRIDE_KEYS.includes(key))
|
|
8019
|
+
continue;
|
|
8020
|
+
issues.push({
|
|
8021
|
+
path: [...path, key],
|
|
8022
|
+
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`
|
|
8023
|
+
});
|
|
8024
|
+
}
|
|
8025
|
+
const scopes = override.scopes === undefined ? [...rule.scopes] : scopeListIssues(override.scopes, [...path, "scopes"], allowedScopesFor(rule), issues);
|
|
8026
|
+
if (override.severity !== undefined && scopes)
|
|
8027
|
+
severityIssues(override.severity, [...path, "severity"], scopes, issues);
|
|
8028
|
+
if (override.exempt !== undefined)
|
|
8029
|
+
pathListIssues(override.exempt, [...path, "exempt"], issues);
|
|
8030
|
+
}
|
|
6910
8031
|
}
|
|
6911
|
-
function
|
|
6912
|
-
if (
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
8032
|
+
function customIssues(value, issues) {
|
|
8033
|
+
if (!Array.isArray(value)) {
|
|
8034
|
+
issues.push({ path: ["custom"], message: "must be a list of rules" });
|
|
8035
|
+
return;
|
|
8036
|
+
}
|
|
8037
|
+
const ids = new Set;
|
|
8038
|
+
value.forEach((rule, index) => {
|
|
8039
|
+
const path = ["custom", index];
|
|
8040
|
+
if (!isPlainObject3(rule)) {
|
|
8041
|
+
issues.push({ path, message: "must be a rule object" });
|
|
8042
|
+
return;
|
|
8043
|
+
}
|
|
8044
|
+
for (const key of Object.keys(rule)) {
|
|
8045
|
+
if (!CUSTOM_KEYS.includes(key)) {
|
|
8046
|
+
issues.push({ path: [...path, key], message: `unknown key "${key}" — a rule takes ${CUSTOM_KEYS.join(", ")}` });
|
|
8047
|
+
}
|
|
8048
|
+
}
|
|
8049
|
+
if (typeof rule.id !== "string" || rule.id.length === 0) {
|
|
8050
|
+
issues.push({ path: [...path, "id"], message: "a custom rule needs an id" });
|
|
8051
|
+
} else if (DEFAULT_IDS.has(rule.id)) {
|
|
8052
|
+
issues.push({
|
|
8053
|
+
path: [...path, "id"],
|
|
8054
|
+
message: `"${rule.id}" is a default rule id — a custom rule needs its own id; retune the default under proseGates.rules.defaults instead`
|
|
8055
|
+
});
|
|
8056
|
+
} else if (ids.has(rule.id)) {
|
|
8057
|
+
issues.push({ path: [...path, "id"], message: `"${rule.id}" is used by an earlier custom rule` });
|
|
8058
|
+
} else {
|
|
8059
|
+
ids.add(rule.id);
|
|
8060
|
+
}
|
|
8061
|
+
if (typeof rule.means !== "string" || rule.means.trim().length === 0) {
|
|
8062
|
+
issues.push({ path: [...path, "means"], message: "a custom rule needs a message (`means`)" });
|
|
8063
|
+
}
|
|
8064
|
+
let scopes = null;
|
|
8065
|
+
if (rule.scopes === undefined) {
|
|
8066
|
+
issues.push({ path: [...path, "scopes"], message: "a custom rule needs at least one scope (`scopes`)" });
|
|
8067
|
+
} else {
|
|
8068
|
+
scopes = scopeListIssues(rule.scopes, [...path, "scopes"], CONFIGURABLE_PROSE_SCOPES, issues);
|
|
8069
|
+
}
|
|
8070
|
+
if (scopes && new Set(scopes.map(groupOfScope)).size > 1) {
|
|
8071
|
+
issues.push({
|
|
8072
|
+
path: [...path, "scopes"],
|
|
8073
|
+
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'
|
|
8074
|
+
});
|
|
8075
|
+
}
|
|
8076
|
+
const flags = flagIssues(rule.flags, [...path, "flags"], issues);
|
|
8077
|
+
if (rule.pattern === undefined && rule.patterns === undefined) {
|
|
8078
|
+
issues.push({
|
|
8079
|
+
path: [...path, "pattern"],
|
|
8080
|
+
message: "a custom rule needs a `pattern` or a per-scope `patterns` map"
|
|
8081
|
+
});
|
|
8082
|
+
}
|
|
8083
|
+
if (rule.pattern !== undefined)
|
|
8084
|
+
patternIssues(rule.pattern, flags, [...path, "pattern"], issues);
|
|
8085
|
+
if (rule.patterns !== undefined) {
|
|
8086
|
+
if (!isPlainObject3(rule.patterns)) {
|
|
8087
|
+
issues.push({ path: [...path, "patterns"], message: "must map a scope to a regular expression" });
|
|
8088
|
+
} else {
|
|
8089
|
+
for (const [scope, source] of Object.entries(rule.patterns)) {
|
|
8090
|
+
if (scopes && !scopes.includes(scope)) {
|
|
8091
|
+
issues.push({
|
|
8092
|
+
path: [...path, "patterns", scope],
|
|
8093
|
+
message: `names scope "${scope}", which this rule's scopes do not cover`
|
|
8094
|
+
});
|
|
8095
|
+
continue;
|
|
8096
|
+
}
|
|
8097
|
+
patternIssues(source, flags, [...path, "patterns", scope], issues);
|
|
8098
|
+
}
|
|
8099
|
+
if (rule.pattern === undefined && scopes) {
|
|
8100
|
+
for (const scope of scopes) {
|
|
8101
|
+
if (!(scope in rule.patterns)) {
|
|
8102
|
+
issues.push({
|
|
8103
|
+
path: [...path, "patterns"],
|
|
8104
|
+
message: `has no pattern for scope "${scope}" — add one, or a \`pattern\` every other scope uses`
|
|
8105
|
+
});
|
|
8106
|
+
}
|
|
8107
|
+
}
|
|
8108
|
+
}
|
|
8109
|
+
}
|
|
8110
|
+
}
|
|
8111
|
+
if (rule.severity !== undefined && scopes)
|
|
8112
|
+
severityIssues(rule.severity, [...path, "severity"], scopes, issues);
|
|
8113
|
+
if (rule.exempt !== undefined)
|
|
8114
|
+
pathListIssues(rule.exempt, [...path, "exempt"], issues);
|
|
8115
|
+
});
|
|
6917
8116
|
}
|
|
8117
|
+
function proseRulesIssues(value) {
|
|
8118
|
+
const issues = [];
|
|
8119
|
+
if (!isPlainObject3(value))
|
|
8120
|
+
return [{ path: [], message: "must be an object with any of exempt, defaults, custom" }];
|
|
8121
|
+
for (const key of Object.keys(value)) {
|
|
8122
|
+
if (!["exempt", "defaults", "custom"].includes(key)) {
|
|
8123
|
+
issues.push({ path: [key], message: `unknown key "${key}" — proseGates.rules takes exempt, defaults and custom` });
|
|
8124
|
+
}
|
|
8125
|
+
}
|
|
8126
|
+
if (value.exempt !== undefined)
|
|
8127
|
+
pathListIssues(value.exempt, ["exempt"], issues);
|
|
8128
|
+
if (value.defaults !== undefined)
|
|
8129
|
+
defaultsIssues(value.defaults, issues);
|
|
8130
|
+
if (value.custom !== undefined)
|
|
8131
|
+
customIssues(value.custom, issues);
|
|
8132
|
+
return issues;
|
|
8133
|
+
}
|
|
8134
|
+
var ProseRulesSchema = z5.unknown().superRefine((value, ctx) => {
|
|
8135
|
+
for (const issue of proseRulesIssues(value)) {
|
|
8136
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: issue.path, message: issue.message });
|
|
8137
|
+
}
|
|
8138
|
+
}).transform((value) => value);
|
|
8139
|
+
var PublishedProseSchema = z5.object({
|
|
8140
|
+
allow: z5.array(z5.string().min(1)).optional()
|
|
8141
|
+
}).strict();
|
|
6918
8142
|
|
|
6919
8143
|
// src/lib/config.ts
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
import { z as z5 } from "zod";
|
|
6926
|
-
|
|
6927
|
-
// src/lib/agent-vendors.ts
|
|
6928
|
-
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
6929
|
-
|
|
6930
|
-
// src/lib/config.ts
|
|
6931
|
-
var EnvEntrySchema = z5.union([
|
|
6932
|
-
z5.literal(true),
|
|
6933
|
-
z5.object({ optional: z5.literal(true) }),
|
|
6934
|
-
z5.object({ anyOf: z5.array(z5.string()).min(2) }),
|
|
6935
|
-
z5.string()
|
|
8144
|
+
var EnvEntrySchema = z6.union([
|
|
8145
|
+
z6.literal(true),
|
|
8146
|
+
z6.object({ optional: z6.literal(true) }),
|
|
8147
|
+
z6.object({ anyOf: z6.array(z6.string()).min(2) }),
|
|
8148
|
+
z6.string()
|
|
6936
8149
|
]);
|
|
6937
|
-
var CheckEntrySchema =
|
|
6938
|
-
run:
|
|
6939
|
-
scope:
|
|
6940
|
-
include:
|
|
6941
|
-
args:
|
|
6942
|
-
timeoutMs:
|
|
6943
|
-
env:
|
|
6944
|
-
requiresOpenPr:
|
|
6945
|
-
ownWorkflow:
|
|
6946
|
-
principalOwed:
|
|
6947
|
-
validates:
|
|
8150
|
+
var CheckEntrySchema = z6.object({
|
|
8151
|
+
run: z6.string(),
|
|
8152
|
+
scope: z6.enum(["diff", "full"]),
|
|
8153
|
+
include: z6.array(z6.string()).optional(),
|
|
8154
|
+
args: z6.array(z6.string()).optional(),
|
|
8155
|
+
timeoutMs: z6.number().optional(),
|
|
8156
|
+
env: z6.record(z6.string(), EnvEntrySchema).optional(),
|
|
8157
|
+
requiresOpenPr: z6.boolean().optional(),
|
|
8158
|
+
ownWorkflow: z6.boolean().optional(),
|
|
8159
|
+
principalOwed: z6.literal(true).optional(),
|
|
8160
|
+
validates: z6.enum(["body", "issue"]).optional(),
|
|
8161
|
+
advisory: z6.literal(true).optional()
|
|
6948
8162
|
}).superRefine((entry, ctx) => {
|
|
6949
8163
|
if (!entry.env)
|
|
6950
8164
|
return;
|
|
@@ -6954,22 +8168,22 @@ var CheckEntrySchema = z5.object({
|
|
|
6954
8168
|
const members = value.anyOf;
|
|
6955
8169
|
if (new Set(members).size !== members.length) {
|
|
6956
8170
|
ctx.addIssue({
|
|
6957
|
-
code:
|
|
8171
|
+
code: z6.ZodIssueCode.custom,
|
|
6958
8172
|
message: `env.${key}.anyOf has duplicate members`,
|
|
6959
8173
|
path: ["env", key, "anyOf"]
|
|
6960
8174
|
});
|
|
6961
8175
|
}
|
|
6962
8176
|
if (!members.includes(key)) {
|
|
6963
8177
|
ctx.addIssue({
|
|
6964
|
-
code:
|
|
8178
|
+
code: z6.ZodIssueCode.custom,
|
|
6965
8179
|
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
6966
8180
|
path: ["env", key, "anyOf"]
|
|
6967
8181
|
});
|
|
6968
8182
|
}
|
|
6969
8183
|
}
|
|
6970
8184
|
});
|
|
6971
|
-
var RoleEntrySchema =
|
|
6972
|
-
contract:
|
|
8185
|
+
var RoleEntrySchema = z6.object({
|
|
8186
|
+
contract: z6.string().refine((p) => p.includes("/"), {
|
|
6973
8187
|
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
6974
8188
|
})
|
|
6975
8189
|
});
|
|
@@ -6993,17 +8207,17 @@ var BRIEF_BUILTINS = [
|
|
|
6993
8207
|
"briefSections",
|
|
6994
8208
|
"milestoneShape"
|
|
6995
8209
|
];
|
|
6996
|
-
var BriefSectionSchema =
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
8210
|
+
var BriefSectionSchema = z6.union([
|
|
8211
|
+
z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
|
|
8212
|
+
z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
|
|
8213
|
+
z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
|
|
8214
|
+
z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
|
|
7001
8215
|
]);
|
|
7002
|
-
var BriefSchemaSchema =
|
|
7003
|
-
pr:
|
|
7004
|
-
issue:
|
|
7005
|
-
milestone:
|
|
7006
|
-
ack:
|
|
8216
|
+
var BriefSchemaSchema = z6.object({
|
|
8217
|
+
pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8218
|
+
issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8219
|
+
milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8220
|
+
ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
|
|
7007
8221
|
});
|
|
7008
8222
|
function isSafeRepoRelPath(p) {
|
|
7009
8223
|
if (p.length === 0)
|
|
@@ -7012,7 +8226,7 @@ function isSafeRepoRelPath(p) {
|
|
|
7012
8226
|
return false;
|
|
7013
8227
|
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
7014
8228
|
}
|
|
7015
|
-
var SafeRepoRelPath =
|
|
8229
|
+
var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
|
|
7016
8230
|
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
7017
8231
|
});
|
|
7018
8232
|
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
@@ -7022,22 +8236,22 @@ function isCanonicalHookBlockPath(p) {
|
|
|
7022
8236
|
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
7023
8237
|
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
7024
8238
|
});
|
|
7025
|
-
var ManagedBlockRecordSchema =
|
|
8239
|
+
var ManagedBlockRecordSchema = z6.object({
|
|
7026
8240
|
path: ManagedHookBlockPath,
|
|
7027
|
-
marker:
|
|
7028
|
-
comment:
|
|
8241
|
+
marker: z6.string(),
|
|
8242
|
+
comment: z6.enum(["hash", "html"])
|
|
7029
8243
|
});
|
|
7030
|
-
var ManagedManifestSchema =
|
|
7031
|
-
version:
|
|
7032
|
-
files:
|
|
7033
|
-
blocks:
|
|
7034
|
-
labels:
|
|
7035
|
-
agents:
|
|
8244
|
+
var ManagedManifestSchema = z6.object({
|
|
8245
|
+
version: z6.number().int().positive(),
|
|
8246
|
+
files: z6.array(SafeRepoRelPath),
|
|
8247
|
+
blocks: z6.array(ManagedBlockRecordSchema),
|
|
8248
|
+
labels: z6.array(z6.string()),
|
|
8249
|
+
agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
|
|
7036
8250
|
});
|
|
7037
|
-
var ProjectEntrySchema =
|
|
7038
|
-
name:
|
|
7039
|
-
description:
|
|
7040
|
-
path:
|
|
8251
|
+
var ProjectEntrySchema = z6.object({
|
|
8252
|
+
name: z6.string().min(1),
|
|
8253
|
+
description: z6.string().min(1).optional(),
|
|
8254
|
+
path: z6.string().min(1).optional()
|
|
7041
8255
|
});
|
|
7042
8256
|
function parseTokensCollectDeclaration(value) {
|
|
7043
8257
|
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
@@ -7048,90 +8262,101 @@ function parseTokensCollectDeclaration(value) {
|
|
|
7048
8262
|
return null;
|
|
7049
8263
|
return { interpreter, script };
|
|
7050
8264
|
}
|
|
7051
|
-
var
|
|
7052
|
-
rings:
|
|
7053
|
-
ring1_forgeWriteInterception:
|
|
7054
|
-
ring2_asyncAudits:
|
|
8265
|
+
var VinayaConfigObjectSchema = z6.object({
|
|
8266
|
+
rings: z6.object({
|
|
8267
|
+
ring1_forgeWriteInterception: z6.boolean(),
|
|
8268
|
+
ring2_asyncAudits: z6.boolean()
|
|
7055
8269
|
}).optional(),
|
|
7056
|
-
checks:
|
|
7057
|
-
roles:
|
|
8270
|
+
checks: z6.record(z6.string(), CheckEntrySchema).optional(),
|
|
8271
|
+
roles: z6.record(z6.string(), RoleEntrySchema).optional(),
|
|
7058
8272
|
briefSchema: BriefSchemaSchema.optional(),
|
|
7059
8273
|
managed: ManagedManifestSchema.optional(),
|
|
7060
|
-
principals:
|
|
7061
|
-
releaseActor:
|
|
7062
|
-
ci:
|
|
7063
|
-
tokens:
|
|
7064
|
-
collect:
|
|
8274
|
+
principals: z6.array(z6.string()).min(1).optional(),
|
|
8275
|
+
releaseActor: z6.string().min(1).optional(),
|
|
8276
|
+
ci: z6.object({ setup: z6.string().min(1) }).optional(),
|
|
8277
|
+
tokens: z6.object({
|
|
8278
|
+
collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
7065
8279
|
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
7066
8280
|
})
|
|
7067
8281
|
}).optional(),
|
|
7068
|
-
blastRadius:
|
|
7069
|
-
proseGates:
|
|
7070
|
-
doctrineRoot:
|
|
7071
|
-
readerFacingPrefix:
|
|
7072
|
-
readerFacingSuffix:
|
|
7073
|
-
legacySlugDir:
|
|
7074
|
-
sourceComments:
|
|
7075
|
-
globs:
|
|
7076
|
-
allowlist:
|
|
7077
|
-
severity:
|
|
8282
|
+
blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
|
|
8283
|
+
proseGates: z6.object({
|
|
8284
|
+
doctrineRoot: z6.string().min(1).optional(),
|
|
8285
|
+
readerFacingPrefix: z6.string().min(1).optional(),
|
|
8286
|
+
readerFacingSuffix: z6.string().min(1).optional(),
|
|
8287
|
+
legacySlugDir: z6.string().min(1).optional(),
|
|
8288
|
+
sourceComments: z6.object({
|
|
8289
|
+
globs: z6.array(z6.string().min(1)).optional(),
|
|
8290
|
+
allowlist: z6.array(z6.string().min(1)).optional(),
|
|
8291
|
+
severity: z6.enum(["warning", "error"]).optional()
|
|
7078
8292
|
}).optional(),
|
|
7079
|
-
specGrandfather:
|
|
7080
|
-
specPaths:
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
})).optional()
|
|
8293
|
+
specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
|
|
8294
|
+
specPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8295
|
+
productPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8296
|
+
published: PublishedProseSchema.optional(),
|
|
8297
|
+
rules: ProseRulesSchema.optional()
|
|
7085
8298
|
}).optional(),
|
|
7086
|
-
projects:
|
|
7087
|
-
dispatch:
|
|
7088
|
-
timeoutMs:
|
|
7089
|
-
|
|
7090
|
-
|
|
8299
|
+
projects: z6.array(ProjectEntrySchema).optional(),
|
|
8300
|
+
dispatch: z6.object({
|
|
8301
|
+
timeoutMs: z6.number().int().positive().optional(),
|
|
8302
|
+
reviewerTimeoutMs: z6.number().int().positive().optional(),
|
|
8303
|
+
killGraceMs: z6.number().int().positive().optional(),
|
|
8304
|
+
agent: z6.enum(["claude", "codex"]).optional()
|
|
7091
8305
|
}).optional(),
|
|
7092
|
-
reviewPolicy:
|
|
7093
|
-
codeReviewThreshold:
|
|
7094
|
-
securityThreshold:
|
|
7095
|
-
maxRounds:
|
|
7096
|
-
maxTaskMinutes:
|
|
8306
|
+
reviewPolicy: z6.object({
|
|
8307
|
+
codeReviewThreshold: z6.string().min(1).optional(),
|
|
8308
|
+
securityThreshold: z6.string().min(1).optional(),
|
|
8309
|
+
maxRounds: z6.number().optional(),
|
|
8310
|
+
maxTaskMinutes: z6.number().optional(),
|
|
8311
|
+
readyPushTimeoutMinutes: z6.number().optional()
|
|
7097
8312
|
}).optional(),
|
|
7098
|
-
securityScan:
|
|
7099
|
-
command:
|
|
8313
|
+
securityScan: z6.object({
|
|
8314
|
+
command: z6.array(z6.string().min(1)).min(1)
|
|
7100
8315
|
}).optional(),
|
|
7101
|
-
gateCutovers:
|
|
7102
|
-
objectivesSinceIssue:
|
|
7103
|
-
briefSectionsSinceIssue:
|
|
7104
|
-
documentationSinceIssue:
|
|
7105
|
-
briefRulesSincePr:
|
|
7106
|
-
agentBoxesRefusedSincePr:
|
|
8316
|
+
gateCutovers: z6.object({
|
|
8317
|
+
objectivesSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8318
|
+
briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8319
|
+
documentationSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8320
|
+
briefRulesSincePr: z6.number().int().nonnegative().optional(),
|
|
8321
|
+
agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
|
|
7107
8322
|
}).optional(),
|
|
7108
|
-
planning:
|
|
7109
|
-
collisionThreshold:
|
|
8323
|
+
planning: z6.object({
|
|
8324
|
+
collisionThreshold: z6.number().int().nonnegative().optional()
|
|
7110
8325
|
}).optional(),
|
|
7111
|
-
prePush:
|
|
7112
|
-
alwaysRun:
|
|
8326
|
+
prePush: z6.object({
|
|
8327
|
+
alwaysRun: z6.array(z6.string()).optional(),
|
|
8328
|
+
readyTests: z6.object({
|
|
8329
|
+
mode: z6.literal("ci"),
|
|
8330
|
+
workflow: z6.literal(".github/workflows/ci.yml"),
|
|
8331
|
+
check: z6.literal("Vinaya CI")
|
|
8332
|
+
}).strict().optional(),
|
|
8333
|
+
requiredCi: z6.object({
|
|
8334
|
+
workflow: z6.literal(".github/workflows/ci.yml"),
|
|
8335
|
+
check: z6.literal("Vinaya CI")
|
|
8336
|
+
}).strict().optional()
|
|
7113
8337
|
}).optional(),
|
|
7114
|
-
report:
|
|
7115
|
-
commandTimeoutMs:
|
|
8338
|
+
report: z6.object({
|
|
8339
|
+
commandTimeoutMs: z6.number().int().positive().optional()
|
|
7116
8340
|
}).superRefine((report, ctx) => {
|
|
7117
8341
|
const commandTimeoutMs = report.commandTimeoutMs;
|
|
7118
8342
|
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
7119
8343
|
ctx.addIssue({
|
|
7120
|
-
code:
|
|
8344
|
+
code: z6.ZodIssueCode.custom,
|
|
7121
8345
|
path: ["commandTimeoutMs"],
|
|
7122
8346
|
message: "must be at most 3600000 (1 hour)"
|
|
7123
8347
|
});
|
|
7124
8348
|
}
|
|
7125
8349
|
}).optional(),
|
|
7126
|
-
logPublish:
|
|
8350
|
+
logPublish: z6.unknown().refine((v) => v === undefined, {
|
|
7127
8351
|
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
7128
8352
|
}),
|
|
7129
|
-
runtimeDir:
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
8353
|
+
runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
8354
|
+
runner: z6.enum(["standalone", "atta-engine"]).optional(),
|
|
8355
|
+
logs: z6.object({
|
|
8356
|
+
folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
8357
|
+
url: z6.string().url().optional(),
|
|
8358
|
+
headers: z6.record(z6.string()).optional(),
|
|
8359
|
+
readHeaders: z6.record(z6.string()).optional(),
|
|
7135
8360
|
events: CustomEventDeclarationsSchema.optional()
|
|
7136
8361
|
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
7137
8362
|
message: "logs: set at most one of folder/url"
|
|
@@ -7139,8 +8364,33 @@ var VinayaConfigSchema = z5.object({
|
|
|
7139
8364
|
message: "logs: headers requires url"
|
|
7140
8365
|
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
7141
8366
|
message: "logs: readHeaders requires url"
|
|
7142
|
-
}).optional()
|
|
8367
|
+
}).or(z6.literal(false)).optional(),
|
|
8368
|
+
decisionRecords: z6.object({
|
|
8369
|
+
path: RepoRelativePathSchema
|
|
8370
|
+
}).strict().optional()
|
|
7143
8371
|
});
|
|
8372
|
+
function decisionRecordsPathIssue(path, doctrineRoot) {
|
|
8373
|
+
const reason = outsideRepositoryReason(path);
|
|
8374
|
+
if (reason)
|
|
8375
|
+
return reason;
|
|
8376
|
+
const folder = normalizeSpecPath(path);
|
|
8377
|
+
if (folder === "" || folder === ".")
|
|
8378
|
+
return "must name a folder, not the repository root";
|
|
8379
|
+
const root = normalizeSpecPath(doctrineRoot ?? "aeg-root");
|
|
8380
|
+
if (folder === root || folder.startsWith(`${root}/`)) {
|
|
8381
|
+
return `must be outside the doctrine tree "${root}" — decision records belong to this repository, not to the doctrine it ships`;
|
|
8382
|
+
}
|
|
8383
|
+
return null;
|
|
8384
|
+
}
|
|
8385
|
+
var VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
|
|
8386
|
+
const path = config.decisionRecords?.path;
|
|
8387
|
+
if (path === undefined || outsideRepositoryReason(path))
|
|
8388
|
+
return;
|
|
8389
|
+
const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
|
|
8390
|
+
if (issue)
|
|
8391
|
+
ctx.addIssue({ code: z6.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
|
|
8392
|
+
});
|
|
8393
|
+
var VinayaConfigShape = VinayaConfigObjectSchema.shape;
|
|
7144
8394
|
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
7145
8395
|
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
7146
8396
|
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
@@ -7221,9 +8471,6 @@ function stripGlobalOnlyKeys(config, path) {
|
|
|
7221
8471
|
}
|
|
7222
8472
|
return result;
|
|
7223
8473
|
}
|
|
7224
|
-
function resolvePrincipalAllowlist(config) {
|
|
7225
|
-
return config?.principals ?? PRINCIPAL_ALLOWLIST;
|
|
7226
|
-
}
|
|
7227
8474
|
function resolveReleaseActor(config) {
|
|
7228
8475
|
return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
|
|
7229
8476
|
}
|
|
@@ -7247,13 +8494,19 @@ function resolveReviewPolicy(config) {
|
|
|
7247
8494
|
if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
|
|
7248
8495
|
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.`);
|
|
7249
8496
|
}
|
|
8497
|
+
const readyPushTimeoutMinutes = raw.readyPushTimeoutMinutes ?? DEFAULT_READY_PUSH_TIMEOUT_MINUTES;
|
|
8498
|
+
if (!Number.isInteger(readyPushTimeoutMinutes) || readyPushTimeoutMinutes < 1) {
|
|
8499
|
+
throw new Error(`vinaya.config.json: reviewPolicy.readyPushTimeoutMinutes "${readyPushTimeoutMinutes}" is not a positive integer — fix the config, this never falls back to a default.`);
|
|
8500
|
+
}
|
|
7250
8501
|
return {
|
|
7251
8502
|
codeReviewThreshold,
|
|
7252
8503
|
securityThreshold,
|
|
7253
8504
|
maxRounds,
|
|
7254
|
-
maxTaskMinutes
|
|
8505
|
+
maxTaskMinutes,
|
|
8506
|
+
readyPushTimeoutMinutes
|
|
7255
8507
|
};
|
|
7256
8508
|
}
|
|
8509
|
+
var emittedLocalOverrideWarnings = new Set;
|
|
7257
8510
|
function resolveGateCutovers(config) {
|
|
7258
8511
|
const raw = config?.gateCutovers;
|
|
7259
8512
|
if (!raw)
|
|
@@ -7305,7 +8558,7 @@ function trustAnchorRepo() {
|
|
|
7305
8558
|
if (fromRunner)
|
|
7306
8559
|
return fromRunner;
|
|
7307
8560
|
try {
|
|
7308
|
-
const url =
|
|
8561
|
+
const url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
7309
8562
|
encoding: "utf-8",
|
|
7310
8563
|
stdio: ["ignore", "pipe", "pipe"]
|
|
7311
8564
|
});
|
|
@@ -7352,21 +8605,22 @@ function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
|
7352
8605
|
return ref;
|
|
7353
8606
|
}
|
|
7354
8607
|
function readTrustAnchorConfigAtRef(ref) {
|
|
7355
|
-
const raw =
|
|
8608
|
+
const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
7356
8609
|
encoding: "utf-8",
|
|
7357
8610
|
stdio: ["ignore", "pipe", "pipe"],
|
|
7358
8611
|
timeout: 1e4
|
|
7359
8612
|
});
|
|
7360
8613
|
return Buffer.from(raw, "utf-8").toString("base64");
|
|
7361
8614
|
}
|
|
8615
|
+
var NO_TRUST_ANCHOR_REPO_MESSAGE = "could not resolve repo identity for the trust-anchor read";
|
|
7362
8616
|
function ghFetchTrustAnchorConfig() {
|
|
7363
8617
|
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
7364
8618
|
if (probeRef)
|
|
7365
8619
|
return readTrustAnchorConfigAtRef(probeRef);
|
|
7366
8620
|
const repo = trustAnchorRepo();
|
|
7367
8621
|
if (!repo)
|
|
7368
|
-
throw new Error(
|
|
7369
|
-
return
|
|
8622
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
8623
|
+
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
7370
8624
|
encoding: "utf-8",
|
|
7371
8625
|
stdio: ["ignore", "pipe", "pipe"]
|
|
7372
8626
|
});
|
|
@@ -7382,7 +8636,7 @@ async function ghFetchTrustAnchorConfigAsync() {
|
|
|
7382
8636
|
}
|
|
7383
8637
|
const repo = await trustAnchorRepoAsync();
|
|
7384
8638
|
if (!repo)
|
|
7385
|
-
throw new Error(
|
|
8639
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7386
8640
|
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
7387
8641
|
return stdout;
|
|
7388
8642
|
}
|
|
@@ -7408,6 +8662,47 @@ function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
|
7408
8662
|
}
|
|
7409
8663
|
return parseTrustAnchorContent(base64);
|
|
7410
8664
|
}
|
|
8665
|
+
class PrincipalsUnresolvedError extends Error {
|
|
8666
|
+
kind;
|
|
8667
|
+
constructor(kind, message) {
|
|
8668
|
+
super(message);
|
|
8669
|
+
this.name = "PrincipalsUnresolvedError";
|
|
8670
|
+
this.kind = kind;
|
|
8671
|
+
}
|
|
8672
|
+
}
|
|
8673
|
+
var PRINCIPALS_FIX = 'add "principals": [...] to vinaya.config.json on the default branch';
|
|
8674
|
+
function fetchFailureReason(err) {
|
|
8675
|
+
const stderr = err?.stderr;
|
|
8676
|
+
const text = (typeof stderr === "string" ? stderr : stderr?.toString() ?? "").trim();
|
|
8677
|
+
return text.split(`
|
|
8678
|
+
`)[0]?.trim() || firstLine(err);
|
|
8679
|
+
}
|
|
8680
|
+
function principalsNotConfigured(why) {
|
|
8681
|
+
return new PrincipalsUnresolvedError("not-configured", `no Principal is configured (${why}) — ${PRINCIPALS_FIX}.`);
|
|
8682
|
+
}
|
|
8683
|
+
function resolveTrustedPrincipals(fetcher = ghFetchTrustAnchorConfig) {
|
|
8684
|
+
let content;
|
|
8685
|
+
try {
|
|
8686
|
+
content = fetcher();
|
|
8687
|
+
} catch (err) {
|
|
8688
|
+
if (err?.message === NO_TRUST_ANCHOR_REPO_MESSAGE) {
|
|
8689
|
+
throw principalsNotConfigured("no repository resolves for the read");
|
|
8690
|
+
}
|
|
8691
|
+
if (isMissingFileError(err))
|
|
8692
|
+
throw principalsNotConfigured("the default branch has no vinaya.config.json");
|
|
8693
|
+
throw new PrincipalsUnresolvedError("read-failed", `could not read "principals" from vinaya.config.json on the default branch: ${fetchFailureReason(err)}`);
|
|
8694
|
+
}
|
|
8695
|
+
const unusable = { why: "" };
|
|
8696
|
+
const config = parseTrustAnchorContent(content, (why) => {
|
|
8697
|
+
unusable.why = why;
|
|
8698
|
+
});
|
|
8699
|
+
if (config === null) {
|
|
8700
|
+
throw principalsNotConfigured(`vinaya.config.json on the default branch ${unusable.why ? `is unusable: ${unusable.why}` : "is empty"}`);
|
|
8701
|
+
}
|
|
8702
|
+
if (!config.principals)
|
|
8703
|
+
throw principalsNotConfigured('vinaya.config.json on the default branch sets no "principals"');
|
|
8704
|
+
return config.principals;
|
|
8705
|
+
}
|
|
7411
8706
|
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
7412
8707
|
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
7413
8708
|
let base64;
|
|
@@ -7447,48 +8742,330 @@ function loadConfig() {
|
|
|
7447
8742
|
const path = configPath();
|
|
7448
8743
|
if (!path)
|
|
7449
8744
|
return null;
|
|
8745
|
+
let text;
|
|
7450
8746
|
try {
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
8747
|
+
text = readFileSync2(path, "utf-8");
|
|
8748
|
+
} catch (err) {
|
|
8749
|
+
reportInvalidConfigOnce(path, `unreadable: ${err.message}`);
|
|
7454
8750
|
return null;
|
|
7455
8751
|
}
|
|
8752
|
+
let raw;
|
|
8753
|
+
try {
|
|
8754
|
+
raw = JSON.parse(text);
|
|
8755
|
+
} catch (err) {
|
|
8756
|
+
reportInvalidConfigOnce(path, `invalid JSON: ${err.message}`);
|
|
8757
|
+
return null;
|
|
8758
|
+
}
|
|
8759
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8760
|
+
if (!parsed.success) {
|
|
8761
|
+
reportInvalidConfigOnce(path, schemaIssueDetail(parsed.error));
|
|
8762
|
+
return null;
|
|
8763
|
+
}
|
|
8764
|
+
return stripGlobalOnlyKeys(parsed.data, path);
|
|
8765
|
+
}
|
|
8766
|
+
function schemaIssueDetail(error) {
|
|
8767
|
+
return error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
|
|
8768
|
+
}
|
|
8769
|
+
var emittedInvalidConfigReports = new Set;
|
|
8770
|
+
function reportInvalidConfigOnce(path, detail) {
|
|
8771
|
+
const key = `${path}
|
|
8772
|
+
${detail}`;
|
|
8773
|
+
if (emittedInvalidConfigReports.has(key))
|
|
8774
|
+
return;
|
|
8775
|
+
emittedInvalidConfigReports.add(key);
|
|
8776
|
+
const message = `${path} is not a valid Vinaya configuration (${detail}) — falling back to built-in defaults.`;
|
|
8777
|
+
const checkName = process.env.VINAYA_CHECK_NAME;
|
|
8778
|
+
if (checkName) {
|
|
8779
|
+
emitCheckError({
|
|
8780
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8781
|
+
check: checkName,
|
|
8782
|
+
severity: "warning",
|
|
8783
|
+
message,
|
|
8784
|
+
agent_recovery_prompt: `Fix the failing keys in ${path} (${detail}) so the file parses and satisfies the configuration schema, then re-run.`,
|
|
8785
|
+
file: path
|
|
8786
|
+
});
|
|
8787
|
+
return;
|
|
8788
|
+
}
|
|
8789
|
+
console.error(`⚠ ${message}`);
|
|
8790
|
+
}
|
|
8791
|
+
function loadConfigChecked() {
|
|
8792
|
+
const path = configPath();
|
|
8793
|
+
if (!path)
|
|
8794
|
+
return { ok: true, config: null };
|
|
8795
|
+
let raw;
|
|
8796
|
+
try {
|
|
8797
|
+
raw = JSON.parse(readFileSync2(path, "utf-8"));
|
|
8798
|
+
} catch (err) {
|
|
8799
|
+
return { ok: false, path, error: `invalid JSON: ${err.message}` };
|
|
8800
|
+
}
|
|
8801
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8802
|
+
if (!parsed.success) {
|
|
8803
|
+
return { ok: false, path, error: schemaIssueDetail(parsed.error) };
|
|
8804
|
+
}
|
|
8805
|
+
return { ok: true, config: stripGlobalOnlyKeys(parsed.data, path) };
|
|
7456
8806
|
}
|
|
7457
8807
|
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
7458
8808
|
|
|
7459
|
-
// src/
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
8809
|
+
// src/lib/forge-read.ts
|
|
8810
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
8811
|
+
|
|
8812
|
+
// src/lib/forge-snapshot.ts
|
|
8813
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
8814
|
+
import { join as join2 } from "node:path";
|
|
8815
|
+
var FORGE_SNAPSHOT_DIR_ENV = "VINAYA_FORGE_SNAPSHOT_DIR";
|
|
8816
|
+
var PULL_FILE = "pull.json";
|
|
8817
|
+
var PULL_COMMENTS_FILE = "pull-comments.json";
|
|
8818
|
+
var ISSUE_FILE = "issue.json";
|
|
8819
|
+
var ISSUE_COMMENTS_FILE = "issue-comments.json";
|
|
8820
|
+
function forgeSnapshotDir(env = process.env) {
|
|
8821
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
8822
|
+
return null;
|
|
8823
|
+
const dir = env[FORGE_SNAPSHOT_DIR_ENV];
|
|
8824
|
+
return dir ? dir : null;
|
|
7463
8825
|
}
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
8826
|
+
|
|
8827
|
+
class ForgeSnapshotIncompleteError extends Error {
|
|
8828
|
+
constructor(dir, file) {
|
|
8829
|
+
super(`the forge snapshot ${dir} has no ${file} — the pull request read that writes it did not complete, so this check refuses to read the forge in its place.`);
|
|
8830
|
+
this.name = "ForgeSnapshotIncompleteError";
|
|
8831
|
+
}
|
|
8832
|
+
}
|
|
8833
|
+
|
|
8834
|
+
class ForgeSnapshotIssueNotFoundError extends Error {
|
|
8835
|
+
constructor(issue) {
|
|
8836
|
+
super(`Issue #${issue} did not resolve (HTTP 404) when this run's forge snapshot was read.`);
|
|
8837
|
+
this.name = "ForgeSnapshotIssueNotFoundError";
|
|
8838
|
+
}
|
|
8839
|
+
}
|
|
8840
|
+
function readSnapshotFile(dir, file) {
|
|
8841
|
+
let text;
|
|
8842
|
+
try {
|
|
8843
|
+
text = readFileSync3(join2(dir, file), "utf8");
|
|
8844
|
+
} catch {
|
|
8845
|
+
throw new ForgeSnapshotIncompleteError(dir, file);
|
|
8846
|
+
}
|
|
8847
|
+
return JSON.parse(text);
|
|
8848
|
+
}
|
|
8849
|
+
function readComments(dir, file, number) {
|
|
8850
|
+
const parsed = readSnapshotFile(dir, file);
|
|
8851
|
+
if (parsed.number !== number)
|
|
8852
|
+
throw new ForgeSnapshotIncompleteError(dir, `${file} for #${number}`);
|
|
8853
|
+
return parsed.comments;
|
|
8854
|
+
}
|
|
8855
|
+
function snapshotPullRequest(number, env = process.env) {
|
|
8856
|
+
const dir = forgeSnapshotDir(env);
|
|
8857
|
+
if (dir === null)
|
|
8858
|
+
return null;
|
|
8859
|
+
const pull = readSnapshotFile(dir, PULL_FILE);
|
|
8860
|
+
return pull.number === number ? pull : null;
|
|
8861
|
+
}
|
|
8862
|
+
function snapshotIssue(number, env = process.env) {
|
|
8863
|
+
const dir = forgeSnapshotDir(env);
|
|
8864
|
+
if (dir === null)
|
|
8865
|
+
return null;
|
|
8866
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
8867
|
+
if (issue.number !== number)
|
|
8868
|
+
return null;
|
|
8869
|
+
if ("notFound" in issue)
|
|
8870
|
+
throw new ForgeSnapshotIssueNotFoundError(number);
|
|
8871
|
+
return issue;
|
|
8872
|
+
}
|
|
8873
|
+
function snapshotComments(number, env = process.env) {
|
|
8874
|
+
const dir = forgeSnapshotDir(env);
|
|
8875
|
+
if (dir === null)
|
|
8876
|
+
return null;
|
|
8877
|
+
if (snapshotPullRequest(number, env) !== null)
|
|
8878
|
+
return readComments(dir, PULL_COMMENTS_FILE, number);
|
|
8879
|
+
if (snapshotIssue(number, env) !== null)
|
|
8880
|
+
return readComments(dir, ISSUE_COMMENTS_FILE, number);
|
|
8881
|
+
return null;
|
|
8882
|
+
}
|
|
8883
|
+
function snapshotBody(number, env = process.env) {
|
|
8884
|
+
const pull = snapshotPullRequest(number, env);
|
|
8885
|
+
if (pull !== null)
|
|
8886
|
+
return pull.body;
|
|
8887
|
+
return snapshotIssue(number, env)?.body ?? null;
|
|
8888
|
+
}
|
|
8889
|
+
function incompleteForgeSnapshot(env = process.env) {
|
|
8890
|
+
const dir = forgeSnapshotDir(env);
|
|
8891
|
+
if (dir === null)
|
|
8892
|
+
return null;
|
|
8893
|
+
for (const file of [PULL_FILE, PULL_COMMENTS_FILE, ISSUE_FILE]) {
|
|
8894
|
+
if (!existsSync2(join2(dir, file)))
|
|
8895
|
+
return new ForgeSnapshotIncompleteError(dir, file).message;
|
|
8896
|
+
}
|
|
8897
|
+
try {
|
|
8898
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
8899
|
+
if (typeof issue.number === "number" && !("notFound" in issue) && !existsSync2(join2(dir, ISSUE_COMMENTS_FILE))) {
|
|
8900
|
+
return new ForgeSnapshotIncompleteError(dir, ISSUE_COMMENTS_FILE).message;
|
|
8901
|
+
}
|
|
8902
|
+
} catch (err) {
|
|
8903
|
+
return `the forge snapshot ${dir} has an unreadable ${ISSUE_FILE}: ${err.message}`;
|
|
8904
|
+
}
|
|
8905
|
+
return null;
|
|
8906
|
+
}
|
|
8907
|
+
function exitOnIncompleteForgeSnapshot(checkName, env = process.env) {
|
|
8908
|
+
const reason = incompleteForgeSnapshot(env);
|
|
8909
|
+
if (reason === null)
|
|
8910
|
+
return;
|
|
8911
|
+
emitCheckError({
|
|
8912
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8913
|
+
check: checkName,
|
|
8914
|
+
severity: "error",
|
|
8915
|
+
message: `${checkName}: ${reason}`,
|
|
8916
|
+
agent_recovery_prompt: `Re-run the whole workflow run so its pull request read step writes the snapshot again (its own log names the failed read), then let \`vinaya check ${checkName}\` re-run.`
|
|
8917
|
+
});
|
|
8918
|
+
process.exit(1);
|
|
8919
|
+
}
|
|
8920
|
+
|
|
8921
|
+
// src/lib/forge-read.ts
|
|
8922
|
+
var FORGE_READ_CEILING_BYTES = 64 * 1024 * 1024;
|
|
8923
|
+
var PAGE_SIZE = 100;
|
|
8924
|
+
var ghRunner = (args, maxBuffer) => execFileSync3("gh", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], maxBuffer });
|
|
8925
|
+
|
|
8926
|
+
class ForgeReadOversizeError extends Error {
|
|
8927
|
+
subject;
|
|
8928
|
+
ceilingBytes;
|
|
8929
|
+
observedBytes;
|
|
8930
|
+
constructor(subject, observedBytes, atLeast = false, ceilingBytes = FORGE_READ_CEILING_BYTES) {
|
|
8931
|
+
super(`The forge response for ${subject} is ${atLeast ? "at least " : ""}${observedBytes} bytes, above the ${ceilingBytes}-byte read ceiling (FORGE_READ_CEILING_BYTES) — refusing rather than buffering it.`);
|
|
8932
|
+
this.name = "ForgeReadOversizeError";
|
|
8933
|
+
this.subject = subject;
|
|
8934
|
+
this.ceilingBytes = ceilingBytes;
|
|
8935
|
+
this.observedBytes = observedBytes;
|
|
8936
|
+
}
|
|
8937
|
+
}
|
|
8938
|
+
function isForgeReadOversize(err) {
|
|
8939
|
+
return err instanceof ForgeReadOversizeError;
|
|
8940
|
+
}
|
|
8941
|
+
function isBufferOverflow(err) {
|
|
8942
|
+
return err?.code === "ENOBUFS";
|
|
8943
|
+
}
|
|
8944
|
+
function runBounded(runner, args, subject, usedBytes) {
|
|
8945
|
+
const remaining = FORGE_READ_CEILING_BYTES - usedBytes;
|
|
8946
|
+
let out;
|
|
8947
|
+
try {
|
|
8948
|
+
out = runner(args, remaining);
|
|
8949
|
+
} catch (err) {
|
|
8950
|
+
if (isBufferOverflow(err))
|
|
8951
|
+
throw new ForgeReadOversizeError(subject, FORGE_READ_CEILING_BYTES + 1, true);
|
|
8952
|
+
throw err;
|
|
8953
|
+
}
|
|
8954
|
+
const size = Buffer.byteLength(out, "utf8");
|
|
8955
|
+
if (usedBytes + size > FORGE_READ_CEILING_BYTES)
|
|
8956
|
+
throw new ForgeReadOversizeError(subject, usedBytes + size);
|
|
8957
|
+
return out;
|
|
8958
|
+
}
|
|
8959
|
+
function readRestCommentRows(number, subjectLabel = `Issue ${number}`, runner = ghRunner) {
|
|
8960
|
+
const rows = [];
|
|
8961
|
+
let used = 0;
|
|
8962
|
+
for (let page = 1;; page++) {
|
|
8963
|
+
const out = runBounded(runner, ["api", `repos/{owner}/{repo}/issues/${number}/comments?per_page=${PAGE_SIZE}&page=${page}`], subjectLabel, used);
|
|
8964
|
+
used += Buffer.byteLength(out, "utf8");
|
|
8965
|
+
const pageRows = JSON.parse(out);
|
|
8966
|
+
rows.push(...pageRows);
|
|
8967
|
+
if (pageRows.length < PAGE_SIZE)
|
|
8968
|
+
return rows;
|
|
8969
|
+
}
|
|
8970
|
+
}
|
|
8971
|
+
function readIssueComments(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
8972
|
+
const number = resolveNumber(issue, subjectLabel, runner);
|
|
8973
|
+
const fromSnapshot = snapshotComments(number);
|
|
8974
|
+
if (fromSnapshot !== null)
|
|
8975
|
+
return fromSnapshot;
|
|
8976
|
+
return readRestCommentRows(number, subjectLabel, runner).map((r) => ({
|
|
8977
|
+
body: r.body ?? "",
|
|
8978
|
+
url: r.html_url ?? "",
|
|
8979
|
+
author: r.user?.login ? { login: r.user.login } : null
|
|
8980
|
+
}));
|
|
8981
|
+
}
|
|
8982
|
+
function readIssueBody(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
8983
|
+
if (forgeSnapshotDir() !== null) {
|
|
8984
|
+
const fromSnapshot = snapshotBody(resolveNumber(issue, subjectLabel, runner));
|
|
8985
|
+
if (fromSnapshot !== null)
|
|
8986
|
+
return fromSnapshot;
|
|
8987
|
+
}
|
|
8988
|
+
const out = runBounded(runner, ["issue", "view", String(issue), "--json", "body"], subjectLabel, 0);
|
|
8989
|
+
return JSON.parse(out).body ?? "";
|
|
8990
|
+
}
|
|
8991
|
+
function readIssueFields(issue, fields, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
8992
|
+
return JSON.parse(runBounded(runner, ["issue", "view", String(issue), "--json", fields], subjectLabel, 0));
|
|
8993
|
+
}
|
|
8994
|
+
function resolveNumber(issue, subjectLabel, runner) {
|
|
8995
|
+
if (typeof issue === "number")
|
|
8996
|
+
return issue;
|
|
8997
|
+
if (/^\d+$/.test(issue))
|
|
8998
|
+
return Number(issue);
|
|
8999
|
+
return readIssueFields(issue, "number", subjectLabel, runner).number;
|
|
9000
|
+
}
|
|
9001
|
+
|
|
9002
|
+
// src/checks/frozen-brief.ts
|
|
9003
|
+
function resolveTaskFrozenBrief(prBody, fetchComments, principalAllowlist, purpose) {
|
|
7467
9004
|
const { issue } = extractIssue(prBody);
|
|
7468
9005
|
if (issue === null) {
|
|
7469
|
-
return {
|
|
9006
|
+
return {
|
|
9007
|
+
ok: false,
|
|
9008
|
+
notFound: false,
|
|
9009
|
+
message: "not dispatched — no `Closes #N` in the PR body to resolve the task Issue."
|
|
9010
|
+
};
|
|
7470
9011
|
}
|
|
7471
|
-
let
|
|
9012
|
+
let comments;
|
|
7472
9013
|
try {
|
|
7473
|
-
|
|
9014
|
+
comments = fetchComments(issue);
|
|
7474
9015
|
} catch (err) {
|
|
7475
|
-
if (isIssueNotFoundError(err)) {
|
|
7476
|
-
return { ok: true, body: prBody };
|
|
7477
|
-
}
|
|
7478
9016
|
if (isForgeReadOversize(err))
|
|
7479
|
-
return { ok: false, message: err.message };
|
|
9017
|
+
return { ok: false, notFound: false, message: err.message };
|
|
7480
9018
|
return {
|
|
7481
9019
|
ok: false,
|
|
7482
|
-
|
|
9020
|
+
notFound: isIssueNotFoundError(err),
|
|
9021
|
+
message: `could not fetch Issue #${issue}'s comments to ${purpose}: ${err instanceof Error ? err.message : String(err)}`
|
|
7483
9022
|
};
|
|
7484
9023
|
}
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
9024
|
+
let principals;
|
|
9025
|
+
try {
|
|
9026
|
+
principals = principalAllowlist();
|
|
9027
|
+
} catch (err) {
|
|
9028
|
+
if (err instanceof PrincipalsUnresolvedError)
|
|
9029
|
+
return { ok: false, notFound: false, message: err.message };
|
|
9030
|
+
throw err;
|
|
9031
|
+
}
|
|
9032
|
+
const resolved = resolveNewestFrozenBrief(comments.map((c) => ({ body: c.body, author: c.author?.login ?? null })), principals);
|
|
7488
9033
|
if (!resolved) {
|
|
7489
|
-
return { ok: false, message: `not dispatched — no \`aeg:brief:v<k>\` comment on Issue #${issue}.` };
|
|
9034
|
+
return { ok: false, notFound: false, message: `not dispatched — no \`aeg:brief:v<k>\` comment on Issue #${issue}.` };
|
|
7490
9035
|
}
|
|
7491
|
-
return { ok: true,
|
|
9036
|
+
return { ok: true, content: resolved.content };
|
|
9037
|
+
}
|
|
9038
|
+
var defaultLiveCheckDeps = {
|
|
9039
|
+
fetchIssueComments: (issue) => readIssueComments(issue, `Issue #${issue}`),
|
|
9040
|
+
principalAllowlist: () => resolveTrustedPrincipals()
|
|
9041
|
+
};
|
|
9042
|
+
function resolveLiveCheckInputs(inputs, deps = defaultLiveCheckDeps) {
|
|
9043
|
+
const { body, branch, head } = inputs;
|
|
9044
|
+
const incomplete = incompleteForgeSnapshot();
|
|
9045
|
+
if (incomplete !== null)
|
|
9046
|
+
return { ok: false, message: incomplete };
|
|
9047
|
+
if (!isTaskBranch(branch))
|
|
9048
|
+
return { ok: true, live: undefined };
|
|
9049
|
+
if (!body) {
|
|
9050
|
+
return head ? { ok: false, message: `no pull request body was supplied for the pull request at \`${head}\`.` } : { ok: true, live: undefined };
|
|
9051
|
+
}
|
|
9052
|
+
const brief = resolveTaskFrozenBrief(body, deps.fetchIssueComments, deps.principalAllowlist, "learn its frozen brief's `[live]` lines");
|
|
9053
|
+
if (!brief.ok)
|
|
9054
|
+
return { ok: false, message: brief.message };
|
|
9055
|
+
return { ok: true, live: { liveCommands: parseLiveTestPlanItems(brief.content), head } };
|
|
9056
|
+
}
|
|
9057
|
+
|
|
9058
|
+
// src/checks/bin/check-brief-shape.ts
|
|
9059
|
+
var CHECK_NAME = "brief-shape";
|
|
9060
|
+
function resolveGradedBody(prBody, taskBranch) {
|
|
9061
|
+
if (!taskBranch)
|
|
9062
|
+
return { ok: true, body: prBody };
|
|
9063
|
+
const resolved = resolveTaskFrozenBrief(prBody, (issue) => readIssueComments(issue, `Issue #${issue}`), () => resolveTrustedPrincipals(), "grade the dispatched brief");
|
|
9064
|
+
if (resolved.ok)
|
|
9065
|
+
return { ok: true, body: resolved.content };
|
|
9066
|
+
if (resolved.notFound)
|
|
9067
|
+
return { ok: true, body: prBody };
|
|
9068
|
+
return { ok: false, message: resolved.message };
|
|
7492
9069
|
}
|
|
7493
9070
|
function listDirs(dir) {
|
|
7494
9071
|
try {
|
|
@@ -7499,7 +9076,7 @@ function listDirs(dir) {
|
|
|
7499
9076
|
}
|
|
7500
9077
|
function readJson(path) {
|
|
7501
9078
|
try {
|
|
7502
|
-
return JSON.parse(
|
|
9079
|
+
return JSON.parse(readFileSync4(path, "utf8"));
|
|
7503
9080
|
} catch {
|
|
7504
9081
|
return {};
|
|
7505
9082
|
}
|
|
@@ -7542,6 +9119,7 @@ function resolveObjectivesApplicability(prBody, taskBranch, objectivesSinceIssue
|
|
|
7542
9119
|
}
|
|
7543
9120
|
}
|
|
7544
9121
|
function main() {
|
|
9122
|
+
exitOnIncompleteForgeSnapshot(CHECK_NAME);
|
|
7545
9123
|
const prBody = process.env.PR_BODY ?? "";
|
|
7546
9124
|
if (!prBody) {
|
|
7547
9125
|
process.exit(0);
|
|
@@ -7559,7 +9137,7 @@ function main() {
|
|
|
7559
9137
|
check: CHECK_NAME,
|
|
7560
9138
|
severity: "error",
|
|
7561
9139
|
message: `brief-shape: ${gradedBodyResolution.message}`,
|
|
7562
|
-
agent_recovery_prompt: "Dispatch this task with `vinaya task dispatch <tranche> <n>` (posts the `aeg:brief:v1` Issue comment), or check `gh auth status`/network, then re-run `vinaya check brief-shape`."
|
|
9140
|
+
agent_recovery_prompt: "Dispatch this task with `vinaya task dispatch <tranche> <n>` (posts the `aeg:brief:v1` Issue comment), or check `gh auth status`/network, then re-run `vinaya check brief-shape`. " + "When the message says no Principal is configured, apply the fix it names instead."
|
|
7563
9141
|
});
|
|
7564
9142
|
process.exit(1);
|
|
7565
9143
|
}
|