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