@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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-changeset-coverage.ts
|
|
4
4
|
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
5
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
6
|
-
import { join as
|
|
5
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync9 } from "node:fs";
|
|
6
|
+
import { join as join11, relative as relative3 } from "node:path";
|
|
7
7
|
|
|
8
8
|
// ../../packages/aeg-core/src/entry-point.ts
|
|
9
9
|
import { realpathSync } from "node:fs";
|
|
@@ -44,7 +44,6 @@ var GATE_AUDIENCE = {
|
|
|
44
44
|
};
|
|
45
45
|
var NON_GATE_BINS = [
|
|
46
46
|
"archive-task",
|
|
47
|
-
"assign-task-issue",
|
|
48
47
|
"dead-branch-audit",
|
|
49
48
|
"eval-agent-compliance",
|
|
50
49
|
"open-issue",
|
|
@@ -307,6 +306,25 @@ async function runAsync(args) {
|
|
|
307
306
|
function ghApiGet(path) {
|
|
308
307
|
return JSON.parse(run(["api", path]));
|
|
309
308
|
}
|
|
309
|
+
var MAX_PER_PAGE = 100;
|
|
310
|
+
var MAX_PAGES = 100;
|
|
311
|
+
async function ghApiGetAllPagesAsync(pathWithoutPage, opts) {
|
|
312
|
+
const [base = pathWithoutPage, query = ""] = pathWithoutPage.split("?");
|
|
313
|
+
const params = new URLSearchParams(query);
|
|
314
|
+
params.set("per_page", String(MAX_PER_PAGE));
|
|
315
|
+
const all = [];
|
|
316
|
+
for (let page = 1;page <= MAX_PAGES; page++) {
|
|
317
|
+
params.set("page", String(page));
|
|
318
|
+
const args = ["api", `${base}?${params.toString()}`];
|
|
319
|
+
if (opts?.jq)
|
|
320
|
+
args.push("-q", opts.jq);
|
|
321
|
+
const batch = JSON.parse(await runAsync(args));
|
|
322
|
+
all.push(...batch);
|
|
323
|
+
if (batch.length < MAX_PER_PAGE)
|
|
324
|
+
return all;
|
|
325
|
+
}
|
|
326
|
+
throw new Error(`ghApiGetAllPagesAsync: "${pathWithoutPage}" did not terminate within ${MAX_PAGES} pages (${MAX_PAGES * MAX_PER_PAGE} items) — refusing to keep walking.`);
|
|
327
|
+
}
|
|
310
328
|
function issueListByLabelArgs(owner, repo, label) {
|
|
311
329
|
return [
|
|
312
330
|
"issue",
|
|
@@ -718,6 +736,10 @@ function intentGoalForSlug(description, slug) {
|
|
|
718
736
|
function matchesLegacyMilestone(milestones, slug) {
|
|
719
737
|
return milestones.find((m) => m.title === slug) ?? null;
|
|
720
738
|
}
|
|
739
|
+
var TRANCHE_SLUG_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*-v\d+$/;
|
|
740
|
+
function slugShapedTitles(milestones) {
|
|
741
|
+
return milestones.map((m) => m.title).filter((t) => TRANCHE_SLUG_SHAPE.test(t));
|
|
742
|
+
}
|
|
721
743
|
function factsFromLegacyMilestone(milestone) {
|
|
722
744
|
return {
|
|
723
745
|
goal: milestone.description ?? "",
|
|
@@ -751,6 +773,105 @@ function findMilestoneForSlug(owner, repo, slug) {
|
|
|
751
773
|
return resolveLegacyFacts(legacy, issues);
|
|
752
774
|
return { goal: goalFromMilestones(milestones, slug), lifecycle: lifecycleFromIssues(issues) };
|
|
753
775
|
}
|
|
776
|
+
function trancheSlugsFromLabels(labels) {
|
|
777
|
+
const slugs = [];
|
|
778
|
+
for (const l of labels) {
|
|
779
|
+
const slug = trancheSlugOf(l.name);
|
|
780
|
+
if (slug !== null)
|
|
781
|
+
slugs.push(slug);
|
|
782
|
+
}
|
|
783
|
+
return slugs;
|
|
784
|
+
}
|
|
785
|
+
async function indexTrancheMilestonesAsync(owner, repo, options = {}) {
|
|
786
|
+
const read = (fetch2) => options.retryFailedReads ? retryOnce(fetch2) : fetch2();
|
|
787
|
+
const [milestones, labels] = await Promise.all([
|
|
788
|
+
read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`)),
|
|
789
|
+
read(() => ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`))
|
|
790
|
+
]);
|
|
791
|
+
const active = [];
|
|
792
|
+
const archived = [];
|
|
793
|
+
const facts = new Map;
|
|
794
|
+
const legacySlugs = new Set(slugShapedTitles(milestones));
|
|
795
|
+
const legacyMilestoneBySlug = new Map(milestones.filter((m) => legacySlugs.has(m.title)).map((m) => [m.title, m]));
|
|
796
|
+
const newPathSlugs = trancheSlugsFromLabels(labels).filter((slug) => !legacySlugs.has(slug));
|
|
797
|
+
const uniqueNewPathSlugs = [...new Set(newPathSlugs)];
|
|
798
|
+
const uniqueLegacySlugs = [...legacySlugs];
|
|
799
|
+
const [legacyIssuesBySlug, newPathIssuesBySlug] = await Promise.all([
|
|
800
|
+
Promise.all(uniqueLegacySlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))))),
|
|
801
|
+
Promise.all(uniqueNewPathSlugs.map((slug) => read(() => ghIssueListByLabelAsync(owner, repo, trancheLabel(slug)))))
|
|
802
|
+
]);
|
|
803
|
+
const issuesBySlug = new Map;
|
|
804
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
805
|
+
issuesBySlug.set(slug, legacyIssuesBySlug[i] ?? []);
|
|
806
|
+
});
|
|
807
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
808
|
+
issuesBySlug.set(slug, newPathIssuesBySlug[i] ?? []);
|
|
809
|
+
});
|
|
810
|
+
uniqueLegacySlugs.forEach((slug, i) => {
|
|
811
|
+
const m = legacyMilestoneBySlug.get(slug);
|
|
812
|
+
if (!m)
|
|
813
|
+
return;
|
|
814
|
+
const ref = { slug, goal: m.description ?? "" };
|
|
815
|
+
const f = resolveLegacyFacts(m, legacyIssuesBySlug[i] ?? []);
|
|
816
|
+
if (f.lifecycle === "complete")
|
|
817
|
+
archived.push(ref);
|
|
818
|
+
else if (f.lifecycle === "active")
|
|
819
|
+
active.push(ref);
|
|
820
|
+
facts.set(slug, f);
|
|
821
|
+
});
|
|
822
|
+
uniqueNewPathSlugs.forEach((slug, i) => {
|
|
823
|
+
const issues = newPathIssuesBySlug[i] ?? [];
|
|
824
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
825
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
826
|
+
const f = { goal, lifecycle };
|
|
827
|
+
facts.set(slug, f);
|
|
828
|
+
if (lifecycle === "active")
|
|
829
|
+
active.push({ slug, goal });
|
|
830
|
+
else if (lifecycle === "complete")
|
|
831
|
+
archived.push({ slug, goal });
|
|
832
|
+
});
|
|
833
|
+
return { active, archived, facts, legacySlugs, issuesBySlug };
|
|
834
|
+
}
|
|
835
|
+
async function retryOnce(fetch2) {
|
|
836
|
+
try {
|
|
837
|
+
return await fetch2();
|
|
838
|
+
} catch {
|
|
839
|
+
return fetch2();
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
async function indexTrancheMilestonesForSlugAsync(owner, repo, slug) {
|
|
843
|
+
const [milestones, labels, issues] = await Promise.all([
|
|
844
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/milestones?state=all&per_page=100`),
|
|
845
|
+
ghApiGetAllPagesAsync(`repos/${owner}/${repo}/labels?per_page=100`),
|
|
846
|
+
ghIssueListByLabelAsync(owner, repo, trancheLabel(slug))
|
|
847
|
+
]);
|
|
848
|
+
const active = [];
|
|
849
|
+
const archived = [];
|
|
850
|
+
const facts = new Map;
|
|
851
|
+
const legacySlugs = new Set;
|
|
852
|
+
const legacyMilestone = slugShapedTitles(milestones).includes(slug) ? matchesLegacyMilestone(milestones, slug) : null;
|
|
853
|
+
if (legacyMilestone) {
|
|
854
|
+
legacySlugs.add(slug);
|
|
855
|
+
const ref = { slug, goal: legacyMilestone.description ?? "" };
|
|
856
|
+
const f = resolveLegacyFacts(legacyMilestone, issues);
|
|
857
|
+
if (f.lifecycle === "complete")
|
|
858
|
+
archived.push(ref);
|
|
859
|
+
else if (f.lifecycle === "active")
|
|
860
|
+
active.push(ref);
|
|
861
|
+
facts.set(slug, f);
|
|
862
|
+
} else if (trancheSlugsFromLabels(labels).includes(slug)) {
|
|
863
|
+
const lifecycle = lifecycleFromIssues(issues);
|
|
864
|
+
const goal = goalFromMilestones(milestones, slug);
|
|
865
|
+
facts.set(slug, { goal, lifecycle });
|
|
866
|
+
if (lifecycle === "active")
|
|
867
|
+
active.push({ slug, goal });
|
|
868
|
+
else if (lifecycle === "complete")
|
|
869
|
+
archived.push({ slug, goal });
|
|
870
|
+
}
|
|
871
|
+
const openLegacyTitles = new Set(slugShapedTitles(milestones.filter((m) => m.state === "open")));
|
|
872
|
+
const otherOpenLegacySlugs = [...openLegacyTitles].filter((t) => t !== slug);
|
|
873
|
+
return { active, archived, facts, legacySlugs, otherOpenLegacySlugs };
|
|
874
|
+
}
|
|
754
875
|
|
|
755
876
|
// ../../packages/aeg-forge-state/src/derive-from-forge.ts
|
|
756
877
|
function trancheFromIssues(slug, issues, known) {
|
|
@@ -1411,6 +1532,125 @@ var graphql2 = withDefaults3(request, {
|
|
|
1411
1532
|
method: "POST",
|
|
1412
1533
|
url: "/graphql"
|
|
1413
1534
|
});
|
|
1535
|
+
|
|
1536
|
+
// ../../packages/aeg-forge-state/src/fetch-provenance.ts
|
|
1537
|
+
var PROVENANCE_PATTERN = /^###\s+AEG provenance\b/im;
|
|
1538
|
+
function provenanceMatchesIssue(text, issueNum) {
|
|
1539
|
+
if (!PROVENANCE_PATTERN.test(text))
|
|
1540
|
+
return false;
|
|
1541
|
+
const m = text.match(/^-\s*Issue:\s*#(\d+)/im);
|
|
1542
|
+
return m !== null && Number(m[1]) === issueNum;
|
|
1543
|
+
}
|
|
1544
|
+
function isPrCloser(closer) {
|
|
1545
|
+
return closer !== null && typeof closer.number === "number";
|
|
1546
|
+
}
|
|
1547
|
+
async function fetchProvenanceViaCrossReferences(issueNums, owner, repo, token) {
|
|
1548
|
+
const result = new Map;
|
|
1549
|
+
if (issueNums.length === 0)
|
|
1550
|
+
return result;
|
|
1551
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1552
|
+
const perIssue = issueNums.map((n) => `
|
|
1553
|
+
i_${n}: issue(number: ${n}) {
|
|
1554
|
+
timelineItems(first: 50, itemTypes: [CROSS_REFERENCED_EVENT]) {
|
|
1555
|
+
nodes {
|
|
1556
|
+
... on CrossReferencedEvent {
|
|
1557
|
+
source {
|
|
1558
|
+
... on PullRequest {
|
|
1559
|
+
number
|
|
1560
|
+
body
|
|
1561
|
+
comments(first: 50) { nodes { body } }
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
}`).join("");
|
|
1568
|
+
const query = `query ProvenanceCrossRef($owner: String!, $repo: String!) {
|
|
1569
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1570
|
+
}
|
|
1571
|
+
}`;
|
|
1572
|
+
let response;
|
|
1573
|
+
try {
|
|
1574
|
+
response = await client(query, { owner, repo });
|
|
1575
|
+
} catch {
|
|
1576
|
+
return result;
|
|
1577
|
+
}
|
|
1578
|
+
if (!response.repository)
|
|
1579
|
+
return result;
|
|
1580
|
+
for (const n of issueNums) {
|
|
1581
|
+
const raw = response.repository[`i_${n}`];
|
|
1582
|
+
const nodes = raw?.timelineItems?.nodes ?? [];
|
|
1583
|
+
const found = nodes.some(({ source }) => {
|
|
1584
|
+
if (!source || typeof source.number !== "number")
|
|
1585
|
+
return false;
|
|
1586
|
+
const pr = source;
|
|
1587
|
+
if (provenanceMatchesIssue(pr.body ?? "", n))
|
|
1588
|
+
return true;
|
|
1589
|
+
return pr.comments.nodes.some((c) => provenanceMatchesIssue(c.body, n));
|
|
1590
|
+
});
|
|
1591
|
+
result.set(n, found);
|
|
1592
|
+
}
|
|
1593
|
+
return result;
|
|
1594
|
+
}
|
|
1595
|
+
async function fetchProvenance(issueNums, owner, repo, token) {
|
|
1596
|
+
const result = new Map;
|
|
1597
|
+
if (issueNums.length === 0)
|
|
1598
|
+
return result;
|
|
1599
|
+
const client = graphql2.defaults({ headers: { authorization: `bearer ${token}` } });
|
|
1600
|
+
const perIssue = issueNums.map((n) => `
|
|
1601
|
+
i_${n}: issue(number: ${n}) {
|
|
1602
|
+
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1603
|
+
nodes {
|
|
1604
|
+
... on ClosedEvent {
|
|
1605
|
+
closer {
|
|
1606
|
+
... on PullRequest {
|
|
1607
|
+
number
|
|
1608
|
+
body
|
|
1609
|
+
comments(first: 50) {
|
|
1610
|
+
nodes { body }
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
}`).join("");
|
|
1618
|
+
const query = `query Provenance($owner: String!, $repo: String!) {
|
|
1619
|
+
repository(owner: $owner, name: $repo) {${perIssue}
|
|
1620
|
+
}
|
|
1621
|
+
}`;
|
|
1622
|
+
let response;
|
|
1623
|
+
try {
|
|
1624
|
+
response = await client(query, { owner, repo });
|
|
1625
|
+
} catch {
|
|
1626
|
+
return result;
|
|
1627
|
+
}
|
|
1628
|
+
if (!response.repository)
|
|
1629
|
+
return result;
|
|
1630
|
+
const needsFallback = [];
|
|
1631
|
+
for (const n of issueNums) {
|
|
1632
|
+
const raw = response.repository[`i_${n}`];
|
|
1633
|
+
if (!raw) {
|
|
1634
|
+
result.set(n, false);
|
|
1635
|
+
continue;
|
|
1636
|
+
}
|
|
1637
|
+
const closer = raw.timelineItems?.nodes?.[0]?.closer;
|
|
1638
|
+
const c = closer ?? null;
|
|
1639
|
+
if (!isPrCloser(c)) {
|
|
1640
|
+
needsFallback.push(n);
|
|
1641
|
+
continue;
|
|
1642
|
+
}
|
|
1643
|
+
const bodyHas = PROVENANCE_PATTERN.test(c.body ?? "");
|
|
1644
|
+
const commentHas = c.comments.nodes.some((x) => PROVENANCE_PATTERN.test(x.body));
|
|
1645
|
+
result.set(n, bodyHas || commentHas);
|
|
1646
|
+
}
|
|
1647
|
+
if (needsFallback.length > 0) {
|
|
1648
|
+
const fallback = await fetchProvenanceViaCrossReferences(needsFallback, owner, repo, token);
|
|
1649
|
+
for (const [n, found] of fallback)
|
|
1650
|
+
result.set(n, found);
|
|
1651
|
+
}
|
|
1652
|
+
return result;
|
|
1653
|
+
}
|
|
1414
1654
|
// ../../packages/aeg-forge-state/src/github-token.ts
|
|
1415
1655
|
import { execFile as execFile2 } from "node:child_process";
|
|
1416
1656
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -1640,6 +1880,52 @@ function describeError(err) {
|
|
|
1640
1880
|
return err;
|
|
1641
1881
|
return "unknown error";
|
|
1642
1882
|
}
|
|
1883
|
+
// ../../packages/aeg-forge-state/src/prior-tranche-archival.ts
|
|
1884
|
+
function defaultPriorTrancheArchivalDeps() {
|
|
1885
|
+
return {
|
|
1886
|
+
activeTranches: async (excludeSlug, repo) => {
|
|
1887
|
+
const index = await indexTrancheMilestonesAsync(repo.owner, repo.repo, { retryFailedReads: true });
|
|
1888
|
+
return index.active.filter((m) => m.slug !== excludeSlug).map((m) => {
|
|
1889
|
+
const issues = index.issuesBySlug?.get(m.slug);
|
|
1890
|
+
if (!issues)
|
|
1891
|
+
throw new Error(`the Milestone index holds no Issue list for tranche \`${m.slug}\``);
|
|
1892
|
+
return { slug: m.slug, issues };
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
function reason(err) {
|
|
1898
|
+
return err instanceof Error ? err.message.split(`
|
|
1899
|
+
`)[0] ?? "failed" : String(err);
|
|
1900
|
+
}
|
|
1901
|
+
async function resolvePriorTrancheArchival(projects, excludeSlug, repo, deps = defaultPriorTrancheArchivalDeps()) {
|
|
1902
|
+
if (projects.length === 0)
|
|
1903
|
+
return { facts: [], infraFailure: null };
|
|
1904
|
+
let candidates;
|
|
1905
|
+
try {
|
|
1906
|
+
candidates = await deps.activeTranches(excludeSlug, repo);
|
|
1907
|
+
} catch (err) {
|
|
1908
|
+
return {
|
|
1909
|
+
facts: [],
|
|
1910
|
+
infraFailure: `severity:infra — could not read the active tranches (${reason(err)}); whether a prior tranche is archived is unknown.`
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
const tasksBySlug = new Map(candidates.map((c) => [c.slug, tasksFromIssues(c.issues)]));
|
|
1914
|
+
const facts = [];
|
|
1915
|
+
for (const project of projects) {
|
|
1916
|
+
let found = null;
|
|
1917
|
+
for (const { slug, issues } of candidates) {
|
|
1918
|
+
if (!(tasksBySlug.get(slug) ?? []).some((t) => t.projects.includes(project)))
|
|
1919
|
+
continue;
|
|
1920
|
+
if (!issues.some((issue) => issue.state === "OPEN")) {
|
|
1921
|
+
found = { project, priorTrancheSlug: slug, archived: false };
|
|
1922
|
+
break;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
facts.push(found ?? { project, priorTrancheSlug: null, archived: false });
|
|
1926
|
+
}
|
|
1927
|
+
return { facts, infraFailure: null };
|
|
1928
|
+
}
|
|
1643
1929
|
// ../../packages/aeg-forge-state/src/fetch-open-issues.ts
|
|
1644
1930
|
async function fetchOpenIssuesByLabel(slugs, owner, repo, token) {
|
|
1645
1931
|
const result = new Map;
|
|
@@ -1714,6 +2000,10 @@ function buildQuery(issueNumbers) {
|
|
|
1714
2000
|
}
|
|
1715
2001
|
}`;
|
|
1716
2002
|
}
|
|
2003
|
+
// ../../packages/aeg-forge-state/src/list-issue-milestones.ts
|
|
2004
|
+
function issueMilestonesFromIssues(issues) {
|
|
2005
|
+
return issues.filter((i) => i.state === "OPEN").map((i) => ({ issue: i.number, milestoneTitle: i.milestone?.title ?? null }));
|
|
2006
|
+
}
|
|
1717
2007
|
// ../../packages/aeg-forge-state/src/resolve-repo.ts
|
|
1718
2008
|
import { execFile as execFile3 } from "node:child_process";
|
|
1719
2009
|
import { promisify as promisify3 } from "node:util";
|
|
@@ -1776,7 +2066,8 @@ var ANCHOR_FIELDS = [
|
|
|
1776
2066
|
"PREMISE",
|
|
1777
2067
|
"TEST-PLAN",
|
|
1778
2068
|
"EVIDENCE",
|
|
1779
|
-
"BEYOND-SURFACE"
|
|
2069
|
+
"BEYOND-SURFACE",
|
|
2070
|
+
"LIVE"
|
|
1780
2071
|
];
|
|
1781
2072
|
function anchoredRegionBounds(body, field) {
|
|
1782
2073
|
const masked = maskCode(body);
|
|
@@ -1977,7 +2268,6 @@ var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
|
1977
2268
|
// ../../packages/aeg-core/src/waiver-label.ts
|
|
1978
2269
|
var WAIVER_LABEL = label("waiver-docs");
|
|
1979
2270
|
var WAIVER_LABEL_REVIEW = label("waiver-review");
|
|
1980
|
-
var PRINCIPAL_ALLOWLIST = ["daniboomerang"];
|
|
1981
2271
|
function isPrincipal(login, principalAllowlist) {
|
|
1982
2272
|
if (login === null)
|
|
1983
2273
|
return false;
|
|
@@ -1996,6 +2286,14 @@ var RULING_ORDINAL_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Ruling ordinal:\s*(\d+)(
|
|
|
1996
2286
|
var BRIEF_HASH_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Brief hash:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1997
2287
|
var POLICY_DIGEST_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Policy digest:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
|
|
1998
2288
|
var BASE_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged base:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
|
|
2289
|
+
var MANIFEST_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Manifest version:\s*(\d+)\s*$/im;
|
|
2290
|
+
var PAUSE_BOUND_RULING_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Pause-bound ruling:\s*(?:(\S+)\|(\S+)\|([0-9a-f]{64})|\(none\))\s*$/im;
|
|
2291
|
+
function extractPauseBoundRuling(comment) {
|
|
2292
|
+
const m = comment.match(PAUSE_BOUND_RULING_PATTERN);
|
|
2293
|
+
if (!m)
|
|
2294
|
+
return;
|
|
2295
|
+
return m[1] ? { rulingId: m[1], pauseId: m[2], contentDigest: m[3] } : null;
|
|
2296
|
+
}
|
|
1999
2297
|
function firstFiveLines(comment) {
|
|
2000
2298
|
return comment.split(`
|
|
2001
2299
|
`).slice(0, 5).join(`
|
|
@@ -2089,6 +2387,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2089
2387
|
danglingNote: `the most recent ${missingLabel} verdict comment carries a VERDICT-shaped line outside the first-five-line read window`
|
|
2090
2388
|
};
|
|
2091
2389
|
}
|
|
2390
|
+
const versionMatch = latest.match(MANIFEST_VERSION_PATTERN);
|
|
2391
|
+
const pauseBoundRuling = extractPauseBoundRuling(latest);
|
|
2092
2392
|
return {
|
|
2093
2393
|
value: m[1].toUpperCase().replace(/[_-]/g, " "),
|
|
2094
2394
|
headSha: extractHeadSha(latest),
|
|
@@ -2097,6 +2397,8 @@ function extractVerdict(comments, valuePattern, missingLabel) {
|
|
|
2097
2397
|
briefHash: extractBriefHash(latest),
|
|
2098
2398
|
policyDigest: extractPolicyDigest(latest),
|
|
2099
2399
|
baseSha: extractBaseSha(latest),
|
|
2400
|
+
...versionMatch ? { manifestVersion: Number.parseInt(versionMatch[1], 10) } : {},
|
|
2401
|
+
...pauseBoundRuling === undefined ? {} : { pauseBoundRuling },
|
|
2100
2402
|
findingSeverities: extractFindingSeverities(latest),
|
|
2101
2403
|
danglingNote: null
|
|
2102
2404
|
};
|
|
@@ -2107,6 +2409,16 @@ function extractCodeReviewVerdict(comments) {
|
|
|
2107
2409
|
function extractSecurityReviewVerdict(comments) {
|
|
2108
2410
|
return extractVerdict(comments, /^[ \t]*(?:\*{1,3}|_{1,3})?VERDICT:\s*(PASS|FAIL)(?![A-Za-z0-9])/im, "security-review");
|
|
2109
2411
|
}
|
|
2412
|
+
|
|
2413
|
+
// ../../packages/aeg-core/src/review-status.ts
|
|
2414
|
+
var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-(\d+)\s*-->/i;
|
|
2415
|
+
function parseDeveloperRoundMarker(body) {
|
|
2416
|
+
const m = body.match(DEVELOPER_ROUND_MARKER);
|
|
2417
|
+
if (!m)
|
|
2418
|
+
return null;
|
|
2419
|
+
const n = Number(m[1]);
|
|
2420
|
+
return Number.isFinite(n) ? n : null;
|
|
2421
|
+
}
|
|
2110
2422
|
// ../../packages/aeg-core/src/report-tokens.ts
|
|
2111
2423
|
var DASH_LOOKALIKES = {
|
|
2112
2424
|
"-": "‑",
|
|
@@ -2438,11 +2750,13 @@ var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
|
|
|
2438
2750
|
var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
|
|
2439
2751
|
var DEFAULT_MAX_ROUNDS = 3;
|
|
2440
2752
|
var DEFAULT_MAX_TASK_MINUTES = 180;
|
|
2753
|
+
var DEFAULT_READY_PUSH_TIMEOUT_MINUTES = 20;
|
|
2441
2754
|
var DEFAULT_REVIEW_POLICY = {
|
|
2442
2755
|
codeReviewThreshold: "BLOCKER",
|
|
2443
2756
|
securityThreshold: "HIGH",
|
|
2444
2757
|
maxRounds: DEFAULT_MAX_ROUNDS,
|
|
2445
|
-
maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
|
|
2758
|
+
maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES,
|
|
2759
|
+
readyPushTimeoutMinutes: DEFAULT_READY_PUSH_TIMEOUT_MINUTES
|
|
2446
2760
|
};
|
|
2447
2761
|
var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
|
|
2448
2762
|
var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
|
|
@@ -2802,14 +3116,14 @@ function checkTestPlan(prBody) {
|
|
|
2802
3116
|
const region = located.found ? located.section : prBody;
|
|
2803
3117
|
if (TEST_PLAN_UNIT_TESTS_ONLY_RE.test(region))
|
|
2804
3118
|
return { status: "pass", errors: [] };
|
|
2805
|
-
if (/\*\*\[(?:agent|principal)\]\*\*/.test(region))
|
|
3119
|
+
if (/\*\*\[(?:agent|principal|live)\]\*\*/.test(region))
|
|
2806
3120
|
return { status: "pass", errors: [] };
|
|
2807
3121
|
if (located.found && extractFencedBlocks(region).length > 0)
|
|
2808
3122
|
return { status: "pass", errors: [] };
|
|
2809
3123
|
return {
|
|
2810
3124
|
status: "fail",
|
|
2811
3125
|
errors: [
|
|
2812
|
-
"brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`-tagged
|
|
3126
|
+
"brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`/`**[live]**`-tagged item."
|
|
2813
3127
|
]
|
|
2814
3128
|
};
|
|
2815
3129
|
}
|
|
@@ -3431,6 +3745,375 @@ function checkPrReportDensity(prBody) {
|
|
|
3431
3745
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3432
3746
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3433
3747
|
}
|
|
3748
|
+
// ../../packages/aeg-core/src/prose-rules.ts
|
|
3749
|
+
var RETIRED_GLOBAL_EXEMPTIONS = [
|
|
3750
|
+
"docs/decisions-legacy.md",
|
|
3751
|
+
"apps/herald-ai/docs/",
|
|
3752
|
+
"apps/vada-ai/docs/",
|
|
3753
|
+
"aeg-root/tranches/completed/",
|
|
3754
|
+
"packages/aeg-core/src/docs/published-prose",
|
|
3755
|
+
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
3756
|
+
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
3757
|
+
"/fixtures/",
|
|
3758
|
+
"/node_modules/",
|
|
3759
|
+
"/.next/",
|
|
3760
|
+
"/.turbo/"
|
|
3761
|
+
];
|
|
3762
|
+
var PLAN_ON_DISK_PATTERNS = ["[Tt]opology files?", "aeg-root/tranches/", "aeg-project/"];
|
|
3763
|
+
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
3764
|
+
var RETIRED_PATTERN_EXEMPTIONS = {
|
|
3765
|
+
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
3766
|
+
[String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`]: [
|
|
3767
|
+
"docs-index.md",
|
|
3768
|
+
"apps/vada-ai/specs/legacy/README.md",
|
|
3769
|
+
"apps/vada-ai/specs/vada-product-spec.md",
|
|
3770
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3771
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3772
|
+
],
|
|
3773
|
+
"decisions-legacy": [
|
|
3774
|
+
"packages/aeg-core/src/file-classify.ts",
|
|
3775
|
+
"packages/aeg-core/src/file-classify.test.ts",
|
|
3776
|
+
"packages/aeg-core/src/pr-tier.test.ts",
|
|
3777
|
+
"docs-index.md",
|
|
3778
|
+
".claude/skills/database/SKILL.md",
|
|
3779
|
+
".claude/skills/vada-architecture/SKILL.md",
|
|
3780
|
+
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
3781
|
+
"apps/vada-ai/web/CLAUDE.md",
|
|
3782
|
+
"apps/vada-ai/CLAUDE.md"
|
|
3783
|
+
],
|
|
3784
|
+
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
3785
|
+
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
3786
|
+
};
|
|
3787
|
+
var retiredPatterns = [
|
|
3788
|
+
String.raw`\bD-[0-9]{3}\b`,
|
|
3789
|
+
"D-(###|NNN|nnn|xxx)",
|
|
3790
|
+
"decision (entry|logged)",
|
|
3791
|
+
"decision-log entry",
|
|
3792
|
+
"decision log entry",
|
|
3793
|
+
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
3794
|
+
"decision-log",
|
|
3795
|
+
"decision entr",
|
|
3796
|
+
"decisions? (are |is )?logged",
|
|
3797
|
+
"log entries",
|
|
3798
|
+
String.raw`(^|[^-_a-zA-Z0-9])decisions\.md`,
|
|
3799
|
+
"decisions-legacy",
|
|
3800
|
+
"CONTRADICTION",
|
|
3801
|
+
"assumes Tier 3",
|
|
3802
|
+
"Lock: ?YES",
|
|
3803
|
+
"Lock: ?NO",
|
|
3804
|
+
"lock approvals?",
|
|
3805
|
+
"approves locks",
|
|
3806
|
+
"Conforms to lock",
|
|
3807
|
+
"Challenges lock",
|
|
3808
|
+
"checkDecisionNumbersFresh",
|
|
3809
|
+
String.raw`roles/team-leader\.md`,
|
|
3810
|
+
String.raw`\(,`,
|
|
3811
|
+
String.raw`,\)`,
|
|
3812
|
+
String.raw`\(\.\)`,
|
|
3813
|
+
...PLAN_ON_DISK_PATTERNS
|
|
3814
|
+
];
|
|
3815
|
+
var published = [
|
|
3816
|
+
["decision-id", "a decision id", /\bD-\d{3,}\b/],
|
|
3817
|
+
["section-ref", "a section reference", /§/],
|
|
3818
|
+
["forge-number", "a forge number", /#\d+/],
|
|
3819
|
+
["retired-name", "the retired public name", /\bAEG\b/],
|
|
3820
|
+
["tranche-slug", "a tranche slug", /\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+-v\d+\b/],
|
|
3821
|
+
[
|
|
3822
|
+
"label-vocabulary",
|
|
3823
|
+
"forge label vocabulary",
|
|
3824
|
+
/(?:vinaya\/)?\b(?:tranche|iteration|tier|needs|waiver|project|aeg):(?![/\s]|$)/
|
|
3825
|
+
],
|
|
3826
|
+
["internal-path", "a repo-internal path", /\b(?:packages|apps|aeg-root|tools|scripts)\//],
|
|
3827
|
+
["internal-path", "a repo-internal path", /\.(?:claude|husky|github)\//],
|
|
3828
|
+
[
|
|
3829
|
+
"internal-path",
|
|
3830
|
+
"a repo-internal file",
|
|
3831
|
+
/(?:^|[\s(`"'[])[\w.-]+(?:\/[\w.-]+)*\.(?:ts|tsx|js|jsx|mjs|cjs|sh|ya?ml|json|md)\b/
|
|
3832
|
+
]
|
|
3833
|
+
];
|
|
3834
|
+
var DEFAULT_PROSE_RULES = [
|
|
3835
|
+
{
|
|
3836
|
+
id: "forge-number",
|
|
3837
|
+
group: "reader-resolvable",
|
|
3838
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3839
|
+
patterns: { prose: /#[0-9]{2,4}/g },
|
|
3840
|
+
flags: ["global"],
|
|
3841
|
+
message: "a forge number",
|
|
3842
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3843
|
+
exemptions: []
|
|
3844
|
+
},
|
|
3845
|
+
{
|
|
3846
|
+
id: "tranche-slug",
|
|
3847
|
+
group: "reader-resolvable",
|
|
3848
|
+
scopes: ["ships", "reader-facing", "product", "spec"],
|
|
3849
|
+
patterns: { prose: /[a-z][a-z-]+-v[0-9]/g },
|
|
3850
|
+
flags: ["global"],
|
|
3851
|
+
message: "an internal tranche slug",
|
|
3852
|
+
severity: { ships: "warning", "reader-facing": "warning", product: "error", spec: "error" },
|
|
3853
|
+
exemptions: []
|
|
3854
|
+
},
|
|
3855
|
+
{
|
|
3856
|
+
id: "task-number",
|
|
3857
|
+
group: "reader-resolvable",
|
|
3858
|
+
scopes: ["spec"],
|
|
3859
|
+
patterns: { prose: /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi },
|
|
3860
|
+
flags: ["global", "ignore-case"],
|
|
3861
|
+
message: "a task number",
|
|
3862
|
+
severity: { spec: "error" },
|
|
3863
|
+
exemptions: []
|
|
3864
|
+
},
|
|
3865
|
+
{
|
|
3866
|
+
id: "source-comment-tranche-slug",
|
|
3867
|
+
group: "reader-resolvable",
|
|
3868
|
+
scopes: ["source-comment"],
|
|
3869
|
+
patterns: { comment: /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g },
|
|
3870
|
+
flags: ["global"],
|
|
3871
|
+
message: "a tranche-slug citation",
|
|
3872
|
+
severity: { "source-comment": "warning" },
|
|
3873
|
+
exemptions: []
|
|
3874
|
+
},
|
|
3875
|
+
{
|
|
3876
|
+
id: "source-comment-forge-number",
|
|
3877
|
+
group: "reader-resolvable",
|
|
3878
|
+
scopes: ["source-comment"],
|
|
3879
|
+
patterns: { comment: /#[0-9]{2,}/g },
|
|
3880
|
+
flags: ["global"],
|
|
3881
|
+
message: "a forge-number citation",
|
|
3882
|
+
severity: { "source-comment": "warning" },
|
|
3883
|
+
exemptions: []
|
|
3884
|
+
},
|
|
3885
|
+
{
|
|
3886
|
+
id: "legacy-batch-name",
|
|
3887
|
+
group: "reader-resolvable",
|
|
3888
|
+
scopes: ["ships", "reader-facing", "spec"],
|
|
3889
|
+
patterns: {},
|
|
3890
|
+
flags: ["built-in"],
|
|
3891
|
+
message: "an internal tranche slug",
|
|
3892
|
+
severity: { ships: "warning", "reader-facing": "warning", spec: "error" },
|
|
3893
|
+
exemptions: [],
|
|
3894
|
+
builtIn: true
|
|
3895
|
+
},
|
|
3896
|
+
{
|
|
3897
|
+
id: "coined-term",
|
|
3898
|
+
group: "reader-resolvable",
|
|
3899
|
+
scopes: ["ships", "reader-facing"],
|
|
3900
|
+
patterns: {},
|
|
3901
|
+
flags: ["built-in"],
|
|
3902
|
+
message: "uses coined term without defining it inline or linking the glossary",
|
|
3903
|
+
severity: { ships: "warning", "reader-facing": "warning" },
|
|
3904
|
+
exemptions: [],
|
|
3905
|
+
builtIn: true
|
|
3906
|
+
},
|
|
3907
|
+
...retiredPatterns.map((pattern, index) => ({
|
|
3908
|
+
id: `retired-vocabulary-${index + 1}`,
|
|
3909
|
+
group: "retired-vocabulary",
|
|
3910
|
+
scopes: ["repository"],
|
|
3911
|
+
patterns: { repository: pattern },
|
|
3912
|
+
flags: [],
|
|
3913
|
+
message: "retired vocabulary",
|
|
3914
|
+
severity: { repository: "error" },
|
|
3915
|
+
exemptions: RETIRED_GLOBAL_EXEMPTIONS,
|
|
3916
|
+
patternExemptions: RETIRED_PATTERN_EXEMPTIONS
|
|
3917
|
+
})),
|
|
3918
|
+
...published.map(([id, message, pattern]) => ({
|
|
3919
|
+
id,
|
|
3920
|
+
group: "published-prose",
|
|
3921
|
+
scopes: ["published"],
|
|
3922
|
+
patterns: { published: pattern },
|
|
3923
|
+
flags: [],
|
|
3924
|
+
message,
|
|
3925
|
+
severity: { published: "error" },
|
|
3926
|
+
exemptions: [".worktrees/task/<tranche>/<n>", "task/<tranche>/<n>", ".worktrees/"]
|
|
3927
|
+
}))
|
|
3928
|
+
];
|
|
3929
|
+
var rulesForGroup = (group) => DEFAULT_PROSE_RULES.filter((rule) => rule.group === group);
|
|
3930
|
+
var RESOLVABLE_SCOPES = ["ships", "reader-facing", "product", "spec", "source-comment"];
|
|
3931
|
+
var RETIRED_SCOPES = ["repository"];
|
|
3932
|
+
var CONFIGURABLE_PROSE_SCOPES = [...RESOLVABLE_SCOPES, ...RETIRED_SCOPES];
|
|
3933
|
+
function groupOfScope(scope) {
|
|
3934
|
+
if (RESOLVABLE_SCOPES.includes(scope))
|
|
3935
|
+
return "reader-resolvable";
|
|
3936
|
+
if (RETIRED_SCOPES.includes(scope))
|
|
3937
|
+
return "retired-vocabulary";
|
|
3938
|
+
return;
|
|
3939
|
+
}
|
|
3940
|
+
var CONFIGURED_PROSE_FLAGS = ["i", "u"];
|
|
3941
|
+
var CONFIGURED_PATTERN_MAX_LENGTH = 200;
|
|
3942
|
+
var CONFIGURABLE_DEFAULT_RULES = DEFAULT_PROSE_RULES.filter((rule) => rule.group !== "published-prose");
|
|
3943
|
+
function allowedScopesFor(rule) {
|
|
3944
|
+
if (rule.builtIn)
|
|
3945
|
+
return rule.scopes;
|
|
3946
|
+
return rule.group === "retired-vocabulary" ? RETIRED_SCOPES : RESOLVABLE_SCOPES;
|
|
3947
|
+
}
|
|
3948
|
+
function normalizeRepoPath(entry) {
|
|
3949
|
+
let out = entry.replace(/\\/g, "/");
|
|
3950
|
+
while (out.startsWith("./"))
|
|
3951
|
+
out = out.slice(2);
|
|
3952
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3953
|
+
while (out.endsWith("/"))
|
|
3954
|
+
out = out.slice(0, -1);
|
|
3955
|
+
return out;
|
|
3956
|
+
}
|
|
3957
|
+
function isConfiguredExempt(path, exempt, repoRoot) {
|
|
3958
|
+
if (exempt.length === 0)
|
|
3959
|
+
return false;
|
|
3960
|
+
const root = repoRoot === undefined ? undefined : normalizeRepoPath(repoRoot);
|
|
3961
|
+
let rel = normalizeRepoPath(path);
|
|
3962
|
+
if (root && rel.startsWith(`${root}/`))
|
|
3963
|
+
rel = rel.slice(root.length + 1);
|
|
3964
|
+
return exempt.some((entry) => {
|
|
3965
|
+
const e = normalizeRepoPath(entry);
|
|
3966
|
+
return rel === e || rel.startsWith(`${e}/`);
|
|
3967
|
+
});
|
|
3968
|
+
}
|
|
3969
|
+
function ruleReads(set, rule, path) {
|
|
3970
|
+
return !isConfiguredExempt(path, set.exempt, set.repoRoot) && !isConfiguredExempt(path, rule.exempt, set.repoRoot);
|
|
3971
|
+
}
|
|
3972
|
+
var RESOLVABLE_RUN_ORDER = [
|
|
3973
|
+
"forge-number",
|
|
3974
|
+
"tranche-slug",
|
|
3975
|
+
"legacy-batch-name",
|
|
3976
|
+
"task-number",
|
|
3977
|
+
"source-comment-tranche-slug",
|
|
3978
|
+
"source-comment-forge-number",
|
|
3979
|
+
"coined-term"
|
|
3980
|
+
];
|
|
3981
|
+
var REPORT_GROUPS = { "task-number": 2, "legacy-batch-name": 2 };
|
|
3982
|
+
function scopeDefaultSeverity(scope, sourceCommentSeverity) {
|
|
3983
|
+
if (scope === "source-comment")
|
|
3984
|
+
return sourceCommentSeverity ?? "warning";
|
|
3985
|
+
if (scope === "repository")
|
|
3986
|
+
return "error";
|
|
3987
|
+
return "warning";
|
|
3988
|
+
}
|
|
3989
|
+
function applySeverity(scopes, base, setting) {
|
|
3990
|
+
const out = {};
|
|
3991
|
+
for (const scope of scopes) {
|
|
3992
|
+
const configured = typeof setting === "string" ? setting : setting?.[scope];
|
|
3993
|
+
const value = configured ?? base[scope];
|
|
3994
|
+
if (value !== undefined)
|
|
3995
|
+
out[scope] = value;
|
|
3996
|
+
}
|
|
3997
|
+
return out;
|
|
3998
|
+
}
|
|
3999
|
+
function defaultPatternFor(rule) {
|
|
4000
|
+
const cache = new Map;
|
|
4001
|
+
return (scope) => {
|
|
4002
|
+
if (cache.has(scope))
|
|
4003
|
+
return cache.get(scope) ?? null;
|
|
4004
|
+
const own = rule.patterns[scope] ?? (scope === "source-comment" ? rule.patterns.comment : rule.patterns.prose) ?? Object.values(rule.patterns)[0];
|
|
4005
|
+
const compiled = own === undefined ? null : own instanceof RegExp ? own : new RegExp(own);
|
|
4006
|
+
cache.set(scope, compiled);
|
|
4007
|
+
return compiled;
|
|
4008
|
+
};
|
|
4009
|
+
}
|
|
4010
|
+
function customPatternFor(rule, global) {
|
|
4011
|
+
const cache = new Map;
|
|
4012
|
+
return (scope) => {
|
|
4013
|
+
if (cache.has(scope))
|
|
4014
|
+
return cache.get(scope) ?? null;
|
|
4015
|
+
const source = rule.patterns?.[scope] ?? rule.pattern;
|
|
4016
|
+
const compiled = source === undefined ? null : new RegExp(source, `${rule.flags ?? ""}${global ? "g" : ""}`);
|
|
4017
|
+
cache.set(scope, compiled);
|
|
4018
|
+
return compiled;
|
|
4019
|
+
};
|
|
4020
|
+
}
|
|
4021
|
+
function resolveProseRules(config = undefined, options = {}) {
|
|
4022
|
+
const rules = [];
|
|
4023
|
+
const defaults = config?.defaults ?? {};
|
|
4024
|
+
for (const rule of CONFIGURABLE_DEFAULT_RULES) {
|
|
4025
|
+
const override = defaults[rule.id];
|
|
4026
|
+
if (override === "off")
|
|
4027
|
+
continue;
|
|
4028
|
+
const group = rule.group;
|
|
4029
|
+
const scopes = override?.scopes ?? rule.scopes;
|
|
4030
|
+
const base = {};
|
|
4031
|
+
for (const scope of scopes) {
|
|
4032
|
+
base[scope] = scope === "source-comment" ? options.sourceCommentSeverity ?? rule.severity[scope] ?? "warning" : rule.severity[scope] ?? scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4033
|
+
}
|
|
4034
|
+
rules.push({
|
|
4035
|
+
id: rule.id,
|
|
4036
|
+
group,
|
|
4037
|
+
custom: false,
|
|
4038
|
+
builtIn: rule.builtIn === true,
|
|
4039
|
+
scopes,
|
|
4040
|
+
message: rule.message,
|
|
4041
|
+
severity: applySeverity(scopes, base, override?.severity),
|
|
4042
|
+
exempt: override?.exempt ?? [],
|
|
4043
|
+
substringExempt: rule.exemptions,
|
|
4044
|
+
reportGroup: REPORT_GROUPS[rule.id],
|
|
4045
|
+
patternFor: defaultPatternFor(rule)
|
|
4046
|
+
});
|
|
4047
|
+
}
|
|
4048
|
+
for (const rule of config?.custom ?? []) {
|
|
4049
|
+
const group = groupOfScope(rule.scopes[0] ?? "") ?? "reader-resolvable";
|
|
4050
|
+
const base = {};
|
|
4051
|
+
for (const scope of rule.scopes)
|
|
4052
|
+
base[scope] = scopeDefaultSeverity(scope, options.sourceCommentSeverity);
|
|
4053
|
+
rules.push({
|
|
4054
|
+
id: rule.id,
|
|
4055
|
+
group,
|
|
4056
|
+
custom: true,
|
|
4057
|
+
builtIn: false,
|
|
4058
|
+
scopes: rule.scopes,
|
|
4059
|
+
message: rule.means,
|
|
4060
|
+
severity: applySeverity(rule.scopes, base, rule.severity),
|
|
4061
|
+
exempt: rule.exempt ?? [],
|
|
4062
|
+
substringExempt: [],
|
|
4063
|
+
patternFor: customPatternFor(rule, group === "reader-resolvable")
|
|
4064
|
+
});
|
|
4065
|
+
}
|
|
4066
|
+
if (options.decisionRecordsPath !== undefined)
|
|
4067
|
+
rules.push(decisionRecordCitationRule(options.decisionRecordsPath));
|
|
4068
|
+
const order = (rule) => {
|
|
4069
|
+
const at = RESOLVABLE_RUN_ORDER.indexOf(rule.id);
|
|
4070
|
+
return rule.custom || at === -1 ? RESOLVABLE_RUN_ORDER.length : at;
|
|
4071
|
+
};
|
|
4072
|
+
const resolvable = rules.filter((rule) => rule.group === "reader-resolvable");
|
|
4073
|
+
const sorted = resolvable.map((rule, index) => ({ rule, index })).sort((a, b) => order(a.rule) - order(b.rule) || a.index - b.index).map(({ rule }) => rule);
|
|
4074
|
+
return {
|
|
4075
|
+
rules: [...sorted, ...rules.filter((rule) => rule.group === "retired-vocabulary")],
|
|
4076
|
+
exempt: config?.exempt ?? [],
|
|
4077
|
+
repoRoot: options.repoRoot
|
|
4078
|
+
};
|
|
4079
|
+
}
|
|
4080
|
+
function rulesOfGroup(set, group) {
|
|
4081
|
+
return set.rules.filter((rule) => rule.group === group);
|
|
4082
|
+
}
|
|
4083
|
+
function rulesInScope(set, scope) {
|
|
4084
|
+
return set.rules.filter((rule) => rule.scopes.includes(scope));
|
|
4085
|
+
}
|
|
4086
|
+
var DEFAULT_PROSE_RULE_SET = resolveProseRules();
|
|
4087
|
+
var DECISION_RECORD_CITATION_ID = "decision-record-citation";
|
|
4088
|
+
var DECISION_RECORD_CITATION_SCOPES = ["ships", "product", "spec", "source-comment"];
|
|
4089
|
+
var DECISION_RECORD_CITATION_MESSAGE = "a decision-record number";
|
|
4090
|
+
function escapeRegExp(text) {
|
|
4091
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4092
|
+
}
|
|
4093
|
+
function decisionRecordCitationPattern(decisionRecordsPath) {
|
|
4094
|
+
const folder = escapeRegExp(normalizeRepoPath(decisionRecordsPath));
|
|
4095
|
+
return new RegExp(String.raw`\bADR[- ]?[0-9]+\b|(?<![A-Za-z0-9_-])${folder}/[0-9]+[A-Za-z0-9._-]*`, "g");
|
|
4096
|
+
}
|
|
4097
|
+
function decisionRecordCitationRule(decisionRecordsPath) {
|
|
4098
|
+
const folder = normalizeRepoPath(decisionRecordsPath);
|
|
4099
|
+
const pattern = decisionRecordCitationPattern(folder);
|
|
4100
|
+
const severity = {};
|
|
4101
|
+
for (const scope of DECISION_RECORD_CITATION_SCOPES)
|
|
4102
|
+
severity[scope] = "error";
|
|
4103
|
+
return {
|
|
4104
|
+
id: DECISION_RECORD_CITATION_ID,
|
|
4105
|
+
group: "reader-resolvable",
|
|
4106
|
+
custom: false,
|
|
4107
|
+
builtIn: false,
|
|
4108
|
+
scopes: DECISION_RECORD_CITATION_SCOPES,
|
|
4109
|
+
message: DECISION_RECORD_CITATION_MESSAGE,
|
|
4110
|
+
severity,
|
|
4111
|
+
exempt: [folder],
|
|
4112
|
+
substringExempt: [],
|
|
4113
|
+
patternFor: () => pattern
|
|
4114
|
+
};
|
|
4115
|
+
}
|
|
4116
|
+
|
|
3434
4117
|
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3435
4118
|
var PRODUCT_SLUG_SCOPE = [
|
|
3436
4119
|
"apps/cli/src",
|
|
@@ -3442,8 +4125,8 @@ var PRODUCT_SLUG_SCOPE = [
|
|
|
3442
4125
|
function isUnderOrEqual(path, prefix) {
|
|
3443
4126
|
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3444
4127
|
}
|
|
3445
|
-
function isProductScopeFile(path) {
|
|
3446
|
-
return
|
|
4128
|
+
function isProductScopeFile(path, productPaths) {
|
|
4129
|
+
return productPaths.some((prefix) => isUnderOrEqual(path, normalizeRepoPath(prefix)));
|
|
3447
4130
|
}
|
|
3448
4131
|
var SHIPS_PREFIX = "aeg-root/";
|
|
3449
4132
|
function shipsArchivePrefix(shipsPrefix) {
|
|
@@ -3451,13 +4134,7 @@ function shipsArchivePrefix(shipsPrefix) {
|
|
|
3451
4134
|
}
|
|
3452
4135
|
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3453
4136
|
function normalizeSpecPath(entry) {
|
|
3454
|
-
|
|
3455
|
-
while (out.startsWith("./"))
|
|
3456
|
-
out = out.slice(2);
|
|
3457
|
-
out = out.replace(/\/{2,}/g, "/");
|
|
3458
|
-
while (out.endsWith("/"))
|
|
3459
|
-
out = out.slice(0, -1);
|
|
3460
|
-
return out;
|
|
4137
|
+
return normalizeRepoPath(entry);
|
|
3461
4138
|
}
|
|
3462
4139
|
function isSpecFile2(path, specPaths) {
|
|
3463
4140
|
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
@@ -3469,7 +4146,7 @@ function isSpecFile2(path, specPaths) {
|
|
|
3469
4146
|
function isClaudeMdFile(path) {
|
|
3470
4147
|
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3471
4148
|
}
|
|
3472
|
-
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
4149
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS, productPaths = PRODUCT_SLUG_SCOPE) {
|
|
3473
4150
|
if (path.startsWith(shipsPrefix)) {
|
|
3474
4151
|
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3475
4152
|
}
|
|
@@ -3480,7 +4157,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
|
|
|
3480
4157
|
return "internal";
|
|
3481
4158
|
if (isSpecFile2(path, specPaths))
|
|
3482
4159
|
return "spec";
|
|
3483
|
-
if (isProductScopeFile(path))
|
|
4160
|
+
if (isProductScopeFile(path, productPaths))
|
|
3484
4161
|
return "product";
|
|
3485
4162
|
return null;
|
|
3486
4163
|
}
|
|
@@ -3505,9 +4182,16 @@ function lineAt(content, index) {
|
|
|
3505
4182
|
}
|
|
3506
4183
|
return line;
|
|
3507
4184
|
}
|
|
3508
|
-
var
|
|
3509
|
-
var
|
|
3510
|
-
|
|
4185
|
+
var readerRules = rulesForGroup("reader-resolvable");
|
|
4186
|
+
var readerPattern = (id, scope = "prose") => {
|
|
4187
|
+
const pattern = readerRules.find((rule) => rule.id === id)?.patterns[scope];
|
|
4188
|
+
if (!(pattern instanceof RegExp))
|
|
4189
|
+
throw new Error(`default prose rule ${id} has no ${scope} pattern`);
|
|
4190
|
+
return pattern;
|
|
4191
|
+
};
|
|
4192
|
+
var FORGE_NUMBER_PATTERN = readerPattern("forge-number");
|
|
4193
|
+
var TRANCHE_SLUG_VN_PATTERN = readerPattern("tranche-slug");
|
|
4194
|
+
var TASK_NUMBER_PATTERN = readerPattern("task-number");
|
|
3511
4195
|
function legacySlugPattern(legacySlugs) {
|
|
3512
4196
|
if (legacySlugs.length === 0)
|
|
3513
4197
|
return null;
|
|
@@ -3517,48 +4201,61 @@ function legacySlugPattern(legacySlugs) {
|
|
|
3517
4201
|
function specGrandfatherPaths(specGrandfather) {
|
|
3518
4202
|
return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
|
|
3519
4203
|
}
|
|
3520
|
-
|
|
4204
|
+
var REFERENCE_CLASSES = new Set(["ships", "reader-facing", "product", "spec"]);
|
|
4205
|
+
function referenceRulesFor(set, cls) {
|
|
4206
|
+
return rulesInScope(set, cls).filter((rule) => rule.group === "reader-resolvable" && rule.id !== "coined-term");
|
|
4207
|
+
}
|
|
4208
|
+
function citations(pattern, text, group) {
|
|
4209
|
+
const out = [];
|
|
4210
|
+
const re = pattern.global ? pattern : new RegExp(pattern.source, `${pattern.flags}g`);
|
|
4211
|
+
re.lastIndex = 0;
|
|
4212
|
+
let match = re.exec(text);
|
|
4213
|
+
while (match !== null) {
|
|
4214
|
+
if (match[0] === "") {
|
|
4215
|
+
re.lastIndex++;
|
|
4216
|
+
} else {
|
|
4217
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4218
|
+
out.push({ cited, index: match.index + match[0].indexOf(cited) });
|
|
4219
|
+
}
|
|
4220
|
+
match = re.exec(text);
|
|
4221
|
+
}
|
|
4222
|
+
re.lastIndex = 0;
|
|
4223
|
+
return out;
|
|
4224
|
+
}
|
|
4225
|
+
function customMessage(rule, cited) {
|
|
4226
|
+
return `${rule.id}: ${rule.message} ("${cited}")`;
|
|
4227
|
+
}
|
|
4228
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
4229
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4230
|
+
const productPaths = options.productPaths ?? PRODUCT_SLUG_SCOPE;
|
|
3521
4231
|
const findings = [];
|
|
3522
4232
|
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3523
4233
|
const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
|
|
3524
4234
|
const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
|
|
3525
|
-
const patterns = [
|
|
3526
|
-
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3527
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3528
|
-
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3529
|
-
];
|
|
3530
|
-
const productPatterns = [
|
|
3531
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3532
|
-
];
|
|
3533
|
-
const specPatterns = [
|
|
3534
|
-
...patterns,
|
|
3535
|
-
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3536
|
-
];
|
|
3537
4235
|
for (const file of files) {
|
|
3538
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3539
|
-
if (!cls || cls
|
|
3540
|
-
continue;
|
|
3541
|
-
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
4236
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths, productPaths);
|
|
4237
|
+
if (!cls || !REFERENCE_CLASSES.has(cls))
|
|
3542
4238
|
continue;
|
|
3543
4239
|
if (cls === "spec" && grandfatheredWhole.has(file.path))
|
|
3544
4240
|
continue;
|
|
3545
|
-
const blocking = cls === "product" || cls === "spec";
|
|
3546
4241
|
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3547
|
-
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3548
4242
|
const fileFindings = [];
|
|
3549
|
-
for (const
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
4243
|
+
for (const rule of referenceRulesFor(set, cls)) {
|
|
4244
|
+
if (!ruleReads(set, rule, file.path))
|
|
4245
|
+
continue;
|
|
4246
|
+
const pattern = !rule.custom && rule.id === "legacy-batch-name" ? legacyPattern : rule.patternFor(cls);
|
|
4247
|
+
if (!pattern)
|
|
4248
|
+
continue;
|
|
4249
|
+
const blocking = rule.severity[cls] === "error";
|
|
4250
|
+
const what = cls === "product" ? `${rule.message} in product code` : rule.message;
|
|
4251
|
+
for (const { cited, index } of citations(pattern, scrubbed, rule.custom ? undefined : rule.reportGroup)) {
|
|
3555
4252
|
fileFindings.push({
|
|
3556
4253
|
file: file.path,
|
|
3557
|
-
line: lineAt(scrubbed,
|
|
3558
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3559
|
-
blocking
|
|
4254
|
+
line: lineAt(scrubbed, index),
|
|
4255
|
+
message: rule.custom ? customMessage(rule, cited) : `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4256
|
+
blocking,
|
|
4257
|
+
rule: rule.id
|
|
3560
4258
|
});
|
|
3561
|
-
match = pattern.exec(scrubbed);
|
|
3562
4259
|
}
|
|
3563
4260
|
}
|
|
3564
4261
|
const limit = cls === "spec" ? limits.get(file.path) : undefined;
|
|
@@ -3599,11 +4296,17 @@ function definesOrLinksGlossary(content, term) {
|
|
|
3599
4296
|
return true;
|
|
3600
4297
|
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3601
4298
|
}
|
|
3602
|
-
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
4299
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, options = {}) {
|
|
3603
4300
|
const findings = [];
|
|
4301
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4302
|
+
const rule = set.rules.find((r) => !r.custom && r.id === "coined-term");
|
|
4303
|
+
if (!rule)
|
|
4304
|
+
return findings;
|
|
3604
4305
|
for (const file of files) {
|
|
3605
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3606
|
-
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
4306
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, DEFAULT_SPEC_PATHS, options.productPaths);
|
|
4307
|
+
if (!cls || !SWEPT_CLASSES.has(cls) || !rule.scopes.includes(cls))
|
|
4308
|
+
continue;
|
|
4309
|
+
if (!ruleReads(set, rule, file.path))
|
|
3607
4310
|
continue;
|
|
3608
4311
|
const scrubbed = stripNonProse(file.path, file.content);
|
|
3609
4312
|
for (const term of glossaryTerms) {
|
|
@@ -3616,14 +4319,15 @@ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, read
|
|
|
3616
4319
|
file: file.path,
|
|
3617
4320
|
line,
|
|
3618
4321
|
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3619
|
-
blocking:
|
|
4322
|
+
blocking: rule.severity[cls] === "error",
|
|
4323
|
+
rule: rule.id
|
|
3620
4324
|
});
|
|
3621
4325
|
}
|
|
3622
4326
|
}
|
|
3623
4327
|
return findings;
|
|
3624
4328
|
}
|
|
3625
|
-
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN =
|
|
3626
|
-
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN =
|
|
4329
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = readerPattern("source-comment-tranche-slug", "comment");
|
|
4330
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = readerPattern("source-comment-forge-number", "comment");
|
|
3627
4331
|
function extractComments(path, content) {
|
|
3628
4332
|
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3629
4333
|
return content.replace(/[^\n]/g, "");
|
|
@@ -3720,39 +4424,40 @@ function extractComments(path, content) {
|
|
|
3720
4424
|
}
|
|
3721
4425
|
return out;
|
|
3722
4426
|
}
|
|
3723
|
-
function checkSourceComments(files, allowlist = []) {
|
|
4427
|
+
function checkSourceComments(files, allowlist = [], options = {}) {
|
|
3724
4428
|
const findings = [];
|
|
3725
4429
|
const allowed = new Set(allowlist);
|
|
3726
|
-
const
|
|
3727
|
-
|
|
3728
|
-
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3729
|
-
];
|
|
4430
|
+
const set = options.rules ?? DEFAULT_PROSE_RULE_SET;
|
|
4431
|
+
const rules = rulesInScope(set, "source-comment").filter((rule) => rule.group === "reader-resolvable");
|
|
3730
4432
|
for (const file of files) {
|
|
3731
4433
|
if (!file.path.endsWith(".ts"))
|
|
3732
4434
|
continue;
|
|
3733
4435
|
if (allowed.has(file.path))
|
|
3734
4436
|
continue;
|
|
3735
4437
|
const comments = extractComments(file.path, file.content);
|
|
3736
|
-
for (const
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
4438
|
+
for (const rule of rules) {
|
|
4439
|
+
if (!ruleReads(set, rule, file.path))
|
|
4440
|
+
continue;
|
|
4441
|
+
const pattern = rule.patternFor("source-comment");
|
|
4442
|
+
if (!pattern)
|
|
4443
|
+
continue;
|
|
4444
|
+
for (const { cited, index } of citations(pattern, comments)) {
|
|
4445
|
+
findings.push({
|
|
3741
4446
|
file: file.path,
|
|
3742
|
-
line: lineAt(comments,
|
|
3743
|
-
message: `comment cites ${
|
|
3744
|
-
blocking:
|
|
4447
|
+
line: lineAt(comments, index),
|
|
4448
|
+
message: rule.custom ? customMessage(rule, cited) : `comment cites ${rule.message} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4449
|
+
blocking: rule.severity["source-comment"] === "error",
|
|
4450
|
+
rule: rule.id
|
|
3745
4451
|
});
|
|
3746
|
-
match = pattern.exec(comments);
|
|
3747
4452
|
}
|
|
3748
4453
|
}
|
|
3749
4454
|
}
|
|
3750
4455
|
return findings;
|
|
3751
4456
|
}
|
|
3752
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4457
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS, options = {}) {
|
|
3753
4458
|
return [
|
|
3754
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3755
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4459
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths, options),
|
|
4460
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix, options)
|
|
3756
4461
|
];
|
|
3757
4462
|
}
|
|
3758
4463
|
function parseGlossaryTerms(glossaryContent) {
|
|
@@ -3955,6 +4660,17 @@ function checkDocClaims(files, fileReader) {
|
|
|
3955
4660
|
};
|
|
3956
4661
|
}
|
|
3957
4662
|
|
|
4663
|
+
// ../../packages/aeg-core/src/protected-paths.ts
|
|
4664
|
+
import { posix as posixPath } from "node:path";
|
|
4665
|
+
var PROTECTED_ADMIN_PATHS = ["vinaya.config.json", ".vinaya/doc-owners", ".github/", "aeg-root/"];
|
|
4666
|
+
function normalizeTouchedPath(path) {
|
|
4667
|
+
return posixPath.resolve("/", path.replace(/\\/g, "/")).replace(/^\/+/, "");
|
|
4668
|
+
}
|
|
4669
|
+
function isProtectedAdminPath(path) {
|
|
4670
|
+
const normalized = normalizeTouchedPath(path);
|
|
4671
|
+
return PROTECTED_ADMIN_PATHS.some((prefix) => normalized === prefix || normalized.startsWith(prefix));
|
|
4672
|
+
}
|
|
4673
|
+
|
|
3958
4674
|
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3959
4675
|
function hasRationaleField(body, labelPattern) {
|
|
3960
4676
|
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
@@ -4074,13 +4790,20 @@ function globCoversPath(glob, path) {
|
|
|
4074
4790
|
return !p.includes("/");
|
|
4075
4791
|
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
4076
4792
|
}
|
|
4793
|
+
function surfaceEntryResolves(entry, resolvesToFile, pinnedFiles) {
|
|
4794
|
+
if (resolvesToFile(entry))
|
|
4795
|
+
return true;
|
|
4796
|
+
const directory = entry.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
4797
|
+
return pinnedFiles.some((path) => path.startsWith(`${directory}/`));
|
|
4798
|
+
}
|
|
4077
4799
|
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
4078
4800
|
const surface = parseIssueSurface(body);
|
|
4079
4801
|
if (!surface.ok)
|
|
4080
4802
|
return { status: "pass", errors: [] };
|
|
4803
|
+
const pinnedFiles = boundaryPinnedFiles(body);
|
|
4081
4804
|
const errors = [];
|
|
4082
4805
|
for (const glob of surface.value.in) {
|
|
4083
|
-
if (!
|
|
4806
|
+
if (!surfaceEntryResolves(glob, resolvesToFile, pinnedFiles)) {
|
|
4084
4807
|
errors.push(`issue-validation Surface: \`${glob}\` in \`## Surface\`'s \`in:\` list matches no tracked file — a Surface that cannot resolve cannot render a brief's file list.`);
|
|
4085
4808
|
}
|
|
4086
4809
|
}
|
|
@@ -4110,6 +4833,14 @@ function recordedBeyondSurfacePaths(body) {
|
|
|
4110
4833
|
return paths;
|
|
4111
4834
|
}
|
|
4112
4835
|
function checkSurfaceScope(changedFiles, surface, recorded) {
|
|
4836
|
+
for (const path of changedFiles) {
|
|
4837
|
+
if (!isProtectedAdminPath(path))
|
|
4838
|
+
continue;
|
|
4839
|
+
const normalized = normalizeTouchedPath(path);
|
|
4840
|
+
if (!surface.in.some((glob) => globCoversPath(glob, normalized))) {
|
|
4841
|
+
return { ok: false, violation: { path, reason: "protected" } };
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4113
4844
|
const listed = new Set(recorded);
|
|
4114
4845
|
const violation = beyondSurfacePaths(changedFiles, surface).find((entry) => !listed.has(entry.path));
|
|
4115
4846
|
return violation ? { ok: false, violation } : { ok: true };
|
|
@@ -4165,12 +4896,22 @@ function checkPartsCiteDefinedObjectives(body) {
|
|
|
4165
4896
|
}
|
|
4166
4897
|
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4167
4898
|
}
|
|
4899
|
+
var ISSUE_LIVE_LINE_RE = /^-\s*\*{2}\[live\]\*{2}(.*)$/gim;
|
|
4900
|
+
function liveCommand(text) {
|
|
4901
|
+
const trimmed = text.trim();
|
|
4902
|
+
const span = /^(`+)(.+)\1$/.exec(trimmed);
|
|
4903
|
+
return span ? span[2].trim() : trimmed;
|
|
4904
|
+
}
|
|
4905
|
+
function liveItemsIn(region) {
|
|
4906
|
+
return [...region.matchAll(ISSUE_LIVE_LINE_RE)].map((m) => liveCommand(m[1] ?? "")).filter(Boolean);
|
|
4907
|
+
}
|
|
4908
|
+
function parseLiveTestPlanItems(body) {
|
|
4909
|
+
const located = locateTestPlanSection(body);
|
|
4910
|
+
return located.found ? liveItemsIn(located.section) : [];
|
|
4911
|
+
}
|
|
4168
4912
|
function isTaskIssueLabelSet(labels) {
|
|
4169
4913
|
return hasLabel("tranche", labels);
|
|
4170
4914
|
}
|
|
4171
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
4172
|
-
return { status: "pass", errors: [] };
|
|
4173
|
-
}
|
|
4174
4915
|
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4175
4916
|
if (!isTaskIssueLabelSet(labels))
|
|
4176
4917
|
return { status: "pass", errors: [] };
|
|
@@ -4186,6 +4927,7 @@ function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTi
|
|
|
4186
4927
|
};
|
|
4187
4928
|
}
|
|
4188
4929
|
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4930
|
+
var PATH_TEXT = (body) => stripCode(body, { inlineSpans: "keep" });
|
|
4189
4931
|
function isControlCodePoint(codePoint) {
|
|
4190
4932
|
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4191
4933
|
}
|
|
@@ -4246,8 +4988,14 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
|
4246
4988
|
}
|
|
4247
4989
|
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4248
4990
|
}
|
|
4991
|
+
function rationaleFieldText(text, labelPattern) {
|
|
4992
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})[^\\n]*\\n?([\\s\\S]*?)(?=\\n\\s*(?:\\*\\*[A-Z]|#{1,4}\\s)|(?![\\s\\S]))`, "im");
|
|
4993
|
+
const m = re.exec(text);
|
|
4994
|
+
return m ? m[0] : "";
|
|
4995
|
+
}
|
|
4249
4996
|
var DOC_PATH_RE = /(?:(?:aeg-root|apps|packages|specs|docs|tools|\.claude|\.github)\/[\w./@-]*\.(?:md|mdx)|\.claude\/(?:skills|rules)\/[\w./-]+|\b(?:docs-index|decisions|projects|state-machine|enforcement|process|README|CLAUDE)\.md\b|\b[\w-]+-(?:spec|decisions|backlog)\.md\b)/i;
|
|
4250
4997
|
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
4998
|
+
var RATIONALE_PATH_RE_GLOBAL = /`([\w.@-]+(?:\/[\w.@-]+)+)`/g;
|
|
4251
4999
|
function normalizeEdgeId(s) {
|
|
4252
5000
|
const qualified = splitSlugQualifiedEdge(s);
|
|
4253
5001
|
return (qualified ? qualified.bareId : s).replace(/^#/, "").trim();
|
|
@@ -4255,6 +5003,15 @@ function normalizeEdgeId(s) {
|
|
|
4255
5003
|
function edgesNameEachOther(a, b) {
|
|
4256
5004
|
return a.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(b.ref)) || b.conflictsWith.map(normalizeEdgeId).includes(normalizeEdgeId(a.ref));
|
|
4257
5005
|
}
|
|
5006
|
+
var BOUNDARY_OUT_RE = /\bOut\s*:\s*([\s\S]*)$/im;
|
|
5007
|
+
function boundaryOutText(body) {
|
|
5008
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5009
|
+
const m = BOUNDARY_OUT_RE.exec(boundary);
|
|
5010
|
+
return m ? m[1] : "";
|
|
5011
|
+
}
|
|
5012
|
+
function namedPathsIn(text) {
|
|
5013
|
+
return [...new Set([...text.matchAll(RATIONALE_PATH_RE_GLOBAL)].map((m) => m[1]))].filter((p) => !/^https?:\/\//i.test(p));
|
|
5014
|
+
}
|
|
4258
5015
|
var FILE_EXTENSIONS = new Set([
|
|
4259
5016
|
"ts",
|
|
4260
5017
|
"tsx",
|
|
@@ -4276,6 +5033,11 @@ var FILE_EXTENSIONS = new Set([
|
|
|
4276
5033
|
"html",
|
|
4277
5034
|
"css"
|
|
4278
5035
|
]);
|
|
5036
|
+
function boundaryPinnedFiles(body) {
|
|
5037
|
+
const boundary = rationaleFieldText(PATH_TEXT(body), "Boundary");
|
|
5038
|
+
const excluded = new Set(namedPathsIn(boundaryOutText(body)));
|
|
5039
|
+
return namedPathsIn(boundary).filter((p) => looksLikeFilePath(p) && !excluded.has(p));
|
|
5040
|
+
}
|
|
4279
5041
|
var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
|
|
4280
5042
|
var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
|
|
4281
5043
|
|
|
@@ -4300,7 +5062,7 @@ function isGrandfathered(isoDate) {
|
|
|
4300
5062
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4301
5063
|
}
|
|
4302
5064
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4303
|
-
function checkA1(entries, principalAllowlist
|
|
5065
|
+
function checkA1(entries, principalAllowlist) {
|
|
4304
5066
|
const failures = [];
|
|
4305
5067
|
for (const e of entries) {
|
|
4306
5068
|
if (!e.facts)
|
|
@@ -4330,6 +5092,37 @@ function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
|
4330
5092
|
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4331
5093
|
};
|
|
4332
5094
|
}
|
|
5095
|
+
function checkA2(entries, hasProvenanceByKey) {
|
|
5096
|
+
const failures = [];
|
|
5097
|
+
for (const e of entries) {
|
|
5098
|
+
if (!e.facts)
|
|
5099
|
+
continue;
|
|
5100
|
+
if (e.facts.issueState !== "closed" || e.facts.prState !== "merged")
|
|
5101
|
+
continue;
|
|
5102
|
+
const key = `${e.trancheSlug}/${e.task.id}`;
|
|
5103
|
+
const hasProvenance = hasProvenanceByKey.get(key);
|
|
5104
|
+
if (hasProvenance === undefined)
|
|
5105
|
+
continue;
|
|
5106
|
+
if (!hasProvenance) {
|
|
5107
|
+
failures.push({
|
|
5108
|
+
code: "archived-without-provenance",
|
|
5109
|
+
issue: e.task.issue,
|
|
5110
|
+
tranche: e.trancheSlug,
|
|
5111
|
+
task: e.task.id,
|
|
5112
|
+
reason: "Closing PR has no `### AEG provenance` comment (Archivist close-out missing)",
|
|
5113
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
5114
|
+
});
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
5118
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
5119
|
+
return {
|
|
5120
|
+
check: "A2",
|
|
5121
|
+
status,
|
|
5122
|
+
failures,
|
|
5123
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
5124
|
+
};
|
|
5125
|
+
}
|
|
4333
5126
|
function checkA3(entries) {
|
|
4334
5127
|
const failures = [];
|
|
4335
5128
|
for (const e of entries) {
|
|
@@ -4545,6 +5338,33 @@ function checkL1(files, entriesBySlug) {
|
|
|
4545
5338
|
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4546
5339
|
};
|
|
4547
5340
|
}
|
|
5341
|
+
function checkL2(files, entriesBySlug) {
|
|
5342
|
+
const failures = [];
|
|
5343
|
+
for (const f of files) {
|
|
5344
|
+
if (!f.archived)
|
|
5345
|
+
continue;
|
|
5346
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
5347
|
+
for (const e of entries) {
|
|
5348
|
+
if (!e.facts)
|
|
5349
|
+
continue;
|
|
5350
|
+
if (e.facts.issueState === "open") {
|
|
5351
|
+
failures.push({
|
|
5352
|
+
code: "premature-archive",
|
|
5353
|
+
issue: e.task.issue,
|
|
5354
|
+
tranche: f.slug,
|
|
5355
|
+
task: e.task.id,
|
|
5356
|
+
reason: `Archived tranche has open task-Issue #${e.task.issue ?? "?"} (premature archive)`
|
|
5357
|
+
});
|
|
5358
|
+
}
|
|
5359
|
+
}
|
|
5360
|
+
}
|
|
5361
|
+
return {
|
|
5362
|
+
check: "L2",
|
|
5363
|
+
status: "info",
|
|
5364
|
+
failures,
|
|
5365
|
+
note: failures.length > 0 ? `${failures.length} archived tranche(s) with an open task-Issue — investigate (advisory)` : undefined
|
|
5366
|
+
};
|
|
5367
|
+
}
|
|
4548
5368
|
function checkL3(files) {
|
|
4549
5369
|
const active = files.filter((f) => !f.archived);
|
|
4550
5370
|
return {
|
|
@@ -4554,6 +5374,51 @@ function checkL3(files) {
|
|
|
4554
5374
|
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4555
5375
|
};
|
|
4556
5376
|
}
|
|
5377
|
+
function checkL4(activeTrancheSlugs, issueMilestones) {
|
|
5378
|
+
const activeSet = new Set(activeTrancheSlugs);
|
|
5379
|
+
const failures = [];
|
|
5380
|
+
for (const f of issueMilestones) {
|
|
5381
|
+
if (!activeSet.has(f.tranche))
|
|
5382
|
+
continue;
|
|
5383
|
+
if (f.milestoneTitle === f.tranche)
|
|
5384
|
+
continue;
|
|
5385
|
+
failures.push({
|
|
5386
|
+
code: "milestone-drift",
|
|
5387
|
+
issue: f.issue,
|
|
5388
|
+
tranche: f.tranche,
|
|
5389
|
+
reason: f.milestoneTitle === null ? `Issue #${f.issue} carries ${trancheLabel(f.tranche)} (active) but has no GitHub-native milestone attached` : `Issue #${f.issue} carries ${trancheLabel(f.tranche)} (active) but is attached to Milestone "${f.milestoneTitle}" instead`
|
|
5390
|
+
});
|
|
5391
|
+
}
|
|
5392
|
+
return {
|
|
5393
|
+
check: "L4",
|
|
5394
|
+
status: "info",
|
|
5395
|
+
failures,
|
|
5396
|
+
note: failures.length > 0 ? `${failures.length} open task-Issue(s) in an active tranche whose GitHub-native milestone doesn't match their ${label("tranche")}<slug> label (cosmetic drift, advisory)` : undefined
|
|
5397
|
+
};
|
|
5398
|
+
}
|
|
5399
|
+
function checkL5(activeTrancheSlugs, entriesBySlug) {
|
|
5400
|
+
const failures = [];
|
|
5401
|
+
for (const slug of activeTrancheSlugs) {
|
|
5402
|
+
const entries = entriesBySlug.get(slug) ?? [];
|
|
5403
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
5404
|
+
if (withFacts.length === 0)
|
|
5405
|
+
continue;
|
|
5406
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
5407
|
+
if (allClosed) {
|
|
5408
|
+
failures.push({
|
|
5409
|
+
code: "tranche-not-archived",
|
|
5410
|
+
tranche: slug,
|
|
5411
|
+
reason: "Every task Issue is closed but the tranche is not recorded as complete — archive it"
|
|
5412
|
+
});
|
|
5413
|
+
}
|
|
5414
|
+
}
|
|
5415
|
+
return {
|
|
5416
|
+
check: "L5",
|
|
5417
|
+
status: failures.length > 0 ? "fail" : "pass",
|
|
5418
|
+
failures,
|
|
5419
|
+
note: failures.length > 0 ? `${failures.length} tranche(s) whose task Issues are all closed but were never archived` : undefined
|
|
5420
|
+
};
|
|
5421
|
+
}
|
|
4557
5422
|
function extractClosesReferences(prBody) {
|
|
4558
5423
|
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4559
5424
|
const stripped = stripCode(prBody);
|
|
@@ -4649,6 +5514,58 @@ function extractIssue(body) {
|
|
|
4649
5514
|
}
|
|
4650
5515
|
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4651
5516
|
import { createHash as createHash4 } from "node:crypto";
|
|
5517
|
+
|
|
5518
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
5519
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
5520
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
5521
|
+
let best = 0;
|
|
5522
|
+
for (const c of comments) {
|
|
5523
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5524
|
+
continue;
|
|
5525
|
+
const firstLine = (c.body.split(`
|
|
5526
|
+
`)[0] ?? "").trim();
|
|
5527
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
5528
|
+
if (!m)
|
|
5529
|
+
continue;
|
|
5530
|
+
const k = Number.parseInt(m[1], 10);
|
|
5531
|
+
if (k > best)
|
|
5532
|
+
best = k;
|
|
5533
|
+
}
|
|
5534
|
+
return best;
|
|
5535
|
+
}
|
|
5536
|
+
function parseRulingIdentity(rulingId) {
|
|
5537
|
+
const m = /^(issue-)?(\d+)-(\d+)$/.exec(rulingId);
|
|
5538
|
+
if (!m)
|
|
5539
|
+
return null;
|
|
5540
|
+
const ref = Number.parseInt(m[2], 10);
|
|
5541
|
+
const ordinal = Number.parseInt(m[3], 10);
|
|
5542
|
+
if (ref <= 0 || ordinal <= 0)
|
|
5543
|
+
return null;
|
|
5544
|
+
return { target: m[1] ? "issue" : "pr", ref, ordinal };
|
|
5545
|
+
}
|
|
5546
|
+
function principalRulingTextById(comments, allowlist, rulingId) {
|
|
5547
|
+
const identity = parseRulingIdentity(rulingId);
|
|
5548
|
+
if (identity === null)
|
|
5549
|
+
return null;
|
|
5550
|
+
const matches = comments.filter((c) => {
|
|
5551
|
+
if (!isPrincipal(c.author, allowlist))
|
|
5552
|
+
return false;
|
|
5553
|
+
const m = RULING_MARKER_ORDINAL.exec((c.body.split(`
|
|
5554
|
+
`)[0] ?? "").trim());
|
|
5555
|
+
return m !== null && Number.parseInt(m[1], 10) === identity.ordinal;
|
|
5556
|
+
});
|
|
5557
|
+
if (matches.length !== 1)
|
|
5558
|
+
return null;
|
|
5559
|
+
const body = matches[0].body;
|
|
5560
|
+
const idx = body.indexOf(`
|
|
5561
|
+
`);
|
|
5562
|
+
return idx === -1 ? "" : body.slice(idx + 1).trim();
|
|
5563
|
+
}
|
|
5564
|
+
|
|
5565
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
5566
|
+
function pauseBoundRulingDigest(rulingText) {
|
|
5567
|
+
return createHash4("sha256").update(rulingText).digest("hex");
|
|
5568
|
+
}
|
|
4652
5569
|
function briefHash(brief) {
|
|
4653
5570
|
return createHash4("sha256").update(`${brief}
|
|
4654
5571
|
`).digest("hex");
|
|
@@ -4709,14 +5626,19 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4709
5626
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4710
5627
|
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4711
5628
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
5629
|
+
const legacyCurrent = current.manifestVersion === undefined;
|
|
5630
|
+
const manifestVersion = legacyCurrent ? echoed.manifestVersion === undefined || echoed.manifestVersion === null : echoed.manifestVersion === current.manifestVersion;
|
|
5631
|
+
const pauseBoundRuling = legacyCurrent ? true : Object.hasOwn(echoed, "pauseBoundRuling") && JSON.stringify(echoed.pauseBoundRuling) === JSON.stringify(current.pauseBoundRuling);
|
|
4712
5632
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4713
5633
|
return {
|
|
4714
|
-
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
5634
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && pauseBoundRuling && manifestVersion && policyDigestBound,
|
|
4715
5635
|
head,
|
|
4716
5636
|
base,
|
|
4717
5637
|
briefHash: briefHashBound,
|
|
4718
5638
|
objectivesVersion,
|
|
4719
5639
|
rulingOrdinal,
|
|
5640
|
+
pauseBoundRuling,
|
|
5641
|
+
manifestVersion,
|
|
4720
5642
|
policyDigest: policyDigestBound
|
|
4721
5643
|
};
|
|
4722
5644
|
}
|
|
@@ -4732,7 +5654,7 @@ function renderGateDeferred(deferred) {
|
|
|
4732
5654
|
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4733
5655
|
}
|
|
4734
5656
|
function checkReviewGate(input) {
|
|
4735
|
-
const principalAllowlist = input
|
|
5657
|
+
const { principalAllowlist } = input;
|
|
4736
5658
|
const waived = isWaiverLabelActorVerified({
|
|
4737
5659
|
label: WAIVER_LABEL_REVIEW,
|
|
4738
5660
|
labels: input.labels,
|
|
@@ -4771,27 +5693,33 @@ function checkReviewGate(input) {
|
|
|
4771
5693
|
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4772
5694
|
const securityClean = securityTextClean && securityPolicyClean;
|
|
4773
5695
|
const currentManifest = {
|
|
5696
|
+
...input.manifestVersion === undefined ? {} : { manifestVersion: input.manifestVersion },
|
|
4774
5697
|
headSha: input.headSha,
|
|
4775
5698
|
baseSha: input.baseSha ?? null,
|
|
4776
5699
|
briefHash: input.briefHash ?? null,
|
|
4777
5700
|
objectivesVersion: input.objectivesVersion,
|
|
4778
5701
|
rulingOrdinal: input.rulingOrdinal,
|
|
5702
|
+
pauseBoundRuling: input.pauseBoundRuling ?? null,
|
|
4779
5703
|
policyDigest: policyDigest(policy)
|
|
4780
5704
|
};
|
|
4781
5705
|
const codeReviewEchoed = {
|
|
5706
|
+
manifestVersion: codeReview.manifestVersion,
|
|
4782
5707
|
headSha: codeReview.headSha,
|
|
4783
5708
|
baseSha: codeReview.baseSha,
|
|
4784
5709
|
briefHash: codeReview.briefHash,
|
|
4785
5710
|
objectivesVersion: codeReview.objectivesVersion,
|
|
4786
5711
|
rulingOrdinal: codeReview.rulingOrdinal,
|
|
5712
|
+
pauseBoundRuling: codeReview.pauseBoundRuling,
|
|
4787
5713
|
policyDigest: codeReview.policyDigest
|
|
4788
5714
|
};
|
|
4789
5715
|
const securityEchoed = {
|
|
5716
|
+
manifestVersion: security.manifestVersion,
|
|
4790
5717
|
headSha: security.headSha,
|
|
4791
5718
|
baseSha: security.baseSha,
|
|
4792
5719
|
briefHash: security.briefHash,
|
|
4793
5720
|
objectivesVersion: security.objectivesVersion,
|
|
4794
5721
|
rulingOrdinal: security.rulingOrdinal,
|
|
5722
|
+
pauseBoundRuling: security.pauseBoundRuling,
|
|
4795
5723
|
policyDigest: security.policyDigest
|
|
4796
5724
|
};
|
|
4797
5725
|
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
@@ -4830,6 +5758,10 @@ function checkReviewGate(input) {
|
|
|
4830
5758
|
problems.push(`the newest code-review verdict was cast against brief hash ${codeReview.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
|
|
4831
5759
|
} else if (!codeReviewBinding.policyDigest) {
|
|
4832
5760
|
problems.push(`the newest code-review verdict was cast against review policy digest ${codeReview.policyDigest ?? "none"}, this repository's current policy digest is ${currentManifest.policyDigest}`);
|
|
5761
|
+
} else if (!codeReviewBinding.manifestVersion) {
|
|
5762
|
+
problems.push(`the newest code-review verdict echoes manifest version ${codeReview.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5763
|
+
} else if (!codeReviewBinding.pauseBoundRuling) {
|
|
5764
|
+
problems.push(`the newest code-review verdict echoes pauseBoundRuling ${renderBinding(codeReview.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4833
5765
|
}
|
|
4834
5766
|
if (!securityTextClean) {
|
|
4835
5767
|
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
@@ -4847,6 +5779,10 @@ function checkReviewGate(input) {
|
|
|
4847
5779
|
problems.push(`the newest security-review verdict was cast against brief hash ${security.briefHash ?? "none"}, the frozen brief's current hash is ${currentManifest.briefHash ?? "none"}`);
|
|
4848
5780
|
} else if (!securityBinding.policyDigest) {
|
|
4849
5781
|
problems.push(`the newest security-review verdict was cast against review policy digest ${security.policyDigest ?? "none"}, this repository's current policy digest is ${currentManifest.policyDigest}`);
|
|
5782
|
+
} else if (!securityBinding.manifestVersion) {
|
|
5783
|
+
problems.push(`the newest security-review verdict echoes manifest version ${security.manifestVersion ?? "none"}, the frozen review-input manifest is version ${currentManifest.manifestVersion ?? "unversioned"}`);
|
|
5784
|
+
} else if (!securityBinding.pauseBoundRuling) {
|
|
5785
|
+
problems.push(`the newest security-review verdict echoes pauseBoundRuling ${renderBinding(security.pauseBoundRuling)}, the frozen review-input manifest binds ${renderBinding(currentManifest.pauseBoundRuling)}`);
|
|
4850
5786
|
}
|
|
4851
5787
|
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4852
5788
|
return {
|
|
@@ -4855,29 +5791,16 @@ function checkReviewGate(input) {
|
|
|
4855
5791
|
waived: false
|
|
4856
5792
|
};
|
|
4857
5793
|
}
|
|
5794
|
+
function renderBinding(binding) {
|
|
5795
|
+
if (binding === undefined)
|
|
5796
|
+
return "(absent)";
|
|
5797
|
+
return binding === null ? "(none)" : `${binding.rulingId}|${binding.pauseId}|${binding.contentDigest}`;
|
|
5798
|
+
}
|
|
4858
5799
|
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4859
5800
|
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4860
5801
|
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4861
5802
|
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4862
5803
|
}
|
|
4863
|
-
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4864
|
-
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4865
|
-
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4866
|
-
let best = 0;
|
|
4867
|
-
for (const c of comments) {
|
|
4868
|
-
if (!isPrincipal(c.author, allowlist))
|
|
4869
|
-
continue;
|
|
4870
|
-
const firstLine = (c.body.split(`
|
|
4871
|
-
`)[0] ?? "").trim();
|
|
4872
|
-
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4873
|
-
if (!m)
|
|
4874
|
-
continue;
|
|
4875
|
-
const k = Number.parseInt(m[1], 10);
|
|
4876
|
-
if (k > best)
|
|
4877
|
-
best = k;
|
|
4878
|
-
}
|
|
4879
|
-
return best;
|
|
4880
|
-
}
|
|
4881
5804
|
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4882
5805
|
function splitRow(line) {
|
|
4883
5806
|
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
@@ -5029,7 +5952,6 @@ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
|
5029
5952
|
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
5030
5953
|
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
5031
5954
|
"apps/cli/src/checks/bin/check-dead-branch-push.ts": 'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
|
|
5032
|
-
"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)`,
|
|
5033
5955
|
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
5034
5956
|
};
|
|
5035
5957
|
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
@@ -5253,72 +6175,10 @@ function compareToBaseline(current, baseline) {
|
|
|
5253
6175
|
};
|
|
5254
6176
|
}
|
|
5255
6177
|
// ../../packages/aeg-core/src/retired-vocabulary.ts
|
|
5256
|
-
var
|
|
5257
|
-
var RETIRED_PATTERNS =
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
"decision (entry|logged)",
|
|
5261
|
-
"decision-log entry",
|
|
5262
|
-
"decision log entry",
|
|
5263
|
-
"decision log(s|ged|ging)?([^a-z]|$)",
|
|
5264
|
-
"decision-log",
|
|
5265
|
-
"decision entr",
|
|
5266
|
-
"decisions? (are |is )?logged",
|
|
5267
|
-
"log entries",
|
|
5268
|
-
String.raw`decisions\.md`,
|
|
5269
|
-
"decisions-legacy",
|
|
5270
|
-
"CONTRADICTION",
|
|
5271
|
-
"assumes Tier 3",
|
|
5272
|
-
"Lock: ?YES",
|
|
5273
|
-
"Lock: ?NO",
|
|
5274
|
-
"lock approvals?",
|
|
5275
|
-
"approves locks",
|
|
5276
|
-
"Conforms to lock",
|
|
5277
|
-
"Challenges lock",
|
|
5278
|
-
"checkDecisionNumbersFresh",
|
|
5279
|
-
String.raw`roles/team-leader\.md`,
|
|
5280
|
-
String.raw`\(,`,
|
|
5281
|
-
String.raw`,\)`,
|
|
5282
|
-
String.raw`\(\.\)`,
|
|
5283
|
-
...PLAN_ON_DISK_PATTERNS
|
|
5284
|
-
];
|
|
5285
|
-
var TRANCHE_MODEL_FILE = "/tranche-model.md";
|
|
5286
|
-
var RETIRED_EXEMPT_SUBSTRINGS = [
|
|
5287
|
-
"docs/decisions-legacy.md",
|
|
5288
|
-
"apps/herald-ai/docs/",
|
|
5289
|
-
"apps/vada-ai/docs/",
|
|
5290
|
-
"aeg-root/tranches/completed/",
|
|
5291
|
-
"packages/aeg-core/src/docs/published-prose",
|
|
5292
|
-
"packages/aeg-core/src/retired-vocabulary.test.ts",
|
|
5293
|
-
"packages/aeg-core/src/retired-vocabulary.ts",
|
|
5294
|
-
"/fixtures/",
|
|
5295
|
-
"/node_modules/",
|
|
5296
|
-
"/.next/",
|
|
5297
|
-
"/.turbo/"
|
|
5298
|
-
];
|
|
5299
|
-
var PATTERN_EXEMPT = {
|
|
5300
|
-
[String.raw`\bD-[0-9]{3}\b`]: ["./CLAUDE.md"],
|
|
5301
|
-
[String.raw`decisions\.md`]: [
|
|
5302
|
-
"docs-index.md",
|
|
5303
|
-
"apps/vada-ai/specs/legacy/README.md",
|
|
5304
|
-
"apps/vada-ai/specs/vada-product-spec.md",
|
|
5305
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5306
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5307
|
-
],
|
|
5308
|
-
"decisions-legacy": [
|
|
5309
|
-
"packages/aeg-core/src/file-classify.ts",
|
|
5310
|
-
"packages/aeg-core/src/file-classify.test.ts",
|
|
5311
|
-
"packages/aeg-core/src/pr-tier.test.ts",
|
|
5312
|
-
"docs-index.md",
|
|
5313
|
-
".claude/skills/database/SKILL.md",
|
|
5314
|
-
".claude/skills/vada-architecture/SKILL.md",
|
|
5315
|
-
"apps/vada-ai/specs/vada-byok-principles.md",
|
|
5316
|
-
"apps/vada-ai/web/CLAUDE.md",
|
|
5317
|
-
"apps/vada-ai/CLAUDE.md"
|
|
5318
|
-
],
|
|
5319
|
-
CONTRADICTION: ["apps/vada-ai/specs/vada-reviewers-spec.md"],
|
|
5320
|
-
...Object.fromEntries(PLAN_ON_DISK_PATTERNS.map((pattern) => [pattern, [TRANCHE_MODEL_FILE]]))
|
|
5321
|
-
};
|
|
6178
|
+
var retiredRules = rulesForGroup("retired-vocabulary");
|
|
6179
|
+
var RETIRED_PATTERNS = retiredRules.map((rule) => rule.patterns.repository);
|
|
6180
|
+
var PATTERN_EXEMPT = RETIRED_PATTERN_EXEMPTIONS;
|
|
6181
|
+
var DEFAULT_PATTERN_OF = new Map(retiredRules.map((rule) => [rule.id, rule.patterns.repository]));
|
|
5322
6182
|
function lineNumbers(content, pattern) {
|
|
5323
6183
|
const out = [];
|
|
5324
6184
|
const lines = content.split(`
|
|
@@ -5329,22 +6189,29 @@ function lineNumbers(content, pattern) {
|
|
|
5329
6189
|
}
|
|
5330
6190
|
return out;
|
|
5331
6191
|
}
|
|
5332
|
-
function scanRetiredVocabulary(files) {
|
|
6192
|
+
function scanRetiredVocabulary(files, rules = DEFAULT_PROSE_RULE_SET) {
|
|
5333
6193
|
const findings = [];
|
|
6194
|
+
const retired = rulesOfGroup(rules, "retired-vocabulary");
|
|
5334
6195
|
for (const file of files) {
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
6196
|
+
for (const rule of retired) {
|
|
6197
|
+
if (rule.substringExempt.some((e) => file.path.includes(e)))
|
|
6198
|
+
continue;
|
|
6199
|
+
if (!ruleReads(rules, rule, file.path))
|
|
6200
|
+
continue;
|
|
6201
|
+
const re = rule.patternFor("repository");
|
|
6202
|
+
if (!re)
|
|
6203
|
+
continue;
|
|
6204
|
+
const pattern = rule.custom ? re.source : DEFAULT_PATTERN_OF.get(rule.id) ?? re.source;
|
|
6205
|
+
if (!rule.custom && (PATTERN_EXEMPT[pattern] ?? []).some((e) => file.path.includes(e)))
|
|
5340
6206
|
continue;
|
|
5341
|
-
const re = new RegExp(pattern);
|
|
5342
6207
|
for (const line of lineNumbers(file.content, re)) {
|
|
5343
6208
|
findings.push({
|
|
5344
6209
|
file: file.path,
|
|
5345
6210
|
line,
|
|
5346
6211
|
pattern,
|
|
5347
|
-
message: `claims a retired AEG mechanism is still live (matches /${pattern}/)
|
|
6212
|
+
message: rule.custom ? `${rule.id}: ${rule.message} (matches /${pattern}/)` : `claims a retired AEG mechanism is still live (matches /${pattern}/)`,
|
|
6213
|
+
rule: rule.id,
|
|
6214
|
+
blocking: rule.severity.repository === "error"
|
|
5348
6215
|
});
|
|
5349
6216
|
}
|
|
5350
6217
|
}
|
|
@@ -5368,7 +6235,7 @@ function isSelfDependency(dep, task, issue) {
|
|
|
5368
6235
|
function checkDispatchReadiness(input) {
|
|
5369
6236
|
const { trancheSlug, task } = input;
|
|
5370
6237
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
5371
|
-
const principalAllowlist = input
|
|
6238
|
+
const { principalAllowlist } = input;
|
|
5372
6239
|
const blockerDetails = [];
|
|
5373
6240
|
const push = (blockerClass, message) => {
|
|
5374
6241
|
blockerDetails.push({ class: blockerClass, message });
|
|
@@ -5460,6 +6327,16 @@ function pushesAnyBranchRef(pushRefs) {
|
|
|
5460
6327
|
return pushRefs.split(`
|
|
5461
6328
|
`).map((line) => line.trim()).filter((line) => line.length > 0).some((line) => line.split(/\s+/)[2]?.startsWith("refs/heads/") === true);
|
|
5462
6329
|
}
|
|
6330
|
+
function resolveDefaultBranch(facts) {
|
|
6331
|
+
const { originHead, hasOriginMain, hasOriginMaster } = facts;
|
|
6332
|
+
if (originHead !== null && originHead !== "")
|
|
6333
|
+
return originHead;
|
|
6334
|
+
if (hasOriginMain)
|
|
6335
|
+
return "main";
|
|
6336
|
+
if (hasOriginMaster)
|
|
6337
|
+
return "master";
|
|
6338
|
+
return null;
|
|
6339
|
+
}
|
|
5463
6340
|
function checkMainBranchRefusal(facts) {
|
|
5464
6341
|
const { currentSymbolicBranch, defaultBranch, pushRefs = null } = facts;
|
|
5465
6342
|
if (currentSymbolicBranch === null)
|
|
@@ -5720,54 +6597,61 @@ function checkFirstPushDispatchGate(input) {
|
|
|
5720
6597
|
reason: `verify-dispatch reports READY TO DISPATCH for \`${branch}\`.`
|
|
5721
6598
|
};
|
|
5722
6599
|
}
|
|
5723
|
-
// ../../packages/aeg-core/src/
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
6600
|
+
// ../../packages/aeg-core/src/live-record.ts
|
|
6601
|
+
var RECORD_LINE_RE = /^-\s*\[([ xX])\]\s*\*\*\[live\]\*\*\s+(`+) ?(.+?) ?\2(?!`)\s+—\s+(passed|failed|unverified)\s+at\s+`([^`]+)`/;
|
|
6602
|
+
function liveMarkers(body) {
|
|
6603
|
+
const masked = maskCode(body);
|
|
6604
|
+
return [...masked.matchAll(/<!--\s*AEG:LIVE:(?:START|END)\s*-->/g)].map((m) => ({
|
|
6605
|
+
start: m.index,
|
|
6606
|
+
end: m.index + m[0].length
|
|
6607
|
+
}));
|
|
6608
|
+
}
|
|
6609
|
+
var AMBIGUOUS_RECORD_LINE = {
|
|
6610
|
+
line: "- [ ] **[live]** the pull request body carries more than one `AEG:LIVE` marker pair, so the driver's record cannot be told apart",
|
|
6611
|
+
ticked: false,
|
|
6612
|
+
command: "",
|
|
6613
|
+
outcome: "failed",
|
|
6614
|
+
head: ""
|
|
6615
|
+
};
|
|
6616
|
+
function readLiveRecord(body) {
|
|
6617
|
+
const markers = liveMarkers(body).length;
|
|
6618
|
+
if (markers === 0)
|
|
6619
|
+
return [];
|
|
6620
|
+
if (markers !== 2)
|
|
6621
|
+
return [AMBIGUOUS_RECORD_LINE];
|
|
6622
|
+
const region = anchoredRegion(body, "LIVE");
|
|
6623
|
+
if (region === null)
|
|
6624
|
+
return [];
|
|
6625
|
+
const lines = [];
|
|
6626
|
+
for (const raw of region.split(`
|
|
6627
|
+
`)) {
|
|
6628
|
+
const line = raw.trim();
|
|
6629
|
+
const m = RECORD_LINE_RE.exec(line);
|
|
6630
|
+
if (!m)
|
|
6631
|
+
continue;
|
|
6632
|
+
lines.push({
|
|
6633
|
+
line,
|
|
6634
|
+
ticked: m[1].toLowerCase() === "x",
|
|
6635
|
+
command: m[3],
|
|
6636
|
+
outcome: m[4],
|
|
6637
|
+
head: m[5]
|
|
6638
|
+
});
|
|
5761
6639
|
}
|
|
5762
|
-
return
|
|
5763
|
-
action: "assign",
|
|
5764
|
-
issue,
|
|
5765
|
-
login,
|
|
5766
|
-
reason: `First push of \`${branch}\` — assigning Issue #${issue} to @${login} (the authenticated pusher).`
|
|
5767
|
-
};
|
|
6640
|
+
return lines;
|
|
5768
6641
|
}
|
|
5769
6642
|
// ../../packages/aeg-core/src/test-plan-gate.ts
|
|
5770
|
-
function
|
|
6643
|
+
function gradedLiveLines(record, live) {
|
|
6644
|
+
if (live === undefined)
|
|
6645
|
+
return record.map((entry) => entry.line);
|
|
6646
|
+
const commands = new Set(live.liveCommands);
|
|
6647
|
+
const others = record.filter((entry) => !commands.has(entry.command)).map((entry) => entry.line);
|
|
6648
|
+
const graded = live.liveCommands.map((command) => {
|
|
6649
|
+
const atHead = record.filter((entry) => entry.command === command && entry.head === live.head);
|
|
6650
|
+
return (atHead.find((entry) => entry.ticked) ?? atHead[0])?.line ?? `- [ ] **[live]** \`${command}\` — no passed run recorded at \`${live.head || "an unknown head"}\``;
|
|
6651
|
+
});
|
|
6652
|
+
return [...others, ...graded];
|
|
6653
|
+
}
|
|
6654
|
+
function evaluateTestPlanGate(body, branch, live) {
|
|
5771
6655
|
if (!body) {
|
|
5772
6656
|
return {
|
|
5773
6657
|
verdict: "pass",
|
|
@@ -5778,7 +6662,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5778
6662
|
};
|
|
5779
6663
|
}
|
|
5780
6664
|
const located = locateTestPlanSection(body);
|
|
5781
|
-
|
|
6665
|
+
const liveLines = gradedLiveLines(readLiveRecord(body), live);
|
|
6666
|
+
const liveUnticked = liveLines.some((line) => /^[-*]\s+\[\s\]/.test(line));
|
|
6667
|
+
if (!located.found && !liveUnticked) {
|
|
5782
6668
|
if (parseTaskBranchIdentity(branch) !== null) {
|
|
5783
6669
|
return {
|
|
5784
6670
|
verdict: "fail",
|
|
@@ -5798,15 +6684,18 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5798
6684
|
]
|
|
5799
6685
|
};
|
|
5800
6686
|
}
|
|
5801
|
-
const section = located.section;
|
|
5802
|
-
if (/unit-tests-only/i.test(section)) {
|
|
6687
|
+
const section = located.found ? located.section : "";
|
|
6688
|
+
if (/unit-tests-only/i.test(section) && !liveUnticked) {
|
|
5803
6689
|
return {
|
|
5804
6690
|
verdict: "pass",
|
|
5805
6691
|
messages: ["Test Plan: unit-tests-only — pure-logic brief, CI unit-tests are the proof.", "PASS."]
|
|
5806
6692
|
};
|
|
5807
6693
|
}
|
|
5808
|
-
const checkboxLines =
|
|
5809
|
-
|
|
6694
|
+
const checkboxLines = [
|
|
6695
|
+
...section.split(`
|
|
6696
|
+
`).map((line) => line.trimStart()).filter((line) => /^[-*]\s+\[[ xX]\]\s*\*{0,2}\[principal\]\*{0,2}/i.test(line)),
|
|
6697
|
+
...liveLines
|
|
6698
|
+
];
|
|
5810
6699
|
if (checkboxLines.length === 0) {
|
|
5811
6700
|
return {
|
|
5812
6701
|
verdict: "pass",
|
|
@@ -5823,7 +6712,9 @@ function evaluateTestPlanGate(body, branch) {
|
|
|
5823
6712
|
messages.push("", "FAIL — the following [principal] Test Plan items are unticked:");
|
|
5824
6713
|
for (const line of unchecked)
|
|
5825
6714
|
messages.push(` ${line}`);
|
|
5826
|
-
messages.push("", "Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.", "The Principal runs the item in a real signed-in browser and ticks the box.",
|
|
6715
|
+
messages.push("", "Per aeg-root/roles/developer.md (Verification), a PR is not mergeable while any [principal] Test Plan box is unticked.", "The Principal runs the item in a real signed-in browser and ticks the box.", ...liveUnticked ? [
|
|
6716
|
+
"An unticked [live] line is a live run that failed or that the review loop could not verify on its host: a later head re-runs it, or the Principal runs it and ticks the box."
|
|
6717
|
+
] : [], "Note: editing the PR body does not retrigger most workflows. If your PR body changes do not surface here, push an empty commit to re-run.");
|
|
5827
6718
|
return { verdict: "fail", messages };
|
|
5828
6719
|
}
|
|
5829
6720
|
messages.push("All [principal] Test Plan items ticked — runtime verification complete.", "PASS.");
|
|
@@ -6012,9 +6903,11 @@ var LineageSchema = z3.object({
|
|
|
6012
6903
|
parent: z3.string().nullable()
|
|
6013
6904
|
}).strict();
|
|
6014
6905
|
var InputVersionsSchema = z3.object({
|
|
6906
|
+
manifest_version: z3.literal(2).nullable().optional(),
|
|
6015
6907
|
objectives_version: z3.string().nullable(),
|
|
6016
6908
|
brief_hash: z3.string().nullable(),
|
|
6017
6909
|
ruling_ordinal: z3.number().int().nullable(),
|
|
6910
|
+
pause_bound_ruling: z3.object({ rulingId: z3.string().min(1), pauseId: z3.string().min(1), contentDigest: z3.string().min(1) }).strict().nullable().optional(),
|
|
6018
6911
|
policy_digest: z3.string().nullable()
|
|
6019
6912
|
}).strict();
|
|
6020
6913
|
var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
|
|
@@ -6052,7 +6945,17 @@ var HeaderMetaV3Schema = z3.object({
|
|
|
6052
6945
|
runtime: z3.string().nullable(),
|
|
6053
6946
|
source: z3.string().nullable()
|
|
6054
6947
|
}).strict();
|
|
6055
|
-
var
|
|
6948
|
+
var HeaderMetaV4Schema = HeaderMetaV3Schema.extend({
|
|
6949
|
+
schema: z3.literal(4),
|
|
6950
|
+
process: z3.object({ id: z3.string(), version: z3.string().nullable(), digest: z3.string().nullable() }).strict(),
|
|
6951
|
+
runner: z3.object({ id: z3.string(), version: z3.string().nullable() }).strict()
|
|
6952
|
+
}).strict();
|
|
6953
|
+
var HeaderMetaSchema = z3.discriminatedUnion("schema", [
|
|
6954
|
+
HeaderMetaV1Schema,
|
|
6955
|
+
HeaderMetaV2Schema,
|
|
6956
|
+
HeaderMetaV3Schema,
|
|
6957
|
+
HeaderMetaV4Schema
|
|
6958
|
+
]);
|
|
6056
6959
|
var SubjectSchema = z3.object({
|
|
6057
6960
|
issue: z3.number().int().nullable(),
|
|
6058
6961
|
pr: z3.number().int().optional(),
|
|
@@ -6272,6 +7175,75 @@ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
|
|
|
6272
7175
|
round: z3.number().int(),
|
|
6273
7176
|
phase: z3.string()
|
|
6274
7177
|
}).strict(),
|
|
7178
|
+
z3.object({
|
|
7179
|
+
...loopShared,
|
|
7180
|
+
event: z3.literal("conflict_reentry"),
|
|
7181
|
+
task: z3.number().int(),
|
|
7182
|
+
pr: z3.number().int().positive(),
|
|
7183
|
+
attempt: z3.number().int().positive(),
|
|
7184
|
+
bound: z3.number().int().positive()
|
|
7185
|
+
}).strict(),
|
|
7186
|
+
z3.object({
|
|
7187
|
+
...loopShared,
|
|
7188
|
+
event: z3.literal("storage_push"),
|
|
7189
|
+
round: z3.number().int(),
|
|
7190
|
+
branch: z3.string(),
|
|
7191
|
+
head: z3.string()
|
|
7192
|
+
}).strict(),
|
|
7193
|
+
z3.object({
|
|
7194
|
+
...loopShared,
|
|
7195
|
+
event: z3.literal("local_checks_run"),
|
|
7196
|
+
round: z3.number().int(),
|
|
7197
|
+
head: z3.string().nullable(),
|
|
7198
|
+
passed: z3.boolean(),
|
|
7199
|
+
wall_ms: z3.number().nonnegative()
|
|
7200
|
+
}).strict(),
|
|
7201
|
+
z3.object({
|
|
7202
|
+
...loopShared,
|
|
7203
|
+
event: z3.literal("ready_push"),
|
|
7204
|
+
round: z3.number().int(),
|
|
7205
|
+
head: z3.string(),
|
|
7206
|
+
outcome: z3.enum(["passed", "refused"]),
|
|
7207
|
+
selected: z3.number().int().nonnegative(),
|
|
7208
|
+
failed: z3.number().int().nonnegative(),
|
|
7209
|
+
rerun: z3.boolean(),
|
|
7210
|
+
wall_ms: z3.number().nonnegative()
|
|
7211
|
+
}).strict(),
|
|
7212
|
+
z3.object({
|
|
7213
|
+
...loopShared,
|
|
7214
|
+
event: z3.literal("failed_tests_rerun"),
|
|
7215
|
+
round: z3.number().int(),
|
|
7216
|
+
head: z3.string(),
|
|
7217
|
+
rerun_of: z3.string(),
|
|
7218
|
+
failed_files: z3.number().int().nonnegative(),
|
|
7219
|
+
affected_files: z3.number().int().nonnegative(),
|
|
7220
|
+
full_count: z3.number().int().nonnegative()
|
|
7221
|
+
}).strict(),
|
|
7222
|
+
z3.object({
|
|
7223
|
+
...loopShared,
|
|
7224
|
+
event: z3.literal("pr_opened"),
|
|
7225
|
+
round: z3.number().int(),
|
|
7226
|
+
pr: z3.number().int().positive(),
|
|
7227
|
+
head: z3.string()
|
|
7228
|
+
}).strict(),
|
|
7229
|
+
z3.object({
|
|
7230
|
+
...loopShared,
|
|
7231
|
+
event: z3.literal("ci_result_read"),
|
|
7232
|
+
round: z3.number().int(),
|
|
7233
|
+
pr: z3.number().int().positive(),
|
|
7234
|
+
head: z3.string(),
|
|
7235
|
+
conclusion: z3.enum(["green", "red", "pending", "skipped"]),
|
|
7236
|
+
failing_checks: z3.array(z3.string()),
|
|
7237
|
+
wait_ms: z3.number().nonnegative()
|
|
7238
|
+
}).strict(),
|
|
7239
|
+
z3.object({
|
|
7240
|
+
...loopShared,
|
|
7241
|
+
event: z3.literal("phase_time"),
|
|
7242
|
+
round: z3.number().int(),
|
|
7243
|
+
phase: z3.enum(["developer", "local_checks", "review", "push", "ci", "other"]),
|
|
7244
|
+
step: z3.string(),
|
|
7245
|
+
wall_ms: z3.number().nonnegative()
|
|
7246
|
+
}).strict(),
|
|
6275
7247
|
z3.object({
|
|
6276
7248
|
...loopShared,
|
|
6277
7249
|
event: z3.literal("driver_exited"),
|
|
@@ -6459,7 +7431,7 @@ var EffectEventSchema = z3.discriminatedUnion("event", [
|
|
|
6459
7431
|
]);
|
|
6460
7432
|
var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
|
|
6461
7433
|
var customShared = {
|
|
6462
|
-
meta:
|
|
7434
|
+
meta: HeaderMetaSchema,
|
|
6463
7435
|
subject: SubjectSchema,
|
|
6464
7436
|
kind: z3.literal("custom"),
|
|
6465
7437
|
...envelopeTail
|
|
@@ -6544,7 +7516,7 @@ function buildHeader(input) {
|
|
|
6544
7516
|
const issue = subject.issue;
|
|
6545
7517
|
return {
|
|
6546
7518
|
meta: {
|
|
6547
|
-
schema:
|
|
7519
|
+
schema: 4,
|
|
6548
7520
|
ts: input.now.toISOString(),
|
|
6549
7521
|
run_id: input.runId,
|
|
6550
7522
|
seq: input.seq,
|
|
@@ -6562,23 +7534,34 @@ function buildHeader(input) {
|
|
|
6562
7534
|
parent: lineageFieldFromEnv(input.env.parent)
|
|
6563
7535
|
},
|
|
6564
7536
|
input_versions: {
|
|
7537
|
+
manifest_version: input.inputVersions?.manifestVersion ?? null,
|
|
6565
7538
|
objectives_version: input.inputVersions?.objectivesVersion ?? null,
|
|
6566
7539
|
brief_hash: input.inputVersions?.briefHash ?? null,
|
|
6567
7540
|
ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
|
|
7541
|
+
pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
|
|
6568
7542
|
policy_digest: input.inputVersions?.policyDigest ?? null
|
|
6569
7543
|
},
|
|
6570
7544
|
provenance: provenanceFor(input),
|
|
6571
7545
|
work: {
|
|
6572
7546
|
ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
|
|
6573
7547
|
repo: input.repo,
|
|
6574
|
-
change: null,
|
|
6575
|
-
revision: null
|
|
7548
|
+
change: pr === undefined ? null : String(pr),
|
|
7549
|
+
revision: input.revision ?? null
|
|
6576
7550
|
},
|
|
6577
7551
|
flow: {
|
|
6578
7552
|
id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
|
|
6579
7553
|
version: lineageFieldFromEnv(input.env.flowVersion)
|
|
6580
7554
|
},
|
|
6581
7555
|
runtime: lineageFieldFromEnv(input.env.runtime),
|
|
7556
|
+
process: {
|
|
7557
|
+
id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
|
|
7558
|
+
version: lineageFieldFromEnv(input.env.processVersion),
|
|
7559
|
+
digest: lineageFieldFromEnv(input.env.processDigest)
|
|
7560
|
+
},
|
|
7561
|
+
runner: {
|
|
7562
|
+
id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
|
|
7563
|
+
version: lineageFieldFromEnv(input.env.runnerVersion)
|
|
7564
|
+
},
|
|
6582
7565
|
source: lineageFieldFromEnv(input.env.source)
|
|
6583
7566
|
},
|
|
6584
7567
|
subject
|
|
@@ -6622,7 +7605,7 @@ function redact(value, home) {
|
|
|
6622
7605
|
return value;
|
|
6623
7606
|
}
|
|
6624
7607
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6625
|
-
var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
|
|
7608
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2, 3, 4];
|
|
6626
7609
|
function metaOf(obj) {
|
|
6627
7610
|
if (obj === null || typeof obj !== "object")
|
|
6628
7611
|
return null;
|
|
@@ -6760,6 +7743,12 @@ var ManifestRecordSchema = z4.object({
|
|
|
6760
7743
|
briefHash: z4.string().min(1).nullable(),
|
|
6761
7744
|
objectivesVersion: z4.string().min(1).nullable(),
|
|
6762
7745
|
rulingOrdinal: epochNumber,
|
|
7746
|
+
manifestVersion: z4.literal(2).optional(),
|
|
7747
|
+
pauseBoundRuling: z4.object({
|
|
7748
|
+
rulingId: z4.string().min(1),
|
|
7749
|
+
pauseId: z4.string().min(1),
|
|
7750
|
+
contentDigest: z4.string().min(1)
|
|
7751
|
+
}).strict().nullable().optional(),
|
|
6763
7752
|
policyDigest: z4.string().min(1),
|
|
6764
7753
|
recordedAt: isoTimestamp
|
|
6765
7754
|
}).strict();
|
|
@@ -6781,7 +7770,11 @@ var LoopStateRecordSchema = z4.object({
|
|
|
6781
7770
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6782
7771
|
repeatMemory: z4.object({
|
|
6783
7772
|
blockingFindings: z4.array(z4.string()),
|
|
6784
|
-
lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
|
|
7773
|
+
lastFailure: z4.object({ signature: z4.string(), message: z4.string(), developerAttemptedSince: z4.boolean().optional() }).nullable()
|
|
7774
|
+
}).strict().optional(),
|
|
7775
|
+
developerHandoff: z4.object({
|
|
7776
|
+
findings: z4.array(z4.object({ id: z4.string().min(1), description: z4.string().min(1) }).strict()),
|
|
7777
|
+
failingChecks: z4.array(z4.string().min(1))
|
|
6785
7778
|
}).strict().optional(),
|
|
6786
7779
|
publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
|
|
6787
7780
|
taskStartedAt: isoTimestamp.optional(),
|
|
@@ -6836,41 +7829,342 @@ var ResolutionRecordSchema = z4.object({
|
|
|
6836
7829
|
authenticatedFrom: z4.string().min(1),
|
|
6837
7830
|
consumedAt: isoTimestamp
|
|
6838
7831
|
}).strict();
|
|
7832
|
+
var ExecutionRoundMirrorRecordSchema = z4.object({
|
|
7833
|
+
version: z4.literal(1),
|
|
7834
|
+
kind: z4.literal("execution_round"),
|
|
7835
|
+
task: taskId,
|
|
7836
|
+
repository: z4.string().min(1),
|
|
7837
|
+
threadId: z4.string().min(1),
|
|
7838
|
+
checkpointId: z4.string().min(1),
|
|
7839
|
+
round: z4.number().int().positive(),
|
|
7840
|
+
recordedAt: isoTimestamp
|
|
7841
|
+
}).strict();
|
|
6839
7842
|
// ../../packages/aeg-core/src/control-store/local.ts
|
|
6840
7843
|
var CONTROL_AREA_DIRNAME = "control";
|
|
6841
7844
|
// src/lib/diff-evidence.ts
|
|
6842
7845
|
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
6843
|
-
import { join as
|
|
7846
|
+
import { join as join10, relative as relative2, resolve as resolve2 } from "node:path";
|
|
6844
7847
|
|
|
6845
7848
|
// src/lib/config.ts
|
|
6846
7849
|
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
6847
7850
|
import { promisify as promisify4 } from "node:util";
|
|
6848
|
-
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
7851
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync } from "node:fs";
|
|
6849
7852
|
import { homedir } from "node:os";
|
|
6850
|
-
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
6851
|
-
import { z as
|
|
7853
|
+
import { basename as basename3, dirname, isAbsolute, join, resolve } from "node:path";
|
|
7854
|
+
import { z as z6 } from "zod";
|
|
7855
|
+
|
|
7856
|
+
// src/checks/contract.ts
|
|
7857
|
+
var CHECK_SCHEMA_VERSION = 1;
|
|
7858
|
+
function emitCheckError(error) {
|
|
7859
|
+
process.stderr.write(`${JSON.stringify(error)}
|
|
7860
|
+
`);
|
|
7861
|
+
}
|
|
6852
7862
|
|
|
6853
7863
|
// src/lib/agent-vendors.ts
|
|
6854
7864
|
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
6855
7865
|
|
|
7866
|
+
// src/lib/prose-rules-config.ts
|
|
7867
|
+
import safeRegex from "safe-regex2";
|
|
7868
|
+
import { z as z5 } from "zod";
|
|
7869
|
+
var SEVERITIES = ["error", "warning"];
|
|
7870
|
+
var OVERRIDE_KEYS = ["scopes", "severity", "exempt"];
|
|
7871
|
+
var FIXED_DEFAULT_KEYS = ["pattern", "patterns", "flags", "means", "message", "id"];
|
|
7872
|
+
var CUSTOM_KEYS = ["id", "pattern", "patterns", "flags", "means", "scopes", "severity", "exempt"];
|
|
7873
|
+
var DEFAULT_IDS = new Set([...DEFAULT_PROSE_RULES.map((rule) => rule.id), DECISION_RECORD_CITATION_ID]);
|
|
7874
|
+
function isPlainObject3(value) {
|
|
7875
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7876
|
+
}
|
|
7877
|
+
function outsideRepositoryReason(entry) {
|
|
7878
|
+
if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
|
|
7879
|
+
return "must be a repository-relative path, not an absolute one";
|
|
7880
|
+
if (entry.split(/[\\/]/).includes(".."))
|
|
7881
|
+
return "must stay inside the repository — no `..` segment";
|
|
7882
|
+
return null;
|
|
7883
|
+
}
|
|
7884
|
+
var RepoRelativePathSchema = z5.string().min(1).superRefine((entry, ctx) => {
|
|
7885
|
+
const reason = outsideRepositoryReason(entry);
|
|
7886
|
+
if (reason)
|
|
7887
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, message: reason });
|
|
7888
|
+
});
|
|
7889
|
+
function pathListIssues(value, path, issues) {
|
|
7890
|
+
if (!Array.isArray(value)) {
|
|
7891
|
+
issues.push({ path, message: "must be a list of repository-relative paths" });
|
|
7892
|
+
return;
|
|
7893
|
+
}
|
|
7894
|
+
value.forEach((entry, index) => {
|
|
7895
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
7896
|
+
issues.push({ path: [...path, index], message: "must be a non-empty repository-relative path" });
|
|
7897
|
+
return;
|
|
7898
|
+
}
|
|
7899
|
+
const reason = outsideRepositoryReason(entry);
|
|
7900
|
+
if (reason)
|
|
7901
|
+
issues.push({ path: [...path, index], message: reason });
|
|
7902
|
+
});
|
|
7903
|
+
}
|
|
7904
|
+
function scopeListIssues(value, path, allowed, issues) {
|
|
7905
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
7906
|
+
issues.push({ path, message: "must name at least one scope" });
|
|
7907
|
+
return null;
|
|
7908
|
+
}
|
|
7909
|
+
const scopes = [];
|
|
7910
|
+
value.forEach((scope, index) => {
|
|
7911
|
+
if (typeof scope !== "string" || !CONFIGURABLE_PROSE_SCOPES.includes(scope)) {
|
|
7912
|
+
issues.push({
|
|
7913
|
+
path: [...path, index],
|
|
7914
|
+
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(", ")}`
|
|
7915
|
+
});
|
|
7916
|
+
return;
|
|
7917
|
+
}
|
|
7918
|
+
if (!allowed.includes(scope)) {
|
|
7919
|
+
issues.push({
|
|
7920
|
+
path: [...path, index],
|
|
7921
|
+
message: `scope "${scope}" is not one this rule can run in — it can run in: ${allowed.join(", ")}`
|
|
7922
|
+
});
|
|
7923
|
+
return;
|
|
7924
|
+
}
|
|
7925
|
+
scopes.push(scope);
|
|
7926
|
+
});
|
|
7927
|
+
return scopes;
|
|
7928
|
+
}
|
|
7929
|
+
function severityIssues(value, path, scopes, issues) {
|
|
7930
|
+
if (typeof value === "string") {
|
|
7931
|
+
if (!SEVERITIES.includes(value)) {
|
|
7932
|
+
issues.push({ path, message: `unknown severity ${JSON.stringify(value)} — use "error" or "warning"` });
|
|
7933
|
+
}
|
|
7934
|
+
return;
|
|
7935
|
+
}
|
|
7936
|
+
if (!isPlainObject3(value)) {
|
|
7937
|
+
issues.push({ path, message: 'must be "error", "warning", or a map from scope to one of them' });
|
|
7938
|
+
return;
|
|
7939
|
+
}
|
|
7940
|
+
for (const [scope, severity] of Object.entries(value)) {
|
|
7941
|
+
if (!scopes.includes(scope)) {
|
|
7942
|
+
issues.push({ path: [...path, scope], message: `names scope "${scope}", which this rule's scopes do not cover` });
|
|
7943
|
+
}
|
|
7944
|
+
if (typeof severity !== "string" || !SEVERITIES.includes(severity)) {
|
|
7945
|
+
issues.push({
|
|
7946
|
+
path: [...path, scope],
|
|
7947
|
+
message: `unknown severity ${JSON.stringify(severity)} — use "error" or "warning"`
|
|
7948
|
+
});
|
|
7949
|
+
}
|
|
7950
|
+
}
|
|
7951
|
+
}
|
|
7952
|
+
function patternIssues(source, flags, path, issues) {
|
|
7953
|
+
if (typeof source !== "string" || source.length === 0) {
|
|
7954
|
+
issues.push({ path, message: "must be a non-empty regular expression" });
|
|
7955
|
+
return;
|
|
7956
|
+
}
|
|
7957
|
+
if (source.length > CONFIGURED_PATTERN_MAX_LENGTH) {
|
|
7958
|
+
issues.push({
|
|
7959
|
+
path,
|
|
7960
|
+
message: `is ${source.length} characters, over the ${CONFIGURED_PATTERN_MAX_LENGTH}-character limit for a configured pattern`
|
|
7961
|
+
});
|
|
7962
|
+
return;
|
|
7963
|
+
}
|
|
7964
|
+
try {
|
|
7965
|
+
new RegExp(source, flags);
|
|
7966
|
+
} catch (err) {
|
|
7967
|
+
issues.push({ path, message: `does not compile: ${err.message}` });
|
|
7968
|
+
return;
|
|
7969
|
+
}
|
|
7970
|
+
if (!safeRegex(source, { limit: Number.MAX_SAFE_INTEGER })) {
|
|
7971
|
+
issues.push({
|
|
7972
|
+
path,
|
|
7973
|
+
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."
|
|
7974
|
+
});
|
|
7975
|
+
}
|
|
7976
|
+
}
|
|
7977
|
+
function flagIssues(value, path, issues) {
|
|
7978
|
+
if (value === undefined)
|
|
7979
|
+
return "";
|
|
7980
|
+
if (typeof value !== "string") {
|
|
7981
|
+
issues.push({ path, message: 'must be a string of flags, e.g. "i"' });
|
|
7982
|
+
return "";
|
|
7983
|
+
}
|
|
7984
|
+
const seen = new Set;
|
|
7985
|
+
for (const flag of value) {
|
|
7986
|
+
if (!CONFIGURED_PROSE_FLAGS.includes(flag)) {
|
|
7987
|
+
issues.push({
|
|
7988
|
+
path,
|
|
7989
|
+
message: `unknown flag ${JSON.stringify(flag)} — only ${CONFIGURED_PROSE_FLAGS.map((f) => `"${f}"`).join(" and ")} are allowed`
|
|
7990
|
+
});
|
|
7991
|
+
return "";
|
|
7992
|
+
}
|
|
7993
|
+
if (seen.has(flag)) {
|
|
7994
|
+
issues.push({ path, message: `repeats the flag "${flag}"` });
|
|
7995
|
+
return "";
|
|
7996
|
+
}
|
|
7997
|
+
seen.add(flag);
|
|
7998
|
+
}
|
|
7999
|
+
return value;
|
|
8000
|
+
}
|
|
8001
|
+
function defaultsIssues(value, issues) {
|
|
8002
|
+
const base = ["defaults"];
|
|
8003
|
+
if (!isPlainObject3(value)) {
|
|
8004
|
+
issues.push({ path: base, message: 'must map a default rule id to "off" or an override' });
|
|
8005
|
+
return;
|
|
8006
|
+
}
|
|
8007
|
+
for (const [id, override] of Object.entries(value)) {
|
|
8008
|
+
const path = [...base, id];
|
|
8009
|
+
const rule = CONFIGURABLE_DEFAULT_RULES.find((candidate) => candidate.id === id);
|
|
8010
|
+
if (!rule) {
|
|
8011
|
+
issues.push({
|
|
8012
|
+
path,
|
|
8013
|
+
message: `unknown default rule id "${id}" — \`vinaya check --plan\` lists the rules each prose check runs`
|
|
8014
|
+
});
|
|
8015
|
+
continue;
|
|
8016
|
+
}
|
|
8017
|
+
if (override === "off")
|
|
8018
|
+
continue;
|
|
8019
|
+
if (!isPlainObject3(override)) {
|
|
8020
|
+
issues.push({ path, message: 'must be "off" or an object with any of scopes, severity, exempt' });
|
|
8021
|
+
continue;
|
|
8022
|
+
}
|
|
8023
|
+
for (const key of Object.keys(override)) {
|
|
8024
|
+
if (OVERRIDE_KEYS.includes(key))
|
|
8025
|
+
continue;
|
|
8026
|
+
issues.push({
|
|
8027
|
+
path: [...path, key],
|
|
8028
|
+
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`
|
|
8029
|
+
});
|
|
8030
|
+
}
|
|
8031
|
+
const scopes = override.scopes === undefined ? [...rule.scopes] : scopeListIssues(override.scopes, [...path, "scopes"], allowedScopesFor(rule), issues);
|
|
8032
|
+
if (override.severity !== undefined && scopes)
|
|
8033
|
+
severityIssues(override.severity, [...path, "severity"], scopes, issues);
|
|
8034
|
+
if (override.exempt !== undefined)
|
|
8035
|
+
pathListIssues(override.exempt, [...path, "exempt"], issues);
|
|
8036
|
+
}
|
|
8037
|
+
}
|
|
8038
|
+
function customIssues(value, issues) {
|
|
8039
|
+
if (!Array.isArray(value)) {
|
|
8040
|
+
issues.push({ path: ["custom"], message: "must be a list of rules" });
|
|
8041
|
+
return;
|
|
8042
|
+
}
|
|
8043
|
+
const ids = new Set;
|
|
8044
|
+
value.forEach((rule, index) => {
|
|
8045
|
+
const path = ["custom", index];
|
|
8046
|
+
if (!isPlainObject3(rule)) {
|
|
8047
|
+
issues.push({ path, message: "must be a rule object" });
|
|
8048
|
+
return;
|
|
8049
|
+
}
|
|
8050
|
+
for (const key of Object.keys(rule)) {
|
|
8051
|
+
if (!CUSTOM_KEYS.includes(key)) {
|
|
8052
|
+
issues.push({ path: [...path, key], message: `unknown key "${key}" — a rule takes ${CUSTOM_KEYS.join(", ")}` });
|
|
8053
|
+
}
|
|
8054
|
+
}
|
|
8055
|
+
if (typeof rule.id !== "string" || rule.id.length === 0) {
|
|
8056
|
+
issues.push({ path: [...path, "id"], message: "a custom rule needs an id" });
|
|
8057
|
+
} else if (DEFAULT_IDS.has(rule.id)) {
|
|
8058
|
+
issues.push({
|
|
8059
|
+
path: [...path, "id"],
|
|
8060
|
+
message: `"${rule.id}" is a default rule id — a custom rule needs its own id; retune the default under proseGates.rules.defaults instead`
|
|
8061
|
+
});
|
|
8062
|
+
} else if (ids.has(rule.id)) {
|
|
8063
|
+
issues.push({ path: [...path, "id"], message: `"${rule.id}" is used by an earlier custom rule` });
|
|
8064
|
+
} else {
|
|
8065
|
+
ids.add(rule.id);
|
|
8066
|
+
}
|
|
8067
|
+
if (typeof rule.means !== "string" || rule.means.trim().length === 0) {
|
|
8068
|
+
issues.push({ path: [...path, "means"], message: "a custom rule needs a message (`means`)" });
|
|
8069
|
+
}
|
|
8070
|
+
let scopes = null;
|
|
8071
|
+
if (rule.scopes === undefined) {
|
|
8072
|
+
issues.push({ path: [...path, "scopes"], message: "a custom rule needs at least one scope (`scopes`)" });
|
|
8073
|
+
} else {
|
|
8074
|
+
scopes = scopeListIssues(rule.scopes, [...path, "scopes"], CONFIGURABLE_PROSE_SCOPES, issues);
|
|
8075
|
+
}
|
|
8076
|
+
if (scopes && new Set(scopes.map(groupOfScope)).size > 1) {
|
|
8077
|
+
issues.push({
|
|
8078
|
+
path: [...path, "scopes"],
|
|
8079
|
+
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'
|
|
8080
|
+
});
|
|
8081
|
+
}
|
|
8082
|
+
const flags = flagIssues(rule.flags, [...path, "flags"], issues);
|
|
8083
|
+
if (rule.pattern === undefined && rule.patterns === undefined) {
|
|
8084
|
+
issues.push({
|
|
8085
|
+
path: [...path, "pattern"],
|
|
8086
|
+
message: "a custom rule needs a `pattern` or a per-scope `patterns` map"
|
|
8087
|
+
});
|
|
8088
|
+
}
|
|
8089
|
+
if (rule.pattern !== undefined)
|
|
8090
|
+
patternIssues(rule.pattern, flags, [...path, "pattern"], issues);
|
|
8091
|
+
if (rule.patterns !== undefined) {
|
|
8092
|
+
if (!isPlainObject3(rule.patterns)) {
|
|
8093
|
+
issues.push({ path: [...path, "patterns"], message: "must map a scope to a regular expression" });
|
|
8094
|
+
} else {
|
|
8095
|
+
for (const [scope, source] of Object.entries(rule.patterns)) {
|
|
8096
|
+
if (scopes && !scopes.includes(scope)) {
|
|
8097
|
+
issues.push({
|
|
8098
|
+
path: [...path, "patterns", scope],
|
|
8099
|
+
message: `names scope "${scope}", which this rule's scopes do not cover`
|
|
8100
|
+
});
|
|
8101
|
+
continue;
|
|
8102
|
+
}
|
|
8103
|
+
patternIssues(source, flags, [...path, "patterns", scope], issues);
|
|
8104
|
+
}
|
|
8105
|
+
if (rule.pattern === undefined && scopes) {
|
|
8106
|
+
for (const scope of scopes) {
|
|
8107
|
+
if (!(scope in rule.patterns)) {
|
|
8108
|
+
issues.push({
|
|
8109
|
+
path: [...path, "patterns"],
|
|
8110
|
+
message: `has no pattern for scope "${scope}" — add one, or a \`pattern\` every other scope uses`
|
|
8111
|
+
});
|
|
8112
|
+
}
|
|
8113
|
+
}
|
|
8114
|
+
}
|
|
8115
|
+
}
|
|
8116
|
+
}
|
|
8117
|
+
if (rule.severity !== undefined && scopes)
|
|
8118
|
+
severityIssues(rule.severity, [...path, "severity"], scopes, issues);
|
|
8119
|
+
if (rule.exempt !== undefined)
|
|
8120
|
+
pathListIssues(rule.exempt, [...path, "exempt"], issues);
|
|
8121
|
+
});
|
|
8122
|
+
}
|
|
8123
|
+
function proseRulesIssues(value) {
|
|
8124
|
+
const issues = [];
|
|
8125
|
+
if (!isPlainObject3(value))
|
|
8126
|
+
return [{ path: [], message: "must be an object with any of exempt, defaults, custom" }];
|
|
8127
|
+
for (const key of Object.keys(value)) {
|
|
8128
|
+
if (!["exempt", "defaults", "custom"].includes(key)) {
|
|
8129
|
+
issues.push({ path: [key], message: `unknown key "${key}" — proseGates.rules takes exempt, defaults and custom` });
|
|
8130
|
+
}
|
|
8131
|
+
}
|
|
8132
|
+
if (value.exempt !== undefined)
|
|
8133
|
+
pathListIssues(value.exempt, ["exempt"], issues);
|
|
8134
|
+
if (value.defaults !== undefined)
|
|
8135
|
+
defaultsIssues(value.defaults, issues);
|
|
8136
|
+
if (value.custom !== undefined)
|
|
8137
|
+
customIssues(value.custom, issues);
|
|
8138
|
+
return issues;
|
|
8139
|
+
}
|
|
8140
|
+
var ProseRulesSchema = z5.unknown().superRefine((value, ctx) => {
|
|
8141
|
+
for (const issue of proseRulesIssues(value)) {
|
|
8142
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: issue.path, message: issue.message });
|
|
8143
|
+
}
|
|
8144
|
+
}).transform((value) => value);
|
|
8145
|
+
var PublishedProseSchema = z5.object({
|
|
8146
|
+
allow: z5.array(z5.string().min(1)).optional()
|
|
8147
|
+
}).strict();
|
|
8148
|
+
|
|
6856
8149
|
// src/lib/config.ts
|
|
6857
|
-
var EnvEntrySchema =
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
8150
|
+
var EnvEntrySchema = z6.union([
|
|
8151
|
+
z6.literal(true),
|
|
8152
|
+
z6.object({ optional: z6.literal(true) }),
|
|
8153
|
+
z6.object({ anyOf: z6.array(z6.string()).min(2) }),
|
|
8154
|
+
z6.string()
|
|
6862
8155
|
]);
|
|
6863
|
-
var CheckEntrySchema =
|
|
6864
|
-
run:
|
|
6865
|
-
scope:
|
|
6866
|
-
include:
|
|
6867
|
-
args:
|
|
6868
|
-
timeoutMs:
|
|
6869
|
-
env:
|
|
6870
|
-
requiresOpenPr:
|
|
6871
|
-
ownWorkflow:
|
|
6872
|
-
principalOwed:
|
|
6873
|
-
validates:
|
|
8156
|
+
var CheckEntrySchema = z6.object({
|
|
8157
|
+
run: z6.string(),
|
|
8158
|
+
scope: z6.enum(["diff", "full"]),
|
|
8159
|
+
include: z6.array(z6.string()).optional(),
|
|
8160
|
+
args: z6.array(z6.string()).optional(),
|
|
8161
|
+
timeoutMs: z6.number().optional(),
|
|
8162
|
+
env: z6.record(z6.string(), EnvEntrySchema).optional(),
|
|
8163
|
+
requiresOpenPr: z6.boolean().optional(),
|
|
8164
|
+
ownWorkflow: z6.boolean().optional(),
|
|
8165
|
+
principalOwed: z6.literal(true).optional(),
|
|
8166
|
+
validates: z6.enum(["body", "issue"]).optional(),
|
|
8167
|
+
advisory: z6.literal(true).optional()
|
|
6874
8168
|
}).superRefine((entry, ctx) => {
|
|
6875
8169
|
if (!entry.env)
|
|
6876
8170
|
return;
|
|
@@ -6880,22 +8174,22 @@ var CheckEntrySchema = z5.object({
|
|
|
6880
8174
|
const members = value.anyOf;
|
|
6881
8175
|
if (new Set(members).size !== members.length) {
|
|
6882
8176
|
ctx.addIssue({
|
|
6883
|
-
code:
|
|
8177
|
+
code: z6.ZodIssueCode.custom,
|
|
6884
8178
|
message: `env.${key}.anyOf has duplicate members`,
|
|
6885
8179
|
path: ["env", key, "anyOf"]
|
|
6886
8180
|
});
|
|
6887
8181
|
}
|
|
6888
8182
|
if (!members.includes(key)) {
|
|
6889
8183
|
ctx.addIssue({
|
|
6890
|
-
code:
|
|
8184
|
+
code: z6.ZodIssueCode.custom,
|
|
6891
8185
|
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
6892
8186
|
path: ["env", key, "anyOf"]
|
|
6893
8187
|
});
|
|
6894
8188
|
}
|
|
6895
8189
|
}
|
|
6896
8190
|
});
|
|
6897
|
-
var RoleEntrySchema =
|
|
6898
|
-
contract:
|
|
8191
|
+
var RoleEntrySchema = z6.object({
|
|
8192
|
+
contract: z6.string().refine((p) => p.includes("/"), {
|
|
6899
8193
|
message: 'must be a path (contain at least one "/"), not a bare filename'
|
|
6900
8194
|
})
|
|
6901
8195
|
});
|
|
@@ -6919,17 +8213,17 @@ var BRIEF_BUILTINS = [
|
|
|
6919
8213
|
"briefSections",
|
|
6920
8214
|
"milestoneShape"
|
|
6921
8215
|
];
|
|
6922
|
-
var BriefSectionSchema =
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
8216
|
+
var BriefSectionSchema = z6.union([
|
|
8217
|
+
z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
|
|
8218
|
+
z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
|
|
8219
|
+
z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
|
|
8220
|
+
z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
|
|
6927
8221
|
]);
|
|
6928
|
-
var BriefSchemaSchema =
|
|
6929
|
-
pr:
|
|
6930
|
-
issue:
|
|
6931
|
-
milestone:
|
|
6932
|
-
ack:
|
|
8222
|
+
var BriefSchemaSchema = z6.object({
|
|
8223
|
+
pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8224
|
+
issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8225
|
+
milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
|
|
8226
|
+
ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
|
|
6933
8227
|
});
|
|
6934
8228
|
function isSafeRepoRelPath(p) {
|
|
6935
8229
|
if (p.length === 0)
|
|
@@ -6938,7 +8232,7 @@ function isSafeRepoRelPath(p) {
|
|
|
6938
8232
|
return false;
|
|
6939
8233
|
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
6940
8234
|
}
|
|
6941
|
-
var SafeRepoRelPath =
|
|
8235
|
+
var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
|
|
6942
8236
|
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
6943
8237
|
});
|
|
6944
8238
|
var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
|
|
@@ -6948,22 +8242,22 @@ function isCanonicalHookBlockPath(p) {
|
|
|
6948
8242
|
var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
|
|
6949
8243
|
message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
|
|
6950
8244
|
});
|
|
6951
|
-
var ManagedBlockRecordSchema =
|
|
8245
|
+
var ManagedBlockRecordSchema = z6.object({
|
|
6952
8246
|
path: ManagedHookBlockPath,
|
|
6953
|
-
marker:
|
|
6954
|
-
comment:
|
|
8247
|
+
marker: z6.string(),
|
|
8248
|
+
comment: z6.enum(["hash", "html"])
|
|
6955
8249
|
});
|
|
6956
|
-
var ManagedManifestSchema =
|
|
6957
|
-
version:
|
|
6958
|
-
files:
|
|
6959
|
-
blocks:
|
|
6960
|
-
labels:
|
|
6961
|
-
agents:
|
|
8250
|
+
var ManagedManifestSchema = z6.object({
|
|
8251
|
+
version: z6.number().int().positive(),
|
|
8252
|
+
files: z6.array(SafeRepoRelPath),
|
|
8253
|
+
blocks: z6.array(ManagedBlockRecordSchema),
|
|
8254
|
+
labels: z6.array(z6.string()),
|
|
8255
|
+
agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
|
|
6962
8256
|
});
|
|
6963
|
-
var ProjectEntrySchema =
|
|
6964
|
-
name:
|
|
6965
|
-
description:
|
|
6966
|
-
path:
|
|
8257
|
+
var ProjectEntrySchema = z6.object({
|
|
8258
|
+
name: z6.string().min(1),
|
|
8259
|
+
description: z6.string().min(1).optional(),
|
|
8260
|
+
path: z6.string().min(1).optional()
|
|
6967
8261
|
});
|
|
6968
8262
|
function parseTokensCollectDeclaration(value) {
|
|
6969
8263
|
const m = value.trim().match(/^(\S+)\s+(\S+)$/);
|
|
@@ -6974,90 +8268,101 @@ function parseTokensCollectDeclaration(value) {
|
|
|
6974
8268
|
return null;
|
|
6975
8269
|
return { interpreter, script };
|
|
6976
8270
|
}
|
|
6977
|
-
var
|
|
6978
|
-
rings:
|
|
6979
|
-
ring1_forgeWriteInterception:
|
|
6980
|
-
ring2_asyncAudits:
|
|
8271
|
+
var VinayaConfigObjectSchema = z6.object({
|
|
8272
|
+
rings: z6.object({
|
|
8273
|
+
ring1_forgeWriteInterception: z6.boolean(),
|
|
8274
|
+
ring2_asyncAudits: z6.boolean()
|
|
6981
8275
|
}).optional(),
|
|
6982
|
-
checks:
|
|
6983
|
-
roles:
|
|
8276
|
+
checks: z6.record(z6.string(), CheckEntrySchema).optional(),
|
|
8277
|
+
roles: z6.record(z6.string(), RoleEntrySchema).optional(),
|
|
6984
8278
|
briefSchema: BriefSchemaSchema.optional(),
|
|
6985
8279
|
managed: ManagedManifestSchema.optional(),
|
|
6986
|
-
principals:
|
|
6987
|
-
releaseActor:
|
|
6988
|
-
ci:
|
|
6989
|
-
tokens:
|
|
6990
|
-
collect:
|
|
8280
|
+
principals: z6.array(z6.string()).min(1).optional(),
|
|
8281
|
+
releaseActor: z6.string().min(1).optional(),
|
|
8282
|
+
ci: z6.object({ setup: z6.string().min(1) }).optional(),
|
|
8283
|
+
tokens: z6.object({
|
|
8284
|
+
collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
|
|
6991
8285
|
message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
|
|
6992
8286
|
})
|
|
6993
8287
|
}).optional(),
|
|
6994
|
-
blastRadius:
|
|
6995
|
-
proseGates:
|
|
6996
|
-
doctrineRoot:
|
|
6997
|
-
readerFacingPrefix:
|
|
6998
|
-
readerFacingSuffix:
|
|
6999
|
-
legacySlugDir:
|
|
7000
|
-
sourceComments:
|
|
7001
|
-
globs:
|
|
7002
|
-
allowlist:
|
|
7003
|
-
severity:
|
|
8288
|
+
blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
|
|
8289
|
+
proseGates: z6.object({
|
|
8290
|
+
doctrineRoot: z6.string().min(1).optional(),
|
|
8291
|
+
readerFacingPrefix: z6.string().min(1).optional(),
|
|
8292
|
+
readerFacingSuffix: z6.string().min(1).optional(),
|
|
8293
|
+
legacySlugDir: z6.string().min(1).optional(),
|
|
8294
|
+
sourceComments: z6.object({
|
|
8295
|
+
globs: z6.array(z6.string().min(1)).optional(),
|
|
8296
|
+
allowlist: z6.array(z6.string().min(1)).optional(),
|
|
8297
|
+
severity: z6.enum(["warning", "error"]).optional()
|
|
7004
8298
|
}).optional(),
|
|
7005
|
-
specGrandfather:
|
|
7006
|
-
specPaths:
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
})).optional()
|
|
8299
|
+
specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
|
|
8300
|
+
specPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8301
|
+
productPaths: z6.array(RepoRelativePathSchema).optional(),
|
|
8302
|
+
published: PublishedProseSchema.optional(),
|
|
8303
|
+
rules: ProseRulesSchema.optional()
|
|
7011
8304
|
}).optional(),
|
|
7012
|
-
projects:
|
|
7013
|
-
dispatch:
|
|
7014
|
-
timeoutMs:
|
|
7015
|
-
|
|
7016
|
-
|
|
8305
|
+
projects: z6.array(ProjectEntrySchema).optional(),
|
|
8306
|
+
dispatch: z6.object({
|
|
8307
|
+
timeoutMs: z6.number().int().positive().optional(),
|
|
8308
|
+
reviewerTimeoutMs: z6.number().int().positive().optional(),
|
|
8309
|
+
killGraceMs: z6.number().int().positive().optional(),
|
|
8310
|
+
agent: z6.enum(["claude", "codex"]).optional()
|
|
7017
8311
|
}).optional(),
|
|
7018
|
-
reviewPolicy:
|
|
7019
|
-
codeReviewThreshold:
|
|
7020
|
-
securityThreshold:
|
|
7021
|
-
maxRounds:
|
|
7022
|
-
maxTaskMinutes:
|
|
8312
|
+
reviewPolicy: z6.object({
|
|
8313
|
+
codeReviewThreshold: z6.string().min(1).optional(),
|
|
8314
|
+
securityThreshold: z6.string().min(1).optional(),
|
|
8315
|
+
maxRounds: z6.number().optional(),
|
|
8316
|
+
maxTaskMinutes: z6.number().optional(),
|
|
8317
|
+
readyPushTimeoutMinutes: z6.number().optional()
|
|
7023
8318
|
}).optional(),
|
|
7024
|
-
securityScan:
|
|
7025
|
-
command:
|
|
8319
|
+
securityScan: z6.object({
|
|
8320
|
+
command: z6.array(z6.string().min(1)).min(1)
|
|
7026
8321
|
}).optional(),
|
|
7027
|
-
gateCutovers:
|
|
7028
|
-
objectivesSinceIssue:
|
|
7029
|
-
briefSectionsSinceIssue:
|
|
7030
|
-
documentationSinceIssue:
|
|
7031
|
-
briefRulesSincePr:
|
|
7032
|
-
agentBoxesRefusedSincePr:
|
|
8322
|
+
gateCutovers: z6.object({
|
|
8323
|
+
objectivesSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8324
|
+
briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8325
|
+
documentationSinceIssue: z6.number().int().nonnegative().optional(),
|
|
8326
|
+
briefRulesSincePr: z6.number().int().nonnegative().optional(),
|
|
8327
|
+
agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
|
|
7033
8328
|
}).optional(),
|
|
7034
|
-
planning:
|
|
7035
|
-
collisionThreshold:
|
|
8329
|
+
planning: z6.object({
|
|
8330
|
+
collisionThreshold: z6.number().int().nonnegative().optional()
|
|
7036
8331
|
}).optional(),
|
|
7037
|
-
prePush:
|
|
7038
|
-
alwaysRun:
|
|
8332
|
+
prePush: z6.object({
|
|
8333
|
+
alwaysRun: z6.array(z6.string()).optional(),
|
|
8334
|
+
readyTests: z6.object({
|
|
8335
|
+
mode: z6.literal("ci"),
|
|
8336
|
+
workflow: z6.literal(".github/workflows/ci.yml"),
|
|
8337
|
+
check: z6.literal("Vinaya CI")
|
|
8338
|
+
}).strict().optional(),
|
|
8339
|
+
requiredCi: z6.object({
|
|
8340
|
+
workflow: z6.literal(".github/workflows/ci.yml"),
|
|
8341
|
+
check: z6.literal("Vinaya CI")
|
|
8342
|
+
}).strict().optional()
|
|
7039
8343
|
}).optional(),
|
|
7040
|
-
report:
|
|
7041
|
-
commandTimeoutMs:
|
|
8344
|
+
report: z6.object({
|
|
8345
|
+
commandTimeoutMs: z6.number().int().positive().optional()
|
|
7042
8346
|
}).superRefine((report, ctx) => {
|
|
7043
8347
|
const commandTimeoutMs = report.commandTimeoutMs;
|
|
7044
8348
|
if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
|
|
7045
8349
|
ctx.addIssue({
|
|
7046
|
-
code:
|
|
8350
|
+
code: z6.ZodIssueCode.custom,
|
|
7047
8351
|
path: ["commandTimeoutMs"],
|
|
7048
8352
|
message: "must be at most 3600000 (1 hour)"
|
|
7049
8353
|
});
|
|
7050
8354
|
}
|
|
7051
8355
|
}).optional(),
|
|
7052
|
-
logPublish:
|
|
8356
|
+
logPublish: z6.unknown().refine((v) => v === undefined, {
|
|
7053
8357
|
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
7054
8358
|
}),
|
|
7055
|
-
runtimeDir:
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
8359
|
+
runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
8360
|
+
runner: z6.enum(["standalone", "atta-engine"]).optional(),
|
|
8361
|
+
logs: z6.object({
|
|
8362
|
+
folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
8363
|
+
url: z6.string().url().optional(),
|
|
8364
|
+
headers: z6.record(z6.string()).optional(),
|
|
8365
|
+
readHeaders: z6.record(z6.string()).optional(),
|
|
7061
8366
|
events: CustomEventDeclarationsSchema.optional()
|
|
7062
8367
|
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
7063
8368
|
message: "logs: set at most one of folder/url"
|
|
@@ -7065,8 +8370,33 @@ var VinayaConfigSchema = z5.object({
|
|
|
7065
8370
|
message: "logs: headers requires url"
|
|
7066
8371
|
}).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
|
|
7067
8372
|
message: "logs: readHeaders requires url"
|
|
7068
|
-
}).optional()
|
|
8373
|
+
}).or(z6.literal(false)).optional(),
|
|
8374
|
+
decisionRecords: z6.object({
|
|
8375
|
+
path: RepoRelativePathSchema
|
|
8376
|
+
}).strict().optional()
|
|
8377
|
+
});
|
|
8378
|
+
function decisionRecordsPathIssue(path, doctrineRoot) {
|
|
8379
|
+
const reason = outsideRepositoryReason(path);
|
|
8380
|
+
if (reason)
|
|
8381
|
+
return reason;
|
|
8382
|
+
const folder = normalizeSpecPath(path);
|
|
8383
|
+
if (folder === "" || folder === ".")
|
|
8384
|
+
return "must name a folder, not the repository root";
|
|
8385
|
+
const root = normalizeSpecPath(doctrineRoot ?? "aeg-root");
|
|
8386
|
+
if (folder === root || folder.startsWith(`${root}/`)) {
|
|
8387
|
+
return `must be outside the doctrine tree "${root}" — decision records belong to this repository, not to the doctrine it ships`;
|
|
8388
|
+
}
|
|
8389
|
+
return null;
|
|
8390
|
+
}
|
|
8391
|
+
var VinayaConfigSchema = VinayaConfigObjectSchema.superRefine((config, ctx) => {
|
|
8392
|
+
const path = config.decisionRecords?.path;
|
|
8393
|
+
if (path === undefined || outsideRepositoryReason(path))
|
|
8394
|
+
return;
|
|
8395
|
+
const issue = decisionRecordsPathIssue(path, config.proseGates?.doctrineRoot);
|
|
8396
|
+
if (issue)
|
|
8397
|
+
ctx.addIssue({ code: z6.ZodIssueCode.custom, path: ["decisionRecords", "path"], message: issue });
|
|
7069
8398
|
});
|
|
8399
|
+
var VinayaConfigShape = VinayaConfigObjectSchema.shape;
|
|
7070
8400
|
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
7071
8401
|
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
7072
8402
|
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
@@ -7147,9 +8477,6 @@ function stripGlobalOnlyKeys(config, path) {
|
|
|
7147
8477
|
}
|
|
7148
8478
|
return result;
|
|
7149
8479
|
}
|
|
7150
|
-
function resolvePrincipalAllowlist(config) {
|
|
7151
|
-
return config?.principals ?? PRINCIPAL_ALLOWLIST;
|
|
7152
|
-
}
|
|
7153
8480
|
function resolveReleaseActor(config) {
|
|
7154
8481
|
return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
|
|
7155
8482
|
}
|
|
@@ -7173,13 +8500,19 @@ function resolveReviewPolicy(config) {
|
|
|
7173
8500
|
if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
|
|
7174
8501
|
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.`);
|
|
7175
8502
|
}
|
|
8503
|
+
const readyPushTimeoutMinutes = raw.readyPushTimeoutMinutes ?? DEFAULT_READY_PUSH_TIMEOUT_MINUTES;
|
|
8504
|
+
if (!Number.isInteger(readyPushTimeoutMinutes) || readyPushTimeoutMinutes < 1) {
|
|
8505
|
+
throw new Error(`vinaya.config.json: reviewPolicy.readyPushTimeoutMinutes "${readyPushTimeoutMinutes}" is not a positive integer — fix the config, this never falls back to a default.`);
|
|
8506
|
+
}
|
|
7176
8507
|
return {
|
|
7177
8508
|
codeReviewThreshold,
|
|
7178
8509
|
securityThreshold,
|
|
7179
8510
|
maxRounds,
|
|
7180
|
-
maxTaskMinutes
|
|
8511
|
+
maxTaskMinutes,
|
|
8512
|
+
readyPushTimeoutMinutes
|
|
7181
8513
|
};
|
|
7182
8514
|
}
|
|
8515
|
+
var emittedLocalOverrideWarnings = new Set;
|
|
7183
8516
|
function resolveGateCutovers(config) {
|
|
7184
8517
|
const raw = config?.gateCutovers;
|
|
7185
8518
|
if (!raw)
|
|
@@ -7285,13 +8618,14 @@ function readTrustAnchorConfigAtRef(ref) {
|
|
|
7285
8618
|
});
|
|
7286
8619
|
return Buffer.from(raw, "utf-8").toString("base64");
|
|
7287
8620
|
}
|
|
8621
|
+
var NO_TRUST_ANCHOR_REPO_MESSAGE = "could not resolve repo identity for the trust-anchor read";
|
|
7288
8622
|
function ghFetchTrustAnchorConfig() {
|
|
7289
8623
|
const probeRef = resolveCiTrustAnchorProbeRef();
|
|
7290
8624
|
if (probeRef)
|
|
7291
8625
|
return readTrustAnchorConfigAtRef(probeRef);
|
|
7292
8626
|
const repo = trustAnchorRepo();
|
|
7293
8627
|
if (!repo)
|
|
7294
|
-
throw new Error(
|
|
8628
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7295
8629
|
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
7296
8630
|
encoding: "utf-8",
|
|
7297
8631
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -7308,7 +8642,7 @@ async function ghFetchTrustAnchorConfigAsync() {
|
|
|
7308
8642
|
}
|
|
7309
8643
|
const repo = await trustAnchorRepoAsync();
|
|
7310
8644
|
if (!repo)
|
|
7311
|
-
throw new Error(
|
|
8645
|
+
throw new Error(NO_TRUST_ANCHOR_REPO_MESSAGE);
|
|
7312
8646
|
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
7313
8647
|
return stdout;
|
|
7314
8648
|
}
|
|
@@ -7334,6 +8668,47 @@ function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
|
7334
8668
|
}
|
|
7335
8669
|
return parseTrustAnchorContent(base64);
|
|
7336
8670
|
}
|
|
8671
|
+
class PrincipalsUnresolvedError extends Error {
|
|
8672
|
+
kind;
|
|
8673
|
+
constructor(kind, message) {
|
|
8674
|
+
super(message);
|
|
8675
|
+
this.name = "PrincipalsUnresolvedError";
|
|
8676
|
+
this.kind = kind;
|
|
8677
|
+
}
|
|
8678
|
+
}
|
|
8679
|
+
var PRINCIPALS_FIX = 'add "principals": [...] to vinaya.config.json on the default branch';
|
|
8680
|
+
function fetchFailureReason(err) {
|
|
8681
|
+
const stderr = err?.stderr;
|
|
8682
|
+
const text = (typeof stderr === "string" ? stderr : stderr?.toString() ?? "").trim();
|
|
8683
|
+
return text.split(`
|
|
8684
|
+
`)[0]?.trim() || firstLine(err);
|
|
8685
|
+
}
|
|
8686
|
+
function principalsNotConfigured(why) {
|
|
8687
|
+
return new PrincipalsUnresolvedError("not-configured", `no Principal is configured (${why}) — ${PRINCIPALS_FIX}.`);
|
|
8688
|
+
}
|
|
8689
|
+
function resolveTrustedPrincipals(fetcher = ghFetchTrustAnchorConfig) {
|
|
8690
|
+
let content;
|
|
8691
|
+
try {
|
|
8692
|
+
content = fetcher();
|
|
8693
|
+
} catch (err) {
|
|
8694
|
+
if (err?.message === NO_TRUST_ANCHOR_REPO_MESSAGE) {
|
|
8695
|
+
throw principalsNotConfigured("no repository resolves for the read");
|
|
8696
|
+
}
|
|
8697
|
+
if (isMissingFileError(err))
|
|
8698
|
+
throw principalsNotConfigured("the default branch has no vinaya.config.json");
|
|
8699
|
+
throw new PrincipalsUnresolvedError("read-failed", `could not read "principals" from vinaya.config.json on the default branch: ${fetchFailureReason(err)}`);
|
|
8700
|
+
}
|
|
8701
|
+
const unusable = { why: "" };
|
|
8702
|
+
const config = parseTrustAnchorContent(content, (why) => {
|
|
8703
|
+
unusable.why = why;
|
|
8704
|
+
});
|
|
8705
|
+
if (config === null) {
|
|
8706
|
+
throw principalsNotConfigured(`vinaya.config.json on the default branch ${unusable.why ? `is unusable: ${unusable.why}` : "is empty"}`);
|
|
8707
|
+
}
|
|
8708
|
+
if (!config.principals)
|
|
8709
|
+
throw principalsNotConfigured('vinaya.config.json on the default branch sets no "principals"');
|
|
8710
|
+
return config.principals;
|
|
8711
|
+
}
|
|
7337
8712
|
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
7338
8713
|
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
7339
8714
|
let base64;
|
|
@@ -7353,37 +8728,203 @@ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
|
7353
8728
|
warn(firstLine(err));
|
|
7354
8729
|
return null;
|
|
7355
8730
|
}
|
|
7356
|
-
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
7357
|
-
const base64 = content.trim();
|
|
7358
|
-
if (!base64)
|
|
8731
|
+
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
8732
|
+
const base64 = content.trim();
|
|
8733
|
+
if (!base64)
|
|
8734
|
+
return null;
|
|
8735
|
+
try {
|
|
8736
|
+
const raw = Buffer.from(base64, "base64").toString("utf-8");
|
|
8737
|
+
const parsed = VinayaConfigSchema.safeParse(JSON.parse(raw));
|
|
8738
|
+
if (parsed.success)
|
|
8739
|
+
return parsed.data;
|
|
8740
|
+
warn("it did not satisfy the config schema");
|
|
8741
|
+
return null;
|
|
8742
|
+
} catch {
|
|
8743
|
+
warn("it was not readable as JSON");
|
|
8744
|
+
return null;
|
|
8745
|
+
}
|
|
8746
|
+
}
|
|
8747
|
+
function loadConfig() {
|
|
8748
|
+
const path = configPath();
|
|
8749
|
+
if (!path)
|
|
8750
|
+
return null;
|
|
8751
|
+
let text;
|
|
8752
|
+
try {
|
|
8753
|
+
text = readFileSync2(path, "utf-8");
|
|
8754
|
+
} catch (err) {
|
|
8755
|
+
reportInvalidConfigOnce(path, `unreadable: ${err.message}`);
|
|
8756
|
+
return null;
|
|
8757
|
+
}
|
|
8758
|
+
let raw;
|
|
8759
|
+
try {
|
|
8760
|
+
raw = JSON.parse(text);
|
|
8761
|
+
} catch (err) {
|
|
8762
|
+
reportInvalidConfigOnce(path, `invalid JSON: ${err.message}`);
|
|
8763
|
+
return null;
|
|
8764
|
+
}
|
|
8765
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8766
|
+
if (!parsed.success) {
|
|
8767
|
+
reportInvalidConfigOnce(path, schemaIssueDetail(parsed.error));
|
|
8768
|
+
return null;
|
|
8769
|
+
}
|
|
8770
|
+
return stripGlobalOnlyKeys(parsed.data, path);
|
|
8771
|
+
}
|
|
8772
|
+
function schemaIssueDetail(error) {
|
|
8773
|
+
return error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
|
|
8774
|
+
}
|
|
8775
|
+
var emittedInvalidConfigReports = new Set;
|
|
8776
|
+
function reportInvalidConfigOnce(path, detail) {
|
|
8777
|
+
const key = `${path}
|
|
8778
|
+
${detail}`;
|
|
8779
|
+
if (emittedInvalidConfigReports.has(key))
|
|
8780
|
+
return;
|
|
8781
|
+
emittedInvalidConfigReports.add(key);
|
|
8782
|
+
const message = `${path} is not a valid Vinaya configuration (${detail}) — falling back to built-in defaults.`;
|
|
8783
|
+
const checkName = process.env.VINAYA_CHECK_NAME;
|
|
8784
|
+
if (checkName) {
|
|
8785
|
+
emitCheckError({
|
|
8786
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8787
|
+
check: checkName,
|
|
8788
|
+
severity: "warning",
|
|
8789
|
+
message,
|
|
8790
|
+
agent_recovery_prompt: `Fix the failing keys in ${path} (${detail}) so the file parses and satisfies the configuration schema, then re-run.`,
|
|
8791
|
+
file: path
|
|
8792
|
+
});
|
|
8793
|
+
return;
|
|
8794
|
+
}
|
|
8795
|
+
console.error(`⚠ ${message}`);
|
|
8796
|
+
}
|
|
8797
|
+
function loadConfigChecked() {
|
|
8798
|
+
const path = configPath();
|
|
8799
|
+
if (!path)
|
|
8800
|
+
return { ok: true, config: null };
|
|
8801
|
+
let raw;
|
|
8802
|
+
try {
|
|
8803
|
+
raw = JSON.parse(readFileSync2(path, "utf-8"));
|
|
8804
|
+
} catch (err) {
|
|
8805
|
+
return { ok: false, path, error: `invalid JSON: ${err.message}` };
|
|
8806
|
+
}
|
|
8807
|
+
const parsed = VinayaConfigSchema.safeParse(raw);
|
|
8808
|
+
if (!parsed.success) {
|
|
8809
|
+
return { ok: false, path, error: schemaIssueDetail(parsed.error) };
|
|
8810
|
+
}
|
|
8811
|
+
return { ok: true, config: stripGlobalOnlyKeys(parsed.data, path) };
|
|
8812
|
+
}
|
|
8813
|
+
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
8814
|
+
|
|
8815
|
+
// src/lib/forge-read.ts
|
|
8816
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
8817
|
+
|
|
8818
|
+
// src/lib/forge-snapshot.ts
|
|
8819
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
8820
|
+
import { join as join2 } from "node:path";
|
|
8821
|
+
var FORGE_SNAPSHOT_DIR_ENV = "VINAYA_FORGE_SNAPSHOT_DIR";
|
|
8822
|
+
var PULL_FILE = "pull.json";
|
|
8823
|
+
var PULL_COMMENTS_FILE = "pull-comments.json";
|
|
8824
|
+
var ISSUE_FILE = "issue.json";
|
|
8825
|
+
var ISSUE_COMMENTS_FILE = "issue-comments.json";
|
|
8826
|
+
function forgeSnapshotDir(env = process.env) {
|
|
8827
|
+
if (env.GITHUB_ACTIONS !== "true")
|
|
8828
|
+
return null;
|
|
8829
|
+
const dir = env[FORGE_SNAPSHOT_DIR_ENV];
|
|
8830
|
+
return dir ? dir : null;
|
|
8831
|
+
}
|
|
8832
|
+
|
|
8833
|
+
class ForgeSnapshotIncompleteError extends Error {
|
|
8834
|
+
constructor(dir, file) {
|
|
8835
|
+
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.`);
|
|
8836
|
+
this.name = "ForgeSnapshotIncompleteError";
|
|
8837
|
+
}
|
|
8838
|
+
}
|
|
8839
|
+
|
|
8840
|
+
class ForgeSnapshotIssueNotFoundError extends Error {
|
|
8841
|
+
constructor(issue) {
|
|
8842
|
+
super(`Issue #${issue} did not resolve (HTTP 404) when this run's forge snapshot was read.`);
|
|
8843
|
+
this.name = "ForgeSnapshotIssueNotFoundError";
|
|
8844
|
+
}
|
|
8845
|
+
}
|
|
8846
|
+
function readSnapshotFile(dir, file) {
|
|
8847
|
+
let text;
|
|
8848
|
+
try {
|
|
8849
|
+
text = readFileSync3(join2(dir, file), "utf8");
|
|
8850
|
+
} catch {
|
|
8851
|
+
throw new ForgeSnapshotIncompleteError(dir, file);
|
|
8852
|
+
}
|
|
8853
|
+
return JSON.parse(text);
|
|
8854
|
+
}
|
|
8855
|
+
function readComments(dir, file, number) {
|
|
8856
|
+
const parsed = readSnapshotFile(dir, file);
|
|
8857
|
+
if (parsed.number !== number)
|
|
8858
|
+
throw new ForgeSnapshotIncompleteError(dir, `${file} for #${number}`);
|
|
8859
|
+
return parsed.comments;
|
|
8860
|
+
}
|
|
8861
|
+
function snapshotPullRequest(number, env = process.env) {
|
|
8862
|
+
const dir = forgeSnapshotDir(env);
|
|
8863
|
+
if (dir === null)
|
|
7359
8864
|
return null;
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
8865
|
+
const pull = readSnapshotFile(dir, PULL_FILE);
|
|
8866
|
+
return pull.number === number ? pull : null;
|
|
8867
|
+
}
|
|
8868
|
+
function snapshotIssue(number, env = process.env) {
|
|
8869
|
+
const dir = forgeSnapshotDir(env);
|
|
8870
|
+
if (dir === null)
|
|
7366
8871
|
return null;
|
|
7367
|
-
|
|
7368
|
-
|
|
8872
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
8873
|
+
if (issue.number !== number)
|
|
7369
8874
|
return null;
|
|
7370
|
-
|
|
8875
|
+
if ("notFound" in issue)
|
|
8876
|
+
throw new ForgeSnapshotIssueNotFoundError(number);
|
|
8877
|
+
return issue;
|
|
7371
8878
|
}
|
|
7372
|
-
function
|
|
7373
|
-
const
|
|
7374
|
-
if (
|
|
8879
|
+
function snapshotComments(number, env = process.env) {
|
|
8880
|
+
const dir = forgeSnapshotDir(env);
|
|
8881
|
+
if (dir === null)
|
|
7375
8882
|
return null;
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
8883
|
+
if (snapshotPullRequest(number, env) !== null)
|
|
8884
|
+
return readComments(dir, PULL_COMMENTS_FILE, number);
|
|
8885
|
+
if (snapshotIssue(number, env) !== null)
|
|
8886
|
+
return readComments(dir, ISSUE_COMMENTS_FILE, number);
|
|
8887
|
+
return null;
|
|
8888
|
+
}
|
|
8889
|
+
function snapshotBody(number, env = process.env) {
|
|
8890
|
+
const pull = snapshotPullRequest(number, env);
|
|
8891
|
+
if (pull !== null)
|
|
8892
|
+
return pull.body;
|
|
8893
|
+
return snapshotIssue(number, env)?.body ?? null;
|
|
8894
|
+
}
|
|
8895
|
+
function incompleteForgeSnapshot(env = process.env) {
|
|
8896
|
+
const dir = forgeSnapshotDir(env);
|
|
8897
|
+
if (dir === null)
|
|
7380
8898
|
return null;
|
|
8899
|
+
for (const file of [PULL_FILE, PULL_COMMENTS_FILE, ISSUE_FILE]) {
|
|
8900
|
+
if (!existsSync2(join2(dir, file)))
|
|
8901
|
+
return new ForgeSnapshotIncompleteError(dir, file).message;
|
|
8902
|
+
}
|
|
8903
|
+
try {
|
|
8904
|
+
const issue = readSnapshotFile(dir, ISSUE_FILE);
|
|
8905
|
+
if (typeof issue.number === "number" && !("notFound" in issue) && !existsSync2(join2(dir, ISSUE_COMMENTS_FILE))) {
|
|
8906
|
+
return new ForgeSnapshotIncompleteError(dir, ISSUE_COMMENTS_FILE).message;
|
|
8907
|
+
}
|
|
8908
|
+
} catch (err) {
|
|
8909
|
+
return `the forge snapshot ${dir} has an unreadable ${ISSUE_FILE}: ${err.message}`;
|
|
7381
8910
|
}
|
|
8911
|
+
return null;
|
|
8912
|
+
}
|
|
8913
|
+
function exitOnIncompleteForgeSnapshot(checkName, env = process.env) {
|
|
8914
|
+
const reason = incompleteForgeSnapshot(env);
|
|
8915
|
+
if (reason === null)
|
|
8916
|
+
return;
|
|
8917
|
+
emitCheckError({
|
|
8918
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
8919
|
+
check: checkName,
|
|
8920
|
+
severity: "error",
|
|
8921
|
+
message: `${checkName}: ${reason}`,
|
|
8922
|
+
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.`
|
|
8923
|
+
});
|
|
8924
|
+
process.exit(1);
|
|
7382
8925
|
}
|
|
7383
|
-
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
7384
8926
|
|
|
7385
8927
|
// src/lib/forge-read.ts
|
|
7386
|
-
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
7387
8928
|
var FORGE_READ_CEILING_BYTES = 64 * 1024 * 1024;
|
|
7388
8929
|
var PAGE_SIZE = 100;
|
|
7389
8930
|
var ghRunner = (args, maxBuffer) => execFileSync3("gh", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], maxBuffer });
|
|
@@ -7406,7 +8947,7 @@ function isForgeReadOversize(err) {
|
|
|
7406
8947
|
function isBufferOverflow(err) {
|
|
7407
8948
|
return err?.code === "ENOBUFS";
|
|
7408
8949
|
}
|
|
7409
|
-
function
|
|
8950
|
+
function runBounded(runner, args, subject, usedBytes) {
|
|
7410
8951
|
const remaining = FORGE_READ_CEILING_BYTES - usedBytes;
|
|
7411
8952
|
let out;
|
|
7412
8953
|
try {
|
|
@@ -7421,31 +8962,40 @@ function run2(runner, args, subject, usedBytes) {
|
|
|
7421
8962
|
throw new ForgeReadOversizeError(subject, usedBytes + size);
|
|
7422
8963
|
return out;
|
|
7423
8964
|
}
|
|
7424
|
-
function
|
|
7425
|
-
const
|
|
7426
|
-
const comments = [];
|
|
8965
|
+
function readRestCommentRows(number, subjectLabel = `Issue ${number}`, runner = ghRunner) {
|
|
8966
|
+
const rows = [];
|
|
7427
8967
|
let used = 0;
|
|
7428
8968
|
for (let page = 1;; page++) {
|
|
7429
|
-
const out =
|
|
8969
|
+
const out = runBounded(runner, ["api", `repos/{owner}/{repo}/issues/${number}/comments?per_page=${PAGE_SIZE}&page=${page}`], subjectLabel, used);
|
|
7430
8970
|
used += Buffer.byteLength(out, "utf8");
|
|
7431
|
-
const
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
url: r.html_url ?? "",
|
|
7436
|
-
author: r.user?.login ? { login: r.user.login } : null
|
|
7437
|
-
});
|
|
7438
|
-
}
|
|
7439
|
-
if (rows.length < PAGE_SIZE)
|
|
7440
|
-
return comments;
|
|
8971
|
+
const pageRows = JSON.parse(out);
|
|
8972
|
+
rows.push(...pageRows);
|
|
8973
|
+
if (pageRows.length < PAGE_SIZE)
|
|
8974
|
+
return rows;
|
|
7441
8975
|
}
|
|
7442
8976
|
}
|
|
8977
|
+
function readIssueComments(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
8978
|
+
const number = resolveNumber(issue, subjectLabel, runner);
|
|
8979
|
+
const fromSnapshot = snapshotComments(number);
|
|
8980
|
+
if (fromSnapshot !== null)
|
|
8981
|
+
return fromSnapshot;
|
|
8982
|
+
return readRestCommentRows(number, subjectLabel, runner).map((r) => ({
|
|
8983
|
+
body: r.body ?? "",
|
|
8984
|
+
url: r.html_url ?? "",
|
|
8985
|
+
author: r.user?.login ? { login: r.user.login } : null
|
|
8986
|
+
}));
|
|
8987
|
+
}
|
|
7443
8988
|
function readIssueBody(issue, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
7444
|
-
|
|
8989
|
+
if (forgeSnapshotDir() !== null) {
|
|
8990
|
+
const fromSnapshot = snapshotBody(resolveNumber(issue, subjectLabel, runner));
|
|
8991
|
+
if (fromSnapshot !== null)
|
|
8992
|
+
return fromSnapshot;
|
|
8993
|
+
}
|
|
8994
|
+
const out = runBounded(runner, ["issue", "view", String(issue), "--json", "body"], subjectLabel, 0);
|
|
7445
8995
|
return JSON.parse(out).body ?? "";
|
|
7446
8996
|
}
|
|
7447
8997
|
function readIssueFields(issue, fields, subjectLabel = `Issue ${issue}`, runner = ghRunner) {
|
|
7448
|
-
return JSON.parse(
|
|
8998
|
+
return JSON.parse(runBounded(runner, ["issue", "view", String(issue), "--json", fields], subjectLabel, 0));
|
|
7449
8999
|
}
|
|
7450
9000
|
function resolveNumber(issue, subjectLabel, runner) {
|
|
7451
9001
|
if (typeof issue === "number")
|
|
@@ -7457,8 +9007,8 @@ function resolveNumber(issue, subjectLabel, runner) {
|
|
|
7457
9007
|
|
|
7458
9008
|
// src/lib/brief-assembly.ts
|
|
7459
9009
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
7460
|
-
import { existsSync as
|
|
7461
|
-
import { join as
|
|
9010
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, readdirSync as readdirSync2 } from "node:fs";
|
|
9011
|
+
import { join as join5 } from "node:path";
|
|
7462
9012
|
|
|
7463
9013
|
// ../../packages/sources/src/commands.ts
|
|
7464
9014
|
var COMMANDS = [
|
|
@@ -7574,6 +9124,16 @@ var COMMANDS = [
|
|
|
7574
9124
|
],
|
|
7575
9125
|
status: "shipped"
|
|
7576
9126
|
},
|
|
9127
|
+
{
|
|
9128
|
+
name: "new adr",
|
|
9129
|
+
needs: [],
|
|
9130
|
+
description: "Write the next numbered decision record into the folder decisionRecords.path names",
|
|
9131
|
+
details: [
|
|
9132
|
+
"`vinaya new adr <title>` writes `<decisionRecords.path>/NNNN-<kebab-title>.md` from the shipped decision-record template (`vinaya doctrine --template decision-record`), with status Proposed and today's date, and adds a row for it to the folder's `README.md` index page, creating that page on the first record. Numbers start at `0001` and are one past the highest number any file in the folder or any row of the index carries, so a number is never reused, even after its file is removed.",
|
|
9133
|
+
"Refuses, naming the key, while `decisionRecords.path` is unset: decision records are opt-in. The same key switches on the `decision-record-citation` writing rule — see `decisionRecords.path` in the configuration reference."
|
|
9134
|
+
],
|
|
9135
|
+
status: "shipped"
|
|
9136
|
+
},
|
|
7577
9137
|
{
|
|
7578
9138
|
name: "brief render",
|
|
7579
9139
|
needs: ["forge", "default-branch"],
|
|
@@ -7592,9 +9152,7 @@ var COMMANDS = [
|
|
|
7592
9152
|
name: "task dispatch",
|
|
7593
9153
|
needs: ["forge", "operator-seat"],
|
|
7594
9154
|
description: "Deprecated — render, pin, and post the brief on the Issue as the frozen original; start the developer",
|
|
7595
|
-
flags: [
|
|
7596
|
-
{ flag: "--agent <claude|codex|gemini>", description: "Start the developer through dispatchRole once posted" }
|
|
7597
|
-
],
|
|
9155
|
+
flags: [{ flag: "--agent <claude|codex>", description: "Start the developer through dispatchRole once posted" }],
|
|
7598
9156
|
details: [
|
|
7599
9157
|
"Renders the brief from the Issue and the tree (the same assembly `brief render` uses) and posts it once as an Issue comment whose first line is `<!-- aeg:brief:v1 -->` and whose second line is `Brief hash: <sha256>` — the hash covers only the body below those two lines, so any reader recomputes it. Refuses outright, naming the existing comment's URL, when a `v1` comment already exists on the Issue — the brief is frozen by design, never overwritten or silently reissued.",
|
|
7600
9158
|
"With `--agent`, starts the Developer through `dispatchRole` when `apps/cli/src/lib/dispatch.ts` exports it; otherwise prints the rendered brief and the manual dispatch instruction and exits `0` — a soft dependency, never a hard block.",
|
|
@@ -7619,7 +9177,11 @@ var COMMANDS = [
|
|
|
7619
9177
|
description: "One command from a planned Issue to a reviewed pull request — exactly one developer started",
|
|
7620
9178
|
flags: [
|
|
7621
9179
|
{
|
|
7622
|
-
flag: "--
|
|
9180
|
+
flag: "--runner <standalone|atta-engine>",
|
|
9181
|
+
description: "Override runner config for this invocation; absent uses config, whose default is standalone"
|
|
9182
|
+
},
|
|
9183
|
+
{
|
|
9184
|
+
flag: "--agent <claude|codex>",
|
|
7623
9185
|
description: "Vendor for the developer and both reviewers this run dispatches"
|
|
7624
9186
|
},
|
|
7625
9187
|
{
|
|
@@ -7629,17 +9191,39 @@ var COMMANDS = [
|
|
|
7629
9191
|
{
|
|
7630
9192
|
flag: "--widen-surface <glob,...> --reason <text>",
|
|
7631
9193
|
description: "Continue a pre-pull-request escalation whose Developer asked for `widen_surface`: supersede the frozen brief with the globs added to `## Surface`, record that as the escalation's resolution, grade the widened Issue through the write gate, then start the run"
|
|
9194
|
+
},
|
|
9195
|
+
{
|
|
9196
|
+
flag: "--rollback",
|
|
9197
|
+
description: "Run the terminate-and-restart procedure for this task: cancel its in-flight Engine run, reconcile every prepared and uncertain effect by its identity, then start a fresh standalone run from the same frozen brief. Refuses a task whose recorded runner is not `atta-engine`"
|
|
7632
9198
|
}
|
|
7633
9199
|
],
|
|
7634
9200
|
details: [
|
|
9201
|
+
"The atta-engine runner starts the workspace Engine script with Bun, streams its output and returns its exit code. A published install without the script prints one notice and falls back to standalone. Engine Log events use the local folder only; logs: false disables all Log destinations for both runners.",
|
|
9202
|
+
"A run's runner is recorded when it starts and never changes: switching `runner` in config changes only the runner of new runs, and a run recorded on `atta-engine` keeps routing to the Engine for `task status`, `task_resume` and `task_cancel`. A start on a pause another runner holds is refused with a typed reason naming the recorded runner and the requested one, and so is a start on another runner's Engine run that is still in flight with no pause held — halted or stopped short of completed or cancelled.",
|
|
9203
|
+
"`--rollback` ends the Engine run first: a held pause through the shared cancel `task_cancel` uses, which needs a Principal ruling newer than the pause as any cancel does; a run halted with no pause held has its started effects fenced; a run that already completed or was cancelled is refused, as is a driver still running with no pause held, which is never signalled; and the standalone run never starts while the Engine driver lives, a cancelled run's driver given a bounded wait to release its lock. Every started and uncertain effect is then reconciled by its identity: one the forge carries is recorded verified, one it does not carry is left for the restarted run to complete, and one the forge read cannot settle refuses the restart. Each rehearsal appends a record — task, recorded runner, action, reconciled effect identities, the restarted run's runner and terminal state — to `backend-rollback-rehearsals.jsonl` in the task's runtime directory, whether it completed, was refused or failed at a later step, and nothing removes it.",
|
|
7635
9204
|
"`--widen-surface` is the Planner's one command for a widen-surface escalation, and refuses before any write when the held pause is not one (no pause, a pause with a pull request — whose continuation is the ruling on that pull request — or a round whose Developer asked for no `widen_surface`), when a driver is still alive for the task, when the escalation's resolution is already consumed (a replay — the Surface is never widened twice), or when the widened body fails the write gate, whose findings name the field to edit first. The escalation packet's permitted next actions name this command with the globs the Developer asked for, and `task_resume` refuses such an escalation naming it.",
|
|
7636
|
-
"
|
|
9205
|
+
"Prepares the frozen brief and resolves the task, branch and model once. The standalone runner then starts the watching driver (`runDriverLoop`, `dev-review-loop.ts`). Preparation starts no agent; the loop's own round 1 reads the frozen brief off the Issue and is the only place a developer is ever dispatched from a fresh task, so exactly one developer is started by construction.",
|
|
7637
9206
|
"A brief already frozen on the Issue is reused, never re-posted — the second `task dispatch`/`task brief` call this composes around does not fail the whole run, it just skips straight to running the loop. A task whose Issue refuses preparation (a missing brief section, an unmet dispatch gate) is refused before any agent starts, with nothing posted.",
|
|
7638
9207
|
"Refuses when the frozen brief's developer branch already has an open pull request AND a driver is still live for it — a driver that crashed or was killed leaves its PR behind, and this command is the one that revives it, in any state, pause held or not.",
|
|
7639
9208
|
"issue-711 O4: a pause never ends this process — it keeps running and watches the pull request, continuing on its own once a newer Principal ruling appears (or, for an `'infrastructure'`/`'stale_driver'` pause, after a bounded backoff), with no `--resume` command needed for the ordinary case. Exit and printed summary distinguish a published pull request OR a watched pause's own genuine end — merged, closed, or an operator's own `--cancel` (exit `0` either way, the PR URL) — from the one pause this process can never watch (no pull request exists yet — exit `1`, with the working `vinaya task run` command for this task's own branch to continue by hand — `<tranche> <n>` for a tranche task, `--issue <n>` for a backlog one — never a `dev-review-loop --resume` line naming a pull-request number this pause does not have), a usage/argv error (exit `2`), and any other failure (exit `3`)."
|
|
7640
9209
|
],
|
|
7641
9210
|
status: "shipped"
|
|
7642
9211
|
},
|
|
9212
|
+
{
|
|
9213
|
+
name: "task switch",
|
|
9214
|
+
needs: ["forge"],
|
|
9215
|
+
description: "Change a task's agent or model by setting its Engine checkpoint aside, so the next `task run` is accepted",
|
|
9216
|
+
flags: [
|
|
9217
|
+
{ flag: "--issue <n>", description: "Address the task by its Issue number instead of `<tranche> <n>`" },
|
|
9218
|
+
{ flag: "--agent <claude|codex>", description: "Vendor the next `task run` of the task continues on" },
|
|
9219
|
+
{ flag: "--model <model>", description: "Model the next `task run` is meant to use; absent, the vendor default" }
|
|
9220
|
+
],
|
|
9221
|
+
details: [
|
|
9222
|
+
"Refuses, changing nothing, while a driver for the task is alive, naming its pid. Otherwise moves the task's Engine checkpoint (`checkpoints.sqlite` with its `-wal` and `-shm` files) into a timestamped `switched-*` folder of the task's run directory and never deletes it; the branch, its commits and its pull request are untouched, so the next `task run` with the new agent continues the same branch on a fresh checkpoint.",
|
|
9223
|
+
"Writes one driver-log line naming the from and to agent, the from and to model and the folder the checkpoint went to. On the standalone runner it changes nothing on disk and says that runner already continues a task on a new `--agent` by itself. `task run` and `run-engine --resume` still refuse an agent other than the checkpoint's, and their refusal names this command."
|
|
9224
|
+
],
|
|
9225
|
+
status: "shipped"
|
|
9226
|
+
},
|
|
7643
9227
|
{
|
|
7644
9228
|
name: "task status",
|
|
7645
9229
|
needs: ["forge"],
|
|
@@ -7794,6 +9378,22 @@ var COMMANDS = [
|
|
|
7794
9378
|
],
|
|
7795
9379
|
status: "shipped"
|
|
7796
9380
|
},
|
|
9381
|
+
{
|
|
9382
|
+
name: "pr snapshot",
|
|
9383
|
+
needs: ["forge"],
|
|
9384
|
+
description: "CI plumbing: write a run's forge snapshot of the pull request and its task Issue, read over REST",
|
|
9385
|
+
flags: [
|
|
9386
|
+
{
|
|
9387
|
+
flag: "--dir",
|
|
9388
|
+
description: "The snapshot directory; its `raw/` holds the REST pull request and comment pages the read step wrote"
|
|
9389
|
+
}
|
|
9390
|
+
],
|
|
9391
|
+
details: [
|
|
9392
|
+
"Run by the generated workflows' read step, never by hand. Maps the REST pull request and its comments to the shape `gh pr view --json` prints, resolves the task Issue from the body's `Closes #N`, and reads that Issue and its comments over REST — never GraphQL.",
|
|
9393
|
+
"A check reads the snapshot only when `GITHUB_ACTIONS` is `true` and the step running it sets `VINAYA_FORGE_SNAPSHOT_DIR`; anywhere else every read goes to the forge as before. Exits 1, naming what it could not read and both token budgets, on a failed read; 2 on a usage error."
|
|
9394
|
+
],
|
|
9395
|
+
status: "shipped"
|
|
9396
|
+
},
|
|
7797
9397
|
{
|
|
7798
9398
|
name: "issue create",
|
|
7799
9399
|
needs: ["forge"],
|
|
@@ -7914,14 +9514,14 @@ var COMMANDS = [
|
|
|
7914
9514
|
{
|
|
7915
9515
|
name: "milestone close",
|
|
7916
9516
|
needs: ["forge"],
|
|
7917
|
-
description: "Close a tranche's Milestone after verifying every labeled Issue is
|
|
9517
|
+
description: "Close a tranche's Milestone after verifying every labeled Issue is attached and every tranche it declares is complete",
|
|
7918
9518
|
flags: [
|
|
7919
9519
|
{ flag: "--slug", description: "The tranche whose Milestone is being closed" },
|
|
7920
9520
|
{ flag: "--validate-only", description: "Run every gate and report PASS without closing the Milestone" },
|
|
7921
9521
|
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
7922
9522
|
],
|
|
7923
9523
|
details: [
|
|
7924
|
-
"Resolves the target Milestone the same legacy-or-intent-declared way Issue create auto-attach does, then refuses to close on any mismatch between the label's Issues and the Milestone's natively attached Issues — naming each unattached or foreign Issue and its repair path (`gh issue edit <n> --milestone <title>`, or `vinaya milestone adopt`) — before the PATCH ever reaches the forge."
|
|
9524
|
+
"Resolves the target Milestone the same legacy-or-intent-declared way Issue create auto-attach does, then refuses to close on any mismatch between the label's Issues and the Milestone's natively attached Issues — naming each unattached or foreign Issue and its repair path (`gh issue edit <n> --milestone <title>`, or `vinaya milestone adopt`) — before the PATCH ever reaches the forge. It also holds the Milestone open while a tranche its `### Tranche intents` section declares is not complete — naming each unfinished tranche and its lifecycle — or while that section carries no readable tranche line; a Milestone with no such section closes on attachment alone. `--validate-only` refuses with the same reasons."
|
|
7925
9525
|
],
|
|
7926
9526
|
status: "shipped"
|
|
7927
9527
|
},
|
|
@@ -8210,7 +9810,7 @@ var COMMANDS = [
|
|
|
8210
9810
|
}
|
|
8211
9811
|
],
|
|
8212
9812
|
details: [
|
|
8213
|
-
"Refuses unless HEAD is the default branch, the working tree is clean, HEAD equals `origin/<default>` (after `git fetch origin`), HEAD's commit subject starts with `Chore(release): Version packages` (unless `--allow-any-commit`), and `npm whoami` exits `0`
|
|
9813
|
+
"Refuses unless HEAD is the default branch, the working tree is clean, HEAD equals `origin/<default>` (after `git fetch origin`), HEAD's commit subject starts with `Chore(release): Version packages` (unless `--allow-any-commit`), and `npm whoami` exits `0`. Before any plan step, including under `--dry-run`, every package in `.changeset/config.json` fixed groups must have an unpublished working-tree version. Exact-version registry queries refuse with every already-published package and version; workspace read failures and registry errors other than E404 also refuse with their reason. E404 for a missing package or version counts as unpublished.",
|
|
8214
9814
|
"Then streams `bun install --frozen-lockfile`, `bun run build`, `bun run changeset:publish`, and `git push origin --tags` — a real push, so the repo's own generated pre-push hook sees it exactly as any other push would. After it, prints `npm view <pkg> version` for every tag now on HEAD, noting registry lag on `@attalabs/vinaya` (observed ~20 minutes) when it still shows the previous version.",
|
|
8215
9815
|
'This is the one procedure named in `apps/cli/specs/self-hosting.md`, "How the published version is produced" — publishing itself stays manual and human-triggered; this command only removes the hand-typed four-step recipe.'
|
|
8216
9816
|
],
|
|
@@ -8219,11 +9819,11 @@ var COMMANDS = [
|
|
|
8219
9819
|
{
|
|
8220
9820
|
name: "dispatch",
|
|
8221
9821
|
needs: ["operator-seat"],
|
|
8222
|
-
description: "Start a role's headless agent session (claude/codex
|
|
9822
|
+
description: "Start a role's headless agent session (claude/codex) with attribution set on its environment, recording the outcome through the Vinaya Log",
|
|
8223
9823
|
flags: [
|
|
8224
9824
|
{
|
|
8225
9825
|
flag: "--agent",
|
|
8226
|
-
description: "Vendor to start: `claude
|
|
9826
|
+
description: "Vendor to start: `claude` or `codex` (falls back to `dispatch.agent` in config)"
|
|
8227
9827
|
},
|
|
8228
9828
|
{ flag: "--prompt-file", description: "Path to the prompt text sent to the agent (never on argv)" },
|
|
8229
9829
|
{ flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
|
|
@@ -8240,9 +9840,9 @@ var COMMANDS = [
|
|
|
8240
9840
|
],
|
|
8241
9841
|
details: [
|
|
8242
9842
|
"Sets `VINAYA_RUN_ID`/`VINAYA_ROLE`/`VINAYA_TASK`/`VINAYA_ROUND` on the child only — never on this process's own environment — and refuses by name, before any spawn attempt, when the named vendor binary is absent from `PATH` or present but not executable.",
|
|
8243
|
-
"Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, or `
|
|
9843
|
+
"Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, `refused`, or `usage_limit`) through the Vinaya Log's one `dispatch` family writer, `dispatchRole`. A wall-time ceiling (`dispatch.timeoutMs` in config, default one hour) sends `SIGTERM` then, after a grace window, `SIGKILL`.",
|
|
8244
9844
|
"Runs no flush of its own after the dispatch returns: every log line `dispatchRole` emits reaches its configured `logs` destination live, as it is emitted, so there is nothing left to ship in a trailing step. `--task`/`--pr` are attribution only, and remain mutually exclusive.",
|
|
8245
|
-
"A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude
|
|
9845
|
+
"A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude: `session_id`; codex: `thread_id`), parsed from its stdout, `null` on any failure. Passing that value as `--resume <id>` on a later call swaps in that vendor's own resume invocation (`claude -p -r <id> ...`; `codex exec resume <id> ...`) in place of its first-dispatch args."
|
|
8246
9846
|
],
|
|
8247
9847
|
status: "shipped"
|
|
8248
9848
|
},
|
|
@@ -8253,7 +9853,7 @@ var COMMANDS = [
|
|
|
8253
9853
|
flags: [
|
|
8254
9854
|
{ flag: "--task <n>", description: "This task's Issue number — its frozen `aeg:brief:v1` comment is the brief" },
|
|
8255
9855
|
{
|
|
8256
|
-
flag: "--agent <claude|codex
|
|
9856
|
+
flag: "--agent <claude|codex>",
|
|
8257
9857
|
description: "Vendor for every dispatch this loop makes (falls back to `dispatch.agent` in config)"
|
|
8258
9858
|
},
|
|
8259
9859
|
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
@@ -8332,22 +9932,78 @@ function createForgeSource(config) {
|
|
|
8332
9932
|
};
|
|
8333
9933
|
}
|
|
8334
9934
|
// ../../packages/sources/src/select-source.ts
|
|
8335
|
-
import { z as
|
|
8336
|
-
var StateSourceConfigSchema =
|
|
8337
|
-
|
|
8338
|
-
|
|
9935
|
+
import { z as z7 } from "zod";
|
|
9936
|
+
var StateSourceConfigSchema = z7.discriminatedUnion("kind", [
|
|
9937
|
+
z7.object({ kind: z7.literal("forge"), owner: z7.string(), repo: z7.string() }),
|
|
9938
|
+
z7.object({ kind: z7.literal("file"), root: z7.string().optional() })
|
|
8339
9939
|
]);
|
|
8340
9940
|
// src/checks/edge-resolve.ts
|
|
9941
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
9942
|
+
import { promisify as promisify5 } from "node:util";
|
|
9943
|
+
|
|
9944
|
+
// src/lib/github-rate-limit.ts
|
|
8341
9945
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
9946
|
+
var GITHUB_RATE_LIMIT_WORDING = /api rate limit (?:already )?exceeded|secondary rate limit|rate limit exceeded/i;
|
|
9947
|
+
var SECONDARY_RATE_LIMIT_WORDING = /secondary rate limit/i;
|
|
9948
|
+
function isGithubRateLimitError(text) {
|
|
9949
|
+
return GITHUB_RATE_LIMIT_WORDING.test(text);
|
|
9950
|
+
}
|
|
9951
|
+
function rateLimitBudget(errorText) {
|
|
9952
|
+
return errorText.trimStart().startsWith("GraphQL:") ? "GraphQL" : "REST";
|
|
9953
|
+
}
|
|
9954
|
+
var defaultReader = () => execFileSync4("gh", ["api", "rate_limit"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
9955
|
+
function readRateLimitReset(budget, read = defaultReader) {
|
|
9956
|
+
let parsed;
|
|
9957
|
+
try {
|
|
9958
|
+
parsed = JSON.parse(read());
|
|
9959
|
+
} catch {
|
|
9960
|
+
return null;
|
|
9961
|
+
}
|
|
9962
|
+
const resources = parsed.resources;
|
|
9963
|
+
const entry = resources?.[budget === "GraphQL" ? "graphql" : "core"];
|
|
9964
|
+
if (!entry || typeof entry.reset !== "number" || !Number.isFinite(entry.reset) || entry.reset <= 0)
|
|
9965
|
+
return null;
|
|
9966
|
+
if (typeof entry.remaining === "number" && entry.remaining > 0)
|
|
9967
|
+
return null;
|
|
9968
|
+
return entry.reset;
|
|
9969
|
+
}
|
|
9970
|
+
function formatResetUtc(epochSeconds) {
|
|
9971
|
+
const d = new Date(epochSeconds * 1000);
|
|
9972
|
+
const hh = String(d.getUTCHours()).padStart(2, "0");
|
|
9973
|
+
const mm = String(d.getUTCMinutes()).padStart(2, "0");
|
|
9974
|
+
return `${hh}:${mm} UTC`;
|
|
9975
|
+
}
|
|
9976
|
+
function rateLimitMessage(errorText, read = defaultReader) {
|
|
9977
|
+
const budget = rateLimitBudget(errorText);
|
|
9978
|
+
const reset = SECONDARY_RATE_LIMIT_WORDING.test(errorText) ? null : readRateLimitReset(budget, read);
|
|
9979
|
+
const when = reset === null ? "resets in a few minutes" : `resets at ${formatResetUtc(reset)}`;
|
|
9980
|
+
return `GitHub rate limit (${budget}), ${when}`;
|
|
9981
|
+
}
|
|
9982
|
+
function execErrorText(err) {
|
|
9983
|
+
const e = err;
|
|
9984
|
+
const stderr = e?.stderr === undefined || e.stderr === null ? "" : String(e.stderr);
|
|
9985
|
+
const message = typeof e?.message === "string" ? e.message : "";
|
|
9986
|
+
return stderr.trim() !== "" ? `${stderr}
|
|
9987
|
+
${message}` : message;
|
|
9988
|
+
}
|
|
9989
|
+
|
|
9990
|
+
// src/checks/edge-resolve.ts
|
|
8342
9991
|
var DIRECT_ISSUE_REF = /#(\d+)/;
|
|
8343
9992
|
var issueCache = new Map;
|
|
9993
|
+
var execFileAsync5 = promisify5(execFile5);
|
|
9994
|
+
var ISSUE_NOT_FOUND = /could not resolve to an issue/i;
|
|
8344
9995
|
function fetchIssueState(num, repo) {
|
|
8345
9996
|
const key = `${repo.owner}/${repo.repo}#${num}`;
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
9997
|
+
const cached = issueCache.get(key);
|
|
9998
|
+
if (cached)
|
|
9999
|
+
return cached;
|
|
10000
|
+
const out = readIssueOnce(num, repo).then((first) => first.readFailed ? readIssueOnce(num, repo) : first);
|
|
10001
|
+
issueCache.set(key, out);
|
|
10002
|
+
return out;
|
|
10003
|
+
}
|
|
10004
|
+
async function readIssueOnce(num, repo) {
|
|
8349
10005
|
try {
|
|
8350
|
-
const
|
|
10006
|
+
const { stdout } = await execFileAsync5("gh", [
|
|
8351
10007
|
"issue",
|
|
8352
10008
|
"view",
|
|
8353
10009
|
String(num),
|
|
@@ -8355,13 +10011,11 @@ function fetchIssueState(num, repo) {
|
|
|
8355
10011
|
`${repo.owner}/${repo.repo}`,
|
|
8356
10012
|
"--json",
|
|
8357
10013
|
"state,stateReason,closedByPullRequestsReferences"
|
|
8358
|
-
], { encoding: "utf8"
|
|
8359
|
-
|
|
8360
|
-
} catch {
|
|
8361
|
-
|
|
10014
|
+
], { encoding: "utf8" });
|
|
10015
|
+
return { json: JSON.parse(stdout), readFailed: false };
|
|
10016
|
+
} catch (err) {
|
|
10017
|
+
return { json: null, readFailed: !ISSUE_NOT_FOUND.test(execErrorText(err)) };
|
|
8362
10018
|
}
|
|
8363
|
-
issueCache.set(key, out);
|
|
8364
|
-
return out;
|
|
8365
10019
|
}
|
|
8366
10020
|
var defaultResolveSiblingTranche = async (slug, repo) => {
|
|
8367
10021
|
let tranche;
|
|
@@ -8378,7 +10032,7 @@ var defaultResolveSiblingTranche = async (slug, repo) => {
|
|
|
8378
10032
|
};
|
|
8379
10033
|
};
|
|
8380
10034
|
var siblingTrancheCache = new Map;
|
|
8381
|
-
function edgeFromIssueJson(num, json) {
|
|
10035
|
+
function edgeFromIssueJson(num, json, readFailed = false) {
|
|
8382
10036
|
if (json === null) {
|
|
8383
10037
|
return {
|
|
8384
10038
|
issue: num,
|
|
@@ -8387,7 +10041,8 @@ function edgeFromIssueJson(num, json) {
|
|
|
8387
10041
|
issueState: null,
|
|
8388
10042
|
stateReason: null,
|
|
8389
10043
|
closedByActor: null,
|
|
8390
|
-
resolved: true
|
|
10044
|
+
resolved: true,
|
|
10045
|
+
...readFailed ? { readFailed: true } : {}
|
|
8391
10046
|
};
|
|
8392
10047
|
}
|
|
8393
10048
|
const state = json.state === "CLOSED" ? "closed" : json.state === "OPEN" ? "open" : null;
|
|
@@ -8420,7 +10075,8 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
8420
10075
|
const direct = id.match(DIRECT_ISSUE_REF);
|
|
8421
10076
|
if (direct) {
|
|
8422
10077
|
const num = Number(direct[1]);
|
|
8423
|
-
|
|
10078
|
+
const read = await fetchIssueState(num, repo);
|
|
10079
|
+
return edgeFromIssueJson(num, read.json, read.readFailed);
|
|
8424
10080
|
}
|
|
8425
10081
|
const qualified = splitSlugQualifiedEdge(id);
|
|
8426
10082
|
if (qualified) {
|
|
@@ -8454,15 +10110,27 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
8454
10110
|
resolved: false
|
|
8455
10111
|
};
|
|
8456
10112
|
}
|
|
10113
|
+
function dependsOnFactFromEdge(id, r) {
|
|
10114
|
+
return {
|
|
10115
|
+
id,
|
|
10116
|
+
issue: r.issue,
|
|
10117
|
+
merged: r.merged,
|
|
10118
|
+
resolved: r.resolved,
|
|
10119
|
+
issueState: r.issueState,
|
|
10120
|
+
stateReason: r.stateReason,
|
|
10121
|
+
closedByActor: r.closedByActor,
|
|
10122
|
+
...r.readFailed ? { readFailed: true } : {}
|
|
10123
|
+
};
|
|
10124
|
+
}
|
|
8457
10125
|
|
|
8458
10126
|
// src/lib/package-root.ts
|
|
8459
|
-
import { existsSync as
|
|
8460
|
-
import { dirname as dirname2, join as
|
|
10127
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
10128
|
+
import { dirname as dirname2, join as join3 } from "node:path";
|
|
8461
10129
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8462
10130
|
function packageRoot(moduleUrl) {
|
|
8463
10131
|
let dir = dirname2(fileURLToPath2(moduleUrl));
|
|
8464
|
-
while (!
|
|
8465
|
-
if (
|
|
10132
|
+
while (!existsSync3(join3(dir, "package.json"))) {
|
|
10133
|
+
if (existsSync3(join3(dir, ".git")))
|
|
8466
10134
|
break;
|
|
8467
10135
|
const parent = dirname2(dir);
|
|
8468
10136
|
if (parent === dir)
|
|
@@ -8474,14 +10142,21 @@ function packageRoot(moduleUrl) {
|
|
|
8474
10142
|
|
|
8475
10143
|
// src/commands/doctrine.ts
|
|
8476
10144
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
8477
|
-
import { existsSync as
|
|
8478
|
-
import { dirname as dirname3, join as
|
|
10145
|
+
import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync4 } from "node:fs";
|
|
10146
|
+
import { dirname as dirname3, join as join4, sep } from "node:path";
|
|
8479
10147
|
import matter4 from "gray-matter";
|
|
8480
10148
|
|
|
8481
10149
|
// ../../packages/aeg-core/src/docs/parse-doc.ts
|
|
8482
10150
|
import matter2 from "gray-matter";
|
|
8483
10151
|
// ../../packages/aeg-core/src/docs/surfaced-manifest.ts
|
|
8484
10152
|
var NO_MODEL_BACKED_PATHS = new Set;
|
|
10153
|
+
// ../../packages/aeg-core/src/docs/published-prose.ts
|
|
10154
|
+
var ALLOWED_MECHANICS = rulesForGroup("published-prose")[0]?.exemptions ?? [];
|
|
10155
|
+
var PROSE_RULES = rulesForGroup("published-prose").map((rule) => ({
|
|
10156
|
+
id: rule.id,
|
|
10157
|
+
what: rule.message,
|
|
10158
|
+
pattern: rule.patterns.published
|
|
10159
|
+
}));
|
|
8485
10160
|
// src/roles/contract.ts
|
|
8486
10161
|
import matter3 from "gray-matter";
|
|
8487
10162
|
|
|
@@ -8503,22 +10178,22 @@ function gitToplevel(cwd) {
|
|
|
8503
10178
|
function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
|
|
8504
10179
|
const toplevel = gitToplevel(cwd);
|
|
8505
10180
|
if (toplevel !== null) {
|
|
8506
|
-
const treeRoot =
|
|
8507
|
-
if (
|
|
10181
|
+
const treeRoot = join4(toplevel, "aeg-root");
|
|
10182
|
+
if (existsSync4(join4(treeRoot, "roles")))
|
|
8508
10183
|
return { root: treeRoot, source: "tree" };
|
|
8509
10184
|
}
|
|
8510
10185
|
const fromSource = !pkg.split(sep).includes("node_modules");
|
|
8511
|
-
const bundleRoot = fromSource ?
|
|
10186
|
+
const bundleRoot = fromSource ? join4(dirname3(dirname3(pkg)), "aeg-root") : join4(pkg, "aeg-root");
|
|
8512
10187
|
return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
|
|
8513
10188
|
}
|
|
8514
10189
|
function hasDoctrineEntry(root) {
|
|
8515
|
-
return
|
|
10190
|
+
return existsSync4(join4(root, ...ENTRY_SEGMENTS));
|
|
8516
10191
|
}
|
|
8517
10192
|
|
|
8518
10193
|
// src/lib/brief-assembly.ts
|
|
8519
10194
|
var PACKAGE_ROOT = packageRoot(import.meta.url);
|
|
8520
|
-
var PACKAGED_TEMPLATE_PATH =
|
|
8521
|
-
var TEMPLATE_PATH =
|
|
10195
|
+
var PACKAGED_TEMPLATE_PATH = join5(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
|
|
10196
|
+
var TEMPLATE_PATH = existsSync5(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join5(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
8522
10197
|
function git(args) {
|
|
8523
10198
|
try {
|
|
8524
10199
|
return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
@@ -8534,24 +10209,25 @@ function expandGlob(glob) {
|
|
|
8534
10209
|
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
8535
10210
|
|
|
8536
10211
|
// src/checks/registry.ts
|
|
8537
|
-
import { join as
|
|
10212
|
+
import { join as join6, relative, sep as sep2 } from "node:path";
|
|
8538
10213
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
8539
10214
|
function resolveCheckBin(packageDir, moduleUrl) {
|
|
8540
10215
|
const fromPackage = relative(packageDir, fileURLToPath3(moduleUrl));
|
|
8541
10216
|
const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep2}`);
|
|
8542
|
-
return bundled ? { dir:
|
|
10217
|
+
return bundled ? { dir: join6(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join6(packageDir, "src", "checks", "bin"), ext: ".ts" };
|
|
8543
10218
|
}
|
|
8544
10219
|
var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
|
|
8545
10220
|
var BIN_DIR = CHECK_BIN.dir;
|
|
8546
10221
|
var BIN_EXT = CHECK_BIN.ext;
|
|
8547
10222
|
function bin(name) {
|
|
8548
|
-
return
|
|
10223
|
+
return join6(BIN_DIR, `${name}${BIN_EXT}`);
|
|
8549
10224
|
}
|
|
8550
10225
|
var REGISTRY = [
|
|
8551
10226
|
[
|
|
8552
10227
|
{
|
|
8553
10228
|
name: "brief-shape",
|
|
8554
10229
|
validates: "body",
|
|
10230
|
+
requiresOpenPr: true,
|
|
8555
10231
|
run: bin("check-brief-shape"),
|
|
8556
10232
|
scope: "diff",
|
|
8557
10233
|
timeoutMs: 15000,
|
|
@@ -8560,7 +10236,9 @@ var REGISTRY = [
|
|
|
8560
10236
|
BRANCH: { optional: true },
|
|
8561
10237
|
PR_NUMBER: { optional: true },
|
|
8562
10238
|
GITHUB_TOKEN: { optional: true },
|
|
8563
|
-
GH_TOKEN: { optional: true }
|
|
10239
|
+
GH_TOKEN: { optional: true },
|
|
10240
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10241
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8564
10242
|
}
|
|
8565
10243
|
},
|
|
8566
10244
|
0
|
|
@@ -8569,6 +10247,7 @@ var REGISTRY = [
|
|
|
8569
10247
|
{
|
|
8570
10248
|
name: "pr-report-density",
|
|
8571
10249
|
validates: "body",
|
|
10250
|
+
requiresOpenPr: true,
|
|
8572
10251
|
run: bin("check-pr-report-density"),
|
|
8573
10252
|
scope: "diff",
|
|
8574
10253
|
timeoutMs: 15000,
|
|
@@ -8594,7 +10273,9 @@ var REGISTRY = [
|
|
|
8594
10273
|
PR_NUMBER: { optional: true },
|
|
8595
10274
|
GITHUB_REPOSITORY: { optional: true },
|
|
8596
10275
|
GITHUB_TOKEN: { optional: true },
|
|
8597
|
-
GH_TOKEN: { optional: true }
|
|
10276
|
+
GH_TOKEN: { optional: true },
|
|
10277
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10278
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8598
10279
|
}
|
|
8599
10280
|
},
|
|
8600
10281
|
0
|
|
@@ -8618,6 +10299,7 @@ var REGISTRY = [
|
|
|
8618
10299
|
{
|
|
8619
10300
|
name: "pr-premise-reassert",
|
|
8620
10301
|
validates: "body",
|
|
10302
|
+
requiresOpenPr: true,
|
|
8621
10303
|
run: bin("check-pr-premise-reassert"),
|
|
8622
10304
|
scope: "diff",
|
|
8623
10305
|
timeoutMs: 15000,
|
|
@@ -8638,7 +10320,9 @@ var REGISTRY = [
|
|
|
8638
10320
|
BRANCH: { optional: true },
|
|
8639
10321
|
GITHUB_TOKEN: { optional: true },
|
|
8640
10322
|
GH_TOKEN: { optional: true },
|
|
8641
|
-
PREMISE_FILE: { optional: true }
|
|
10323
|
+
PREMISE_FILE: { optional: true },
|
|
10324
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10325
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8642
10326
|
}
|
|
8643
10327
|
},
|
|
8644
10328
|
0
|
|
@@ -8690,7 +10374,9 @@ var REGISTRY = [
|
|
|
8690
10374
|
PR_BODY: { optional: true },
|
|
8691
10375
|
PR_BODY_FILE: { optional: true },
|
|
8692
10376
|
GITHUB_TOKEN: { optional: true },
|
|
8693
|
-
GH_TOKEN: { optional: true }
|
|
10377
|
+
GH_TOKEN: { optional: true },
|
|
10378
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10379
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8694
10380
|
}
|
|
8695
10381
|
},
|
|
8696
10382
|
1
|
|
@@ -8706,7 +10392,13 @@ var REGISTRY = [
|
|
|
8706
10392
|
principalOwed: true,
|
|
8707
10393
|
env: {
|
|
8708
10394
|
PR_BODY: { optional: true },
|
|
8709
|
-
BRANCH: { optional: true }
|
|
10395
|
+
BRANCH: { optional: true },
|
|
10396
|
+
PULL_REQUEST_HEAD_SHA: { optional: true },
|
|
10397
|
+
GITHUB_REPOSITORY: { optional: true },
|
|
10398
|
+
GITHUB_TOKEN: { optional: true },
|
|
10399
|
+
GH_TOKEN: { optional: true },
|
|
10400
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10401
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8710
10402
|
}
|
|
8711
10403
|
},
|
|
8712
10404
|
1
|
|
@@ -8722,7 +10414,13 @@ var REGISTRY = [
|
|
|
8722
10414
|
ownWorkflow: true,
|
|
8723
10415
|
env: {
|
|
8724
10416
|
PR_BODY: { optional: true },
|
|
8725
|
-
BRANCH: { optional: true }
|
|
10417
|
+
BRANCH: { optional: true },
|
|
10418
|
+
PULL_REQUEST_HEAD_SHA: { optional: true },
|
|
10419
|
+
GITHUB_REPOSITORY: { optional: true },
|
|
10420
|
+
GITHUB_TOKEN: { optional: true },
|
|
10421
|
+
GH_TOKEN: { optional: true },
|
|
10422
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10423
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8726
10424
|
}
|
|
8727
10425
|
},
|
|
8728
10426
|
1
|
|
@@ -8741,7 +10439,9 @@ var REGISTRY = [
|
|
|
8741
10439
|
PR_NUMBER: { optional: true },
|
|
8742
10440
|
GITHUB_REPOSITORY: { optional: true },
|
|
8743
10441
|
GITHUB_TOKEN: { optional: true },
|
|
8744
|
-
GH_TOKEN: { optional: true }
|
|
10442
|
+
GH_TOKEN: { optional: true },
|
|
10443
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10444
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8745
10445
|
}
|
|
8746
10446
|
},
|
|
8747
10447
|
1
|
|
@@ -8781,7 +10481,9 @@ var REGISTRY = [
|
|
|
8781
10481
|
PR_NUMBER: { optional: true },
|
|
8782
10482
|
GITHUB_REPOSITORY: { optional: true },
|
|
8783
10483
|
GITHUB_TOKEN: { optional: true },
|
|
8784
|
-
GH_TOKEN: { optional: true }
|
|
10484
|
+
GH_TOKEN: { optional: true },
|
|
10485
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10486
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8785
10487
|
}
|
|
8786
10488
|
},
|
|
8787
10489
|
1
|
|
@@ -8834,12 +10536,15 @@ var REGISTRY = [
|
|
|
8834
10536
|
{
|
|
8835
10537
|
name: "doc-coverage-push",
|
|
8836
10538
|
validates: "body",
|
|
10539
|
+
advisory: true,
|
|
8837
10540
|
run: bin("check-doc-coverage-push"),
|
|
8838
10541
|
scope: "diff",
|
|
8839
10542
|
timeoutMs: 15000,
|
|
8840
10543
|
env: {
|
|
8841
10544
|
OVERRIDE_DOCS: { optional: true },
|
|
8842
10545
|
BASE_SHA: { optional: true },
|
|
10546
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10547
|
+
VINAYA_COMMIT_HOOK: { optional: true },
|
|
8843
10548
|
PR_BODY: { optional: true },
|
|
8844
10549
|
PR_BODY_FILE: { optional: true },
|
|
8845
10550
|
PR_LABELS: { optional: true },
|
|
@@ -8851,21 +10556,6 @@ var REGISTRY = [
|
|
|
8851
10556
|
},
|
|
8852
10557
|
0
|
|
8853
10558
|
],
|
|
8854
|
-
[
|
|
8855
|
-
{
|
|
8856
|
-
name: "issue-assignment",
|
|
8857
|
-
run: bin("check-issue-assignment"),
|
|
8858
|
-
scope: "full",
|
|
8859
|
-
timeoutMs: 30000,
|
|
8860
|
-
env: {
|
|
8861
|
-
AEG_REPO: { optional: true },
|
|
8862
|
-
BRANCH: { optional: true },
|
|
8863
|
-
GITHUB_TOKEN: { optional: true },
|
|
8864
|
-
GH_TOKEN: { optional: true }
|
|
8865
|
-
}
|
|
8866
|
-
},
|
|
8867
|
-
0
|
|
8868
|
-
],
|
|
8869
10559
|
[
|
|
8870
10560
|
{
|
|
8871
10561
|
name: "evidence-fresh",
|
|
@@ -8879,7 +10569,9 @@ var REGISTRY = [
|
|
|
8879
10569
|
PR_BODY: { optional: true },
|
|
8880
10570
|
BASE_SHA: { optional: true },
|
|
8881
10571
|
GITHUB_TOKEN: { optional: true },
|
|
8882
|
-
GH_TOKEN: { optional: true }
|
|
10572
|
+
GH_TOKEN: { optional: true },
|
|
10573
|
+
VINAYA_FORGE_SNAPSHOT_DIR: { optional: true },
|
|
10574
|
+
GITHUB_ACTIONS: { optional: true }
|
|
8883
10575
|
}
|
|
8884
10576
|
},
|
|
8885
10577
|
1
|
|
@@ -8890,7 +10582,11 @@ var REGISTRY = [
|
|
|
8890
10582
|
run: bin("check-reader-resolvable-prose"),
|
|
8891
10583
|
scope: "full",
|
|
8892
10584
|
timeoutMs: 30000,
|
|
8893
|
-
env: {
|
|
10585
|
+
env: {
|
|
10586
|
+
BASE_SHA: { optional: true },
|
|
10587
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10588
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10589
|
+
},
|
|
8894
10590
|
include: [
|
|
8895
10591
|
"aeg-root/**/*.md",
|
|
8896
10592
|
"apps/cli/src/**",
|
|
@@ -8908,7 +10604,11 @@ var REGISTRY = [
|
|
|
8908
10604
|
run: bin("check-retired-vocabulary"),
|
|
8909
10605
|
scope: "full",
|
|
8910
10606
|
timeoutMs: 30000,
|
|
8911
|
-
env: {
|
|
10607
|
+
env: {
|
|
10608
|
+
BASE_SHA: { optional: true },
|
|
10609
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10610
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10611
|
+
},
|
|
8912
10612
|
include: ["aeg-root/**/*.md"]
|
|
8913
10613
|
},
|
|
8914
10614
|
0
|
|
@@ -8916,10 +10616,15 @@ var REGISTRY = [
|
|
|
8916
10616
|
[
|
|
8917
10617
|
{
|
|
8918
10618
|
name: "doctrine-portability",
|
|
10619
|
+
advisory: true,
|
|
8919
10620
|
run: bin("check-doctrine-portability"),
|
|
8920
10621
|
scope: "full",
|
|
8921
10622
|
timeoutMs: 30000,
|
|
8922
|
-
env: {
|
|
10623
|
+
env: {
|
|
10624
|
+
BASE_SHA: { optional: true },
|
|
10625
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10626
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10627
|
+
},
|
|
8923
10628
|
include: ["aeg-root/**/*.md"]
|
|
8924
10629
|
},
|
|
8925
10630
|
0
|
|
@@ -8952,7 +10657,11 @@ var REGISTRY = [
|
|
|
8952
10657
|
run: bin("check-exec-bits"),
|
|
8953
10658
|
scope: "diff",
|
|
8954
10659
|
timeoutMs: 30000,
|
|
8955
|
-
env: {
|
|
10660
|
+
env: {
|
|
10661
|
+
BASE_SHA: { optional: true },
|
|
10662
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10663
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10664
|
+
}
|
|
8956
10665
|
},
|
|
8957
10666
|
0
|
|
8958
10667
|
],
|
|
@@ -8962,17 +10671,26 @@ var REGISTRY = [
|
|
|
8962
10671
|
run: bin("check-ci-shard-coverage"),
|
|
8963
10672
|
scope: "diff",
|
|
8964
10673
|
timeoutMs: 15000,
|
|
8965
|
-
env: {
|
|
10674
|
+
env: {
|
|
10675
|
+
BASE_SHA: { optional: true },
|
|
10676
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10677
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10678
|
+
}
|
|
8966
10679
|
},
|
|
8967
10680
|
0
|
|
8968
10681
|
],
|
|
8969
10682
|
[
|
|
8970
10683
|
{
|
|
8971
10684
|
name: "workspace-escape",
|
|
10685
|
+
advisory: true,
|
|
8972
10686
|
run: bin("check-workspace-escape"),
|
|
8973
10687
|
scope: "full",
|
|
8974
10688
|
timeoutMs: 30000,
|
|
8975
|
-
env: {
|
|
10689
|
+
env: {
|
|
10690
|
+
BASE_SHA: { optional: true },
|
|
10691
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10692
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10693
|
+
},
|
|
8976
10694
|
include: ["aeg-root/**/*.md"]
|
|
8977
10695
|
},
|
|
8978
10696
|
0
|
|
@@ -8983,17 +10701,23 @@ var REGISTRY = [
|
|
|
8983
10701
|
run: bin("check-changeset-coverage"),
|
|
8984
10702
|
scope: "diff",
|
|
8985
10703
|
timeoutMs: 15000,
|
|
8986
|
-
env: {
|
|
10704
|
+
env: {
|
|
10705
|
+
BASE_SHA: { optional: true },
|
|
10706
|
+
GIT_INDEX_FILE: { optional: true },
|
|
10707
|
+
VINAYA_COMMIT_HOOK: { optional: true }
|
|
10708
|
+
}
|
|
8987
10709
|
},
|
|
8988
10710
|
0
|
|
8989
10711
|
],
|
|
8990
10712
|
[
|
|
8991
10713
|
{
|
|
8992
10714
|
name: "quoted-command",
|
|
10715
|
+
advisory: true,
|
|
8993
10716
|
run: bin("check-quoted-command"),
|
|
8994
|
-
scope: "
|
|
10717
|
+
scope: "full",
|
|
8995
10718
|
timeoutMs: 15000,
|
|
8996
|
-
env: {}
|
|
10719
|
+
env: {},
|
|
10720
|
+
include: ["aeg-root/**/*.md"]
|
|
8997
10721
|
},
|
|
8998
10722
|
0
|
|
8999
10723
|
],
|
|
@@ -9001,7 +10725,7 @@ var REGISTRY = [
|
|
|
9001
10725
|
{
|
|
9002
10726
|
name: "main-branch-refusal",
|
|
9003
10727
|
run: bin("check-main-branch-refusal"),
|
|
9004
|
-
scope: "
|
|
10728
|
+
scope: "diff",
|
|
9005
10729
|
timeoutMs: 15000,
|
|
9006
10730
|
env: { VINAYA_PUSH_REFS: { optional: true } }
|
|
9007
10731
|
},
|
|
@@ -9068,18 +10792,6 @@ var REGISTRY = [
|
|
|
9068
10792
|
},
|
|
9069
10793
|
1
|
|
9070
10794
|
],
|
|
9071
|
-
[
|
|
9072
|
-
{
|
|
9073
|
-
name: "issue-tranche-label",
|
|
9074
|
-
run: bin("check-issue-tranche-label"),
|
|
9075
|
-
validates: "issue",
|
|
9076
|
-
scope: "full",
|
|
9077
|
-
ownWorkflow: true,
|
|
9078
|
-
timeoutMs: 15000,
|
|
9079
|
-
env: { ISSUE_BODY: { optional: true }, ISSUE_LABELS: { optional: true } }
|
|
9080
|
-
},
|
|
9081
|
-
1
|
|
9082
|
-
],
|
|
9083
10795
|
[
|
|
9084
10796
|
{
|
|
9085
10797
|
name: "issue-milestone-attach",
|
|
@@ -9103,30 +10815,30 @@ function coreCheckRegistry() {
|
|
|
9103
10815
|
var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.name, ring]));
|
|
9104
10816
|
|
|
9105
10817
|
// src/lib/log-sink.ts
|
|
9106
|
-
import { execFile as
|
|
10818
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
9107
10819
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
9108
10820
|
import {
|
|
9109
10821
|
appendFileSync,
|
|
9110
10822
|
closeSync as closeSync4,
|
|
9111
10823
|
constants as fsConstants4,
|
|
9112
|
-
existsSync as
|
|
10824
|
+
existsSync as existsSync8,
|
|
9113
10825
|
fstatSync as fstatSync3,
|
|
9114
10826
|
mkdirSync as mkdirSync4,
|
|
9115
|
-
lstatSync as
|
|
10827
|
+
lstatSync as lstatSync3,
|
|
9116
10828
|
openSync as openSync4,
|
|
9117
|
-
readFileSync as
|
|
10829
|
+
readFileSync as readFileSync8,
|
|
9118
10830
|
renameSync as renameSync2,
|
|
9119
|
-
writeFileSync as
|
|
10831
|
+
writeFileSync as writeFileSync4,
|
|
9120
10832
|
writeSync as writeSync3
|
|
9121
10833
|
} from "node:fs";
|
|
9122
10834
|
import { hostname as osHostname, homedir as homedir3 } from "node:os";
|
|
9123
|
-
import { dirname as dirname7, join as
|
|
9124
|
-
import { promisify as
|
|
10835
|
+
import { dirname as dirname7, join as join9 } from "node:path";
|
|
10836
|
+
import { promisify as promisify6 } from "node:util";
|
|
9125
10837
|
|
|
9126
10838
|
// src/lib/run-paths.ts
|
|
9127
10839
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
9128
|
-
import { chmodSync, existsSync as
|
|
9129
|
-
import { dirname as dirname4, join as
|
|
10840
|
+
import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync3 } from "node:fs";
|
|
10841
|
+
import { dirname as dirname4, join as join7, resolve as resolvePath } from "node:path";
|
|
9130
10842
|
var TASKS_EXECUTION_DIRNAME = "tasks-execution";
|
|
9131
10843
|
var RUN_AREA_DIRNAMES = {
|
|
9132
10844
|
control: CONTROL_AREA_DIRNAME,
|
|
@@ -9145,7 +10857,7 @@ function repoSegment(repo) {
|
|
|
9145
10857
|
return `${repo.owner}-${repo.repo}`;
|
|
9146
10858
|
}
|
|
9147
10859
|
function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
|
|
9148
|
-
return
|
|
10860
|
+
return join7(home, "runtime", repoSegment(repo));
|
|
9149
10861
|
}
|
|
9150
10862
|
function resolveRuntimeDir(input) {
|
|
9151
10863
|
const local = resolveRuntimeDirSetting(input.localConfig);
|
|
@@ -9166,27 +10878,27 @@ function isInsideRepo(candidate, repoRoot) {
|
|
|
9166
10878
|
return target === root || target.startsWith(`${root}/`);
|
|
9167
10879
|
}
|
|
9168
10880
|
function runPath(runtimeDir, scope, location) {
|
|
9169
|
-
const dir =
|
|
10881
|
+
const dir = join7(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
|
|
9170
10882
|
switch (location.area) {
|
|
9171
10883
|
case "task":
|
|
9172
|
-
return location.file ?
|
|
10884
|
+
return location.file ? join7(dir, location.file) : dir;
|
|
9173
10885
|
case "control": {
|
|
9174
|
-
const controlDir =
|
|
9175
|
-
return location.file ?
|
|
10886
|
+
const controlDir = join7(dir, RUN_AREA_DIRNAMES.control);
|
|
10887
|
+
return location.file ? join7(controlDir, location.file) : controlDir;
|
|
9176
10888
|
}
|
|
9177
10889
|
case "rounds":
|
|
9178
|
-
return
|
|
10890
|
+
return join7(dir, RUN_AREA_DIRNAMES.rounds);
|
|
9179
10891
|
case "round": {
|
|
9180
|
-
const roundDir =
|
|
9181
|
-
return location.file ?
|
|
10892
|
+
const roundDir = join7(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
|
|
10893
|
+
return location.file ? join7(roundDir, location.file) : roundDir;
|
|
9182
10894
|
}
|
|
9183
10895
|
case "developer": {
|
|
9184
|
-
const developerDir =
|
|
9185
|
-
return location.file ?
|
|
10896
|
+
const developerDir = join7(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
|
|
10897
|
+
return location.file ? join7(developerDir, location.file) : developerDir;
|
|
9186
10898
|
}
|
|
9187
10899
|
default: {
|
|
9188
|
-
const areaDir =
|
|
9189
|
-
return location.file ?
|
|
10900
|
+
const areaDir = join7(dir, RUN_AREA_DIRNAMES[location.area]);
|
|
10901
|
+
return location.file ? join7(areaDir, location.file) : areaDir;
|
|
9190
10902
|
}
|
|
9191
10903
|
}
|
|
9192
10904
|
}
|
|
@@ -9255,7 +10967,7 @@ function repoRootSync(start = process.cwd()) {
|
|
|
9255
10967
|
return null;
|
|
9256
10968
|
}
|
|
9257
10969
|
for (;; ) {
|
|
9258
|
-
if (
|
|
10970
|
+
if (existsSync6(join7(dir, ".git")))
|
|
9259
10971
|
return dir;
|
|
9260
10972
|
const parent = dirname4(dir);
|
|
9261
10973
|
if (parent === dir)
|
|
@@ -9299,11 +11011,11 @@ function runtimeDirForThisRepo() {
|
|
|
9299
11011
|
import {
|
|
9300
11012
|
closeSync as closeSync2,
|
|
9301
11013
|
constants as fsConstants2,
|
|
9302
|
-
existsSync as
|
|
11014
|
+
existsSync as existsSync7,
|
|
9303
11015
|
fstatSync as fstatSync2,
|
|
9304
11016
|
mkdirSync as mkdirSync2,
|
|
9305
11017
|
openSync as openSync2,
|
|
9306
|
-
readFileSync as
|
|
11018
|
+
readFileSync as readFileSync6,
|
|
9307
11019
|
readSync,
|
|
9308
11020
|
statSync,
|
|
9309
11021
|
writeSync
|
|
@@ -9336,21 +11048,21 @@ function appendLoopLogLine(path, line) {
|
|
|
9336
11048
|
import {
|
|
9337
11049
|
closeSync as closeSync3,
|
|
9338
11050
|
constants as fsConstants3,
|
|
9339
|
-
lstatSync,
|
|
11051
|
+
lstatSync as lstatSync2,
|
|
9340
11052
|
mkdirSync as mkdirSync3,
|
|
9341
11053
|
openSync as openSync3,
|
|
9342
11054
|
linkSync,
|
|
9343
|
-
readFileSync as
|
|
11055
|
+
readFileSync as readFileSync7,
|
|
9344
11056
|
renameSync,
|
|
9345
11057
|
statSync as statSync2,
|
|
9346
11058
|
unlinkSync,
|
|
9347
11059
|
utimesSync,
|
|
9348
|
-
writeFileSync as
|
|
11060
|
+
writeFileSync as writeFileSync3,
|
|
9349
11061
|
writeSync as writeSync2
|
|
9350
11062
|
} from "node:fs";
|
|
9351
11063
|
import { randomUUID } from "node:crypto";
|
|
9352
11064
|
import { homedir as homedir2 } from "node:os";
|
|
9353
|
-
import { dirname as dirname6, join as
|
|
11065
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
9354
11066
|
var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
|
|
9355
11067
|
var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
|
|
9356
11068
|
var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
@@ -9431,7 +11143,7 @@ function acquireDrainLock(lockPath) {
|
|
|
9431
11143
|
function renewDrainLock(lockPath, token) {
|
|
9432
11144
|
let holder;
|
|
9433
11145
|
try {
|
|
9434
|
-
holder =
|
|
11146
|
+
holder = readFileSync7(lockPath, "utf8").trim();
|
|
9435
11147
|
} catch (err) {
|
|
9436
11148
|
if (!isEnoent(err))
|
|
9437
11149
|
throw err;
|
|
@@ -9451,7 +11163,7 @@ function renewDrainLock(lockPath, token) {
|
|
|
9451
11163
|
}
|
|
9452
11164
|
function releaseDrainLock(lockPath, token) {
|
|
9453
11165
|
try {
|
|
9454
|
-
const holder =
|
|
11166
|
+
const holder = readFileSync7(lockPath, "utf8").trim();
|
|
9455
11167
|
if (holder !== token)
|
|
9456
11168
|
return;
|
|
9457
11169
|
unlinkSync(lockPath);
|
|
@@ -9501,13 +11213,13 @@ function queueLines(buf) {
|
|
|
9501
11213
|
return lines;
|
|
9502
11214
|
}
|
|
9503
11215
|
function removeQueueHead(path, cut) {
|
|
9504
|
-
const remaining =
|
|
9505
|
-
|
|
11216
|
+
const remaining = readFileSync7(path);
|
|
11217
|
+
writeFileSync3(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
|
|
9506
11218
|
}
|
|
9507
11219
|
function queueBucketSize(path) {
|
|
9508
11220
|
let lstat;
|
|
9509
11221
|
try {
|
|
9510
|
-
lstat =
|
|
11222
|
+
lstat = lstatSync2(path);
|
|
9511
11223
|
} catch (err) {
|
|
9512
11224
|
if (!isEnoent(err))
|
|
9513
11225
|
throw err;
|
|
@@ -9522,7 +11234,7 @@ function queueBucketSize(path) {
|
|
|
9522
11234
|
function readQueueFile(path) {
|
|
9523
11235
|
if (queueBucketSize(path) === null)
|
|
9524
11236
|
return null;
|
|
9525
|
-
return
|
|
11237
|
+
return readFileSync7(path);
|
|
9526
11238
|
}
|
|
9527
11239
|
function rejectLine(rejectedPath, reason, status, identity, raw) {
|
|
9528
11240
|
const record = JSON.stringify({
|
|
@@ -9637,7 +11349,7 @@ async function drainRenamedAside(args, livePath, source) {
|
|
|
9637
11349
|
async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
|
|
9638
11350
|
const resolved = await resolveRepo();
|
|
9639
11351
|
const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
|
|
9640
|
-
const outboxRoot = () =>
|
|
11352
|
+
const outboxRoot = () => join8(GLOBAL_VINAYA_HOME, "outbox");
|
|
9641
11353
|
const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
|
|
9642
11354
|
const lockPath = `${path}.flush-lock`;
|
|
9643
11355
|
const lockToken = acquireDrainLock(lockPath);
|
|
@@ -9674,6 +11386,7 @@ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeou
|
|
|
9674
11386
|
|
|
9675
11387
|
// src/lib/log-sink.ts
|
|
9676
11388
|
var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
|
|
11389
|
+
var LOG_FOLDER_ONLY_ENV = "VINAYA_LOG_FOLDER_ONLY";
|
|
9677
11390
|
function describeFolderFallback(reason) {
|
|
9678
11391
|
if (reason.kind === "anchor-unreadable") {
|
|
9679
11392
|
return `not delivering to the configured log server ${reason.intendedUrl} — the default branch's ` + "vinaya.config.json could not be read to confirm it (the trust-anchor read via `gh` was offline, " + "unauthenticated, or slower than its deadline); events are written to the local folder and can be " + "delivered later with `vinaya log send`";
|
|
@@ -9713,6 +11426,9 @@ function logsCredentialMissing(headers, env) {
|
|
|
9713
11426
|
return false;
|
|
9714
11427
|
}
|
|
9715
11428
|
function resolveLogDestinationFrom(input) {
|
|
11429
|
+
if (input.localConfig?.logs === false || input.unattended && input.trustAnchorConfig?.logs === false) {
|
|
11430
|
+
return { kind: "none", reason: "logs: false disables Log recording" };
|
|
11431
|
+
}
|
|
9716
11432
|
const spoolDir = input.env.VINAYA_LOG_SPOOL_DIR;
|
|
9717
11433
|
if (spoolDir !== undefined && spoolDir.trim() !== "") {
|
|
9718
11434
|
return { kind: "folder", folder: spoolDir };
|
|
@@ -9732,6 +11448,10 @@ function resolveLogDestinationFrom(input) {
|
|
|
9732
11448
|
} else {
|
|
9733
11449
|
effective = local;
|
|
9734
11450
|
}
|
|
11451
|
+
if (input.folderOnly || input.env[LOG_FOLDER_ONLY_ENV] === "1") {
|
|
11452
|
+
const folder = effective && "folder" in effective && !isInsideRepo(effective.folder, input.repoRoot) ? effective.folder : input.defaultFolder;
|
|
11453
|
+
return { kind: "folder", folder };
|
|
11454
|
+
}
|
|
9735
11455
|
if (hostFromEnv(input.env) === "ci") {
|
|
9736
11456
|
if (effective && "url" in effective) {
|
|
9737
11457
|
if (logsCredentialMissing(effective.headers, input.env)) {
|
|
@@ -9756,41 +11476,73 @@ function resolveLogDestinationFrom(input) {
|
|
|
9756
11476
|
const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
|
|
9757
11477
|
return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
|
|
9758
11478
|
}
|
|
9759
|
-
var
|
|
11479
|
+
var LOG_DESTINATION_ANCHOR_RETRY_INTERVAL_MS = 30000;
|
|
11480
|
+
var LOG_DESTINATION_ANCHOR_MAX_RETRIES = 5;
|
|
11481
|
+
function createTrustAnchorCache(read, now = Date.now, bounds = {
|
|
11482
|
+
retryIntervalMs: LOG_DESTINATION_ANCHOR_RETRY_INTERVAL_MS,
|
|
11483
|
+
maxRetries: LOG_DESTINATION_ANCHOR_MAX_RETRIES
|
|
11484
|
+
}) {
|
|
11485
|
+
const slots = new Map;
|
|
11486
|
+
const start = (repoRoot, retries) => {
|
|
11487
|
+
const slot = {
|
|
11488
|
+
reading: Promise.resolve().then(read).catch(() => null),
|
|
11489
|
+
retries,
|
|
11490
|
+
missedAt: null
|
|
11491
|
+
};
|
|
11492
|
+
slots.set(repoRoot, slot);
|
|
11493
|
+
slot.reading.then((config) => {
|
|
11494
|
+
if (config === null)
|
|
11495
|
+
slot.missedAt = now();
|
|
11496
|
+
});
|
|
11497
|
+
return slot.reading;
|
|
11498
|
+
};
|
|
11499
|
+
return {
|
|
11500
|
+
get: (repoRoot) => {
|
|
11501
|
+
const slot = slots.get(repoRoot);
|
|
11502
|
+
if (slot === undefined)
|
|
11503
|
+
return start(repoRoot, 0);
|
|
11504
|
+
if (slot.missedAt === null)
|
|
11505
|
+
return slot.reading;
|
|
11506
|
+
if (slot.retries >= bounds.maxRetries || now() - slot.missedAt < bounds.retryIntervalMs)
|
|
11507
|
+
return slot.reading;
|
|
11508
|
+
return start(repoRoot, slot.retries + 1);
|
|
11509
|
+
},
|
|
11510
|
+
clear: () => slots.clear()
|
|
11511
|
+
};
|
|
11512
|
+
}
|
|
11513
|
+
var processTrustAnchorByRepo = createTrustAnchorCache(safeLoadTrustAnchorConfig);
|
|
9760
11514
|
function processTrustAnchor(repoRoot) {
|
|
9761
|
-
|
|
9762
|
-
if (cached !== undefined)
|
|
9763
|
-
return cached;
|
|
9764
|
-
const reading = safeLoadTrustAnchorConfig();
|
|
9765
|
-
processTrustAnchorByRepo.set(repoRoot, reading);
|
|
9766
|
-
return reading;
|
|
11515
|
+
return processTrustAnchorByRepo.get(repoRoot);
|
|
9767
11516
|
}
|
|
9768
|
-
async function defaultResolveLogDestination(repo, env) {
|
|
11517
|
+
async function defaultResolveLogDestination(repo, env, folderOnly = false) {
|
|
9769
11518
|
const localConfig = loadConfig();
|
|
9770
11519
|
const unattended = isUnattendedProcess(process.env);
|
|
9771
11520
|
const repoRoot = repoRootSync();
|
|
9772
11521
|
return resolveLogDestinationFrom({
|
|
9773
11522
|
localConfig,
|
|
11523
|
+
folderOnly,
|
|
9774
11524
|
trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
|
|
9775
11525
|
unattended,
|
|
9776
11526
|
env,
|
|
9777
|
-
defaultFolder:
|
|
11527
|
+
defaultFolder: join9(await runtimeDirForRepoAsync(repo), "logs"),
|
|
9778
11528
|
repoRoot
|
|
9779
11529
|
});
|
|
9780
11530
|
}
|
|
9781
11531
|
function unresolvedLogDestination(env) {
|
|
11532
|
+
const loaded = loadConfig();
|
|
11533
|
+
if (loaded?.logs === false)
|
|
11534
|
+
return { kind: "none", reason: "logs: false disables Log recording" };
|
|
9782
11535
|
if (hostFromEnv(env) === "ci") {
|
|
9783
11536
|
return {
|
|
9784
11537
|
kind: "none",
|
|
9785
11538
|
reason: "the process ended before its log destination was resolved, and a CI job never records to a folder"
|
|
9786
11539
|
};
|
|
9787
11540
|
}
|
|
9788
|
-
const
|
|
9789
|
-
const localConfig = loaded?.logs?.url !== undefined ? { ...loaded, logs: undefined } : loaded;
|
|
11541
|
+
const localConfig = loaded?.logs && loaded.logs.url !== undefined ? { ...loaded, logs: undefined } : loaded;
|
|
9790
11542
|
const unattended = isUnattendedProcess(process.env);
|
|
9791
11543
|
const repoRoot = repoRootSync();
|
|
9792
11544
|
const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
|
|
9793
|
-
const defaultFolder =
|
|
11545
|
+
const defaultFolder = join9(runtimeDir, "logs");
|
|
9794
11546
|
const resolved = resolveLogDestinationFrom({
|
|
9795
11547
|
localConfig,
|
|
9796
11548
|
trustAnchorConfig: null,
|
|
@@ -9803,7 +11555,7 @@ function unresolvedLogDestination(env) {
|
|
|
9803
11555
|
}
|
|
9804
11556
|
function folderFallbackStatePath(repo, stateRoot = GLOBAL_VINAYA_HOME) {
|
|
9805
11557
|
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
9806
|
-
return
|
|
11558
|
+
return join9(stateRoot, "fallback", `${dirName}.json`);
|
|
9807
11559
|
}
|
|
9808
11560
|
function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot = GLOBAL_VINAYA_HOME) {
|
|
9809
11561
|
const message = describeFolderFallback(reason);
|
|
@@ -9819,25 +11571,25 @@ function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot =
|
|
|
9819
11571
|
};
|
|
9820
11572
|
const path = folderFallbackStatePath(repo, stateRoot);
|
|
9821
11573
|
mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
|
|
9822
|
-
|
|
11574
|
+
writeFileSync4(path, `${JSON.stringify(record)}
|
|
9823
11575
|
`, { mode: 384 });
|
|
9824
11576
|
} catch {}
|
|
9825
11577
|
}
|
|
9826
11578
|
function isEnoent2(err) {
|
|
9827
11579
|
return typeof err === "object" && err !== null && err.code === "ENOENT";
|
|
9828
11580
|
}
|
|
9829
|
-
var
|
|
11581
|
+
var execFileAsync6 = promisify6(execFile6);
|
|
9830
11582
|
async function resolveDoctrine(cwd, vinayaVersion) {
|
|
9831
11583
|
let toplevel;
|
|
9832
11584
|
try {
|
|
9833
|
-
toplevel = (await
|
|
11585
|
+
toplevel = (await execFileAsync6("git", ["-C", cwd, "rev-parse", "--show-toplevel"], { encoding: "utf8" })).stdout.trim();
|
|
9834
11586
|
} catch (err) {
|
|
9835
11587
|
return isEnoent2(err) ? "unknown" : vinayaVersion;
|
|
9836
11588
|
}
|
|
9837
|
-
if (!
|
|
11589
|
+
if (!existsSync8(join9(toplevel, "aeg-root", "roles")))
|
|
9838
11590
|
return vinayaVersion;
|
|
9839
11591
|
try {
|
|
9840
|
-
const sha = (await
|
|
11592
|
+
const sha = (await execFileAsync6("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
|
|
9841
11593
|
return `aeg-root@${sha}`;
|
|
9842
11594
|
} catch {
|
|
9843
11595
|
return vinayaVersion;
|
|
@@ -9860,7 +11612,7 @@ var TRANCHE_ISSUE_LIST_LIMIT = 200;
|
|
|
9860
11612
|
async function issueForTrancheTask(tranche, taskId, cwd, repo) {
|
|
9861
11613
|
let stdout;
|
|
9862
11614
|
try {
|
|
9863
|
-
({ stdout } = await
|
|
11615
|
+
({ stdout } = await execFileAsync6("gh", [
|
|
9864
11616
|
"issue",
|
|
9865
11617
|
"list",
|
|
9866
11618
|
"--state",
|
|
@@ -9898,7 +11650,7 @@ async function issueForTrancheTask(tranche, taskId, cwd, repo) {
|
|
|
9898
11650
|
async function confirmBacklogIssue(issue, cwd, repo) {
|
|
9899
11651
|
let stdout;
|
|
9900
11652
|
try {
|
|
9901
|
-
({ stdout } = await
|
|
11653
|
+
({ stdout } = await execFileAsync6("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
|
|
9902
11654
|
cwd,
|
|
9903
11655
|
encoding: "utf8",
|
|
9904
11656
|
timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
|
|
@@ -9917,7 +11669,7 @@ async function confirmBacklogIssue(issue, cwd, repo) {
|
|
|
9917
11669
|
async function resolveBranchIssue(cwd, env = process.env, repo = null) {
|
|
9918
11670
|
let branch;
|
|
9919
11671
|
try {
|
|
9920
|
-
branch = (await
|
|
11672
|
+
branch = (await execFileAsync6("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
|
|
9921
11673
|
encoding: "utf8",
|
|
9922
11674
|
timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
|
|
9923
11675
|
killSignal: "SIGKILL"
|
|
@@ -9935,7 +11687,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
|
|
|
9935
11687
|
}
|
|
9936
11688
|
function readVinayaVersion() {
|
|
9937
11689
|
try {
|
|
9938
|
-
const pkg = JSON.parse(
|
|
11690
|
+
const pkg = JSON.parse(readFileSync8(join9(packageRoot(import.meta.url), "package.json"), "utf8"));
|
|
9939
11691
|
return pkg.version ?? "unknown";
|
|
9940
11692
|
} catch {
|
|
9941
11693
|
return "unknown";
|
|
@@ -9953,7 +11705,7 @@ function safeRepoSlug(repo) {
|
|
|
9953
11705
|
function outboxPathFor(deps, repo, issue) {
|
|
9954
11706
|
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
9955
11707
|
const fileName = `${issue ?? "none"}.ndjson`;
|
|
9956
|
-
return
|
|
11708
|
+
return join9(deps.outboxRoot(), dirName, fileName);
|
|
9957
11709
|
}
|
|
9958
11710
|
function hostFromEnv(env) {
|
|
9959
11711
|
if (env.GITHUB_ACTIONS)
|
|
@@ -10000,7 +11752,7 @@ function headShaRead(key, read, shared) {
|
|
|
10000
11752
|
}
|
|
10001
11753
|
async function resolveHeadSha(cwd) {
|
|
10002
11754
|
try {
|
|
10003
|
-
const out = (await
|
|
11755
|
+
const out = (await execFileAsync6("git", ["-C", cwd, "rev-parse", "HEAD"], { encoding: "utf8" })).stdout.trim();
|
|
10004
11756
|
return /^[0-9a-f]{40}$/.test(out) ? out : null;
|
|
10005
11757
|
} catch {
|
|
10006
11758
|
return null;
|
|
@@ -10008,7 +11760,8 @@ async function resolveHeadSha(cwd) {
|
|
|
10008
11760
|
}
|
|
10009
11761
|
function defaultDeps() {
|
|
10010
11762
|
return {
|
|
10011
|
-
|
|
11763
|
+
readConfig: loadConfig,
|
|
11764
|
+
outboxRoot: () => join9(GLOBAL_VINAYA_HOME, "outbox"),
|
|
10012
11765
|
home: () => homedir3(),
|
|
10013
11766
|
hostname: () => osHostname(),
|
|
10014
11767
|
cwd: () => process.cwd(),
|
|
@@ -10053,7 +11806,7 @@ function appendHardenedLine(path, line) {
|
|
|
10053
11806
|
function reportRotationOverflow(backupPath, warn) {
|
|
10054
11807
|
let raw;
|
|
10055
11808
|
try {
|
|
10056
|
-
raw =
|
|
11809
|
+
raw = readFileSync8(backupPath, "utf8");
|
|
10057
11810
|
} catch {
|
|
10058
11811
|
return;
|
|
10059
11812
|
}
|
|
@@ -10191,23 +11944,59 @@ function createLogSink(overrides = {}) {
|
|
|
10191
11944
|
};
|
|
10192
11945
|
let contextCache;
|
|
10193
11946
|
let settledContext;
|
|
11947
|
+
let contextEnv = {};
|
|
11948
|
+
const resolveDestination = async (repo, env) => deps.readConfig()?.logs === false ? { kind: "none", reason: "logs: false disables Log recording" } : await deps.resolveLogDestination(repo, env, deps.folderOnly);
|
|
10194
11949
|
const context = () => {
|
|
10195
11950
|
if (contextCache === undefined) {
|
|
10196
11951
|
const env = deps.env();
|
|
11952
|
+
contextEnv = env;
|
|
10197
11953
|
contextCache = Promise.all([
|
|
10198
11954
|
withDeadline(resolveRepoOnce(), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null),
|
|
10199
11955
|
doctrine()
|
|
10200
11956
|
]).then(async ([resolved, doctrineValue]) => {
|
|
10201
11957
|
const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
|
|
10202
|
-
settledContext = { repo, doctrine: doctrineValue, destination: await
|
|
11958
|
+
settledContext = { repo, doctrine: doctrineValue, destination: await resolveDestination(repo, env) };
|
|
11959
|
+
destinationRetryDueAt = deps.now().getTime() + LOG_DESTINATION_ANCHOR_RETRY_INTERVAL_MS;
|
|
10203
11960
|
return settledContext;
|
|
10204
11961
|
});
|
|
10205
11962
|
}
|
|
10206
11963
|
return contextCache;
|
|
10207
11964
|
};
|
|
11965
|
+
let destinationRetries = 0;
|
|
11966
|
+
let destinationRetryDueAt = 0;
|
|
11967
|
+
let destinationRetryInFlight = false;
|
|
11968
|
+
const retryDestinationIfDue = (ctx) => {
|
|
11969
|
+
if (ctx.destination.kind !== "folder" || ctx.destination.fallbackReason?.kind !== "anchor-unreadable")
|
|
11970
|
+
return;
|
|
11971
|
+
if (destinationRetryInFlight || destinationRetries >= LOG_DESTINATION_ANCHOR_MAX_RETRIES)
|
|
11972
|
+
return;
|
|
11973
|
+
if (deps.now().getTime() < destinationRetryDueAt)
|
|
11974
|
+
return;
|
|
11975
|
+
destinationRetryInFlight = true;
|
|
11976
|
+
destinationRetries++;
|
|
11977
|
+
const generation = contextCache;
|
|
11978
|
+
Promise.resolve().then(() => resolveDestination(ctx.repo, contextEnv)).then((destination) => {
|
|
11979
|
+
if (contextCache !== generation)
|
|
11980
|
+
return;
|
|
11981
|
+
if (destination.kind === "server") {
|
|
11982
|
+
settledContext = { ...ctx, destination };
|
|
11983
|
+
contextCache = Promise.resolve(settledContext);
|
|
11984
|
+
return;
|
|
11985
|
+
}
|
|
11986
|
+
if (destination.kind !== "folder" || destination.fallbackReason?.kind !== "anchor-unreadable") {
|
|
11987
|
+
destinationRetries = LOG_DESTINATION_ANCHOR_MAX_RETRIES;
|
|
11988
|
+
}
|
|
11989
|
+
}, () => {
|
|
11990
|
+
return;
|
|
11991
|
+
}).finally(() => {
|
|
11992
|
+
destinationRetryInFlight = false;
|
|
11993
|
+
destinationRetryDueAt = deps.now().getTime() + LOG_DESTINATION_ANCHOR_RETRY_INTERVAL_MS;
|
|
11994
|
+
});
|
|
11995
|
+
};
|
|
10208
11996
|
const resetContext = () => {
|
|
10209
11997
|
contextCache = undefined;
|
|
10210
11998
|
settledContext = undefined;
|
|
11999
|
+
destinationRetries = 0;
|
|
10211
12000
|
};
|
|
10212
12001
|
let drainChain = Promise.resolve();
|
|
10213
12002
|
const pendingWrites = new Set;
|
|
@@ -10220,24 +12009,30 @@ function createLogSink(overrides = {}) {
|
|
|
10220
12009
|
`);
|
|
10221
12010
|
});
|
|
10222
12011
|
};
|
|
10223
|
-
const snapshot = () => {
|
|
12012
|
+
const snapshot = (attribution) => {
|
|
10224
12013
|
const env = deps.env();
|
|
10225
12014
|
return {
|
|
12015
|
+
attributed: attribution !== undefined,
|
|
10226
12016
|
host: hostFromEnv(env),
|
|
10227
12017
|
now: deps.now(),
|
|
10228
12018
|
seq: seq++,
|
|
10229
12019
|
envFields: {
|
|
10230
|
-
role: env.VINAYA_ROLE,
|
|
12020
|
+
role: attribution?.role ?? env.VINAYA_ROLE,
|
|
10231
12021
|
task: env.VINAYA_TASK,
|
|
10232
|
-
round: env.VINAYA_ROUND,
|
|
12022
|
+
round: attribution ? String(attribution.round) : env.VINAYA_ROUND,
|
|
10233
12023
|
pr: env.VINAYA_PR,
|
|
10234
12024
|
run: env.VINAYA_RUN || runId,
|
|
10235
|
-
attempt: env.VINAYA_ATTEMPT,
|
|
12025
|
+
attempt: attribution ? String(attribution.attempt) : env.VINAYA_ATTEMPT,
|
|
10236
12026
|
parent: env.VINAYA_PARENT_EVENT,
|
|
10237
12027
|
workRef: env.VINAYA_WORK_REF,
|
|
10238
12028
|
flow: env.VINAYA_FLOW,
|
|
10239
12029
|
flowVersion: env.VINAYA_FLOW_VERSION,
|
|
10240
12030
|
runtime: env.VINAYA_RUNTIME,
|
|
12031
|
+
processId: env.VINAYA_PROCESS_ID,
|
|
12032
|
+
processVersion: env.VINAYA_PROCESS_VERSION,
|
|
12033
|
+
processDigest: env.VINAYA_PROCESS_DIGEST,
|
|
12034
|
+
runnerId: env.VINAYA_RUNNER_ID,
|
|
12035
|
+
runnerVersion: env.VINAYA_RUNNER_VERSION,
|
|
10241
12036
|
source: env.VINAYA_SOURCE
|
|
10242
12037
|
}
|
|
10243
12038
|
};
|
|
@@ -10266,12 +12061,14 @@ function createLogSink(overrides = {}) {
|
|
|
10266
12061
|
branchIssue,
|
|
10267
12062
|
eventId: randomUUID2(),
|
|
10268
12063
|
processId,
|
|
12064
|
+
revision: headSha,
|
|
12065
|
+
provenance: call.attributed ? "parent_attributed" : deps.provenance,
|
|
10269
12066
|
inputVersions: deps.inputVersions()
|
|
10270
12067
|
});
|
|
10271
12068
|
const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
|
|
10272
12069
|
if (destination.kind === "folder" && destination.fallbackReason && !folderFallbackRecorded) {
|
|
10273
12070
|
folderFallbackRecorded = true;
|
|
10274
|
-
recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname7(destination.folder),
|
|
12071
|
+
recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname7(destination.folder), join9(deps.home(), ".vinaya"));
|
|
10275
12072
|
}
|
|
10276
12073
|
const full = { ...e, ...header };
|
|
10277
12074
|
const parsed = LogEventSchema.safeParse(full);
|
|
@@ -10290,11 +12087,14 @@ function createLogSink(overrides = {}) {
|
|
|
10290
12087
|
appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
|
|
10291
12088
|
}
|
|
10292
12089
|
};
|
|
10293
|
-
function log(e) {
|
|
12090
|
+
function log(e, attribution) {
|
|
10294
12091
|
try {
|
|
10295
|
-
const call = snapshot();
|
|
12092
|
+
const call = snapshot(attribution);
|
|
10296
12093
|
const write = async () => {
|
|
10297
12094
|
const ctx = await context();
|
|
12095
|
+
try {
|
|
12096
|
+
retryDestinationIfDue(ctx);
|
|
12097
|
+
} catch {}
|
|
10298
12098
|
if (ctx.destination.kind === "none") {
|
|
10299
12099
|
writeEvent(e, call, ctx, null, null, true);
|
|
10300
12100
|
return;
|
|
@@ -10318,9 +12118,13 @@ function createLogSink(overrides = {}) {
|
|
|
10318
12118
|
function logSync(e, opts = {}) {
|
|
10319
12119
|
try {
|
|
10320
12120
|
const call = snapshot();
|
|
10321
|
-
let ctx =
|
|
12121
|
+
let ctx = deps.readConfig()?.logs === false ? {
|
|
12122
|
+
repo: null,
|
|
12123
|
+
doctrine: "unknown",
|
|
12124
|
+
destination: { kind: "none", reason: "logs: false disables Log recording" }
|
|
12125
|
+
} : settledContext;
|
|
10322
12126
|
if (ctx === undefined) {
|
|
10323
|
-
const destination = deps.unresolvedLogDestination(deps.env());
|
|
12127
|
+
const destination = deps.readConfig()?.logs === false ? { kind: "none", reason: "logs: false disables Log recording" } : deps.unresolvedLogDestination(deps.env());
|
|
10324
12128
|
if (destination.kind === "folder" && !opts.quiet) {
|
|
10325
12129
|
warnOnce(`vinaya: the process ended before its log destination was resolved — the event is written to ${destination.folder}; \`vinaya log send\` delivers it to a configured server later
|
|
10326
12130
|
`);
|
|
@@ -10356,13 +12160,6 @@ function createLogSink(overrides = {}) {
|
|
|
10356
12160
|
}
|
|
10357
12161
|
var defaultSink = createLogSink();
|
|
10358
12162
|
|
|
10359
|
-
// src/checks/contract.ts
|
|
10360
|
-
var CHECK_SCHEMA_VERSION = 1;
|
|
10361
|
-
function emitCheckError(error) {
|
|
10362
|
-
process.stderr.write(`${JSON.stringify(error)}
|
|
10363
|
-
`);
|
|
10364
|
-
}
|
|
10365
|
-
|
|
10366
12163
|
// src/checks/runner.ts
|
|
10367
12164
|
var activeChecks = new Map;
|
|
10368
12165
|
|
|
@@ -10403,17 +12200,37 @@ function parseChangedLineRanges(diffOutput) {
|
|
|
10403
12200
|
|
|
10404
12201
|
// src/lib/diff-evidence.ts
|
|
10405
12202
|
function fileDiffAgainst(ref, path) {
|
|
10406
|
-
let
|
|
12203
|
+
let committed;
|
|
10407
12204
|
try {
|
|
10408
|
-
|
|
12205
|
+
committed = execFileSync8("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
10409
12206
|
encoding: "utf8",
|
|
10410
12207
|
stdio: ["ignore", "pipe", "pipe"]
|
|
10411
12208
|
}).trim();
|
|
10412
12209
|
} catch {
|
|
10413
12210
|
return null;
|
|
10414
12211
|
}
|
|
12212
|
+
const staged = stagedDiff(["--", path]);
|
|
12213
|
+
if (staged === null)
|
|
12214
|
+
return null;
|
|
12215
|
+
const out = [committed, staged].filter(Boolean).join(`
|
|
12216
|
+
`);
|
|
10415
12217
|
return out === "" ? null : out;
|
|
10416
12218
|
}
|
|
12219
|
+
function readsStagedDiff() {
|
|
12220
|
+
return process.env.VINAYA_COMMIT_HOOK === "1" && Boolean(process.env.GIT_INDEX_FILE);
|
|
12221
|
+
}
|
|
12222
|
+
function stagedDiff(args) {
|
|
12223
|
+
if (!readsStagedDiff())
|
|
12224
|
+
return "";
|
|
12225
|
+
try {
|
|
12226
|
+
return execFileSync8("git", ["diff", "--cached", ...args], {
|
|
12227
|
+
encoding: "utf8",
|
|
12228
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
12229
|
+
}).trim();
|
|
12230
|
+
} catch {
|
|
12231
|
+
return null;
|
|
12232
|
+
}
|
|
12233
|
+
}
|
|
10417
12234
|
function revParse(ref) {
|
|
10418
12235
|
try {
|
|
10419
12236
|
return execFileSync8("git", ["rev-parse", "--verify", ref], {
|
|
@@ -10447,6 +12264,13 @@ function changedFiles(base) {
|
|
|
10447
12264
|
return out === "" ? [] : out.split(`
|
|
10448
12265
|
`).map((s) => s.trim()).filter(Boolean);
|
|
10449
12266
|
}
|
|
12267
|
+
function stagedChangedFiles() {
|
|
12268
|
+
const out = stagedDiff(["--name-only"]);
|
|
12269
|
+
if (out === null)
|
|
12270
|
+
return null;
|
|
12271
|
+
return out === "" ? [] : out.split(`
|
|
12272
|
+
`).map((s) => s.trim()).filter(Boolean);
|
|
12273
|
+
}
|
|
10450
12274
|
function resolveChangedFiles(base = process.env.BASE_SHA || "origin/main") {
|
|
10451
12275
|
return resolveDiff(base)?.files ?? null;
|
|
10452
12276
|
}
|
|
@@ -10462,7 +12286,30 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
|
|
|
10462
12286
|
const relPaths = changedFiles(ref);
|
|
10463
12287
|
if (relPaths === null)
|
|
10464
12288
|
continue;
|
|
10465
|
-
|
|
12289
|
+
const stagedPaths = stagedChangedFiles();
|
|
12290
|
+
if (stagedPaths === null)
|
|
12291
|
+
return null;
|
|
12292
|
+
const paths = [...new Set([...relPaths, ...stagedPaths])];
|
|
12293
|
+
return { base: ref, root, files: paths.map((p) => join10(root, p)) };
|
|
12294
|
+
}
|
|
12295
|
+
return null;
|
|
12296
|
+
}
|
|
12297
|
+
function resolveAddedFiles(base = process.env.BASE_SHA || "origin/main") {
|
|
12298
|
+
if (repoRoot() === null)
|
|
12299
|
+
return null;
|
|
12300
|
+
const head = revParse("HEAD");
|
|
12301
|
+
for (const ref of new Set([base, "origin/main", "main"])) {
|
|
12302
|
+
const resolved = revParse(ref);
|
|
12303
|
+
if (resolved === null || resolved === head)
|
|
12304
|
+
continue;
|
|
12305
|
+
try {
|
|
12306
|
+
const out = execFileSync8("git", ["diff", "--name-only", "--diff-filter=A", `${ref}...HEAD`], {
|
|
12307
|
+
encoding: "utf8",
|
|
12308
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
12309
|
+
}).trim();
|
|
12310
|
+
return out === "" ? [] : out.split(`
|
|
12311
|
+
`).map((p) => p.trim()).filter(Boolean);
|
|
12312
|
+
} catch {}
|
|
10466
12313
|
}
|
|
10467
12314
|
return null;
|
|
10468
12315
|
}
|
|
@@ -10580,7 +12427,7 @@ function toPosix(p) {
|
|
|
10580
12427
|
}
|
|
10581
12428
|
function readPackageJson(path) {
|
|
10582
12429
|
try {
|
|
10583
|
-
const parsed = JSON.parse(
|
|
12430
|
+
const parsed = JSON.parse(readFileSync9(path, "utf8"));
|
|
10584
12431
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
10585
12432
|
} catch {
|
|
10586
12433
|
return null;
|
|
@@ -10601,18 +12448,18 @@ function childDirs(absoluteDir) {
|
|
|
10601
12448
|
function candidateMemberDirs(root, pattern) {
|
|
10602
12449
|
if (pattern.endsWith("/*")) {
|
|
10603
12450
|
const prefix = pattern.slice(0, -2);
|
|
10604
|
-
return childDirs(
|
|
12451
|
+
return childDirs(join11(root, prefix)).map((name) => `${prefix}/${name}`);
|
|
10605
12452
|
}
|
|
10606
12453
|
if (!pattern.includes("*"))
|
|
10607
12454
|
return [pattern];
|
|
10608
12455
|
return [];
|
|
10609
12456
|
}
|
|
10610
12457
|
function resolveWorkspaceMembers(root) {
|
|
10611
|
-
const rootPkg = readPackageJson(
|
|
12458
|
+
const rootPkg = readPackageJson(join11(root, "package.json"));
|
|
10612
12459
|
const members = new Map;
|
|
10613
12460
|
for (const pattern of workspacePatterns(rootPkg)) {
|
|
10614
12461
|
for (const dir of candidateMemberDirs(root, pattern)) {
|
|
10615
|
-
const pkg = readPackageJson(
|
|
12462
|
+
const pkg = readPackageJson(join11(root, dir, "package.json"));
|
|
10616
12463
|
const name = pkg?.name;
|
|
10617
12464
|
const files = pkg?.files;
|
|
10618
12465
|
if (typeof name !== "string" || !Array.isArray(files))
|
|
@@ -10623,7 +12470,7 @@ function resolveWorkspaceMembers(root) {
|
|
|
10623
12470
|
return members;
|
|
10624
12471
|
}
|
|
10625
12472
|
function fixedGroupNames(root) {
|
|
10626
|
-
const pkg = readPackageJson(
|
|
12473
|
+
const pkg = readPackageJson(join11(root, ".changeset", "config.json"));
|
|
10627
12474
|
const fixed = pkg?.fixed;
|
|
10628
12475
|
if (!Array.isArray(fixed))
|
|
10629
12476
|
return [];
|