@attalabs/vinaya 0.35.0 → 0.36.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/aeg-root/roles/planner/reference.md +20 -5
- package/aeg-root/roles/planner.md +2 -0
- package/aeg-root/roles/reviewer.md +3 -1
- package/aeg-root/templates/brief-template.md +4 -0
- package/dist/checks/bin/check-body-bare-digits.js +1447 -1350
- package/dist/checks/bin/check-branch-topology.js +1418 -1341
- package/dist/checks/bin/check-brief-shape.js +1448 -1351
- package/dist/checks/bin/check-changeset-coverage.js +1470 -1361
- package/dist/checks/bin/check-closes-n.js +1418 -1341
- package/dist/checks/bin/check-coherence.js +1459 -1352
- package/dist/checks/bin/check-dead-branch-push.js +1407 -1340
- package/dist/checks/bin/check-dispatch-readiness.js +1462 -1355
- package/dist/checks/bin/check-doc-coverage-push.js +1470 -1361
- package/dist/checks/bin/check-doc-coverage.js +1472 -1363
- package/dist/checks/bin/check-doctrine-no-procedures.js +1445 -1348
- package/dist/checks/bin/check-doctrine-portability.js +1470 -1361
- package/dist/checks/bin/check-evidence-fresh.js +1477 -1368
- package/dist/checks/bin/check-exec-bits.js +1471 -1362
- package/dist/checks/bin/check-first-push-dispatch.js +1461 -1354
- package/dist/checks/bin/check-issue-assignment.js +1418 -1341
- package/dist/checks/bin/check-issue-milestone-attach.js +1407 -1340
- package/dist/checks/bin/check-issue-objectives-numbering.js +1445 -1348
- package/dist/checks/bin/check-issue-parts-coverage.js +1407 -1340
- package/dist/checks/bin/check-issue-surface-globs.js +1461 -1354
- package/dist/checks/bin/check-issue-title-grammar.js +1407 -1340
- package/dist/checks/bin/check-issue-tranche-label.js +1407 -1340
- package/dist/checks/bin/check-main-branch-refusal.js +1409 -1342
- package/dist/checks/bin/check-no-disk-state.js +1409 -1342
- package/dist/checks/bin/check-pr-premise-reassert.js +1445 -1348
- package/dist/checks/bin/check-pr-report-density.js +1409 -1342
- package/dist/checks/bin/check-principal-test-plan-wait.js +1409 -1342
- package/dist/checks/bin/check-quoted-command.js +1468 -1359
- package/dist/checks/bin/check-reader-resolvable-prose.js +1468 -1359
- package/dist/checks/bin/check-registry-gates.js +1409 -1342
- package/dist/checks/bin/check-retired-vocabulary.js +1468 -1359
- package/dist/checks/bin/check-review-gate.js +1459 -1362
- package/dist/checks/bin/check-single-plan-pr.js +1407 -1340
- package/dist/checks/bin/check-surface-scope.js +1418 -1341
- package/dist/checks/bin/check-test-plan.js +1407 -1340
- package/dist/checks/bin/check-token-collection-wired.js +1409 -1342
- package/dist/checks/bin/check-token-report.js +1409 -1342
- package/dist/checks/bin/check-workspace-escape.js +1471 -1362
- package/dist/index.js +4029 -1880
- package/dist/lib/pre-push-cache-test-run.js +94 -14
- package/dist/lib/pre-push-select-tests.js +83 -15
- package/package.json +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +24 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +33 -10
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +28 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +10 -0
- 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/api/coherence/route.js.nft.json +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.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.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.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.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.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.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.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]__074w9nf._.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]__1gjqmhq._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0zc_0gx._.js → [root-of-the-server]__1wy7w66._.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/00z3-ljjd1gj9.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3goaig_rysc6p.js → 2o9l0b7eqbr57.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3ip5z3cf43bgo.js → 3lqjwjrcvq481.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3u9emqjwpd0t9.js +0 -1
- /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{ca66rAHI_w9D7S7ceXDvR → z1fTSBP6ZlUjObzFIp-qq}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{ca66rAHI_w9D7S7ceXDvR → z1fTSBP6ZlUjObzFIp-qq}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{ca66rAHI_w9D7S7ceXDvR → z1fTSBP6ZlUjObzFIp-qq}/_ssgManifest.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-exec-bits.ts
|
|
4
|
-
import { execFileSync as
|
|
4
|
+
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
5
5
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
6
6
|
|
|
7
7
|
// src/checks/contract.ts
|
|
@@ -12,7 +12,7 @@ function emitCheckError(error) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// src/lib/diff-evidence.ts
|
|
15
|
-
import { execFileSync as
|
|
15
|
+
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
16
16
|
import { join as join9, relative, resolve as resolve2 } from "node:path";
|
|
17
17
|
// ../../packages/aeg-core/src/gate-audience.ts
|
|
18
18
|
var GATE_AUDIENCE = {
|
|
@@ -2477,16 +2477,42 @@ function blockingSeverities(scale, threshold) {
|
|
|
2477
2477
|
}
|
|
2478
2478
|
return scale.slice(0, idx + 1);
|
|
2479
2479
|
}
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
}
|
|
2489
|
-
|
|
2480
|
+
var DEFERRAL_REASON_TEXT = {
|
|
2481
|
+
"unchanged-line": "unchanged line",
|
|
2482
|
+
"outside-surface": "outside the Surface"
|
|
2483
|
+
};
|
|
2484
|
+
var SECURITY_HIGH_AND_ABOVE = blockingSeverities(SECURITY_SEVERITY_ORDER, "HIGH");
|
|
2485
|
+
function classifyFinding(finding, scale, threshold, context = {}) {
|
|
2486
|
+
if (!scale.includes(finding.severity)) {
|
|
2487
|
+
throw new Error(`classifyFinding: severity "${finding.severity}" is not one of ${scale.join(" > ")}`);
|
|
2488
|
+
}
|
|
2489
|
+
const location = finding.location;
|
|
2490
|
+
const effectiveSeverity = location !== undefined && isProseLocation(location) ? PROSE_CAP_SEVERITY : finding.severity;
|
|
2491
|
+
const wouldBlock = blockingSeverities(scale, threshold).includes(effectiveSeverity);
|
|
2492
|
+
if (!wouldBlock)
|
|
2493
|
+
return { outcome: "non_blocking", deferralReason: null };
|
|
2494
|
+
const hasLocation = location !== undefined && location.length > 0;
|
|
2495
|
+
if (hasLocation && context.inSurface && !context.inSurface(location)) {
|
|
2496
|
+
return { outcome: "deferred", deferralReason: "outside-surface" };
|
|
2497
|
+
}
|
|
2498
|
+
if (hasLocation && context.changedLine && !SECURITY_HIGH_AND_ABOVE.includes(effectiveSeverity)) {
|
|
2499
|
+
if (!context.changedLine(location)) {
|
|
2500
|
+
return { outcome: "deferred", deferralReason: "unchanged-line" };
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
return { outcome: "blocking", deferralReason: null };
|
|
2504
|
+
}
|
|
2505
|
+
function evaluateReviewFindings(findings, scale, threshold, context = {}) {
|
|
2506
|
+
const blockingFindings = [];
|
|
2507
|
+
const deferredFindings = [];
|
|
2508
|
+
for (const f of findings) {
|
|
2509
|
+
const c = classifyFinding(f, scale, threshold, context);
|
|
2510
|
+
if (c.outcome === "blocking")
|
|
2511
|
+
blockingFindings.push(f);
|
|
2512
|
+
else if (c.outcome === "deferred")
|
|
2513
|
+
deferredFindings.push({ finding: f, reason: c.deferralReason });
|
|
2514
|
+
}
|
|
2515
|
+
return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings, deferredFindings };
|
|
2490
2516
|
}
|
|
2491
2517
|
function isConsequentialFinding(finding) {
|
|
2492
2518
|
return finding.state !== "resolved";
|
|
@@ -2494,11 +2520,11 @@ function isConsequentialFinding(finding) {
|
|
|
2494
2520
|
function consequentialFindings(findings) {
|
|
2495
2521
|
return findings.filter((f) => isConsequentialFinding(f));
|
|
2496
2522
|
}
|
|
2497
|
-
function evaluateCodeReview(findings, policy) {
|
|
2498
|
-
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
|
|
2523
|
+
function evaluateCodeReview(findings, policy, context = {}) {
|
|
2524
|
+
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold, context);
|
|
2499
2525
|
}
|
|
2500
|
-
function evaluateSecurityReview(findings, policy) {
|
|
2501
|
-
return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold);
|
|
2526
|
+
function evaluateSecurityReview(findings, policy, context = {}) {
|
|
2527
|
+
return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold, context);
|
|
2502
2528
|
}
|
|
2503
2529
|
function isKnownSeverity(scale, value) {
|
|
2504
2530
|
return scale.includes(value);
|
|
@@ -3412,1513 +3438,1548 @@ function checkPrReportDensity(prBody) {
|
|
|
3412
3438
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3413
3439
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3414
3440
|
}
|
|
3415
|
-
// ../../packages/aeg-core/src/
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
{ name: "Sizing", pattern: "Sizing" },
|
|
3423
|
-
{ name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
|
|
3424
|
-
{ name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
|
|
3425
|
-
{ name: "Traps to avoid", pattern: "Traps" },
|
|
3426
|
-
{ name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
|
|
3427
|
-
{ name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
|
|
3428
|
-
{ name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
|
|
3441
|
+
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3442
|
+
var PRODUCT_SLUG_SCOPE = [
|
|
3443
|
+
"apps/cli/src",
|
|
3444
|
+
".github/workflows",
|
|
3445
|
+
".vinaya",
|
|
3446
|
+
"apps/cli/README.md",
|
|
3447
|
+
"packages/sources/README.md"
|
|
3429
3448
|
];
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
const errors = [];
|
|
3433
|
-
for (const f of RATIONALE_FIELDS) {
|
|
3434
|
-
if (!hasRationaleField(body, f.pattern)) {
|
|
3435
|
-
errors.push(`issue-validation ${f.name}: rationale field not found in the Issue body — every task Issue carries the full Planner's rationale (aeg-root/contracts/planner-brief.md).`);
|
|
3436
|
-
continue;
|
|
3437
|
-
}
|
|
3438
|
-
if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
|
|
3439
|
-
errors.push(`issue-validation ${f.name}: rationale field found, but not in the form amend-deps requires — ` + "write `**Dependency rationale** — …`, not `**Dependency rationale:** …`. " + "`amendRationaleDeps` (the only sanctioned way to edit Depends-on/Conflicts-with) locates this " + "section by the exact anchor `**Dependency rationale**`; a colon inside the bold breaks that match " + "and the Issue becomes unamendable.");
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3443
|
-
}
|
|
3444
|
-
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3445
|
-
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3446
|
-
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3447
|
-
return { status: "pass", errors: [] };
|
|
3448
|
-
const result = objectivesOf(body);
|
|
3449
|
-
if (result.ok)
|
|
3450
|
-
return { status: "pass", errors: [] };
|
|
3451
|
-
return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
|
|
3449
|
+
function isUnderOrEqual(path, prefix) {
|
|
3450
|
+
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3452
3451
|
}
|
|
3453
|
-
function
|
|
3454
|
-
|
|
3455
|
-
const heading = headingRe.exec(body);
|
|
3456
|
-
if (!heading)
|
|
3457
|
-
return null;
|
|
3458
|
-
const afterHeading = body.slice(heading.index + heading[0].length);
|
|
3459
|
-
const next = /^##[ \t]/m.exec(afterHeading);
|
|
3460
|
-
return next ? afterHeading.slice(0, next.index) : afterHeading;
|
|
3452
|
+
function isProductScopeFile(path) {
|
|
3453
|
+
return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
|
|
3461
3454
|
}
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
const start = text.indexOf("`", i);
|
|
3466
|
-
if (start === -1)
|
|
3467
|
-
return false;
|
|
3468
|
-
const end = text.indexOf("`", start + 1);
|
|
3469
|
-
if (end === -1)
|
|
3470
|
-
return false;
|
|
3471
|
-
if (text.slice(start + 1, end).includes("/"))
|
|
3472
|
-
return true;
|
|
3473
|
-
i = end + 1;
|
|
3474
|
-
}
|
|
3475
|
-
return false;
|
|
3455
|
+
var SHIPS_PREFIX = "aeg-root/";
|
|
3456
|
+
function shipsArchivePrefix(shipsPrefix) {
|
|
3457
|
+
return `${shipsPrefix}tranches/completed/`;
|
|
3476
3458
|
}
|
|
3477
|
-
var
|
|
3478
|
-
function
|
|
3479
|
-
|
|
3459
|
+
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3460
|
+
function normalizeSpecPath(entry) {
|
|
3461
|
+
let out = entry.replace(/\\/g, "/");
|
|
3462
|
+
while (out.startsWith("./"))
|
|
3463
|
+
out = out.slice(2);
|
|
3464
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3465
|
+
while (out.endsWith("/"))
|
|
3466
|
+
out = out.slice(0, -1);
|
|
3467
|
+
return out;
|
|
3480
3468
|
}
|
|
3481
|
-
function
|
|
3482
|
-
|
|
3469
|
+
function isSpecFile2(path, specPaths) {
|
|
3470
|
+
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
3471
|
+
return true;
|
|
3472
|
+
if (!path.endsWith(".md"))
|
|
3473
|
+
return false;
|
|
3474
|
+
return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
|
|
3483
3475
|
}
|
|
3484
|
-
function
|
|
3485
|
-
|
|
3486
|
-
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3487
|
-
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3488
|
-
return extMatch !== null && extMatch.index > 0;
|
|
3476
|
+
function isClaudeMdFile(path) {
|
|
3477
|
+
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3489
3478
|
}
|
|
3490
|
-
function
|
|
3491
|
-
|
|
3479
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
3480
|
+
if (path.startsWith(shipsPrefix)) {
|
|
3481
|
+
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3482
|
+
}
|
|
3483
|
+
if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
|
|
3484
|
+
return "reader-facing";
|
|
3485
|
+
}
|
|
3486
|
+
if (isClaudeMdFile(path))
|
|
3487
|
+
return "internal";
|
|
3488
|
+
if (isSpecFile2(path, specPaths))
|
|
3489
|
+
return "spec";
|
|
3490
|
+
if (isProductScopeFile(path))
|
|
3491
|
+
return "product";
|
|
3492
|
+
return null;
|
|
3492
3493
|
}
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
if (
|
|
3496
|
-
return
|
|
3497
|
-
const inLine = /^in:\s*(.+)$/im.exec(section);
|
|
3498
|
-
const outLine = /^out:\s*(.+)$/im.exec(section);
|
|
3499
|
-
const errors = [];
|
|
3500
|
-
if (!inLine)
|
|
3501
|
-
errors.push("`## Surface` has no `in:` line.");
|
|
3502
|
-
if (!outLine)
|
|
3503
|
-
errors.push("`## Surface` has no `out:` line.");
|
|
3504
|
-
if (errors.length > 0)
|
|
3505
|
-
return { ok: false, errors };
|
|
3506
|
-
const inGlobs = splitGlobList(inLine[1]);
|
|
3507
|
-
const outGlobs = splitGlobList(outLine[1]);
|
|
3508
|
-
for (const g of [...inGlobs, ...outGlobs]) {
|
|
3509
|
-
if (looksLikeFilePath(g)) {
|
|
3510
|
-
errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
|
|
3511
|
-
}
|
|
3494
|
+
var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
3495
|
+
function stripNonProse(path, content) {
|
|
3496
|
+
if (path.endsWith(".md")) {
|
|
3497
|
+
return content.replace(/```.*?```/gs, (m) => m.replace(/[^\n]/g, "")).replace(/`[^`\n]*`/g, (m) => m.replace(/[^\n]/g, ""));
|
|
3512
3498
|
}
|
|
3513
|
-
if (
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
return { ok: true, value: { in: inGlobs, out: outGlobs } };
|
|
3499
|
+
if (path.endsWith(".tsx") || path.endsWith(".ts")) {
|
|
3500
|
+
return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
|
|
3501
|
+
}
|
|
3502
|
+
return content;
|
|
3518
3503
|
}
|
|
3519
|
-
function
|
|
3520
|
-
|
|
3521
|
-
const p = path.replace(/\/+$/, "");
|
|
3522
|
-
if (g === "*")
|
|
3523
|
-
return !p.includes("/");
|
|
3524
|
-
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
3504
|
+
function stripNonProseForProduct(path, content) {
|
|
3505
|
+
return path.endsWith(".md") ? stripNonProse(path, content) : content;
|
|
3525
3506
|
}
|
|
3526
|
-
function
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
for (const glob of surface.value.in) {
|
|
3532
|
-
if (!resolvesToFile(glob)) {
|
|
3533
|
-
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.`);
|
|
3534
|
-
}
|
|
3507
|
+
function lineAt(content, index) {
|
|
3508
|
+
let line = 1;
|
|
3509
|
+
for (let i = 0;i < index; i++) {
|
|
3510
|
+
if (content.charCodeAt(i) === 10)
|
|
3511
|
+
line++;
|
|
3535
3512
|
}
|
|
3536
|
-
return
|
|
3513
|
+
return line;
|
|
3537
3514
|
}
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
}
|
|
3547
|
-
return violations.length > 0 ? { ok: false, violations } : { ok: true };
|
|
3515
|
+
var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
|
|
3516
|
+
var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
|
|
3517
|
+
var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
|
|
3518
|
+
function legacySlugPattern(legacySlugs) {
|
|
3519
|
+
if (legacySlugs.length === 0)
|
|
3520
|
+
return null;
|
|
3521
|
+
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
3522
|
+
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
3548
3523
|
}
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
const
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3524
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
3525
|
+
const findings = [];
|
|
3526
|
+
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3527
|
+
const grandfathered = new Set(specGrandfather);
|
|
3528
|
+
const patterns = [
|
|
3529
|
+
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3530
|
+
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3531
|
+
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3532
|
+
];
|
|
3533
|
+
const productPatterns = [
|
|
3534
|
+
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3535
|
+
];
|
|
3536
|
+
const specPatterns = [
|
|
3537
|
+
...patterns,
|
|
3538
|
+
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3539
|
+
];
|
|
3540
|
+
for (const file of files) {
|
|
3541
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3542
|
+
if (!cls || cls === "internal")
|
|
3561
3543
|
continue;
|
|
3562
|
-
|
|
3563
|
-
const n = Number.parseInt(m[1], 10);
|
|
3564
|
-
const refs = m[2];
|
|
3565
|
-
const text = m[3].trim();
|
|
3566
|
-
if (text.length === 0) {
|
|
3567
|
-
errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
|
|
3544
|
+
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
3568
3545
|
continue;
|
|
3569
|
-
|
|
3570
|
-
if (partHasBacktickedPath(text) && partWordCount(stripPartBackticks(text)) < PART_MIN_WORDS_OUTSIDE_BACKTICKS) {
|
|
3571
|
-
errors.push(`Part ${n} is little more than a file path — a Part names an outcome and symbols, never a bare path.`);
|
|
3546
|
+
if (cls === "spec" && grandfathered.has(file.path))
|
|
3572
3547
|
continue;
|
|
3548
|
+
const blocking = cls === "product" || cls === "spec";
|
|
3549
|
+
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3550
|
+
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3551
|
+
for (const { pattern, what, group } of patternsToRun) {
|
|
3552
|
+
pattern.lastIndex = 0;
|
|
3553
|
+
let match = pattern.exec(scrubbed);
|
|
3554
|
+
while (match !== null) {
|
|
3555
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
3556
|
+
const citedIndex = match.index + match[0].indexOf(cited);
|
|
3557
|
+
findings.push({
|
|
3558
|
+
file: file.path,
|
|
3559
|
+
line: lineAt(scrubbed, citedIndex),
|
|
3560
|
+
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3561
|
+
blocking
|
|
3562
|
+
});
|
|
3563
|
+
match = pattern.exec(scrubbed);
|
|
3564
|
+
}
|
|
3573
3565
|
}
|
|
3574
|
-
const objectiveIds = [...refs.matchAll(/O(\d+)/g)].map((r) => Number.parseInt(r[1], 10));
|
|
3575
|
-
parts.push({ n, objectiveIds, text });
|
|
3576
3566
|
}
|
|
3577
|
-
|
|
3578
|
-
errors.push("the `## Parts` section has no well-formed `Part <n> (<refs>) — <outcome>` lines.");
|
|
3579
|
-
}
|
|
3580
|
-
if (errors.length > 0)
|
|
3581
|
-
return { ok: false, errors };
|
|
3582
|
-
return { ok: true, value: parts };
|
|
3583
|
-
}
|
|
3584
|
-
function checkPartsCiteDefinedObjectives(body) {
|
|
3585
|
-
const parts = parseIssueParts(body);
|
|
3586
|
-
const objectives = objectivesOf(body);
|
|
3587
|
-
if (!parts.ok || !objectives.ok)
|
|
3588
|
-
return { status: "pass", errors: [] };
|
|
3589
|
-
const definedIds = new Set(objectives.objectives.map((o) => Number.parseInt(o.id.slice(1), 10)));
|
|
3590
|
-
const errors = [];
|
|
3591
|
-
for (const part of parts.value) {
|
|
3592
|
-
for (const objectiveId of part.objectiveIds) {
|
|
3593
|
-
if (!definedIds.has(objectiveId)) {
|
|
3594
|
-
errors.push(`issue-validation Parts: Part ${part.n} cites O${objectiveId}, which the Issue's own \`## Objectives\` section does not define.`);
|
|
3595
|
-
}
|
|
3596
|
-
}
|
|
3597
|
-
}
|
|
3598
|
-
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3599
|
-
}
|
|
3600
|
-
function isTaskIssueLabelSet(labels) {
|
|
3601
|
-
return hasLabel("tranche", labels);
|
|
3602
|
-
}
|
|
3603
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
3604
|
-
return { status: "pass", errors: [] };
|
|
3605
|
-
}
|
|
3606
|
-
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
3607
|
-
if (!isTaskIssueLabelSet(labels))
|
|
3608
|
-
return { status: "pass", errors: [] };
|
|
3609
|
-
if (resolvedMilestoneTitle === null)
|
|
3610
|
-
return { status: "pass", errors: [] };
|
|
3611
|
-
if (currentMilestoneTitle === resolvedMilestoneTitle)
|
|
3612
|
-
return { status: "pass", errors: [] };
|
|
3613
|
-
return {
|
|
3614
|
-
status: "fail",
|
|
3615
|
-
errors: [
|
|
3616
|
-
`issue-validation milestone attach: this task Issue's tranche label resolves to Milestone "${resolvedMilestoneTitle}", but its live Milestone is ${currentMilestoneTitle === null ? "unset" : `"${currentMilestoneTitle}"`} — attach it to "${resolvedMilestoneTitle}".`
|
|
3617
|
-
]
|
|
3618
|
-
};
|
|
3619
|
-
}
|
|
3620
|
-
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
3621
|
-
function isControlCodePoint(codePoint) {
|
|
3622
|
-
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
3623
|
-
}
|
|
3624
|
-
function isDisplayControlCodePoint(codePoint) {
|
|
3625
|
-
return codePoint >= 8203 && codePoint <= 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
|
|
3567
|
+
return findings;
|
|
3626
3568
|
}
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
const shown = values.slice(0, MESSAGE_VALUE_COUNT_MAX).map((v) => `\`${forMessage(v)}\``);
|
|
3630
|
-
const rest = values.length - shown.length;
|
|
3631
|
-
return rest > 0 ? `${shown.join(", ")} and ${rest} more` : shown.join(", ");
|
|
3569
|
+
function escapeTerm(term) {
|
|
3570
|
+
return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3632
3571
|
}
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
const
|
|
3636
|
-
|
|
3637
|
-
const codePoint = ch.codePointAt(0) ?? 0;
|
|
3638
|
-
if (isControlCodePoint(codePoint) || isDisplayControlCodePoint(codePoint))
|
|
3639
|
-
continue;
|
|
3640
|
-
kept.push(ch);
|
|
3641
|
-
}
|
|
3642
|
-
const cleaned = kept.join("").trim();
|
|
3643
|
-
if (cleaned.length === 0)
|
|
3644
|
-
return "(unprintable)";
|
|
3645
|
-
const points = Array.from(cleaned);
|
|
3646
|
-
return points.length > MESSAGE_VALUE_MAX ? `${points.slice(0, MESSAGE_VALUE_MAX).join("")}…` : cleaned;
|
|
3572
|
+
function containsWholeWord(text, term) {
|
|
3573
|
+
const escaped = escapeTerm(term);
|
|
3574
|
+
const re = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)`, "i");
|
|
3575
|
+
return re.test(text);
|
|
3647
3576
|
}
|
|
3648
|
-
function
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
const errors = [];
|
|
3657
|
-
if (field.unreadable) {
|
|
3658
|
-
return {
|
|
3659
|
-
status: "fail",
|
|
3660
|
-
errors: [
|
|
3661
|
-
`issue-validation project registry: the body has an unterminated code fence, so its \`**Project:**\` field could not be read reliably — the fence runs to end of body (CommonMark, and how the forge renders it), swallowing everything after it including the foot field where the declaration lives by convention. Read from the raw body the field says ${residueForMessage(field.unparsed) || "(nothing)"}, but a line inside a swallowed region may be a quoted example rather than a real declaration, so this gate refuses rather than guessing which. Balance the fences — every opening run of backticks or tildes needs a closing run at least as long — and the field reads normally.`
|
|
3662
|
-
]
|
|
3663
|
-
};
|
|
3664
|
-
}
|
|
3665
|
-
const unregistered = field.names.filter((p) => !known.has(p));
|
|
3666
|
-
if (unregistered.length > 0) {
|
|
3667
|
-
const caseHints = unregistered.map((p) => {
|
|
3668
|
-
const row = [...known].find((k) => k.toLowerCase() === p.toLowerCase());
|
|
3669
|
-
return row ? `\`${forMessage(p)}\` differs from the registered \`${forMessage(row)}\` only in case` : null;
|
|
3670
|
-
}).filter((h) => h !== null);
|
|
3671
|
-
errors.push(`issue-validation project registry: the \`**Project:**\` field declares ${unregistered.map(forMessage).join(", ")} — no such row in \`.vinaya/projects.md\`, which is the authority for valid project names (registered: ${registeredList}). Fix the name, or register the project with \`vinaya init product <name> --path <folder>\` first; an unregistered project has no specs to read and no per-project state to update.${caseHints.length > 0 ? ` Note: ${caseHints.join("; ")} — project names are matched exactly, because every downstream consumer compares them literally.` : ""} This reads the same field \`projectsFromBody\` derives the task's project from, so a name here that is not a row is a task that resolves to a project that does not exist.`);
|
|
3672
|
-
}
|
|
3673
|
-
if (field.names.length === 0) {
|
|
3674
|
-
const residue = field.unparsed.length > 0 ? ` — ${residueForMessage(field.unparsed)}` : " — the field is empty";
|
|
3675
|
-
errors.push(`issue-validation project registry: the \`**Project:**\` field is present but resolves to no project name${residue} (registered: ${registeredList}). A project name is a slug (\`[a-z0-9][a-z0-9-]*\`, matched exactly); prose, a parenthetical, or a sentence in this field resolves to no project at all, and this gate cannot check a name it never receives — which is how a declaration like this used to pass. Write the registered name on its own, or register the project with \`vinaya init product <name> --path <folder>\` first. If the task genuinely touches no registered project, omit the field rather than explaining its absence inside it — \`checkIssueRationale\` already requires the \`Project(s) + blast radius\` narrative field for that.`);
|
|
3676
|
-
} else if (field.unparsed.length > 0) {
|
|
3677
|
-
errors.push(`issue-validation project registry: the \`**Project:**\` field declares a value that is not a project name — ${residueForMessage(field.unparsed)} (registered: ${registeredList}). The rest of the field parsed, so this is a name the gate silently could not check rather than a field it could not read at all. A project name is a slug (\`[a-z0-9][a-z0-9-]*\`, matched exactly); write it on its own, or drop it if it names no project.`);
|
|
3577
|
+
function findWholeWordLine(content, term) {
|
|
3578
|
+
const lines = content.split(`
|
|
3579
|
+
`);
|
|
3580
|
+
let lineNo = 0;
|
|
3581
|
+
for (const line of lines) {
|
|
3582
|
+
lineNo++;
|
|
3583
|
+
if (containsWholeWord(line, term))
|
|
3584
|
+
return lineNo;
|
|
3678
3585
|
}
|
|
3679
|
-
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
3680
|
-
}
|
|
3681
|
-
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;
|
|
3682
|
-
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
3683
|
-
|
|
3684
|
-
// ../../packages/aeg-core/src/task-branch-identity.ts
|
|
3685
|
-
var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
|
|
3686
|
-
var TRANCHE_BRANCH_PATTERN = /^task\/([^/]+)\/([^/]+)$/;
|
|
3687
|
-
function parseTaskBranchIdentity(branch) {
|
|
3688
|
-
const issueMatch = ISSUE_BRANCH_PATTERN.exec(branch);
|
|
3689
|
-
if (issueMatch)
|
|
3690
|
-
return { kind: "issue", issueNumber: Number(issueMatch[1]) };
|
|
3691
|
-
const trancheMatch = TRANCHE_BRANCH_PATTERN.exec(branch);
|
|
3692
|
-
if (trancheMatch)
|
|
3693
|
-
return { kind: "tranche", tranche: trancheMatch[1], taskId: trancheMatch[2] };
|
|
3694
3586
|
return null;
|
|
3695
3587
|
}
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
3588
|
+
function definesOrLinksGlossary(content, term) {
|
|
3589
|
+
const escaped = escapeTerm(term);
|
|
3590
|
+
const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
|
|
3591
|
+
if (definesInline)
|
|
3592
|
+
return true;
|
|
3593
|
+
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3703
3594
|
}
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
const
|
|
3707
|
-
|
|
3708
|
-
if (!
|
|
3709
|
-
continue;
|
|
3710
|
-
if (e.facts.stateReason === "not_planned")
|
|
3595
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
3596
|
+
const findings = [];
|
|
3597
|
+
for (const file of files) {
|
|
3598
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3599
|
+
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
3711
3600
|
continue;
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3601
|
+
const scrubbed = stripNonProse(file.path, file.content);
|
|
3602
|
+
for (const term of glossaryTerms) {
|
|
3603
|
+
const line = findWholeWordLine(scrubbed, term);
|
|
3604
|
+
if (line === null)
|
|
3715
3605
|
continue;
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3606
|
+
if (definesOrLinksGlossary(scrubbed, term))
|
|
3607
|
+
continue;
|
|
3608
|
+
findings.push({
|
|
3609
|
+
file: file.path,
|
|
3610
|
+
line,
|
|
3611
|
+
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3612
|
+
blocking: false
|
|
3723
3613
|
});
|
|
3724
3614
|
}
|
|
3725
3615
|
}
|
|
3726
|
-
|
|
3727
|
-
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
3728
|
-
return {
|
|
3729
|
-
check: "A1",
|
|
3730
|
-
status,
|
|
3731
|
-
failures,
|
|
3732
|
-
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
3733
|
-
};
|
|
3616
|
+
return findings;
|
|
3734
3617
|
}
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3618
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g;
|
|
3619
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g;
|
|
3620
|
+
function extractComments(path, content) {
|
|
3621
|
+
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3622
|
+
return content.replace(/[^\n]/g, "");
|
|
3623
|
+
let state = "code";
|
|
3624
|
+
let out = "";
|
|
3625
|
+
const n = content.length;
|
|
3626
|
+
let i = 0;
|
|
3627
|
+
const blank = (ch) => ch === `
|
|
3628
|
+
` ? `
|
|
3629
|
+
` : " ";
|
|
3630
|
+
while (i < n) {
|
|
3631
|
+
const c = content[i];
|
|
3632
|
+
const next = i + 1 < n ? content[i + 1] : "";
|
|
3633
|
+
if (state === "code") {
|
|
3634
|
+
if (c === "/" && next === "/") {
|
|
3635
|
+
state = "line-comment";
|
|
3636
|
+
out += c;
|
|
3637
|
+
i++;
|
|
3638
|
+
continue;
|
|
3639
|
+
}
|
|
3640
|
+
if (c === "/" && next === "*") {
|
|
3641
|
+
state = "block-comment";
|
|
3642
|
+
out += c;
|
|
3643
|
+
i++;
|
|
3644
|
+
continue;
|
|
3645
|
+
}
|
|
3646
|
+
if (c === "'") {
|
|
3647
|
+
state = "single-quote";
|
|
3648
|
+
out += blank(c);
|
|
3649
|
+
i++;
|
|
3650
|
+
continue;
|
|
3651
|
+
}
|
|
3652
|
+
if (c === '"') {
|
|
3653
|
+
state = "double-quote";
|
|
3654
|
+
out += blank(c);
|
|
3655
|
+
i++;
|
|
3656
|
+
continue;
|
|
3657
|
+
}
|
|
3658
|
+
if (c === "`") {
|
|
3659
|
+
state = "template";
|
|
3660
|
+
out += blank(c);
|
|
3661
|
+
i++;
|
|
3662
|
+
continue;
|
|
3663
|
+
}
|
|
3664
|
+
out += blank(c);
|
|
3665
|
+
i++;
|
|
3739
3666
|
continue;
|
|
3740
|
-
if (e.facts.prState === "merged" && e.facts.issueState !== "closed") {
|
|
3741
|
-
failures.push({
|
|
3742
|
-
code: "auto-close-misfire",
|
|
3743
|
-
issue: e.task.issue,
|
|
3744
|
-
tranche: e.trancheSlug,
|
|
3745
|
-
task: e.task.id,
|
|
3746
|
-
reason: "Closing PR is merged but Issue is still open (GitHub auto-close misfire)",
|
|
3747
|
-
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
3748
|
-
});
|
|
3749
3667
|
}
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
const failures = [];
|
|
3762
|
-
for (const e of entries) {
|
|
3763
|
-
if (e.task.issue === null)
|
|
3668
|
+
if (state === "line-comment") {
|
|
3669
|
+
if (c === `
|
|
3670
|
+
`) {
|
|
3671
|
+
state = "code";
|
|
3672
|
+
out += `
|
|
3673
|
+
`;
|
|
3674
|
+
i++;
|
|
3675
|
+
continue;
|
|
3676
|
+
}
|
|
3677
|
+
out += c;
|
|
3678
|
+
i++;
|
|
3764
3679
|
continue;
|
|
3765
|
-
if (e.facts === undefined) {
|
|
3766
|
-
failures.push({
|
|
3767
|
-
code: "phantom-issue-ref",
|
|
3768
|
-
issue: e.task.issue,
|
|
3769
|
-
tranche: e.trancheSlug,
|
|
3770
|
-
task: e.task.id,
|
|
3771
|
-
reason: `Issue #${e.task.issue} in topology does not resolve to a real GitHub Issue`
|
|
3772
|
-
});
|
|
3773
3680
|
}
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
continue;
|
|
3782
|
-
const topologySet = topologyIssuesBySlug.get(slug) ?? new Set;
|
|
3783
|
-
for (const num of openNums) {
|
|
3784
|
-
if (!topologySet.has(num)) {
|
|
3785
|
-
failures.push({
|
|
3786
|
-
code: "orphan-task",
|
|
3787
|
-
issue: num,
|
|
3788
|
-
tranche: slug,
|
|
3789
|
-
reason: `Issue #${num} is open and labeled ${trancheLabel(slug)} but does not appear in the topology file`
|
|
3790
|
-
});
|
|
3681
|
+
if (state === "block-comment") {
|
|
3682
|
+
if (c === "*" && next === "/") {
|
|
3683
|
+
out += c;
|
|
3684
|
+
out += next;
|
|
3685
|
+
state = "code";
|
|
3686
|
+
i += 2;
|
|
3687
|
+
continue;
|
|
3791
3688
|
}
|
|
3689
|
+
out += c === `
|
|
3690
|
+
` ? `
|
|
3691
|
+
` : c;
|
|
3692
|
+
i++;
|
|
3693
|
+
continue;
|
|
3792
3694
|
}
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
...result,
|
|
3801
|
-
status: "info",
|
|
3802
|
-
note: result.note ?? "T2 findings are non-blocking outside plan PRs (point-of-power principle) — see aeg-root/enforcement.md."
|
|
3803
|
-
};
|
|
3804
|
-
}
|
|
3805
|
-
function checkT3(entries, ciTrancheSlug, enrichedEntries, forgeUnavailableSlugs) {
|
|
3806
|
-
const preEnforcement = new Set;
|
|
3807
|
-
if (enrichedEntries) {
|
|
3808
|
-
for (const e of enrichedEntries) {
|
|
3809
|
-
if (isGrandfathered(e.facts?.closedAt) || isGrandfathered(e.facts?.mergedAt)) {
|
|
3810
|
-
preEnforcement.add(e.trancheSlug);
|
|
3695
|
+
const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
|
|
3696
|
+
if (c === "\\") {
|
|
3697
|
+
out += blank(c);
|
|
3698
|
+
i++;
|
|
3699
|
+
if (i < n) {
|
|
3700
|
+
out += blank(content[i]);
|
|
3701
|
+
i++;
|
|
3811
3702
|
}
|
|
3703
|
+
continue;
|
|
3812
3704
|
}
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
continue;
|
|
3819
|
-
if (forgeUnavailableSlugs?.has(e.trancheSlug)) {
|
|
3820
|
-
failures.push({
|
|
3821
|
-
code: "tbd-in-active-tranche",
|
|
3822
|
-
issue: null,
|
|
3823
|
-
tranche: e.trancheSlug,
|
|
3824
|
-
task: e.task.id,
|
|
3825
|
-
reason: `Task ${e.task.id} in active tranche has no Issue ref (#TBD or empty), but forge data for tranche "${e.trancheSlug}" was unavailable — cannot evaluate grandfather status, not silently failed`,
|
|
3826
|
-
grandfathered: true
|
|
3827
|
-
});
|
|
3828
|
-
continue;
|
|
3829
|
-
}
|
|
3830
|
-
failures.push({
|
|
3831
|
-
code: "tbd-in-active-tranche",
|
|
3832
|
-
issue: null,
|
|
3833
|
-
tranche: e.trancheSlug,
|
|
3834
|
-
task: e.task.id,
|
|
3835
|
-
reason: `Task ${e.task.id} in active tranche has no Issue ref (#TBD or empty) — the model requires all active tasks to have Issue numbers`,
|
|
3836
|
-
grandfathered: preEnforcement.has(e.trancheSlug)
|
|
3837
|
-
});
|
|
3705
|
+
if (c === closer) {
|
|
3706
|
+
state = "code";
|
|
3707
|
+
out += blank(c);
|
|
3708
|
+
i++;
|
|
3709
|
+
continue;
|
|
3838
3710
|
}
|
|
3711
|
+
out += blank(c);
|
|
3712
|
+
i++;
|
|
3839
3713
|
}
|
|
3840
|
-
|
|
3841
|
-
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
3842
|
-
return {
|
|
3843
|
-
check: "T3",
|
|
3844
|
-
status,
|
|
3845
|
-
failures,
|
|
3846
|
-
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
3847
|
-
};
|
|
3714
|
+
return out;
|
|
3848
3715
|
}
|
|
3849
|
-
function
|
|
3850
|
-
const
|
|
3851
|
-
|
|
3852
|
-
|
|
3716
|
+
function checkSourceComments(files, allowlist = []) {
|
|
3717
|
+
const findings = [];
|
|
3718
|
+
const allowed = new Set(allowlist);
|
|
3719
|
+
const patterns = [
|
|
3720
|
+
{ pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
|
|
3721
|
+
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3722
|
+
];
|
|
3723
|
+
for (const file of files) {
|
|
3724
|
+
if (!file.path.endsWith(".ts"))
|
|
3853
3725
|
continue;
|
|
3854
|
-
if (
|
|
3726
|
+
if (allowed.has(file.path))
|
|
3855
3727
|
continue;
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
tranche: e.trancheSlug,
|
|
3867
|
-
task: e.task.id,
|
|
3868
|
-
reason: `INTERNAL: parsed a self-dependency (depends-on ${dep}) — this is a parser bug in parseRationaleDeps, not a real dependency. Please report it upstream.`
|
|
3869
|
-
});
|
|
3870
|
-
continue;
|
|
3871
|
-
}
|
|
3872
|
-
const depFacts = depEntry.facts;
|
|
3873
|
-
const depClosed = depFacts?.issueState === "closed";
|
|
3874
|
-
if (!depClosed) {
|
|
3875
|
-
failures.push({
|
|
3876
|
-
code: "dispatched-on-unmet-deps",
|
|
3877
|
-
issue: e.task.issue,
|
|
3878
|
-
tranche: e.trancheSlug,
|
|
3879
|
-
task: e.task.id,
|
|
3880
|
-
reason: `Task has open PR but depends-on ${dep} (issue #${depEntry.task.issue ?? "?"}) is not closed`
|
|
3728
|
+
const comments = extractComments(file.path, file.content);
|
|
3729
|
+
for (const { pattern, what } of patterns) {
|
|
3730
|
+
pattern.lastIndex = 0;
|
|
3731
|
+
let match = pattern.exec(comments);
|
|
3732
|
+
while (match !== null) {
|
|
3733
|
+
findings.push({
|
|
3734
|
+
file: file.path,
|
|
3735
|
+
line: lineAt(comments, match.index),
|
|
3736
|
+
message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
|
|
3737
|
+
blocking: false
|
|
3881
3738
|
});
|
|
3739
|
+
match = pattern.exec(comments);
|
|
3882
3740
|
}
|
|
3883
3741
|
}
|
|
3884
3742
|
}
|
|
3885
|
-
return
|
|
3743
|
+
return findings;
|
|
3886
3744
|
}
|
|
3887
|
-
function
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3745
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
3746
|
+
return [
|
|
3747
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3748
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
3749
|
+
];
|
|
3892
3750
|
}
|
|
3893
|
-
function
|
|
3894
|
-
const
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
|
|
3902
|
-
...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
|
|
3903
|
-
...checkPartsCiteDefinedObjectives(issue.body).errors
|
|
3904
|
-
];
|
|
3905
|
-
if (errors.length === 0)
|
|
3906
|
-
continue;
|
|
3907
|
-
failures.push({
|
|
3908
|
-
code: "missing-rationale-field",
|
|
3909
|
-
issue: issue.number,
|
|
3910
|
-
tranche: slug,
|
|
3911
|
-
reason: `Issue #${issue.number} fails the rationale gate: ${errors.join(" | ")}`,
|
|
3912
|
-
grandfathered: grandfatheredIssues.has(issue.number)
|
|
3913
|
-
});
|
|
3914
|
-
}
|
|
3751
|
+
function parseGlossaryTerms(glossaryContent) {
|
|
3752
|
+
const terms = [];
|
|
3753
|
+
const re = /^\*\*(.+?)\*\* —/gm;
|
|
3754
|
+
let match = re.exec(glossaryContent);
|
|
3755
|
+
while (match !== null) {
|
|
3756
|
+
if (match[1] !== undefined)
|
|
3757
|
+
terms.push(match[1]);
|
|
3758
|
+
match = re.exec(glossaryContent);
|
|
3915
3759
|
}
|
|
3916
|
-
|
|
3917
|
-
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
3918
|
-
return {
|
|
3919
|
-
check: "R1",
|
|
3920
|
-
status,
|
|
3921
|
-
failures,
|
|
3922
|
-
note: status === "info" ? `${failures.length} grandfathered task Issue(s) predate this check's grammar (rationale fields and/or the project registry)` : undefined
|
|
3923
|
-
};
|
|
3760
|
+
return terms;
|
|
3924
3761
|
}
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3762
|
+
|
|
3763
|
+
// ../../packages/aeg-core/src/quoted-command.ts
|
|
3764
|
+
var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
|
|
3765
|
+
var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
3766
|
+
var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
|
|
3767
|
+
var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
|
|
3768
|
+
function isValidCitedFilePath(path) {
|
|
3769
|
+
if (path.length === 0)
|
|
3770
|
+
return false;
|
|
3771
|
+
if (path.startsWith("/") || path.startsWith("\\"))
|
|
3772
|
+
return false;
|
|
3773
|
+
if (/^[A-Za-z]:[\\/]/.test(path))
|
|
3774
|
+
return false;
|
|
3775
|
+
return !path.split(/[\\/]+/).includes("..");
|
|
3776
|
+
}
|
|
3777
|
+
function quotedCommandLineAt(content, index) {
|
|
3778
|
+
let line = 1;
|
|
3779
|
+
for (let i = 0;i < index; i++) {
|
|
3780
|
+
if (content.charCodeAt(i) === 10)
|
|
3781
|
+
line++;
|
|
3942
3782
|
}
|
|
3943
|
-
return
|
|
3944
|
-
check: "L1",
|
|
3945
|
-
status: "info",
|
|
3946
|
-
failures,
|
|
3947
|
-
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
3948
|
-
};
|
|
3949
|
-
}
|
|
3950
|
-
function checkL3(files) {
|
|
3951
|
-
const active = files.filter((f) => !f.archived);
|
|
3952
|
-
return {
|
|
3953
|
-
check: "L3",
|
|
3954
|
-
status: "info",
|
|
3955
|
-
failures: [],
|
|
3956
|
-
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
3957
|
-
};
|
|
3783
|
+
return line;
|
|
3958
3784
|
}
|
|
3959
|
-
function
|
|
3960
|
-
const
|
|
3961
|
-
const
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
return
|
|
3785
|
+
function extractQuotedText(raw) {
|
|
3786
|
+
const trimmed = raw.trim();
|
|
3787
|
+
const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
|
|
3788
|
+
if (fenced)
|
|
3789
|
+
return (fenced[1] ?? "").trim();
|
|
3790
|
+
const inline = /^`([^`]+)`$/.exec(trimmed);
|
|
3791
|
+
if (inline)
|
|
3792
|
+
return (inline[1] ?? "").trim();
|
|
3793
|
+
return trimmed;
|
|
3968
3794
|
}
|
|
3969
|
-
function
|
|
3970
|
-
const
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
}
|
|
3795
|
+
function findQuotesInFile(path, content) {
|
|
3796
|
+
const masked = maskCode(content);
|
|
3797
|
+
const quotes = [];
|
|
3798
|
+
START_PATTERN.lastIndex = 0;
|
|
3799
|
+
let start = START_PATTERN.exec(masked);
|
|
3800
|
+
while (start !== null) {
|
|
3801
|
+
const citedFile = start[1];
|
|
3802
|
+
const innerStart = start.index + start[0].length;
|
|
3803
|
+
const end = END_PATTERN.exec(masked.slice(innerStart));
|
|
3804
|
+
if (end === null) {
|
|
3805
|
+
START_PATTERN.lastIndex = innerStart;
|
|
3806
|
+
start = START_PATTERN.exec(masked);
|
|
3807
|
+
continue;
|
|
3983
3808
|
}
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
if (!referenced.has(expectedIssue)) {
|
|
3991
|
-
return {
|
|
3992
|
-
ok: false,
|
|
3993
|
-
expectedIssue,
|
|
3994
|
-
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
3995
|
-
};
|
|
3809
|
+
const innerEnd = innerStart + end.index;
|
|
3810
|
+
if (isValidCitedFilePath(citedFile)) {
|
|
3811
|
+
const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
|
|
3812
|
+
if (quotedText.length > 0) {
|
|
3813
|
+
quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
|
|
3814
|
+
}
|
|
3996
3815
|
}
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
const trancheSlug = ref.tranche;
|
|
4000
|
-
const taskId = ref.taskId;
|
|
4001
|
-
const trancheFile = trancheFiles.find((f) => f.slug === trancheSlug);
|
|
4002
|
-
if (!trancheFile) {
|
|
4003
|
-
return {
|
|
4004
|
-
ok: false,
|
|
4005
|
-
message: `closes-n: branch "${branch}" references tranche "${trancheSlug}" but no topology file found at aeg-root/tranches/${trancheSlug}.md. Ensure the tranche file exists before opening the PR.`
|
|
4006
|
-
};
|
|
4007
|
-
}
|
|
4008
|
-
const task = trancheFile.tranche.tasks.find((t) => t.id === taskId);
|
|
4009
|
-
if (!task) {
|
|
4010
|
-
return {
|
|
4011
|
-
ok: false,
|
|
4012
|
-
message: `closes-n: branch "${branch}" references task "${taskId}" not found in ${trancheSlug} topology. Verify the task ID matches the tranche file.`
|
|
4013
|
-
};
|
|
3816
|
+
START_PATTERN.lastIndex = innerEnd + end[0].length;
|
|
3817
|
+
start = START_PATTERN.exec(masked);
|
|
4014
3818
|
}
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
3819
|
+
return quotes;
|
|
3820
|
+
}
|
|
3821
|
+
function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
|
|
3822
|
+
const quotes = [];
|
|
3823
|
+
for (const file of files) {
|
|
3824
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3825
|
+
if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
|
|
3826
|
+
continue;
|
|
3827
|
+
quotes.push(...findQuotesInFile(file.path, file.content));
|
|
4020
3828
|
}
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
3829
|
+
return quotes;
|
|
3830
|
+
}
|
|
3831
|
+
function evaluateCitedQuotes(citedQuotes, citedFileContents) {
|
|
3832
|
+
const findings = [];
|
|
3833
|
+
for (const quote of citedQuotes) {
|
|
3834
|
+
const content = citedFileContents.get(quote.citedFile);
|
|
3835
|
+
if (content === undefined) {
|
|
3836
|
+
findings.push({
|
|
3837
|
+
file: quote.file,
|
|
3838
|
+
line: quote.line,
|
|
3839
|
+
citedFile: quote.citedFile,
|
|
3840
|
+
quotedText: quote.quotedText,
|
|
3841
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
|
|
3842
|
+
});
|
|
3843
|
+
continue;
|
|
3844
|
+
}
|
|
3845
|
+
if (!content.includes(quote.quotedText)) {
|
|
3846
|
+
findings.push({
|
|
3847
|
+
file: quote.file,
|
|
3848
|
+
line: quote.line,
|
|
3849
|
+
citedFile: quote.citedFile,
|
|
3850
|
+
quotedText: quote.quotedText,
|
|
3851
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
|
|
3852
|
+
});
|
|
3853
|
+
}
|
|
4028
3854
|
}
|
|
4029
|
-
return
|
|
3855
|
+
return findings;
|
|
4030
3856
|
}
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
3857
|
+
|
|
3858
|
+
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3859
|
+
function hasRationaleField(body, labelPattern) {
|
|
3860
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
3861
|
+
return re.test(body);
|
|
4034
3862
|
}
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
3863
|
+
var RATIONALE_FIELDS = [
|
|
3864
|
+
{ name: "Boundary", pattern: "Boundary" },
|
|
3865
|
+
{ name: "Sizing", pattern: "Sizing" },
|
|
3866
|
+
{ name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
|
|
3867
|
+
{ name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
|
|
3868
|
+
{ name: "Traps to avoid", pattern: "Traps" },
|
|
3869
|
+
{ name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
|
|
3870
|
+
{ name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
|
|
3871
|
+
{ name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
|
|
3872
|
+
];
|
|
3873
|
+
var DEPENDENCY_RATIONALE_FIELD_NAME = "Dependency rationale";
|
|
3874
|
+
function checkIssueRationale(body) {
|
|
3875
|
+
const errors = [];
|
|
3876
|
+
for (const f of RATIONALE_FIELDS) {
|
|
3877
|
+
if (!hasRationaleField(body, f.pattern)) {
|
|
3878
|
+
errors.push(`issue-validation ${f.name}: rationale field not found in the Issue body — every task Issue carries the full Planner's rationale (aeg-root/contracts/planner-brief.md).`);
|
|
3879
|
+
continue;
|
|
3880
|
+
}
|
|
3881
|
+
if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
|
|
3882
|
+
errors.push(`issue-validation ${f.name}: rationale field found, but not in the form amend-deps requires — ` + "write `**Dependency rationale** — …`, not `**Dependency rationale:** …`. " + "`amendRationaleDeps` (the only sanctioned way to edit Depends-on/Conflicts-with) locates this " + "section by the exact anchor `**Dependency rationale**`; a colon inside the bold breaks that match " + "and the Issue becomes unamendable.");
|
|
3883
|
+
}
|
|
4045
3884
|
}
|
|
4046
|
-
|
|
4047
|
-
if (bodyNums.length === 0)
|
|
4048
|
-
return { issue: null, extraIssues: [], outsideHeader: false };
|
|
4049
|
-
const issue = headerNums.length > 0 ? headerNums[0] : bodyNums[0];
|
|
4050
|
-
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: headerNums.length === 0 };
|
|
3885
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4051
3886
|
}
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
3887
|
+
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3888
|
+
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3889
|
+
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3890
|
+
return { status: "pass", errors: [] };
|
|
3891
|
+
const result = objectivesOf(body);
|
|
3892
|
+
if (result.ok)
|
|
3893
|
+
return { status: "pass", errors: [] };
|
|
3894
|
+
return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
|
|
4057
3895
|
}
|
|
4058
|
-
function
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
3896
|
+
function topLevelSectionText(body, headingName) {
|
|
3897
|
+
const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
|
|
3898
|
+
const heading = headingRe.exec(body);
|
|
3899
|
+
if (!heading)
|
|
3900
|
+
return null;
|
|
3901
|
+
const afterHeading = body.slice(heading.index + heading[0].length);
|
|
3902
|
+
const next = /^##[ \t]/m.exec(afterHeading);
|
|
3903
|
+
return next ? afterHeading.slice(0, next.index) : afterHeading;
|
|
4064
3904
|
}
|
|
4065
|
-
function
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
3905
|
+
function partHasBacktickedPath(text) {
|
|
3906
|
+
let i = 0;
|
|
3907
|
+
while (i < text.length) {
|
|
3908
|
+
const start = text.indexOf("`", i);
|
|
3909
|
+
if (start === -1)
|
|
3910
|
+
return false;
|
|
3911
|
+
const end = text.indexOf("`", start + 1);
|
|
3912
|
+
if (end === -1)
|
|
3913
|
+
return false;
|
|
3914
|
+
if (text.slice(start + 1, end).includes("/"))
|
|
3915
|
+
return true;
|
|
3916
|
+
i = end + 1;
|
|
3917
|
+
}
|
|
3918
|
+
return false;
|
|
4069
3919
|
}
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
const judged = patchIdOf(echoed.headSha);
|
|
4074
|
-
const current = patchIdOf(headSha);
|
|
4075
|
-
if (judged === null || current === null)
|
|
4076
|
-
return false;
|
|
4077
|
-
return judged === current;
|
|
3920
|
+
var PART_MIN_WORDS_OUTSIDE_BACKTICKS = 3;
|
|
3921
|
+
function stripPartBackticks(text) {
|
|
3922
|
+
return text.replace(/`[^`\n]*`/g, " ");
|
|
4078
3923
|
}
|
|
4079
|
-
function
|
|
4080
|
-
|
|
4081
|
-
return true;
|
|
4082
|
-
if (!echoed.baseSha)
|
|
4083
|
-
return false;
|
|
4084
|
-
return currentBase.toLowerCase().startsWith(echoed.baseSha.toLowerCase());
|
|
3924
|
+
function partWordCount(text) {
|
|
3925
|
+
return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
|
|
4085
3926
|
}
|
|
4086
|
-
function
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
3927
|
+
function looksLikeFilePath(entry) {
|
|
3928
|
+
const stripped = entry.replace(/\/\*\*?$/, "");
|
|
3929
|
+
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3930
|
+
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3931
|
+
return extMatch !== null && extMatch.index > 0;
|
|
4090
3932
|
}
|
|
4091
|
-
function
|
|
4092
|
-
|
|
4093
|
-
return currentOrdinal === 0;
|
|
4094
|
-
return echoed.rulingOrdinal === currentOrdinal;
|
|
3933
|
+
function splitGlobList(raw) {
|
|
3934
|
+
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
4095
3935
|
}
|
|
4096
|
-
function
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
3936
|
+
function parseIssueSurface(body) {
|
|
3937
|
+
const section = topLevelSectionText(body, "Surface");
|
|
3938
|
+
if (section === null)
|
|
3939
|
+
return { ok: false, errors: ["no `## Surface` heading found in the body."] };
|
|
3940
|
+
const inLine = /^in:\s*(.+)$/im.exec(section);
|
|
3941
|
+
const outLine = /^out:\s*(.+)$/im.exec(section);
|
|
3942
|
+
const errors = [];
|
|
3943
|
+
if (!inLine)
|
|
3944
|
+
errors.push("`## Surface` has no `in:` line.");
|
|
3945
|
+
if (!outLine)
|
|
3946
|
+
errors.push("`## Surface` has no `out:` line.");
|
|
3947
|
+
if (errors.length > 0)
|
|
3948
|
+
return { ok: false, errors };
|
|
3949
|
+
const inGlobs = splitGlobList(inLine[1]);
|
|
3950
|
+
const outGlobs = splitGlobList(outLine[1]);
|
|
3951
|
+
for (const g of [...inGlobs, ...outGlobs]) {
|
|
3952
|
+
if (looksLikeFilePath(g)) {
|
|
3953
|
+
errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
if (inGlobs.length === 0)
|
|
3957
|
+
errors.push("`## Surface`'s `in:` line resolved to zero globs.");
|
|
3958
|
+
if (errors.length > 0)
|
|
3959
|
+
return { ok: false, errors };
|
|
3960
|
+
return { ok: true, value: { in: inGlobs, out: outGlobs } };
|
|
4100
3961
|
}
|
|
4101
|
-
function
|
|
4102
|
-
|
|
3962
|
+
function globCoversPath(glob, path) {
|
|
3963
|
+
const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
3964
|
+
const p = path.replace(/\/+$/, "");
|
|
3965
|
+
if (g === "*")
|
|
3966
|
+
return !p.includes("/");
|
|
3967
|
+
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
4103
3968
|
}
|
|
4104
|
-
function
|
|
4105
|
-
const
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
const
|
|
4109
|
-
const
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
3969
|
+
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
3970
|
+
const surface = parseIssueSurface(body);
|
|
3971
|
+
if (!surface.ok)
|
|
3972
|
+
return { status: "pass", errors: [] };
|
|
3973
|
+
const errors = [];
|
|
3974
|
+
for (const glob of surface.value.in) {
|
|
3975
|
+
if (!resolvesToFile(glob)) {
|
|
3976
|
+
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.`);
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3980
|
+
}
|
|
3981
|
+
function checkSurfaceScope(changedFiles, outGlobs) {
|
|
3982
|
+
if (outGlobs.length === 0)
|
|
3983
|
+
return { ok: true };
|
|
3984
|
+
const violations = [];
|
|
3985
|
+
for (const file of changedFiles) {
|
|
3986
|
+
const glob = outGlobs.find((g) => globCoversPath(g, file));
|
|
3987
|
+
if (glob)
|
|
3988
|
+
violations.push({ file, glob });
|
|
3989
|
+
}
|
|
3990
|
+
return violations.length > 0 ? { ok: false, violations } : { ok: true };
|
|
3991
|
+
}
|
|
3992
|
+
var ISSUE_PART_LINE_RE = /^Part\s+(\d+)\s*\(([^)]*)\)\s*[-—–]\s*(.*)$/i;
|
|
3993
|
+
function parseIssueParts(body) {
|
|
3994
|
+
const section = topLevelSectionText(body, "Parts");
|
|
3995
|
+
if (section === null)
|
|
3996
|
+
return { ok: false, errors: ["no `## Parts` heading found in the body."] };
|
|
3997
|
+
const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
|
|
3998
|
+
const parts = [];
|
|
3999
|
+
const errors = [];
|
|
4000
|
+
for (const line of lines) {
|
|
4001
|
+
const m = ISSUE_PART_LINE_RE.exec(line);
|
|
4002
|
+
if (!m) {
|
|
4003
|
+
errors.push(`"${line}" is not a well-formed Parts line — expected \`Part <n> (<refs>) — <outcome>\`.`);
|
|
4004
|
+
continue;
|
|
4005
|
+
}
|
|
4006
|
+
const n = Number.parseInt(m[1], 10);
|
|
4007
|
+
const refs = m[2];
|
|
4008
|
+
const text = m[3].trim();
|
|
4009
|
+
if (text.length === 0) {
|
|
4010
|
+
errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
|
|
4011
|
+
continue;
|
|
4012
|
+
}
|
|
4013
|
+
if (partHasBacktickedPath(text) && partWordCount(stripPartBackticks(text)) < PART_MIN_WORDS_OUTSIDE_BACKTICKS) {
|
|
4014
|
+
errors.push(`Part ${n} is little more than a file path — a Part names an outcome and symbols, never a bare path.`);
|
|
4015
|
+
continue;
|
|
4016
|
+
}
|
|
4017
|
+
const objectiveIds = [...refs.matchAll(/O(\d+)/g)].map((r) => Number.parseInt(r[1], 10));
|
|
4018
|
+
parts.push({ n, objectiveIds, text });
|
|
4019
|
+
}
|
|
4020
|
+
if (parts.length === 0) {
|
|
4021
|
+
errors.push("the `## Parts` section has no well-formed `Part <n> (<refs>) — <outcome>` lines.");
|
|
4022
|
+
}
|
|
4023
|
+
if (errors.length > 0)
|
|
4024
|
+
return { ok: false, errors };
|
|
4025
|
+
return { ok: true, value: parts };
|
|
4026
|
+
}
|
|
4027
|
+
function checkPartsCiteDefinedObjectives(body) {
|
|
4028
|
+
const parts = parseIssueParts(body);
|
|
4029
|
+
const objectives = objectivesOf(body);
|
|
4030
|
+
if (!parts.ok || !objectives.ok)
|
|
4031
|
+
return { status: "pass", errors: [] };
|
|
4032
|
+
const definedIds = new Set(objectives.objectives.map((o) => Number.parseInt(o.id.slice(1), 10)));
|
|
4033
|
+
const errors = [];
|
|
4034
|
+
for (const part of parts.value) {
|
|
4035
|
+
for (const objectiveId of part.objectiveIds) {
|
|
4036
|
+
if (!definedIds.has(objectiveId)) {
|
|
4037
|
+
errors.push(`issue-validation Parts: Part ${part.n} cites O${objectiveId}, which the Issue's own \`## Objectives\` section does not define.`);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4042
|
+
}
|
|
4043
|
+
function isTaskIssueLabelSet(labels) {
|
|
4044
|
+
return hasLabel("tranche", labels);
|
|
4045
|
+
}
|
|
4046
|
+
function checkTrancheLabelPresence(_body, _labels) {
|
|
4047
|
+
return { status: "pass", errors: [] };
|
|
4048
|
+
}
|
|
4049
|
+
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4050
|
+
if (!isTaskIssueLabelSet(labels))
|
|
4051
|
+
return { status: "pass", errors: [] };
|
|
4052
|
+
if (resolvedMilestoneTitle === null)
|
|
4053
|
+
return { status: "pass", errors: [] };
|
|
4054
|
+
if (currentMilestoneTitle === resolvedMilestoneTitle)
|
|
4055
|
+
return { status: "pass", errors: [] };
|
|
4116
4056
|
return {
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
objectivesVersion,
|
|
4122
|
-
rulingOrdinal,
|
|
4123
|
-
policyDigest: policyDigestBound
|
|
4057
|
+
status: "fail",
|
|
4058
|
+
errors: [
|
|
4059
|
+
`issue-validation milestone attach: this task Issue's tranche label resolves to Milestone "${resolvedMilestoneTitle}", but its live Milestone is ${currentMilestoneTitle === null ? "unset" : `"${currentMilestoneTitle}"`} — attach it to "${resolvedMilestoneTitle}".`
|
|
4060
|
+
]
|
|
4124
4061
|
};
|
|
4125
4062
|
}
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
});
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4063
|
+
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4064
|
+
function isControlCodePoint(codePoint) {
|
|
4065
|
+
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4066
|
+
}
|
|
4067
|
+
function isDisplayControlCodePoint(codePoint) {
|
|
4068
|
+
return codePoint >= 8203 && codePoint <= 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
|
|
4069
|
+
}
|
|
4070
|
+
var MESSAGE_VALUE_COUNT_MAX = 5;
|
|
4071
|
+
function residueForMessage(values) {
|
|
4072
|
+
const shown = values.slice(0, MESSAGE_VALUE_COUNT_MAX).map((v) => `\`${forMessage(v)}\``);
|
|
4073
|
+
const rest = values.length - shown.length;
|
|
4074
|
+
return rest > 0 ? `${shown.join(", ")} and ${rest} more` : shown.join(", ");
|
|
4075
|
+
}
|
|
4076
|
+
var MESSAGE_VALUE_MAX = 64;
|
|
4077
|
+
function forMessage(value) {
|
|
4078
|
+
const kept = [];
|
|
4079
|
+
for (const ch of value.replace(/\s+/g, " ")) {
|
|
4080
|
+
const codePoint = ch.codePointAt(0) ?? 0;
|
|
4081
|
+
if (isControlCodePoint(codePoint) || isDisplayControlCodePoint(codePoint))
|
|
4082
|
+
continue;
|
|
4083
|
+
kept.push(ch);
|
|
4142
4084
|
}
|
|
4143
|
-
const
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
const
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4085
|
+
const cleaned = kept.join("").trim();
|
|
4086
|
+
if (cleaned.length === 0)
|
|
4087
|
+
return "(unprintable)";
|
|
4088
|
+
const points = Array.from(cleaned);
|
|
4089
|
+
return points.length > MESSAGE_VALUE_MAX ? `${points.slice(0, MESSAGE_VALUE_MAX).join("")}…` : cleaned;
|
|
4090
|
+
}
|
|
4091
|
+
function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
4092
|
+
if (registeredNames.length === 0)
|
|
4093
|
+
return { status: "pass", errors: [] };
|
|
4094
|
+
const field = projectFieldFromBody(body);
|
|
4095
|
+
if (!field.declared)
|
|
4096
|
+
return { status: "pass", errors: [] };
|
|
4097
|
+
const known = new Set(registeredNames.map((n) => n.trim()));
|
|
4098
|
+
const registeredList = [...registeredNames].map(forMessage).join(", ");
|
|
4099
|
+
const errors = [];
|
|
4100
|
+
if (field.unreadable) {
|
|
4155
4101
|
return {
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4102
|
+
status: "fail",
|
|
4103
|
+
errors: [
|
|
4104
|
+
`issue-validation project registry: the body has an unterminated code fence, so its \`**Project:**\` field could not be read reliably — the fence runs to end of body (CommonMark, and how the forge renders it), swallowing everything after it including the foot field where the declaration lives by convention. Read from the raw body the field says ${residueForMessage(field.unparsed) || "(nothing)"}, but a line inside a swallowed region may be a quoted example rather than a real declaration, so this gate refuses rather than guessing which. Balance the fences — every opening run of backticks or tildes needs a closing run at least as long — and the field reads normally.`
|
|
4105
|
+
]
|
|
4159
4106
|
};
|
|
4160
4107
|
}
|
|
4161
|
-
const
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
headSha: input.headSha,
|
|
4169
|
-
baseSha: input.baseSha ?? null,
|
|
4170
|
-
briefHash: input.briefHash ?? null,
|
|
4171
|
-
objectivesVersion: input.objectivesVersion,
|
|
4172
|
-
rulingOrdinal: input.rulingOrdinal,
|
|
4173
|
-
policyDigest: policyDigest(policy)
|
|
4174
|
-
};
|
|
4175
|
-
const codeReviewEchoed = {
|
|
4176
|
-
headSha: codeReview.headSha,
|
|
4177
|
-
baseSha: codeReview.baseSha,
|
|
4178
|
-
briefHash: codeReview.briefHash,
|
|
4179
|
-
objectivesVersion: codeReview.objectivesVersion,
|
|
4180
|
-
rulingOrdinal: codeReview.rulingOrdinal,
|
|
4181
|
-
policyDigest: codeReview.policyDigest
|
|
4182
|
-
};
|
|
4183
|
-
const securityEchoed = {
|
|
4184
|
-
headSha: security.headSha,
|
|
4185
|
-
baseSha: security.baseSha,
|
|
4186
|
-
briefHash: security.briefHash,
|
|
4187
|
-
objectivesVersion: security.objectivesVersion,
|
|
4188
|
-
rulingOrdinal: security.rulingOrdinal,
|
|
4189
|
-
policyDigest: security.policyDigest
|
|
4190
|
-
};
|
|
4191
|
-
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
4192
|
-
const securityBinding = compareManifest(securityEchoed, currentManifest, input.patchIdOf);
|
|
4193
|
-
const codeReviewBound = codeReviewBinding.head;
|
|
4194
|
-
const securityBound = securityBinding.head;
|
|
4195
|
-
const codeReviewObjectivesBound = codeReviewBinding.objectivesVersion;
|
|
4196
|
-
const securityObjectivesBound = securityBinding.objectivesVersion;
|
|
4197
|
-
const codeReviewRulingsBound = codeReviewBinding.rulingOrdinal;
|
|
4198
|
-
const securityRulingsBound = securityBinding.rulingOrdinal;
|
|
4199
|
-
if (codeReviewClean && codeReviewBinding.bound && securityClean && securityBinding.bound) {
|
|
4200
|
-
return {
|
|
4201
|
-
verdict: "pass",
|
|
4202
|
-
reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.`,
|
|
4203
|
-
waived: false
|
|
4204
|
-
};
|
|
4108
|
+
const unregistered = field.names.filter((p) => !known.has(p));
|
|
4109
|
+
if (unregistered.length > 0) {
|
|
4110
|
+
const caseHints = unregistered.map((p) => {
|
|
4111
|
+
const row = [...known].find((k) => k.toLowerCase() === p.toLowerCase());
|
|
4112
|
+
return row ? `\`${forMessage(p)}\` differs from the registered \`${forMessage(row)}\` only in case` : null;
|
|
4113
|
+
}).filter((h) => h !== null);
|
|
4114
|
+
errors.push(`issue-validation project registry: the \`**Project:**\` field declares ${unregistered.map(forMessage).join(", ")} — no such row in \`.vinaya/projects.md\`, which is the authority for valid project names (registered: ${registeredList}). Fix the name, or register the project with \`vinaya init product <name> --path <folder>\` first; an unregistered project has no specs to read and no per-project state to update.${caseHints.length > 0 ? ` Note: ${caseHints.join("; ")} — project names are matched exactly, because every downstream consumer compares them literally.` : ""} This reads the same field \`projectsFromBody\` derives the task's project from, so a name here that is not a row is a task that resolves to a project that does not exist.`);
|
|
4205
4115
|
}
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
} else if (
|
|
4210
|
-
|
|
4211
|
-
} else if (!codeReviewBound) {
|
|
4212
|
-
problems.push(`the newest code-review verdict covers ${codeReview.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
|
|
4213
|
-
} else if (!codeReviewBinding.base) {
|
|
4214
|
-
problems.push(`the newest code-review verdict was cast against base ${codeReview.baseSha ?? "no recorded base"}, the PR's base is now ${currentManifest.baseSha ?? "unresolved"} (a base-only change under an unchanged candidate — same patch text on a new base is not automatically equivalent)`);
|
|
4215
|
-
} else if (!codeReviewObjectivesBound) {
|
|
4216
|
-
problems.push(`the newest code-review verdict was cast against objectives version ${codeReview.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
|
|
4217
|
-
} else if (!codeReviewRulingsBound) {
|
|
4218
|
-
problems.push(`the newest code-review verdict was cast against ruling ordinal ${codeReview.rulingOrdinal ?? "none"}, a newer ruling (ruling ${input.rulingOrdinal}) is now posted on this PR`);
|
|
4219
|
-
} else if (!codeReviewBinding.briefHash) {
|
|
4220
|
-
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"}`);
|
|
4221
|
-
} else if (!codeReviewBinding.policyDigest) {
|
|
4222
|
-
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}`);
|
|
4116
|
+
if (field.names.length === 0) {
|
|
4117
|
+
const residue = field.unparsed.length > 0 ? ` — ${residueForMessage(field.unparsed)}` : " — the field is empty";
|
|
4118
|
+
errors.push(`issue-validation project registry: the \`**Project:**\` field is present but resolves to no project name${residue} (registered: ${registeredList}). A project name is a slug (\`[a-z0-9][a-z0-9-]*\`, matched exactly); prose, a parenthetical, or a sentence in this field resolves to no project at all, and this gate cannot check a name it never receives — which is how a declaration like this used to pass. Write the registered name on its own, or register the project with \`vinaya init product <name> --path <folder>\` first. If the task genuinely touches no registered project, omit the field rather than explaining its absence inside it — \`checkIssueRationale\` already requires the \`Project(s) + blast radius\` narrative field for that.`);
|
|
4119
|
+
} else if (field.unparsed.length > 0) {
|
|
4120
|
+
errors.push(`issue-validation project registry: the \`**Project:**\` field declares a value that is not a project name — ${residueForMessage(field.unparsed)} (registered: ${registeredList}). The rest of the field parsed, so this is a name the gate silently could not check rather than a field it could not read at all. A project name is a slug (\`[a-z0-9][a-z0-9-]*\`, matched exactly); write it on its own, or drop it if it names no project.`);
|
|
4223
4121
|
}
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4122
|
+
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4123
|
+
}
|
|
4124
|
+
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;
|
|
4125
|
+
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
4126
|
+
var FILE_EXTENSIONS = new Set([
|
|
4127
|
+
"ts",
|
|
4128
|
+
"tsx",
|
|
4129
|
+
"js",
|
|
4130
|
+
"jsx",
|
|
4131
|
+
"mjs",
|
|
4132
|
+
"cjs",
|
|
4133
|
+
"json",
|
|
4134
|
+
"jsonc",
|
|
4135
|
+
"md",
|
|
4136
|
+
"mdx",
|
|
4137
|
+
"yml",
|
|
4138
|
+
"yaml",
|
|
4139
|
+
"txt",
|
|
4140
|
+
"sh",
|
|
4141
|
+
"lock",
|
|
4142
|
+
"toml",
|
|
4143
|
+
"ndjson",
|
|
4144
|
+
"html",
|
|
4145
|
+
"css"
|
|
4146
|
+
]);
|
|
4147
|
+
|
|
4148
|
+
// ../../packages/aeg-core/src/task-branch-identity.ts
|
|
4149
|
+
var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
|
|
4150
|
+
var TRANCHE_BRANCH_PATTERN = /^task\/([^/]+)\/([^/]+)$/;
|
|
4151
|
+
function parseTaskBranchIdentity(branch) {
|
|
4152
|
+
const issueMatch = ISSUE_BRANCH_PATTERN.exec(branch);
|
|
4153
|
+
if (issueMatch)
|
|
4154
|
+
return { kind: "issue", issueNumber: Number(issueMatch[1]) };
|
|
4155
|
+
const trancheMatch = TRANCHE_BRANCH_PATTERN.exec(branch);
|
|
4156
|
+
if (trancheMatch)
|
|
4157
|
+
return { kind: "tranche", tranche: trancheMatch[1], taskId: trancheMatch[2] };
|
|
4158
|
+
return null;
|
|
4159
|
+
}
|
|
4160
|
+
|
|
4161
|
+
// ../../packages/aeg-core/src/coherence-checks.ts
|
|
4162
|
+
var COHERENCE_ENFORCED_FROM = "2026-07-01";
|
|
4163
|
+
function isGrandfathered(isoDate) {
|
|
4164
|
+
if (!isoDate)
|
|
4165
|
+
return false;
|
|
4166
|
+
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4167
|
+
}
|
|
4168
|
+
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4169
|
+
function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
4170
|
+
const failures = [];
|
|
4171
|
+
for (const e of entries) {
|
|
4172
|
+
if (!e.facts)
|
|
4173
|
+
continue;
|
|
4174
|
+
if (e.facts.stateReason === "not_planned")
|
|
4175
|
+
continue;
|
|
4176
|
+
if (e.facts.issueState === "closed" && e.facts.prState !== "merged") {
|
|
4177
|
+
const handClosed = e.facts.stateReason === "completed" && isPrincipal(e.facts.closedByActor, principalAllowlist);
|
|
4178
|
+
if (handClosed)
|
|
4179
|
+
continue;
|
|
4180
|
+
failures.push({
|
|
4181
|
+
code: "closed-without-merge",
|
|
4182
|
+
issue: e.task.issue,
|
|
4183
|
+
tranche: e.trancheSlug,
|
|
4184
|
+
task: e.task.id,
|
|
4185
|
+
reason: `Issue closed but closing PR is not merged (prState: ${e.facts.prState})`,
|
|
4186
|
+
grandfathered: isGrandfathered(e.facts.closedAt)
|
|
4187
|
+
});
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4191
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4192
|
+
return {
|
|
4193
|
+
check: "A1",
|
|
4194
|
+
status,
|
|
4195
|
+
failures,
|
|
4196
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4197
|
+
};
|
|
4198
|
+
}
|
|
4199
|
+
function checkA3(entries) {
|
|
4200
|
+
const failures = [];
|
|
4201
|
+
for (const e of entries) {
|
|
4202
|
+
if (!e.facts)
|
|
4203
|
+
continue;
|
|
4204
|
+
if (e.facts.prState === "merged" && e.facts.issueState !== "closed") {
|
|
4205
|
+
failures.push({
|
|
4206
|
+
code: "auto-close-misfire",
|
|
4207
|
+
issue: e.task.issue,
|
|
4208
|
+
tranche: e.trancheSlug,
|
|
4209
|
+
task: e.task.id,
|
|
4210
|
+
reason: "Closing PR is merged but Issue is still open (GitHub auto-close misfire)",
|
|
4211
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
4212
|
+
});
|
|
4213
|
+
}
|
|
4240
4214
|
}
|
|
4241
|
-
const
|
|
4215
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4216
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4242
4217
|
return {
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4218
|
+
check: "A3",
|
|
4219
|
+
status,
|
|
4220
|
+
failures,
|
|
4221
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4246
4222
|
};
|
|
4247
4223
|
}
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
}
|
|
4253
|
-
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4254
|
-
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4255
|
-
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4256
|
-
let best = 0;
|
|
4257
|
-
for (const c of comments) {
|
|
4258
|
-
if (!isPrincipal(c.author, allowlist))
|
|
4259
|
-
continue;
|
|
4260
|
-
const firstLine = (c.body.split(`
|
|
4261
|
-
`)[0] ?? "").trim();
|
|
4262
|
-
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4263
|
-
if (!m)
|
|
4224
|
+
function checkT1(entries) {
|
|
4225
|
+
const failures = [];
|
|
4226
|
+
for (const e of entries) {
|
|
4227
|
+
if (e.task.issue === null)
|
|
4264
4228
|
continue;
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4229
|
+
if (e.facts === undefined) {
|
|
4230
|
+
failures.push({
|
|
4231
|
+
code: "phantom-issue-ref",
|
|
4232
|
+
issue: e.task.issue,
|
|
4233
|
+
tranche: e.trancheSlug,
|
|
4234
|
+
task: e.task.id,
|
|
4235
|
+
reason: `Issue #${e.task.issue} in topology does not resolve to a real GitHub Issue`
|
|
4236
|
+
});
|
|
4237
|
+
}
|
|
4268
4238
|
}
|
|
4269
|
-
return
|
|
4270
|
-
}
|
|
4271
|
-
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4272
|
-
function splitRow(line) {
|
|
4273
|
-
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
4274
|
-
return trimmed.split("|").map((cell) => cell.trim());
|
|
4239
|
+
return { check: "T1", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
4275
4240
|
}
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
const
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
}
|
|
4291
|
-
const headers = splitRow(headerLine);
|
|
4292
|
-
const rows = [];
|
|
4293
|
-
let j = i + 2;
|
|
4294
|
-
while (j < lines.length && TABLE_ROW_PATTERN.test(lines[j] ?? "")) {
|
|
4295
|
-
rows.push({ cells: splitRow(lines[j] ?? ""), line: j + 1 });
|
|
4296
|
-
j++;
|
|
4241
|
+
function checkT2(openIssuesBySlug, topologyIssuesBySlug, ciTrancheSlug) {
|
|
4242
|
+
const failures = [];
|
|
4243
|
+
for (const [slug, openNums] of openIssuesBySlug) {
|
|
4244
|
+
if (ciTrancheSlug && slug !== ciTrancheSlug)
|
|
4245
|
+
continue;
|
|
4246
|
+
const topologySet = topologyIssuesBySlug.get(slug) ?? new Set;
|
|
4247
|
+
for (const num of openNums) {
|
|
4248
|
+
if (!topologySet.has(num)) {
|
|
4249
|
+
failures.push({
|
|
4250
|
+
code: "orphan-task",
|
|
4251
|
+
issue: num,
|
|
4252
|
+
tranche: slug,
|
|
4253
|
+
reason: `Issue #${num} is open and labeled ${trancheLabel(slug)} but does not appear in the topology file`
|
|
4254
|
+
});
|
|
4297
4255
|
}
|
|
4298
|
-
return { headers, rows };
|
|
4299
4256
|
}
|
|
4300
|
-
i++;
|
|
4301
4257
|
}
|
|
4302
|
-
return
|
|
4258
|
+
return { check: "T2", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
4303
4259
|
}
|
|
4304
|
-
function
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4260
|
+
function scopeT2ToPlanPr(result, isPlanPr) {
|
|
4261
|
+
if (isPlanPr || result.status !== "fail")
|
|
4262
|
+
return result;
|
|
4263
|
+
return {
|
|
4264
|
+
...result,
|
|
4265
|
+
status: "info",
|
|
4266
|
+
note: result.note ?? "T2 findings are non-blocking outside plan PRs (point-of-power principle) — see aeg-root/enforcement.md."
|
|
4267
|
+
};
|
|
4310
4268
|
}
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
];
|
|
4320
|
-
function stripBackticks2(cell) {
|
|
4321
|
-
const trimmed = cell.trim();
|
|
4322
|
-
if (trimmed.length >= 2 && trimmed.startsWith("`") && trimmed.endsWith("`")) {
|
|
4323
|
-
return trimmed.slice(1, -1);
|
|
4269
|
+
function checkT3(entries, ciTrancheSlug, enrichedEntries, forgeUnavailableSlugs) {
|
|
4270
|
+
const preEnforcement = new Set;
|
|
4271
|
+
if (enrichedEntries) {
|
|
4272
|
+
for (const e of enrichedEntries) {
|
|
4273
|
+
if (isGrandfathered(e.facts?.closedAt) || isGrandfathered(e.facts?.mergedAt)) {
|
|
4274
|
+
preEnforcement.add(e.trancheSlug);
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4324
4277
|
}
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4278
|
+
const failures = [];
|
|
4279
|
+
for (const e of entries) {
|
|
4280
|
+
if (!e.archived && e.task.issue === null) {
|
|
4281
|
+
if (ciTrancheSlug && e.trancheSlug !== ciTrancheSlug)
|
|
4282
|
+
continue;
|
|
4283
|
+
if (forgeUnavailableSlugs?.has(e.trancheSlug)) {
|
|
4284
|
+
failures.push({
|
|
4285
|
+
code: "tbd-in-active-tranche",
|
|
4286
|
+
issue: null,
|
|
4287
|
+
tranche: e.trancheSlug,
|
|
4288
|
+
task: e.task.id,
|
|
4289
|
+
reason: `Task ${e.task.id} in active tranche has no Issue ref (#TBD or empty), but forge data for tranche "${e.trancheSlug}" was unavailable — cannot evaluate grandfather status, not silently failed`,
|
|
4290
|
+
grandfathered: true
|
|
4291
|
+
});
|
|
4292
|
+
continue;
|
|
4293
|
+
}
|
|
4294
|
+
failures.push({
|
|
4295
|
+
code: "tbd-in-active-tranche",
|
|
4296
|
+
issue: null,
|
|
4297
|
+
tranche: e.trancheSlug,
|
|
4298
|
+
task: e.task.id,
|
|
4299
|
+
reason: `Task ${e.task.id} in active tranche has no Issue ref (#TBD or empty) — the model requires all active tasks to have Issue numbers`,
|
|
4300
|
+
grandfathered: preEnforcement.has(e.trancheSlug)
|
|
4301
|
+
});
|
|
4302
|
+
}
|
|
4303
|
+
}
|
|
4304
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4305
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4306
|
+
return {
|
|
4307
|
+
check: "T3",
|
|
4308
|
+
status,
|
|
4309
|
+
failures,
|
|
4310
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4311
|
+
};
|
|
4329
4312
|
}
|
|
4330
|
-
function
|
|
4331
|
-
const
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
for (const { ring, pattern } of RING_HEADINGS) {
|
|
4335
|
-
const headingLine = findHeadingLine(lines, pattern);
|
|
4336
|
-
if (headingLine === null)
|
|
4313
|
+
function checkD1(entries, issueToEntry, taskToEntry) {
|
|
4314
|
+
const failures = [];
|
|
4315
|
+
for (const e of entries) {
|
|
4316
|
+
if (!e.facts)
|
|
4337
4317
|
continue;
|
|
4338
|
-
|
|
4339
|
-
if (!table)
|
|
4318
|
+
if (e.facts.prState !== "open")
|
|
4340
4319
|
continue;
|
|
4341
|
-
const
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
for (const row of table.rows) {
|
|
4345
|
-
const cells = row.cells;
|
|
4346
|
-
if (cells.length < 3)
|
|
4320
|
+
for (const dep of e.task.dependsOn) {
|
|
4321
|
+
const depEntry = resolveDepEntry(dep, e.trancheSlug, issueToEntry, taskToEntry);
|
|
4322
|
+
if (!depEntry)
|
|
4347
4323
|
continue;
|
|
4348
|
-
const
|
|
4349
|
-
const
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4324
|
+
const sameTask = depEntry.trancheSlug === e.trancheSlug && depEntry.task.id === e.task.id;
|
|
4325
|
+
const sameIssue = depEntry.task.issue !== null && e.task.issue !== null && depEntry.task.issue === e.task.issue;
|
|
4326
|
+
if (sameTask || sameIssue) {
|
|
4327
|
+
failures.push({
|
|
4328
|
+
code: "d1-self-dependency",
|
|
4329
|
+
issue: e.task.issue,
|
|
4330
|
+
tranche: e.trancheSlug,
|
|
4331
|
+
task: e.task.id,
|
|
4332
|
+
reason: `INTERNAL: parsed a self-dependency (depends-on ${dep}) — this is a parser bug in parseRationaleDeps, not a real dependency. Please report it upstream.`
|
|
4333
|
+
});
|
|
4334
|
+
continue;
|
|
4335
|
+
}
|
|
4336
|
+
const depFacts = depEntry.facts;
|
|
4337
|
+
const depClosed = depFacts?.issueState === "closed";
|
|
4338
|
+
if (!depClosed) {
|
|
4339
|
+
failures.push({
|
|
4340
|
+
code: "dispatched-on-unmet-deps",
|
|
4341
|
+
issue: e.task.issue,
|
|
4342
|
+
tranche: e.trancheSlug,
|
|
4343
|
+
task: e.task.id,
|
|
4344
|
+
reason: `Task has open PR but depends-on ${dep} (issue #${depEntry.task.issue ?? "?"}) is not closed`
|
|
4345
|
+
});
|
|
4346
|
+
}
|
|
4357
4347
|
}
|
|
4358
4348
|
}
|
|
4359
|
-
return
|
|
4349
|
+
return { check: "D1", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
4360
4350
|
}
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4351
|
+
function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
|
|
4352
|
+
const issueMatch = dep.match(/^#(\d+)$/);
|
|
4353
|
+
if (issueMatch?.[1])
|
|
4354
|
+
return issueToEntry.get(Number(issueMatch[1]));
|
|
4355
|
+
return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
|
|
4356
|
+
}
|
|
4357
|
+
function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
|
|
4358
|
+
const failures = [];
|
|
4359
|
+
for (const [slug, issues] of issuesBySlug) {
|
|
4360
|
+
for (const issue of issues) {
|
|
4361
|
+
if (!isTaskIssueLabelSet(issue.labels))
|
|
4362
|
+
continue;
|
|
4363
|
+
const errors = [
|
|
4364
|
+
...checkIssueRationale(issue.body).errors,
|
|
4365
|
+
...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
|
|
4366
|
+
...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
|
|
4367
|
+
...checkPartsCiteDefinedObjectives(issue.body).errors
|
|
4368
|
+
];
|
|
4369
|
+
if (errors.length === 0)
|
|
4370
|
+
continue;
|
|
4371
|
+
failures.push({
|
|
4372
|
+
code: "missing-rationale-field",
|
|
4373
|
+
issue: issue.number,
|
|
4374
|
+
tranche: slug,
|
|
4375
|
+
reason: `Issue #${issue.number} fails the rationale gate: ${errors.join(" | ")}`,
|
|
4376
|
+
grandfathered: grandfatheredIssues.has(issue.number)
|
|
4372
4377
|
});
|
|
4373
4378
|
}
|
|
4374
4379
|
}
|
|
4375
|
-
|
|
4380
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4381
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4382
|
+
return {
|
|
4383
|
+
check: "R1",
|
|
4384
|
+
status,
|
|
4385
|
+
failures,
|
|
4386
|
+
note: status === "info" ? `${failures.length} grandfathered task Issue(s) predate this check's grammar (rationale fields and/or the project registry)` : undefined
|
|
4387
|
+
};
|
|
4376
4388
|
}
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
"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)`,
|
|
4382
|
-
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
4383
|
-
};
|
|
4384
|
-
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
4385
|
-
function checkG2(rows, candidateFiles) {
|
|
4386
|
-
const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
|
|
4387
|
-
const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
|
|
4388
|
-
const findings = [];
|
|
4389
|
-
for (const path of candidateFiles) {
|
|
4390
|
-
if (implementations.has(path))
|
|
4391
|
-
continue;
|
|
4392
|
-
if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
|
|
4393
|
-
continue;
|
|
4394
|
-
if (NON_GATE_HOOK_SCRIPTS.includes(path))
|
|
4395
|
-
continue;
|
|
4396
|
-
if (path in TWIN_CANDIDATE_EXCEPTIONS)
|
|
4389
|
+
function checkL1(files, entriesBySlug) {
|
|
4390
|
+
const failures = [];
|
|
4391
|
+
for (const f of files) {
|
|
4392
|
+
if (f.archived)
|
|
4397
4393
|
continue;
|
|
4398
|
-
const
|
|
4399
|
-
|
|
4394
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
4395
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
4396
|
+
if (withFacts.length === 0)
|
|
4400
4397
|
continue;
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
|
|
4408
|
-
if (carriesPlaceholder) {
|
|
4409
|
-
findings.push({
|
|
4410
|
-
row: row.action,
|
|
4411
|
-
path: row.implementation,
|
|
4412
|
-
reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
|
|
4398
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
4399
|
+
if (allClosed) {
|
|
4400
|
+
failures.push({
|
|
4401
|
+
code: "archive-recommended",
|
|
4402
|
+
tranche: f.slug,
|
|
4403
|
+
reason: "Active tranche has no open task-Issues — consider archiving to completed/"
|
|
4413
4404
|
});
|
|
4414
4405
|
}
|
|
4415
4406
|
}
|
|
4416
|
-
return {
|
|
4407
|
+
return {
|
|
4408
|
+
check: "L1",
|
|
4409
|
+
status: "info",
|
|
4410
|
+
failures,
|
|
4411
|
+
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4412
|
+
};
|
|
4417
4413
|
}
|
|
4418
|
-
function
|
|
4419
|
-
const
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
});
|
|
4427
|
-
}
|
|
4428
|
-
}
|
|
4429
|
-
return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4414
|
+
function checkL3(files) {
|
|
4415
|
+
const active = files.filter((f) => !f.archived);
|
|
4416
|
+
return {
|
|
4417
|
+
check: "L3",
|
|
4418
|
+
status: "info",
|
|
4419
|
+
failures: [],
|
|
4420
|
+
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4421
|
+
};
|
|
4430
4422
|
}
|
|
4431
|
-
function
|
|
4432
|
-
const
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
const
|
|
4437
|
-
|
|
4438
|
-
if (!resolveFn(n)) {
|
|
4439
|
-
findings.push({
|
|
4440
|
-
reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
|
|
4441
|
-
});
|
|
4442
|
-
}
|
|
4423
|
+
function extractClosesReferences(prBody) {
|
|
4424
|
+
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4425
|
+
const stripped = stripCode(prBody);
|
|
4426
|
+
const searchIn = anchoredRegion(stripped, "CLOSES") ?? stripped;
|
|
4427
|
+
const referenced = new Set;
|
|
4428
|
+
for (const hit of searchIn.matchAll(closesPattern)) {
|
|
4429
|
+
referenced.add(Number(hit[1]));
|
|
4443
4430
|
}
|
|
4444
|
-
return
|
|
4431
|
+
return referenced;
|
|
4445
4432
|
}
|
|
4446
|
-
function
|
|
4447
|
-
const
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
});
|
|
4433
|
+
function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
4434
|
+
const referenced = extractClosesReferences(prBody);
|
|
4435
|
+
if (taskIssueRefs) {
|
|
4436
|
+
for (const n of referenced) {
|
|
4437
|
+
const ref = taskIssueRefs.get(n);
|
|
4438
|
+
if (!ref)
|
|
4439
|
+
continue;
|
|
4440
|
+
const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
|
|
4441
|
+
if (branch !== expectedBranch) {
|
|
4442
|
+
return {
|
|
4443
|
+
ok: false,
|
|
4444
|
+
message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${ref.taskId} of tranche "${ref.trancheSlug}") but is not named "${expectedBranch}" — rename the branch and re-push, or if this work is intentionally outside AEG's dispatch flow, remove the Closes reference.`
|
|
4445
|
+
};
|
|
4446
|
+
}
|
|
4461
4447
|
}
|
|
4462
4448
|
}
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4449
|
+
const ref = parseTaskBranchIdentity(branch);
|
|
4450
|
+
if (!ref)
|
|
4451
|
+
return { ok: true };
|
|
4452
|
+
if (ref.kind === "issue") {
|
|
4453
|
+
const expectedIssue = ref.issueNumber;
|
|
4454
|
+
if (!referenced.has(expectedIssue)) {
|
|
4455
|
+
return {
|
|
4456
|
+
ok: false,
|
|
4457
|
+
expectedIssue,
|
|
4458
|
+
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
4459
|
+
};
|
|
4469
4460
|
}
|
|
4461
|
+
return { ok: true, expectedIssue };
|
|
4470
4462
|
}
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
}
|
|
4479
|
-
function claimedCheckNames(implementation) {
|
|
4480
|
-
if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
|
|
4481
|
-
return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
|
|
4463
|
+
const trancheSlug = ref.tranche;
|
|
4464
|
+
const taskId = ref.taskId;
|
|
4465
|
+
const trancheFile = trancheFiles.find((f) => f.slug === trancheSlug);
|
|
4466
|
+
if (!trancheFile) {
|
|
4467
|
+
return {
|
|
4468
|
+
ok: false,
|
|
4469
|
+
message: `closes-n: branch "${branch}" references tranche "${trancheSlug}" but no topology file found at aeg-root/tranches/${trancheSlug}.md. Ensure the tranche file exists before opening the PR.`
|
|
4470
|
+
};
|
|
4482
4471
|
}
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4472
|
+
const task = trancheFile.tranche.tasks.find((t) => t.id === taskId);
|
|
4473
|
+
if (!task) {
|
|
4474
|
+
return {
|
|
4475
|
+
ok: false,
|
|
4476
|
+
message: `closes-n: branch "${branch}" references task "${taskId}" not found in ${trancheSlug} topology. Verify the task ID matches the tranche file.`
|
|
4477
|
+
};
|
|
4488
4478
|
}
|
|
4489
|
-
|
|
4479
|
+
if (task.issue === null) {
|
|
4480
|
+
return {
|
|
4481
|
+
ok: false,
|
|
4482
|
+
message: `closes-n: task "${taskId}" in "${trancheSlug}" has no Issue number (#TBD). The Planner must cut the Issue before this PR can be validated.`
|
|
4483
|
+
};
|
|
4484
|
+
}
|
|
4485
|
+
const expectedIssue = task.issue;
|
|
4486
|
+
if (!referenced.has(expectedIssue)) {
|
|
4487
|
+
return {
|
|
4488
|
+
ok: false,
|
|
4489
|
+
expectedIssue,
|
|
4490
|
+
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for task "${taskId}" in tranche "${trancheSlug}"). Add it to the PR body Summary section.`
|
|
4491
|
+
};
|
|
4492
|
+
}
|
|
4493
|
+
return { ok: true, expectedIssue };
|
|
4490
4494
|
}
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
}
|
|
4503
|
-
|
|
4495
|
+
// ../../packages/aeg-core/src/archive-task.ts
|
|
4496
|
+
function closesRefs(text) {
|
|
4497
|
+
return [...new Set([...text.matchAll(/Closes #(\d+)/gi)].map((m) => Number(m[1])))];
|
|
4498
|
+
}
|
|
4499
|
+
function extractIssue(body) {
|
|
4500
|
+
const stripped = stripCode(body);
|
|
4501
|
+
const bodyNums = closesRefs(stripped);
|
|
4502
|
+
const anchored = anchoredRegion(stripped, "CLOSES");
|
|
4503
|
+
if (anchored !== null) {
|
|
4504
|
+
const anchorNums = closesRefs(anchored);
|
|
4505
|
+
if (anchorNums.length === 0)
|
|
4506
|
+
return { issue: null, extraIssues: bodyNums, outsideHeader: false };
|
|
4507
|
+
const issue = anchorNums[0];
|
|
4508
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
|
|
4504
4509
|
}
|
|
4505
|
-
|
|
4510
|
+
const headerNums = closesRefs(headerRegion(stripped));
|
|
4511
|
+
if (bodyNums.length === 0)
|
|
4512
|
+
return { issue: null, extraIssues: [], outsideHeader: false };
|
|
4513
|
+
const issue = headerNums.length > 0 ? headerNums[0] : bodyNums[0];
|
|
4514
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: headerNums.length === 0 };
|
|
4506
4515
|
}
|
|
4507
|
-
// ../../packages/aeg-core/src/
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
".
|
|
4511
|
-
|
|
4512
|
-
"apps/cli/README.md",
|
|
4513
|
-
"packages/sources/README.md"
|
|
4514
|
-
];
|
|
4515
|
-
function isUnderOrEqual(path, prefix) {
|
|
4516
|
-
return path === prefix || path.startsWith(`${prefix}/`);
|
|
4516
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4517
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
4518
|
+
function briefHash(brief) {
|
|
4519
|
+
return createHash4("sha256").update(`${brief}
|
|
4520
|
+
`).digest("hex");
|
|
4517
4521
|
}
|
|
4518
|
-
function
|
|
4519
|
-
return
|
|
4522
|
+
function policyDigest(policy) {
|
|
4523
|
+
return createHash4("sha256").update(JSON.stringify({
|
|
4524
|
+
codeReviewThreshold: policy.codeReviewThreshold,
|
|
4525
|
+
securityThreshold: policy.securityThreshold,
|
|
4526
|
+
maxRounds: policy.maxRounds
|
|
4527
|
+
})).digest("hex");
|
|
4520
4528
|
}
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4529
|
+
function isBoundToHead(echoed, headSha) {
|
|
4530
|
+
if (!echoed.headSha)
|
|
4531
|
+
return false;
|
|
4532
|
+
return headSha.toLowerCase().startsWith(echoed.headSha.toLowerCase());
|
|
4524
4533
|
}
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
return out;
|
|
4534
|
+
function isBoundByPatchIdentity(echoed, headSha, patchIdOf) {
|
|
4535
|
+
if (patchIdOf === undefined || !echoed.headSha)
|
|
4536
|
+
return false;
|
|
4537
|
+
const judged = patchIdOf(echoed.headSha);
|
|
4538
|
+
const current = patchIdOf(headSha);
|
|
4539
|
+
if (judged === null || current === null)
|
|
4540
|
+
return false;
|
|
4541
|
+
return judged === current;
|
|
4534
4542
|
}
|
|
4535
|
-
function
|
|
4536
|
-
if (
|
|
4543
|
+
function isBoundToBase(echoed, currentBase) {
|
|
4544
|
+
if (currentBase === null)
|
|
4537
4545
|
return true;
|
|
4538
|
-
if (!
|
|
4546
|
+
if (!echoed.baseSha)
|
|
4539
4547
|
return false;
|
|
4540
|
-
return
|
|
4548
|
+
return currentBase.toLowerCase().startsWith(echoed.baseSha.toLowerCase());
|
|
4541
4549
|
}
|
|
4542
|
-
function
|
|
4543
|
-
|
|
4550
|
+
function isBoundToObjectives(echoed, currentVersion) {
|
|
4551
|
+
if (currentVersion === null)
|
|
4552
|
+
return true;
|
|
4553
|
+
return echoed.objectivesVersion === currentVersion;
|
|
4544
4554
|
}
|
|
4545
|
-
function
|
|
4546
|
-
if (
|
|
4547
|
-
return
|
|
4548
|
-
|
|
4549
|
-
if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
|
|
4550
|
-
return "reader-facing";
|
|
4551
|
-
}
|
|
4552
|
-
if (isClaudeMdFile(path))
|
|
4553
|
-
return "internal";
|
|
4554
|
-
if (isSpecFile2(path, specPaths))
|
|
4555
|
-
return "spec";
|
|
4556
|
-
if (isProductScopeFile(path))
|
|
4557
|
-
return "product";
|
|
4558
|
-
return null;
|
|
4555
|
+
function isBoundToRulings(echoed, currentOrdinal) {
|
|
4556
|
+
if (echoed.rulingOrdinal === null)
|
|
4557
|
+
return currentOrdinal === 0;
|
|
4558
|
+
return echoed.rulingOrdinal === currentOrdinal;
|
|
4559
4559
|
}
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
}
|
|
4565
|
-
if (path.endsWith(".tsx") || path.endsWith(".ts")) {
|
|
4566
|
-
return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
|
|
4567
|
-
}
|
|
4568
|
-
return content;
|
|
4560
|
+
function isBoundToBriefHash(echoed, currentHash) {
|
|
4561
|
+
if (currentHash === null)
|
|
4562
|
+
return true;
|
|
4563
|
+
return echoed.briefHash === currentHash;
|
|
4569
4564
|
}
|
|
4570
|
-
function
|
|
4571
|
-
return
|
|
4565
|
+
function isBoundToPolicy(echoed, currentDigest) {
|
|
4566
|
+
return echoed.policyDigest === currentDigest;
|
|
4572
4567
|
}
|
|
4573
|
-
function
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4568
|
+
function compareManifest(echoed, current, patchIdOf) {
|
|
4569
|
+
const exactHead = isBoundToHead(echoed, current.headSha);
|
|
4570
|
+
const patchHead = exactHead ? false : isBoundByPatchIdentity(echoed, current.headSha, patchIdOf);
|
|
4571
|
+
const head = exactHead || patchHead;
|
|
4572
|
+
const echoedShaLen = echoed.baseSha?.length ?? 0;
|
|
4573
|
+
const currentShaLen = current.baseSha?.length ?? 0;
|
|
4574
|
+
const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
|
|
4575
|
+
const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
|
|
4576
|
+
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4577
|
+
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4578
|
+
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
4579
|
+
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4580
|
+
return {
|
|
4581
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
4582
|
+
head,
|
|
4583
|
+
base,
|
|
4584
|
+
briefHash: briefHashBound,
|
|
4585
|
+
objectivesVersion,
|
|
4586
|
+
rulingOrdinal,
|
|
4587
|
+
policyDigest: policyDigestBound
|
|
4588
|
+
};
|
|
4580
4589
|
}
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4590
|
+
|
|
4591
|
+
// ../../packages/aeg-core/src/review-gate.ts
|
|
4592
|
+
function renderGateDeferred(deferred) {
|
|
4593
|
+
if (deferred.length === 0)
|
|
4594
|
+
return "";
|
|
4595
|
+
const items = deferred.map((d) => {
|
|
4596
|
+
const where = d.finding.location && d.finding.location.length > 0 ? d.finding.location : "(no location)";
|
|
4597
|
+
return `${d.finding.severity} ${where} (${DEFERRAL_REASON_TEXT[d.reason]})`;
|
|
4598
|
+
}).join("; ");
|
|
4599
|
+
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4589
4600
|
}
|
|
4590
|
-
function
|
|
4591
|
-
const
|
|
4592
|
-
const
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4601
|
+
function checkReviewGate(input) {
|
|
4602
|
+
const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
|
|
4603
|
+
const waived = isWaiverLabelActorVerified({
|
|
4604
|
+
label: WAIVER_LABEL_REVIEW,
|
|
4605
|
+
labels: input.labels,
|
|
4606
|
+
labelActor: input.waiverLabelActor,
|
|
4607
|
+
principalAllowlist
|
|
4608
|
+
});
|
|
4609
|
+
if (waived) {
|
|
4610
|
+
return {
|
|
4611
|
+
verdict: "pass",
|
|
4612
|
+
reason: `\`${WAIVER_LABEL_REVIEW}\` label is actor-verified — review requirement waived for this PR.`,
|
|
4613
|
+
waived: true
|
|
4614
|
+
};
|
|
4615
|
+
}
|
|
4616
|
+
const verified = input.comments.filter((c) => isPrincipal(c.author, principalAllowlist));
|
|
4617
|
+
const ignoredCount = input.comments.filter((c) => !isPrincipal(c.author, principalAllowlist) && c.body.includes("VERDICT")).length;
|
|
4618
|
+
const verifiedBodies = verified.map((c) => c.body);
|
|
4619
|
+
const codeReview = extractCodeReviewVerdict(verifiedBodies);
|
|
4620
|
+
const security = extractSecurityReviewVerdict(verifiedBodies);
|
|
4621
|
+
const policy = input.policy ?? DEFAULT_REVIEW_POLICY;
|
|
4622
|
+
let codeReviewPolicyEvaluation;
|
|
4623
|
+
let securityPolicyEvaluation;
|
|
4624
|
+
try {
|
|
4625
|
+
codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy, input.deferralContext);
|
|
4626
|
+
securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy, input.deferralContext);
|
|
4627
|
+
} catch (err) {
|
|
4628
|
+
return {
|
|
4629
|
+
verdict: "fail",
|
|
4630
|
+
reason: `a verdict comment carries a finding severity this repository's policy does not recognize: ${err instanceof Error ? err.message : String(err)}`,
|
|
4631
|
+
waived: false
|
|
4632
|
+
};
|
|
4633
|
+
}
|
|
4634
|
+
const codeReviewTextClean = codeReview.value === "APPROVE";
|
|
4635
|
+
const securityTextClean = security.value === "PASS";
|
|
4636
|
+
const codeReviewPolicyClean = codeReviewPolicyEvaluation.outcome === "clean";
|
|
4637
|
+
const securityPolicyClean = securityPolicyEvaluation.outcome === "clean";
|
|
4638
|
+
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4639
|
+
const securityClean = securityTextClean && securityPolicyClean;
|
|
4640
|
+
const currentManifest = {
|
|
4641
|
+
headSha: input.headSha,
|
|
4642
|
+
baseSha: input.baseSha ?? null,
|
|
4643
|
+
briefHash: input.briefHash ?? null,
|
|
4644
|
+
objectivesVersion: input.objectivesVersion,
|
|
4645
|
+
rulingOrdinal: input.rulingOrdinal,
|
|
4646
|
+
policyDigest: policyDigest(policy)
|
|
4647
|
+
};
|
|
4648
|
+
const codeReviewEchoed = {
|
|
4649
|
+
headSha: codeReview.headSha,
|
|
4650
|
+
baseSha: codeReview.baseSha,
|
|
4651
|
+
briefHash: codeReview.briefHash,
|
|
4652
|
+
objectivesVersion: codeReview.objectivesVersion,
|
|
4653
|
+
rulingOrdinal: codeReview.rulingOrdinal,
|
|
4654
|
+
policyDigest: codeReview.policyDigest
|
|
4655
|
+
};
|
|
4656
|
+
const securityEchoed = {
|
|
4657
|
+
headSha: security.headSha,
|
|
4658
|
+
baseSha: security.baseSha,
|
|
4659
|
+
briefHash: security.briefHash,
|
|
4660
|
+
objectivesVersion: security.objectivesVersion,
|
|
4661
|
+
rulingOrdinal: security.rulingOrdinal,
|
|
4662
|
+
policyDigest: security.policyDigest
|
|
4663
|
+
};
|
|
4664
|
+
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
4665
|
+
const securityBinding = compareManifest(securityEchoed, currentManifest, input.patchIdOf);
|
|
4666
|
+
const codeReviewBound = codeReviewBinding.head;
|
|
4667
|
+
const securityBound = securityBinding.head;
|
|
4668
|
+
const codeReviewObjectivesBound = codeReviewBinding.objectivesVersion;
|
|
4669
|
+
const securityObjectivesBound = securityBinding.objectivesVersion;
|
|
4670
|
+
const codeReviewRulingsBound = codeReviewBinding.rulingOrdinal;
|
|
4671
|
+
const securityRulingsBound = securityBinding.rulingOrdinal;
|
|
4672
|
+
const deferredNote = renderGateDeferred([
|
|
4673
|
+
...codeReviewPolicyEvaluation.deferredFindings,
|
|
4674
|
+
...securityPolicyEvaluation.deferredFindings
|
|
4675
|
+
]);
|
|
4676
|
+
if (codeReviewClean && codeReviewBinding.bound && securityClean && securityBinding.bound) {
|
|
4677
|
+
return {
|
|
4678
|
+
verdict: "pass",
|
|
4679
|
+
reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.${deferredNote}`,
|
|
4680
|
+
waived: false
|
|
4681
|
+
};
|
|
4682
|
+
}
|
|
4683
|
+
const problems = [];
|
|
4684
|
+
if (!codeReviewTextClean) {
|
|
4685
|
+
problems.push(`code-reviewer verdict is not a clean APPROVE (found: ${codeReview.value})`);
|
|
4686
|
+
} else if (!codeReviewPolicyClean) {
|
|
4687
|
+
problems.push(`code-reviewer verdict says APPROVE but carries a finding (${codeReviewPolicyEvaluation.blockingFindings.map((f) => f.severity).join(", ")}) at or above this repository's code-review policy threshold (${policy.codeReviewThreshold}) — a reviewer's own APPROVE never overrides policy`);
|
|
4688
|
+
} else if (!codeReviewBound) {
|
|
4689
|
+
problems.push(`the newest code-review verdict covers ${codeReview.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
|
|
4690
|
+
} else if (!codeReviewBinding.base) {
|
|
4691
|
+
problems.push(`the newest code-review verdict was cast against base ${codeReview.baseSha ?? "no recorded base"}, the PR's base is now ${currentManifest.baseSha ?? "unresolved"} (a base-only change under an unchanged candidate — same patch text on a new base is not automatically equivalent)`);
|
|
4692
|
+
} else if (!codeReviewObjectivesBound) {
|
|
4693
|
+
problems.push(`the newest code-review verdict was cast against objectives version ${codeReview.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
|
|
4694
|
+
} else if (!codeReviewRulingsBound) {
|
|
4695
|
+
problems.push(`the newest code-review verdict was cast against ruling ordinal ${codeReview.rulingOrdinal ?? "none"}, a newer ruling (ruling ${input.rulingOrdinal}) is now posted on this PR`);
|
|
4696
|
+
} else if (!codeReviewBinding.briefHash) {
|
|
4697
|
+
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"}`);
|
|
4698
|
+
} else if (!codeReviewBinding.policyDigest) {
|
|
4699
|
+
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}`);
|
|
4700
|
+
}
|
|
4701
|
+
if (!securityTextClean) {
|
|
4702
|
+
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
4703
|
+
} else if (!securityPolicyClean) {
|
|
4704
|
+
problems.push(`security-review verdict says PASS but carries a finding (${securityPolicyEvaluation.blockingFindings.map((f) => f.severity).join(", ")}) at or above this repository's security policy threshold (${policy.securityThreshold}) — a reviewer's own PASS never overrides policy`);
|
|
4705
|
+
} else if (!securityBound) {
|
|
4706
|
+
problems.push(`the newest security-review verdict covers ${security.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
|
|
4707
|
+
} else if (!securityBinding.base) {
|
|
4708
|
+
problems.push(`the newest security-review verdict was cast against base ${security.baseSha ?? "no recorded base"}, the PR's base is now ${currentManifest.baseSha ?? "unresolved"} (a base-only change under an unchanged candidate — same patch text on a new base is not automatically equivalent)`);
|
|
4709
|
+
} else if (!securityObjectivesBound) {
|
|
4710
|
+
problems.push(`the newest security-review verdict was cast against objectives version ${security.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
|
|
4711
|
+
} else if (!securityRulingsBound) {
|
|
4712
|
+
problems.push(`the newest security-review verdict was cast against ruling ordinal ${security.rulingOrdinal ?? "none"}, a newer ruling (ruling ${input.rulingOrdinal}) is now posted on this PR`);
|
|
4713
|
+
} else if (!securityBinding.briefHash) {
|
|
4714
|
+
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"}`);
|
|
4715
|
+
} else if (!securityBinding.policyDigest) {
|
|
4716
|
+
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}`);
|
|
4717
|
+
}
|
|
4718
|
+
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4719
|
+
return {
|
|
4720
|
+
verdict: "fail",
|
|
4721
|
+
reason: `${problems.join("; ")}. A principal can apply an actor-verified \`${WAIVER_LABEL_REVIEW}\` label to skip this requirement, or post the missing/clean verdict comment(s).${ignoredNote}${deferredNote}`,
|
|
4722
|
+
waived: false
|
|
4723
|
+
};
|
|
4724
|
+
}
|
|
4725
|
+
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4726
|
+
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4727
|
+
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4728
|
+
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4729
|
+
}
|
|
4730
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4731
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4732
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4733
|
+
let best = 0;
|
|
4734
|
+
for (const c of comments) {
|
|
4735
|
+
if (!isPrincipal(c.author, allowlist))
|
|
4611
4736
|
continue;
|
|
4612
|
-
|
|
4737
|
+
const firstLine = (c.body.split(`
|
|
4738
|
+
`)[0] ?? "").trim();
|
|
4739
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4740
|
+
if (!m)
|
|
4613
4741
|
continue;
|
|
4614
|
-
const
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
for (const { pattern, what, group } of patternsToRun) {
|
|
4618
|
-
pattern.lastIndex = 0;
|
|
4619
|
-
let match = pattern.exec(scrubbed);
|
|
4620
|
-
while (match !== null) {
|
|
4621
|
-
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4622
|
-
const citedIndex = match.index + match[0].indexOf(cited);
|
|
4623
|
-
findings.push({
|
|
4624
|
-
file: file.path,
|
|
4625
|
-
line: lineAt(scrubbed, citedIndex),
|
|
4626
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4627
|
-
blocking
|
|
4628
|
-
});
|
|
4629
|
-
match = pattern.exec(scrubbed);
|
|
4630
|
-
}
|
|
4631
|
-
}
|
|
4742
|
+
const k = Number.parseInt(m[1], 10);
|
|
4743
|
+
if (k > best)
|
|
4744
|
+
best = k;
|
|
4632
4745
|
}
|
|
4633
|
-
return
|
|
4634
|
-
}
|
|
4635
|
-
function escapeTerm(term) {
|
|
4636
|
-
return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4746
|
+
return best;
|
|
4637
4747
|
}
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
const
|
|
4641
|
-
return
|
|
4748
|
+
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4749
|
+
function splitRow(line) {
|
|
4750
|
+
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
4751
|
+
return trimmed.split("|").map((cell) => cell.trim());
|
|
4642
4752
|
}
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
let
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
if (
|
|
4650
|
-
return
|
|
4753
|
+
var TABLE_ROW_PATTERN = /^\s*\|.*\|\s*$/;
|
|
4754
|
+
var SEPARATOR_ROW_PATTERN = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
|
|
4755
|
+
function findTable(lines, fromLine, stopAtHeading = true) {
|
|
4756
|
+
let i = fromLine - 1;
|
|
4757
|
+
while (i < lines.length) {
|
|
4758
|
+
const line = lines[i] ?? "";
|
|
4759
|
+
if (stopAtHeading && i > fromLine - 1 && /^##\s/.test(line))
|
|
4760
|
+
return null;
|
|
4761
|
+
if (TABLE_ROW_PATTERN.test(line)) {
|
|
4762
|
+
const headerLine = line;
|
|
4763
|
+
const sepLine = lines[i + 1] ?? "";
|
|
4764
|
+
if (!SEPARATOR_ROW_PATTERN.test(sepLine)) {
|
|
4765
|
+
i++;
|
|
4766
|
+
continue;
|
|
4767
|
+
}
|
|
4768
|
+
const headers = splitRow(headerLine);
|
|
4769
|
+
const rows = [];
|
|
4770
|
+
let j = i + 2;
|
|
4771
|
+
while (j < lines.length && TABLE_ROW_PATTERN.test(lines[j] ?? "")) {
|
|
4772
|
+
rows.push({ cells: splitRow(lines[j] ?? ""), line: j + 1 });
|
|
4773
|
+
j++;
|
|
4774
|
+
}
|
|
4775
|
+
return { headers, rows };
|
|
4776
|
+
}
|
|
4777
|
+
i++;
|
|
4651
4778
|
}
|
|
4652
4779
|
return null;
|
|
4653
4780
|
}
|
|
4654
|
-
function
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
return
|
|
4781
|
+
function findHeadingLine(lines, pattern) {
|
|
4782
|
+
for (let i = 0;i < lines.length; i++) {
|
|
4783
|
+
if (pattern.test(lines[i] ?? ""))
|
|
4784
|
+
return i + 1;
|
|
4785
|
+
}
|
|
4786
|
+
return null;
|
|
4660
4787
|
}
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
findings.push({
|
|
4675
|
-
file: file.path,
|
|
4676
|
-
line,
|
|
4677
|
-
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
4678
|
-
blocking: false
|
|
4679
|
-
});
|
|
4680
|
-
}
|
|
4788
|
+
// ../../packages/aeg-core/src/diagram-model.ts
|
|
4789
|
+
import matter from "gray-matter";
|
|
4790
|
+
|
|
4791
|
+
// ../../packages/aeg-core/src/registry-parse.ts
|
|
4792
|
+
var RING_HEADINGS = [
|
|
4793
|
+
{ ring: "ring0", pattern: /^##\s+Ring 0\b/ },
|
|
4794
|
+
{ ring: "ring1", pattern: /^##\s+Ring 1\b/ },
|
|
4795
|
+
{ ring: "ring2", pattern: /^##\s+Ring 2\b/ }
|
|
4796
|
+
];
|
|
4797
|
+
function stripBackticks2(cell) {
|
|
4798
|
+
const trimmed = cell.trim();
|
|
4799
|
+
if (trimmed.length >= 2 && trimmed.startsWith("`") && trimmed.endsWith("`")) {
|
|
4800
|
+
return trimmed.slice(1, -1);
|
|
4681
4801
|
}
|
|
4682
|
-
return
|
|
4802
|
+
return trimmed;
|
|
4683
4803
|
}
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
const
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
` ? `
|
|
4695
|
-
` : " ";
|
|
4696
|
-
while (i < n) {
|
|
4697
|
-
const c = content[i];
|
|
4698
|
-
const next = i + 1 < n ? content[i + 1] : "";
|
|
4699
|
-
if (state === "code") {
|
|
4700
|
-
if (c === "/" && next === "/") {
|
|
4701
|
-
state = "line-comment";
|
|
4702
|
-
out += c;
|
|
4703
|
-
i++;
|
|
4704
|
-
continue;
|
|
4705
|
-
}
|
|
4706
|
-
if (c === "/" && next === "*") {
|
|
4707
|
-
state = "block-comment";
|
|
4708
|
-
out += c;
|
|
4709
|
-
i++;
|
|
4710
|
-
continue;
|
|
4711
|
-
}
|
|
4712
|
-
if (c === "'") {
|
|
4713
|
-
state = "single-quote";
|
|
4714
|
-
out += blank(c);
|
|
4715
|
-
i++;
|
|
4716
|
-
continue;
|
|
4717
|
-
}
|
|
4718
|
-
if (c === '"') {
|
|
4719
|
-
state = "double-quote";
|
|
4720
|
-
out += blank(c);
|
|
4721
|
-
i++;
|
|
4722
|
-
continue;
|
|
4723
|
-
}
|
|
4724
|
-
if (c === "`") {
|
|
4725
|
-
state = "template";
|
|
4726
|
-
out += blank(c);
|
|
4727
|
-
i++;
|
|
4728
|
-
continue;
|
|
4729
|
-
}
|
|
4730
|
-
out += blank(c);
|
|
4731
|
-
i++;
|
|
4804
|
+
function stripBold(cell) {
|
|
4805
|
+
return cell.trim().replace(/\*\*/g, "");
|
|
4806
|
+
}
|
|
4807
|
+
function parseEnforcementRegistry(content) {
|
|
4808
|
+
const lines = content.split(`
|
|
4809
|
+
`);
|
|
4810
|
+
const result = [];
|
|
4811
|
+
for (const { ring, pattern } of RING_HEADINGS) {
|
|
4812
|
+
const headingLine = findHeadingLine(lines, pattern);
|
|
4813
|
+
if (headingLine === null)
|
|
4732
4814
|
continue;
|
|
4733
|
-
|
|
4734
|
-
if (
|
|
4735
|
-
if (c === `
|
|
4736
|
-
`) {
|
|
4737
|
-
state = "code";
|
|
4738
|
-
out += `
|
|
4739
|
-
`;
|
|
4740
|
-
i++;
|
|
4741
|
-
continue;
|
|
4742
|
-
}
|
|
4743
|
-
out += c;
|
|
4744
|
-
i++;
|
|
4815
|
+
const table = findTable(lines, headingLine + 1);
|
|
4816
|
+
if (!table)
|
|
4745
4817
|
continue;
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
i += 2;
|
|
4818
|
+
const descriptionIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "description");
|
|
4819
|
+
const implementationIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "implementation");
|
|
4820
|
+
const audienceIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "audience");
|
|
4821
|
+
for (const row of table.rows) {
|
|
4822
|
+
const cells = row.cells;
|
|
4823
|
+
if (cells.length < 3)
|
|
4753
4824
|
continue;
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
out += blank(c);
|
|
4764
|
-
i++;
|
|
4765
|
-
if (i < n) {
|
|
4766
|
-
out += blank(content[i]);
|
|
4767
|
-
i++;
|
|
4768
|
-
}
|
|
4769
|
-
continue;
|
|
4825
|
+
const action = stripBold(cells[0] ?? "");
|
|
4826
|
+
const summary = stripBackticks2(cells[1] ?? "");
|
|
4827
|
+
const category = stripBackticks2(cells[2] ?? "");
|
|
4828
|
+
const implementation = stripBackticks2((implementationIndex === -1 ? cells[cells.length - 1] : cells[implementationIndex]) ?? "");
|
|
4829
|
+
const description = descriptionIndex === -1 ? undefined : stripBackticks2(cells[descriptionIndex] ?? "") || undefined;
|
|
4830
|
+
const specIndex = (audienceIndex === -1 ? cells.length - 1 : audienceIndex) - 1;
|
|
4831
|
+
const spec = specIndex >= 3 ? stripBackticks2(cells[specIndex] ?? "") || undefined : undefined;
|
|
4832
|
+
const audience = audienceIndex === -1 ? "repo-own" : stripBackticks2(cells[audienceIndex] ?? "") === "product" ? "product" : "repo-own";
|
|
4833
|
+
result.push({ ring, action, summary, category, description, spec, implementation, audience, line: row.line });
|
|
4770
4834
|
}
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4835
|
+
}
|
|
4836
|
+
return result;
|
|
4837
|
+
}
|
|
4838
|
+
// ../../packages/aeg-core/src/registry-checks.ts
|
|
4839
|
+
function checkG1(rows, existsFn) {
|
|
4840
|
+
const findings = [];
|
|
4841
|
+
for (const row of rows) {
|
|
4842
|
+
if (row.implementation === "")
|
|
4775
4843
|
continue;
|
|
4844
|
+
if (!existsFn(row.implementation)) {
|
|
4845
|
+
findings.push({
|
|
4846
|
+
row: row.action,
|
|
4847
|
+
path: row.implementation,
|
|
4848
|
+
reason: `${row.ring} row "${row.action}" names implementation "${row.implementation}", which does not exist on disk`
|
|
4849
|
+
});
|
|
4776
4850
|
}
|
|
4777
|
-
out += blank(c);
|
|
4778
|
-
i++;
|
|
4779
4851
|
}
|
|
4780
|
-
return
|
|
4852
|
+
return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4781
4853
|
}
|
|
4782
|
-
|
|
4854
|
+
var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
4855
|
+
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
4856
|
+
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
4857
|
+
"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)',
|
|
4858
|
+
"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)`,
|
|
4859
|
+
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
4860
|
+
};
|
|
4861
|
+
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
4862
|
+
function checkG2(rows, candidateFiles) {
|
|
4863
|
+
const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
|
|
4864
|
+
const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
|
|
4783
4865
|
const findings = [];
|
|
4784
|
-
const
|
|
4785
|
-
|
|
4786
|
-
{ pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
|
|
4787
|
-
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
4788
|
-
];
|
|
4789
|
-
for (const file of files) {
|
|
4790
|
-
if (!file.path.endsWith(".ts"))
|
|
4866
|
+
for (const path of candidateFiles) {
|
|
4867
|
+
if (implementations.has(path))
|
|
4791
4868
|
continue;
|
|
4792
|
-
if (
|
|
4869
|
+
if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
|
|
4793
4870
|
continue;
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4871
|
+
if (NON_GATE_HOOK_SCRIPTS.includes(path))
|
|
4872
|
+
continue;
|
|
4873
|
+
if (path in TWIN_CANDIDATE_EXCEPTIONS)
|
|
4874
|
+
continue;
|
|
4875
|
+
const candidateNames = claimedCheckNames(path);
|
|
4876
|
+
if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
|
|
4877
|
+
continue;
|
|
4878
|
+
findings.push({
|
|
4879
|
+
path,
|
|
4880
|
+
reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
|
|
4881
|
+
});
|
|
4882
|
+
}
|
|
4883
|
+
for (const row of rows) {
|
|
4884
|
+
const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
|
|
4885
|
+
if (carriesPlaceholder) {
|
|
4886
|
+
findings.push({
|
|
4887
|
+
row: row.action,
|
|
4888
|
+
path: row.implementation,
|
|
4889
|
+
reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
|
|
4890
|
+
});
|
|
4807
4891
|
}
|
|
4808
4892
|
}
|
|
4809
|
-
return findings;
|
|
4810
|
-
}
|
|
4811
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4812
|
-
return [
|
|
4813
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
4814
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4815
|
-
];
|
|
4893
|
+
return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4816
4894
|
}
|
|
4817
|
-
function
|
|
4818
|
-
const
|
|
4819
|
-
const
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4895
|
+
function checkG3(ring0Rows, crossingFiles) {
|
|
4896
|
+
const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
|
|
4897
|
+
const findings = [];
|
|
4898
|
+
for (const path of crossingFiles) {
|
|
4899
|
+
if (!ring0Implementations.has(path)) {
|
|
4900
|
+
findings.push({
|
|
4901
|
+
path,
|
|
4902
|
+
reason: `"${path}" makes a GitHub-crossing call but is not named by any Ring-0 row's implementation — a seventh, unlisted way into GitHub`
|
|
4903
|
+
});
|
|
4904
|
+
}
|
|
4825
4905
|
}
|
|
4826
|
-
return
|
|
4827
|
-
}
|
|
4828
|
-
|
|
4829
|
-
// ../../packages/aeg-core/src/quoted-command.ts
|
|
4830
|
-
var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
|
|
4831
|
-
var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
4832
|
-
var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
|
|
4833
|
-
var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
|
|
4834
|
-
function isValidCitedFilePath(path) {
|
|
4835
|
-
if (path.length === 0)
|
|
4836
|
-
return false;
|
|
4837
|
-
if (path.startsWith("/") || path.startsWith("\\"))
|
|
4838
|
-
return false;
|
|
4839
|
-
if (/^[A-Za-z]:[\\/]/.test(path))
|
|
4840
|
-
return false;
|
|
4841
|
-
return !path.split(/[\\/]+/).includes("..");
|
|
4906
|
+
return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4842
4907
|
}
|
|
4843
|
-
function
|
|
4844
|
-
|
|
4845
|
-
for (
|
|
4846
|
-
|
|
4847
|
-
line++;
|
|
4908
|
+
function checkG4(content, resolveFn) {
|
|
4909
|
+
const cited = new Set;
|
|
4910
|
+
for (const hit of content.matchAll(/#(\d{3,})\b/g)) {
|
|
4911
|
+
cited.add(Number(hit[1]));
|
|
4848
4912
|
}
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
return (inline[1] ?? "").trim();
|
|
4859
|
-
return trimmed;
|
|
4913
|
+
const findings = [];
|
|
4914
|
+
for (const n of cited) {
|
|
4915
|
+
if (!resolveFn(n)) {
|
|
4916
|
+
findings.push({
|
|
4917
|
+
reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
|
|
4918
|
+
});
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4921
|
+
return { check: "G4", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4860
4922
|
}
|
|
4861
|
-
function
|
|
4862
|
-
const
|
|
4863
|
-
const
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
if (end === null) {
|
|
4871
|
-
START_PATTERN.lastIndex = innerStart;
|
|
4872
|
-
start = START_PATTERN.exec(masked);
|
|
4873
|
-
continue;
|
|
4923
|
+
function checkG5(roles, contracts) {
|
|
4924
|
+
const roleIds = new Set(roles.map((r) => r.role_id));
|
|
4925
|
+
const findings = [];
|
|
4926
|
+
for (const contract of contracts) {
|
|
4927
|
+
if (!roleIds.has(contract.producer)) {
|
|
4928
|
+
findings.push({
|
|
4929
|
+
path: contract.file,
|
|
4930
|
+
reason: `contract "${contract.file}" names producer "${contract.producer}", which is not a real role_id`
|
|
4931
|
+
});
|
|
4874
4932
|
}
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
}
|
|
4933
|
+
if (!roleIds.has(contract.consumer)) {
|
|
4934
|
+
findings.push({
|
|
4935
|
+
path: contract.file,
|
|
4936
|
+
reason: `contract "${contract.file}" names consumer "${contract.consumer}", which is not a real role_id`
|
|
4937
|
+
});
|
|
4881
4938
|
}
|
|
4882
|
-
START_PATTERN.lastIndex = innerEnd + end[0].length;
|
|
4883
|
-
start = START_PATTERN.exec(masked);
|
|
4884
4939
|
}
|
|
4885
|
-
|
|
4940
|
+
for (const role of roles) {
|
|
4941
|
+
if (role.performs.length === 0) {
|
|
4942
|
+
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty performs array` });
|
|
4943
|
+
}
|
|
4944
|
+
if (role.refuses_when.trim() === "") {
|
|
4945
|
+
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty refuses_when` });
|
|
4946
|
+
}
|
|
4947
|
+
}
|
|
4948
|
+
return { check: "G5", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4886
4949
|
}
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4950
|
+
var SHIPPED_BIN_PATH_PREFIX = "apps/cli/src/checks/bin/check-";
|
|
4951
|
+
var AEG_CORE_BIN_PATH_PREFIX = "packages/aeg-core/bin/";
|
|
4952
|
+
function basenameNoExt(path) {
|
|
4953
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
4954
|
+
return base.replace(/\.ts$/, "");
|
|
4955
|
+
}
|
|
4956
|
+
function claimedCheckNames(implementation) {
|
|
4957
|
+
if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
|
|
4958
|
+
return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
|
|
4894
4959
|
}
|
|
4895
|
-
|
|
4960
|
+
if (implementation.startsWith(AEG_CORE_BIN_PATH_PREFIX)) {
|
|
4961
|
+
const audience = GATE_AUDIENCE[basenameNoExt(implementation)];
|
|
4962
|
+
if (audience && isShipped(audience)) {
|
|
4963
|
+
return Array.isArray(audience.shippedAs) ? audience.shippedAs : [audience.shippedAs];
|
|
4964
|
+
}
|
|
4965
|
+
}
|
|
4966
|
+
return [];
|
|
4896
4967
|
}
|
|
4897
|
-
function
|
|
4968
|
+
function checkG6(rows, registeredCheckNames) {
|
|
4898
4969
|
const findings = [];
|
|
4899
|
-
for (const
|
|
4900
|
-
|
|
4901
|
-
if (content === undefined) {
|
|
4902
|
-
findings.push({
|
|
4903
|
-
file: quote.file,
|
|
4904
|
-
line: quote.line,
|
|
4905
|
-
citedFile: quote.citedFile,
|
|
4906
|
-
quotedText: quote.quotedText,
|
|
4907
|
-
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
|
|
4908
|
-
});
|
|
4970
|
+
for (const row of rows) {
|
|
4971
|
+
if (row.audience !== "product")
|
|
4909
4972
|
continue;
|
|
4910
|
-
|
|
4911
|
-
if (!
|
|
4973
|
+
const candidates = claimedCheckNames(row.implementation);
|
|
4974
|
+
if (!candidates.some((name) => registeredCheckNames.has(name))) {
|
|
4912
4975
|
findings.push({
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
quotedText: quote.quotedText,
|
|
4917
|
-
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
|
|
4976
|
+
row: row.action,
|
|
4977
|
+
path: row.implementation,
|
|
4978
|
+
reason: `${row.ring} row "${row.action}" is marked \`product\` but its implementation "${row.implementation}" does not resolve to a coreCheckRegistry() entry`
|
|
4918
4979
|
});
|
|
4919
4980
|
}
|
|
4920
4981
|
}
|
|
4921
|
-
return findings;
|
|
4982
|
+
return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4922
4983
|
}
|
|
4923
4984
|
// ../../packages/aeg-core/src/dead-branch-push-guard.ts
|
|
4924
4985
|
function checkDeadBranchPush(input) {
|
|
@@ -5825,7 +5886,9 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
|
|
|
5825
5886
|
"escalated",
|
|
5826
5887
|
"principal_stop",
|
|
5827
5888
|
"confidence",
|
|
5828
|
-
"reappearance"
|
|
5889
|
+
"reappearance",
|
|
5890
|
+
"repeat_finding",
|
|
5891
|
+
"repeat_failure"
|
|
5829
5892
|
])
|
|
5830
5893
|
}).strict(),
|
|
5831
5894
|
z2.object({
|
|
@@ -6329,6 +6392,10 @@ var LoopStateRecordSchema = z3.object({
|
|
|
6329
6392
|
budgets: LoopBudgetsSchema,
|
|
6330
6393
|
heldResult: roundHeadIdentity.nullable(),
|
|
6331
6394
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6395
|
+
repeatMemory: z3.object({
|
|
6396
|
+
blockingFindings: z3.array(z3.string()),
|
|
6397
|
+
lastFailure: z3.object({ signature: z3.string(), message: z3.string() }).nullable()
|
|
6398
|
+
}).strict().optional(),
|
|
6332
6399
|
recordedAt: isoTimestamp
|
|
6333
6400
|
}).strict();
|
|
6334
6401
|
var EffectRecordSchema = z3.object({
|
|
@@ -6380,7 +6447,7 @@ var ResolutionRecordSchema = z3.object({
|
|
|
6380
6447
|
consumedAt: isoTimestamp
|
|
6381
6448
|
}).strict();
|
|
6382
6449
|
// src/lib/config.ts
|
|
6383
|
-
import { execFile as execFile4, execFileSync as
|
|
6450
|
+
import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
|
|
6384
6451
|
import { promisify as promisify4 } from "node:util";
|
|
6385
6452
|
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
|
|
6386
6453
|
import { homedir } from "node:os";
|
|
@@ -6390,6 +6457,28 @@ import { z as z4 } from "zod";
|
|
|
6390
6457
|
// src/lib/agent-vendors.ts
|
|
6391
6458
|
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
6392
6459
|
|
|
6460
|
+
// src/lib/worker-boundary.ts
|
|
6461
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6462
|
+
var LOG_HEADER_KEYCHAIN_SERVICE = "Vinaya Log";
|
|
6463
|
+
var logHeaderKeychainCache = new Map;
|
|
6464
|
+
function readRealLogHeaderKeychainCredential(variable) {
|
|
6465
|
+
if (process.platform !== "darwin")
|
|
6466
|
+
return null;
|
|
6467
|
+
try {
|
|
6468
|
+
return execFileSync2("/usr/bin/security", ["find-generic-password", "-s", LOG_HEADER_KEYCHAIN_SERVICE, "-a", variable, "-w"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5000, maxBuffer: 1024 * 1024 }).replace(/\n$/, "");
|
|
6469
|
+
} catch {
|
|
6470
|
+
return null;
|
|
6471
|
+
}
|
|
6472
|
+
}
|
|
6473
|
+
function readLogHeaderKeychainCredential(variable) {
|
|
6474
|
+
const cached = logHeaderKeychainCache.get(variable);
|
|
6475
|
+
if (cached !== undefined)
|
|
6476
|
+
return cached;
|
|
6477
|
+
const value = readRealLogHeaderKeychainCredential(variable);
|
|
6478
|
+
logHeaderKeychainCache.set(variable, value);
|
|
6479
|
+
return value;
|
|
6480
|
+
}
|
|
6481
|
+
|
|
6393
6482
|
// src/lib/config.ts
|
|
6394
6483
|
var EnvEntrySchema = z4.union([
|
|
6395
6484
|
z4.literal(true),
|
|
@@ -6565,6 +6654,9 @@ var VinayaConfigSchema = z4.object({
|
|
|
6565
6654
|
briefRulesSincePr: z4.number().int().nonnegative().optional(),
|
|
6566
6655
|
agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
|
|
6567
6656
|
}).optional(),
|
|
6657
|
+
planning: z4.object({
|
|
6658
|
+
collisionThreshold: z4.number().int().nonnegative().optional()
|
|
6659
|
+
}).optional(),
|
|
6568
6660
|
prePush: z4.object({
|
|
6569
6661
|
alwaysRun: z4.array(z4.string()).optional()
|
|
6570
6662
|
}).optional(),
|
|
@@ -6739,12 +6831,17 @@ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
|
6739
6831
|
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
6740
6832
|
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
6741
6833
|
}
|
|
6742
|
-
function resolveLogsHeaderValues(headers, env) {
|
|
6834
|
+
function resolveLogsHeaderValues(headers, env, readKeychain = readLogHeaderKeychainCredential) {
|
|
6743
6835
|
if (!headers)
|
|
6744
6836
|
return;
|
|
6745
6837
|
const resolved = {};
|
|
6746
6838
|
for (const [key, value] of Object.entries(headers)) {
|
|
6747
|
-
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) =>
|
|
6839
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
|
|
6840
|
+
const fromEnv = env[name];
|
|
6841
|
+
if (fromEnv !== undefined)
|
|
6842
|
+
return fromEnv;
|
|
6843
|
+
return readKeychain(name) ?? "";
|
|
6844
|
+
});
|
|
6748
6845
|
}
|
|
6749
6846
|
return resolved;
|
|
6750
6847
|
}
|
|
@@ -6753,7 +6850,7 @@ function trustAnchorRepo() {
|
|
|
6753
6850
|
if (fromRunner)
|
|
6754
6851
|
return fromRunner;
|
|
6755
6852
|
try {
|
|
6756
|
-
const url =
|
|
6853
|
+
const url = execFileSync3("git", ["remote", "get-url", "origin"], {
|
|
6757
6854
|
encoding: "utf-8",
|
|
6758
6855
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6759
6856
|
});
|
|
@@ -6800,7 +6897,7 @@ function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
|
6800
6897
|
return ref;
|
|
6801
6898
|
}
|
|
6802
6899
|
function readTrustAnchorConfigAtRef(ref) {
|
|
6803
|
-
const raw =
|
|
6900
|
+
const raw = execFileSync3("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6804
6901
|
encoding: "utf-8",
|
|
6805
6902
|
stdio: ["ignore", "pipe", "pipe"],
|
|
6806
6903
|
timeout: 1e4
|
|
@@ -6814,7 +6911,7 @@ function ghFetchTrustAnchorConfig() {
|
|
|
6814
6911
|
const repo = trustAnchorRepo();
|
|
6815
6912
|
if (!repo)
|
|
6816
6913
|
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6817
|
-
return
|
|
6914
|
+
return execFileSync3("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
6818
6915
|
encoding: "utf-8",
|
|
6819
6916
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6820
6917
|
});
|
|
@@ -6905,7 +7002,7 @@ function loadConfig() {
|
|
|
6905
7002
|
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
6906
7003
|
|
|
6907
7004
|
// src/lib/brief-assembly.ts
|
|
6908
|
-
import { execFileSync as
|
|
7005
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
6909
7006
|
import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
|
|
6910
7007
|
import { join as join4 } from "node:path";
|
|
6911
7008
|
|
|
@@ -7612,6 +7709,16 @@ var COMMANDS = [
|
|
|
7612
7709
|
"Safe to run more than once: the server stores events by `event_id` and ignores one it already holds, so a re-sent chunk creates no duplicate, and a second run finds the folder emptied and the queue drained."
|
|
7613
7710
|
],
|
|
7614
7711
|
status: "shipped"
|
|
7712
|
+
},
|
|
7713
|
+
{
|
|
7714
|
+
name: "log set-credential",
|
|
7715
|
+
description: "Store a `logs.headers` delivery credential in the macOS login Keychain, read from standard input",
|
|
7716
|
+
details: [
|
|
7717
|
+
'For a `logs.url` server whose `headers` reference a credential by variable name (`{ "authorization": "Bearer ${VINAYA_LOG_TOKEN}" }`) on a host where that variable is not in the process environment — the case an Operator the Claude desktop app starts on macOS hits, since the token lives in an interactive shell file the app never reads. It stores the value so header resolution finds it in the Keychain when the environment does not, with no token copied into any settings file.',
|
|
7718
|
+
'The value is read from STANDARD INPUT, never a command-line argument a `ps` listing could show — `printf %s "$TOKEN" | vinaya log set-credential VINAYA_LOG_TOKEN`. Only the variable NAME, which is not a secret, sits on the command line; the value is stored under the Keychain service `Vinaya Log` keyed by that name. The command prints a confirmation naming the variable and never echoes, returns, or logs the value.',
|
|
7719
|
+
"macOS only (Linux keyrings are out of scope); it refuses with a clear message elsewhere. The environment still wins over the Keychain wherever the variable is set, so this changes nothing for a host that already exports it."
|
|
7720
|
+
],
|
|
7721
|
+
status: "shipped"
|
|
7615
7722
|
}
|
|
7616
7723
|
];
|
|
7617
7724
|
// ../../packages/sources/src/forge-adapter.ts
|
|
@@ -7629,7 +7736,7 @@ var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
|
|
|
7629
7736
|
z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
|
|
7630
7737
|
]);
|
|
7631
7738
|
// src/checks/edge-resolve.ts
|
|
7632
|
-
import { execFileSync as
|
|
7739
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
7633
7740
|
var DIRECT_ISSUE_REF = /#(\d+)/;
|
|
7634
7741
|
var issueCache = new Map;
|
|
7635
7742
|
function fetchIssueState(num, repo) {
|
|
@@ -7638,7 +7745,7 @@ function fetchIssueState(num, repo) {
|
|
|
7638
7745
|
return issueCache.get(key) ?? null;
|
|
7639
7746
|
let out = null;
|
|
7640
7747
|
try {
|
|
7641
|
-
const raw =
|
|
7748
|
+
const raw = execFileSync4("gh", [
|
|
7642
7749
|
"issue",
|
|
7643
7750
|
"view",
|
|
7644
7751
|
String(num),
|
|
@@ -7764,7 +7871,7 @@ function packageRoot(moduleUrl) {
|
|
|
7764
7871
|
}
|
|
7765
7872
|
|
|
7766
7873
|
// src/commands/doctrine.ts
|
|
7767
|
-
import { execFileSync as
|
|
7874
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
7768
7875
|
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
|
|
7769
7876
|
import { dirname as dirname3, join as join3, sep } from "node:path";
|
|
7770
7877
|
import matter2 from "gray-matter";
|
|
@@ -7774,7 +7881,7 @@ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.c
|
|
|
7774
7881
|
}
|
|
7775
7882
|
function gitToplevel(cwd) {
|
|
7776
7883
|
try {
|
|
7777
|
-
return
|
|
7884
|
+
return execFileSync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
7778
7885
|
encoding: "utf8",
|
|
7779
7886
|
stdio: ["ignore", "pipe", "pipe"]
|
|
7780
7887
|
}).trim();
|
|
@@ -7803,7 +7910,7 @@ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief
|
|
|
7803
7910
|
var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
7804
7911
|
function git(args) {
|
|
7805
7912
|
try {
|
|
7806
|
-
return
|
|
7913
|
+
return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7807
7914
|
} catch {
|
|
7808
7915
|
return "";
|
|
7809
7916
|
}
|
|
@@ -9350,6 +9457,8 @@ var defaultSink = createLogSink();
|
|
|
9350
9457
|
var activeChecks = new Map;
|
|
9351
9458
|
|
|
9352
9459
|
// src/lib/forge-write.ts
|
|
9460
|
+
var IMPORTABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
9461
|
+
var IMPORT_SEARCH_PATHSPEC = IMPORTABLE_EXTENSIONS.map((e) => `*${e}`);
|
|
9353
9462
|
var INFORMATIONAL_DISPATCH_BLOCKER_CLASSES = new Set([
|
|
9354
9463
|
"depends-on-not-merged",
|
|
9355
9464
|
"conflicts-with"
|
|
@@ -9386,7 +9495,7 @@ function parseChangedLineRanges(diffOutput) {
|
|
|
9386
9495
|
function fileDiffAgainst(ref, path) {
|
|
9387
9496
|
let out;
|
|
9388
9497
|
try {
|
|
9389
|
-
out =
|
|
9498
|
+
out = execFileSync7("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
9390
9499
|
encoding: "utf8",
|
|
9391
9500
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9392
9501
|
}).trim();
|
|
@@ -9397,7 +9506,7 @@ function fileDiffAgainst(ref, path) {
|
|
|
9397
9506
|
}
|
|
9398
9507
|
function revParse(ref) {
|
|
9399
9508
|
try {
|
|
9400
|
-
return
|
|
9509
|
+
return execFileSync7("git", ["rev-parse", "--verify", ref], {
|
|
9401
9510
|
encoding: "utf8",
|
|
9402
9511
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9403
9512
|
}).trim();
|
|
@@ -9407,7 +9516,7 @@ function revParse(ref) {
|
|
|
9407
9516
|
}
|
|
9408
9517
|
function repoRoot() {
|
|
9409
9518
|
try {
|
|
9410
|
-
return
|
|
9519
|
+
return execFileSync7("git", ["rev-parse", "--show-toplevel"], {
|
|
9411
9520
|
encoding: "utf8",
|
|
9412
9521
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9413
9522
|
}).trim();
|
|
@@ -9418,7 +9527,7 @@ function repoRoot() {
|
|
|
9418
9527
|
function changedFiles(base) {
|
|
9419
9528
|
let out;
|
|
9420
9529
|
try {
|
|
9421
|
-
out =
|
|
9530
|
+
out = execFileSync7("git", ["diff", "--name-only", `${base}...HEAD`], {
|
|
9422
9531
|
encoding: "utf8",
|
|
9423
9532
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9424
9533
|
}).trim();
|
|
@@ -9479,7 +9588,7 @@ var CHECK_NAME = "exec-bits";
|
|
|
9479
9588
|
var EXECUTABLE_MODE = "100755";
|
|
9480
9589
|
function git2(args) {
|
|
9481
9590
|
try {
|
|
9482
|
-
return
|
|
9591
|
+
return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
9483
9592
|
} catch {
|
|
9484
9593
|
return null;
|
|
9485
9594
|
}
|