@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
|
@@ -2464,16 +2464,42 @@ function blockingSeverities(scale, threshold) {
|
|
|
2464
2464
|
}
|
|
2465
2465
|
return scale.slice(0, idx + 1);
|
|
2466
2466
|
}
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2467
|
+
var DEFERRAL_REASON_TEXT = {
|
|
2468
|
+
"unchanged-line": "unchanged line",
|
|
2469
|
+
"outside-surface": "outside the Surface"
|
|
2470
|
+
};
|
|
2471
|
+
var SECURITY_HIGH_AND_ABOVE = blockingSeverities(SECURITY_SEVERITY_ORDER, "HIGH");
|
|
2472
|
+
function classifyFinding(finding, scale, threshold, context = {}) {
|
|
2473
|
+
if (!scale.includes(finding.severity)) {
|
|
2474
|
+
throw new Error(`classifyFinding: severity "${finding.severity}" is not one of ${scale.join(" > ")}`);
|
|
2475
|
+
}
|
|
2476
|
+
const location = finding.location;
|
|
2477
|
+
const effectiveSeverity = location !== undefined && isProseLocation(location) ? PROSE_CAP_SEVERITY : finding.severity;
|
|
2478
|
+
const wouldBlock = blockingSeverities(scale, threshold).includes(effectiveSeverity);
|
|
2479
|
+
if (!wouldBlock)
|
|
2480
|
+
return { outcome: "non_blocking", deferralReason: null };
|
|
2481
|
+
const hasLocation = location !== undefined && location.length > 0;
|
|
2482
|
+
if (hasLocation && context.inSurface && !context.inSurface(location)) {
|
|
2483
|
+
return { outcome: "deferred", deferralReason: "outside-surface" };
|
|
2484
|
+
}
|
|
2485
|
+
if (hasLocation && context.changedLine && !SECURITY_HIGH_AND_ABOVE.includes(effectiveSeverity)) {
|
|
2486
|
+
if (!context.changedLine(location)) {
|
|
2487
|
+
return { outcome: "deferred", deferralReason: "unchanged-line" };
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
return { outcome: "blocking", deferralReason: null };
|
|
2491
|
+
}
|
|
2492
|
+
function evaluateReviewFindings(findings, scale, threshold, context = {}) {
|
|
2493
|
+
const blockingFindings = [];
|
|
2494
|
+
const deferredFindings = [];
|
|
2495
|
+
for (const f of findings) {
|
|
2496
|
+
const c = classifyFinding(f, scale, threshold, context);
|
|
2497
|
+
if (c.outcome === "blocking")
|
|
2498
|
+
blockingFindings.push(f);
|
|
2499
|
+
else if (c.outcome === "deferred")
|
|
2500
|
+
deferredFindings.push({ finding: f, reason: c.deferralReason });
|
|
2501
|
+
}
|
|
2502
|
+
return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings, deferredFindings };
|
|
2477
2503
|
}
|
|
2478
2504
|
function isConsequentialFinding(finding) {
|
|
2479
2505
|
return finding.state !== "resolved";
|
|
@@ -2481,11 +2507,11 @@ function isConsequentialFinding(finding) {
|
|
|
2481
2507
|
function consequentialFindings(findings) {
|
|
2482
2508
|
return findings.filter((f) => isConsequentialFinding(f));
|
|
2483
2509
|
}
|
|
2484
|
-
function evaluateCodeReview(findings, policy) {
|
|
2485
|
-
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
|
|
2510
|
+
function evaluateCodeReview(findings, policy, context = {}) {
|
|
2511
|
+
return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold, context);
|
|
2486
2512
|
}
|
|
2487
|
-
function evaluateSecurityReview(findings, policy) {
|
|
2488
|
-
return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold);
|
|
2513
|
+
function evaluateSecurityReview(findings, policy, context = {}) {
|
|
2514
|
+
return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold, context);
|
|
2489
2515
|
}
|
|
2490
2516
|
function isKnownSeverity(scale, value) {
|
|
2491
2517
|
return scale.includes(value);
|
|
@@ -3399,1511 +3425,1548 @@ function checkPrReportDensity(prBody) {
|
|
|
3399
3425
|
const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
|
|
3400
3426
|
return { errors: results.flatMap((r) => r.errors) };
|
|
3401
3427
|
}
|
|
3402
|
-
// ../../packages/aeg-core/src/
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
{ name: "Sizing", pattern: "Sizing" },
|
|
3410
|
-
{ name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
|
|
3411
|
-
{ name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
|
|
3412
|
-
{ name: "Traps to avoid", pattern: "Traps" },
|
|
3413
|
-
{ name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
|
|
3414
|
-
{ name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
|
|
3415
|
-
{ name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
|
|
3428
|
+
// ../../packages/aeg-core/src/reader-resolvable-prose.ts
|
|
3429
|
+
var PRODUCT_SLUG_SCOPE = [
|
|
3430
|
+
"apps/cli/src",
|
|
3431
|
+
".github/workflows",
|
|
3432
|
+
".vinaya",
|
|
3433
|
+
"apps/cli/README.md",
|
|
3434
|
+
"packages/sources/README.md"
|
|
3416
3435
|
];
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
const errors = [];
|
|
3420
|
-
for (const f of RATIONALE_FIELDS) {
|
|
3421
|
-
if (!hasRationaleField(body, f.pattern)) {
|
|
3422
|
-
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).`);
|
|
3423
|
-
continue;
|
|
3424
|
-
}
|
|
3425
|
-
if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
|
|
3426
|
-
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.");
|
|
3427
|
-
}
|
|
3428
|
-
}
|
|
3429
|
-
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3430
|
-
}
|
|
3431
|
-
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3432
|
-
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3433
|
-
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3434
|
-
return { status: "pass", errors: [] };
|
|
3435
|
-
const result = objectivesOf(body);
|
|
3436
|
-
if (result.ok)
|
|
3437
|
-
return { status: "pass", errors: [] };
|
|
3438
|
-
return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
|
|
3436
|
+
function isUnderOrEqual(path, prefix) {
|
|
3437
|
+
return path === prefix || path.startsWith(`${prefix}/`);
|
|
3439
3438
|
}
|
|
3440
|
-
function
|
|
3441
|
-
|
|
3442
|
-
const heading = headingRe.exec(body);
|
|
3443
|
-
if (!heading)
|
|
3444
|
-
return null;
|
|
3445
|
-
const afterHeading = body.slice(heading.index + heading[0].length);
|
|
3446
|
-
const next = /^##[ \t]/m.exec(afterHeading);
|
|
3447
|
-
return next ? afterHeading.slice(0, next.index) : afterHeading;
|
|
3439
|
+
function isProductScopeFile(path) {
|
|
3440
|
+
return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
|
|
3448
3441
|
}
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
const start = text.indexOf("`", i);
|
|
3453
|
-
if (start === -1)
|
|
3454
|
-
return false;
|
|
3455
|
-
const end = text.indexOf("`", start + 1);
|
|
3456
|
-
if (end === -1)
|
|
3457
|
-
return false;
|
|
3458
|
-
if (text.slice(start + 1, end).includes("/"))
|
|
3459
|
-
return true;
|
|
3460
|
-
i = end + 1;
|
|
3461
|
-
}
|
|
3462
|
-
return false;
|
|
3442
|
+
var SHIPS_PREFIX = "aeg-root/";
|
|
3443
|
+
function shipsArchivePrefix(shipsPrefix) {
|
|
3444
|
+
return `${shipsPrefix}tranches/completed/`;
|
|
3463
3445
|
}
|
|
3464
|
-
var
|
|
3465
|
-
function
|
|
3466
|
-
|
|
3446
|
+
var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
|
|
3447
|
+
function normalizeSpecPath(entry) {
|
|
3448
|
+
let out = entry.replace(/\\/g, "/");
|
|
3449
|
+
while (out.startsWith("./"))
|
|
3450
|
+
out = out.slice(2);
|
|
3451
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
3452
|
+
while (out.endsWith("/"))
|
|
3453
|
+
out = out.slice(0, -1);
|
|
3454
|
+
return out;
|
|
3467
3455
|
}
|
|
3468
|
-
function
|
|
3469
|
-
|
|
3456
|
+
function isSpecFile2(path, specPaths) {
|
|
3457
|
+
if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
|
|
3458
|
+
return true;
|
|
3459
|
+
if (!path.endsWith(".md"))
|
|
3460
|
+
return false;
|
|
3461
|
+
return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
|
|
3470
3462
|
}
|
|
3471
|
-
function
|
|
3472
|
-
|
|
3473
|
-
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3474
|
-
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3475
|
-
return extMatch !== null && extMatch.index > 0;
|
|
3463
|
+
function isClaudeMdFile(path) {
|
|
3464
|
+
return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
|
|
3476
3465
|
}
|
|
3477
|
-
function
|
|
3478
|
-
|
|
3466
|
+
function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
|
|
3467
|
+
if (path.startsWith(shipsPrefix)) {
|
|
3468
|
+
return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
|
|
3469
|
+
}
|
|
3470
|
+
if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
|
|
3471
|
+
return "reader-facing";
|
|
3472
|
+
}
|
|
3473
|
+
if (isClaudeMdFile(path))
|
|
3474
|
+
return "internal";
|
|
3475
|
+
if (isSpecFile2(path, specPaths))
|
|
3476
|
+
return "spec";
|
|
3477
|
+
if (isProductScopeFile(path))
|
|
3478
|
+
return "product";
|
|
3479
|
+
return null;
|
|
3479
3480
|
}
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
if (
|
|
3483
|
-
return
|
|
3484
|
-
const inLine = /^in:\s*(.+)$/im.exec(section);
|
|
3485
|
-
const outLine = /^out:\s*(.+)$/im.exec(section);
|
|
3486
|
-
const errors = [];
|
|
3487
|
-
if (!inLine)
|
|
3488
|
-
errors.push("`## Surface` has no `in:` line.");
|
|
3489
|
-
if (!outLine)
|
|
3490
|
-
errors.push("`## Surface` has no `out:` line.");
|
|
3491
|
-
if (errors.length > 0)
|
|
3492
|
-
return { ok: false, errors };
|
|
3493
|
-
const inGlobs = splitGlobList(inLine[1]);
|
|
3494
|
-
const outGlobs = splitGlobList(outLine[1]);
|
|
3495
|
-
for (const g of [...inGlobs, ...outGlobs]) {
|
|
3496
|
-
if (looksLikeFilePath(g)) {
|
|
3497
|
-
errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
|
|
3498
|
-
}
|
|
3481
|
+
var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
3482
|
+
function stripNonProse(path, content) {
|
|
3483
|
+
if (path.endsWith(".md")) {
|
|
3484
|
+
return content.replace(/```.*?```/gs, (m) => m.replace(/[^\n]/g, "")).replace(/`[^`\n]*`/g, (m) => m.replace(/[^\n]/g, ""));
|
|
3499
3485
|
}
|
|
3500
|
-
if (
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
return { ok: true, value: { in: inGlobs, out: outGlobs } };
|
|
3486
|
+
if (path.endsWith(".tsx") || path.endsWith(".ts")) {
|
|
3487
|
+
return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
|
|
3488
|
+
}
|
|
3489
|
+
return content;
|
|
3505
3490
|
}
|
|
3506
|
-
function
|
|
3507
|
-
|
|
3508
|
-
const p = path.replace(/\/+$/, "");
|
|
3509
|
-
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
3491
|
+
function stripNonProseForProduct(path, content) {
|
|
3492
|
+
return path.endsWith(".md") ? stripNonProse(path, content) : content;
|
|
3510
3493
|
}
|
|
3511
|
-
function
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
for (const glob of surface.value.in) {
|
|
3517
|
-
if (!resolvesToFile(glob)) {
|
|
3518
|
-
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.`);
|
|
3519
|
-
}
|
|
3494
|
+
function lineAt(content, index) {
|
|
3495
|
+
let line = 1;
|
|
3496
|
+
for (let i = 0;i < index; i++) {
|
|
3497
|
+
if (content.charCodeAt(i) === 10)
|
|
3498
|
+
line++;
|
|
3520
3499
|
}
|
|
3521
|
-
return
|
|
3500
|
+
return line;
|
|
3522
3501
|
}
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
}
|
|
3532
|
-
return violations.length > 0 ? { ok: false, violations } : { ok: true };
|
|
3502
|
+
var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
|
|
3503
|
+
var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
|
|
3504
|
+
var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
|
|
3505
|
+
function legacySlugPattern(legacySlugs) {
|
|
3506
|
+
if (legacySlugs.length === 0)
|
|
3507
|
+
return null;
|
|
3508
|
+
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
3509
|
+
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
3533
3510
|
}
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
const
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3511
|
+
function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
3512
|
+
const findings = [];
|
|
3513
|
+
const legacyPattern = legacySlugPattern(legacySlugs);
|
|
3514
|
+
const grandfathered = new Set(specGrandfather);
|
|
3515
|
+
const patterns = [
|
|
3516
|
+
{ pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
|
|
3517
|
+
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
|
|
3518
|
+
...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
|
|
3519
|
+
];
|
|
3520
|
+
const productPatterns = [
|
|
3521
|
+
{ pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
|
|
3522
|
+
];
|
|
3523
|
+
const specPatterns = [
|
|
3524
|
+
...patterns,
|
|
3525
|
+
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
3526
|
+
];
|
|
3527
|
+
for (const file of files) {
|
|
3528
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
3529
|
+
if (!cls || cls === "internal")
|
|
3546
3530
|
continue;
|
|
3547
|
-
|
|
3548
|
-
const n = Number.parseInt(m[1], 10);
|
|
3549
|
-
const refs = m[2];
|
|
3550
|
-
const text = m[3].trim();
|
|
3551
|
-
if (text.length === 0) {
|
|
3552
|
-
errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
|
|
3531
|
+
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
3553
3532
|
continue;
|
|
3554
|
-
|
|
3555
|
-
if (partHasBacktickedPath(text) && partWordCount(stripPartBackticks(text)) < PART_MIN_WORDS_OUTSIDE_BACKTICKS) {
|
|
3556
|
-
errors.push(`Part ${n} is little more than a file path — a Part names an outcome and symbols, never a bare path.`);
|
|
3533
|
+
if (cls === "spec" && grandfathered.has(file.path))
|
|
3557
3534
|
continue;
|
|
3535
|
+
const blocking = cls === "product" || cls === "spec";
|
|
3536
|
+
const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
|
|
3537
|
+
const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
|
|
3538
|
+
for (const { pattern, what, group } of patternsToRun) {
|
|
3539
|
+
pattern.lastIndex = 0;
|
|
3540
|
+
let match = pattern.exec(scrubbed);
|
|
3541
|
+
while (match !== null) {
|
|
3542
|
+
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
3543
|
+
const citedIndex = match.index + match[0].indexOf(cited);
|
|
3544
|
+
findings.push({
|
|
3545
|
+
file: file.path,
|
|
3546
|
+
line: lineAt(scrubbed, citedIndex),
|
|
3547
|
+
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
3548
|
+
blocking
|
|
3549
|
+
});
|
|
3550
|
+
match = pattern.exec(scrubbed);
|
|
3551
|
+
}
|
|
3558
3552
|
}
|
|
3559
|
-
const objectiveIds = [...refs.matchAll(/O(\d+)/g)].map((r) => Number.parseInt(r[1], 10));
|
|
3560
|
-
parts.push({ n, objectiveIds, text });
|
|
3561
|
-
}
|
|
3562
|
-
if (parts.length === 0) {
|
|
3563
|
-
errors.push("the `## Parts` section has no well-formed `Part <n> (<refs>) — <outcome>` lines.");
|
|
3564
3553
|
}
|
|
3565
|
-
|
|
3566
|
-
return { ok: false, errors };
|
|
3567
|
-
return { ok: true, value: parts };
|
|
3568
|
-
}
|
|
3569
|
-
function checkPartsCiteDefinedObjectives(body) {
|
|
3570
|
-
const parts = parseIssueParts(body);
|
|
3571
|
-
const objectives = objectivesOf(body);
|
|
3572
|
-
if (!parts.ok || !objectives.ok)
|
|
3573
|
-
return { status: "pass", errors: [] };
|
|
3574
|
-
const definedIds = new Set(objectives.objectives.map((o) => Number.parseInt(o.id.slice(1), 10)));
|
|
3575
|
-
const errors = [];
|
|
3576
|
-
for (const part of parts.value) {
|
|
3577
|
-
for (const objectiveId of part.objectiveIds) {
|
|
3578
|
-
if (!definedIds.has(objectiveId)) {
|
|
3579
|
-
errors.push(`issue-validation Parts: Part ${part.n} cites O${objectiveId}, which the Issue's own \`## Objectives\` section does not define.`);
|
|
3580
|
-
}
|
|
3581
|
-
}
|
|
3582
|
-
}
|
|
3583
|
-
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3584
|
-
}
|
|
3585
|
-
function isTaskIssueLabelSet(labels) {
|
|
3586
|
-
return hasLabel("tranche", labels);
|
|
3587
|
-
}
|
|
3588
|
-
function checkTrancheLabelPresence(_body, _labels) {
|
|
3589
|
-
return { status: "pass", errors: [] };
|
|
3590
|
-
}
|
|
3591
|
-
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
3592
|
-
if (!isTaskIssueLabelSet(labels))
|
|
3593
|
-
return { status: "pass", errors: [] };
|
|
3594
|
-
if (resolvedMilestoneTitle === null)
|
|
3595
|
-
return { status: "pass", errors: [] };
|
|
3596
|
-
if (currentMilestoneTitle === resolvedMilestoneTitle)
|
|
3597
|
-
return { status: "pass", errors: [] };
|
|
3598
|
-
return {
|
|
3599
|
-
status: "fail",
|
|
3600
|
-
errors: [
|
|
3601
|
-
`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}".`
|
|
3602
|
-
]
|
|
3603
|
-
};
|
|
3604
|
-
}
|
|
3605
|
-
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
3606
|
-
function isControlCodePoint(codePoint) {
|
|
3607
|
-
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
3608
|
-
}
|
|
3609
|
-
function isDisplayControlCodePoint(codePoint) {
|
|
3610
|
-
return codePoint >= 8203 && codePoint <= 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
|
|
3554
|
+
return findings;
|
|
3611
3555
|
}
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
const shown = values.slice(0, MESSAGE_VALUE_COUNT_MAX).map((v) => `\`${forMessage(v)}\``);
|
|
3615
|
-
const rest = values.length - shown.length;
|
|
3616
|
-
return rest > 0 ? `${shown.join(", ")} and ${rest} more` : shown.join(", ");
|
|
3556
|
+
function escapeTerm(term) {
|
|
3557
|
+
return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3617
3558
|
}
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
const
|
|
3621
|
-
|
|
3622
|
-
const codePoint = ch.codePointAt(0) ?? 0;
|
|
3623
|
-
if (isControlCodePoint(codePoint) || isDisplayControlCodePoint(codePoint))
|
|
3624
|
-
continue;
|
|
3625
|
-
kept.push(ch);
|
|
3626
|
-
}
|
|
3627
|
-
const cleaned = kept.join("").trim();
|
|
3628
|
-
if (cleaned.length === 0)
|
|
3629
|
-
return "(unprintable)";
|
|
3630
|
-
const points = Array.from(cleaned);
|
|
3631
|
-
return points.length > MESSAGE_VALUE_MAX ? `${points.slice(0, MESSAGE_VALUE_MAX).join("")}…` : cleaned;
|
|
3559
|
+
function containsWholeWord(text, term) {
|
|
3560
|
+
const escaped = escapeTerm(term);
|
|
3561
|
+
const re = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)`, "i");
|
|
3562
|
+
return re.test(text);
|
|
3632
3563
|
}
|
|
3633
|
-
function
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
const errors = [];
|
|
3642
|
-
if (field.unreadable) {
|
|
3643
|
-
return {
|
|
3644
|
-
status: "fail",
|
|
3645
|
-
errors: [
|
|
3646
|
-
`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.`
|
|
3647
|
-
]
|
|
3648
|
-
};
|
|
3649
|
-
}
|
|
3650
|
-
const unregistered = field.names.filter((p) => !known.has(p));
|
|
3651
|
-
if (unregistered.length > 0) {
|
|
3652
|
-
const caseHints = unregistered.map((p) => {
|
|
3653
|
-
const row = [...known].find((k) => k.toLowerCase() === p.toLowerCase());
|
|
3654
|
-
return row ? `\`${forMessage(p)}\` differs from the registered \`${forMessage(row)}\` only in case` : null;
|
|
3655
|
-
}).filter((h) => h !== null);
|
|
3656
|
-
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.`);
|
|
3657
|
-
}
|
|
3658
|
-
if (field.names.length === 0) {
|
|
3659
|
-
const residue = field.unparsed.length > 0 ? ` — ${residueForMessage(field.unparsed)}` : " — the field is empty";
|
|
3660
|
-
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.`);
|
|
3661
|
-
} else if (field.unparsed.length > 0) {
|
|
3662
|
-
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.`);
|
|
3564
|
+
function findWholeWordLine(content, term) {
|
|
3565
|
+
const lines = content.split(`
|
|
3566
|
+
`);
|
|
3567
|
+
let lineNo = 0;
|
|
3568
|
+
for (const line of lines) {
|
|
3569
|
+
lineNo++;
|
|
3570
|
+
if (containsWholeWord(line, term))
|
|
3571
|
+
return lineNo;
|
|
3663
3572
|
}
|
|
3664
|
-
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
3665
|
-
}
|
|
3666
|
-
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;
|
|
3667
|
-
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
3668
|
-
|
|
3669
|
-
// ../../packages/aeg-core/src/task-branch-identity.ts
|
|
3670
|
-
var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
|
|
3671
|
-
var TRANCHE_BRANCH_PATTERN = /^task\/([^/]+)\/([^/]+)$/;
|
|
3672
|
-
function parseTaskBranchIdentity(branch) {
|
|
3673
|
-
const issueMatch = ISSUE_BRANCH_PATTERN.exec(branch);
|
|
3674
|
-
if (issueMatch)
|
|
3675
|
-
return { kind: "issue", issueNumber: Number(issueMatch[1]) };
|
|
3676
|
-
const trancheMatch = TRANCHE_BRANCH_PATTERN.exec(branch);
|
|
3677
|
-
if (trancheMatch)
|
|
3678
|
-
return { kind: "tranche", tranche: trancheMatch[1], taskId: trancheMatch[2] };
|
|
3679
3573
|
return null;
|
|
3680
3574
|
}
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
3575
|
+
function definesOrLinksGlossary(content, term) {
|
|
3576
|
+
const escaped = escapeTerm(term);
|
|
3577
|
+
const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
|
|
3578
|
+
if (definesInline)
|
|
3579
|
+
return true;
|
|
3580
|
+
return /docs\/glossary|glossary\.md/i.test(content);
|
|
3688
3581
|
}
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
const
|
|
3692
|
-
|
|
3693
|
-
if (!
|
|
3694
|
-
continue;
|
|
3695
|
-
if (e.facts.stateReason === "not_planned")
|
|
3582
|
+
function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
|
|
3583
|
+
const findings = [];
|
|
3584
|
+
for (const file of files) {
|
|
3585
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3586
|
+
if (!cls || !SWEPT_CLASSES.has(cls))
|
|
3696
3587
|
continue;
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3588
|
+
const scrubbed = stripNonProse(file.path, file.content);
|
|
3589
|
+
for (const term of glossaryTerms) {
|
|
3590
|
+
const line = findWholeWordLine(scrubbed, term);
|
|
3591
|
+
if (line === null)
|
|
3700
3592
|
continue;
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3593
|
+
if (definesOrLinksGlossary(scrubbed, term))
|
|
3594
|
+
continue;
|
|
3595
|
+
findings.push({
|
|
3596
|
+
file: file.path,
|
|
3597
|
+
line,
|
|
3598
|
+
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
3599
|
+
blocking: false
|
|
3708
3600
|
});
|
|
3709
3601
|
}
|
|
3710
3602
|
}
|
|
3711
|
-
|
|
3712
|
-
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
3713
|
-
return {
|
|
3714
|
-
check: "A1",
|
|
3715
|
-
status,
|
|
3716
|
-
failures,
|
|
3717
|
-
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
3718
|
-
};
|
|
3603
|
+
return findings;
|
|
3719
3604
|
}
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3605
|
+
var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g;
|
|
3606
|
+
var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g;
|
|
3607
|
+
function extractComments(path, content) {
|
|
3608
|
+
if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
|
|
3609
|
+
return content.replace(/[^\n]/g, "");
|
|
3610
|
+
let state = "code";
|
|
3611
|
+
let out = "";
|
|
3612
|
+
const n = content.length;
|
|
3613
|
+
let i = 0;
|
|
3614
|
+
const blank = (ch) => ch === `
|
|
3615
|
+
` ? `
|
|
3616
|
+
` : " ";
|
|
3617
|
+
while (i < n) {
|
|
3618
|
+
const c = content[i];
|
|
3619
|
+
const next = i + 1 < n ? content[i + 1] : "";
|
|
3620
|
+
if (state === "code") {
|
|
3621
|
+
if (c === "/" && next === "/") {
|
|
3622
|
+
state = "line-comment";
|
|
3623
|
+
out += c;
|
|
3624
|
+
i++;
|
|
3625
|
+
continue;
|
|
3626
|
+
}
|
|
3627
|
+
if (c === "/" && next === "*") {
|
|
3628
|
+
state = "block-comment";
|
|
3629
|
+
out += c;
|
|
3630
|
+
i++;
|
|
3631
|
+
continue;
|
|
3632
|
+
}
|
|
3633
|
+
if (c === "'") {
|
|
3634
|
+
state = "single-quote";
|
|
3635
|
+
out += blank(c);
|
|
3636
|
+
i++;
|
|
3637
|
+
continue;
|
|
3638
|
+
}
|
|
3639
|
+
if (c === '"') {
|
|
3640
|
+
state = "double-quote";
|
|
3641
|
+
out += blank(c);
|
|
3642
|
+
i++;
|
|
3643
|
+
continue;
|
|
3644
|
+
}
|
|
3645
|
+
if (c === "`") {
|
|
3646
|
+
state = "template";
|
|
3647
|
+
out += blank(c);
|
|
3648
|
+
i++;
|
|
3649
|
+
continue;
|
|
3650
|
+
}
|
|
3651
|
+
out += blank(c);
|
|
3652
|
+
i++;
|
|
3724
3653
|
continue;
|
|
3725
|
-
if (e.facts.prState === "merged" && e.facts.issueState !== "closed") {
|
|
3726
|
-
failures.push({
|
|
3727
|
-
code: "auto-close-misfire",
|
|
3728
|
-
issue: e.task.issue,
|
|
3729
|
-
tranche: e.trancheSlug,
|
|
3730
|
-
task: e.task.id,
|
|
3731
|
-
reason: "Closing PR is merged but Issue is still open (GitHub auto-close misfire)",
|
|
3732
|
-
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
3733
|
-
});
|
|
3734
3654
|
}
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
};
|
|
3744
|
-
}
|
|
3745
|
-
function checkT1(entries) {
|
|
3746
|
-
const failures = [];
|
|
3747
|
-
for (const e of entries) {
|
|
3748
|
-
if (e.task.issue === null)
|
|
3749
|
-
continue;
|
|
3750
|
-
if (e.facts === undefined) {
|
|
3751
|
-
failures.push({
|
|
3752
|
-
code: "phantom-issue-ref",
|
|
3753
|
-
issue: e.task.issue,
|
|
3754
|
-
tranche: e.trancheSlug,
|
|
3755
|
-
task: e.task.id,
|
|
3756
|
-
reason: `Issue #${e.task.issue} in topology does not resolve to a real GitHub Issue`
|
|
3757
|
-
});
|
|
3758
|
-
}
|
|
3759
|
-
}
|
|
3760
|
-
return { check: "T1", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
3761
|
-
}
|
|
3762
|
-
function checkT2(openIssuesBySlug, topologyIssuesBySlug, ciTrancheSlug) {
|
|
3763
|
-
const failures = [];
|
|
3764
|
-
for (const [slug, openNums] of openIssuesBySlug) {
|
|
3765
|
-
if (ciTrancheSlug && slug !== ciTrancheSlug)
|
|
3766
|
-
continue;
|
|
3767
|
-
const topologySet = topologyIssuesBySlug.get(slug) ?? new Set;
|
|
3768
|
-
for (const num of openNums) {
|
|
3769
|
-
if (!topologySet.has(num)) {
|
|
3770
|
-
failures.push({
|
|
3771
|
-
code: "orphan-task",
|
|
3772
|
-
issue: num,
|
|
3773
|
-
tranche: slug,
|
|
3774
|
-
reason: `Issue #${num} is open and labeled ${trancheLabel(slug)} but does not appear in the topology file`
|
|
3775
|
-
});
|
|
3655
|
+
if (state === "line-comment") {
|
|
3656
|
+
if (c === `
|
|
3657
|
+
`) {
|
|
3658
|
+
state = "code";
|
|
3659
|
+
out += `
|
|
3660
|
+
`;
|
|
3661
|
+
i++;
|
|
3662
|
+
continue;
|
|
3776
3663
|
}
|
|
3664
|
+
out += c;
|
|
3665
|
+
i++;
|
|
3666
|
+
continue;
|
|
3777
3667
|
}
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
...result,
|
|
3786
|
-
status: "info",
|
|
3787
|
-
note: result.note ?? "T2 findings are non-blocking outside plan PRs (point-of-power principle) — see aeg-root/enforcement.md."
|
|
3788
|
-
};
|
|
3789
|
-
}
|
|
3790
|
-
function checkT3(entries, ciTrancheSlug, enrichedEntries, forgeUnavailableSlugs) {
|
|
3791
|
-
const preEnforcement = new Set;
|
|
3792
|
-
if (enrichedEntries) {
|
|
3793
|
-
for (const e of enrichedEntries) {
|
|
3794
|
-
if (isGrandfathered(e.facts?.closedAt) || isGrandfathered(e.facts?.mergedAt)) {
|
|
3795
|
-
preEnforcement.add(e.trancheSlug);
|
|
3668
|
+
if (state === "block-comment") {
|
|
3669
|
+
if (c === "*" && next === "/") {
|
|
3670
|
+
out += c;
|
|
3671
|
+
out += next;
|
|
3672
|
+
state = "code";
|
|
3673
|
+
i += 2;
|
|
3674
|
+
continue;
|
|
3796
3675
|
}
|
|
3676
|
+
out += c === `
|
|
3677
|
+
` ? `
|
|
3678
|
+
` : c;
|
|
3679
|
+
i++;
|
|
3680
|
+
continue;
|
|
3797
3681
|
}
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
if (
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
failures.push({
|
|
3806
|
-
code: "tbd-in-active-tranche",
|
|
3807
|
-
issue: null,
|
|
3808
|
-
tranche: e.trancheSlug,
|
|
3809
|
-
task: e.task.id,
|
|
3810
|
-
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`,
|
|
3811
|
-
grandfathered: true
|
|
3812
|
-
});
|
|
3813
|
-
continue;
|
|
3682
|
+
const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
|
|
3683
|
+
if (c === "\\") {
|
|
3684
|
+
out += blank(c);
|
|
3685
|
+
i++;
|
|
3686
|
+
if (i < n) {
|
|
3687
|
+
out += blank(content[i]);
|
|
3688
|
+
i++;
|
|
3814
3689
|
}
|
|
3815
|
-
|
|
3816
|
-
code: "tbd-in-active-tranche",
|
|
3817
|
-
issue: null,
|
|
3818
|
-
tranche: e.trancheSlug,
|
|
3819
|
-
task: e.task.id,
|
|
3820
|
-
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`,
|
|
3821
|
-
grandfathered: preEnforcement.has(e.trancheSlug)
|
|
3822
|
-
});
|
|
3690
|
+
continue;
|
|
3823
3691
|
}
|
|
3692
|
+
if (c === closer) {
|
|
3693
|
+
state = "code";
|
|
3694
|
+
out += blank(c);
|
|
3695
|
+
i++;
|
|
3696
|
+
continue;
|
|
3697
|
+
}
|
|
3698
|
+
out += blank(c);
|
|
3699
|
+
i++;
|
|
3824
3700
|
}
|
|
3825
|
-
|
|
3826
|
-
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
3827
|
-
return {
|
|
3828
|
-
check: "T3",
|
|
3829
|
-
status,
|
|
3830
|
-
failures,
|
|
3831
|
-
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
3832
|
-
};
|
|
3701
|
+
return out;
|
|
3833
3702
|
}
|
|
3834
|
-
function
|
|
3835
|
-
const
|
|
3836
|
-
|
|
3837
|
-
|
|
3703
|
+
function checkSourceComments(files, allowlist = []) {
|
|
3704
|
+
const findings = [];
|
|
3705
|
+
const allowed = new Set(allowlist);
|
|
3706
|
+
const patterns = [
|
|
3707
|
+
{ pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
|
|
3708
|
+
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
3709
|
+
];
|
|
3710
|
+
for (const file of files) {
|
|
3711
|
+
if (!file.path.endsWith(".ts"))
|
|
3838
3712
|
continue;
|
|
3839
|
-
if (
|
|
3713
|
+
if (allowed.has(file.path))
|
|
3840
3714
|
continue;
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
tranche: e.trancheSlug,
|
|
3852
|
-
task: e.task.id,
|
|
3853
|
-
reason: `INTERNAL: parsed a self-dependency (depends-on ${dep}) — this is a parser bug in parseRationaleDeps, not a real dependency. Please report it upstream.`
|
|
3854
|
-
});
|
|
3855
|
-
continue;
|
|
3856
|
-
}
|
|
3857
|
-
const depFacts = depEntry.facts;
|
|
3858
|
-
const depClosed = depFacts?.issueState === "closed";
|
|
3859
|
-
if (!depClosed) {
|
|
3860
|
-
failures.push({
|
|
3861
|
-
code: "dispatched-on-unmet-deps",
|
|
3862
|
-
issue: e.task.issue,
|
|
3863
|
-
tranche: e.trancheSlug,
|
|
3864
|
-
task: e.task.id,
|
|
3865
|
-
reason: `Task has open PR but depends-on ${dep} (issue #${depEntry.task.issue ?? "?"}) is not closed`
|
|
3715
|
+
const comments = extractComments(file.path, file.content);
|
|
3716
|
+
for (const { pattern, what } of patterns) {
|
|
3717
|
+
pattern.lastIndex = 0;
|
|
3718
|
+
let match = pattern.exec(comments);
|
|
3719
|
+
while (match !== null) {
|
|
3720
|
+
findings.push({
|
|
3721
|
+
file: file.path,
|
|
3722
|
+
line: lineAt(comments, match.index),
|
|
3723
|
+
message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
|
|
3724
|
+
blocking: false
|
|
3866
3725
|
});
|
|
3726
|
+
match = pattern.exec(comments);
|
|
3867
3727
|
}
|
|
3868
3728
|
}
|
|
3869
3729
|
}
|
|
3870
|
-
return
|
|
3730
|
+
return findings;
|
|
3871
3731
|
}
|
|
3872
|
-
function
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3732
|
+
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
3733
|
+
return [
|
|
3734
|
+
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
3735
|
+
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
3736
|
+
];
|
|
3877
3737
|
}
|
|
3878
|
-
function
|
|
3879
|
-
const
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
|
|
3887
|
-
...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
|
|
3888
|
-
...checkPartsCiteDefinedObjectives(issue.body).errors
|
|
3889
|
-
];
|
|
3890
|
-
if (errors.length === 0)
|
|
3891
|
-
continue;
|
|
3892
|
-
failures.push({
|
|
3893
|
-
code: "missing-rationale-field",
|
|
3894
|
-
issue: issue.number,
|
|
3895
|
-
tranche: slug,
|
|
3896
|
-
reason: `Issue #${issue.number} fails the rationale gate: ${errors.join(" | ")}`,
|
|
3897
|
-
grandfathered: grandfatheredIssues.has(issue.number)
|
|
3898
|
-
});
|
|
3899
|
-
}
|
|
3738
|
+
function parseGlossaryTerms(glossaryContent) {
|
|
3739
|
+
const terms = [];
|
|
3740
|
+
const re = /^\*\*(.+?)\*\* —/gm;
|
|
3741
|
+
let match = re.exec(glossaryContent);
|
|
3742
|
+
while (match !== null) {
|
|
3743
|
+
if (match[1] !== undefined)
|
|
3744
|
+
terms.push(match[1]);
|
|
3745
|
+
match = re.exec(glossaryContent);
|
|
3900
3746
|
}
|
|
3901
|
-
|
|
3902
|
-
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
3903
|
-
return {
|
|
3904
|
-
check: "R1",
|
|
3905
|
-
status,
|
|
3906
|
-
failures,
|
|
3907
|
-
note: status === "info" ? `${failures.length} grandfathered task Issue(s) predate this check's grammar (rationale fields and/or the project registry)` : undefined
|
|
3908
|
-
};
|
|
3747
|
+
return terms;
|
|
3909
3748
|
}
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
reason: "Active tranche has no open task-Issues — consider archiving to completed/"
|
|
3925
|
-
});
|
|
3926
|
-
}
|
|
3927
|
-
}
|
|
3928
|
-
return {
|
|
3929
|
-
check: "L1",
|
|
3930
|
-
status: "info",
|
|
3931
|
-
failures,
|
|
3932
|
-
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
3933
|
-
};
|
|
3749
|
+
|
|
3750
|
+
// ../../packages/aeg-core/src/quoted-command.ts
|
|
3751
|
+
var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
|
|
3752
|
+
var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
3753
|
+
var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
|
|
3754
|
+
var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
|
|
3755
|
+
function isValidCitedFilePath(path) {
|
|
3756
|
+
if (path.length === 0)
|
|
3757
|
+
return false;
|
|
3758
|
+
if (path.startsWith("/") || path.startsWith("\\"))
|
|
3759
|
+
return false;
|
|
3760
|
+
if (/^[A-Za-z]:[\\/]/.test(path))
|
|
3761
|
+
return false;
|
|
3762
|
+
return !path.split(/[\\/]+/).includes("..");
|
|
3934
3763
|
}
|
|
3935
|
-
function
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
failures: [],
|
|
3941
|
-
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
3942
|
-
};
|
|
3943
|
-
}
|
|
3944
|
-
function extractClosesReferences(prBody) {
|
|
3945
|
-
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
3946
|
-
const stripped = stripCode(prBody);
|
|
3947
|
-
const searchIn = anchoredRegion(stripped, "CLOSES") ?? stripped;
|
|
3948
|
-
const referenced = new Set;
|
|
3949
|
-
for (const hit of searchIn.matchAll(closesPattern)) {
|
|
3950
|
-
referenced.add(Number(hit[1]));
|
|
3764
|
+
function quotedCommandLineAt(content, index) {
|
|
3765
|
+
let line = 1;
|
|
3766
|
+
for (let i = 0;i < index; i++) {
|
|
3767
|
+
if (content.charCodeAt(i) === 10)
|
|
3768
|
+
line++;
|
|
3951
3769
|
}
|
|
3952
|
-
return
|
|
3770
|
+
return line;
|
|
3953
3771
|
}
|
|
3954
|
-
function
|
|
3955
|
-
const
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3772
|
+
function extractQuotedText(raw) {
|
|
3773
|
+
const trimmed = raw.trim();
|
|
3774
|
+
const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
|
|
3775
|
+
if (fenced)
|
|
3776
|
+
return (fenced[1] ?? "").trim();
|
|
3777
|
+
const inline = /^`([^`]+)`$/.exec(trimmed);
|
|
3778
|
+
if (inline)
|
|
3779
|
+
return (inline[1] ?? "").trim();
|
|
3780
|
+
return trimmed;
|
|
3781
|
+
}
|
|
3782
|
+
function findQuotesInFile(path, content) {
|
|
3783
|
+
const masked = maskCode(content);
|
|
3784
|
+
const quotes = [];
|
|
3785
|
+
START_PATTERN.lastIndex = 0;
|
|
3786
|
+
let start = START_PATTERN.exec(masked);
|
|
3787
|
+
while (start !== null) {
|
|
3788
|
+
const citedFile = start[1];
|
|
3789
|
+
const innerStart = start.index + start[0].length;
|
|
3790
|
+
const end = END_PATTERN.exec(masked.slice(innerStart));
|
|
3791
|
+
if (end === null) {
|
|
3792
|
+
START_PATTERN.lastIndex = innerStart;
|
|
3793
|
+
start = START_PATTERN.exec(masked);
|
|
3794
|
+
continue;
|
|
3968
3795
|
}
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
if (!referenced.has(expectedIssue)) {
|
|
3976
|
-
return {
|
|
3977
|
-
ok: false,
|
|
3978
|
-
expectedIssue,
|
|
3979
|
-
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
3980
|
-
};
|
|
3796
|
+
const innerEnd = innerStart + end.index;
|
|
3797
|
+
if (isValidCitedFilePath(citedFile)) {
|
|
3798
|
+
const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
|
|
3799
|
+
if (quotedText.length > 0) {
|
|
3800
|
+
quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
|
|
3801
|
+
}
|
|
3981
3802
|
}
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
const trancheSlug = ref.tranche;
|
|
3985
|
-
const taskId = ref.taskId;
|
|
3986
|
-
const trancheFile = trancheFiles.find((f) => f.slug === trancheSlug);
|
|
3987
|
-
if (!trancheFile) {
|
|
3988
|
-
return {
|
|
3989
|
-
ok: false,
|
|
3990
|
-
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.`
|
|
3991
|
-
};
|
|
3992
|
-
}
|
|
3993
|
-
const task = trancheFile.tranche.tasks.find((t) => t.id === taskId);
|
|
3994
|
-
if (!task) {
|
|
3995
|
-
return {
|
|
3996
|
-
ok: false,
|
|
3997
|
-
message: `closes-n: branch "${branch}" references task "${taskId}" not found in ${trancheSlug} topology. Verify the task ID matches the tranche file.`
|
|
3998
|
-
};
|
|
3803
|
+
START_PATTERN.lastIndex = innerEnd + end[0].length;
|
|
3804
|
+
start = START_PATTERN.exec(masked);
|
|
3999
3805
|
}
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
3806
|
+
return quotes;
|
|
3807
|
+
}
|
|
3808
|
+
function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
|
|
3809
|
+
const quotes = [];
|
|
3810
|
+
for (const file of files) {
|
|
3811
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3812
|
+
if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
|
|
3813
|
+
continue;
|
|
3814
|
+
quotes.push(...findQuotesInFile(file.path, file.content));
|
|
4005
3815
|
}
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
3816
|
+
return quotes;
|
|
3817
|
+
}
|
|
3818
|
+
function evaluateCitedQuotes(citedQuotes, citedFileContents) {
|
|
3819
|
+
const findings = [];
|
|
3820
|
+
for (const quote of citedQuotes) {
|
|
3821
|
+
const content = citedFileContents.get(quote.citedFile);
|
|
3822
|
+
if (content === undefined) {
|
|
3823
|
+
findings.push({
|
|
3824
|
+
file: quote.file,
|
|
3825
|
+
line: quote.line,
|
|
3826
|
+
citedFile: quote.citedFile,
|
|
3827
|
+
quotedText: quote.quotedText,
|
|
3828
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
|
|
3829
|
+
});
|
|
3830
|
+
continue;
|
|
3831
|
+
}
|
|
3832
|
+
if (!content.includes(quote.quotedText)) {
|
|
3833
|
+
findings.push({
|
|
3834
|
+
file: quote.file,
|
|
3835
|
+
line: quote.line,
|
|
3836
|
+
citedFile: quote.citedFile,
|
|
3837
|
+
quotedText: quote.quotedText,
|
|
3838
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
4013
3841
|
}
|
|
4014
|
-
return
|
|
3842
|
+
return findings;
|
|
4015
3843
|
}
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
3844
|
+
|
|
3845
|
+
// ../../packages/aeg-core/src/issue-validation.ts
|
|
3846
|
+
function hasRationaleField(body, labelPattern) {
|
|
3847
|
+
const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
|
|
3848
|
+
return re.test(body);
|
|
4019
3849
|
}
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
3850
|
+
var RATIONALE_FIELDS = [
|
|
3851
|
+
{ name: "Boundary", pattern: "Boundary" },
|
|
3852
|
+
{ name: "Sizing", pattern: "Sizing" },
|
|
3853
|
+
{ name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
|
|
3854
|
+
{ name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
|
|
3855
|
+
{ name: "Traps to avoid", pattern: "Traps" },
|
|
3856
|
+
{ name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
|
|
3857
|
+
{ name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
|
|
3858
|
+
{ name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
|
|
3859
|
+
];
|
|
3860
|
+
var DEPENDENCY_RATIONALE_FIELD_NAME = "Dependency rationale";
|
|
3861
|
+
function checkIssueRationale(body) {
|
|
3862
|
+
const errors = [];
|
|
3863
|
+
for (const f of RATIONALE_FIELDS) {
|
|
3864
|
+
if (!hasRationaleField(body, f.pattern)) {
|
|
3865
|
+
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).`);
|
|
3866
|
+
continue;
|
|
3867
|
+
}
|
|
3868
|
+
if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
|
|
3869
|
+
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.");
|
|
3870
|
+
}
|
|
4030
3871
|
}
|
|
4031
|
-
|
|
4032
|
-
if (bodyNums.length === 0)
|
|
4033
|
-
return { issue: null, extraIssues: [], outsideHeader: false };
|
|
4034
|
-
const issue = headerNums.length > 0 ? headerNums[0] : bodyNums[0];
|
|
4035
|
-
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: headerNums.length === 0 };
|
|
4036
|
-
}
|
|
4037
|
-
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4038
|
-
import { createHash as createHash4 } from "node:crypto";
|
|
4039
|
-
function briefHash(brief) {
|
|
4040
|
-
return createHash4("sha256").update(`${brief}
|
|
4041
|
-
`).digest("hex");
|
|
3872
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4042
3873
|
}
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
3874
|
+
var OBJECTIVES_SINCE_ISSUE = 404;
|
|
3875
|
+
function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
|
|
3876
|
+
if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
|
|
3877
|
+
return { status: "pass", errors: [] };
|
|
3878
|
+
const result = objectivesOf(body);
|
|
3879
|
+
if (result.ok)
|
|
3880
|
+
return { status: "pass", errors: [] };
|
|
3881
|
+
return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
|
|
4049
3882
|
}
|
|
4050
|
-
function
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
3883
|
+
function topLevelSectionText(body, headingName) {
|
|
3884
|
+
const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
|
|
3885
|
+
const heading = headingRe.exec(body);
|
|
3886
|
+
if (!heading)
|
|
3887
|
+
return null;
|
|
3888
|
+
const afterHeading = body.slice(heading.index + heading[0].length);
|
|
3889
|
+
const next = /^##[ \t]/m.exec(afterHeading);
|
|
3890
|
+
return next ? afterHeading.slice(0, next.index) : afterHeading;
|
|
4054
3891
|
}
|
|
4055
|
-
function
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
3892
|
+
function partHasBacktickedPath(text) {
|
|
3893
|
+
let i = 0;
|
|
3894
|
+
while (i < text.length) {
|
|
3895
|
+
const start = text.indexOf("`", i);
|
|
3896
|
+
if (start === -1)
|
|
3897
|
+
return false;
|
|
3898
|
+
const end = text.indexOf("`", start + 1);
|
|
3899
|
+
if (end === -1)
|
|
3900
|
+
return false;
|
|
3901
|
+
if (text.slice(start + 1, end).includes("/"))
|
|
3902
|
+
return true;
|
|
3903
|
+
i = end + 1;
|
|
3904
|
+
}
|
|
3905
|
+
return false;
|
|
4063
3906
|
}
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
if (!echoed.baseSha)
|
|
4068
|
-
return false;
|
|
4069
|
-
return currentBase.toLowerCase().startsWith(echoed.baseSha.toLowerCase());
|
|
3907
|
+
var PART_MIN_WORDS_OUTSIDE_BACKTICKS = 3;
|
|
3908
|
+
function stripPartBackticks(text) {
|
|
3909
|
+
return text.replace(/`[^`\n]*`/g, " ");
|
|
4070
3910
|
}
|
|
4071
|
-
function
|
|
4072
|
-
|
|
4073
|
-
return true;
|
|
4074
|
-
return echoed.objectivesVersion === currentVersion;
|
|
3911
|
+
function partWordCount(text) {
|
|
3912
|
+
return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
|
|
4075
3913
|
}
|
|
4076
|
-
function
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
3914
|
+
function looksLikeFilePath(entry) {
|
|
3915
|
+
const stripped = entry.replace(/\/\*\*?$/, "");
|
|
3916
|
+
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3917
|
+
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3918
|
+
return extMatch !== null && extMatch.index > 0;
|
|
4080
3919
|
}
|
|
4081
|
-
function
|
|
4082
|
-
|
|
4083
|
-
return true;
|
|
4084
|
-
return echoed.briefHash === currentHash;
|
|
3920
|
+
function splitGlobList(raw) {
|
|
3921
|
+
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
4085
3922
|
}
|
|
4086
|
-
function
|
|
4087
|
-
|
|
3923
|
+
function parseIssueSurface(body) {
|
|
3924
|
+
const section = topLevelSectionText(body, "Surface");
|
|
3925
|
+
if (section === null)
|
|
3926
|
+
return { ok: false, errors: ["no `## Surface` heading found in the body."] };
|
|
3927
|
+
const inLine = /^in:\s*(.+)$/im.exec(section);
|
|
3928
|
+
const outLine = /^out:\s*(.+)$/im.exec(section);
|
|
3929
|
+
const errors = [];
|
|
3930
|
+
if (!inLine)
|
|
3931
|
+
errors.push("`## Surface` has no `in:` line.");
|
|
3932
|
+
if (!outLine)
|
|
3933
|
+
errors.push("`## Surface` has no `out:` line.");
|
|
3934
|
+
if (errors.length > 0)
|
|
3935
|
+
return { ok: false, errors };
|
|
3936
|
+
const inGlobs = splitGlobList(inLine[1]);
|
|
3937
|
+
const outGlobs = splitGlobList(outLine[1]);
|
|
3938
|
+
for (const g of [...inGlobs, ...outGlobs]) {
|
|
3939
|
+
if (looksLikeFilePath(g)) {
|
|
3940
|
+
errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
if (inGlobs.length === 0)
|
|
3944
|
+
errors.push("`## Surface`'s `in:` line resolved to zero globs.");
|
|
3945
|
+
if (errors.length > 0)
|
|
3946
|
+
return { ok: false, errors };
|
|
3947
|
+
return { ok: true, value: { in: inGlobs, out: outGlobs } };
|
|
4088
3948
|
}
|
|
4089
|
-
function
|
|
4090
|
-
const
|
|
4091
|
-
const
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
const
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
const
|
|
3949
|
+
function globCoversPath(glob, path) {
|
|
3950
|
+
const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
|
|
3951
|
+
const p = path.replace(/\/+$/, "");
|
|
3952
|
+
if (g === "*")
|
|
3953
|
+
return !p.includes("/");
|
|
3954
|
+
return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
|
|
3955
|
+
}
|
|
3956
|
+
function checkSurfaceGlobsResolve(body, resolvesToFile) {
|
|
3957
|
+
const surface = parseIssueSurface(body);
|
|
3958
|
+
if (!surface.ok)
|
|
3959
|
+
return { status: "pass", errors: [] };
|
|
3960
|
+
const errors = [];
|
|
3961
|
+
for (const glob of surface.value.in) {
|
|
3962
|
+
if (!resolvesToFile(glob)) {
|
|
3963
|
+
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.`);
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3966
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
3967
|
+
}
|
|
3968
|
+
function checkSurfaceScope(changedFiles, outGlobs) {
|
|
3969
|
+
if (outGlobs.length === 0)
|
|
3970
|
+
return { ok: true };
|
|
3971
|
+
const violations = [];
|
|
3972
|
+
for (const file of changedFiles) {
|
|
3973
|
+
const glob = outGlobs.find((g) => globCoversPath(g, file));
|
|
3974
|
+
if (glob)
|
|
3975
|
+
violations.push({ file, glob });
|
|
3976
|
+
}
|
|
3977
|
+
return violations.length > 0 ? { ok: false, violations } : { ok: true };
|
|
3978
|
+
}
|
|
3979
|
+
var ISSUE_PART_LINE_RE = /^Part\s+(\d+)\s*\(([^)]*)\)\s*[-—–]\s*(.*)$/i;
|
|
3980
|
+
function parseIssueParts(body) {
|
|
3981
|
+
const section = topLevelSectionText(body, "Parts");
|
|
3982
|
+
if (section === null)
|
|
3983
|
+
return { ok: false, errors: ["no `## Parts` heading found in the body."] };
|
|
3984
|
+
const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
|
|
3985
|
+
const parts = [];
|
|
3986
|
+
const errors = [];
|
|
3987
|
+
for (const line of lines) {
|
|
3988
|
+
const m = ISSUE_PART_LINE_RE.exec(line);
|
|
3989
|
+
if (!m) {
|
|
3990
|
+
errors.push(`"${line}" is not a well-formed Parts line — expected \`Part <n> (<refs>) — <outcome>\`.`);
|
|
3991
|
+
continue;
|
|
3992
|
+
}
|
|
3993
|
+
const n = Number.parseInt(m[1], 10);
|
|
3994
|
+
const refs = m[2];
|
|
3995
|
+
const text = m[3].trim();
|
|
3996
|
+
if (text.length === 0) {
|
|
3997
|
+
errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
|
|
3998
|
+
continue;
|
|
3999
|
+
}
|
|
4000
|
+
if (partHasBacktickedPath(text) && partWordCount(stripPartBackticks(text)) < PART_MIN_WORDS_OUTSIDE_BACKTICKS) {
|
|
4001
|
+
errors.push(`Part ${n} is little more than a file path — a Part names an outcome and symbols, never a bare path.`);
|
|
4002
|
+
continue;
|
|
4003
|
+
}
|
|
4004
|
+
const objectiveIds = [...refs.matchAll(/O(\d+)/g)].map((r) => Number.parseInt(r[1], 10));
|
|
4005
|
+
parts.push({ n, objectiveIds, text });
|
|
4006
|
+
}
|
|
4007
|
+
if (parts.length === 0) {
|
|
4008
|
+
errors.push("the `## Parts` section has no well-formed `Part <n> (<refs>) — <outcome>` lines.");
|
|
4009
|
+
}
|
|
4010
|
+
if (errors.length > 0)
|
|
4011
|
+
return { ok: false, errors };
|
|
4012
|
+
return { ok: true, value: parts };
|
|
4013
|
+
}
|
|
4014
|
+
function checkPartsCiteDefinedObjectives(body) {
|
|
4015
|
+
const parts = parseIssueParts(body);
|
|
4016
|
+
const objectives = objectivesOf(body);
|
|
4017
|
+
if (!parts.ok || !objectives.ok)
|
|
4018
|
+
return { status: "pass", errors: [] };
|
|
4019
|
+
const definedIds = new Set(objectives.objectives.map((o) => Number.parseInt(o.id.slice(1), 10)));
|
|
4020
|
+
const errors = [];
|
|
4021
|
+
for (const part of parts.value) {
|
|
4022
|
+
for (const objectiveId of part.objectiveIds) {
|
|
4023
|
+
if (!definedIds.has(objectiveId)) {
|
|
4024
|
+
errors.push(`issue-validation Parts: Part ${part.n} cites O${objectiveId}, which the Issue's own \`## Objectives\` section does not define.`);
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
return { status: errors.length > 0 ? "fail" : "pass", errors };
|
|
4029
|
+
}
|
|
4030
|
+
function isTaskIssueLabelSet(labels) {
|
|
4031
|
+
return hasLabel("tranche", labels);
|
|
4032
|
+
}
|
|
4033
|
+
function checkTrancheLabelPresence(_body, _labels) {
|
|
4034
|
+
return { status: "pass", errors: [] };
|
|
4035
|
+
}
|
|
4036
|
+
function checkMilestoneAttach(labels, currentMilestoneTitle, resolvedMilestoneTitle) {
|
|
4037
|
+
if (!isTaskIssueLabelSet(labels))
|
|
4038
|
+
return { status: "pass", errors: [] };
|
|
4039
|
+
if (resolvedMilestoneTitle === null)
|
|
4040
|
+
return { status: "pass", errors: [] };
|
|
4041
|
+
if (currentMilestoneTitle === resolvedMilestoneTitle)
|
|
4042
|
+
return { status: "pass", errors: [] };
|
|
4101
4043
|
return {
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
objectivesVersion,
|
|
4107
|
-
rulingOrdinal,
|
|
4108
|
-
policyDigest: policyDigestBound
|
|
4044
|
+
status: "fail",
|
|
4045
|
+
errors: [
|
|
4046
|
+
`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}".`
|
|
4047
|
+
]
|
|
4109
4048
|
};
|
|
4110
4049
|
}
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
});
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4050
|
+
var TYPE_LABEL_IDS = LABELS.filter((l) => l.category === "type").map((l) => l.id);
|
|
4051
|
+
function isControlCodePoint(codePoint) {
|
|
4052
|
+
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
|
|
4053
|
+
}
|
|
4054
|
+
function isDisplayControlCodePoint(codePoint) {
|
|
4055
|
+
return codePoint >= 8203 && codePoint <= 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
|
|
4056
|
+
}
|
|
4057
|
+
var MESSAGE_VALUE_COUNT_MAX = 5;
|
|
4058
|
+
function residueForMessage(values) {
|
|
4059
|
+
const shown = values.slice(0, MESSAGE_VALUE_COUNT_MAX).map((v) => `\`${forMessage(v)}\``);
|
|
4060
|
+
const rest = values.length - shown.length;
|
|
4061
|
+
return rest > 0 ? `${shown.join(", ")} and ${rest} more` : shown.join(", ");
|
|
4062
|
+
}
|
|
4063
|
+
var MESSAGE_VALUE_MAX = 64;
|
|
4064
|
+
function forMessage(value) {
|
|
4065
|
+
const kept = [];
|
|
4066
|
+
for (const ch of value.replace(/\s+/g, " ")) {
|
|
4067
|
+
const codePoint = ch.codePointAt(0) ?? 0;
|
|
4068
|
+
if (isControlCodePoint(codePoint) || isDisplayControlCodePoint(codePoint))
|
|
4069
|
+
continue;
|
|
4070
|
+
kept.push(ch);
|
|
4127
4071
|
}
|
|
4128
|
-
const
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
const
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4072
|
+
const cleaned = kept.join("").trim();
|
|
4073
|
+
if (cleaned.length === 0)
|
|
4074
|
+
return "(unprintable)";
|
|
4075
|
+
const points = Array.from(cleaned);
|
|
4076
|
+
return points.length > MESSAGE_VALUE_MAX ? `${points.slice(0, MESSAGE_VALUE_MAX).join("")}…` : cleaned;
|
|
4077
|
+
}
|
|
4078
|
+
function checkProjectsRegistered(body, _labels, registeredNames) {
|
|
4079
|
+
if (registeredNames.length === 0)
|
|
4080
|
+
return { status: "pass", errors: [] };
|
|
4081
|
+
const field = projectFieldFromBody(body);
|
|
4082
|
+
if (!field.declared)
|
|
4083
|
+
return { status: "pass", errors: [] };
|
|
4084
|
+
const known = new Set(registeredNames.map((n) => n.trim()));
|
|
4085
|
+
const registeredList = [...registeredNames].map(forMessage).join(", ");
|
|
4086
|
+
const errors = [];
|
|
4087
|
+
if (field.unreadable) {
|
|
4140
4088
|
return {
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4089
|
+
status: "fail",
|
|
4090
|
+
errors: [
|
|
4091
|
+
`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.`
|
|
4092
|
+
]
|
|
4144
4093
|
};
|
|
4145
4094
|
}
|
|
4146
|
-
const
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
headSha: input.headSha,
|
|
4154
|
-
baseSha: input.baseSha ?? null,
|
|
4155
|
-
briefHash: input.briefHash ?? null,
|
|
4156
|
-
objectivesVersion: input.objectivesVersion,
|
|
4157
|
-
rulingOrdinal: input.rulingOrdinal,
|
|
4158
|
-
policyDigest: policyDigest(policy)
|
|
4159
|
-
};
|
|
4160
|
-
const codeReviewEchoed = {
|
|
4161
|
-
headSha: codeReview.headSha,
|
|
4162
|
-
baseSha: codeReview.baseSha,
|
|
4163
|
-
briefHash: codeReview.briefHash,
|
|
4164
|
-
objectivesVersion: codeReview.objectivesVersion,
|
|
4165
|
-
rulingOrdinal: codeReview.rulingOrdinal,
|
|
4166
|
-
policyDigest: codeReview.policyDigest
|
|
4167
|
-
};
|
|
4168
|
-
const securityEchoed = {
|
|
4169
|
-
headSha: security.headSha,
|
|
4170
|
-
baseSha: security.baseSha,
|
|
4171
|
-
briefHash: security.briefHash,
|
|
4172
|
-
objectivesVersion: security.objectivesVersion,
|
|
4173
|
-
rulingOrdinal: security.rulingOrdinal,
|
|
4174
|
-
policyDigest: security.policyDigest
|
|
4175
|
-
};
|
|
4176
|
-
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
4177
|
-
const securityBinding = compareManifest(securityEchoed, currentManifest, input.patchIdOf);
|
|
4178
|
-
const codeReviewBound = codeReviewBinding.head;
|
|
4179
|
-
const securityBound = securityBinding.head;
|
|
4180
|
-
const codeReviewObjectivesBound = codeReviewBinding.objectivesVersion;
|
|
4181
|
-
const securityObjectivesBound = securityBinding.objectivesVersion;
|
|
4182
|
-
const codeReviewRulingsBound = codeReviewBinding.rulingOrdinal;
|
|
4183
|
-
const securityRulingsBound = securityBinding.rulingOrdinal;
|
|
4184
|
-
if (codeReviewClean && codeReviewBinding.bound && securityClean && securityBinding.bound) {
|
|
4185
|
-
return {
|
|
4186
|
-
verdict: "pass",
|
|
4187
|
-
reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.`,
|
|
4188
|
-
waived: false
|
|
4189
|
-
};
|
|
4095
|
+
const unregistered = field.names.filter((p) => !known.has(p));
|
|
4096
|
+
if (unregistered.length > 0) {
|
|
4097
|
+
const caseHints = unregistered.map((p) => {
|
|
4098
|
+
const row = [...known].find((k) => k.toLowerCase() === p.toLowerCase());
|
|
4099
|
+
return row ? `\`${forMessage(p)}\` differs from the registered \`${forMessage(row)}\` only in case` : null;
|
|
4100
|
+
}).filter((h) => h !== null);
|
|
4101
|
+
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.`);
|
|
4190
4102
|
}
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
} else if (
|
|
4195
|
-
|
|
4196
|
-
} else if (!codeReviewBound) {
|
|
4197
|
-
problems.push(`the newest code-review verdict covers ${codeReview.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
|
|
4198
|
-
} else if (!codeReviewBinding.base) {
|
|
4199
|
-
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)`);
|
|
4200
|
-
} else if (!codeReviewObjectivesBound) {
|
|
4201
|
-
problems.push(`the newest code-review verdict was cast against objectives version ${codeReview.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
|
|
4202
|
-
} else if (!codeReviewRulingsBound) {
|
|
4203
|
-
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`);
|
|
4204
|
-
} else if (!codeReviewBinding.briefHash) {
|
|
4205
|
-
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"}`);
|
|
4206
|
-
} else if (!codeReviewBinding.policyDigest) {
|
|
4207
|
-
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}`);
|
|
4103
|
+
if (field.names.length === 0) {
|
|
4104
|
+
const residue = field.unparsed.length > 0 ? ` — ${residueForMessage(field.unparsed)}` : " — the field is empty";
|
|
4105
|
+
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.`);
|
|
4106
|
+
} else if (field.unparsed.length > 0) {
|
|
4107
|
+
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.`);
|
|
4208
4108
|
}
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4109
|
+
return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
|
|
4110
|
+
}
|
|
4111
|
+
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;
|
|
4112
|
+
var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
|
|
4113
|
+
var FILE_EXTENSIONS = new Set([
|
|
4114
|
+
"ts",
|
|
4115
|
+
"tsx",
|
|
4116
|
+
"js",
|
|
4117
|
+
"jsx",
|
|
4118
|
+
"mjs",
|
|
4119
|
+
"cjs",
|
|
4120
|
+
"json",
|
|
4121
|
+
"jsonc",
|
|
4122
|
+
"md",
|
|
4123
|
+
"mdx",
|
|
4124
|
+
"yml",
|
|
4125
|
+
"yaml",
|
|
4126
|
+
"txt",
|
|
4127
|
+
"sh",
|
|
4128
|
+
"lock",
|
|
4129
|
+
"toml",
|
|
4130
|
+
"ndjson",
|
|
4131
|
+
"html",
|
|
4132
|
+
"css"
|
|
4133
|
+
]);
|
|
4134
|
+
|
|
4135
|
+
// ../../packages/aeg-core/src/task-branch-identity.ts
|
|
4136
|
+
var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
|
|
4137
|
+
var TRANCHE_BRANCH_PATTERN = /^task\/([^/]+)\/([^/]+)$/;
|
|
4138
|
+
function parseTaskBranchIdentity(branch) {
|
|
4139
|
+
const issueMatch = ISSUE_BRANCH_PATTERN.exec(branch);
|
|
4140
|
+
if (issueMatch)
|
|
4141
|
+
return { kind: "issue", issueNumber: Number(issueMatch[1]) };
|
|
4142
|
+
const trancheMatch = TRANCHE_BRANCH_PATTERN.exec(branch);
|
|
4143
|
+
if (trancheMatch)
|
|
4144
|
+
return { kind: "tranche", tranche: trancheMatch[1], taskId: trancheMatch[2] };
|
|
4145
|
+
return null;
|
|
4146
|
+
}
|
|
4147
|
+
|
|
4148
|
+
// ../../packages/aeg-core/src/coherence-checks.ts
|
|
4149
|
+
var COHERENCE_ENFORCED_FROM = "2026-07-01";
|
|
4150
|
+
function isGrandfathered(isoDate) {
|
|
4151
|
+
if (!isoDate)
|
|
4152
|
+
return false;
|
|
4153
|
+
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
4154
|
+
}
|
|
4155
|
+
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
4156
|
+
function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
4157
|
+
const failures = [];
|
|
4158
|
+
for (const e of entries) {
|
|
4159
|
+
if (!e.facts)
|
|
4160
|
+
continue;
|
|
4161
|
+
if (e.facts.stateReason === "not_planned")
|
|
4162
|
+
continue;
|
|
4163
|
+
if (e.facts.issueState === "closed" && e.facts.prState !== "merged") {
|
|
4164
|
+
const handClosed = e.facts.stateReason === "completed" && isPrincipal(e.facts.closedByActor, principalAllowlist);
|
|
4165
|
+
if (handClosed)
|
|
4166
|
+
continue;
|
|
4167
|
+
failures.push({
|
|
4168
|
+
code: "closed-without-merge",
|
|
4169
|
+
issue: e.task.issue,
|
|
4170
|
+
tranche: e.trancheSlug,
|
|
4171
|
+
task: e.task.id,
|
|
4172
|
+
reason: `Issue closed but closing PR is not merged (prState: ${e.facts.prState})`,
|
|
4173
|
+
grandfathered: isGrandfathered(e.facts.closedAt)
|
|
4174
|
+
});
|
|
4175
|
+
}
|
|
4225
4176
|
}
|
|
4226
|
-
const
|
|
4177
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4178
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4227
4179
|
return {
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4180
|
+
check: "A1",
|
|
4181
|
+
status,
|
|
4182
|
+
failures,
|
|
4183
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4231
4184
|
};
|
|
4232
4185
|
}
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
}
|
|
4238
|
-
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4239
|
-
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4240
|
-
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4241
|
-
let best = 0;
|
|
4242
|
-
for (const c of comments) {
|
|
4243
|
-
if (!isPrincipal(c.author, allowlist))
|
|
4244
|
-
continue;
|
|
4245
|
-
const firstLine = (c.body.split(`
|
|
4246
|
-
`)[0] ?? "").trim();
|
|
4247
|
-
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4248
|
-
if (!m)
|
|
4186
|
+
function checkA3(entries) {
|
|
4187
|
+
const failures = [];
|
|
4188
|
+
for (const e of entries) {
|
|
4189
|
+
if (!e.facts)
|
|
4249
4190
|
continue;
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4191
|
+
if (e.facts.prState === "merged" && e.facts.issueState !== "closed") {
|
|
4192
|
+
failures.push({
|
|
4193
|
+
code: "auto-close-misfire",
|
|
4194
|
+
issue: e.task.issue,
|
|
4195
|
+
tranche: e.trancheSlug,
|
|
4196
|
+
task: e.task.id,
|
|
4197
|
+
reason: "Closing PR is merged but Issue is still open (GitHub auto-close misfire)",
|
|
4198
|
+
grandfathered: isGrandfathered(e.facts.mergedAt)
|
|
4199
|
+
});
|
|
4200
|
+
}
|
|
4253
4201
|
}
|
|
4254
|
-
|
|
4202
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4203
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4204
|
+
return {
|
|
4205
|
+
check: "A3",
|
|
4206
|
+
status,
|
|
4207
|
+
failures,
|
|
4208
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4209
|
+
};
|
|
4255
4210
|
}
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
const
|
|
4259
|
-
|
|
4211
|
+
function checkT1(entries) {
|
|
4212
|
+
const failures = [];
|
|
4213
|
+
for (const e of entries) {
|
|
4214
|
+
if (e.task.issue === null)
|
|
4215
|
+
continue;
|
|
4216
|
+
if (e.facts === undefined) {
|
|
4217
|
+
failures.push({
|
|
4218
|
+
code: "phantom-issue-ref",
|
|
4219
|
+
issue: e.task.issue,
|
|
4220
|
+
tranche: e.trancheSlug,
|
|
4221
|
+
task: e.task.id,
|
|
4222
|
+
reason: `Issue #${e.task.issue} in topology does not resolve to a real GitHub Issue`
|
|
4223
|
+
});
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
return { check: "T1", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
4260
4227
|
}
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
const
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
}
|
|
4276
|
-
const headers = splitRow(headerLine);
|
|
4277
|
-
const rows = [];
|
|
4278
|
-
let j = i + 2;
|
|
4279
|
-
while (j < lines.length && TABLE_ROW_PATTERN.test(lines[j] ?? "")) {
|
|
4280
|
-
rows.push({ cells: splitRow(lines[j] ?? ""), line: j + 1 });
|
|
4281
|
-
j++;
|
|
4228
|
+
function checkT2(openIssuesBySlug, topologyIssuesBySlug, ciTrancheSlug) {
|
|
4229
|
+
const failures = [];
|
|
4230
|
+
for (const [slug, openNums] of openIssuesBySlug) {
|
|
4231
|
+
if (ciTrancheSlug && slug !== ciTrancheSlug)
|
|
4232
|
+
continue;
|
|
4233
|
+
const topologySet = topologyIssuesBySlug.get(slug) ?? new Set;
|
|
4234
|
+
for (const num of openNums) {
|
|
4235
|
+
if (!topologySet.has(num)) {
|
|
4236
|
+
failures.push({
|
|
4237
|
+
code: "orphan-task",
|
|
4238
|
+
issue: num,
|
|
4239
|
+
tranche: slug,
|
|
4240
|
+
reason: `Issue #${num} is open and labeled ${trancheLabel(slug)} but does not appear in the topology file`
|
|
4241
|
+
});
|
|
4282
4242
|
}
|
|
4283
|
-
return { headers, rows };
|
|
4284
4243
|
}
|
|
4285
|
-
i++;
|
|
4286
4244
|
}
|
|
4287
|
-
return
|
|
4245
|
+
return { check: "T2", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
4288
4246
|
}
|
|
4289
|
-
function
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4247
|
+
function scopeT2ToPlanPr(result, isPlanPr) {
|
|
4248
|
+
if (isPlanPr || result.status !== "fail")
|
|
4249
|
+
return result;
|
|
4250
|
+
return {
|
|
4251
|
+
...result,
|
|
4252
|
+
status: "info",
|
|
4253
|
+
note: result.note ?? "T2 findings are non-blocking outside plan PRs (point-of-power principle) — see aeg-root/enforcement.md."
|
|
4254
|
+
};
|
|
4295
4255
|
}
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
];
|
|
4305
|
-
function stripBackticks2(cell) {
|
|
4306
|
-
const trimmed = cell.trim();
|
|
4307
|
-
if (trimmed.length >= 2 && trimmed.startsWith("`") && trimmed.endsWith("`")) {
|
|
4308
|
-
return trimmed.slice(1, -1);
|
|
4256
|
+
function checkT3(entries, ciTrancheSlug, enrichedEntries, forgeUnavailableSlugs) {
|
|
4257
|
+
const preEnforcement = new Set;
|
|
4258
|
+
if (enrichedEntries) {
|
|
4259
|
+
for (const e of enrichedEntries) {
|
|
4260
|
+
if (isGrandfathered(e.facts?.closedAt) || isGrandfathered(e.facts?.mergedAt)) {
|
|
4261
|
+
preEnforcement.add(e.trancheSlug);
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4309
4264
|
}
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4265
|
+
const failures = [];
|
|
4266
|
+
for (const e of entries) {
|
|
4267
|
+
if (!e.archived && e.task.issue === null) {
|
|
4268
|
+
if (ciTrancheSlug && e.trancheSlug !== ciTrancheSlug)
|
|
4269
|
+
continue;
|
|
4270
|
+
if (forgeUnavailableSlugs?.has(e.trancheSlug)) {
|
|
4271
|
+
failures.push({
|
|
4272
|
+
code: "tbd-in-active-tranche",
|
|
4273
|
+
issue: null,
|
|
4274
|
+
tranche: e.trancheSlug,
|
|
4275
|
+
task: e.task.id,
|
|
4276
|
+
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`,
|
|
4277
|
+
grandfathered: true
|
|
4278
|
+
});
|
|
4279
|
+
continue;
|
|
4280
|
+
}
|
|
4281
|
+
failures.push({
|
|
4282
|
+
code: "tbd-in-active-tranche",
|
|
4283
|
+
issue: null,
|
|
4284
|
+
tranche: e.trancheSlug,
|
|
4285
|
+
task: e.task.id,
|
|
4286
|
+
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`,
|
|
4287
|
+
grandfathered: preEnforcement.has(e.trancheSlug)
|
|
4288
|
+
});
|
|
4289
|
+
}
|
|
4290
|
+
}
|
|
4291
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4292
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4293
|
+
return {
|
|
4294
|
+
check: "T3",
|
|
4295
|
+
status,
|
|
4296
|
+
failures,
|
|
4297
|
+
note: status === "info" ? `${failures.length} grandfathered (pre-${COHERENCE_ENFORCED_FROM})` : undefined
|
|
4298
|
+
};
|
|
4314
4299
|
}
|
|
4315
|
-
function
|
|
4316
|
-
const
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
for (const { ring, pattern } of RING_HEADINGS) {
|
|
4320
|
-
const headingLine = findHeadingLine(lines, pattern);
|
|
4321
|
-
if (headingLine === null)
|
|
4300
|
+
function checkD1(entries, issueToEntry, taskToEntry) {
|
|
4301
|
+
const failures = [];
|
|
4302
|
+
for (const e of entries) {
|
|
4303
|
+
if (!e.facts)
|
|
4322
4304
|
continue;
|
|
4323
|
-
|
|
4324
|
-
if (!table)
|
|
4305
|
+
if (e.facts.prState !== "open")
|
|
4325
4306
|
continue;
|
|
4326
|
-
const
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
for (const row of table.rows) {
|
|
4330
|
-
const cells = row.cells;
|
|
4331
|
-
if (cells.length < 3)
|
|
4307
|
+
for (const dep of e.task.dependsOn) {
|
|
4308
|
+
const depEntry = resolveDepEntry(dep, e.trancheSlug, issueToEntry, taskToEntry);
|
|
4309
|
+
if (!depEntry)
|
|
4332
4310
|
continue;
|
|
4333
|
-
const
|
|
4334
|
-
const
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4311
|
+
const sameTask = depEntry.trancheSlug === e.trancheSlug && depEntry.task.id === e.task.id;
|
|
4312
|
+
const sameIssue = depEntry.task.issue !== null && e.task.issue !== null && depEntry.task.issue === e.task.issue;
|
|
4313
|
+
if (sameTask || sameIssue) {
|
|
4314
|
+
failures.push({
|
|
4315
|
+
code: "d1-self-dependency",
|
|
4316
|
+
issue: e.task.issue,
|
|
4317
|
+
tranche: e.trancheSlug,
|
|
4318
|
+
task: e.task.id,
|
|
4319
|
+
reason: `INTERNAL: parsed a self-dependency (depends-on ${dep}) — this is a parser bug in parseRationaleDeps, not a real dependency. Please report it upstream.`
|
|
4320
|
+
});
|
|
4321
|
+
continue;
|
|
4322
|
+
}
|
|
4323
|
+
const depFacts = depEntry.facts;
|
|
4324
|
+
const depClosed = depFacts?.issueState === "closed";
|
|
4325
|
+
if (!depClosed) {
|
|
4326
|
+
failures.push({
|
|
4327
|
+
code: "dispatched-on-unmet-deps",
|
|
4328
|
+
issue: e.task.issue,
|
|
4329
|
+
tranche: e.trancheSlug,
|
|
4330
|
+
task: e.task.id,
|
|
4331
|
+
reason: `Task has open PR but depends-on ${dep} (issue #${depEntry.task.issue ?? "?"}) is not closed`
|
|
4332
|
+
});
|
|
4333
|
+
}
|
|
4342
4334
|
}
|
|
4343
4335
|
}
|
|
4344
|
-
return
|
|
4336
|
+
return { check: "D1", status: failures.length > 0 ? "fail" : "pass", failures };
|
|
4337
|
+
}
|
|
4338
|
+
function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
|
|
4339
|
+
const issueMatch = dep.match(/^#(\d+)$/);
|
|
4340
|
+
if (issueMatch?.[1])
|
|
4341
|
+
return issueToEntry.get(Number(issueMatch[1]));
|
|
4342
|
+
return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
|
|
4345
4343
|
}
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
const
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4344
|
+
function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
|
|
4345
|
+
const failures = [];
|
|
4346
|
+
for (const [slug, issues] of issuesBySlug) {
|
|
4347
|
+
for (const issue of issues) {
|
|
4348
|
+
if (!isTaskIssueLabelSet(issue.labels))
|
|
4349
|
+
continue;
|
|
4350
|
+
const errors = [
|
|
4351
|
+
...checkIssueRationale(issue.body).errors,
|
|
4352
|
+
...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
|
|
4353
|
+
...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
|
|
4354
|
+
...checkPartsCiteDefinedObjectives(issue.body).errors
|
|
4355
|
+
];
|
|
4356
|
+
if (errors.length === 0)
|
|
4357
|
+
continue;
|
|
4358
|
+
failures.push({
|
|
4359
|
+
code: "missing-rationale-field",
|
|
4360
|
+
issue: issue.number,
|
|
4361
|
+
tranche: slug,
|
|
4362
|
+
reason: `Issue #${issue.number} fails the rationale gate: ${errors.join(" | ")}`,
|
|
4363
|
+
grandfathered: grandfatheredIssues.has(issue.number)
|
|
4357
4364
|
});
|
|
4358
4365
|
}
|
|
4359
4366
|
}
|
|
4360
|
-
|
|
4367
|
+
const activeFails = failures.filter((f) => !f.grandfathered);
|
|
4368
|
+
const status = activeFails.length > 0 ? "fail" : failures.length > 0 ? "info" : "pass";
|
|
4369
|
+
return {
|
|
4370
|
+
check: "R1",
|
|
4371
|
+
status,
|
|
4372
|
+
failures,
|
|
4373
|
+
note: status === "info" ? `${failures.length} grandfathered task Issue(s) predate this check's grammar (rationale fields and/or the project registry)` : undefined
|
|
4374
|
+
};
|
|
4361
4375
|
}
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
"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)`,
|
|
4367
|
-
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
4368
|
-
};
|
|
4369
|
-
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
4370
|
-
function checkG2(rows, candidateFiles) {
|
|
4371
|
-
const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
|
|
4372
|
-
const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
|
|
4373
|
-
const findings = [];
|
|
4374
|
-
for (const path of candidateFiles) {
|
|
4375
|
-
if (implementations.has(path))
|
|
4376
|
-
continue;
|
|
4377
|
-
if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
|
|
4378
|
-
continue;
|
|
4379
|
-
if (NON_GATE_HOOK_SCRIPTS.includes(path))
|
|
4380
|
-
continue;
|
|
4381
|
-
if (path in TWIN_CANDIDATE_EXCEPTIONS)
|
|
4376
|
+
function checkL1(files, entriesBySlug) {
|
|
4377
|
+
const failures = [];
|
|
4378
|
+
for (const f of files) {
|
|
4379
|
+
if (f.archived)
|
|
4382
4380
|
continue;
|
|
4383
|
-
const
|
|
4384
|
-
|
|
4381
|
+
const entries = entriesBySlug.get(f.slug) ?? [];
|
|
4382
|
+
const withFacts = entries.filter((e) => e.facts !== undefined);
|
|
4383
|
+
if (withFacts.length === 0)
|
|
4385
4384
|
continue;
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
|
|
4393
|
-
if (carriesPlaceholder) {
|
|
4394
|
-
findings.push({
|
|
4395
|
-
row: row.action,
|
|
4396
|
-
path: row.implementation,
|
|
4397
|
-
reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
|
|
4385
|
+
const allClosed = withFacts.every((e) => e.facts?.issueState === "closed");
|
|
4386
|
+
if (allClosed) {
|
|
4387
|
+
failures.push({
|
|
4388
|
+
code: "archive-recommended",
|
|
4389
|
+
tranche: f.slug,
|
|
4390
|
+
reason: "Active tranche has no open task-Issues — consider archiving to completed/"
|
|
4398
4391
|
});
|
|
4399
4392
|
}
|
|
4400
4393
|
}
|
|
4401
|
-
return {
|
|
4394
|
+
return {
|
|
4395
|
+
check: "L1",
|
|
4396
|
+
status: "info",
|
|
4397
|
+
failures,
|
|
4398
|
+
note: failures.length > 0 ? `${failures.length} active tranche(s) with no open task-Issues — consider archiving (advisory)` : undefined
|
|
4399
|
+
};
|
|
4402
4400
|
}
|
|
4403
|
-
function
|
|
4404
|
-
const
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
});
|
|
4412
|
-
}
|
|
4413
|
-
}
|
|
4414
|
-
return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4401
|
+
function checkL3(files) {
|
|
4402
|
+
const active = files.filter((f) => !f.archived);
|
|
4403
|
+
return {
|
|
4404
|
+
check: "L3",
|
|
4405
|
+
status: "info",
|
|
4406
|
+
failures: [],
|
|
4407
|
+
note: `${active.length} active tranche(s): ${active.map((f) => f.slug).join(", ") || "(none)"}`
|
|
4408
|
+
};
|
|
4415
4409
|
}
|
|
4416
|
-
function
|
|
4417
|
-
const
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
const
|
|
4422
|
-
|
|
4423
|
-
if (!resolveFn(n)) {
|
|
4424
|
-
findings.push({
|
|
4425
|
-
reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
|
|
4426
|
-
});
|
|
4427
|
-
}
|
|
4410
|
+
function extractClosesReferences(prBody) {
|
|
4411
|
+
const closesPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s{0,8}:?\s{0,8}#(\d+)/gi;
|
|
4412
|
+
const stripped = stripCode(prBody);
|
|
4413
|
+
const searchIn = anchoredRegion(stripped, "CLOSES") ?? stripped;
|
|
4414
|
+
const referenced = new Set;
|
|
4415
|
+
for (const hit of searchIn.matchAll(closesPattern)) {
|
|
4416
|
+
referenced.add(Number(hit[1]));
|
|
4428
4417
|
}
|
|
4429
|
-
return
|
|
4418
|
+
return referenced;
|
|
4430
4419
|
}
|
|
4431
|
-
function
|
|
4432
|
-
const
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
});
|
|
4420
|
+
function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
4421
|
+
const referenced = extractClosesReferences(prBody);
|
|
4422
|
+
if (taskIssueRefs) {
|
|
4423
|
+
for (const n of referenced) {
|
|
4424
|
+
const ref = taskIssueRefs.get(n);
|
|
4425
|
+
if (!ref)
|
|
4426
|
+
continue;
|
|
4427
|
+
const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
|
|
4428
|
+
if (branch !== expectedBranch) {
|
|
4429
|
+
return {
|
|
4430
|
+
ok: false,
|
|
4431
|
+
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.`
|
|
4432
|
+
};
|
|
4433
|
+
}
|
|
4446
4434
|
}
|
|
4447
4435
|
}
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4436
|
+
const ref = parseTaskBranchIdentity(branch);
|
|
4437
|
+
if (!ref)
|
|
4438
|
+
return { ok: true };
|
|
4439
|
+
if (ref.kind === "issue") {
|
|
4440
|
+
const expectedIssue = ref.issueNumber;
|
|
4441
|
+
if (!referenced.has(expectedIssue)) {
|
|
4442
|
+
return {
|
|
4443
|
+
ok: false,
|
|
4444
|
+
expectedIssue,
|
|
4445
|
+
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
4446
|
+
};
|
|
4454
4447
|
}
|
|
4448
|
+
return { ok: true, expectedIssue };
|
|
4455
4449
|
}
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
}
|
|
4464
|
-
function claimedCheckNames(implementation) {
|
|
4465
|
-
if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
|
|
4466
|
-
return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
|
|
4450
|
+
const trancheSlug = ref.tranche;
|
|
4451
|
+
const taskId = ref.taskId;
|
|
4452
|
+
const trancheFile = trancheFiles.find((f) => f.slug === trancheSlug);
|
|
4453
|
+
if (!trancheFile) {
|
|
4454
|
+
return {
|
|
4455
|
+
ok: false,
|
|
4456
|
+
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.`
|
|
4457
|
+
};
|
|
4467
4458
|
}
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4459
|
+
const task = trancheFile.tranche.tasks.find((t) => t.id === taskId);
|
|
4460
|
+
if (!task) {
|
|
4461
|
+
return {
|
|
4462
|
+
ok: false,
|
|
4463
|
+
message: `closes-n: branch "${branch}" references task "${taskId}" not found in ${trancheSlug} topology. Verify the task ID matches the tranche file.`
|
|
4464
|
+
};
|
|
4473
4465
|
}
|
|
4474
|
-
|
|
4466
|
+
if (task.issue === null) {
|
|
4467
|
+
return {
|
|
4468
|
+
ok: false,
|
|
4469
|
+
message: `closes-n: task "${taskId}" in "${trancheSlug}" has no Issue number (#TBD). The Planner must cut the Issue before this PR can be validated.`
|
|
4470
|
+
};
|
|
4471
|
+
}
|
|
4472
|
+
const expectedIssue = task.issue;
|
|
4473
|
+
if (!referenced.has(expectedIssue)) {
|
|
4474
|
+
return {
|
|
4475
|
+
ok: false,
|
|
4476
|
+
expectedIssue,
|
|
4477
|
+
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.`
|
|
4478
|
+
};
|
|
4479
|
+
}
|
|
4480
|
+
return { ok: true, expectedIssue };
|
|
4475
4481
|
}
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
}
|
|
4488
|
-
|
|
4482
|
+
// ../../packages/aeg-core/src/archive-task.ts
|
|
4483
|
+
function closesRefs(text) {
|
|
4484
|
+
return [...new Set([...text.matchAll(/Closes #(\d+)/gi)].map((m) => Number(m[1])))];
|
|
4485
|
+
}
|
|
4486
|
+
function extractIssue(body) {
|
|
4487
|
+
const stripped = stripCode(body);
|
|
4488
|
+
const bodyNums = closesRefs(stripped);
|
|
4489
|
+
const anchored = anchoredRegion(stripped, "CLOSES");
|
|
4490
|
+
if (anchored !== null) {
|
|
4491
|
+
const anchorNums = closesRefs(anchored);
|
|
4492
|
+
if (anchorNums.length === 0)
|
|
4493
|
+
return { issue: null, extraIssues: bodyNums, outsideHeader: false };
|
|
4494
|
+
const issue = anchorNums[0];
|
|
4495
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
|
|
4489
4496
|
}
|
|
4490
|
-
|
|
4497
|
+
const headerNums = closesRefs(headerRegion(stripped));
|
|
4498
|
+
if (bodyNums.length === 0)
|
|
4499
|
+
return { issue: null, extraIssues: [], outsideHeader: false };
|
|
4500
|
+
const issue = headerNums.length > 0 ? headerNums[0] : bodyNums[0];
|
|
4501
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: headerNums.length === 0 };
|
|
4491
4502
|
}
|
|
4492
|
-
// ../../packages/aeg-core/src/
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
".
|
|
4496
|
-
|
|
4497
|
-
"apps/cli/README.md",
|
|
4498
|
-
"packages/sources/README.md"
|
|
4499
|
-
];
|
|
4500
|
-
function isUnderOrEqual(path, prefix) {
|
|
4501
|
-
return path === prefix || path.startsWith(`${prefix}/`);
|
|
4503
|
+
// ../../packages/aeg-core/src/review-input-manifest.ts
|
|
4504
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
4505
|
+
function briefHash(brief) {
|
|
4506
|
+
return createHash4("sha256").update(`${brief}
|
|
4507
|
+
`).digest("hex");
|
|
4502
4508
|
}
|
|
4503
|
-
function
|
|
4504
|
-
return
|
|
4509
|
+
function policyDigest(policy) {
|
|
4510
|
+
return createHash4("sha256").update(JSON.stringify({
|
|
4511
|
+
codeReviewThreshold: policy.codeReviewThreshold,
|
|
4512
|
+
securityThreshold: policy.securityThreshold,
|
|
4513
|
+
maxRounds: policy.maxRounds
|
|
4514
|
+
})).digest("hex");
|
|
4505
4515
|
}
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4516
|
+
function isBoundToHead(echoed, headSha) {
|
|
4517
|
+
if (!echoed.headSha)
|
|
4518
|
+
return false;
|
|
4519
|
+
return headSha.toLowerCase().startsWith(echoed.headSha.toLowerCase());
|
|
4509
4520
|
}
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
return out;
|
|
4521
|
+
function isBoundByPatchIdentity(echoed, headSha, patchIdOf) {
|
|
4522
|
+
if (patchIdOf === undefined || !echoed.headSha)
|
|
4523
|
+
return false;
|
|
4524
|
+
const judged = patchIdOf(echoed.headSha);
|
|
4525
|
+
const current = patchIdOf(headSha);
|
|
4526
|
+
if (judged === null || current === null)
|
|
4527
|
+
return false;
|
|
4528
|
+
return judged === current;
|
|
4519
4529
|
}
|
|
4520
|
-
function
|
|
4521
|
-
if (
|
|
4530
|
+
function isBoundToBase(echoed, currentBase) {
|
|
4531
|
+
if (currentBase === null)
|
|
4522
4532
|
return true;
|
|
4523
|
-
if (!
|
|
4533
|
+
if (!echoed.baseSha)
|
|
4524
4534
|
return false;
|
|
4525
|
-
return
|
|
4535
|
+
return currentBase.toLowerCase().startsWith(echoed.baseSha.toLowerCase());
|
|
4526
4536
|
}
|
|
4527
|
-
function
|
|
4528
|
-
|
|
4537
|
+
function isBoundToObjectives(echoed, currentVersion) {
|
|
4538
|
+
if (currentVersion === null)
|
|
4539
|
+
return true;
|
|
4540
|
+
return echoed.objectivesVersion === currentVersion;
|
|
4529
4541
|
}
|
|
4530
|
-
function
|
|
4531
|
-
if (
|
|
4532
|
-
return
|
|
4542
|
+
function isBoundToRulings(echoed, currentOrdinal) {
|
|
4543
|
+
if (echoed.rulingOrdinal === null)
|
|
4544
|
+
return currentOrdinal === 0;
|
|
4545
|
+
return echoed.rulingOrdinal === currentOrdinal;
|
|
4546
|
+
}
|
|
4547
|
+
function isBoundToBriefHash(echoed, currentHash) {
|
|
4548
|
+
if (currentHash === null)
|
|
4549
|
+
return true;
|
|
4550
|
+
return echoed.briefHash === currentHash;
|
|
4551
|
+
}
|
|
4552
|
+
function isBoundToPolicy(echoed, currentDigest) {
|
|
4553
|
+
return echoed.policyDigest === currentDigest;
|
|
4554
|
+
}
|
|
4555
|
+
function compareManifest(echoed, current, patchIdOf) {
|
|
4556
|
+
const exactHead = isBoundToHead(echoed, current.headSha);
|
|
4557
|
+
const patchHead = exactHead ? false : isBoundByPatchIdentity(echoed, current.headSha, patchIdOf);
|
|
4558
|
+
const head = exactHead || patchHead;
|
|
4559
|
+
const echoedShaLen = echoed.baseSha?.length ?? 0;
|
|
4560
|
+
const currentShaLen = current.baseSha?.length ?? 0;
|
|
4561
|
+
const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
|
|
4562
|
+
const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
|
|
4563
|
+
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4564
|
+
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4565
|
+
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
4566
|
+
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4567
|
+
return {
|
|
4568
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
4569
|
+
head,
|
|
4570
|
+
base,
|
|
4571
|
+
briefHash: briefHashBound,
|
|
4572
|
+
objectivesVersion,
|
|
4573
|
+
rulingOrdinal,
|
|
4574
|
+
policyDigest: policyDigestBound
|
|
4575
|
+
};
|
|
4576
|
+
}
|
|
4577
|
+
|
|
4578
|
+
// ../../packages/aeg-core/src/review-gate.ts
|
|
4579
|
+
function renderGateDeferred(deferred) {
|
|
4580
|
+
if (deferred.length === 0)
|
|
4581
|
+
return "";
|
|
4582
|
+
const items = deferred.map((d) => {
|
|
4583
|
+
const where = d.finding.location && d.finding.location.length > 0 ? d.finding.location : "(no location)";
|
|
4584
|
+
return `${d.finding.severity} ${where} (${DEFERRAL_REASON_TEXT[d.reason]})`;
|
|
4585
|
+
}).join("; ");
|
|
4586
|
+
return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
|
|
4587
|
+
}
|
|
4588
|
+
function checkReviewGate(input) {
|
|
4589
|
+
const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
|
|
4590
|
+
const waived = isWaiverLabelActorVerified({
|
|
4591
|
+
label: WAIVER_LABEL_REVIEW,
|
|
4592
|
+
labels: input.labels,
|
|
4593
|
+
labelActor: input.waiverLabelActor,
|
|
4594
|
+
principalAllowlist
|
|
4595
|
+
});
|
|
4596
|
+
if (waived) {
|
|
4597
|
+
return {
|
|
4598
|
+
verdict: "pass",
|
|
4599
|
+
reason: `\`${WAIVER_LABEL_REVIEW}\` label is actor-verified — review requirement waived for this PR.`,
|
|
4600
|
+
waived: true
|
|
4601
|
+
};
|
|
4533
4602
|
}
|
|
4534
|
-
|
|
4535
|
-
|
|
4603
|
+
const verified = input.comments.filter((c) => isPrincipal(c.author, principalAllowlist));
|
|
4604
|
+
const ignoredCount = input.comments.filter((c) => !isPrincipal(c.author, principalAllowlist) && c.body.includes("VERDICT")).length;
|
|
4605
|
+
const verifiedBodies = verified.map((c) => c.body);
|
|
4606
|
+
const codeReview = extractCodeReviewVerdict(verifiedBodies);
|
|
4607
|
+
const security = extractSecurityReviewVerdict(verifiedBodies);
|
|
4608
|
+
const policy = input.policy ?? DEFAULT_REVIEW_POLICY;
|
|
4609
|
+
let codeReviewPolicyEvaluation;
|
|
4610
|
+
let securityPolicyEvaluation;
|
|
4611
|
+
try {
|
|
4612
|
+
codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy, input.deferralContext);
|
|
4613
|
+
securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy, input.deferralContext);
|
|
4614
|
+
} catch (err) {
|
|
4615
|
+
return {
|
|
4616
|
+
verdict: "fail",
|
|
4617
|
+
reason: `a verdict comment carries a finding severity this repository's policy does not recognize: ${err instanceof Error ? err.message : String(err)}`,
|
|
4618
|
+
waived: false
|
|
4619
|
+
};
|
|
4536
4620
|
}
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4621
|
+
const codeReviewTextClean = codeReview.value === "APPROVE";
|
|
4622
|
+
const securityTextClean = security.value === "PASS";
|
|
4623
|
+
const codeReviewPolicyClean = codeReviewPolicyEvaluation.outcome === "clean";
|
|
4624
|
+
const securityPolicyClean = securityPolicyEvaluation.outcome === "clean";
|
|
4625
|
+
const codeReviewClean = codeReviewTextClean && codeReviewPolicyClean;
|
|
4626
|
+
const securityClean = securityTextClean && securityPolicyClean;
|
|
4627
|
+
const currentManifest = {
|
|
4628
|
+
headSha: input.headSha,
|
|
4629
|
+
baseSha: input.baseSha ?? null,
|
|
4630
|
+
briefHash: input.briefHash ?? null,
|
|
4631
|
+
objectivesVersion: input.objectivesVersion,
|
|
4632
|
+
rulingOrdinal: input.rulingOrdinal,
|
|
4633
|
+
policyDigest: policyDigest(policy)
|
|
4634
|
+
};
|
|
4635
|
+
const codeReviewEchoed = {
|
|
4636
|
+
headSha: codeReview.headSha,
|
|
4637
|
+
baseSha: codeReview.baseSha,
|
|
4638
|
+
briefHash: codeReview.briefHash,
|
|
4639
|
+
objectivesVersion: codeReview.objectivesVersion,
|
|
4640
|
+
rulingOrdinal: codeReview.rulingOrdinal,
|
|
4641
|
+
policyDigest: codeReview.policyDigest
|
|
4642
|
+
};
|
|
4643
|
+
const securityEchoed = {
|
|
4644
|
+
headSha: security.headSha,
|
|
4645
|
+
baseSha: security.baseSha,
|
|
4646
|
+
briefHash: security.briefHash,
|
|
4647
|
+
objectivesVersion: security.objectivesVersion,
|
|
4648
|
+
rulingOrdinal: security.rulingOrdinal,
|
|
4649
|
+
policyDigest: security.policyDigest
|
|
4650
|
+
};
|
|
4651
|
+
const codeReviewBinding = compareManifest(codeReviewEchoed, currentManifest, input.patchIdOf);
|
|
4652
|
+
const securityBinding = compareManifest(securityEchoed, currentManifest, input.patchIdOf);
|
|
4653
|
+
const codeReviewBound = codeReviewBinding.head;
|
|
4654
|
+
const securityBound = securityBinding.head;
|
|
4655
|
+
const codeReviewObjectivesBound = codeReviewBinding.objectivesVersion;
|
|
4656
|
+
const securityObjectivesBound = securityBinding.objectivesVersion;
|
|
4657
|
+
const codeReviewRulingsBound = codeReviewBinding.rulingOrdinal;
|
|
4658
|
+
const securityRulingsBound = securityBinding.rulingOrdinal;
|
|
4659
|
+
const deferredNote = renderGateDeferred([
|
|
4660
|
+
...codeReviewPolicyEvaluation.deferredFindings,
|
|
4661
|
+
...securityPolicyEvaluation.deferredFindings
|
|
4662
|
+
]);
|
|
4663
|
+
if (codeReviewClean && codeReviewBinding.bound && securityClean && securityBinding.bound) {
|
|
4664
|
+
return {
|
|
4665
|
+
verdict: "pass",
|
|
4666
|
+
reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.${deferredNote}`,
|
|
4667
|
+
waived: false
|
|
4668
|
+
};
|
|
4549
4669
|
}
|
|
4550
|
-
|
|
4551
|
-
|
|
4670
|
+
const problems = [];
|
|
4671
|
+
if (!codeReviewTextClean) {
|
|
4672
|
+
problems.push(`code-reviewer verdict is not a clean APPROVE (found: ${codeReview.value})`);
|
|
4673
|
+
} else if (!codeReviewPolicyClean) {
|
|
4674
|
+
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`);
|
|
4675
|
+
} else if (!codeReviewBound) {
|
|
4676
|
+
problems.push(`the newest code-review verdict covers ${codeReview.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
|
|
4677
|
+
} else if (!codeReviewBinding.base) {
|
|
4678
|
+
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)`);
|
|
4679
|
+
} else if (!codeReviewObjectivesBound) {
|
|
4680
|
+
problems.push(`the newest code-review verdict was cast against objectives version ${codeReview.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
|
|
4681
|
+
} else if (!codeReviewRulingsBound) {
|
|
4682
|
+
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`);
|
|
4683
|
+
} else if (!codeReviewBinding.briefHash) {
|
|
4684
|
+
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"}`);
|
|
4685
|
+
} else if (!codeReviewBinding.policyDigest) {
|
|
4686
|
+
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}`);
|
|
4552
4687
|
}
|
|
4553
|
-
|
|
4554
|
-
}
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
}
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4688
|
+
if (!securityTextClean) {
|
|
4689
|
+
problems.push(`security-review verdict is not a clean PASS (found: ${security.value})`);
|
|
4690
|
+
} else if (!securityPolicyClean) {
|
|
4691
|
+
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`);
|
|
4692
|
+
} else if (!securityBound) {
|
|
4693
|
+
problems.push(`the newest security-review verdict covers ${security.headSha ?? "no recorded commit"}, head is ${input.headSha}`);
|
|
4694
|
+
} else if (!securityBinding.base) {
|
|
4695
|
+
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)`);
|
|
4696
|
+
} else if (!securityObjectivesBound) {
|
|
4697
|
+
problems.push(`the newest security-review verdict was cast against objectives version ${security.objectivesVersion ?? "none"}, the Issue's list is now ${input.objectivesVersion}`);
|
|
4698
|
+
} else if (!securityRulingsBound) {
|
|
4699
|
+
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`);
|
|
4700
|
+
} else if (!securityBinding.briefHash) {
|
|
4701
|
+
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"}`);
|
|
4702
|
+
} else if (!securityBinding.policyDigest) {
|
|
4703
|
+
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}`);
|
|
4563
4704
|
}
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
if (legacySlugs.length === 0)
|
|
4571
|
-
return null;
|
|
4572
|
-
const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
4573
|
-
return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
|
|
4705
|
+
const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
|
|
4706
|
+
return {
|
|
4707
|
+
verdict: "fail",
|
|
4708
|
+
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}`,
|
|
4709
|
+
waived: false
|
|
4710
|
+
};
|
|
4574
4711
|
}
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
const
|
|
4585
|
-
|
|
4586
|
-
];
|
|
4587
|
-
const specPatterns = [
|
|
4588
|
-
...patterns,
|
|
4589
|
-
{ pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
|
|
4590
|
-
];
|
|
4591
|
-
for (const file of files) {
|
|
4592
|
-
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
|
|
4593
|
-
if (!cls || cls === "internal")
|
|
4594
|
-
continue;
|
|
4595
|
-
if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
|
|
4712
|
+
var CHANGESET_RELEASE_BRANCH = "changeset-release/main";
|
|
4713
|
+
var DEFAULT_RELEASE_ACTOR = "github-actions[bot]";
|
|
4714
|
+
function isChangesetsReleasePr(branch, author, expectedAuthor) {
|
|
4715
|
+
return branch === CHANGESET_RELEASE_BRANCH && author === expectedAuthor;
|
|
4716
|
+
}
|
|
4717
|
+
// ../../packages/aeg-core/src/ruling-ordinal.ts
|
|
4718
|
+
var RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/;
|
|
4719
|
+
function newestPrincipalRulingOrdinal(comments, allowlist) {
|
|
4720
|
+
let best = 0;
|
|
4721
|
+
for (const c of comments) {
|
|
4722
|
+
if (!isPrincipal(c.author, allowlist))
|
|
4596
4723
|
continue;
|
|
4597
|
-
|
|
4724
|
+
const firstLine = (c.body.split(`
|
|
4725
|
+
`)[0] ?? "").trim();
|
|
4726
|
+
const m = RULING_MARKER_ORDINAL.exec(firstLine);
|
|
4727
|
+
if (!m)
|
|
4598
4728
|
continue;
|
|
4599
|
-
const
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
for (const { pattern, what, group } of patternsToRun) {
|
|
4603
|
-
pattern.lastIndex = 0;
|
|
4604
|
-
let match = pattern.exec(scrubbed);
|
|
4605
|
-
while (match !== null) {
|
|
4606
|
-
const cited = group !== undefined ? match[group] ?? match[0] : match[0];
|
|
4607
|
-
const citedIndex = match.index + match[0].indexOf(cited);
|
|
4608
|
-
findings.push({
|
|
4609
|
-
file: file.path,
|
|
4610
|
-
line: lineAt(scrubbed, citedIndex),
|
|
4611
|
-
message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
|
|
4612
|
-
blocking
|
|
4613
|
-
});
|
|
4614
|
-
match = pattern.exec(scrubbed);
|
|
4615
|
-
}
|
|
4616
|
-
}
|
|
4729
|
+
const k = Number.parseInt(m[1], 10);
|
|
4730
|
+
if (k > best)
|
|
4731
|
+
best = k;
|
|
4617
4732
|
}
|
|
4618
|
-
return
|
|
4619
|
-
}
|
|
4620
|
-
function escapeTerm(term) {
|
|
4621
|
-
return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4733
|
+
return best;
|
|
4622
4734
|
}
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
const
|
|
4626
|
-
return
|
|
4735
|
+
// ../../packages/aeg-core/src/markdown-table.ts
|
|
4736
|
+
function splitRow(line) {
|
|
4737
|
+
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
4738
|
+
return trimmed.split("|").map((cell) => cell.trim());
|
|
4627
4739
|
}
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
let
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
if (
|
|
4635
|
-
return
|
|
4740
|
+
var TABLE_ROW_PATTERN = /^\s*\|.*\|\s*$/;
|
|
4741
|
+
var SEPARATOR_ROW_PATTERN = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
|
|
4742
|
+
function findTable(lines, fromLine, stopAtHeading = true) {
|
|
4743
|
+
let i = fromLine - 1;
|
|
4744
|
+
while (i < lines.length) {
|
|
4745
|
+
const line = lines[i] ?? "";
|
|
4746
|
+
if (stopAtHeading && i > fromLine - 1 && /^##\s/.test(line))
|
|
4747
|
+
return null;
|
|
4748
|
+
if (TABLE_ROW_PATTERN.test(line)) {
|
|
4749
|
+
const headerLine = line;
|
|
4750
|
+
const sepLine = lines[i + 1] ?? "";
|
|
4751
|
+
if (!SEPARATOR_ROW_PATTERN.test(sepLine)) {
|
|
4752
|
+
i++;
|
|
4753
|
+
continue;
|
|
4754
|
+
}
|
|
4755
|
+
const headers = splitRow(headerLine);
|
|
4756
|
+
const rows = [];
|
|
4757
|
+
let j = i + 2;
|
|
4758
|
+
while (j < lines.length && TABLE_ROW_PATTERN.test(lines[j] ?? "")) {
|
|
4759
|
+
rows.push({ cells: splitRow(lines[j] ?? ""), line: j + 1 });
|
|
4760
|
+
j++;
|
|
4761
|
+
}
|
|
4762
|
+
return { headers, rows };
|
|
4763
|
+
}
|
|
4764
|
+
i++;
|
|
4636
4765
|
}
|
|
4637
4766
|
return null;
|
|
4638
4767
|
}
|
|
4639
|
-
function
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
return
|
|
4768
|
+
function findHeadingLine(lines, pattern) {
|
|
4769
|
+
for (let i = 0;i < lines.length; i++) {
|
|
4770
|
+
if (pattern.test(lines[i] ?? ""))
|
|
4771
|
+
return i + 1;
|
|
4772
|
+
}
|
|
4773
|
+
return null;
|
|
4645
4774
|
}
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
findings.push({
|
|
4660
|
-
file: file.path,
|
|
4661
|
-
line,
|
|
4662
|
-
message: `uses coined term "${term}" without defining it inline or linking the glossary`,
|
|
4663
|
-
blocking: false
|
|
4664
|
-
});
|
|
4665
|
-
}
|
|
4775
|
+
// ../../packages/aeg-core/src/diagram-model.ts
|
|
4776
|
+
import matter from "gray-matter";
|
|
4777
|
+
|
|
4778
|
+
// ../../packages/aeg-core/src/registry-parse.ts
|
|
4779
|
+
var RING_HEADINGS = [
|
|
4780
|
+
{ ring: "ring0", pattern: /^##\s+Ring 0\b/ },
|
|
4781
|
+
{ ring: "ring1", pattern: /^##\s+Ring 1\b/ },
|
|
4782
|
+
{ ring: "ring2", pattern: /^##\s+Ring 2\b/ }
|
|
4783
|
+
];
|
|
4784
|
+
function stripBackticks2(cell) {
|
|
4785
|
+
const trimmed = cell.trim();
|
|
4786
|
+
if (trimmed.length >= 2 && trimmed.startsWith("`") && trimmed.endsWith("`")) {
|
|
4787
|
+
return trimmed.slice(1, -1);
|
|
4666
4788
|
}
|
|
4667
|
-
return
|
|
4789
|
+
return trimmed;
|
|
4668
4790
|
}
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
const
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
` ? `
|
|
4680
|
-
` : " ";
|
|
4681
|
-
while (i < n) {
|
|
4682
|
-
const c = content[i];
|
|
4683
|
-
const next = i + 1 < n ? content[i + 1] : "";
|
|
4684
|
-
if (state === "code") {
|
|
4685
|
-
if (c === "/" && next === "/") {
|
|
4686
|
-
state = "line-comment";
|
|
4687
|
-
out += c;
|
|
4688
|
-
i++;
|
|
4689
|
-
continue;
|
|
4690
|
-
}
|
|
4691
|
-
if (c === "/" && next === "*") {
|
|
4692
|
-
state = "block-comment";
|
|
4693
|
-
out += c;
|
|
4694
|
-
i++;
|
|
4695
|
-
continue;
|
|
4696
|
-
}
|
|
4697
|
-
if (c === "'") {
|
|
4698
|
-
state = "single-quote";
|
|
4699
|
-
out += blank(c);
|
|
4700
|
-
i++;
|
|
4701
|
-
continue;
|
|
4702
|
-
}
|
|
4703
|
-
if (c === '"') {
|
|
4704
|
-
state = "double-quote";
|
|
4705
|
-
out += blank(c);
|
|
4706
|
-
i++;
|
|
4707
|
-
continue;
|
|
4708
|
-
}
|
|
4709
|
-
if (c === "`") {
|
|
4710
|
-
state = "template";
|
|
4711
|
-
out += blank(c);
|
|
4712
|
-
i++;
|
|
4713
|
-
continue;
|
|
4714
|
-
}
|
|
4715
|
-
out += blank(c);
|
|
4716
|
-
i++;
|
|
4791
|
+
function stripBold(cell) {
|
|
4792
|
+
return cell.trim().replace(/\*\*/g, "");
|
|
4793
|
+
}
|
|
4794
|
+
function parseEnforcementRegistry(content) {
|
|
4795
|
+
const lines = content.split(`
|
|
4796
|
+
`);
|
|
4797
|
+
const result = [];
|
|
4798
|
+
for (const { ring, pattern } of RING_HEADINGS) {
|
|
4799
|
+
const headingLine = findHeadingLine(lines, pattern);
|
|
4800
|
+
if (headingLine === null)
|
|
4717
4801
|
continue;
|
|
4718
|
-
|
|
4719
|
-
if (
|
|
4720
|
-
if (c === `
|
|
4721
|
-
`) {
|
|
4722
|
-
state = "code";
|
|
4723
|
-
out += `
|
|
4724
|
-
`;
|
|
4725
|
-
i++;
|
|
4726
|
-
continue;
|
|
4727
|
-
}
|
|
4728
|
-
out += c;
|
|
4729
|
-
i++;
|
|
4802
|
+
const table = findTable(lines, headingLine + 1);
|
|
4803
|
+
if (!table)
|
|
4730
4804
|
continue;
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
i += 2;
|
|
4805
|
+
const descriptionIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "description");
|
|
4806
|
+
const implementationIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "implementation");
|
|
4807
|
+
const audienceIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "audience");
|
|
4808
|
+
for (const row of table.rows) {
|
|
4809
|
+
const cells = row.cells;
|
|
4810
|
+
if (cells.length < 3)
|
|
4738
4811
|
continue;
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
out += blank(c);
|
|
4749
|
-
i++;
|
|
4750
|
-
if (i < n) {
|
|
4751
|
-
out += blank(content[i]);
|
|
4752
|
-
i++;
|
|
4753
|
-
}
|
|
4754
|
-
continue;
|
|
4812
|
+
const action = stripBold(cells[0] ?? "");
|
|
4813
|
+
const summary = stripBackticks2(cells[1] ?? "");
|
|
4814
|
+
const category = stripBackticks2(cells[2] ?? "");
|
|
4815
|
+
const implementation = stripBackticks2((implementationIndex === -1 ? cells[cells.length - 1] : cells[implementationIndex]) ?? "");
|
|
4816
|
+
const description = descriptionIndex === -1 ? undefined : stripBackticks2(cells[descriptionIndex] ?? "") || undefined;
|
|
4817
|
+
const specIndex = (audienceIndex === -1 ? cells.length - 1 : audienceIndex) - 1;
|
|
4818
|
+
const spec = specIndex >= 3 ? stripBackticks2(cells[specIndex] ?? "") || undefined : undefined;
|
|
4819
|
+
const audience = audienceIndex === -1 ? "repo-own" : stripBackticks2(cells[audienceIndex] ?? "") === "product" ? "product" : "repo-own";
|
|
4820
|
+
result.push({ ring, action, summary, category, description, spec, implementation, audience, line: row.line });
|
|
4755
4821
|
}
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4822
|
+
}
|
|
4823
|
+
return result;
|
|
4824
|
+
}
|
|
4825
|
+
// ../../packages/aeg-core/src/registry-checks.ts
|
|
4826
|
+
function checkG1(rows, existsFn) {
|
|
4827
|
+
const findings = [];
|
|
4828
|
+
for (const row of rows) {
|
|
4829
|
+
if (row.implementation === "")
|
|
4760
4830
|
continue;
|
|
4831
|
+
if (!existsFn(row.implementation)) {
|
|
4832
|
+
findings.push({
|
|
4833
|
+
row: row.action,
|
|
4834
|
+
path: row.implementation,
|
|
4835
|
+
reason: `${row.ring} row "${row.action}" names implementation "${row.implementation}", which does not exist on disk`
|
|
4836
|
+
});
|
|
4761
4837
|
}
|
|
4762
|
-
out += blank(c);
|
|
4763
|
-
i++;
|
|
4764
4838
|
}
|
|
4765
|
-
return
|
|
4839
|
+
return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4766
4840
|
}
|
|
4767
|
-
|
|
4841
|
+
var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
4842
|
+
var NON_GATE_BIN_NAMES = NON_GATE_BINS;
|
|
4843
|
+
var TWIN_CANDIDATE_EXCEPTIONS = {
|
|
4844
|
+
"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)',
|
|
4845
|
+
"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)`,
|
|
4846
|
+
"apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
|
|
4847
|
+
};
|
|
4848
|
+
var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
|
|
4849
|
+
function checkG2(rows, candidateFiles) {
|
|
4850
|
+
const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
|
|
4851
|
+
const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
|
|
4768
4852
|
const findings = [];
|
|
4769
|
-
const
|
|
4770
|
-
|
|
4771
|
-
{ pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
|
|
4772
|
-
{ pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
|
|
4773
|
-
];
|
|
4774
|
-
for (const file of files) {
|
|
4775
|
-
if (!file.path.endsWith(".ts"))
|
|
4853
|
+
for (const path of candidateFiles) {
|
|
4854
|
+
if (implementations.has(path))
|
|
4776
4855
|
continue;
|
|
4777
|
-
if (
|
|
4856
|
+
if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
|
|
4778
4857
|
continue;
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4858
|
+
if (NON_GATE_HOOK_SCRIPTS.includes(path))
|
|
4859
|
+
continue;
|
|
4860
|
+
if (path in TWIN_CANDIDATE_EXCEPTIONS)
|
|
4861
|
+
continue;
|
|
4862
|
+
const candidateNames = claimedCheckNames(path);
|
|
4863
|
+
if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
|
|
4864
|
+
continue;
|
|
4865
|
+
findings.push({
|
|
4866
|
+
path,
|
|
4867
|
+
reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
|
|
4868
|
+
});
|
|
4869
|
+
}
|
|
4870
|
+
for (const row of rows) {
|
|
4871
|
+
const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
|
|
4872
|
+
if (carriesPlaceholder) {
|
|
4873
|
+
findings.push({
|
|
4874
|
+
row: row.action,
|
|
4875
|
+
path: row.implementation,
|
|
4876
|
+
reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
|
|
4877
|
+
});
|
|
4792
4878
|
}
|
|
4793
4879
|
}
|
|
4794
|
-
return findings;
|
|
4795
|
-
}
|
|
4796
|
-
function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
|
|
4797
|
-
return [
|
|
4798
|
-
...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
|
|
4799
|
-
...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
|
|
4800
|
-
];
|
|
4880
|
+
return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4801
4881
|
}
|
|
4802
|
-
function
|
|
4803
|
-
const
|
|
4804
|
-
const
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4882
|
+
function checkG3(ring0Rows, crossingFiles) {
|
|
4883
|
+
const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
|
|
4884
|
+
const findings = [];
|
|
4885
|
+
for (const path of crossingFiles) {
|
|
4886
|
+
if (!ring0Implementations.has(path)) {
|
|
4887
|
+
findings.push({
|
|
4888
|
+
path,
|
|
4889
|
+
reason: `"${path}" makes a GitHub-crossing call but is not named by any Ring-0 row's implementation — a seventh, unlisted way into GitHub`
|
|
4890
|
+
});
|
|
4891
|
+
}
|
|
4810
4892
|
}
|
|
4811
|
-
return
|
|
4812
|
-
}
|
|
4813
|
-
|
|
4814
|
-
// ../../packages/aeg-core/src/quoted-command.ts
|
|
4815
|
-
var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
|
|
4816
|
-
var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
4817
|
-
var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
|
|
4818
|
-
var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
|
|
4819
|
-
function isValidCitedFilePath(path) {
|
|
4820
|
-
if (path.length === 0)
|
|
4821
|
-
return false;
|
|
4822
|
-
if (path.startsWith("/") || path.startsWith("\\"))
|
|
4823
|
-
return false;
|
|
4824
|
-
if (/^[A-Za-z]:[\\/]/.test(path))
|
|
4825
|
-
return false;
|
|
4826
|
-
return !path.split(/[\\/]+/).includes("..");
|
|
4893
|
+
return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4827
4894
|
}
|
|
4828
|
-
function
|
|
4829
|
-
|
|
4830
|
-
for (
|
|
4831
|
-
|
|
4832
|
-
line++;
|
|
4895
|
+
function checkG4(content, resolveFn) {
|
|
4896
|
+
const cited = new Set;
|
|
4897
|
+
for (const hit of content.matchAll(/#(\d{3,})\b/g)) {
|
|
4898
|
+
cited.add(Number(hit[1]));
|
|
4833
4899
|
}
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
return (inline[1] ?? "").trim();
|
|
4844
|
-
return trimmed;
|
|
4900
|
+
const findings = [];
|
|
4901
|
+
for (const n of cited) {
|
|
4902
|
+
if (!resolveFn(n)) {
|
|
4903
|
+
findings.push({
|
|
4904
|
+
reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
|
|
4905
|
+
});
|
|
4906
|
+
}
|
|
4907
|
+
}
|
|
4908
|
+
return { check: "G4", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4845
4909
|
}
|
|
4846
|
-
function
|
|
4847
|
-
const
|
|
4848
|
-
const
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
if (end === null) {
|
|
4856
|
-
START_PATTERN.lastIndex = innerStart;
|
|
4857
|
-
start = START_PATTERN.exec(masked);
|
|
4858
|
-
continue;
|
|
4910
|
+
function checkG5(roles, contracts) {
|
|
4911
|
+
const roleIds = new Set(roles.map((r) => r.role_id));
|
|
4912
|
+
const findings = [];
|
|
4913
|
+
for (const contract of contracts) {
|
|
4914
|
+
if (!roleIds.has(contract.producer)) {
|
|
4915
|
+
findings.push({
|
|
4916
|
+
path: contract.file,
|
|
4917
|
+
reason: `contract "${contract.file}" names producer "${contract.producer}", which is not a real role_id`
|
|
4918
|
+
});
|
|
4859
4919
|
}
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
}
|
|
4920
|
+
if (!roleIds.has(contract.consumer)) {
|
|
4921
|
+
findings.push({
|
|
4922
|
+
path: contract.file,
|
|
4923
|
+
reason: `contract "${contract.file}" names consumer "${contract.consumer}", which is not a real role_id`
|
|
4924
|
+
});
|
|
4866
4925
|
}
|
|
4867
|
-
START_PATTERN.lastIndex = innerEnd + end[0].length;
|
|
4868
|
-
start = START_PATTERN.exec(masked);
|
|
4869
4926
|
}
|
|
4870
|
-
|
|
4927
|
+
for (const role of roles) {
|
|
4928
|
+
if (role.performs.length === 0) {
|
|
4929
|
+
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty performs array` });
|
|
4930
|
+
}
|
|
4931
|
+
if (role.refuses_when.trim() === "") {
|
|
4932
|
+
findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty refuses_when` });
|
|
4933
|
+
}
|
|
4934
|
+
}
|
|
4935
|
+
return { check: "G5", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4871
4936
|
}
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4937
|
+
var SHIPPED_BIN_PATH_PREFIX = "apps/cli/src/checks/bin/check-";
|
|
4938
|
+
var AEG_CORE_BIN_PATH_PREFIX = "packages/aeg-core/bin/";
|
|
4939
|
+
function basenameNoExt(path) {
|
|
4940
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
4941
|
+
return base.replace(/\.ts$/, "");
|
|
4942
|
+
}
|
|
4943
|
+
function claimedCheckNames(implementation) {
|
|
4944
|
+
if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
|
|
4945
|
+
return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
|
|
4879
4946
|
}
|
|
4880
|
-
|
|
4947
|
+
if (implementation.startsWith(AEG_CORE_BIN_PATH_PREFIX)) {
|
|
4948
|
+
const audience = GATE_AUDIENCE[basenameNoExt(implementation)];
|
|
4949
|
+
if (audience && isShipped(audience)) {
|
|
4950
|
+
return Array.isArray(audience.shippedAs) ? audience.shippedAs : [audience.shippedAs];
|
|
4951
|
+
}
|
|
4952
|
+
}
|
|
4953
|
+
return [];
|
|
4881
4954
|
}
|
|
4882
|
-
function
|
|
4955
|
+
function checkG6(rows, registeredCheckNames) {
|
|
4883
4956
|
const findings = [];
|
|
4884
|
-
for (const
|
|
4885
|
-
|
|
4886
|
-
if (content === undefined) {
|
|
4887
|
-
findings.push({
|
|
4888
|
-
file: quote.file,
|
|
4889
|
-
line: quote.line,
|
|
4890
|
-
citedFile: quote.citedFile,
|
|
4891
|
-
quotedText: quote.quotedText,
|
|
4892
|
-
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
|
|
4893
|
-
});
|
|
4957
|
+
for (const row of rows) {
|
|
4958
|
+
if (row.audience !== "product")
|
|
4894
4959
|
continue;
|
|
4895
|
-
|
|
4896
|
-
if (!
|
|
4960
|
+
const candidates = claimedCheckNames(row.implementation);
|
|
4961
|
+
if (!candidates.some((name) => registeredCheckNames.has(name))) {
|
|
4897
4962
|
findings.push({
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
quotedText: quote.quotedText,
|
|
4902
|
-
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
|
|
4963
|
+
row: row.action,
|
|
4964
|
+
path: row.implementation,
|
|
4965
|
+
reason: `${row.ring} row "${row.action}" is marked \`product\` but its implementation "${row.implementation}" does not resolve to a coreCheckRegistry() entry`
|
|
4903
4966
|
});
|
|
4904
4967
|
}
|
|
4905
4968
|
}
|
|
4906
|
-
return findings;
|
|
4969
|
+
return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
4907
4970
|
}
|
|
4908
4971
|
// ../../packages/aeg-core/src/dead-branch-push-guard.ts
|
|
4909
4972
|
function checkDeadBranchPush(input) {
|
|
@@ -5810,7 +5873,9 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
|
|
|
5810
5873
|
"escalated",
|
|
5811
5874
|
"principal_stop",
|
|
5812
5875
|
"confidence",
|
|
5813
|
-
"reappearance"
|
|
5876
|
+
"reappearance",
|
|
5877
|
+
"repeat_finding",
|
|
5878
|
+
"repeat_failure"
|
|
5814
5879
|
])
|
|
5815
5880
|
}).strict(),
|
|
5816
5881
|
z2.object({
|
|
@@ -6314,6 +6379,10 @@ var LoopStateRecordSchema = z3.object({
|
|
|
6314
6379
|
budgets: LoopBudgetsSchema,
|
|
6315
6380
|
heldResult: roundHeadIdentity.nullable(),
|
|
6316
6381
|
deliveredFindings: roundHeadIdentity.nullable(),
|
|
6382
|
+
repeatMemory: z3.object({
|
|
6383
|
+
blockingFindings: z3.array(z3.string()),
|
|
6384
|
+
lastFailure: z3.object({ signature: z3.string(), message: z3.string() }).nullable()
|
|
6385
|
+
}).strict().optional(),
|
|
6317
6386
|
recordedAt: isoTimestamp
|
|
6318
6387
|
}).strict();
|
|
6319
6388
|
var EffectRecordSchema = z3.object({
|