@attalabs/vinaya 0.34.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/LICENSE +104 -201
- package/README.md +1 -1
- package/aeg-root/roles/planner/reference.md +21 -6
- 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 +1450 -1350
- package/dist/checks/bin/check-branch-topology.js +1432 -1342
- package/dist/checks/bin/check-brief-shape.js +1451 -1351
- package/dist/checks/bin/check-changeset-coverage.js +1502 -1360
- package/dist/checks/bin/check-closes-n.js +1432 -1342
- package/dist/checks/bin/check-coherence.js +1472 -1351
- package/dist/checks/bin/check-dead-branch-push.js +1408 -1339
- package/dist/checks/bin/check-dispatch-readiness.js +1475 -1354
- package/dist/checks/bin/check-doc-coverage-push.js +1502 -1360
- package/dist/checks/bin/check-doc-coverage.js +1504 -1362
- package/dist/checks/bin/check-doctrine-no-procedures.js +1449 -1349
- package/dist/checks/bin/check-doctrine-portability.js +1502 -1360
- package/dist/checks/bin/check-evidence-fresh.js +1508 -1366
- package/dist/checks/bin/check-exec-bits.js +1502 -1360
- package/dist/checks/bin/check-first-push-dispatch.js +1476 -1355
- package/dist/checks/bin/check-issue-assignment.js +1432 -1342
- package/dist/checks/bin/check-issue-milestone-attach.js +1408 -1339
- package/dist/checks/bin/check-issue-objectives-numbering.js +1449 -1349
- package/dist/checks/bin/check-issue-parts-coverage.js +1408 -1339
- package/dist/checks/bin/check-issue-surface-globs.js +1475 -1354
- package/dist/checks/bin/check-issue-title-grammar.js +1408 -1339
- package/dist/checks/bin/check-issue-tranche-label.js +1408 -1339
- package/dist/checks/bin/check-main-branch-refusal.js +1410 -1341
- package/dist/checks/bin/check-no-disk-state.js +1410 -1341
- package/dist/checks/bin/check-pr-premise-reassert.js +1449 -1349
- package/dist/checks/bin/check-pr-report-density.js +1410 -1341
- package/dist/checks/bin/check-principal-test-plan-wait.js +1410 -1341
- package/dist/checks/bin/check-quoted-command.js +1500 -1358
- package/dist/checks/bin/check-reader-resolvable-prose.js +1500 -1358
- package/dist/checks/bin/check-registry-gates.js +1410 -1341
- package/dist/checks/bin/check-retired-vocabulary.js +1500 -1358
- package/dist/checks/bin/check-review-gate.js +1463 -1363
- package/dist/checks/bin/check-single-plan-pr.js +1408 -1339
- package/dist/checks/bin/check-surface-scope.js +1432 -1342
- package/dist/checks/bin/check-test-plan.js +1408 -1339
- package/dist/checks/bin/check-token-collection-wired.js +1410 -1341
- package/dist/checks/bin/check-token-report.js +1410 -1341
- package/dist/checks/bin/check-workspace-escape.js +1501 -1359
- package/dist/index.js +4261 -1917
- package/dist/lib/pre-push-cache-test-run.js +130 -19
- package/dist/lib/pre-push-select-tests.js +86 -17
- package/package.json +2 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +153 -37
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +87 -24
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +9 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +31 -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 +52 -3
- 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/gate-cutovers.ts +49 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +13 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +148 -54
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +26 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives-cutover-config.ts +31 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +15 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +122 -23
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +38 -3
- 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/[root-of-the-server]__02a-3g8._.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]__07uhu5z._.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/_15gdg48._.js +2 -2
- 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/{2174nz5he_oc4.js → 2o9l0b7eqbr57.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0q9p7c6vn-x2w.js → 3lqjwjrcvq481.js} +4 -4
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3xnma0-359j17.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/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{HmoeqXdX1E4drt7GReFOO → z1fTSBP6ZlUjObzFIp-qq}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{HmoeqXdX1E4drt7GReFOO → z1fTSBP6ZlUjObzFIp-qq}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{HmoeqXdX1E4drt7GReFOO → z1fTSBP6ZlUjObzFIp-qq}/_ssgManifest.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-doc-coverage.ts
|
|
4
|
-
import { execFileSync as
|
|
4
|
+
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
5
5
|
import { existsSync as existsSync8, readFileSync as readFileSync7 } from "node:fs";
|
|
6
6
|
// ../../packages/aeg-core/src/gate-audience.ts
|
|
7
7
|
var GATE_AUDIENCE = {
|
|
@@ -2466,16 +2466,42 @@ function blockingSeverities(scale, threshold) {
|
|
|
2466
2466
|
}
|
|
2467
2467
|
return scale.slice(0, idx + 1);
|
|
2468
2468
|
}
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
}
|
|
2478
|
-
|
|
2469
|
+
var DEFERRAL_REASON_TEXT = {
|
|
2470
|
+
"unchanged-line": "unchanged line",
|
|
2471
|
+
"outside-surface": "outside the Surface"
|
|
2472
|
+
};
|
|
2473
|
+
var SECURITY_HIGH_AND_ABOVE = blockingSeverities(SECURITY_SEVERITY_ORDER, "HIGH");
|
|
2474
|
+
function classifyFinding(finding, scale, threshold, context = {}) {
|
|
2475
|
+
if (!scale.includes(finding.severity)) {
|
|
2476
|
+
throw new Error(`classifyFinding: severity "${finding.severity}" is not one of ${scale.join(" > ")}`);
|
|
2477
|
+
}
|
|
2478
|
+
const location = finding.location;
|
|
2479
|
+
const effectiveSeverity = location !== undefined && isProseLocation(location) ? PROSE_CAP_SEVERITY : finding.severity;
|
|
2480
|
+
const wouldBlock = blockingSeverities(scale, threshold).includes(effectiveSeverity);
|
|
2481
|
+
if (!wouldBlock)
|
|
2482
|
+
return { outcome: "non_blocking", deferralReason: null };
|
|
2483
|
+
const hasLocation = location !== undefined && location.length > 0;
|
|
2484
|
+
if (hasLocation && context.inSurface && !context.inSurface(location)) {
|
|
2485
|
+
return { outcome: "deferred", deferralReason: "outside-surface" };
|
|
2486
|
+
}
|
|
2487
|
+
if (hasLocation && context.changedLine && !SECURITY_HIGH_AND_ABOVE.includes(effectiveSeverity)) {
|
|
2488
|
+
if (!context.changedLine(location)) {
|
|
2489
|
+
return { outcome: "deferred", deferralReason: "unchanged-line" };
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
return { outcome: "blocking", deferralReason: null };
|
|
2493
|
+
}
|
|
2494
|
+
function evaluateReviewFindings(findings, scale, threshold, context = {}) {
|
|
2495
|
+
const blockingFindings = [];
|
|
2496
|
+
const deferredFindings = [];
|
|
2497
|
+
for (const f of findings) {
|
|
2498
|
+
const c = classifyFinding(f, scale, threshold, context);
|
|
2499
|
+
if (c.outcome === "blocking")
|
|
2500
|
+
blockingFindings.push(f);
|
|
2501
|
+
else if (c.outcome === "deferred")
|
|
2502
|
+
deferredFindings.push({ finding: f, reason: c.deferralReason });
|
|
2503
|
+
}
|
|
2504
|
+
return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings, deferredFindings };
|
|
2479
2505
|
}
|
|
2480
2506
|
function isConsequentialFinding(finding) {
|
|
2481
2507
|
return finding.state !== "resolved";
|
|
@@ -2483,11 +2509,11 @@ function isConsequentialFinding(finding) {
|
|
|
2483
2509
|
function consequentialFindings(findings) {
|
|
2484
2510
|
return findings.filter((f) => isConsequentialFinding(f));
|
|
2485
2511
|
}
|
|
2486
|
-
function evaluateCodeReview(findings, policy) {
|
|
2487
|
-
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
|
|
2512
|
+
function evaluateCodeReview(findings, policy, context = {}) {
|
|
2513
|
+
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold, context);
|
|
2488
2514
|
}
|
|
2489
|
-
function evaluateSecurityReview(findings, policy) {
|
|
2490
|
-
return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold);
|
|
2515
|
+
function evaluateSecurityReview(findings, policy, context = {}) {
|
|
2516
|
+
return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold, context);
|
|
2491
2517
|
}
|
|
2492
2518
|
function isKnownSeverity(scale, value) {
|
|
2493
2519
|
return scale.includes(value);
|
|
@@ -3401,1511 +3427,1548 @@ function checkPrReportDensity(prBody) {
|
|
|
3401
3427
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3402
3428
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3403
3429
|
}
|
|
3404
|
-
// ../../packages/aeg-core/src/
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
{ name: "Sizing", pattern: "Sizing" },
|
|
3412
|
-
{ name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
|
|
3413
|
-
{ name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
|
|
3414
|
-
{ name: "Traps to avoid", pattern: "Traps" },
|
|
3415
|
-
{ name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
|
|
3416
|
-
{ name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
|
|
3417
|
-
{ name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
|
|
3430
|
+
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3431
|
+
var PRODUCT_SLUG_SCOPE = [
|
|
3432
|
+
"apps/cli/src",
|
|
3433
|
+
".github/workflows",
|
|
3434
|
+
".vinaya",
|
|
3435
|
+
"apps/cli/README.md",
|
|
3436
|
+
"packages/sources/README.md"
|
|
3418
3437
|
];
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
const errors = [];
|
|
3422
|
-
for (const f of RATIONALE_FIELDS) {
|
|
3423
|
-
if (!hasRationaleField(body, f.pattern)) {
|
|
3424
|
-
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).`);
|
|
3425
|
-
continue;
|
|
3426
|
-
}
|
|
3427
|
-
if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
|
|
3428
|
-
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.");
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3432
|
-
}
|
|
3433
|
-
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3434
|
-
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3435
|
-
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3436
|
-
return { status: "pass", errors: [] };
|
|
3437
|
-
const result = objectivesOf(body);
|
|
3438
|
-
if (result.ok)
|
|
3439
|
-
return { status: "pass", errors: [] };
|
|
3440
|
-
return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
|
|
3438
|
+
function isUnderOrEqual(path, prefix) {
|
|
3439
|
+
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3441
3440
|
}
|
|
3442
|
-
function
|
|
3443
|
-
|
|
3444
|
-
const heading = headingRe.exec(body);
|
|
3445
|
-
if (!heading)
|
|
3446
|
-
return null;
|
|
3447
|
-
const afterHeading = body.slice(heading.index + heading[0].length);
|
|
3448
|
-
const next = /^##[ \t]/m.exec(afterHeading);
|
|
3449
|
-
return next ? afterHeading.slice(0, next.index) : afterHeading;
|
|
3441
|
+
function isProductScopeFile(path) {
|
|
3442
|
+
return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
|
|
3450
3443
|
}
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
const start = text.indexOf("`", i);
|
|
3455
|
-
if (start === -1)
|
|
3456
|
-
return false;
|
|
3457
|
-
const end = text.indexOf("`", start + 1);
|
|
3458
|
-
if (end === -1)
|
|
3459
|
-
return false;
|
|
3460
|
-
if (text.slice(start + 1, end).includes("/"))
|
|
3461
|
-
return true;
|
|
3462
|
-
i = end + 1;
|
|
3463
|
-
}
|
|
3464
|
-
return false;
|
|
3444
|
+
var SHIPS_PREFIX = "aeg-root/";
|
|
3445
|
+
function shipsArchivePrefix(shipsPrefix) {
|
|
3446
|
+
return `${shipsPrefix}tranches/completed/`;
|
|
3465
3447
|
}
|
|
3466
|
-
var
|
|
3467
|
-
function
|
|
3468
|
-
|
|
3448
|
+
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3449
|
+
function normalizeSpecPath(entry) {
|
|
3450
|
+
let out = entry.replace(/\\/g, "/");
|
|
3451
|
+
while (out.startsWith("./"))
|
|
3452
|
+
out = out.slice(2);
|
|
3453
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3454
|
+
while (out.endsWith("/"))
|
|
3455
|
+
out = out.slice(0, -1);
|
|
3456
|
+
return out;
|
|
3469
3457
|
}
|
|
3470
|
-
function
|
|
3471
|
-
|
|
3458
|
+
function isSpecFile2(path, specPaths) {
|
|
3459
|
+
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
3460
|
+
return true;
|
|
3461
|
+
if (!path.endsWith(".md"))
|
|
3462
|
+
return false;
|
|
3463
|
+
return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
|
|
3472
3464
|
}
|
|
3473
|
-
function
|
|
3474
|
-
|
|
3475
|
-
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3476
|
-
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3477
|
-
return extMatch !== null && extMatch.index > 0;
|
|
3465
|
+
function isClaudeMdFile(path) {
|
|
3466
|
+
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3478
3467
|
}
|
|
3479
|
-
function
|
|
3480
|
-
|
|
3468
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
3469
|
+
if (path.startsWith(shipsPrefix)) {
|
|
3470
|
+
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3471
|
+
}
|
|
3472
|
+
if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
|
|
3473
|
+
return "reader-facing";
|
|
3474
|
+
}
|
|
3475
|
+
if (isClaudeMdFile(path))
|
|
3476
|
+
return "internal";
|
|
3477
|
+
if (isSpecFile2(path, specPaths))
|
|
3478
|
+
return "spec";
|
|
3479
|
+
if (isProductScopeFile(path))
|
|
3480
|
+
return "product";
|
|
3481
|
+
return null;
|
|
3481
3482
|
}
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
if (
|
|
3485
|
-
return
|
|
3486
|
-
const inLine = /^in:\s*(.+)$/im.exec(section);
|
|
3487
|
-
const outLine = /^out:\s*(.+)$/im.exec(section);
|
|
3488
|
-
const errors = [];
|
|
3489
|
-
if (!inLine)
|
|
3490
|
-
errors.push("`## Surface` has no `in:` line.");
|
|
3491
|
-
if (!outLine)
|
|
3492
|
-
errors.push("`## Surface` has no `out:` line.");
|
|
3493
|
-
if (errors.length > 0)
|
|
3494
|
-
return { ok: false, errors };
|
|
3495
|
-
const inGlobs = splitGlobList(inLine[1]);
|
|
3496
|
-
const outGlobs = splitGlobList(outLine[1]);
|
|
3497
|
-
for (const g of [...inGlobs, ...outGlobs]) {
|
|
3498
|
-
if (looksLikeFilePath(g)) {
|
|
3499
|
-
errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
|
|
3500
|
-
}
|
|
3483
|
+
var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
3484
|
+
function stripNonProse(path, content) {
|
|
3485
|
+
if (path.endsWith(".md")) {
|
|
3486
|
+
return content.replace(/```.*?```/gs, (m) => m.replace(/[^\n]/g, "")).replace(/`[^`\n]*`/g, (m) => m.replace(/[^\n]/g, ""));
|
|
3501
3487
|
}
|
|
3502
|
-
if (
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
return { ok: true, value: { in: inGlobs, out: outGlobs } };
|
|
3488
|
+
if (path.endsWith(".tsx") || path.endsWith(".ts")) {
|
|
3489
|
+
return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
|
|
3490
|
+
}
|
|
3491
|
+
return content;
|
|
3507
3492
|
}
|
|
3508
|
-
function
|
|
3509
|
-
|
|
3510
|
-
const p = path.replace(/\/+$/, "");
|
|
3511
|
-
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
3493
|
+
function stripNonProseForProduct(path, content) {
|
|
3494
|
+
return path.endsWith(".md") ? stripNonProse(path, content) : content;
|
|
3512
3495
|
}
|
|
3513
|
-
function
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
for (const glob of surface.value.in) {
|
|
3519
|
-
if (!resolvesToFile(glob)) {
|
|
3520
|
-
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.`);
|
|
3521
|
-
}
|
|
3496
|
+
function lineAt(content, index) {
|
|
3497
|
+
let line = 1;
|
|
3498
|
+
for (let i = 0;i < index; i++) {
|
|
3499
|
+
if (content.charCodeAt(i) === 10)
|
|
3500
|
+
line++;
|
|
3522
3501
|
}
|
|
3523
|
-
return
|
|
3502
|
+
return line;
|
|
3524
3503
|
}
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
}
|
|
3534
|
-
return violations.length > 0 ? { ok: false, violations } : { ok: true };
|
|
3504
|
+
var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
|
|
3505
|
+
var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
|
|
3506
|
+
var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
|
|
3507
|
+
function legacySlugPattern(legacySlugs) {
|
|
3508
|
+
if (legacySlugs.length === 0)
|
|
3509
|
+
return null;
|
|
3510
|
+
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
3511
|
+
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
3535
3512
|
}
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
const
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3513
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
3514
|
+
const findings = [];
|
|
3515
|
+
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3516
|
+
const grandfathered = new Set(specGrandfather);
|
|
3517
|
+
const patterns = [
|
|
3518
|
+
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3519
|
+
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3520
|
+
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3521
|
+
];
|
|
3522
|
+
const productPatterns = [
|
|
3523
|
+
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3524
|
+
];
|
|
3525
|
+
const specPatterns = [
|
|
3526
|
+
...patterns,
|
|
3527
|
+
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3528
|
+
];
|
|
3529
|
+
for (const file of files) {
|
|
3530
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3531
|
+
if (!cls || cls === "internal")
|
|
3548
3532
|
continue;
|
|
3549
|
-
|
|
3550
|
-
const n = Number.parseInt(m[1], 10);
|
|
3551
|
-
const refs = m[2];
|
|
3552
|
-
const text = m[3].trim();
|
|
3553
|
-
if (text.length === 0) {
|
|
3554
|
-
errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
|
|
3533
|
+
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
3555
3534
|
continue;
|
|
3556
|
-
|
|
3557
|
-
if (partHasBacktickedPath(text) && partWordCount(stripPartBackticks(text)) < PART_MIN_WORDS_OUTSIDE_BACKTICKS) {
|
|
3558
|
-
errors.push(`Part ${n} is little more than a file path — a Part names an outcome and symbols, never a bare path.`);
|
|
3535
|
+
if (cls === "spec" && grandfathered.has(file.path))
|
|
3559
3536
|
continue;
|
|
3537
|
+
const blocking = cls === "product" || cls === "spec";
|
|
3538
|
+
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3539
|
+
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3540
|
+
for (const { pattern, what, group } of patternsToRun) {
|
|
3541
|
+
pattern.lastIndex = 0;
|
|
3542
|
+
let match = pattern.exec(scrubbed);
|
|
3543
|
+
while (match !== null) {
|
|
3544
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
3545
|
+
const citedIndex = match.index + match[0].indexOf(cited);
|
|
3546
|
+
findings.push({
|
|
3547
|
+
file: file.path,
|
|
3548
|
+
line: lineAt(scrubbed, citedIndex),
|
|
3549
|
+
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3550
|
+
blocking
|
|
3551
|
+
});
|
|
3552
|
+
match = pattern.exec(scrubbed);
|
|
3553
|
+
}
|
|
3560
3554
|
}
|
|
3561
|
-
const objectiveIds = [...refs.matchAll(/O(\d+)/g)].map((r) => Number.parseInt(r[1], 10));
|
|
3562
|
-
parts.push({ n, objectiveIds, text });
|
|
3563
3555
|
}
|
|
3564
|
-
|
|
3565
|
-
errors.push("the `## Parts` section has no well-formed `Part <n> (<refs>) — <outcome>` lines.");
|
|
3566
|
-
}
|
|
3567
|
-
if (errors.length > 0)
|
|
3568
|
-
return { ok: false, errors };
|
|
3569
|
-
return { ok: true, value: parts };
|
|
3570
|
-
}
|
|
3571
|
-
function checkPartsCiteDefinedObjectives(body) {
|
|
3572
|
-
const parts = parseIssueParts(body);
|
|
3573
|
-
const objectives = objectivesOf(body);
|
|
3574
|
-
if (!parts.ok || !objectives.ok)
|
|
3575
|
-
return { status: "pass", errors: [] };
|
|
3576
|
-
const definedIds = new Set(objectives.objectives.map((o) => Number.parseInt(o.id.slice(1), 10)));
|
|
3577
|
-
const errors = [];
|
|
3578
|
-
for (const part of parts.value) {
|
|
3579
|
-
for (const objectiveId of part.objectiveIds) {
|
|
3580
|
-
if (!definedIds.has(objectiveId)) {
|
|
3581
|
-
errors.push(`issue-validation Parts: Part ${part.n} cites O${objectiveId}, which the Issue's own \`## Objectives\` section does not define.`);
|
|
3582
|
-
}
|
|
3583
|
-
}
|
|
3584
|
-
}
|
|
3585
|
-
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3586
|
-
}
|
|
3587
|
-
function isTaskIssueLabelSet(labels) {
|
|
3588
|
-
return hasLabel("tranche", labels);
|
|
3589
|
-
}
|
|
3590
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
3591
|
-
return { status: "pass", errors: [] };
|
|
3592
|
-
}
|
|
3593
|
-
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
3594
|
-
if (!isTaskIssueLabelSet(labels))
|
|
3595
|
-
return { status: "pass", errors: [] };
|
|
3596
|
-
if (resolvedMilestoneTitle === null)
|
|
3597
|
-
return { status: "pass", errors: [] };
|
|
3598
|
-
if (currentMilestoneTitle === resolvedMilestoneTitle)
|
|
3599
|
-
return { status: "pass", errors: [] };
|
|
3600
|
-
return {
|
|
3601
|
-
status: "fail",
|
|
3602
|
-
errors: [
|
|
3603
|
-
`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}".`
|
|
3604
|
-
]
|
|
3605
|
-
};
|
|
3606
|
-
}
|
|
3607
|
-
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
3608
|
-
function isControlCodePoint(codePoint) {
|
|
3609
|
-
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
3610
|
-
}
|
|
3611
|
-
function isDisplayControlCodePoint(codePoint) {
|
|
3612
|
-
return codePoint >= 8203 && codePoint <= 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
|
|
3556
|
+
return findings;
|
|
3613
3557
|
}
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
const shown = values.slice(0, MESSAGE_VALUE_COUNT_MAX).map((v) => `\`${forMessage(v)}\``);
|
|
3617
|
-
const rest = values.length - shown.length;
|
|
3618
|
-
return rest > 0 ? `${shown.join(", ")} and ${rest} more` : shown.join(", ");
|
|
3558
|
+
function escapeTerm(term) {
|
|
3559
|
+
return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3619
3560
|
}
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
const
|
|
3623
|
-
|
|
3624
|
-
const codePoint = ch.codePointAt(0) ?? 0;
|
|
3625
|
-
if (isControlCodePoint(codePoint) || isDisplayControlCodePoint(codePoint))
|
|
3626
|
-
continue;
|
|
3627
|
-
kept.push(ch);
|
|
3628
|
-
}
|
|
3629
|
-
const cleaned = kept.join("").trim();
|
|
3630
|
-
if (cleaned.length === 0)
|
|
3631
|
-
return "(unprintable)";
|
|
3632
|
-
const points = Array.from(cleaned);
|
|
3633
|
-
return points.length > MESSAGE_VALUE_MAX ? `${points.slice(0, MESSAGE_VALUE_MAX).join("")}…` : cleaned;
|
|
3561
|
+
function containsWholeWord(text, term) {
|
|
3562
|
+
const escaped = escapeTerm(term);
|
|
3563
|
+
const re = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)`, "i");
|
|
3564
|
+
return re.test(text);
|
|
3634
3565
|
}
|
|
3635
|
-
function
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
const errors = [];
|
|
3644
|
-
if (field.unreadable) {
|
|
3645
|
-
return {
|
|
3646
|
-
status: "fail",
|
|
3647
|
-
errors: [
|
|
3648
|
-
`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.`
|
|
3649
|
-
]
|
|
3650
|
-
};
|
|
3651
|
-
}
|
|
3652
|
-
const unregistered = field.names.filter((p) => !known.has(p));
|
|
3653
|
-
if (unregistered.length > 0) {
|
|
3654
|
-
const caseHints = unregistered.map((p) => {
|
|
3655
|
-
const row = [...known].find((k) => k.toLowerCase() === p.toLowerCase());
|
|
3656
|
-
return row ? `\`${forMessage(p)}\` differs from the registered \`${forMessage(row)}\` only in case` : null;
|
|
3657
|
-
}).filter((h) => h !== null);
|
|
3658
|
-
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.`);
|
|
3659
|
-
}
|
|
3660
|
-
if (field.names.length === 0) {
|
|
3661
|
-
const residue = field.unparsed.length > 0 ? ` — ${residueForMessage(field.unparsed)}` : " — the field is empty";
|
|
3662
|
-
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.`);
|
|
3663
|
-
} else if (field.unparsed.length > 0) {
|
|
3664
|
-
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.`);
|
|
3566
|
+
function findWholeWordLine(content, term) {
|
|
3567
|
+
const lines = content.split(`
|
|
3568
|
+
`);
|
|
3569
|
+
let lineNo = 0;
|
|
3570
|
+
for (const line of lines) {
|
|
3571
|
+
lineNo++;
|
|
3572
|
+
if (containsWholeWord(line, term))
|
|
3573
|
+
return lineNo;
|
|
3665
3574
|
}
|
|
3666
|
-
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
3667
|
-
}
|
|
3668
|
-
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;
|
|
3669
|
-
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
3670
|
-
|
|
3671
|
-
// ../../packages/aeg-core/src/task-branch-identity.ts
|
|
3672
|
-
var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
|
|
3673
|
-
var TRANCHE_BRANCH_PATTERN = /^task\/([^/]+)\/([^/]+)$/;
|
|
3674
|
-
function parseTaskBranchIdentity(branch) {
|
|
3675
|
-
const issueMatch = ISSUE_BRANCH_PATTERN.exec(branch);
|
|
3676
|
-
if (issueMatch)
|
|
3677
|
-
return { kind: "issue", issueNumber: Number(issueMatch[1]) };
|
|
3678
|
-
const trancheMatch = TRANCHE_BRANCH_PATTERN.exec(branch);
|
|
3679
|
-
if (trancheMatch)
|
|
3680
|
-
return { kind: "tranche", tranche: trancheMatch[1], taskId: trancheMatch[2] };
|
|
3681
3575
|
return null;
|
|
3682
3576
|
}
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
3577
|
+
function definesOrLinksGlossary(content, term) {
|
|
3578
|
+
const escaped = escapeTerm(term);
|
|
3579
|
+
const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
|
|
3580
|
+
if (definesInline)
|
|
3581
|
+
return true;
|
|
3582
|
+
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3690
3583
|
}
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
const
|
|
3694
|
-
|
|
3695
|
-
if (!
|
|
3696
|
-
continue;
|
|
3697
|
-
if (e.facts.stateReason === "not_planned")
|
|
3584
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
3585
|
+
const findings = [];
|
|
3586
|
+
for (const file of files) {
|
|
3587
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3588
|
+
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
3698
3589
|
continue;
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3590
|
+
const scrubbed = stripNonProse(file.path, file.content);
|
|
3591
|
+
for (const term of glossaryTerms) {
|
|
3592
|
+
const line = findWholeWordLine(scrubbed, term);
|
|
3593
|
+
if (line === null)
|
|
3702
3594
|
continue;
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3595
|
+
if (definesOrLinksGlossary(scrubbed, term))
|
|
3596
|
+
continue;
|
|
3597
|
+
findings.push({
|
|
3598
|
+
file: file.path,
|
|
3599
|
+
line,
|
|
3600
|
+
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3601
|
+
blocking: false
|
|
3710
3602
|
});
|
|
3711
3603
|
}
|
|
3712
3604
|
}
|
|
3713
|
-
|
|
3714
|
-
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
3715
|
-
return {
|
|
3716
|
-
check: "A1",
|
|
3717
|
-
status,
|
|
3718
|
-
failures,
|
|
3719
|
-
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
3720
|
-
};
|
|
3605
|
+
return findings;
|
|
3721
3606
|
}
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3607
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g;
|
|
3608
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g;
|
|
3609
|
+
function extractComments(path, content) {
|
|
3610
|
+
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3611
|
+
return content.replace(/[^\n]/g, "");
|
|
3612
|
+
let state = "code";
|
|
3613
|
+
let out = "";
|
|
3614
|
+
const n = content.length;
|
|
3615
|
+
let i = 0;
|
|
3616
|
+
const blank = (ch) => ch === `
|
|
3617
|
+
` ? `
|
|
3618
|
+
` : " ";
|
|
3619
|
+
while (i < n) {
|
|
3620
|
+
const c = content[i];
|
|
3621
|
+
const next = i + 1 < n ? content[i + 1] : "";
|
|
3622
|
+
if (state === "code") {
|
|
3623
|
+
if (c === "/" && next === "/") {
|
|
3624
|
+
state = "line-comment";
|
|
3625
|
+
out += c;
|
|
3626
|
+
i++;
|
|
3627
|
+
continue;
|
|
3628
|
+
}
|
|
3629
|
+
if (c === "/" && next === "*") {
|
|
3630
|
+
state = "block-comment";
|
|
3631
|
+
out += c;
|
|
3632
|
+
i++;
|
|
3633
|
+
continue;
|
|
3634
|
+
}
|
|
3635
|
+
if (c === "'") {
|
|
3636
|
+
state = "single-quote";
|
|
3637
|
+
out += blank(c);
|
|
3638
|
+
i++;
|
|
3639
|
+
continue;
|
|
3640
|
+
}
|
|
3641
|
+
if (c === '"') {
|
|
3642
|
+
state = "double-quote";
|
|
3643
|
+
out += blank(c);
|
|
3644
|
+
i++;
|
|
3645
|
+
continue;
|
|
3646
|
+
}
|
|
3647
|
+
if (c === "`") {
|
|
3648
|
+
state = "template";
|
|
3649
|
+
out += blank(c);
|
|
3650
|
+
i++;
|
|
3651
|
+
continue;
|
|
3652
|
+
}
|
|
3653
|
+
out += blank(c);
|
|
3654
|
+
i++;
|
|
3726
3655
|
continue;
|
|
3727
|
-
if (e.facts.prState === "merged" && e.facts.issueState !== "closed") {
|
|
3728
|
-
failures.push({
|
|
3729
|
-
code: "auto-close-misfire",
|
|
3730
|
-
issue: e.task.issue,
|
|
3731
|
-
tranche: e.trancheSlug,
|
|
3732
|
-
task: e.task.id,
|
|
3733
|
-
reason: "Closing PR is merged but Issue is still open (GitHub auto-close misfire)",
|
|
3734
|
-
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
3735
|
-
});
|
|
3736
3656
|
}
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
};
|
|
3746
|
-
}
|
|
3747
|
-
function checkT1(entries) {
|
|
3748
|
-
const failures = [];
|
|
3749
|
-
for (const e of entries) {
|
|
3750
|
-
if (e.task.issue === null)
|
|
3751
|
-
continue;
|
|
3752
|
-
if (e.facts === undefined) {
|
|
3753
|
-
failures.push({
|
|
3754
|
-
code: "phantom-issue-ref",
|
|
3755
|
-
issue: e.task.issue,
|
|
3756
|
-
tranche: e.trancheSlug,
|
|
3757
|
-
task: e.task.id,
|
|
3758
|
-
reason: `Issue #${e.task.issue} in topology does not resolve to a real GitHub Issue`
|
|
3759
|
-
});
|
|
3760
|
-
}
|
|
3761
|
-
}
|
|
3762
|
-
return { check: "T1", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
3763
|
-
}
|
|
3764
|
-
function checkT2(openIssuesBySlug, topologyIssuesBySlug, ciTrancheSlug) {
|
|
3765
|
-
const failures = [];
|
|
3766
|
-
for (const [slug, openNums] of openIssuesBySlug) {
|
|
3767
|
-
if (ciTrancheSlug && slug !== ciTrancheSlug)
|
|
3768
|
-
continue;
|
|
3769
|
-
const topologySet = topologyIssuesBySlug.get(slug) ?? new Set;
|
|
3770
|
-
for (const num of openNums) {
|
|
3771
|
-
if (!topologySet.has(num)) {
|
|
3772
|
-
failures.push({
|
|
3773
|
-
code: "orphan-task",
|
|
3774
|
-
issue: num,
|
|
3775
|
-
tranche: slug,
|
|
3776
|
-
reason: `Issue #${num} is open and labeled ${trancheLabel(slug)} but does not appear in the topology file`
|
|
3777
|
-
});
|
|
3657
|
+
if (state === "line-comment") {
|
|
3658
|
+
if (c === `
|
|
3659
|
+
`) {
|
|
3660
|
+
state = "code";
|
|
3661
|
+
out += `
|
|
3662
|
+
`;
|
|
3663
|
+
i++;
|
|
3664
|
+
continue;
|
|
3778
3665
|
}
|
|
3666
|
+
out += c;
|
|
3667
|
+
i++;
|
|
3668
|
+
continue;
|
|
3779
3669
|
}
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
...result,
|
|
3788
|
-
status: "info",
|
|
3789
|
-
note: result.note ?? "T2 findings are non-blocking outside plan PRs (point-of-power principle) — see aeg-root/enforcement.md."
|
|
3790
|
-
};
|
|
3791
|
-
}
|
|
3792
|
-
function checkT3(entries, ciTrancheSlug, enrichedEntries, forgeUnavailableSlugs) {
|
|
3793
|
-
const preEnforcement = new Set;
|
|
3794
|
-
if (enrichedEntries) {
|
|
3795
|
-
for (const e of enrichedEntries) {
|
|
3796
|
-
if (isGrandfathered(e.facts?.closedAt) || isGrandfathered(e.facts?.mergedAt)) {
|
|
3797
|
-
preEnforcement.add(e.trancheSlug);
|
|
3670
|
+
if (state === "block-comment") {
|
|
3671
|
+
if (c === "*" && next === "/") {
|
|
3672
|
+
out += c;
|
|
3673
|
+
out += next;
|
|
3674
|
+
state = "code";
|
|
3675
|
+
i += 2;
|
|
3676
|
+
continue;
|
|
3798
3677
|
}
|
|
3678
|
+
out += c === `
|
|
3679
|
+
` ? `
|
|
3680
|
+
` : c;
|
|
3681
|
+
i++;
|
|
3682
|
+
continue;
|
|
3799
3683
|
}
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
if (
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
failures.push({
|
|
3808
|
-
code: "tbd-in-active-tranche",
|
|
3809
|
-
issue: null,
|
|
3810
|
-
tranche: e.trancheSlug,
|
|
3811
|
-
task: e.task.id,
|
|
3812
|
-
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`,
|
|
3813
|
-
grandfathered: true
|
|
3814
|
-
});
|
|
3815
|
-
continue;
|
|
3684
|
+
const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
|
|
3685
|
+
if (c === "\\") {
|
|
3686
|
+
out += blank(c);
|
|
3687
|
+
i++;
|
|
3688
|
+
if (i < n) {
|
|
3689
|
+
out += blank(content[i]);
|
|
3690
|
+
i++;
|
|
3816
3691
|
}
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
});
|
|
3692
|
+
continue;
|
|
3693
|
+
}
|
|
3694
|
+
if (c === closer) {
|
|
3695
|
+
state = "code";
|
|
3696
|
+
out += blank(c);
|
|
3697
|
+
i++;
|
|
3698
|
+
continue;
|
|
3825
3699
|
}
|
|
3700
|
+
out += blank(c);
|
|
3701
|
+
i++;
|
|
3826
3702
|
}
|
|
3827
|
-
|
|
3828
|
-
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
3829
|
-
return {
|
|
3830
|
-
check: "T3",
|
|
3831
|
-
status,
|
|
3832
|
-
failures,
|
|
3833
|
-
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
3834
|
-
};
|
|
3703
|
+
return out;
|
|
3835
3704
|
}
|
|
3836
|
-
function
|
|
3837
|
-
const
|
|
3838
|
-
|
|
3839
|
-
|
|
3705
|
+
function checkSourceComments(files, allowlist = []) {
|
|
3706
|
+
const findings = [];
|
|
3707
|
+
const allowed = new Set(allowlist);
|
|
3708
|
+
const patterns = [
|
|
3709
|
+
{ pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
|
|
3710
|
+
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3711
|
+
];
|
|
3712
|
+
for (const file of files) {
|
|
3713
|
+
if (!file.path.endsWith(".ts"))
|
|
3840
3714
|
continue;
|
|
3841
|
-
if (
|
|
3715
|
+
if (allowed.has(file.path))
|
|
3842
3716
|
continue;
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
tranche: e.trancheSlug,
|
|
3854
|
-
task: e.task.id,
|
|
3855
|
-
reason: `INTERNAL: parsed a self-dependency (depends-on ${dep}) — this is a parser bug in parseRationaleDeps, not a real dependency. Please report it upstream.`
|
|
3856
|
-
});
|
|
3857
|
-
continue;
|
|
3858
|
-
}
|
|
3859
|
-
const depFacts = depEntry.facts;
|
|
3860
|
-
const depClosed = depFacts?.issueState === "closed";
|
|
3861
|
-
if (!depClosed) {
|
|
3862
|
-
failures.push({
|
|
3863
|
-
code: "dispatched-on-unmet-deps",
|
|
3864
|
-
issue: e.task.issue,
|
|
3865
|
-
tranche: e.trancheSlug,
|
|
3866
|
-
task: e.task.id,
|
|
3867
|
-
reason: `Task has open PR but depends-on ${dep} (issue #${depEntry.task.issue ?? "?"}) is not closed`
|
|
3717
|
+
const comments = extractComments(file.path, file.content);
|
|
3718
|
+
for (const { pattern, what } of patterns) {
|
|
3719
|
+
pattern.lastIndex = 0;
|
|
3720
|
+
let match = pattern.exec(comments);
|
|
3721
|
+
while (match !== null) {
|
|
3722
|
+
findings.push({
|
|
3723
|
+
file: file.path,
|
|
3724
|
+
line: lineAt(comments, match.index),
|
|
3725
|
+
message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
|
|
3726
|
+
blocking: false
|
|
3868
3727
|
});
|
|
3728
|
+
match = pattern.exec(comments);
|
|
3869
3729
|
}
|
|
3870
3730
|
}
|
|
3871
3731
|
}
|
|
3872
|
-
return
|
|
3732
|
+
return findings;
|
|
3873
3733
|
}
|
|
3874
|
-
function
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3734
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
3735
|
+
return [
|
|
3736
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3737
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
3738
|
+
];
|
|
3879
3739
|
}
|
|
3880
|
-
function
|
|
3881
|
-
const
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
|
|
3889
|
-
...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
|
|
3890
|
-
...checkPartsCiteDefinedObjectives(issue.body).errors
|
|
3891
|
-
];
|
|
3892
|
-
if (errors.length === 0)
|
|
3893
|
-
continue;
|
|
3894
|
-
failures.push({
|
|
3895
|
-
code: "missing-rationale-field",
|
|
3896
|
-
issue: issue.number,
|
|
3897
|
-
tranche: slug,
|
|
3898
|
-
reason: `Issue #${issue.number} fails the rationale gate: ${errors.join(" | ")}`,
|
|
3899
|
-
grandfathered: grandfatheredIssues.has(issue.number)
|
|
3900
|
-
});
|
|
3901
|
-
}
|
|
3740
|
+
function parseGlossaryTerms(glossaryContent) {
|
|
3741
|
+
const terms = [];
|
|
3742
|
+
const re = /^\*\*(.+?)\*\* —/gm;
|
|
3743
|
+
let match = re.exec(glossaryContent);
|
|
3744
|
+
while (match !== null) {
|
|
3745
|
+
if (match[1] !== undefined)
|
|
3746
|
+
terms.push(match[1]);
|
|
3747
|
+
match = re.exec(glossaryContent);
|
|
3902
3748
|
}
|
|
3903
|
-
|
|
3904
|
-
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
3905
|
-
return {
|
|
3906
|
-
check: "R1",
|
|
3907
|
-
status,
|
|
3908
|
-
failures,
|
|
3909
|
-
note: status === "info" ? `${failures.length} grandfathered task Issue(s) predate this check's grammar (rationale fields and/or the project registry)` : undefined
|
|
3910
|
-
};
|
|
3749
|
+
return terms;
|
|
3911
3750
|
}
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
reason: "Active tranche has no open task-Issues — consider archiving to completed/"
|
|
3927
|
-
});
|
|
3928
|
-
}
|
|
3929
|
-
}
|
|
3930
|
-
return {
|
|
3931
|
-
check: "L1",
|
|
3932
|
-
status: "info",
|
|
3933
|
-
failures,
|
|
3934
|
-
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
3935
|
-
};
|
|
3751
|
+
|
|
3752
|
+
// ../../packages/aeg-core/src/quoted-command.ts
|
|
3753
|
+
var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
|
|
3754
|
+
var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
3755
|
+
var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
|
|
3756
|
+
var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
|
|
3757
|
+
function isValidCitedFilePath(path) {
|
|
3758
|
+
if (path.length === 0)
|
|
3759
|
+
return false;
|
|
3760
|
+
if (path.startsWith("/") || path.startsWith("\\"))
|
|
3761
|
+
return false;
|
|
3762
|
+
if (/^[A-Za-z]:[\\/]/.test(path))
|
|
3763
|
+
return false;
|
|
3764
|
+
return !path.split(/[\\/]+/).includes("..");
|
|
3936
3765
|
}
|
|
3937
|
-
function
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
failures: [],
|
|
3943
|
-
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
3944
|
-
};
|
|
3945
|
-
}
|
|
3946
|
-
function extractClosesReferences(prBody) {
|
|
3947
|
-
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
3948
|
-
const stripped = stripCode(prBody);
|
|
3949
|
-
const searchIn = anchoredRegion(stripped, "CLOSES") ?? stripped;
|
|
3950
|
-
const referenced = new Set;
|
|
3951
|
-
for (const hit of searchIn.matchAll(closesPattern)) {
|
|
3952
|
-
referenced.add(Number(hit[1]));
|
|
3766
|
+
function quotedCommandLineAt(content, index) {
|
|
3767
|
+
let line = 1;
|
|
3768
|
+
for (let i = 0;i < index; i++) {
|
|
3769
|
+
if (content.charCodeAt(i) === 10)
|
|
3770
|
+
line++;
|
|
3953
3771
|
}
|
|
3954
|
-
return
|
|
3772
|
+
return line;
|
|
3955
3773
|
}
|
|
3956
|
-
function
|
|
3957
|
-
const
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3774
|
+
function extractQuotedText(raw) {
|
|
3775
|
+
const trimmed = raw.trim();
|
|
3776
|
+
const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
|
|
3777
|
+
if (fenced)
|
|
3778
|
+
return (fenced[1] ?? "").trim();
|
|
3779
|
+
const inline = /^`([^`]+)`$/.exec(trimmed);
|
|
3780
|
+
if (inline)
|
|
3781
|
+
return (inline[1] ?? "").trim();
|
|
3782
|
+
return trimmed;
|
|
3783
|
+
}
|
|
3784
|
+
function findQuotesInFile(path, content) {
|
|
3785
|
+
const masked = maskCode(content);
|
|
3786
|
+
const quotes = [];
|
|
3787
|
+
START_PATTERN.lastIndex = 0;
|
|
3788
|
+
let start = START_PATTERN.exec(masked);
|
|
3789
|
+
while (start !== null) {
|
|
3790
|
+
const citedFile = start[1];
|
|
3791
|
+
const innerStart = start.index + start[0].length;
|
|
3792
|
+
const end = END_PATTERN.exec(masked.slice(innerStart));
|
|
3793
|
+
if (end === null) {
|
|
3794
|
+
START_PATTERN.lastIndex = innerStart;
|
|
3795
|
+
start = START_PATTERN.exec(masked);
|
|
3796
|
+
continue;
|
|
3970
3797
|
}
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
if (!referenced.has(expectedIssue)) {
|
|
3978
|
-
return {
|
|
3979
|
-
ok: false,
|
|
3980
|
-
expectedIssue,
|
|
3981
|
-
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
3982
|
-
};
|
|
3798
|
+
const innerEnd = innerStart + end.index;
|
|
3799
|
+
if (isValidCitedFilePath(citedFile)) {
|
|
3800
|
+
const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
|
|
3801
|
+
if (quotedText.length > 0) {
|
|
3802
|
+
quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
|
|
3803
|
+
}
|
|
3983
3804
|
}
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
const trancheSlug = ref.tranche;
|
|
3987
|
-
const taskId = ref.taskId;
|
|
3988
|
-
const trancheFile = trancheFiles.find((f) => f.slug === trancheSlug);
|
|
3989
|
-
if (!trancheFile) {
|
|
3990
|
-
return {
|
|
3991
|
-
ok: false,
|
|
3992
|
-
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.`
|
|
3993
|
-
};
|
|
3994
|
-
}
|
|
3995
|
-
const task = trancheFile.tranche.tasks.find((t) => t.id === taskId);
|
|
3996
|
-
if (!task) {
|
|
3997
|
-
return {
|
|
3998
|
-
ok: false,
|
|
3999
|
-
message: `closes-n: branch "${branch}" references task "${taskId}" not found in ${trancheSlug} topology. Verify the task ID matches the tranche file.`
|
|
4000
|
-
};
|
|
3805
|
+
START_PATTERN.lastIndex = innerEnd + end[0].length;
|
|
3806
|
+
start = START_PATTERN.exec(masked);
|
|
4001
3807
|
}
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
3808
|
+
return quotes;
|
|
3809
|
+
}
|
|
3810
|
+
function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
|
|
3811
|
+
const quotes = [];
|
|
3812
|
+
for (const file of files) {
|
|
3813
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3814
|
+
if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
|
|
3815
|
+
continue;
|
|
3816
|
+
quotes.push(...findQuotesInFile(file.path, file.content));
|
|
4007
3817
|
}
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
3818
|
+
return quotes;
|
|
3819
|
+
}
|
|
3820
|
+
function evaluateCitedQuotes(citedQuotes, citedFileContents) {
|
|
3821
|
+
const findings = [];
|
|
3822
|
+
for (const quote of citedQuotes) {
|
|
3823
|
+
const content = citedFileContents.get(quote.citedFile);
|
|
3824
|
+
if (content === undefined) {
|
|
3825
|
+
findings.push({
|
|
3826
|
+
file: quote.file,
|
|
3827
|
+
line: quote.line,
|
|
3828
|
+
citedFile: quote.citedFile,
|
|
3829
|
+
quotedText: quote.quotedText,
|
|
3830
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
|
|
3831
|
+
});
|
|
3832
|
+
continue;
|
|
3833
|
+
}
|
|
3834
|
+
if (!content.includes(quote.quotedText)) {
|
|
3835
|
+
findings.push({
|
|
3836
|
+
file: quote.file,
|
|
3837
|
+
line: quote.line,
|
|
3838
|
+
citedFile: quote.citedFile,
|
|
3839
|
+
quotedText: quote.quotedText,
|
|
3840
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
|
|
3841
|
+
});
|
|
3842
|
+
}
|
|
4015
3843
|
}
|
|
4016
|
-
return
|
|
3844
|
+
return findings;
|
|
4017
3845
|
}
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
3846
|
+
|
|
3847
|
+
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3848
|
+
function hasRationaleField(body, labelPattern) {
|
|
3849
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
3850
|
+
return re.test(body);
|
|
4021
3851
|
}
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
3852
|
+
var RATIONALE_FIELDS = [
|
|
3853
|
+
{ name: "Boundary", pattern: "Boundary" },
|
|
3854
|
+
{ name: "Sizing", pattern: "Sizing" },
|
|
3855
|
+
{ name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
|
|
3856
|
+
{ name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
|
|
3857
|
+
{ name: "Traps to avoid", pattern: "Traps" },
|
|
3858
|
+
{ name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
|
|
3859
|
+
{ name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
|
|
3860
|
+
{ name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
|
|
3861
|
+
];
|
|
3862
|
+
var DEPENDENCY_RATIONALE_FIELD_NAME = "Dependency rationale";
|
|
3863
|
+
function checkIssueRationale(body) {
|
|
3864
|
+
const errors = [];
|
|
3865
|
+
for (const f of RATIONALE_FIELDS) {
|
|
3866
|
+
if (!hasRationaleField(body, f.pattern)) {
|
|
3867
|
+
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).`);
|
|
3868
|
+
continue;
|
|
3869
|
+
}
|
|
3870
|
+
if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
|
|
3871
|
+
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.");
|
|
3872
|
+
}
|
|
4032
3873
|
}
|
|
4033
|
-
|
|
4034
|
-
if (bodyNums.length === 0)
|
|
4035
|
-
return { issue: null, extraIssues: [], outsideHeader: false };
|
|
4036
|
-
const issue = headerNums.length > 0 ? headerNums[0] : bodyNums[0];
|
|
4037
|
-
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: headerNums.length === 0 };
|
|
3874
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4038
3875
|
}
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
3876
|
+
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3877
|
+
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3878
|
+
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3879
|
+
return { status: "pass", errors: [] };
|
|
3880
|
+
const result = objectivesOf(body);
|
|
3881
|
+
if (result.ok)
|
|
3882
|
+
return { status: "pass", errors: [] };
|
|
3883
|
+
return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
|
|
4044
3884
|
}
|
|
4045
|
-
function
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
3885
|
+
function topLevelSectionText(body, headingName) {
|
|
3886
|
+
const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
|
|
3887
|
+
const heading = headingRe.exec(body);
|
|
3888
|
+
if (!heading)
|
|
3889
|
+
return null;
|
|
3890
|
+
const afterHeading = body.slice(heading.index + heading[0].length);
|
|
3891
|
+
const next = /^##[ \t]/m.exec(afterHeading);
|
|
3892
|
+
return next ? afterHeading.slice(0, next.index) : afterHeading;
|
|
4051
3893
|
}
|
|
4052
|
-
function
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
3894
|
+
function partHasBacktickedPath(text) {
|
|
3895
|
+
let i = 0;
|
|
3896
|
+
while (i < text.length) {
|
|
3897
|
+
const start = text.indexOf("`", i);
|
|
3898
|
+
if (start === -1)
|
|
3899
|
+
return false;
|
|
3900
|
+
const end = text.indexOf("`", start + 1);
|
|
3901
|
+
if (end === -1)
|
|
3902
|
+
return false;
|
|
3903
|
+
if (text.slice(start + 1, end).includes("/"))
|
|
3904
|
+
return true;
|
|
3905
|
+
i = end + 1;
|
|
3906
|
+
}
|
|
3907
|
+
return false;
|
|
4056
3908
|
}
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
const judged = patchIdOf(echoed.headSha);
|
|
4061
|
-
const current = patchIdOf(headSha);
|
|
4062
|
-
if (judged === null || current === null)
|
|
4063
|
-
return false;
|
|
4064
|
-
return judged === current;
|
|
3909
|
+
var PART_MIN_WORDS_OUTSIDE_BACKTICKS = 3;
|
|
3910
|
+
function stripPartBackticks(text) {
|
|
3911
|
+
return text.replace(/`[^`\n]*`/g, " ");
|
|
4065
3912
|
}
|
|
4066
|
-
function
|
|
4067
|
-
|
|
4068
|
-
return true;
|
|
4069
|
-
if (!echoed.baseSha)
|
|
4070
|
-
return false;
|
|
4071
|
-
return currentBase.toLowerCase().startsWith(echoed.baseSha.toLowerCase());
|
|
3913
|
+
function partWordCount(text) {
|
|
3914
|
+
return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
|
|
4072
3915
|
}
|
|
4073
|
-
function
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
3916
|
+
function looksLikeFilePath(entry) {
|
|
3917
|
+
const stripped = entry.replace(/\/\*\*?$/, "");
|
|
3918
|
+
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3919
|
+
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3920
|
+
return extMatch !== null && extMatch.index > 0;
|
|
4077
3921
|
}
|
|
4078
|
-
function
|
|
4079
|
-
|
|
4080
|
-
return currentOrdinal === 0;
|
|
4081
|
-
return echoed.rulingOrdinal === currentOrdinal;
|
|
3922
|
+
function splitGlobList(raw) {
|
|
3923
|
+
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
4082
3924
|
}
|
|
4083
|
-
function
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
3925
|
+
function parseIssueSurface(body) {
|
|
3926
|
+
const section = topLevelSectionText(body, "Surface");
|
|
3927
|
+
if (section === null)
|
|
3928
|
+
return { ok: false, errors: ["no `## Surface` heading found in the body."] };
|
|
3929
|
+
const inLine = /^in:\s*(.+)$/im.exec(section);
|
|
3930
|
+
const outLine = /^out:\s*(.+)$/im.exec(section);
|
|
3931
|
+
const errors = [];
|
|
3932
|
+
if (!inLine)
|
|
3933
|
+
errors.push("`## Surface` has no `in:` line.");
|
|
3934
|
+
if (!outLine)
|
|
3935
|
+
errors.push("`## Surface` has no `out:` line.");
|
|
3936
|
+
if (errors.length > 0)
|
|
3937
|
+
return { ok: false, errors };
|
|
3938
|
+
const inGlobs = splitGlobList(inLine[1]);
|
|
3939
|
+
const outGlobs = splitGlobList(outLine[1]);
|
|
3940
|
+
for (const g of [...inGlobs, ...outGlobs]) {
|
|
3941
|
+
if (looksLikeFilePath(g)) {
|
|
3942
|
+
errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
|
|
3943
|
+
}
|
|
3944
|
+
}
|
|
3945
|
+
if (inGlobs.length === 0)
|
|
3946
|
+
errors.push("`## Surface`'s `in:` line resolved to zero globs.");
|
|
3947
|
+
if (errors.length > 0)
|
|
3948
|
+
return { ok: false, errors };
|
|
3949
|
+
return { ok: true, value: { in: inGlobs, out: outGlobs } };
|
|
4087
3950
|
}
|
|
4088
|
-
function
|
|
4089
|
-
|
|
3951
|
+
function globCoversPath(glob, path) {
|
|
3952
|
+
const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
3953
|
+
const p = path.replace(/\/+$/, "");
|
|
3954
|
+
if (g === "*")
|
|
3955
|
+
return !p.includes("/");
|
|
3956
|
+
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
4090
3957
|
}
|
|
4091
|
-
function
|
|
4092
|
-
const
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
const
|
|
4096
|
-
const
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
3958
|
+
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
3959
|
+
const surface = parseIssueSurface(body);
|
|
3960
|
+
if (!surface.ok)
|
|
3961
|
+
return { status: "pass", errors: [] };
|
|
3962
|
+
const errors = [];
|
|
3963
|
+
for (const glob of surface.value.in) {
|
|
3964
|
+
if (!resolvesToFile(glob)) {
|
|
3965
|
+
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.`);
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3969
|
+
}
|
|
3970
|
+
function checkSurfaceScope(changedFiles, outGlobs) {
|
|
3971
|
+
if (outGlobs.length === 0)
|
|
3972
|
+
return { ok: true };
|
|
3973
|
+
const violations = [];
|
|
3974
|
+
for (const file of changedFiles) {
|
|
3975
|
+
const glob = outGlobs.find((g) => globCoversPath(g, file));
|
|
3976
|
+
if (glob)
|
|
3977
|
+
violations.push({ file, glob });
|
|
3978
|
+
}
|
|
3979
|
+
return violations.length > 0 ? { ok: false, violations } : { ok: true };
|
|
3980
|
+
}
|
|
3981
|
+
var ISSUE_PART_LINE_RE = /^Part\s+(\d+)\s*\(([^)]*)\)\s*[-—–]\s*(.*)$/i;
|
|
3982
|
+
function parseIssueParts(body) {
|
|
3983
|
+
const section = topLevelSectionText(body, "Parts");
|
|
3984
|
+
if (section === null)
|
|
3985
|
+
return { ok: false, errors: ["no `## Parts` heading found in the body."] };
|
|
3986
|
+
const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
|
|
3987
|
+
const parts = [];
|
|
3988
|
+
const errors = [];
|
|
3989
|
+
for (const line of lines) {
|
|
3990
|
+
const m = ISSUE_PART_LINE_RE.exec(line);
|
|
3991
|
+
if (!m) {
|
|
3992
|
+
errors.push(`"${line}" is not a well-formed Parts line — expected \`Part <n> (<refs>) — <outcome>\`.`);
|
|
3993
|
+
continue;
|
|
3994
|
+
}
|
|
3995
|
+
const n = Number.parseInt(m[1], 10);
|
|
3996
|
+
const refs = m[2];
|
|
3997
|
+
const text = m[3].trim();
|
|
3998
|
+
if (text.length === 0) {
|
|
3999
|
+
errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
|
|
4000
|
+
continue;
|
|
4001
|
+
}
|
|
4002
|
+
if (partHasBacktickedPath(text) && partWordCount(stripPartBackticks(text)) < PART_MIN_WORDS_OUTSIDE_BACKTICKS) {
|
|
4003
|
+
errors.push(`Part ${n} is little more than a file path — a Part names an outcome and symbols, never a bare path.`);
|
|
4004
|
+
continue;
|
|
4005
|
+
}
|
|
4006
|
+
const objectiveIds = [...refs.matchAll(/O(\d+)/g)].map((r) => Number.parseInt(r[1], 10));
|
|
4007
|
+
parts.push({ n, objectiveIds, text });
|
|
4008
|
+
}
|
|
4009
|
+
if (parts.length === 0) {
|
|
4010
|
+
errors.push("the `## Parts` section has no well-formed `Part <n> (<refs>) — <outcome>` lines.");
|
|
4011
|
+
}
|
|
4012
|
+
if (errors.length > 0)
|
|
4013
|
+
return { ok: false, errors };
|
|
4014
|
+
return { ok: true, value: parts };
|
|
4015
|
+
}
|
|
4016
|
+
function checkPartsCiteDefinedObjectives(body) {
|
|
4017
|
+
const parts = parseIssueParts(body);
|
|
4018
|
+
const objectives = objectivesOf(body);
|
|
4019
|
+
if (!parts.ok || !objectives.ok)
|
|
4020
|
+
return { status: "pass", errors: [] };
|
|
4021
|
+
const definedIds = new Set(objectives.objectives.map((o) => Number.parseInt(o.id.slice(1), 10)));
|
|
4022
|
+
const errors = [];
|
|
4023
|
+
for (const part of parts.value) {
|
|
4024
|
+
for (const objectiveId of part.objectiveIds) {
|
|
4025
|
+
if (!definedIds.has(objectiveId)) {
|
|
4026
|
+
errors.push(`issue-validation Parts: Part ${part.n} cites O${objectiveId}, which the Issue's own \`## Objectives\` section does not define.`);
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4031
|
+
}
|
|
4032
|
+
function isTaskIssueLabelSet(labels) {
|
|
4033
|
+
return hasLabel("tranche", labels);
|
|
4034
|
+
}
|
|
4035
|
+
function checkTrancheLabelPresence(_body, _labels) {
|
|
4036
|
+
return { status: "pass", errors: [] };
|
|
4037
|
+
}
|
|
4038
|
+
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4039
|
+
if (!isTaskIssueLabelSet(labels))
|
|
4040
|
+
return { status: "pass", errors: [] };
|
|
4041
|
+
if (resolvedMilestoneTitle === null)
|
|
4042
|
+
return { status: "pass", errors: [] };
|
|
4043
|
+
if (currentMilestoneTitle === resolvedMilestoneTitle)
|
|
4044
|
+
return { status: "pass", errors: [] };
|
|
4103
4045
|
return {
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
objectivesVersion,
|
|
4109
|
-
rulingOrdinal,
|
|
4110
|
-
policyDigest: policyDigestBound
|
|
4046
|
+
status: "fail",
|
|
4047
|
+
errors: [
|
|
4048
|
+
`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}".`
|
|
4049
|
+
]
|
|
4111
4050
|
};
|
|
4112
4051
|
}
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
});
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4052
|
+
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4053
|
+
function isControlCodePoint(codePoint) {
|
|
4054
|
+
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4055
|
+
}
|
|
4056
|
+
function isDisplayControlCodePoint(codePoint) {
|
|
4057
|
+
return codePoint >= 8203 && codePoint <= 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
|
|
4058
|
+
}
|
|
4059
|
+
var MESSAGE_VALUE_COUNT_MAX = 5;
|
|
4060
|
+
function residueForMessage(values) {
|
|
4061
|
+
const shown = values.slice(0, MESSAGE_VALUE_COUNT_MAX).map((v) => `\`${forMessage(v)}\``);
|
|
4062
|
+
const rest = values.length - shown.length;
|
|
4063
|
+
return rest > 0 ? `${shown.join(", ")} and ${rest} more` : shown.join(", ");
|
|
4064
|
+
}
|
|
4065
|
+
var MESSAGE_VALUE_MAX = 64;
|
|
4066
|
+
function forMessage(value) {
|
|
4067
|
+
const kept = [];
|
|
4068
|
+
for (const ch of value.replace(/\s+/g, " ")) {
|
|
4069
|
+
const codePoint = ch.codePointAt(0) ?? 0;
|
|
4070
|
+
if (isControlCodePoint(codePoint) || isDisplayControlCodePoint(codePoint))
|
|
4071
|
+
continue;
|
|
4072
|
+
kept.push(ch);
|
|
4129
4073
|
}
|
|
4130
|
-
const
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
const
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4074
|
+
const cleaned = kept.join("").trim();
|
|
4075
|
+
if (cleaned.length === 0)
|
|
4076
|
+
return "(unprintable)";
|
|
4077
|
+
const points = Array.from(cleaned);
|
|
4078
|
+
return points.length > MESSAGE_VALUE_MAX ? `${points.slice(0, MESSAGE_VALUE_MAX).join("")}…` : cleaned;
|
|
4079
|
+
}
|
|
4080
|
+
function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
4081
|
+
if (registeredNames.length === 0)
|
|
4082
|
+
return { status: "pass", errors: [] };
|
|
4083
|
+
const field = projectFieldFromBody(body);
|
|
4084
|
+
if (!field.declared)
|
|
4085
|
+
return { status: "pass", errors: [] };
|
|
4086
|
+
const known = new Set(registeredNames.map((n) => n.trim()));
|
|
4087
|
+
const registeredList = [...registeredNames].map(forMessage).join(", ");
|
|
4088
|
+
const errors = [];
|
|
4089
|
+
if (field.unreadable) {
|
|
4142
4090
|
return {
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4091
|
+
status: "fail",
|
|
4092
|
+
errors: [
|
|
4093
|
+
`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.`
|
|
4094
|
+
]
|
|
4146
4095
|
};
|
|
4147
4096
|
}
|
|
4148
|
-
const
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
headSha: input.headSha,
|
|
4156
|
-
baseSha: input.baseSha ?? null,
|
|
4157
|
-
briefHash: input.briefHash ?? null,
|
|
4158
|
-
objectivesVersion: input.objectivesVersion,
|
|
4159
|
-
rulingOrdinal: input.rulingOrdinal,
|
|
4160
|
-
policyDigest: policyDigest(policy)
|
|
4161
|
-
};
|
|
4162
|
-
const codeReviewEchoed = {
|
|
4163
|
-
headSha: codeReview.headSha,
|
|
4164
|
-
baseSha: codeReview.baseSha,
|
|
4165
|
-
briefHash: codeReview.briefHash,
|
|
4166
|
-
objectivesVersion: codeReview.objectivesVersion,
|
|
4167
|
-
rulingOrdinal: codeReview.rulingOrdinal,
|
|
4168
|
-
policyDigest: codeReview.policyDigest
|
|
4169
|
-
};
|
|
4170
|
-
const securityEchoed = {
|
|
4171
|
-
headSha: security.headSha,
|
|
4172
|
-
baseSha: security.baseSha,
|
|
4173
|
-
briefHash: security.briefHash,
|
|
4174
|
-
objectivesVersion: security.objectivesVersion,
|
|
4175
|
-
rulingOrdinal: security.rulingOrdinal,
|
|
4176
|
-
policyDigest: security.policyDigest
|
|
4177
|
-
};
|
|
4178
|
-
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
4179
|
-
const securityBinding = compareManifest(securityEchoed, currentManifest, input.patchIdOf);
|
|
4180
|
-
const codeReviewBound = codeReviewBinding.head;
|
|
4181
|
-
const securityBound = securityBinding.head;
|
|
4182
|
-
const codeReviewObjectivesBound = codeReviewBinding.objectivesVersion;
|
|
4183
|
-
const securityObjectivesBound = securityBinding.objectivesVersion;
|
|
4184
|
-
const codeReviewRulingsBound = codeReviewBinding.rulingOrdinal;
|
|
4185
|
-
const securityRulingsBound = securityBinding.rulingOrdinal;
|
|
4186
|
-
if (codeReviewClean && codeReviewBinding.bound && securityClean && securityBinding.bound) {
|
|
4187
|
-
return {
|
|
4188
|
-
verdict: "pass",
|
|
4189
|
-
reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.`,
|
|
4190
|
-
waived: false
|
|
4191
|
-
};
|
|
4097
|
+
const unregistered = field.names.filter((p) => !known.has(p));
|
|
4098
|
+
if (unregistered.length > 0) {
|
|
4099
|
+
const caseHints = unregistered.map((p) => {
|
|
4100
|
+
const row = [...known].find((k) => k.toLowerCase() === p.toLowerCase());
|
|
4101
|
+
return row ? `\`${forMessage(p)}\` differs from the registered \`${forMessage(row)}\` only in case` : null;
|
|
4102
|
+
}).filter((h) => h !== null);
|
|
4103
|
+
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.`);
|
|
4192
4104
|
}
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
} else if (
|
|
4197
|
-
|
|
4198
|
-
} else if (!codeReviewBound) {
|
|
4199
|
-
problems.push(`the newest code-review verdict covers ${codeReview.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
|
|
4200
|
-
} else if (!codeReviewBinding.base) {
|
|
4201
|
-
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)`);
|
|
4202
|
-
} else if (!codeReviewObjectivesBound) {
|
|
4203
|
-
problems.push(`the newest code-review verdict was cast against objectives version ${codeReview.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
|
|
4204
|
-
} else if (!codeReviewRulingsBound) {
|
|
4205
|
-
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`);
|
|
4206
|
-
} else if (!codeReviewBinding.briefHash) {
|
|
4207
|
-
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"}`);
|
|
4208
|
-
} else if (!codeReviewBinding.policyDigest) {
|
|
4209
|
-
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}`);
|
|
4105
|
+
if (field.names.length === 0) {
|
|
4106
|
+
const residue = field.unparsed.length > 0 ? ` — ${residueForMessage(field.unparsed)}` : " — the field is empty";
|
|
4107
|
+
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.`);
|
|
4108
|
+
} else if (field.unparsed.length > 0) {
|
|
4109
|
+
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.`);
|
|
4210
4110
|
}
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4111
|
+
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4112
|
+
}
|
|
4113
|
+
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;
|
|
4114
|
+
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
4115
|
+
var FILE_EXTENSIONS = new Set([
|
|
4116
|
+
"ts",
|
|
4117
|
+
"tsx",
|
|
4118
|
+
"js",
|
|
4119
|
+
"jsx",
|
|
4120
|
+
"mjs",
|
|
4121
|
+
"cjs",
|
|
4122
|
+
"json",
|
|
4123
|
+
"jsonc",
|
|
4124
|
+
"md",
|
|
4125
|
+
"mdx",
|
|
4126
|
+
"yml",
|
|
4127
|
+
"yaml",
|
|
4128
|
+
"txt",
|
|
4129
|
+
"sh",
|
|
4130
|
+
"lock",
|
|
4131
|
+
"toml",
|
|
4132
|
+
"ndjson",
|
|
4133
|
+
"html",
|
|
4134
|
+
"css"
|
|
4135
|
+
]);
|
|
4136
|
+
|
|
4137
|
+
// ../../packages/aeg-core/src/task-branch-identity.ts
|
|
4138
|
+
var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
|
|
4139
|
+
var TRANCHE_BRANCH_PATTERN = /^task\/([^/]+)\/([^/]+)$/;
|
|
4140
|
+
function parseTaskBranchIdentity(branch) {
|
|
4141
|
+
const issueMatch = ISSUE_BRANCH_PATTERN.exec(branch);
|
|
4142
|
+
if (issueMatch)
|
|
4143
|
+
return { kind: "issue", issueNumber: Number(issueMatch[1]) };
|
|
4144
|
+
const trancheMatch = TRANCHE_BRANCH_PATTERN.exec(branch);
|
|
4145
|
+
if (trancheMatch)
|
|
4146
|
+
return { kind: "tranche", tranche: trancheMatch[1], taskId: trancheMatch[2] };
|
|
4147
|
+
return null;
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4150
|
+
// ../../packages/aeg-core/src/coherence-checks.ts
|
|
4151
|
+
var COHERENCE_ENFORCED_FROM = "2026-07-01";
|
|
4152
|
+
function isGrandfathered(isoDate) {
|
|
4153
|
+
if (!isoDate)
|
|
4154
|
+
return false;
|
|
4155
|
+
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4156
|
+
}
|
|
4157
|
+
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4158
|
+
function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
4159
|
+
const failures = [];
|
|
4160
|
+
for (const e of entries) {
|
|
4161
|
+
if (!e.facts)
|
|
4162
|
+
continue;
|
|
4163
|
+
if (e.facts.stateReason === "not_planned")
|
|
4164
|
+
continue;
|
|
4165
|
+
if (e.facts.issueState === "closed" && e.facts.prState !== "merged") {
|
|
4166
|
+
const handClosed = e.facts.stateReason === "completed" && isPrincipal(e.facts.closedByActor, principalAllowlist);
|
|
4167
|
+
if (handClosed)
|
|
4168
|
+
continue;
|
|
4169
|
+
failures.push({
|
|
4170
|
+
code: "closed-without-merge",
|
|
4171
|
+
issue: e.task.issue,
|
|
4172
|
+
tranche: e.trancheSlug,
|
|
4173
|
+
task: e.task.id,
|
|
4174
|
+
reason: `Issue closed but closing PR is not merged (prState: ${e.facts.prState})`,
|
|
4175
|
+
grandfathered: isGrandfathered(e.facts.closedAt)
|
|
4176
|
+
});
|
|
4177
|
+
}
|
|
4178
|
+
}
|
|
4179
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4180
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4181
|
+
return {
|
|
4182
|
+
check: "A1",
|
|
4183
|
+
status,
|
|
4184
|
+
failures,
|
|
4185
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4186
|
+
};
|
|
4187
|
+
}
|
|
4188
|
+
function checkA3(entries) {
|
|
4189
|
+
const failures = [];
|
|
4190
|
+
for (const e of entries) {
|
|
4191
|
+
if (!e.facts)
|
|
4192
|
+
continue;
|
|
4193
|
+
if (e.facts.prState === "merged" && e.facts.issueState !== "closed") {
|
|
4194
|
+
failures.push({
|
|
4195
|
+
code: "auto-close-misfire",
|
|
4196
|
+
issue: e.task.issue,
|
|
4197
|
+
tranche: e.trancheSlug,
|
|
4198
|
+
task: e.task.id,
|
|
4199
|
+
reason: "Closing PR is merged but Issue is still open (GitHub auto-close misfire)",
|
|
4200
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
4201
|
+
});
|
|
4202
|
+
}
|
|
4227
4203
|
}
|
|
4228
|
-
const
|
|
4204
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4205
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4229
4206
|
return {
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4207
|
+
check: "A3",
|
|
4208
|
+
status,
|
|
4209
|
+
failures,
|
|
4210
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4233
4211
|
};
|
|
4234
4212
|
}
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
}
|
|
4240
|
-
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4241
|
-
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4242
|
-
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4243
|
-
let best = 0;
|
|
4244
|
-
for (const c of comments) {
|
|
4245
|
-
if (!isPrincipal(c.author, allowlist))
|
|
4246
|
-
continue;
|
|
4247
|
-
const firstLine = (c.body.split(`
|
|
4248
|
-
`)[0] ?? "").trim();
|
|
4249
|
-
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4250
|
-
if (!m)
|
|
4213
|
+
function checkT1(entries) {
|
|
4214
|
+
const failures = [];
|
|
4215
|
+
for (const e of entries) {
|
|
4216
|
+
if (e.task.issue === null)
|
|
4251
4217
|
continue;
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4218
|
+
if (e.facts === undefined) {
|
|
4219
|
+
failures.push({
|
|
4220
|
+
code: "phantom-issue-ref",
|
|
4221
|
+
issue: e.task.issue,
|
|
4222
|
+
tranche: e.trancheSlug,
|
|
4223
|
+
task: e.task.id,
|
|
4224
|
+
reason: `Issue #${e.task.issue} in topology does not resolve to a real GitHub Issue`
|
|
4225
|
+
});
|
|
4226
|
+
}
|
|
4255
4227
|
}
|
|
4256
|
-
return
|
|
4257
|
-
}
|
|
4258
|
-
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4259
|
-
function splitRow(line) {
|
|
4260
|
-
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
4261
|
-
return trimmed.split("|").map((cell) => cell.trim());
|
|
4228
|
+
return { check: "T1", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
4262
4229
|
}
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
const
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
}
|
|
4278
|
-
const headers = splitRow(headerLine);
|
|
4279
|
-
const rows = [];
|
|
4280
|
-
let j = i + 2;
|
|
4281
|
-
while (j < lines.length && TABLE_ROW_PATTERN.test(lines[j] ?? "")) {
|
|
4282
|
-
rows.push({ cells: splitRow(lines[j] ?? ""), line: j + 1 });
|
|
4283
|
-
j++;
|
|
4230
|
+
function checkT2(openIssuesBySlug, topologyIssuesBySlug, ciTrancheSlug) {
|
|
4231
|
+
const failures = [];
|
|
4232
|
+
for (const [slug, openNums] of openIssuesBySlug) {
|
|
4233
|
+
if (ciTrancheSlug && slug !== ciTrancheSlug)
|
|
4234
|
+
continue;
|
|
4235
|
+
const topologySet = topologyIssuesBySlug.get(slug) ?? new Set;
|
|
4236
|
+
for (const num of openNums) {
|
|
4237
|
+
if (!topologySet.has(num)) {
|
|
4238
|
+
failures.push({
|
|
4239
|
+
code: "orphan-task",
|
|
4240
|
+
issue: num,
|
|
4241
|
+
tranche: slug,
|
|
4242
|
+
reason: `Issue #${num} is open and labeled ${trancheLabel(slug)} but does not appear in the topology file`
|
|
4243
|
+
});
|
|
4284
4244
|
}
|
|
4285
|
-
return { headers, rows };
|
|
4286
4245
|
}
|
|
4287
|
-
i++;
|
|
4288
4246
|
}
|
|
4289
|
-
return
|
|
4247
|
+
return { check: "T2", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
4290
4248
|
}
|
|
4291
|
-
function
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4249
|
+
function scopeT2ToPlanPr(result, isPlanPr) {
|
|
4250
|
+
if (isPlanPr || result.status !== "fail")
|
|
4251
|
+
return result;
|
|
4252
|
+
return {
|
|
4253
|
+
...result,
|
|
4254
|
+
status: "info",
|
|
4255
|
+
note: result.note ?? "T2 findings are non-blocking outside plan PRs (point-of-power principle) — see aeg-root/enforcement.md."
|
|
4256
|
+
};
|
|
4297
4257
|
}
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
];
|
|
4307
|
-
function stripBackticks2(cell) {
|
|
4308
|
-
const trimmed = cell.trim();
|
|
4309
|
-
if (trimmed.length >= 2 && trimmed.startsWith("`") && trimmed.endsWith("`")) {
|
|
4310
|
-
return trimmed.slice(1, -1);
|
|
4258
|
+
function checkT3(entries, ciTrancheSlug, enrichedEntries, forgeUnavailableSlugs) {
|
|
4259
|
+
const preEnforcement = new Set;
|
|
4260
|
+
if (enrichedEntries) {
|
|
4261
|
+
for (const e of enrichedEntries) {
|
|
4262
|
+
if (isGrandfathered(e.facts?.closedAt) || isGrandfathered(e.facts?.mergedAt)) {
|
|
4263
|
+
preEnforcement.add(e.trancheSlug);
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4311
4266
|
}
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4267
|
+
const failures = [];
|
|
4268
|
+
for (const e of entries) {
|
|
4269
|
+
if (!e.archived && e.task.issue === null) {
|
|
4270
|
+
if (ciTrancheSlug && e.trancheSlug !== ciTrancheSlug)
|
|
4271
|
+
continue;
|
|
4272
|
+
if (forgeUnavailableSlugs?.has(e.trancheSlug)) {
|
|
4273
|
+
failures.push({
|
|
4274
|
+
code: "tbd-in-active-tranche",
|
|
4275
|
+
issue: null,
|
|
4276
|
+
tranche: e.trancheSlug,
|
|
4277
|
+
task: e.task.id,
|
|
4278
|
+
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`,
|
|
4279
|
+
grandfathered: true
|
|
4280
|
+
});
|
|
4281
|
+
continue;
|
|
4282
|
+
}
|
|
4283
|
+
failures.push({
|
|
4284
|
+
code: "tbd-in-active-tranche",
|
|
4285
|
+
issue: null,
|
|
4286
|
+
tranche: e.trancheSlug,
|
|
4287
|
+
task: e.task.id,
|
|
4288
|
+
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`,
|
|
4289
|
+
grandfathered: preEnforcement.has(e.trancheSlug)
|
|
4290
|
+
});
|
|
4291
|
+
}
|
|
4292
|
+
}
|
|
4293
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4294
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4295
|
+
return {
|
|
4296
|
+
check: "T3",
|
|
4297
|
+
status,
|
|
4298
|
+
failures,
|
|
4299
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4300
|
+
};
|
|
4316
4301
|
}
|
|
4317
|
-
function
|
|
4318
|
-
const
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
for (const { ring, pattern } of RING_HEADINGS) {
|
|
4322
|
-
const headingLine = findHeadingLine(lines, pattern);
|
|
4323
|
-
if (headingLine === null)
|
|
4302
|
+
function checkD1(entries, issueToEntry, taskToEntry) {
|
|
4303
|
+
const failures = [];
|
|
4304
|
+
for (const e of entries) {
|
|
4305
|
+
if (!e.facts)
|
|
4324
4306
|
continue;
|
|
4325
|
-
|
|
4326
|
-
if (!table)
|
|
4307
|
+
if (e.facts.prState !== "open")
|
|
4327
4308
|
continue;
|
|
4328
|
-
const
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
for (const row of table.rows) {
|
|
4332
|
-
const cells = row.cells;
|
|
4333
|
-
if (cells.length < 3)
|
|
4309
|
+
for (const dep of e.task.dependsOn) {
|
|
4310
|
+
const depEntry = resolveDepEntry(dep, e.trancheSlug, issueToEntry, taskToEntry);
|
|
4311
|
+
if (!depEntry)
|
|
4334
4312
|
continue;
|
|
4335
|
-
const
|
|
4336
|
-
const
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4313
|
+
const sameTask = depEntry.trancheSlug === e.trancheSlug && depEntry.task.id === e.task.id;
|
|
4314
|
+
const sameIssue = depEntry.task.issue !== null && e.task.issue !== null && depEntry.task.issue === e.task.issue;
|
|
4315
|
+
if (sameTask || sameIssue) {
|
|
4316
|
+
failures.push({
|
|
4317
|
+
code: "d1-self-dependency",
|
|
4318
|
+
issue: e.task.issue,
|
|
4319
|
+
tranche: e.trancheSlug,
|
|
4320
|
+
task: e.task.id,
|
|
4321
|
+
reason: `INTERNAL: parsed a self-dependency (depends-on ${dep}) — this is a parser bug in parseRationaleDeps, not a real dependency. Please report it upstream.`
|
|
4322
|
+
});
|
|
4323
|
+
continue;
|
|
4324
|
+
}
|
|
4325
|
+
const depFacts = depEntry.facts;
|
|
4326
|
+
const depClosed = depFacts?.issueState === "closed";
|
|
4327
|
+
if (!depClosed) {
|
|
4328
|
+
failures.push({
|
|
4329
|
+
code: "dispatched-on-unmet-deps",
|
|
4330
|
+
issue: e.task.issue,
|
|
4331
|
+
tranche: e.trancheSlug,
|
|
4332
|
+
task: e.task.id,
|
|
4333
|
+
reason: `Task has open PR but depends-on ${dep} (issue #${depEntry.task.issue ?? "?"}) is not closed`
|
|
4334
|
+
});
|
|
4335
|
+
}
|
|
4344
4336
|
}
|
|
4345
4337
|
}
|
|
4346
|
-
return
|
|
4338
|
+
return { check: "D1", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
4347
4339
|
}
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4340
|
+
function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
|
|
4341
|
+
const issueMatch = dep.match(/^#(\d+)$/);
|
|
4342
|
+
if (issueMatch?.[1])
|
|
4343
|
+
return issueToEntry.get(Number(issueMatch[1]));
|
|
4344
|
+
return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
|
|
4345
|
+
}
|
|
4346
|
+
function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
|
|
4347
|
+
const failures = [];
|
|
4348
|
+
for (const [slug, issues] of issuesBySlug) {
|
|
4349
|
+
for (const issue of issues) {
|
|
4350
|
+
if (!isTaskIssueLabelSet(issue.labels))
|
|
4351
|
+
continue;
|
|
4352
|
+
const errors = [
|
|
4353
|
+
...checkIssueRationale(issue.body).errors,
|
|
4354
|
+
...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
|
|
4355
|
+
...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
|
|
4356
|
+
...checkPartsCiteDefinedObjectives(issue.body).errors
|
|
4357
|
+
];
|
|
4358
|
+
if (errors.length === 0)
|
|
4359
|
+
continue;
|
|
4360
|
+
failures.push({
|
|
4361
|
+
code: "missing-rationale-field",
|
|
4362
|
+
issue: issue.number,
|
|
4363
|
+
tranche: slug,
|
|
4364
|
+
reason: `Issue #${issue.number} fails the rationale gate: ${errors.join(" | ")}`,
|
|
4365
|
+
grandfathered: grandfatheredIssues.has(issue.number)
|
|
4359
4366
|
});
|
|
4360
4367
|
}
|
|
4361
4368
|
}
|
|
4362
|
-
|
|
4369
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4370
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4371
|
+
return {
|
|
4372
|
+
check: "R1",
|
|
4373
|
+
status,
|
|
4374
|
+
failures,
|
|
4375
|
+
note: status === "info" ? `${failures.length} grandfathered task Issue(s) predate this check's grammar (rationale fields and/or the project registry)` : undefined
|
|
4376
|
+
};
|
|
4363
4377
|
}
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
"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)`,
|
|
4369
|
-
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
4370
|
-
};
|
|
4371
|
-
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
4372
|
-
function checkG2(rows, candidateFiles) {
|
|
4373
|
-
const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
|
|
4374
|
-
const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
|
|
4375
|
-
const findings = [];
|
|
4376
|
-
for (const path of candidateFiles) {
|
|
4377
|
-
if (implementations.has(path))
|
|
4378
|
-
continue;
|
|
4379
|
-
if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
|
|
4380
|
-
continue;
|
|
4381
|
-
if (NON_GATE_HOOK_SCRIPTS.includes(path))
|
|
4382
|
-
continue;
|
|
4383
|
-
if (path in TWIN_CANDIDATE_EXCEPTIONS)
|
|
4378
|
+
function checkL1(files, entriesBySlug) {
|
|
4379
|
+
const failures = [];
|
|
4380
|
+
for (const f of files) {
|
|
4381
|
+
if (f.archived)
|
|
4384
4382
|
continue;
|
|
4385
|
-
const
|
|
4386
|
-
|
|
4383
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
4384
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
4385
|
+
if (withFacts.length === 0)
|
|
4387
4386
|
continue;
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
|
|
4395
|
-
if (carriesPlaceholder) {
|
|
4396
|
-
findings.push({
|
|
4397
|
-
row: row.action,
|
|
4398
|
-
path: row.implementation,
|
|
4399
|
-
reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
|
|
4387
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
4388
|
+
if (allClosed) {
|
|
4389
|
+
failures.push({
|
|
4390
|
+
code: "archive-recommended",
|
|
4391
|
+
tranche: f.slug,
|
|
4392
|
+
reason: "Active tranche has no open task-Issues — consider archiving to completed/"
|
|
4400
4393
|
});
|
|
4401
4394
|
}
|
|
4402
4395
|
}
|
|
4403
|
-
return {
|
|
4396
|
+
return {
|
|
4397
|
+
check: "L1",
|
|
4398
|
+
status: "info",
|
|
4399
|
+
failures,
|
|
4400
|
+
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4401
|
+
};
|
|
4404
4402
|
}
|
|
4405
|
-
function
|
|
4406
|
-
const
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
});
|
|
4414
|
-
}
|
|
4415
|
-
}
|
|
4416
|
-
return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4403
|
+
function checkL3(files) {
|
|
4404
|
+
const active = files.filter((f) => !f.archived);
|
|
4405
|
+
return {
|
|
4406
|
+
check: "L3",
|
|
4407
|
+
status: "info",
|
|
4408
|
+
failures: [],
|
|
4409
|
+
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4410
|
+
};
|
|
4417
4411
|
}
|
|
4418
|
-
function
|
|
4419
|
-
const
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
const
|
|
4424
|
-
|
|
4425
|
-
if (!resolveFn(n)) {
|
|
4426
|
-
findings.push({
|
|
4427
|
-
reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
|
|
4428
|
-
});
|
|
4429
|
-
}
|
|
4412
|
+
function extractClosesReferences(prBody) {
|
|
4413
|
+
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4414
|
+
const stripped = stripCode(prBody);
|
|
4415
|
+
const searchIn = anchoredRegion(stripped, "CLOSES") ?? stripped;
|
|
4416
|
+
const referenced = new Set;
|
|
4417
|
+
for (const hit of searchIn.matchAll(closesPattern)) {
|
|
4418
|
+
referenced.add(Number(hit[1]));
|
|
4430
4419
|
}
|
|
4431
|
-
return
|
|
4420
|
+
return referenced;
|
|
4432
4421
|
}
|
|
4433
|
-
function
|
|
4434
|
-
const
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
});
|
|
4422
|
+
function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
4423
|
+
const referenced = extractClosesReferences(prBody);
|
|
4424
|
+
if (taskIssueRefs) {
|
|
4425
|
+
for (const n of referenced) {
|
|
4426
|
+
const ref = taskIssueRefs.get(n);
|
|
4427
|
+
if (!ref)
|
|
4428
|
+
continue;
|
|
4429
|
+
const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
|
|
4430
|
+
if (branch !== expectedBranch) {
|
|
4431
|
+
return {
|
|
4432
|
+
ok: false,
|
|
4433
|
+
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.`
|
|
4434
|
+
};
|
|
4435
|
+
}
|
|
4448
4436
|
}
|
|
4449
4437
|
}
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4438
|
+
const ref = parseTaskBranchIdentity(branch);
|
|
4439
|
+
if (!ref)
|
|
4440
|
+
return { ok: true };
|
|
4441
|
+
if (ref.kind === "issue") {
|
|
4442
|
+
const expectedIssue = ref.issueNumber;
|
|
4443
|
+
if (!referenced.has(expectedIssue)) {
|
|
4444
|
+
return {
|
|
4445
|
+
ok: false,
|
|
4446
|
+
expectedIssue,
|
|
4447
|
+
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
4448
|
+
};
|
|
4456
4449
|
}
|
|
4450
|
+
return { ok: true, expectedIssue };
|
|
4457
4451
|
}
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
}
|
|
4466
|
-
function claimedCheckNames(implementation) {
|
|
4467
|
-
if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
|
|
4468
|
-
return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
|
|
4452
|
+
const trancheSlug = ref.tranche;
|
|
4453
|
+
const taskId = ref.taskId;
|
|
4454
|
+
const trancheFile = trancheFiles.find((f) => f.slug === trancheSlug);
|
|
4455
|
+
if (!trancheFile) {
|
|
4456
|
+
return {
|
|
4457
|
+
ok: false,
|
|
4458
|
+
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.`
|
|
4459
|
+
};
|
|
4469
4460
|
}
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4461
|
+
const task = trancheFile.tranche.tasks.find((t) => t.id === taskId);
|
|
4462
|
+
if (!task) {
|
|
4463
|
+
return {
|
|
4464
|
+
ok: false,
|
|
4465
|
+
message: `closes-n: branch "${branch}" references task "${taskId}" not found in ${trancheSlug} topology. Verify the task ID matches the tranche file.`
|
|
4466
|
+
};
|
|
4475
4467
|
}
|
|
4476
|
-
|
|
4468
|
+
if (task.issue === null) {
|
|
4469
|
+
return {
|
|
4470
|
+
ok: false,
|
|
4471
|
+
message: `closes-n: task "${taskId}" in "${trancheSlug}" has no Issue number (#TBD). The Planner must cut the Issue before this PR can be validated.`
|
|
4472
|
+
};
|
|
4473
|
+
}
|
|
4474
|
+
const expectedIssue = task.issue;
|
|
4475
|
+
if (!referenced.has(expectedIssue)) {
|
|
4476
|
+
return {
|
|
4477
|
+
ok: false,
|
|
4478
|
+
expectedIssue,
|
|
4479
|
+
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.`
|
|
4480
|
+
};
|
|
4481
|
+
}
|
|
4482
|
+
return { ok: true, expectedIssue };
|
|
4477
4483
|
}
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
}
|
|
4490
|
-
|
|
4484
|
+
// ../../packages/aeg-core/src/archive-task.ts
|
|
4485
|
+
function closesRefs(text) {
|
|
4486
|
+
return [...new Set([...text.matchAll(/Closes #(\d+)/gi)].map((m) => Number(m[1])))];
|
|
4487
|
+
}
|
|
4488
|
+
function extractIssue(body) {
|
|
4489
|
+
const stripped = stripCode(body);
|
|
4490
|
+
const bodyNums = closesRefs(stripped);
|
|
4491
|
+
const anchored = anchoredRegion(stripped, "CLOSES");
|
|
4492
|
+
if (anchored !== null) {
|
|
4493
|
+
const anchorNums = closesRefs(anchored);
|
|
4494
|
+
if (anchorNums.length === 0)
|
|
4495
|
+
return { issue: null, extraIssues: bodyNums, outsideHeader: false };
|
|
4496
|
+
const issue = anchorNums[0];
|
|
4497
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
|
|
4491
4498
|
}
|
|
4492
|
-
|
|
4499
|
+
const headerNums = closesRefs(headerRegion(stripped));
|
|
4500
|
+
if (bodyNums.length === 0)
|
|
4501
|
+
return { issue: null, extraIssues: [], outsideHeader: false };
|
|
4502
|
+
const issue = headerNums.length > 0 ? headerNums[0] : bodyNums[0];
|
|
4503
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: headerNums.length === 0 };
|
|
4493
4504
|
}
|
|
4494
|
-
// ../../packages/aeg-core/src/
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
".
|
|
4498
|
-
|
|
4499
|
-
"apps/cli/README.md",
|
|
4500
|
-
"packages/sources/README.md"
|
|
4501
|
-
];
|
|
4502
|
-
function isUnderOrEqual(path, prefix) {
|
|
4503
|
-
return path === prefix || path.startsWith(`${prefix}/`);
|
|
4505
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4506
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
4507
|
+
function briefHash(brief) {
|
|
4508
|
+
return createHash4("sha256").update(`${brief}
|
|
4509
|
+
`).digest("hex");
|
|
4504
4510
|
}
|
|
4505
|
-
function
|
|
4506
|
-
return
|
|
4511
|
+
function policyDigest(policy) {
|
|
4512
|
+
return createHash4("sha256").update(JSON.stringify({
|
|
4513
|
+
codeReviewThreshold: policy.codeReviewThreshold,
|
|
4514
|
+
securityThreshold: policy.securityThreshold,
|
|
4515
|
+
maxRounds: policy.maxRounds
|
|
4516
|
+
})).digest("hex");
|
|
4507
4517
|
}
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4518
|
+
function isBoundToHead(echoed, headSha) {
|
|
4519
|
+
if (!echoed.headSha)
|
|
4520
|
+
return false;
|
|
4521
|
+
return headSha.toLowerCase().startsWith(echoed.headSha.toLowerCase());
|
|
4511
4522
|
}
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
return out;
|
|
4523
|
+
function isBoundByPatchIdentity(echoed, headSha, patchIdOf) {
|
|
4524
|
+
if (patchIdOf === undefined || !echoed.headSha)
|
|
4525
|
+
return false;
|
|
4526
|
+
const judged = patchIdOf(echoed.headSha);
|
|
4527
|
+
const current = patchIdOf(headSha);
|
|
4528
|
+
if (judged === null || current === null)
|
|
4529
|
+
return false;
|
|
4530
|
+
return judged === current;
|
|
4521
4531
|
}
|
|
4522
|
-
function
|
|
4523
|
-
if (
|
|
4532
|
+
function isBoundToBase(echoed, currentBase) {
|
|
4533
|
+
if (currentBase === null)
|
|
4524
4534
|
return true;
|
|
4525
|
-
if (!
|
|
4535
|
+
if (!echoed.baseSha)
|
|
4526
4536
|
return false;
|
|
4527
|
-
return
|
|
4537
|
+
return currentBase.toLowerCase().startsWith(echoed.baseSha.toLowerCase());
|
|
4528
4538
|
}
|
|
4529
|
-
function
|
|
4530
|
-
|
|
4539
|
+
function isBoundToObjectives(echoed, currentVersion) {
|
|
4540
|
+
if (currentVersion === null)
|
|
4541
|
+
return true;
|
|
4542
|
+
return echoed.objectivesVersion === currentVersion;
|
|
4531
4543
|
}
|
|
4532
|
-
function
|
|
4533
|
-
if (
|
|
4534
|
-
return
|
|
4544
|
+
function isBoundToRulings(echoed, currentOrdinal) {
|
|
4545
|
+
if (echoed.rulingOrdinal === null)
|
|
4546
|
+
return currentOrdinal === 0;
|
|
4547
|
+
return echoed.rulingOrdinal === currentOrdinal;
|
|
4548
|
+
}
|
|
4549
|
+
function isBoundToBriefHash(echoed, currentHash) {
|
|
4550
|
+
if (currentHash === null)
|
|
4551
|
+
return true;
|
|
4552
|
+
return echoed.briefHash === currentHash;
|
|
4553
|
+
}
|
|
4554
|
+
function isBoundToPolicy(echoed, currentDigest) {
|
|
4555
|
+
return echoed.policyDigest === currentDigest;
|
|
4556
|
+
}
|
|
4557
|
+
function compareManifest(echoed, current, patchIdOf) {
|
|
4558
|
+
const exactHead = isBoundToHead(echoed, current.headSha);
|
|
4559
|
+
const patchHead = exactHead ? false : isBoundByPatchIdentity(echoed, current.headSha, patchIdOf);
|
|
4560
|
+
const head = exactHead || patchHead;
|
|
4561
|
+
const echoedShaLen = echoed.baseSha?.length ?? 0;
|
|
4562
|
+
const currentShaLen = current.baseSha?.length ?? 0;
|
|
4563
|
+
const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
|
|
4564
|
+
const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
|
|
4565
|
+
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4566
|
+
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4567
|
+
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
4568
|
+
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4569
|
+
return {
|
|
4570
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
4571
|
+
head,
|
|
4572
|
+
base,
|
|
4573
|
+
briefHash: briefHashBound,
|
|
4574
|
+
objectivesVersion,
|
|
4575
|
+
rulingOrdinal,
|
|
4576
|
+
policyDigest: policyDigestBound
|
|
4577
|
+
};
|
|
4578
|
+
}
|
|
4579
|
+
|
|
4580
|
+
// ../../packages/aeg-core/src/review-gate.ts
|
|
4581
|
+
function renderGateDeferred(deferred) {
|
|
4582
|
+
if (deferred.length === 0)
|
|
4583
|
+
return "";
|
|
4584
|
+
const items = deferred.map((d) => {
|
|
4585
|
+
const where = d.finding.location && d.finding.location.length > 0 ? d.finding.location : "(no location)";
|
|
4586
|
+
return `${d.finding.severity} ${where} (${DEFERRAL_REASON_TEXT[d.reason]})`;
|
|
4587
|
+
}).join("; ");
|
|
4588
|
+
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4589
|
+
}
|
|
4590
|
+
function checkReviewGate(input) {
|
|
4591
|
+
const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
|
|
4592
|
+
const waived = isWaiverLabelActorVerified({
|
|
4593
|
+
label: WAIVER_LABEL_REVIEW,
|
|
4594
|
+
labels: input.labels,
|
|
4595
|
+
labelActor: input.waiverLabelActor,
|
|
4596
|
+
principalAllowlist
|
|
4597
|
+
});
|
|
4598
|
+
if (waived) {
|
|
4599
|
+
return {
|
|
4600
|
+
verdict: "pass",
|
|
4601
|
+
reason: `\`${WAIVER_LABEL_REVIEW}\` label is actor-verified — review requirement waived for this PR.`,
|
|
4602
|
+
waived: true
|
|
4603
|
+
};
|
|
4535
4604
|
}
|
|
4536
|
-
|
|
4537
|
-
|
|
4605
|
+
const verified = input.comments.filter((c) => isPrincipal(c.author, principalAllowlist));
|
|
4606
|
+
const ignoredCount = input.comments.filter((c) => !isPrincipal(c.author, principalAllowlist) && c.body.includes("VERDICT")).length;
|
|
4607
|
+
const verifiedBodies = verified.map((c) => c.body);
|
|
4608
|
+
const codeReview = extractCodeReviewVerdict(verifiedBodies);
|
|
4609
|
+
const security = extractSecurityReviewVerdict(verifiedBodies);
|
|
4610
|
+
const policy = input.policy ?? DEFAULT_REVIEW_POLICY;
|
|
4611
|
+
let codeReviewPolicyEvaluation;
|
|
4612
|
+
let securityPolicyEvaluation;
|
|
4613
|
+
try {
|
|
4614
|
+
codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy, input.deferralContext);
|
|
4615
|
+
securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy, input.deferralContext);
|
|
4616
|
+
} catch (err) {
|
|
4617
|
+
return {
|
|
4618
|
+
verdict: "fail",
|
|
4619
|
+
reason: `a verdict comment carries a finding severity this repository's policy does not recognize: ${err instanceof Error ? err.message : String(err)}`,
|
|
4620
|
+
waived: false
|
|
4621
|
+
};
|
|
4538
4622
|
}
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4623
|
+
const codeReviewTextClean = codeReview.value === "APPROVE";
|
|
4624
|
+
const securityTextClean = security.value === "PASS";
|
|
4625
|
+
const codeReviewPolicyClean = codeReviewPolicyEvaluation.outcome === "clean";
|
|
4626
|
+
const securityPolicyClean = securityPolicyEvaluation.outcome === "clean";
|
|
4627
|
+
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4628
|
+
const securityClean = securityTextClean && securityPolicyClean;
|
|
4629
|
+
const currentManifest = {
|
|
4630
|
+
headSha: input.headSha,
|
|
4631
|
+
baseSha: input.baseSha ?? null,
|
|
4632
|
+
briefHash: input.briefHash ?? null,
|
|
4633
|
+
objectivesVersion: input.objectivesVersion,
|
|
4634
|
+
rulingOrdinal: input.rulingOrdinal,
|
|
4635
|
+
policyDigest: policyDigest(policy)
|
|
4636
|
+
};
|
|
4637
|
+
const codeReviewEchoed = {
|
|
4638
|
+
headSha: codeReview.headSha,
|
|
4639
|
+
baseSha: codeReview.baseSha,
|
|
4640
|
+
briefHash: codeReview.briefHash,
|
|
4641
|
+
objectivesVersion: codeReview.objectivesVersion,
|
|
4642
|
+
rulingOrdinal: codeReview.rulingOrdinal,
|
|
4643
|
+
policyDigest: codeReview.policyDigest
|
|
4644
|
+
};
|
|
4645
|
+
const securityEchoed = {
|
|
4646
|
+
headSha: security.headSha,
|
|
4647
|
+
baseSha: security.baseSha,
|
|
4648
|
+
briefHash: security.briefHash,
|
|
4649
|
+
objectivesVersion: security.objectivesVersion,
|
|
4650
|
+
rulingOrdinal: security.rulingOrdinal,
|
|
4651
|
+
policyDigest: security.policyDigest
|
|
4652
|
+
};
|
|
4653
|
+
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
4654
|
+
const securityBinding = compareManifest(securityEchoed, currentManifest, input.patchIdOf);
|
|
4655
|
+
const codeReviewBound = codeReviewBinding.head;
|
|
4656
|
+
const securityBound = securityBinding.head;
|
|
4657
|
+
const codeReviewObjectivesBound = codeReviewBinding.objectivesVersion;
|
|
4658
|
+
const securityObjectivesBound = securityBinding.objectivesVersion;
|
|
4659
|
+
const codeReviewRulingsBound = codeReviewBinding.rulingOrdinal;
|
|
4660
|
+
const securityRulingsBound = securityBinding.rulingOrdinal;
|
|
4661
|
+
const deferredNote = renderGateDeferred([
|
|
4662
|
+
...codeReviewPolicyEvaluation.deferredFindings,
|
|
4663
|
+
...securityPolicyEvaluation.deferredFindings
|
|
4664
|
+
]);
|
|
4665
|
+
if (codeReviewClean && codeReviewBinding.bound && securityClean && securityBinding.bound) {
|
|
4666
|
+
return {
|
|
4667
|
+
verdict: "pass",
|
|
4668
|
+
reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.${deferredNote}`,
|
|
4669
|
+
waived: false
|
|
4670
|
+
};
|
|
4551
4671
|
}
|
|
4552
|
-
|
|
4553
|
-
|
|
4672
|
+
const problems = [];
|
|
4673
|
+
if (!codeReviewTextClean) {
|
|
4674
|
+
problems.push(`code-reviewer verdict is not a clean APPROVE (found: ${codeReview.value})`);
|
|
4675
|
+
} else if (!codeReviewPolicyClean) {
|
|
4676
|
+
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`);
|
|
4677
|
+
} else if (!codeReviewBound) {
|
|
4678
|
+
problems.push(`the newest code-review verdict covers ${codeReview.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
|
|
4679
|
+
} else if (!codeReviewBinding.base) {
|
|
4680
|
+
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)`);
|
|
4681
|
+
} else if (!codeReviewObjectivesBound) {
|
|
4682
|
+
problems.push(`the newest code-review verdict was cast against objectives version ${codeReview.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
|
|
4683
|
+
} else if (!codeReviewRulingsBound) {
|
|
4684
|
+
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`);
|
|
4685
|
+
} else if (!codeReviewBinding.briefHash) {
|
|
4686
|
+
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"}`);
|
|
4687
|
+
} else if (!codeReviewBinding.policyDigest) {
|
|
4688
|
+
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}`);
|
|
4554
4689
|
}
|
|
4555
|
-
|
|
4556
|
-
}
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
}
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4690
|
+
if (!securityTextClean) {
|
|
4691
|
+
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
4692
|
+
} else if (!securityPolicyClean) {
|
|
4693
|
+
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`);
|
|
4694
|
+
} else if (!securityBound) {
|
|
4695
|
+
problems.push(`the newest security-review verdict covers ${security.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
|
|
4696
|
+
} else if (!securityBinding.base) {
|
|
4697
|
+
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)`);
|
|
4698
|
+
} else if (!securityObjectivesBound) {
|
|
4699
|
+
problems.push(`the newest security-review verdict was cast against objectives version ${security.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
|
|
4700
|
+
} else if (!securityRulingsBound) {
|
|
4701
|
+
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`);
|
|
4702
|
+
} else if (!securityBinding.briefHash) {
|
|
4703
|
+
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"}`);
|
|
4704
|
+
} else if (!securityBinding.policyDigest) {
|
|
4705
|
+
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}`);
|
|
4565
4706
|
}
|
|
4566
|
-
|
|
4707
|
+
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4708
|
+
return {
|
|
4709
|
+
verdict: "fail",
|
|
4710
|
+
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}`,
|
|
4711
|
+
waived: false
|
|
4712
|
+
};
|
|
4567
4713
|
}
|
|
4568
|
-
var
|
|
4569
|
-
var
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
if (legacySlugs.length === 0)
|
|
4573
|
-
return null;
|
|
4574
|
-
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
4575
|
-
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
4714
|
+
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4715
|
+
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4716
|
+
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4717
|
+
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4576
4718
|
}
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
const
|
|
4582
|
-
|
|
4583
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
4584
|
-
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
4585
|
-
];
|
|
4586
|
-
const productPatterns = [
|
|
4587
|
-
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
4588
|
-
];
|
|
4589
|
-
const specPatterns = [
|
|
4590
|
-
...patterns,
|
|
4591
|
-
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
4592
|
-
];
|
|
4593
|
-
for (const file of files) {
|
|
4594
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
4595
|
-
if (!cls || cls === "internal")
|
|
4596
|
-
continue;
|
|
4597
|
-
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
4719
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4720
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4721
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4722
|
+
let best = 0;
|
|
4723
|
+
for (const c of comments) {
|
|
4724
|
+
if (!isPrincipal(c.author, allowlist))
|
|
4598
4725
|
continue;
|
|
4599
|
-
|
|
4726
|
+
const firstLine = (c.body.split(`
|
|
4727
|
+
`)[0] ?? "").trim();
|
|
4728
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4729
|
+
if (!m)
|
|
4600
4730
|
continue;
|
|
4601
|
-
const
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4731
|
+
const k = Number.parseInt(m[1], 10);
|
|
4732
|
+
if (k > best)
|
|
4733
|
+
best = k;
|
|
4734
|
+
}
|
|
4735
|
+
return best;
|
|
4736
|
+
}
|
|
4737
|
+
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4738
|
+
function splitRow(line) {
|
|
4739
|
+
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
4740
|
+
return trimmed.split("|").map((cell) => cell.trim());
|
|
4741
|
+
}
|
|
4742
|
+
var TABLE_ROW_PATTERN = /^\s*\|.*\|\s*$/;
|
|
4743
|
+
var SEPARATOR_ROW_PATTERN = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
|
|
4744
|
+
function findTable(lines, fromLine, stopAtHeading = true) {
|
|
4745
|
+
let i = fromLine - 1;
|
|
4746
|
+
while (i < lines.length) {
|
|
4747
|
+
const line = lines[i] ?? "";
|
|
4748
|
+
if (stopAtHeading && i > fromLine - 1 && /^##\s/.test(line))
|
|
4749
|
+
return null;
|
|
4750
|
+
if (TABLE_ROW_PATTERN.test(line)) {
|
|
4751
|
+
const headerLine = line;
|
|
4752
|
+
const sepLine = lines[i + 1] ?? "";
|
|
4753
|
+
if (!SEPARATOR_ROW_PATTERN.test(sepLine)) {
|
|
4754
|
+
i++;
|
|
4755
|
+
continue;
|
|
4756
|
+
}
|
|
4757
|
+
const headers = splitRow(headerLine);
|
|
4758
|
+
const rows = [];
|
|
4759
|
+
let j = i + 2;
|
|
4760
|
+
while (j < lines.length && TABLE_ROW_PATTERN.test(lines[j] ?? "")) {
|
|
4761
|
+
rows.push({ cells: splitRow(lines[j] ?? ""), line: j + 1 });
|
|
4762
|
+
j++;
|
|
4617
4763
|
}
|
|
4764
|
+
return { headers, rows };
|
|
4618
4765
|
}
|
|
4766
|
+
i++;
|
|
4619
4767
|
}
|
|
4620
|
-
return
|
|
4768
|
+
return null;
|
|
4621
4769
|
}
|
|
4622
|
-
function
|
|
4623
|
-
|
|
4770
|
+
function findHeadingLine(lines, pattern) {
|
|
4771
|
+
for (let i = 0;i < lines.length; i++) {
|
|
4772
|
+
if (pattern.test(lines[i] ?? ""))
|
|
4773
|
+
return i + 1;
|
|
4774
|
+
}
|
|
4775
|
+
return null;
|
|
4624
4776
|
}
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4777
|
+
// ../../packages/aeg-core/src/diagram-model.ts
|
|
4778
|
+
import matter from "gray-matter";
|
|
4779
|
+
|
|
4780
|
+
// ../../packages/aeg-core/src/registry-parse.ts
|
|
4781
|
+
var RING_HEADINGS = [
|
|
4782
|
+
{ ring: "ring0", pattern: /^##\s+Ring 0\b/ },
|
|
4783
|
+
{ ring: "ring1", pattern: /^##\s+Ring 1\b/ },
|
|
4784
|
+
{ ring: "ring2", pattern: /^##\s+Ring 2\b/ }
|
|
4785
|
+
];
|
|
4786
|
+
function stripBackticks2(cell) {
|
|
4787
|
+
const trimmed = cell.trim();
|
|
4788
|
+
if (trimmed.length >= 2 && trimmed.startsWith("`") && trimmed.endsWith("`")) {
|
|
4789
|
+
return trimmed.slice(1, -1);
|
|
4790
|
+
}
|
|
4791
|
+
return trimmed;
|
|
4629
4792
|
}
|
|
4630
|
-
function
|
|
4793
|
+
function stripBold(cell) {
|
|
4794
|
+
return cell.trim().replace(/\*\*/g, "");
|
|
4795
|
+
}
|
|
4796
|
+
function parseEnforcementRegistry(content) {
|
|
4631
4797
|
const lines = content.split(`
|
|
4632
4798
|
`);
|
|
4633
|
-
|
|
4634
|
-
for (const
|
|
4635
|
-
|
|
4636
|
-
if (
|
|
4637
|
-
|
|
4799
|
+
const result = [];
|
|
4800
|
+
for (const { ring, pattern } of RING_HEADINGS) {
|
|
4801
|
+
const headingLine = findHeadingLine(lines, pattern);
|
|
4802
|
+
if (headingLine === null)
|
|
4803
|
+
continue;
|
|
4804
|
+
const table = findTable(lines, headingLine + 1);
|
|
4805
|
+
if (!table)
|
|
4806
|
+
continue;
|
|
4807
|
+
const descriptionIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "description");
|
|
4808
|
+
const implementationIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "implementation");
|
|
4809
|
+
const audienceIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "audience");
|
|
4810
|
+
for (const row of table.rows) {
|
|
4811
|
+
const cells = row.cells;
|
|
4812
|
+
if (cells.length < 3)
|
|
4813
|
+
continue;
|
|
4814
|
+
const action = stripBold(cells[0] ?? "");
|
|
4815
|
+
const summary = stripBackticks2(cells[1] ?? "");
|
|
4816
|
+
const category = stripBackticks2(cells[2] ?? "");
|
|
4817
|
+
const implementation = stripBackticks2((implementationIndex === -1 ? cells[cells.length - 1] : cells[implementationIndex]) ?? "");
|
|
4818
|
+
const description = descriptionIndex === -1 ? undefined : stripBackticks2(cells[descriptionIndex] ?? "") || undefined;
|
|
4819
|
+
const specIndex = (audienceIndex === -1 ? cells.length - 1 : audienceIndex) - 1;
|
|
4820
|
+
const spec = specIndex >= 3 ? stripBackticks2(cells[specIndex] ?? "") || undefined : undefined;
|
|
4821
|
+
const audience = audienceIndex === -1 ? "repo-own" : stripBackticks2(cells[audienceIndex] ?? "") === "product" ? "product" : "repo-own";
|
|
4822
|
+
result.push({ ring, action, summary, category, description, spec, implementation, audience, line: row.line });
|
|
4823
|
+
}
|
|
4638
4824
|
}
|
|
4639
|
-
return
|
|
4640
|
-
}
|
|
4641
|
-
function definesOrLinksGlossary(content, term) {
|
|
4642
|
-
const escaped = escapeTerm(term);
|
|
4643
|
-
const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
|
|
4644
|
-
if (definesInline)
|
|
4645
|
-
return true;
|
|
4646
|
-
return /docs\/glossary|glossary\.md/i.test(content);
|
|
4825
|
+
return result;
|
|
4647
4826
|
}
|
|
4648
|
-
|
|
4827
|
+
// ../../packages/aeg-core/src/registry-checks.ts
|
|
4828
|
+
function checkG1(rows, existsFn) {
|
|
4649
4829
|
const findings = [];
|
|
4650
|
-
for (const
|
|
4651
|
-
|
|
4652
|
-
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
4830
|
+
for (const row of rows) {
|
|
4831
|
+
if (row.implementation === "")
|
|
4653
4832
|
continue;
|
|
4654
|
-
|
|
4655
|
-
for (const term of glossaryTerms) {
|
|
4656
|
-
const line = findWholeWordLine(scrubbed, term);
|
|
4657
|
-
if (line === null)
|
|
4658
|
-
continue;
|
|
4659
|
-
if (definesOrLinksGlossary(scrubbed, term))
|
|
4660
|
-
continue;
|
|
4833
|
+
if (!existsFn(row.implementation)) {
|
|
4661
4834
|
findings.push({
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
blocking: false
|
|
4835
|
+
row: row.action,
|
|
4836
|
+
path: row.implementation,
|
|
4837
|
+
reason: `${row.ring} row "${row.action}" names implementation "${row.implementation}", which does not exist on disk`
|
|
4666
4838
|
});
|
|
4667
4839
|
}
|
|
4668
4840
|
}
|
|
4669
|
-
return findings;
|
|
4841
|
+
return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4670
4842
|
}
|
|
4671
|
-
var
|
|
4672
|
-
var
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
const
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
const next = i + 1 < n ? content[i + 1] : "";
|
|
4686
|
-
if (state === "code") {
|
|
4687
|
-
if (c === "/" && next === "/") {
|
|
4688
|
-
state = "line-comment";
|
|
4689
|
-
out += c;
|
|
4690
|
-
i++;
|
|
4691
|
-
continue;
|
|
4692
|
-
}
|
|
4693
|
-
if (c === "/" && next === "*") {
|
|
4694
|
-
state = "block-comment";
|
|
4695
|
-
out += c;
|
|
4696
|
-
i++;
|
|
4697
|
-
continue;
|
|
4698
|
-
}
|
|
4699
|
-
if (c === "'") {
|
|
4700
|
-
state = "single-quote";
|
|
4701
|
-
out += blank(c);
|
|
4702
|
-
i++;
|
|
4703
|
-
continue;
|
|
4704
|
-
}
|
|
4705
|
-
if (c === '"') {
|
|
4706
|
-
state = "double-quote";
|
|
4707
|
-
out += blank(c);
|
|
4708
|
-
i++;
|
|
4709
|
-
continue;
|
|
4710
|
-
}
|
|
4711
|
-
if (c === "`") {
|
|
4712
|
-
state = "template";
|
|
4713
|
-
out += blank(c);
|
|
4714
|
-
i++;
|
|
4715
|
-
continue;
|
|
4716
|
-
}
|
|
4717
|
-
out += blank(c);
|
|
4718
|
-
i++;
|
|
4719
|
-
continue;
|
|
4720
|
-
}
|
|
4721
|
-
if (state === "line-comment") {
|
|
4722
|
-
if (c === `
|
|
4723
|
-
`) {
|
|
4724
|
-
state = "code";
|
|
4725
|
-
out += `
|
|
4726
|
-
`;
|
|
4727
|
-
i++;
|
|
4728
|
-
continue;
|
|
4729
|
-
}
|
|
4730
|
-
out += c;
|
|
4731
|
-
i++;
|
|
4843
|
+
var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
4844
|
+
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
4845
|
+
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
4846
|
+
"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)',
|
|
4847
|
+
"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)`,
|
|
4848
|
+
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
4849
|
+
};
|
|
4850
|
+
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
4851
|
+
function checkG2(rows, candidateFiles) {
|
|
4852
|
+
const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
|
|
4853
|
+
const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
|
|
4854
|
+
const findings = [];
|
|
4855
|
+
for (const path of candidateFiles) {
|
|
4856
|
+
if (implementations.has(path))
|
|
4732
4857
|
continue;
|
|
4733
|
-
|
|
4734
|
-
if (state === "block-comment") {
|
|
4735
|
-
if (c === "*" && next === "/") {
|
|
4736
|
-
out += c;
|
|
4737
|
-
out += next;
|
|
4738
|
-
state = "code";
|
|
4739
|
-
i += 2;
|
|
4740
|
-
continue;
|
|
4741
|
-
}
|
|
4742
|
-
out += c === `
|
|
4743
|
-
` ? `
|
|
4744
|
-
` : c;
|
|
4745
|
-
i++;
|
|
4858
|
+
if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
|
|
4746
4859
|
continue;
|
|
4747
|
-
|
|
4748
|
-
const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
|
|
4749
|
-
if (c === "\\") {
|
|
4750
|
-
out += blank(c);
|
|
4751
|
-
i++;
|
|
4752
|
-
if (i < n) {
|
|
4753
|
-
out += blank(content[i]);
|
|
4754
|
-
i++;
|
|
4755
|
-
}
|
|
4860
|
+
if (NON_GATE_HOOK_SCRIPTS.includes(path))
|
|
4756
4861
|
continue;
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
i++;
|
|
4862
|
+
if (path in TWIN_CANDIDATE_EXCEPTIONS)
|
|
4863
|
+
continue;
|
|
4864
|
+
const candidateNames = claimedCheckNames(path);
|
|
4865
|
+
if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
|
|
4762
4866
|
continue;
|
|
4867
|
+
findings.push({
|
|
4868
|
+
path,
|
|
4869
|
+
reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
|
|
4870
|
+
});
|
|
4871
|
+
}
|
|
4872
|
+
for (const row of rows) {
|
|
4873
|
+
const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
|
|
4874
|
+
if (carriesPlaceholder) {
|
|
4875
|
+
findings.push({
|
|
4876
|
+
row: row.action,
|
|
4877
|
+
path: row.implementation,
|
|
4878
|
+
reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
|
|
4879
|
+
});
|
|
4763
4880
|
}
|
|
4764
|
-
out += blank(c);
|
|
4765
|
-
i++;
|
|
4766
4881
|
}
|
|
4767
|
-
return
|
|
4882
|
+
return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4768
4883
|
}
|
|
4769
|
-
function
|
|
4884
|
+
function checkG3(ring0Rows, crossingFiles) {
|
|
4885
|
+
const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
|
|
4770
4886
|
const findings = [];
|
|
4771
|
-
const
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
if (!file.path.endsWith(".ts"))
|
|
4778
|
-
continue;
|
|
4779
|
-
if (allowed.has(file.path))
|
|
4780
|
-
continue;
|
|
4781
|
-
const comments = extractComments(file.path, file.content);
|
|
4782
|
-
for (const { pattern, what } of patterns) {
|
|
4783
|
-
pattern.lastIndex = 0;
|
|
4784
|
-
let match = pattern.exec(comments);
|
|
4785
|
-
while (match !== null) {
|
|
4786
|
-
findings.push({
|
|
4787
|
-
file: file.path,
|
|
4788
|
-
line: lineAt(comments, match.index),
|
|
4789
|
-
message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
|
|
4790
|
-
blocking: false
|
|
4791
|
-
});
|
|
4792
|
-
match = pattern.exec(comments);
|
|
4793
|
-
}
|
|
4887
|
+
for (const path of crossingFiles) {
|
|
4888
|
+
if (!ring0Implementations.has(path)) {
|
|
4889
|
+
findings.push({
|
|
4890
|
+
path,
|
|
4891
|
+
reason: `"${path}" makes a GitHub-crossing call but is not named by any Ring-0 row's implementation — a seventh, unlisted way into GitHub`
|
|
4892
|
+
});
|
|
4794
4893
|
}
|
|
4795
4894
|
}
|
|
4796
|
-
return findings;
|
|
4797
|
-
}
|
|
4798
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4799
|
-
return [
|
|
4800
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
4801
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4802
|
-
];
|
|
4895
|
+
return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4803
4896
|
}
|
|
4804
|
-
function
|
|
4805
|
-
const
|
|
4806
|
-
const
|
|
4807
|
-
|
|
4808
|
-
while (match !== null) {
|
|
4809
|
-
if (match[1] !== undefined)
|
|
4810
|
-
terms.push(match[1]);
|
|
4811
|
-
match = re.exec(glossaryContent);
|
|
4897
|
+
function checkG4(content, resolveFn) {
|
|
4898
|
+
const cited = new Set;
|
|
4899
|
+
for (const hit of content.matchAll(/#(\d{3,})\b/g)) {
|
|
4900
|
+
cited.add(Number(hit[1]));
|
|
4812
4901
|
}
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
|
|
4821
|
-
function isValidCitedFilePath(path) {
|
|
4822
|
-
if (path.length === 0)
|
|
4823
|
-
return false;
|
|
4824
|
-
if (path.startsWith("/") || path.startsWith("\\"))
|
|
4825
|
-
return false;
|
|
4826
|
-
if (/^[A-Za-z]:[\\/]/.test(path))
|
|
4827
|
-
return false;
|
|
4828
|
-
return !path.split(/[\\/]+/).includes("..");
|
|
4829
|
-
}
|
|
4830
|
-
function quotedCommandLineAt(content, index) {
|
|
4831
|
-
let line = 1;
|
|
4832
|
-
for (let i = 0;i < index; i++) {
|
|
4833
|
-
if (content.charCodeAt(i) === 10)
|
|
4834
|
-
line++;
|
|
4902
|
+
const findings = [];
|
|
4903
|
+
for (const n of cited) {
|
|
4904
|
+
if (!resolveFn(n)) {
|
|
4905
|
+
findings.push({
|
|
4906
|
+
reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
|
|
4907
|
+
});
|
|
4908
|
+
}
|
|
4835
4909
|
}
|
|
4836
|
-
return
|
|
4837
|
-
}
|
|
4838
|
-
function extractQuotedText(raw) {
|
|
4839
|
-
const trimmed = raw.trim();
|
|
4840
|
-
const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
|
|
4841
|
-
if (fenced)
|
|
4842
|
-
return (fenced[1] ?? "").trim();
|
|
4843
|
-
const inline = /^`([^`]+)`$/.exec(trimmed);
|
|
4844
|
-
if (inline)
|
|
4845
|
-
return (inline[1] ?? "").trim();
|
|
4846
|
-
return trimmed;
|
|
4910
|
+
return { check: "G4", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4847
4911
|
}
|
|
4848
|
-
function
|
|
4849
|
-
const
|
|
4850
|
-
const
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
if (end === null) {
|
|
4858
|
-
START_PATTERN.lastIndex = innerStart;
|
|
4859
|
-
start = START_PATTERN.exec(masked);
|
|
4860
|
-
continue;
|
|
4912
|
+
function checkG5(roles, contracts) {
|
|
4913
|
+
const roleIds = new Set(roles.map((r) => r.role_id));
|
|
4914
|
+
const findings = [];
|
|
4915
|
+
for (const contract of contracts) {
|
|
4916
|
+
if (!roleIds.has(contract.producer)) {
|
|
4917
|
+
findings.push({
|
|
4918
|
+
path: contract.file,
|
|
4919
|
+
reason: `contract "${contract.file}" names producer "${contract.producer}", which is not a real role_id`
|
|
4920
|
+
});
|
|
4861
4921
|
}
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
}
|
|
4922
|
+
if (!roleIds.has(contract.consumer)) {
|
|
4923
|
+
findings.push({
|
|
4924
|
+
path: contract.file,
|
|
4925
|
+
reason: `contract "${contract.file}" names consumer "${contract.consumer}", which is not a real role_id`
|
|
4926
|
+
});
|
|
4868
4927
|
}
|
|
4869
|
-
START_PATTERN.lastIndex = innerEnd + end[0].length;
|
|
4870
|
-
start = START_PATTERN.exec(masked);
|
|
4871
4928
|
}
|
|
4872
|
-
|
|
4929
|
+
for (const role of roles) {
|
|
4930
|
+
if (role.performs.length === 0) {
|
|
4931
|
+
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty performs array` });
|
|
4932
|
+
}
|
|
4933
|
+
if (role.refuses_when.trim() === "") {
|
|
4934
|
+
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty refuses_when` });
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
return { check: "G5", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4873
4938
|
}
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4939
|
+
var SHIPPED_BIN_PATH_PREFIX = "apps/cli/src/checks/bin/check-";
|
|
4940
|
+
var AEG_CORE_BIN_PATH_PREFIX = "packages/aeg-core/bin/";
|
|
4941
|
+
function basenameNoExt(path) {
|
|
4942
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
4943
|
+
return base.replace(/\.ts$/, "");
|
|
4944
|
+
}
|
|
4945
|
+
function claimedCheckNames(implementation) {
|
|
4946
|
+
if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
|
|
4947
|
+
return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
|
|
4881
4948
|
}
|
|
4882
|
-
|
|
4949
|
+
if (implementation.startsWith(AEG_CORE_BIN_PATH_PREFIX)) {
|
|
4950
|
+
const audience = GATE_AUDIENCE[basenameNoExt(implementation)];
|
|
4951
|
+
if (audience && isShipped(audience)) {
|
|
4952
|
+
return Array.isArray(audience.shippedAs) ? audience.shippedAs : [audience.shippedAs];
|
|
4953
|
+
}
|
|
4954
|
+
}
|
|
4955
|
+
return [];
|
|
4883
4956
|
}
|
|
4884
|
-
function
|
|
4957
|
+
function checkG6(rows, registeredCheckNames) {
|
|
4885
4958
|
const findings = [];
|
|
4886
|
-
for (const
|
|
4887
|
-
|
|
4888
|
-
if (content === undefined) {
|
|
4889
|
-
findings.push({
|
|
4890
|
-
file: quote.file,
|
|
4891
|
-
line: quote.line,
|
|
4892
|
-
citedFile: quote.citedFile,
|
|
4893
|
-
quotedText: quote.quotedText,
|
|
4894
|
-
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
|
|
4895
|
-
});
|
|
4959
|
+
for (const row of rows) {
|
|
4960
|
+
if (row.audience !== "product")
|
|
4896
4961
|
continue;
|
|
4897
|
-
|
|
4898
|
-
if (!
|
|
4962
|
+
const candidates = claimedCheckNames(row.implementation);
|
|
4963
|
+
if (!candidates.some((name) => registeredCheckNames.has(name))) {
|
|
4899
4964
|
findings.push({
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
quotedText: quote.quotedText,
|
|
4904
|
-
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
|
|
4965
|
+
row: row.action,
|
|
4966
|
+
path: row.implementation,
|
|
4967
|
+
reason: `${row.ring} row "${row.action}" is marked \`product\` but its implementation "${row.implementation}" does not resolve to a coreCheckRegistry() entry`
|
|
4905
4968
|
});
|
|
4906
4969
|
}
|
|
4907
4970
|
}
|
|
4908
|
-
return findings;
|
|
4971
|
+
return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4909
4972
|
}
|
|
4910
4973
|
// ../../packages/aeg-core/src/dead-branch-push-guard.ts
|
|
4911
4974
|
function checkDeadBranchPush(input) {
|
|
@@ -5812,7 +5875,9 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
|
|
|
5812
5875
|
"escalated",
|
|
5813
5876
|
"principal_stop",
|
|
5814
5877
|
"confidence",
|
|
5815
|
-
"reappearance"
|
|
5878
|
+
"reappearance",
|
|
5879
|
+
"repeat_finding",
|
|
5880
|
+
"repeat_failure"
|
|
5816
5881
|
])
|
|
5817
5882
|
}).strict(),
|
|
5818
5883
|
z2.object({
|
|
@@ -6316,6 +6381,10 @@ var LoopStateRecordSchema = z3.object({
|
|
|
6316
6381
|
budgets: LoopBudgetsSchema,
|
|
6317
6382
|
heldResult: roundHeadIdentity.nullable(),
|
|
6318
6383
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6384
|
+
repeatMemory: z3.object({
|
|
6385
|
+
blockingFindings: z3.array(z3.string()),
|
|
6386
|
+
lastFailure: z3.object({ signature: z3.string(), message: z3.string() }).nullable()
|
|
6387
|
+
}).strict().optional(),
|
|
6319
6388
|
recordedAt: isoTimestamp
|
|
6320
6389
|
}).strict();
|
|
6321
6390
|
var EffectRecordSchema = z3.object({
|
|
@@ -6367,11 +6436,11 @@ var ResolutionRecordSchema = z3.object({
|
|
|
6367
6436
|
consumedAt: isoTimestamp
|
|
6368
6437
|
}).strict();
|
|
6369
6438
|
// src/lib/diff-evidence.ts
|
|
6370
|
-
import { execFileSync as
|
|
6439
|
+
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
6371
6440
|
import { join as join9, relative, resolve as resolve2 } from "node:path";
|
|
6372
6441
|
|
|
6373
6442
|
// src/lib/config.ts
|
|
6374
|
-
import { execFile as execFile4, execFileSync as
|
|
6443
|
+
import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
|
|
6375
6444
|
import { promisify as promisify4 } from "node:util";
|
|
6376
6445
|
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
|
|
6377
6446
|
import { homedir } from "node:os";
|
|
@@ -6381,6 +6450,28 @@ import { z as z4 } from "zod";
|
|
|
6381
6450
|
// src/lib/agent-vendors.ts
|
|
6382
6451
|
var AGENT_VENDORS = ["skills", "claude", "gemini"];
|
|
6383
6452
|
|
|
6453
|
+
// src/lib/worker-boundary.ts
|
|
6454
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6455
|
+
var LOG_HEADER_KEYCHAIN_SERVICE = "Vinaya Log";
|
|
6456
|
+
var logHeaderKeychainCache = new Map;
|
|
6457
|
+
function readRealLogHeaderKeychainCredential(variable) {
|
|
6458
|
+
if (process.platform !== "darwin")
|
|
6459
|
+
return null;
|
|
6460
|
+
try {
|
|
6461
|
+
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$/, "");
|
|
6462
|
+
} catch {
|
|
6463
|
+
return null;
|
|
6464
|
+
}
|
|
6465
|
+
}
|
|
6466
|
+
function readLogHeaderKeychainCredential(variable) {
|
|
6467
|
+
const cached = logHeaderKeychainCache.get(variable);
|
|
6468
|
+
if (cached !== undefined)
|
|
6469
|
+
return cached;
|
|
6470
|
+
const value = readRealLogHeaderKeychainCredential(variable);
|
|
6471
|
+
logHeaderKeychainCache.set(variable, value);
|
|
6472
|
+
return value;
|
|
6473
|
+
}
|
|
6474
|
+
|
|
6384
6475
|
// src/lib/config.ts
|
|
6385
6476
|
var EnvEntrySchema = z4.union([
|
|
6386
6477
|
z4.literal(true),
|
|
@@ -6556,6 +6647,9 @@ var VinayaConfigSchema = z4.object({
|
|
|
6556
6647
|
briefRulesSincePr: z4.number().int().nonnegative().optional(),
|
|
6557
6648
|
agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
|
|
6558
6649
|
}).optional(),
|
|
6650
|
+
planning: z4.object({
|
|
6651
|
+
collisionThreshold: z4.number().int().nonnegative().optional()
|
|
6652
|
+
}).optional(),
|
|
6559
6653
|
prePush: z4.object({
|
|
6560
6654
|
alwaysRun: z4.array(z4.string()).optional()
|
|
6561
6655
|
}).optional(),
|
|
@@ -6730,12 +6824,17 @@ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
|
6730
6824
|
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
6731
6825
|
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
6732
6826
|
}
|
|
6733
|
-
function resolveLogsHeaderValues(headers, env) {
|
|
6827
|
+
function resolveLogsHeaderValues(headers, env, readKeychain = readLogHeaderKeychainCredential) {
|
|
6734
6828
|
if (!headers)
|
|
6735
6829
|
return;
|
|
6736
6830
|
const resolved = {};
|
|
6737
6831
|
for (const [key, value] of Object.entries(headers)) {
|
|
6738
|
-
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) =>
|
|
6832
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
|
|
6833
|
+
const fromEnv = env[name];
|
|
6834
|
+
if (fromEnv !== undefined)
|
|
6835
|
+
return fromEnv;
|
|
6836
|
+
return readKeychain(name) ?? "";
|
|
6837
|
+
});
|
|
6739
6838
|
}
|
|
6740
6839
|
return resolved;
|
|
6741
6840
|
}
|
|
@@ -6744,7 +6843,7 @@ function trustAnchorRepo() {
|
|
|
6744
6843
|
if (fromRunner)
|
|
6745
6844
|
return fromRunner;
|
|
6746
6845
|
try {
|
|
6747
|
-
const url =
|
|
6846
|
+
const url = execFileSync3("git", ["remote", "get-url", "origin"], {
|
|
6748
6847
|
encoding: "utf-8",
|
|
6749
6848
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6750
6849
|
});
|
|
@@ -6760,7 +6859,8 @@ async function trustAnchorRepoAsync() {
|
|
|
6760
6859
|
try {
|
|
6761
6860
|
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
6762
6861
|
encoding: "utf-8",
|
|
6763
|
-
timeout: 1e4
|
|
6862
|
+
timeout: 1e4,
|
|
6863
|
+
killSignal: "SIGKILL"
|
|
6764
6864
|
});
|
|
6765
6865
|
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
6766
6866
|
} catch {
|
|
@@ -6790,7 +6890,7 @@ function resolveCiTrustAnchorProbeRef(env = process.env) {
|
|
|
6790
6890
|
return ref;
|
|
6791
6891
|
}
|
|
6792
6892
|
function readTrustAnchorConfigAtRef(ref) {
|
|
6793
|
-
const raw =
|
|
6893
|
+
const raw = execFileSync3("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
|
|
6794
6894
|
encoding: "utf-8",
|
|
6795
6895
|
stdio: ["ignore", "pipe", "pipe"],
|
|
6796
6896
|
timeout: 1e4
|
|
@@ -6804,7 +6904,7 @@ function ghFetchTrustAnchorConfig() {
|
|
|
6804
6904
|
const repo = trustAnchorRepo();
|
|
6805
6905
|
if (!repo)
|
|
6806
6906
|
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6807
|
-
return
|
|
6907
|
+
return execFileSync3("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
6808
6908
|
encoding: "utf-8",
|
|
6809
6909
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6810
6910
|
});
|
|
@@ -6821,7 +6921,7 @@ async function ghFetchTrustAnchorConfigAsync() {
|
|
|
6821
6921
|
const repo = await trustAnchorRepoAsync();
|
|
6822
6922
|
if (!repo)
|
|
6823
6923
|
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6824
|
-
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
|
|
6924
|
+
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
|
|
6825
6925
|
return stdout;
|
|
6826
6926
|
}
|
|
6827
6927
|
function firstLine(err) {
|
|
@@ -6895,7 +6995,7 @@ function loadConfig() {
|
|
|
6895
6995
|
var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
|
|
6896
6996
|
|
|
6897
6997
|
// src/lib/brief-assembly.ts
|
|
6898
|
-
import { execFileSync as
|
|
6998
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
6899
6999
|
import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
|
|
6900
7000
|
import { join as join4 } from "node:path";
|
|
6901
7001
|
|
|
@@ -7591,6 +7691,27 @@ var COMMANDS = [
|
|
|
7591
7691
|
"issue-711 O4: this command — `--task <n>`, `--resume <pr>`, `--cancel <pr>` alike — stays `task run`'s own one-shot debug/direct entry; the watching driver that survives a pause and continues on its own is `task run`'s (see that command's own entry)."
|
|
7592
7692
|
],
|
|
7593
7693
|
status: "shipped"
|
|
7694
|
+
},
|
|
7695
|
+
{
|
|
7696
|
+
name: "log send",
|
|
7697
|
+
description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
|
|
7698
|
+
flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }],
|
|
7699
|
+
details: [
|
|
7700
|
+
"For a run whose events ended up on local disk instead of the configured server — an unattended run that fell back to the local folder because the trust-anchor read could not confirm its `logs.url` (a developer machine slower than the read deadline, or genuinely offline), or a retry queue holding a backlog or a `.draining.ndjson` a dead drain left behind. It moves the local folder's events into the retry queue and drains every queue for this repository through the SAME webhook delivery a live event uses.",
|
|
7701
|
+
"It resolves the destination exactly the way a normal event does — the sink's own decision over `vinaya.config.json`'s `logs` setting, trust-anchor-gated for an unattended caller — never a URL passed on the command line. A repository whose destination is a folder (or none) has nothing to send to a server and the command says so.",
|
|
7702
|
+
"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."
|
|
7703
|
+
],
|
|
7704
|
+
status: "shipped"
|
|
7705
|
+
},
|
|
7706
|
+
{
|
|
7707
|
+
name: "log set-credential",
|
|
7708
|
+
description: "Store a `logs.headers` delivery credential in the macOS login Keychain, read from standard input",
|
|
7709
|
+
details: [
|
|
7710
|
+
'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.',
|
|
7711
|
+
'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.',
|
|
7712
|
+
"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."
|
|
7713
|
+
],
|
|
7714
|
+
status: "shipped"
|
|
7594
7715
|
}
|
|
7595
7716
|
];
|
|
7596
7717
|
// ../../packages/sources/src/forge-adapter.ts
|
|
@@ -7608,7 +7729,7 @@ var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
|
|
|
7608
7729
|
z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
|
|
7609
7730
|
]);
|
|
7610
7731
|
// src/checks/edge-resolve.ts
|
|
7611
|
-
import { execFileSync as
|
|
7732
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
7612
7733
|
var DIRECT_ISSUE_REF = /#(\d+)/;
|
|
7613
7734
|
var issueCache = new Map;
|
|
7614
7735
|
function fetchIssueState(num, repo) {
|
|
@@ -7617,7 +7738,7 @@ function fetchIssueState(num, repo) {
|
|
|
7617
7738
|
return issueCache.get(key) ?? null;
|
|
7618
7739
|
let out = null;
|
|
7619
7740
|
try {
|
|
7620
|
-
const raw =
|
|
7741
|
+
const raw = execFileSync4("gh", [
|
|
7621
7742
|
"issue",
|
|
7622
7743
|
"view",
|
|
7623
7744
|
String(num),
|
|
@@ -7743,7 +7864,7 @@ function packageRoot(moduleUrl) {
|
|
|
7743
7864
|
}
|
|
7744
7865
|
|
|
7745
7866
|
// src/commands/doctrine.ts
|
|
7746
|
-
import { execFileSync as
|
|
7867
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
7747
7868
|
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
|
|
7748
7869
|
import { dirname as dirname3, join as join3, sep } from "node:path";
|
|
7749
7870
|
import matter2 from "gray-matter";
|
|
@@ -7753,7 +7874,7 @@ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.c
|
|
|
7753
7874
|
}
|
|
7754
7875
|
function gitToplevel(cwd) {
|
|
7755
7876
|
try {
|
|
7756
|
-
return
|
|
7877
|
+
return execFileSync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
|
|
7757
7878
|
encoding: "utf8",
|
|
7758
7879
|
stdio: ["ignore", "pipe", "pipe"]
|
|
7759
7880
|
}).trim();
|
|
@@ -7782,7 +7903,7 @@ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief
|
|
|
7782
7903
|
var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
7783
7904
|
function git(args) {
|
|
7784
7905
|
try {
|
|
7785
|
-
return
|
|
7906
|
+
return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
7786
7907
|
} catch {
|
|
7787
7908
|
return "";
|
|
7788
7909
|
}
|
|
@@ -8802,7 +8923,14 @@ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeou
|
|
|
8802
8923
|
|
|
8803
8924
|
// src/lib/log-sink.ts
|
|
8804
8925
|
var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
|
|
8926
|
+
function describeFolderFallback(reason) {
|
|
8927
|
+
if (reason.kind === "anchor-unreadable") {
|
|
8928
|
+
return `not delivering to the configured log server ${reason.intendedUrl} — the default branch's ` + "vinaya.config.json could not be read to confirm it (the trust-anchor read via `gh` was offline, " + "unauthenticated, or slower than its deadline); events are written to the local folder and can be " + "delivered later with `vinaya log send`";
|
|
8929
|
+
}
|
|
8930
|
+
return `not delivering to the working-tree log server ${reason.intendedUrl} — the default branch's ` + "vinaya.config.json does not declare it, so an unattended run does not honour it (a pull request cannot " + "redirect telemetry); events are written to the local folder";
|
|
8931
|
+
}
|
|
8805
8932
|
var LOG_CONTEXT_LOOKUP_DEADLINE_MS = 3000;
|
|
8933
|
+
var LOG_DESTINATION_ANCHOR_DEADLINE_MS = 8000;
|
|
8806
8934
|
function withDeadline(work, ms, fallback) {
|
|
8807
8935
|
return new Promise((resolve) => {
|
|
8808
8936
|
const timer = setTimeout(() => resolve(fallback), ms);
|
|
@@ -8817,7 +8945,7 @@ function withDeadline(work, ms, fallback) {
|
|
|
8817
8945
|
});
|
|
8818
8946
|
}
|
|
8819
8947
|
async function safeLoadTrustAnchorConfig() {
|
|
8820
|
-
return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }),
|
|
8948
|
+
return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_DESTINATION_ANCHOR_DEADLINE_MS, null);
|
|
8821
8949
|
}
|
|
8822
8950
|
function logsCredentialMissing(headers, env) {
|
|
8823
8951
|
if (!headers)
|
|
@@ -8834,8 +8962,16 @@ function logsCredentialMissing(headers, env) {
|
|
|
8834
8962
|
function resolveLogDestinationFrom(input) {
|
|
8835
8963
|
const local = resolveLogsSetting(input.localConfig);
|
|
8836
8964
|
let effective = null;
|
|
8965
|
+
let fallbackReason;
|
|
8837
8966
|
if (input.unattended) {
|
|
8838
|
-
|
|
8967
|
+
if (local) {
|
|
8968
|
+
effective = resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig);
|
|
8969
|
+
if (effective === null && "url" in local) {
|
|
8970
|
+
fallbackReason = input.trustAnchorConfig === null ? { kind: "anchor-unreadable", intendedUrl: local.url } : { kind: "anchor-mismatch", intendedUrl: local.url };
|
|
8971
|
+
}
|
|
8972
|
+
} else {
|
|
8973
|
+
effective = resolveLogsSetting(input.trustAnchorConfig);
|
|
8974
|
+
}
|
|
8839
8975
|
} else {
|
|
8840
8976
|
effective = local;
|
|
8841
8977
|
}
|
|
@@ -8861,7 +8997,7 @@ function resolveLogDestinationFrom(input) {
|
|
|
8861
8997
|
effective = null;
|
|
8862
8998
|
}
|
|
8863
8999
|
const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
|
|
8864
|
-
return { kind: "folder", folder };
|
|
9000
|
+
return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
|
|
8865
9001
|
}
|
|
8866
9002
|
var processTrustAnchorOnce;
|
|
8867
9003
|
function processTrustAnchor() {
|
|
@@ -9240,6 +9376,10 @@ function createLogSink(overrides = {}) {
|
|
|
9240
9376
|
`);
|
|
9241
9377
|
return;
|
|
9242
9378
|
}
|
|
9379
|
+
if (resolvedDestination.kind === "folder" && resolvedDestination.fallbackReason) {
|
|
9380
|
+
warnOnce(`vinaya: ${describeFolderFallback(resolvedDestination.fallbackReason)}
|
|
9381
|
+
`);
|
|
9382
|
+
}
|
|
9243
9383
|
const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
|
|
9244
9384
|
const header = buildHeader({
|
|
9245
9385
|
now,
|
|
@@ -9317,6 +9457,8 @@ function emitCheckError(error) {
|
|
|
9317
9457
|
var activeChecks = new Map;
|
|
9318
9458
|
|
|
9319
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}`);
|
|
9320
9462
|
var INFORMATIONAL_DISPATCH_BLOCKER_CLASSES = new Set([
|
|
9321
9463
|
"depends-on-not-merged",
|
|
9322
9464
|
"conflicts-with"
|
|
@@ -9353,7 +9495,7 @@ function parseChangedLineRanges(diffOutput) {
|
|
|
9353
9495
|
function fileDiffAgainst(ref, path) {
|
|
9354
9496
|
let out;
|
|
9355
9497
|
try {
|
|
9356
|
-
out =
|
|
9498
|
+
out = execFileSync7("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
9357
9499
|
encoding: "utf8",
|
|
9358
9500
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9359
9501
|
}).trim();
|
|
@@ -9364,7 +9506,7 @@ function fileDiffAgainst(ref, path) {
|
|
|
9364
9506
|
}
|
|
9365
9507
|
function revParse(ref) {
|
|
9366
9508
|
try {
|
|
9367
|
-
return
|
|
9509
|
+
return execFileSync7("git", ["rev-parse", "--verify", ref], {
|
|
9368
9510
|
encoding: "utf8",
|
|
9369
9511
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9370
9512
|
}).trim();
|
|
@@ -9374,7 +9516,7 @@ function revParse(ref) {
|
|
|
9374
9516
|
}
|
|
9375
9517
|
function repoRoot() {
|
|
9376
9518
|
try {
|
|
9377
|
-
return
|
|
9519
|
+
return execFileSync7("git", ["rev-parse", "--show-toplevel"], {
|
|
9378
9520
|
encoding: "utf8",
|
|
9379
9521
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9380
9522
|
}).trim();
|
|
@@ -9385,7 +9527,7 @@ function repoRoot() {
|
|
|
9385
9527
|
function changedFiles(base) {
|
|
9386
9528
|
let out;
|
|
9387
9529
|
try {
|
|
9388
|
-
out =
|
|
9530
|
+
out = execFileSync7("git", ["diff", "--name-only", `${base}...HEAD`], {
|
|
9389
9531
|
encoding: "utf8",
|
|
9390
9532
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9391
9533
|
}).trim();
|
|
@@ -9445,7 +9587,7 @@ function findingsInThisDiff(findings) {
|
|
|
9445
9587
|
var CHECK_NAME = "doc-coverage";
|
|
9446
9588
|
function git2(args) {
|
|
9447
9589
|
try {
|
|
9448
|
-
return
|
|
9590
|
+
return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
9449
9591
|
} catch {
|
|
9450
9592
|
return "";
|
|
9451
9593
|
}
|
|
@@ -9468,7 +9610,7 @@ function resolvePrBody() {
|
|
|
9468
9610
|
}
|
|
9469
9611
|
function fetchPrLabels(prNumber) {
|
|
9470
9612
|
try {
|
|
9471
|
-
const out =
|
|
9613
|
+
const out = execFileSync8("gh", ["pr", "view", String(prNumber), "--json", "labels"], {
|
|
9472
9614
|
encoding: "utf8",
|
|
9473
9615
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9474
9616
|
});
|
|
@@ -9479,7 +9621,7 @@ function fetchPrLabels(prNumber) {
|
|
|
9479
9621
|
}
|
|
9480
9622
|
function fetchWaiverLabelActor(prNumber, label) {
|
|
9481
9623
|
try {
|
|
9482
|
-
const out =
|
|
9624
|
+
const out = execFileSync8("gh", ["api", `repos/{owner}/{repo}/issues/${prNumber}/timeline`, "--paginate"], {
|
|
9483
9625
|
encoding: "utf8",
|
|
9484
9626
|
stdio: ["ignore", "pipe", "pipe"]
|
|
9485
9627
|
});
|