forgedock 1.52.0 → 1.54.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/.claude-plugin/marketplace.json +51 -0
- package/README.md +8 -2
- package/bin/auth/app-manifest.mjs +89 -0
- package/bin/auth/app-manifest.test.mjs +75 -0
- package/bin/auth/app-token.mjs +256 -0
- package/bin/auth/app-token.test.mjs +232 -0
- package/bin/brand.mjs +7 -0
- package/bin/config-history.mjs +151 -0
- package/bin/config-schema.mjs +115 -0
- package/bin/demo.mjs +65 -11
- package/bin/engine/outcome-codes.mjs +9 -3
- package/bin/engine/telemetry-seam.mjs +11 -3
- package/bin/engine/telemetry-seam.test.mjs +17 -0
- package/bin/engine-cli.mjs +110 -36
- package/bin/experiment.mjs +58 -6
- package/bin/first-run.mjs +122 -0
- package/bin/forge-utils.mjs +6 -2
- package/bin/forgedock.mjs +138 -142
- package/bin/help-text.mjs +144 -0
- package/bin/hooks/pre-tool-use.mjs +7 -0
- package/bin/journey.mjs +82 -83
- package/bin/lean/acceptance.mjs +313 -0
- package/bin/lean/acceptance.test.mjs +215 -0
- package/bin/lean/account-watch.mjs +28 -0
- package/bin/lean/account-watch.test.mjs +30 -0
- package/bin/lean/activation.mjs +38 -0
- package/bin/lean/activation.test.mjs +36 -1
- package/bin/lean/basered.mjs +115 -0
- package/bin/lean/basered.test.mjs +66 -0
- package/bin/lean/batch-health.mjs +114 -7
- package/bin/lean/batch-health.test.mjs +87 -1
- package/bin/lean/batch.mjs +41 -2
- package/bin/lean/batch.test.mjs +115 -11
- package/bin/lean/branchlock.mjs +54 -0
- package/bin/lean/branchlock.test.mjs +49 -0
- package/bin/lean/ceiling.mjs +72 -0
- package/bin/lean/ceiling.test.mjs +54 -0
- package/bin/lean/checkpoint-reconcile.mjs +43 -0
- package/bin/lean/checkpoint-reconcile.test.mjs +95 -0
- package/bin/lean/ci-budget.mjs +366 -0
- package/bin/lean/ci-budget.test.mjs +167 -0
- package/bin/lean/conformance.e2e.test.mjs +8 -1
- package/bin/lean/conformance.mjs +269 -38
- package/bin/lean/conformance.test.mjs +280 -7
- package/bin/lean/context.mjs +35 -6
- package/bin/lean/context.test.mjs +27 -1
- package/bin/lean/depcache.mjs +25 -1
- package/bin/lean/depcache.test.mjs +26 -0
- package/bin/lean/e2e.mjs +18 -2
- package/bin/lean/e2e.test.mjs +26 -1
- package/bin/lean/effects.mjs +47 -14
- package/bin/lean/execution.mjs +19 -3
- package/bin/lean/execution.test.mjs +63 -0
- package/bin/lean/facts.mjs +3 -3
- package/bin/lean/facts.test.mjs +5 -0
- package/bin/lean/findinglabel.mjs +16 -0
- package/bin/lean/findinglabel.test.mjs +39 -0
- package/bin/lean/fixround.mjs +14 -0
- package/bin/lean/fixround.test.mjs +25 -2
- package/bin/lean/gh-assoc.test.mjs +2 -1
- package/bin/lean/integration.mjs +100 -9
- package/bin/lean/integration.test.mjs +98 -0
- package/bin/lean/issuewatch-parity.mjs +64 -0
- package/bin/lean/issuewatch-parity.test.mjs +127 -0
- package/bin/lean/issuewatch-release.mjs +6 -2
- package/bin/lean/issuewatch-release.test.mjs +17 -1
- package/bin/lean/issuewatch.mjs +45 -6
- package/bin/lean/issuewatch.test.mjs +3 -2
- package/bin/lean/lanelock.mjs +14 -0
- package/bin/lean/lean.mjs +473 -100
- package/bin/lean/lean.test.mjs +686 -33
- package/bin/lean/light.mjs +48 -7
- package/bin/lean/light.test.mjs +37 -3
- package/bin/lean/limits.test.mjs +142 -9
- package/bin/lean/mechfix.mjs +124 -0
- package/bin/lean/mechfix.test.mjs +75 -0
- package/bin/lean/orchestrate-cancel.test.mjs +143 -0
- package/bin/lean/orchestrate.mjs +116 -28
- package/bin/lean/phaseledger.mjs +47 -5
- package/bin/lean/phaseledger.test.mjs +30 -1
- package/bin/lean/postdeploy-check.test.mjs +39 -0
- package/bin/lean/precheck.mjs +23 -4
- package/bin/lean/precheck.test.mjs +14 -1
- package/bin/lean/prereq.mjs +28 -0
- package/bin/lean/prereq.test.mjs +20 -0
- package/bin/lean/probe.mjs +4 -2
- package/bin/lean/prodparity.mjs +52 -0
- package/bin/lean/prodparity.test.mjs +67 -0
- package/bin/lean/prompts.mjs +77 -19
- package/bin/lean/quota.mjs +39 -0
- package/bin/lean/recovery.test.mjs +11 -1
- package/bin/lean/relaxation.mjs +73 -0
- package/bin/lean/relaxation.test.mjs +54 -0
- package/bin/lean/release-io.test.mjs +42 -0
- package/bin/lean/release-postmerge.mjs +125 -0
- package/bin/lean/release-preflight.mjs +58 -0
- package/bin/lean/release-preflight.test.mjs +114 -0
- package/bin/lean/release-rehearsal.mjs +64 -0
- package/bin/lean/release-rehearsal.test.mjs +93 -0
- package/bin/lean/release-review.e2e.test.mjs +77 -0
- package/bin/lean/release-review.mjs +254 -0
- package/bin/lean/release-review.test.mjs +307 -0
- package/bin/lean/release-snapshot.mjs +188 -0
- package/bin/lean/release-snapshot.test.mjs +190 -0
- package/bin/lean/release.mjs +296 -0
- package/bin/lean/release.test.mjs +387 -0
- package/bin/lean/render.mjs +1 -1
- package/bin/lean/replan.mjs +184 -0
- package/bin/lean/replan.test.mjs +110 -0
- package/bin/lean/resume.mjs +9 -7
- package/bin/lean/resume.test.mjs +16 -0
- package/bin/lean/rotator.mjs +150 -31
- package/bin/lean/rotator.test.mjs +105 -2
- package/bin/lean/sandbox-remote.mjs +9 -2
- package/bin/lean/schedd.mjs +83 -5
- package/bin/lean/schedd.test.mjs +108 -7
- package/bin/lean/selfreview.mjs +94 -0
- package/bin/lean/selfreview.test.mjs +58 -1
- package/bin/lean/selftest-gate.mjs +22 -0
- package/bin/lean/selftest-gate.test.mjs +18 -1
- package/bin/lean/selftest-journey.mjs +234 -0
- package/bin/lean/selftest-journey.test.mjs +130 -0
- package/bin/lean/selftest-live.mjs +2 -1
- package/bin/lean/seqlease.mjs +35 -1
- package/bin/lean/seqlease.test.mjs +15 -0
- package/bin/lean/seqreserve.e2e.test.mjs +135 -0
- package/bin/lean/seqreserve.mjs +73 -0
- package/bin/lean/seqreserve.test.mjs +134 -0
- package/bin/lean/sequence.mjs +35 -6
- package/bin/lean/seqversioned.mjs +147 -0
- package/bin/lean/stagestamp.mjs +28 -0
- package/bin/lean/stagestamp.test.mjs +32 -0
- package/bin/lean/surfaces.mjs +75 -0
- package/bin/lean/surfaces.test.mjs +59 -0
- package/bin/lean/toolplace.mjs +28 -0
- package/bin/lean/toolplace.test.mjs +24 -0
- package/bin/lean/toolstats.mjs +3 -1
- package/bin/lean/toolstats.test.mjs +11 -0
- package/bin/lean/validatebest.mjs +28 -0
- package/bin/lean/validatebest.test.mjs +27 -0
- package/bin/lean/verifier.mjs +3 -2
- package/bin/lean/verify.mjs +2 -1
- package/bin/lean/verify.test.mjs +6 -0
- package/bin/pool/agent.mjs +27 -4
- package/bin/pool/docker.mjs +5 -0
- package/bin/pool/router.mjs +74 -28
- package/bin/prereqs.mjs +111 -0
- package/bin/replay-timelapse.mjs +149 -0
- package/bin/review-staging.mjs +123 -16
- package/bin/review-staging.test.mjs +18 -0
- package/bin/runner.mjs +43 -6
- package/bin/splash-install.mjs +157 -0
- package/bin/stats/aggregate.mjs +8 -1
- package/bin/stats/conformance-outcomes.mjs +289 -0
- package/bin/stats/conformance-outcomes.test.mjs +274 -0
- package/bin/stats/depth.mjs +275 -0
- package/bin/stats/depth.test.mjs +158 -0
- package/bin/stats/efficiency.mjs +26 -5
- package/bin/stats/efficiency.test.mjs +45 -1
- package/bin/stats/experiment.mjs +7 -5
- package/bin/stats/first-review.mjs +77 -0
- package/bin/stats/first-review.test.mjs +36 -0
- package/bin/stats/firstmerge.mjs +40 -0
- package/bin/stats/firstmerge.test.mjs +41 -0
- package/bin/stats/github-source.mjs +53 -15
- package/bin/stats/index.mjs +147 -9
- package/bin/stats/local-source.mjs +12 -0
- package/bin/stats/origin.mjs +80 -0
- package/bin/stats/origin.test.mjs +58 -0
- package/bin/stats/query.mjs +69 -0
- package/bin/stats/render.mjs +3 -1
- package/bin/stats/scoreboard.mjs +137 -0
- package/bin/stats/scoreboard.test.mjs +87 -0
- package/bin/stats/selffiled.mjs +52 -0
- package/bin/stats/selffiled.test.mjs +71 -0
- package/bin/stats/stats.test.mjs +80 -0
- package/bin/tui.mjs +3 -2
- package/commands/bootstrap.md +15 -14
- package/commands/deploy-pr.md +18 -3
- package/commands/forge-stats.md +1 -1
- package/commands/forgedock-ci-setup.md +28 -0
- package/commands/forgedock-init.md +4 -5
- package/commands/issue.md +2 -0
- package/commands/milestone.md +9 -1
- package/commands/orchestrate.md +1 -1
- package/commands/replay.md +2 -0
- package/commands/review-pr-agents/security.md +4 -0
- package/commands/review-pr-staging.md +6 -1
- package/commands/work-on/build.md +4 -6
- package/commands/work-on/close.md +8 -0
- package/docs/CONFIG.md +170 -18
- package/docs/ISSUE-WATCH.md +25 -0
- package/docs/OUTCOME-CODES.md +4 -0
- package/docs/REPLAY.md +9 -0
- package/docs/SELFTEST.md +11 -0
- package/docs/STATS.md +61 -0
- package/docs/TELEMETRY.md +1 -1
- package/docs/eval/README.md +6 -0
- package/docs/eval/adversarial-bench.md +68 -0
- package/docs/eval/corpus/adversarial-v1.json +285 -0
- package/docs/eval/feature-bench.md +42 -0
- package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
- package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
- package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
- package/docs/site/start-a-new-project.md +2 -1
- package/package.json +5 -2
- package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
- package/plugins/forgedock-splash/README.md +27 -0
- package/plugins/forgedock-splash/hooks/hooks.json +1 -0
- package/plugins/forgedock-splash/hooks/register.tsx +74 -0
- package/plugins/forgedock-splash/hooks/scene.ts +222 -0
- package/plugins/forgedock-splash/types/index.d.ts +10 -0
- package/pool/README.md +1 -1
- package/pool/image/cs-cred +14 -1
- package/scripts/backfill-finding-labels.mjs +50 -0
- package/scripts/backfill-finding-labels.test.mjs +36 -0
- package/scripts/bench-adversarial.mjs +216 -0
- package/scripts/bench-feature.mjs +170 -0
- package/scripts/bench-lightlane.mjs +2 -2
- package/scripts/bootstrap-create.mjs +2 -2
- package/scripts/bootstrap-validate.mjs +35 -2
- package/scripts/check-spec-size.sh +4 -3
- package/scripts/check-spec-size.test.sh +3 -0
- package/scripts/doctor-pipeline-state.sh +21 -6
- package/scripts/file-deferred-followups.sh +59 -251
- package/scripts/file-deferred-followups.test.sh +85 -206
- package/scripts/followup-route.mjs +12 -0
- package/scripts/owner-route-parity.test.sh +17 -1
- package/scripts/plan-validate-live.mjs +40 -6
- package/scripts/review-pr-side-effects.test.sh +40 -0
- package/scripts/review-pr-staging-scope.test.sh +1 -1
- package/scripts/review-staging-post.sh +23 -0
- package/scripts/review-staging-post.test.sh +8 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { describe, it } from "node:test";
|
|
5
5
|
import assert from "node:assert/strict";
|
|
6
|
-
import { removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, isBugIssue, parseReview, checkCompleteness, decide, closePlan, isInvestigation, formatShadowSummary, followupItems, inIssue, isTestPath, normalizeEvidencePath, mergeReviewRows, reviewSkeleton, missingIds, resolveEvidencePath, movingBaseDiff, scopeText, evidencePathLine, evidencePathOnly, reaskable, matchCriterion, criterionLines, fillEngineRows, explainFailures, resolveForgedockPaths, missingTool, repoTracks, tmpdirInputs, isScopeCheck, isPureScopeCheck, dropScopeValidates, tagOutOfBand, outOfBandRequirements, isOutOfBand, followupMap, renderPendingFollowups, VERIFY_MODES, OUT_OF_BAND_RE, FOLLOWUP_CLASSES, followupClass, BUCKETS, bucketKind, bucketProblems, bucketTally, isE2eCommand, e2eVerified, impliedDocDeliverables, applyValidateRecipes, deferChecklessPostDeploy, substituteShellProblem, reproEnvMiss, ORCHESTRATOR_BUCKET, ownerRoute, weakenedE2eDecisions } from "./conformance.mjs";
|
|
6
|
+
import { outputTail, removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, isBugIssue, parseReview, checkCompleteness, decide, closePlan, isInvestigation, formatShadowSummary, followupItems, inIssue, snapQuote, snapQuotes, isTestPath, normalizeEvidencePath, mergeReviewRows, reviewSkeleton, missingIds, resolveEvidencePath, movingBaseDiff, scopeText, evidencePathLine, evidencePathOnly, reaskable, matchCriterion, criterionLines, fillEngineRows, explainFailures, resolveForgedockPaths, missingTool, repoTracks, tmpdirInputs, isScopeCheck, isPureScopeCheck, dropScopeValidates, tagOutOfBand, outOfBandRequirements, isOutOfBand, followupMap, renderPendingFollowups, VERIFY_MODES, OUT_OF_BAND_RE, FOLLOWUP_CLASSES, followupClass, inLaneDeferral, pendingTracking, BUCKETS, bucketKind, bucketProblems, bucketTally, isE2eCommand, e2eVerified, impliedDocDeliverables, applyValidateRecipes, deferChecklessPostDeploy, substituteShellProblem, reproEnvMiss, ORCHESTRATOR_BUCKET, ownerRoute, weakenedE2eDecisions, guessedUvEnv, projectDirPathMiss, rewriteProjectDirCommand, convertDelivered } from "./conformance.mjs";
|
|
7
7
|
|
|
8
8
|
const ISSUE = "## Requirements\n1. The scrape route must release the spend reservation on 429.\n2. The search route must release the spend reservation on 429.\n\n- [ ] Billing pricing is unchanged.";
|
|
9
9
|
const Q1 = "The scrape route must release the spend reservation on 429.";
|
|
@@ -313,6 +313,31 @@ describe("precheck (deterministic, no reviewer)", () => {
|
|
|
313
313
|
assert.equal(missingTool({ rc: 1, output: "ModuleNotFoundError: No module named 'app'" }, { repoHas: repoTracks(["app.py"]) }), null);
|
|
314
314
|
assert.equal(missingTool({ rc: 1, output: "1 test failed: expected not found" }), null, "rc != 127 needs command not found");
|
|
315
315
|
});
|
|
316
|
+
it("#5371 substituteVerdict treats docker daemon, playwright browser and npm network failures as not runs", () => {
|
|
317
|
+
const sigs = [
|
|
318
|
+
"docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?",
|
|
319
|
+
"docker: Error response from daemon: invalid mount config for type \"bind\": bind source path does not exist: /x/infra",
|
|
320
|
+
"browserType.launch: Executable doesn't exist at /root/.cache/ms-playwright/chromium-1/chrome\nRun npx playwright install",
|
|
321
|
+
"npm ERR! code EAI_AGAIN\nnpm ERR! network request to https://registry.npmjs.org/x failed",
|
|
322
|
+
"npm error code ENOTFOUND",
|
|
323
|
+
];
|
|
324
|
+
for (const output of sigs) {
|
|
325
|
+
assert.equal(substituteVerdict({ rc: 1, output }, { command: "x" }), "ok", output);
|
|
326
|
+
assert.equal(missingTool({ rc: 1, output })?.kind, "environment", output);
|
|
327
|
+
}
|
|
328
|
+
assert.equal(substituteVerdict({ rc: 1, output: "AssertionError: expected 1 to equal 2" }, { command: "x" }), "runs");
|
|
329
|
+
});
|
|
330
|
+
it("#5371 a failed validate detail carries a redacted last-40-line output tail; an env signature is env.tool_missing", () => {
|
|
331
|
+
const C = { requirements: [], validate: [{ id: "V1", command: "bash t.sh" }], deliverables: [{ id: "D1", path: "a.mjs", change: "x" }] };
|
|
332
|
+
const failed = { validation: [{ id: "V1", exit: 1 }], requirements: [] };
|
|
333
|
+
const out = Array.from({ length: 60 }, (_, i) => `line${i}`).join("\n") + "\nGITHUB_TOKEN=ghp_abcdefghijklmnopqrstuvwxyz0123\nAuthorization: Bearer abcdefghijklmnop1234";
|
|
334
|
+
const pc = precheck({ contract: C, result: failed, changedFiles: ["a.mjs"], validateRuns: { V1: { rc: 1, output: out } } });
|
|
335
|
+
const d = pc.failures.find((f) => f.kind === "validate_failed").detail;
|
|
336
|
+
assert.match(d, /line59/); assert.doesNotMatch(d, /line5\b/); assert.doesNotMatch(d, /ghp_abcdef|abcdefghijklmnop1234/); assert.match(d, /\[redacted\]/);
|
|
337
|
+
const env = precheck({ contract: C, result: failed, changedFiles: ["a.mjs"], validateRuns: { V1: { rc: 1, output: "Cannot connect to the Docker daemon" } } });
|
|
338
|
+
assert.deepEqual(env.failures.map((f) => f.code), ["env.tool_missing"]); assert.match(env.failures[0].detail, /Cannot connect/);
|
|
339
|
+
assert.equal(outputTail(""), "");
|
|
340
|
+
});
|
|
316
341
|
it("#5005 a missing forgedock install is env.tool_missing, not conformance; other absolute paths stay code defects", () => {
|
|
317
342
|
const out = "node:internal/modules/cjs/loader\nError: Cannot find module '/opt/node/lib/node_modules/forgedock/bin/lean/checks.mjs'\n code: 'MODULE_NOT_FOUND'";
|
|
318
343
|
assert.deepEqual(missingTool({ rc: 1, output: out }), { tool: "forgedock", kind: "command" });
|
|
@@ -467,6 +492,65 @@ describe("conformance review: the engine computes the verdict from complete rows
|
|
|
467
492
|
assert.equal(validateContract({ ...C, validate: [{ id: "V4", command: ok }] }, ISSUE).ok, true, ok);
|
|
468
493
|
}
|
|
469
494
|
});
|
|
495
|
+
it("#5234 project-dir paths and pytest exit 4", () => {
|
|
496
|
+
const poetry = "poetry -C services/api run pytest -q services/api/tests/test_x.py services/api/tests/test_y.py";
|
|
497
|
+
assert.deepEqual(projectDirPathMiss(poetry), { dir: "services/api", paths: ["services/api/tests/test_x.py", "services/api/tests/test_y.py"] });
|
|
498
|
+
assert.equal(rewriteProjectDirCommand(poetry), "cd services/api && poetry run pytest -q tests/test_x.py tests/test_y.py");
|
|
499
|
+
const uv = "uv run --project services/api pytest services/api/tests/x.py -k foo";
|
|
500
|
+
assert.equal(rewriteProjectDirCommand(uv), "cd services/api && uv run pytest tests/x.py -k foo");
|
|
501
|
+
assert.equal(rewriteProjectDirCommand("poetry --directory=./services/api run pytest services/api/tests/x.py"), "cd services/api && poetry run pytest tests/x.py");
|
|
502
|
+
const mixed = "poetry -C services/api run pytest services/api/tests/x.py tests/hands_conformance";
|
|
503
|
+
assert.equal(rewriteProjectDirCommand(mixed), mixed);
|
|
504
|
+
const chained = "poetry -C services/api run pytest services/api/tests/x.py && echo ok";
|
|
505
|
+
assert.equal(rewriteProjectDirCommand(chained), chained);
|
|
506
|
+
for (const fine of ["cd services/api && poetry run pytest ../../services/api/tests/x.py", "poetry -C services/api run pytest tests/x.py", "poetry run pytest services/api/tests/x.py"]) {
|
|
507
|
+
assert.equal(projectDirPathMiss(fine), null, fine);
|
|
508
|
+
assert.equal(rewriteProjectDirCommand(fine), fine);
|
|
509
|
+
}
|
|
510
|
+
for (const cmd of [poetry, uv, mixed]) {
|
|
511
|
+
const v = validateContract({ ...C, validate: [{ id: "V1", command: cmd }] }, ISSUE);
|
|
512
|
+
assert.ok(v.problems.some((x) => x.startsWith("V1: the command moves its cwd to `services/api`")), v.problems.join("; "));
|
|
513
|
+
}
|
|
514
|
+
const rt = validateContract({ ...C, repro_test: { path: "t/x.py", command: uv } }, ISSUE, { repro: true });
|
|
515
|
+
assert.ok(rt.problems.some((x) => x.startsWith("repro_test: the command moves its cwd")), rt.problems.join("; "));
|
|
516
|
+
// pytest exit 4 is a defect of the frozen command: contract.invalid_command, and a substitute is judged ok
|
|
517
|
+
const exit4 = { rc: 4, output: "ERROR: file or directory not found: services/api/tests/x.py\n\nno tests ran in 0.01s" };
|
|
518
|
+
assert.ok(unrunnableValidate({ rc: 4, output: "ERROR: file or directory not found: services/api/tests/x.py" }));
|
|
519
|
+
assert.ok(unrunnableValidate({ rc: 4, output: "ERROR: not found: /repo/tests/x.py::t" }));
|
|
520
|
+
assert.ok(!unrunnableValidate({ rc: 1, output: "1 failed, 2 passed" }));
|
|
521
|
+
// exit 4 or 5 of a pytest command is unrunnable whatever the output says; other runners and test failures are not
|
|
522
|
+
for (const rc of [4, 5]) assert.ok(unrunnableValidate({ rc, output: "" }, "poetry run pytest -q tests/x.py"), `rc ${rc}`);
|
|
523
|
+
assert.ok(!unrunnableValidate({ rc: 4, output: "" }, "node --test x.mjs"));
|
|
524
|
+
assert.ok(!unrunnableValidate({ rc: 1, output: "1 failed" }, "pytest tests/x.py"));
|
|
525
|
+
assert.equal(substituteVerdict({ rc: 4, output: "" }, { command: poetry }), "ok");
|
|
526
|
+
assert.equal(substituteVerdict({ rc: 1, output: "1 failed" }, { command: poetry }), "runs");
|
|
527
|
+
assert.equal(substituteVerdict(exit4), "ok");
|
|
528
|
+
const contract = { requirements: [], deliverables: [], validate: [{ id: "V1", command: poetry }] };
|
|
529
|
+
const p = precheck({ contract, result: { validation: [{ id: "V1", exit: 4 }] }, changedFiles: [], validateRuns: { V1: exit4 } });
|
|
530
|
+
assert.deepEqual(p.failures.map((f) => [f.code, f.kind]), [["contract.invalid_command", "validate_command_invalid"]]);
|
|
531
|
+
});
|
|
532
|
+
it("#5232 a guessed offline uv --with environment is rejected for repro_test and validate; a requirements export passes", () => {
|
|
533
|
+
const bad = "cd w && uv run --offline --no-project --with pytest --with structlog python -m pytest -q t.py";
|
|
534
|
+
assert.equal(guessedUvEnv(bad), true);
|
|
535
|
+
assert.equal(guessedUvEnv("uv run --no-project --python 3.12 --with-requirements r.txt pytest -q t.py"), false);
|
|
536
|
+
assert.equal(guessedUvEnv("uv run --offline --no-project --with-requirements r.txt pytest"), false);
|
|
537
|
+
assert.equal(guessedUvEnv("pnpm vitest run x"), false);
|
|
538
|
+
const rt = validateContract({ ...C, repro_test: { path: "t/x.py", command: bad } }, ISSUE, { repro: true });
|
|
539
|
+
assert.ok(rt.problems.some((x) => x.startsWith("repro_test: the command builds its environment from a hand-picked")), rt.problems.join("; "));
|
|
540
|
+
const v = validateContract({ ...C, validate: [{ id: "V1", command: bad }] }, ISSUE);
|
|
541
|
+
assert.ok(v.problems.some((x) => x.startsWith("V1: the command builds its environment")), v.problems.join("; "));
|
|
542
|
+
const ok = validateContract({ ...C, repro_test: { path: "t/x.py", command: "uv run --no-project --with-requirements r.txt pytest t/x.py" } }, ISSUE, { repro: true });
|
|
543
|
+
assert.ok(!ok.problems.some((x) => /hand-picked/.test(x)));
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
it("#5230 tmpdirInputs counts venv, clone and worktree dirs as created", () => {
|
|
547
|
+
assert.deepEqual(tmpdirInputs('uv venv -q "$TMPDIR/pv" && uv pip install --offline -q --python "$TMPDIR/pv/bin/python" pytest && "$TMPDIR/pv/bin/python" -m pytest -q x'), []);
|
|
548
|
+
assert.deepEqual(tmpdirInputs("python3 -m venv $TMPDIR/v && $TMPDIR/v/bin/pip install x"), []);
|
|
549
|
+
assert.deepEqual(tmpdirInputs("virtualenv $TMPDIR/v && $TMPDIR/v/bin/pip install x"), []);
|
|
550
|
+
assert.deepEqual(tmpdirInputs("git clone https://x/y.git $TMPDIR/c && cat $TMPDIR/c/f"), []);
|
|
551
|
+
assert.deepEqual(tmpdirInputs("git worktree add $TMPDIR/w && cat $TMPDIR/w/f"), []);
|
|
552
|
+
assert.deepEqual(tmpdirInputs('uv pip install --python "$TMPDIR/pv/bin/python" pytest'), ["$TMPDIR/pv/bin/python"]);
|
|
553
|
+
});
|
|
470
554
|
it("#4325 tmpdirInputs lists read-before-create $TMPDIR paths once, in first-use order", () => {
|
|
471
555
|
assert.deepEqual(tmpdirInputs("cat ${TMPDIR:-/tmp}/a.json | jq . && cp $TMPDIR/b.txt out && cat $TMPDIR/a.json"), ["$TMPDIR/a.json", "$TMPDIR/b.txt"]);
|
|
472
556
|
assert.deepEqual(tmpdirInputs("cp src.txt $TMPDIR/b.txt && cat $TMPDIR/b.txt"), []);
|
|
@@ -521,8 +605,10 @@ describe("conformance review: the engine computes the verdict from complete rows
|
|
|
521
605
|
assert.match(problems[0], /nearest criterion line: "The scrape route must release/);
|
|
522
606
|
assert.ok(reaskable(problems));
|
|
523
607
|
assert.ok(reaskable(["R1: evidence path /layout.tsx does not exist"]), "#4327 evidence paths stay re-askable");
|
|
524
|
-
assert.ok(
|
|
525
|
-
assert.ok(
|
|
608
|
+
assert.ok(reaskable([...problems, "requirement R1 needs exactly one row (has 0)"]), "#5345 a missing row is repaired in place");
|
|
609
|
+
assert.ok(reaskable(["issue_coverage is missing or empty"]));
|
|
610
|
+
assert.ok(!reaskable(["requirements rows are missing"]), "a whole absent section keeps the two-run limit");
|
|
611
|
+
assert.ok(!reaskable([...problems, "something else is wrong"]));
|
|
526
612
|
assert.ok(!reaskable([]));
|
|
527
613
|
assert.deepEqual(fillEngineRows(good, ctx).issue_coverage, good.issue_coverage, "verbatim rows are untouched");
|
|
528
614
|
});
|
|
@@ -548,13 +634,28 @@ describe("conformance review: the engine computes the verdict from complete rows
|
|
|
548
634
|
assert.equal(i.state, "review.inconsistent"); assert.deepEqual(codes(i), ["review.inconsistent"]);
|
|
549
635
|
});
|
|
550
636
|
it("a deferred requirement needs the reviewer's deferral_ok; false is an unjustified deferral", () => {
|
|
551
|
-
const k = { ...C, requirements: [C.requirements[0], { ...C.requirements[1], disposition: "defer", why: "w" }] };
|
|
637
|
+
const k = { ...C, requirements: [C.requirements[0], { ...C.requirements[1], disposition: "defer", why: "w", bucket: "owner:rotate the key" }] };
|
|
552
638
|
const c2 = { ...ctx, contract: k };
|
|
553
639
|
const rv = (extra) => ({ ...good, requirements: [good.requirements[0], { id: "R2", status: "deferred", ...extra }] });
|
|
554
640
|
assert.equal(decide(rv({}), c2).state, "review.incomplete");
|
|
555
641
|
assert.equal(decide(rv({ deferral_ok: true }), c2).state, "conforms");
|
|
556
642
|
assert.deepEqual(codes(decide(rv({ deferral_ok: false, note: "two lines in the same file" }), c2)), ["conformance.unjustified_deferral"]);
|
|
557
643
|
});
|
|
644
|
+
it("#5207 an in-lane engineering deferral (new-issue or unbucketed) is never accepted, whatever deferral_ok says, and is never filed", () => {
|
|
645
|
+
const rv = (extra) => ({ ...good, requirements: [good.requirements[0], { id: "R2", status: "deferred", ...extra }] });
|
|
646
|
+
for (const bucket of ["new-issue", undefined]) {
|
|
647
|
+
const c2 = { ...ctx, contract: { ...C, requirements: [C.requirements[0], { ...C.requirements[1], disposition: "defer", why: "w", ...(bucket ? { bucket } : {}) }] } };
|
|
648
|
+
for (const ok of [true, false]) {
|
|
649
|
+
const d = decide(rv({ deferral_ok: ok }), c2);
|
|
650
|
+
assert.deepEqual(codes(d), ["conformance.unjustified_deferral"], `${bucket} ${ok}`); // one per row, no duplicate
|
|
651
|
+
assert.match(d.failures[0].detail, new RegExp(`^R2 is in-lane engineering work \\(bucket ${bucket ?? "none"}\\): deliver it .*\\(#5207\\)$`));
|
|
652
|
+
}
|
|
653
|
+
assert.deepEqual(pendingTracking(c2.contract).map((r) => r.id), [], "never filed");
|
|
654
|
+
assert.ok(inLaneDeferral(c2.contract.requirements[1]));
|
|
655
|
+
}
|
|
656
|
+
for (const r of [{ disposition: "defer", bucket: "owner:spend" }, { disposition: "defer", bucket: "host" }, { disposition: "post-deploy", bucket: "post-deploy" }, { disposition: "defer", class: "ops" }, { disposition: "deliver" }]) assert.equal(inLaneDeferral(r), false, JSON.stringify(r));
|
|
657
|
+
assert.deepEqual(pendingTracking({ requirements: [{ id: "R1", disposition: "defer", bucket: "owner:spend" }, { id: "R2", disposition: "defer", bucket: "new-issue" }] }).map((r) => r.id), ["R1"]);
|
|
658
|
+
});
|
|
558
659
|
it("short quotes are accepted only as a whole issue line or list item", () => {
|
|
559
660
|
const t = "Do this:\n- [ ] add --dry-run\n2. keep -v";
|
|
560
661
|
assert.ok(inIssue("add --dry-run", t)); assert.ok(inIssue("keep -v", t)); assert.ok(!inIssue("dry-run", t)); assert.ok(!inIssue("do", t));
|
|
@@ -568,6 +669,31 @@ describe("conformance review: the engine computes the verdict from complete rows
|
|
|
568
669
|
});
|
|
569
670
|
|
|
570
671
|
describe("close plan and follow-up items", () => {
|
|
672
|
+
it("#5285: a live default-on change with live acceptance deferred closes partial and names the blocker", () => {
|
|
673
|
+
const k = { requirements: [{ id: "R3", disposition: "defer", bucket: "post-deploy" }] };
|
|
674
|
+
const p = closePlan(k, { liveBlocks: [{ id: "R3", flag: "pool" }] });
|
|
675
|
+
assert.equal(p.reason, "partial");
|
|
676
|
+
assert.equal(p.liveBlocked, true);
|
|
677
|
+
assert.deepEqual(p.open.map((r) => r.id), ["R3"]);
|
|
678
|
+
assert.equal(closePlan(k).reason, "completed");
|
|
679
|
+
});
|
|
680
|
+
it("#5382: a default-on live-blocked lane still transfers its e2e/manual post-deploy rows to the epic", () => {
|
|
681
|
+
const k = { requirements: [{ id: "R3", disposition: "defer", bucket: "post-deploy" }, { id: "R4", quote: "[type:e2e] checkout works", disposition: "post-deploy" }] };
|
|
682
|
+
const p = closePlan(k, { liveBlocks: [{ id: "R3", flag: "pool" }] });
|
|
683
|
+
assert.equal(p.liveBlocked, true);
|
|
684
|
+
assert.equal(p.transferred, true);
|
|
685
|
+
assert.deepEqual(p.transfer.map((r) => r.id), ["R4"]);
|
|
686
|
+
assert.deepEqual(p.open.map((r) => r.id), ["R3"]);
|
|
687
|
+
assert.equal(closePlan({ requirements: [k.requirements[0]] }, { liveBlocks: [{ id: "R3", flag: "pool" }] }).transferred, undefined);
|
|
688
|
+
});
|
|
689
|
+
it("#5285: interactive UI on a high-risk surface with no browser check fails precheck; with one, or off a risk surface, it passes", () => {
|
|
690
|
+
const k = { requirements: [{ id: "R1", disposition: "deliver" }], deliverables: [{ id: "D1", path: "web/Cta.tsx" }] };
|
|
691
|
+
const res = { requirements: [{ id: "R1", status: "implemented" }], validation: [] };
|
|
692
|
+
const run = (uiBrowser) => precheck({ contract: k, result: res, changedFiles: ["web/Cta.tsx"], uiBrowser }).failures.filter((f) => f.kind === "ui_browser_unverified");
|
|
693
|
+
assert.equal(run({ files: ["web/Cta.tsx"], ran: false, highRisk: true, reason: "no e2e_label or e2e_workflow configured" }).length, 1);
|
|
694
|
+
assert.equal(run({ files: ["web/Cta.tsx"], ran: true, highRisk: true, reason: "x" }).length, 0);
|
|
695
|
+
assert.equal(run({ files: ["web/Cta.tsx"], ran: false, highRisk: false, reason: "x" }).length, 0);
|
|
696
|
+
});
|
|
571
697
|
it("links every tracking issue once; nothing tracked when everything is delivered", () => {
|
|
572
698
|
assert.deepEqual(closePlan(C), { reason: "completed", tracked: [] });
|
|
573
699
|
const k = { requirements: [{ id: "R1", disposition: "deliver" }, { id: "R2", disposition: "defer", tracked: "#9" }, { id: "R3", disposition: "post-deploy", tracked: "#9" }] };
|
|
@@ -590,6 +716,22 @@ describe("close plan and follow-up items", () => {
|
|
|
590
716
|
assert.deepEqual(closePlan(d, { title, review: { requirements: [{ id: "R1", status: "implemented" }] } }).open.map((r) => r.id), ["R2"], "a missing row is not an answer");
|
|
591
717
|
assert.equal(closePlan(d, { title, review: null }).reason, "completed", "a skipped review judges dispositions only");
|
|
592
718
|
});
|
|
719
|
+
it("#5240 an unticked acceptance box with an undelivered or untracked requirement closes partial for any title", () => {
|
|
720
|
+
const issueText = "## Acceptance\n\n- [ ] Replaying the incident keeps the issue open with a partial outcome\n- [ ] The gate mode is recorded in the trajectory notes\n";
|
|
721
|
+
const reqs = [
|
|
722
|
+
{ id: "R1", quote: "- [ ] Replaying the incident keeps the issue open with a partial outcome", disposition: "deliver" },
|
|
723
|
+
{ id: "R2", quote: "- [ ] The gate mode is recorded in the trajectory notes", disposition: "defer", tracked: "#9" },
|
|
724
|
+
];
|
|
725
|
+
const rows = (s1) => ({ requirements: [{ id: "R1", status: s1 }, { id: "R2", status: "deferred" }] });
|
|
726
|
+
const p = closePlan({ requirements: reqs }, { title: "fix: x", review: rows("partial"), issueText });
|
|
727
|
+
assert.equal(p.reason, "partial"); assert.equal(p.checklist, true);
|
|
728
|
+
assert.deepEqual(p.open.map((r) => r.id), ["R1"]); assert.deepEqual(p.unticked, ["Replaying the incident keeps the issue open with a partial outcome"]);
|
|
729
|
+
assert.deepEqual(closePlan({ requirements: reqs }, { title: "fix: x", review: rows("implemented"), issueText }), { reason: "completed", tracked: ["#9"] });
|
|
730
|
+
const untracked = closePlan({ requirements: [reqs[0], { ...reqs[1], tracked: undefined }] }, { title: "fix: x", review: rows("implemented"), issueText });
|
|
731
|
+
assert.deepEqual(untracked.open.map((r) => r.id), ["R2"]);
|
|
732
|
+
assert.equal(closePlan({ requirements: reqs }, { title: "fix: x", review: rows("partial") }).reason, "completed", "no issue text: unchanged");
|
|
733
|
+
assert.equal(closePlan({ requirements: reqs }, { title: "fix: x", review: null, issueText }).reason, "completed", "skipped review judges dispositions only");
|
|
734
|
+
});
|
|
593
735
|
it("#4398 formatShadowSummary: shadow would-block and false-block shares, risk-enforced lanes; null without conformance rows", () => {
|
|
594
736
|
assert.equal(formatShadowSummary([{ issue: 1 }]), null); assert.equal(formatShadowSummary(undefined), null);
|
|
595
737
|
const rows = [{ conformance: { mode: "shadow", would: "conforms", risk: false } }, { conformance: { mode: "shadow", would: "nonconforming", risk: false } },
|
|
@@ -998,7 +1140,7 @@ describe("post-deploy check ids (#4626)", () => {
|
|
|
998
1140
|
assert.equal(cls({ disposition: "post-deploy", check: "x" }), "post-deploy");
|
|
999
1141
|
assert.equal(cls({ disposition: "defer", class: "external" }), "external");
|
|
1000
1142
|
assert.equal(cls({ disposition: "defer", class: "bogus" }), "engineering");
|
|
1001
|
-
assert.deepEqual(FOLLOWUP_CLASSES, ["engineering", "post-deploy", "external", "ops", "host"
|
|
1143
|
+
assert.deepEqual(FOLLOWUP_CLASSES, ["engineering", "post-deploy", "external", "ops", "host"]); // #5207: backlog removed
|
|
1002
1144
|
assert.equal(followupClass({ disposition: "post-deploy" }), "post-deploy"); assert.equal(followupClass({ class: "ops" }), "ops");
|
|
1003
1145
|
const v = validateContract({ requirements: [{ id: "R1", quote: Q1, disposition: "defer", why: "w", class: "bogus" }], deliverables: [], preserve: [], validate: [{ id: "V1", command: "true" }] }, Q1);
|
|
1004
1146
|
assert.ok(v.problems.some((x) => /R1: class must be one of/.test(x)), v.problems.join(";"));
|
|
@@ -1025,8 +1167,8 @@ describe("post-deploy check ids (#4626)", () => {
|
|
|
1025
1167
|
assert.equal(followupClass({ disposition: "defer", bucket: "owner:spend" }), "external");
|
|
1026
1168
|
assert.equal(followupClass({ disposition: "defer", bucket: "owner:spend", class: "ops" }), "ops");
|
|
1027
1169
|
assert.equal(followupClass({ disposition: "defer", bucket: "owner:x", class: "post-deploy" }), "external");
|
|
1028
|
-
assert.equal(followupClass({ disposition: "defer", bucket: "new-issue", class: "post-deploy" }), "
|
|
1029
|
-
assert.equal(followupClass({ disposition: "defer", bucket: "new-issue" }), "
|
|
1170
|
+
assert.equal(followupClass({ disposition: "defer", bucket: "new-issue", class: "post-deploy" }), "engineering");
|
|
1171
|
+
assert.equal(followupClass({ disposition: "defer", bucket: "new-issue" }), "engineering"); assert.equal(followupClass({ disposition: "defer", bucket: "new-issue", class: "ops" }), "engineering"); // #5207
|
|
1030
1172
|
for (const bucket of ["post-deploy", "verify-now", "date:2026-12-01"]) assert.equal(followupClass({ disposition: "defer", bucket }), "post-deploy");
|
|
1031
1173
|
assert.equal(one({ bucket: "owner:rotate the key" }).why, "owner: rotate the key. [bucket:owner] w");
|
|
1032
1174
|
assert.equal(one({ bucket: "verify-now" }).why, "post-deploy: [bucket:verify-now] w");
|
|
@@ -1486,3 +1628,134 @@ describe("release review #5103", () => {
|
|
|
1486
1628
|
}
|
|
1487
1629
|
});
|
|
1488
1630
|
});
|
|
1631
|
+
|
|
1632
|
+
import { hostRoute as hostRoute5197 } from "./conformance.mjs";
|
|
1633
|
+
describe("#5197 hostRoute is exported as the single host-route source", () => {
|
|
1634
|
+
it("post-promotion text joins the rollup; pre-promotion and external needs stay host", () => {
|
|
1635
|
+
assert.equal(hostRoute5197({ bucket: "host", why: "verify the dashboard after release" }), "post-deploy");
|
|
1636
|
+
assert.equal(hostRoute5197({ bucket: "host", why: "capture logs before promotion" }), "host");
|
|
1637
|
+
assert.equal(hostRoute5197({ bucket: "host", why: "provide the API key after release" }), "host");
|
|
1638
|
+
});
|
|
1639
|
+
});
|
|
1640
|
+
|
|
1641
|
+
import { intakeHostWork } from "./conformance.mjs";
|
|
1642
|
+
describe("#5250 intakeHostWork", () => {
|
|
1643
|
+
const body = (...items) => `## Problem\nx\n\n## Acceptance Criteria\n\n${items.map((t) => `- [ ] ${t}`).join("\n")}\n`;
|
|
1644
|
+
it("matches when every criterion needs live production measurement or a real-browser capture", () => {
|
|
1645
|
+
const r = intakeHostWork(body("Measured clear rate on live production traffic is above 50%", "Root-cause capture from a real browser is attached"));
|
|
1646
|
+
assert.equal(r.host, true); assert.equal(r.items.length, 2);
|
|
1647
|
+
});
|
|
1648
|
+
it("one code-shaped criterion keeps a code lane", () => {
|
|
1649
|
+
assert.equal(intakeHostWork(body("Measured clear rate on live production traffic is above 50%", "The retry guard stops after a rejection")).host, false);
|
|
1650
|
+
});
|
|
1651
|
+
it("code-only, credential-needing, checklist-less and empty bodies do not match", () => {
|
|
1652
|
+
assert.equal(intakeHostWork(body("The retry guard stops after a rejection")).host, false);
|
|
1653
|
+
assert.equal(intakeHostWork(body("Measure live production latency using the API key")).host, false);
|
|
1654
|
+
assert.equal(intakeHostWork("## Acceptance\nmeasured on live production").host, false);
|
|
1655
|
+
assert.equal(intakeHostWork("").host, false); assert.equal(intakeHostWork(null).host, false);
|
|
1656
|
+
});
|
|
1657
|
+
it("a backlog aggregate that merely quotes such text is not host work", () => {
|
|
1658
|
+
assert.equal(intakeHostWork("## Acceptance Criteria\n\n### #5240\n<!-- FORGE:DEFERRED_FROM: #5240 -->\n\n- [ ] classify issues whose acceptance requires live production measurement or real-browser captures as host work\n").host, false);
|
|
1659
|
+
});
|
|
1660
|
+
});
|
|
1661
|
+
|
|
1662
|
+
describe("contract quote snapping (#5244)", () => {
|
|
1663
|
+
const LINE = "- Add `SLI_CONCENTRATION_MIN_REST_EVENTS` (default 30 per window, documented in `config.env.example`). Below it, publish no signal.";
|
|
1664
|
+
const ISS = `## Problem\n\n${LINE}\n- Remove the legacy **alert** path entirely from the worker.\n- Remove the legacy alert path entirely from the scheduler.\n`;
|
|
1665
|
+
it("markdown inline code spans, elision and spaced identifiers all match", () => {
|
|
1666
|
+
assert.ok(inIssue("Add `SLI_CONCENTRATION_MIN_REST_EVENTS` (default 30 per window, documented in `config.env.example`).", ISS));
|
|
1667
|
+
assert.ok(inIssue("Add SLI_CONCENTRATION_MIN_REST_EVENTS (default 30 per window, documented in config.env.example). Below it, publish...", ISS));
|
|
1668
|
+
assert.ok(inIssue("Add `SLI_CONCENTRATION_MIN_REST_EVENTS` (default 30 per window, documented in `config.env.example`). Below it, publish…", ISS));
|
|
1669
|
+
assert.ok(inIssue("Add SLI CONCENTRATION MIN REST EVENTS (default 30 per window", ISS));
|
|
1670
|
+
assert.ok(!inIssue("Add SLI_CONCENTRATION_MIN_REST_EVENTS (default 99 per window", ISS));
|
|
1671
|
+
});
|
|
1672
|
+
it("a near-verbatim quote snaps to the one issue line and records the original", () => {
|
|
1673
|
+
const q = "Add the SLI_CONCENTRATION_MIN_REST_EVENTS (default 30 per window, documented in config.env.example)";
|
|
1674
|
+
assert.ok(!inIssue(q, ISS));
|
|
1675
|
+
const c = { requirements: [{ id: "R2b", quote: q, disposition: "deliver" }] };
|
|
1676
|
+
const { contract, snapped } = snapQuotes(c, ISS);
|
|
1677
|
+
assert.equal(snapped.length, 1);
|
|
1678
|
+
assert.ok(contract.requirements[0].quote.includes("`SLI_CONCENTRATION_MIN_REST_EVENTS`"));
|
|
1679
|
+
assert.equal(contract.requirements[0].requoted, q);
|
|
1680
|
+
assert.ok(inIssue(contract.requirements[0].quote, ISS));
|
|
1681
|
+
});
|
|
1682
|
+
it("an ambiguous or dissimilar quote does not snap", () => {
|
|
1683
|
+
assert.equal(snapQuote("Remove the legacy alert path entirely from the service", ISS), null);
|
|
1684
|
+
assert.equal(snapQuote("Publish a completely different dashboard widget for billing", ISS), null);
|
|
1685
|
+
assert.equal(snapQuotes({ requirements: [{ id: "R1", quote: "totally unrelated words about something else here" }] }, ISS).snapped.length, 0);
|
|
1686
|
+
});
|
|
1687
|
+
});
|
|
1688
|
+
|
|
1689
|
+
describe("#5345 an incomplete reviewer reply is repaired in place", () => {
|
|
1690
|
+
it("every row-level gap is re-askable and the repaired rows merge into the first reply (no new review round)", () => {
|
|
1691
|
+
for (const p of ["R2: status invalid: maybe", "R1: a defer requirement needs deferral_ok true|false (is deferring it justified?)", "changed file a.js has no scope row", "preserve P1 needs a row with status intact|violated|unverified", "verdict must be CONFORMS or NONCONFORMING"]) assert.ok(reaskable([p]), p);
|
|
1692
|
+
const merged = mergeReviewRows({ verdict: "CONFORMS", requirements: [{ id: "R1", status: "implemented" }] }, { requirements: [{ id: "R2", status: "implemented" }] });
|
|
1693
|
+
assert.deepEqual(merged.requirements.map((r) => r.id), ["R1", "R2"]);
|
|
1694
|
+
});
|
|
1695
|
+
});
|
|
1696
|
+
|
|
1697
|
+
describe("#5339 a faked or deferred e2e/manual requirement is not met", () => {
|
|
1698
|
+
const Q = "Users can render the launch film end to end [type:e2e]";
|
|
1699
|
+
const mk = (cmd, quote, extra = {}, disposition = "deliver") => {
|
|
1700
|
+
const contract = { ...C, requirements: [{ id: "R1", quote, disposition, ...extra }, C.requirements[1]], validate: [{ id: "V1", command: cmd }] };
|
|
1701
|
+
return { contract, ctx: { ...ctx, contract } };
|
|
1702
|
+
};
|
|
1703
|
+
const rv = (contract) => ({ ...good, issue_coverage: [{ quote: contract.requirements[0].quote, status: "covered" }, ...good.issue_coverage.slice(1)] });
|
|
1704
|
+
const run = (cmd, quote, e2e, disposition, row = {}) => { const m = mk(cmd, quote, {}, disposition); const r = rv(m.contract); r.requirements = [{ ...r.requirements[0], ...row }, ...r.requirements.slice(1)]; return decide(r, { ...m.ctx, issueText: `${ISSUE}\n${quote}`, e2e }); };
|
|
1705
|
+
it("a validate that names a faked test is not an e2e run, even with e2e in its name (spectracut #63 replay)", () => {
|
|
1706
|
+
const d = run("node --test tests/e2e/film.e2e.test.mjs", Q, { faked: ["tests/e2e/film.e2e.test.mjs"] });
|
|
1707
|
+
assert.equal(d.state, "nonconforming");
|
|
1708
|
+
assert.deepEqual(codes(d), ["conformance.e2e_unverified"]);
|
|
1709
|
+
assert.equal(d.failures[0].kind, "e2e_row");
|
|
1710
|
+
assert.equal(run("node --test tests/e2e/film.e2e.test.mjs", Q, { faked: [] }).state, "conforms");
|
|
1711
|
+
assert.equal(run("make film", Q, { checks: ["make film"], faked: ["make film"] }).state, "conforms", "a configured e2e check is always real");
|
|
1712
|
+
});
|
|
1713
|
+
it("[type:manual] is judged like [type:e2e]; a deferred e2e row fails, a post-deploy one is transferred", () => {
|
|
1714
|
+
assert.deepEqual(codes(run("pytest tests/test_x.py", "Operators can restore a backup [type:manual]")), ["conformance.e2e_unverified"]);
|
|
1715
|
+
assert.equal(codes(run("pytest tests/test_x.py", Q, undefined, "defer", { status: "deferred", deferral_ok: true })).includes("conformance.e2e_unverified"), true);
|
|
1716
|
+
assert.equal(codes(run("pytest tests/test_x.py", Q, undefined, "post-deploy", { status: "post-deploy" })).includes("conformance.e2e_unverified"), false);
|
|
1717
|
+
});
|
|
1718
|
+
it("e2e_unverified of the e2e row blocks by default; forge.yaml conformance_kinds overrides; other kinds follow the lane", () => {
|
|
1719
|
+
const fs = [{ code: "conformance.e2e_unverified", kind: "e2e_row" }, { code: "conformance.e2e_unverified", kind: "ui_browser_unverified" }];
|
|
1720
|
+
assert.deepEqual(blockingFailures(fs, { shadow: true }).block.map((f) => f.kind), ["e2e_row"]);
|
|
1721
|
+
assert.deepEqual(blockingFailures(fs, { shadow: true, kinds: { "conformance.e2e_unverified": "shadow" } }).block, []);
|
|
1722
|
+
});
|
|
1723
|
+
it("closePlan: a transferred e2e/manual requirement closes partial, never completed", () => {
|
|
1724
|
+
const k = { requirements: [{ id: "R1", quote: Q, disposition: "post-deploy", tracked: "#9" }] };
|
|
1725
|
+
const p = closePlan(k);
|
|
1726
|
+
assert.equal(p.reason, "partial");
|
|
1727
|
+
assert.equal(p.transferred, true);
|
|
1728
|
+
assert.deepEqual(p.open.map((r) => r.id), ["R1"]);
|
|
1729
|
+
assert.equal(closePlan({ requirements: [{ id: "R1", quote: "A plain thing [type:unit]", disposition: "post-deploy" }] }).reason, "completed");
|
|
1730
|
+
});
|
|
1731
|
+
it("#5365 add-requirement id collision is renumbered to the next free R<n> and recorded, never a problem", () => {
|
|
1732
|
+
const add = (id) => ({ kind: "add-requirement", requirement: { id, quote: "Billing pricing is unchanged.", disposition: "deliver" }, why: "missed" });
|
|
1733
|
+
const a = applyAmendments(C, [add("R2"), add("R2")], ISSUE);
|
|
1734
|
+
assert.deepEqual(a.problems, []);
|
|
1735
|
+
assert.deepEqual(a.contract.requirements.map((r) => r.id), ["R1", "R2", "R3", "R4"]);
|
|
1736
|
+
assert.ok(a.applied.some((x) => x.target === "R2 -> R3") && a.applied.some((x) => x.target === "R2 -> R4"));
|
|
1737
|
+
assert.equal(applyAmendments(C, [add("R9")], ISSUE).applied[0].target, "R9");
|
|
1738
|
+
});
|
|
1739
|
+
it("#5365 a file coupled to a deliverable (outcome-codes.mjs <-> docs/OUTCOME-CODES.md) is not scope creep; an unrelated doc still is", () => {
|
|
1740
|
+
const k = { ...C, deliverables: [{ id: "D1", path: "bin/engine/outcome-codes.mjs" }] };
|
|
1741
|
+
const run = (f) => precheck({ contract: k, result: { requirements: [], validation: [{ id: "V1", exit: 0 }] }, changedFiles: ["bin/engine/outcome-codes.mjs", f] }).failures.map((x) => x.kind);
|
|
1742
|
+
assert.equal(run("docs/OUTCOME-CODES.md").includes("scope_creep"), false);
|
|
1743
|
+
assert.ok(run("docs/OTHER.md").includes("scope_creep"));
|
|
1744
|
+
const none = precheck({ contract: C, result: { requirements: [], validation: [] }, changedFiles: ["docs/OUTCOME-CODES.md"] }).failures.map((x) => x.kind);
|
|
1745
|
+
assert.ok(none.includes("scope_creep"), "coupling needs the paired deliverable");
|
|
1746
|
+
const dctx = { ...ctx, contract: k, changedFiles: ["bin/engine/outcome-codes.mjs", "docs/OUTCOME-CODES.md"] };
|
|
1747
|
+
const kr = { ...good, requirements: [good.requirements[0], good.requirements[1]], scope: [{ file: "bin/engine/outcome-codes.mjs", authorized_by: "D1" }, { file: "docs/OUTCOME-CODES.md", authorized_by: "none" }] };
|
|
1748
|
+
assert.ok(!decide(kr, dctx).failures.some((f) => f.code === "conformance.scope_creep"));
|
|
1749
|
+
});
|
|
1750
|
+
it("#5365 a defer row the review finds implemented converts to deliver instead of unjustified_deferral; an undelivered one still fails", () => {
|
|
1751
|
+
const k = { ...C, requirements: [C.requirements[0], { ...C.requirements[1], disposition: "defer", why: "w", bucket: "owner:rotate the key" }] };
|
|
1752
|
+
const c2 = { ...ctx, contract: k };
|
|
1753
|
+
const rv = (extra) => ({ ...good, requirements: [good.requirements[0], { id: "R2", ...extra }] });
|
|
1754
|
+
const d = decide(rv({ status: "implemented", evidence: "src/search.js:7", validated_by: "V1", deferral_ok: false, note: "replay already ships" }), c2);
|
|
1755
|
+
assert.deepEqual(codes(d), []);
|
|
1756
|
+
assert.deepEqual(d.converted, [{ id: "R2", evidence: "src/search.js:7" }]);
|
|
1757
|
+
const conv = convertDelivered(k, d.converted).requirements[1];
|
|
1758
|
+
assert.equal(conv.disposition, "deliver"); assert.equal(conv.bucket, undefined); assert.equal(conv.amended_from.disposition, "defer");
|
|
1759
|
+
assert.deepEqual(codes(decide(rv({ status: "deferred", deferral_ok: false }), c2)), ["conformance.unjustified_deferral"]);
|
|
1760
|
+
});
|
|
1761
|
+
});
|
package/bin/lean/context.mjs
CHANGED
|
@@ -38,6 +38,8 @@ export const MAX_LINKS = 20;
|
|
|
38
38
|
export const MAX_LEDGER_PRS = 8;
|
|
39
39
|
/** #4401: FORGE:FACTS records (earlier lanes) read into one pack: this issue's own attempts first, then the file-path ledger. */
|
|
40
40
|
export const MAX_FACT_LANES = 6;
|
|
41
|
+
/** #5340: sibling issues whose comments are read for FORGE:FACTS, and in-flight declarations kept, per pack. */
|
|
42
|
+
export const MAX_SIBLING_READS = 12;
|
|
41
43
|
/** #5085: subject-history bounds per pack: GitHub searches run, rows kept. */
|
|
42
44
|
export const MAX_SUBJECT_QUERIES = 3;
|
|
43
45
|
export const MAX_SUBJECT_ITEMS = 8;
|
|
@@ -65,6 +67,17 @@ export function parseContextPackConfig({ mode, sources, bytes, days, pitfallLane
|
|
|
65
67
|
return { mode: CONTEXT_MODES.includes(m) ? m : "shadow", sources: picked, budgetBytes: pos(bytes, DEFAULT_CONTEXT_BYTES), days: pos(days, DEFAULT_LEDGER_DAYS), pitfallLanes: pos(pitfallLanes, DEFAULT_PITFALL_LANES) };
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
/**
|
|
71
|
+
* #5340: the mode of a lane once its milestone and parent are known. An explicit forge.yaml engine.context_pack (any valid
|
|
72
|
+
* mode, `ab` included) always wins; unset, a lane with a milestone or a parent epic gets `on` so it sees its siblings,
|
|
73
|
+
* and every other lane keeps the shadow default. `cfg` is parseContextPackConfig's result (after any ab arm).
|
|
74
|
+
*/
|
|
75
|
+
export function resolveContextMode(raw, cfg, { milestone = null, parent = null } = {}) {
|
|
76
|
+
const explicit = CONTEXT_MODES.includes(String(raw?.mode ?? "").trim().toLowerCase());
|
|
77
|
+
if (explicit || cfg.mode !== "shadow") return cfg.mode;
|
|
78
|
+
return milestone || parent ? "on" : cfg.mode;
|
|
79
|
+
}
|
|
80
|
+
|
|
68
81
|
/**
|
|
69
82
|
* #4444: the effective mode of one lane. In `ab` the arm comes from a stable hash of `repo#issue`, so every rerun of an
|
|
70
83
|
* issue stays in its arm and the arms are random, matched cohorts per lane type; any other mode passes through.
|
|
@@ -302,8 +315,8 @@ async function recallStatus(io, dirs, index) {
|
|
|
302
315
|
* base ref; `checkout` (the main checkout, optional) is where repo-fact files absent from the worktree are looked up.
|
|
303
316
|
* Every source is independent and best effort: a failing source is listed in `errors` and contributes nothing.
|
|
304
317
|
*/
|
|
305
|
-
export async function gatherContextFacts({ io, repo, issue, iss, comments = [], cwd, checkout = null, base, sources = CONTEXT_SOURCES, days = DEFAULT_LEDGER_DAYS, now = Date.now(), pitfalls = [], recallIndex = RECALL_INDEX }) {
|
|
306
|
-
const facts = { issue: Number(issue), links: [], attempts: [], pitfalls: [], ledger: [], facts: [], lanes: [], errors: [], recall: null };
|
|
318
|
+
export async function gatherContextFacts({ io, repo, issue, iss, comments = [], cwd, checkout = null, base, sources = CONTEXT_SOURCES, days = DEFAULT_LEDGER_DAYS, now = Date.now(), pitfalls = [], recallIndex = RECALL_INDEX, milestone = null }) {
|
|
319
|
+
const facts = { issue: Number(issue), links: [], attempts: [], pitfalls: [], ledger: [], facts: [], lanes: [], siblings: [], inflight: [], errors: [], recall: null };
|
|
307
320
|
const body = String(iss?.body ?? "");
|
|
308
321
|
const on = new Set(sources);
|
|
309
322
|
const step = async (name, fn) => { if (!on.has(name)) return; try { await fn(); } catch (e) { facts.errors.push(`${name}: ${oneLine(e?.message ?? e, 120)}`); } };
|
|
@@ -332,6 +345,7 @@ export async function gatherContextFacts({ io, repo, issue, iss, comments = [],
|
|
|
332
345
|
for (const s of [...new Set(subs)].sort(byNum)) if (s !== Number(issue) && !rel.has(s)) rel.set(s, "sibling");
|
|
333
346
|
} catch (e) { facts.errors.push(`graph: siblings ${oneLine(e?.message ?? e, 80)}`); }
|
|
334
347
|
}
|
|
348
|
+
facts.siblings = [...rel.entries()].filter(([, r]) => r === "sibling").map(([n]) => n);
|
|
335
349
|
const order = { parent: 0, "depends-on": 1, link: 2, "cross-ref": 3, sibling: 4 };
|
|
336
350
|
const picked = [...rel.entries()].sort((a, b) => order[a[1]] - order[b[1]] || a[0] - b[0]).slice(0, MAX_LINKS);
|
|
337
351
|
for (const [n, r] of picked) {
|
|
@@ -435,6 +449,15 @@ export async function gatherContextFacts({ io, repo, issue, iss, comments = [],
|
|
|
435
449
|
facts.lanes.push({ ref, issue: n, pr, ...rec });
|
|
436
450
|
};
|
|
437
451
|
for (const c of [...comments].reverse()) if (trusted(c)) add(parseFactsComment(c?.body), `#${issue} earlier attempt`, Number(issue), null);
|
|
452
|
+
// #5340: siblings first: the FORGE:FACTS of the lane's siblings (same parent, same milestone), whatever files they touched,
|
|
453
|
+
// and what in-flight sibling lanes declared they will add on shared surfaces (host declarations).
|
|
454
|
+
let ms = [];
|
|
455
|
+
if (milestone) { try { ms = JSON.parse(String(await io.gh(["issue", "list", "-R", repo, "--milestone", String(milestone), "--state", "all", "--limit", "40", "--json", "number"]))).map((x) => Number(x?.number)); } catch (e) { facts.errors.push(`facts: milestone ${oneLine(e?.message ?? e, 80)}`); } }
|
|
456
|
+
facts.siblings = [...new Set([...facts.siblings, ...ms])].filter((n) => Number.isSafeInteger(n) && n > 0 && n !== Number(issue)).sort(byNum);
|
|
457
|
+
for (const n of facts.siblings.slice(0, MAX_SIBLING_READS)) {
|
|
458
|
+
try { for (const c of [...(await readComments(io.gh, repo, n))].reverse().filter(trusted)) add(parseFactsComment(c?.body), `#${n} sibling`, n, null); } catch (e) { facts.errors.push(`facts: sibling #${n} ${oneLine(e?.message ?? e, 80)}`); }
|
|
459
|
+
}
|
|
460
|
+
try { facts.inflight = ((await io.declared?.({ repo, except: issue })) ?? []).slice(0, MAX_SIBLING_READS); } catch (e) { facts.errors.push(`facts: in-flight ${oneLine(e?.message ?? e, 80)}`); }
|
|
438
461
|
const overlaps = (files) => files.some((f) => paths.some((p) => f === p || f.startsWith(`${p.replace(/\/+$/, "")}/`) || p.startsWith(`${f}/`)));
|
|
439
462
|
let prs = [];
|
|
440
463
|
try { prs = await ledgerPrs(); } catch (e) { facts.errors.push(`facts: ledger ${oneLine(e?.message ?? e, 80)}`); }
|
|
@@ -463,6 +486,9 @@ const linkLine = (l) => { const fails = (Array.isArray(l.failures) ? l.failures
|
|
|
463
486
|
const pitfallLine = (p) => `- [${p.trigger}] ${oneLine(p.lesson, 160)}${p.globs?.length ? ` (${p.globs.join(", ")})` : ""}; seen ${p.count}×`;
|
|
464
487
|
const ledgerLine = (p) => `- ${p.pr ? `PR #${p.pr}` : "commit"} ${p.sha}${p.revert ? " [revert]" : ""}${p.reverted ? ` [reverted by ${p.reverted}]` : ""} "${p.title}"${p.files?.length ? ` (${p.files.join(", ")})` : ""}${p.notes?.length ? ` — ${p.notes.join("; ")}` : ""}`;
|
|
465
488
|
|
|
489
|
+
/** #5347: the files earlier merged PRs on the issue's symbols touched (the ledger's), unique, at most 8: the builder's cheap answer to "where to look". */
|
|
490
|
+
const packFiles = (facts) => [...new Set((facts.ledger ?? []).flatMap((p) => p.files ?? []))].slice(0, 8);
|
|
491
|
+
|
|
466
492
|
/**
|
|
467
493
|
* The pack text for `facts`, ranked: explicit links (parent > Depends on > body links > cross-references > siblings),
|
|
468
494
|
* prior attempts, recurring pitfalls of the repo (#4375, in the engine's selected order), the symbol ledger (newest first), repo-fact pointers. One line per item; a parent or dependency also
|
|
@@ -479,13 +505,16 @@ export function compileContextPack(facts, { budgetBytes = DEFAULT_CONTEXT_BYTES,
|
|
|
479
505
|
if (on.has("ledger")) for (const p of facts?.ledger ?? []) cand.push({ src: "ledger", line: ledgerLine(p) });
|
|
480
506
|
if (on.has("facts")) {
|
|
481
507
|
// #4401: earlier lanes' facts by kind (rejected approaches first, across lanes), then the repo-fact file pointers
|
|
482
|
-
|
|
483
|
-
for (const
|
|
508
|
+
// #5340: siblings first: what in-flight siblings declared they will add, then merged siblings' facts, then the rest
|
|
509
|
+
for (const d of facts?.inflight ?? []) cand.push({ src: "facts", line: oneLine(`- #${d.issue} (in flight, sibling) will touch shared surface ${(d.surfaces ?? []).join(", ")}${d.paths?.length ? `: ${d.paths.slice(0, 6).join(", ")}` : ""}`) });
|
|
510
|
+
const sib = new Set(facts?.siblings ?? []);
|
|
511
|
+
const all = (facts?.lanes ?? []).map((l) => ({ sib: sib.has(l.issue), lines: factsLines(l, l.ref) }));
|
|
512
|
+
for (const group of [all.filter((l) => l.sib), all.filter((l) => !l.sib)]) for (const k of FACTS_RANK) for (const l of group) for (const line of l.lines[k]) cand.push({ src: "facts", line: oneLine(line) });
|
|
484
513
|
for (const f of facts?.facts ?? []) cand.push({ src: "facts", line: `- ${f} (repo facts file; read it if relevant)` });
|
|
485
514
|
}
|
|
486
515
|
const found = Object.fromEntries(CONTEXT_SOURCES.map((s) => [s, cand.filter((c) => c.src === s).length]));
|
|
487
516
|
const recall = facts?.recall && typeof facts.recall === "object" ? { present: Boolean(facts.recall.present), reason: oneLine(facts.recall.reason ?? "", 80) } : null;
|
|
488
|
-
const empty = { text: "", bytes: 0, items: 0, truncated: 0, sources: Object.fromEntries(CONTEXT_SOURCES.map((s) => [s, 0])), found, hash: null, pitfalls: [], recall };
|
|
517
|
+
const empty = { text: "", bytes: 0, items: 0, truncated: 0, sources: Object.fromEntries(CONTEXT_SOURCES.map((s) => [s, 0])), found, hash: null, pitfalls: [], recall, files: [] };
|
|
489
518
|
if (!cand.length) return empty;
|
|
490
519
|
const titles = { graph: "Linked issues and PRs", attempts: "Prior attempts (this issue and the same subject)", pitfalls: "Recurring pitfalls in this repo (past rework)", ledger: "Merged PRs on the same symbols (reverts, decisions, findings)", facts: "Facts from earlier lanes and repo facts" };
|
|
491
520
|
const head = `Context pack for #${facts.issue}`;
|
|
@@ -506,7 +535,7 @@ export function compileContextPack(facts, { budgetBytes = DEFAULT_CONTEXT_BYTES,
|
|
|
506
535
|
if (rows.length) parts.push(`\n${titles[s]}:`, ...rows.map((r) => r.text));
|
|
507
536
|
}
|
|
508
537
|
const text = parts.join("\n");
|
|
509
|
-
return { text, bytes: size(text), items: kept.length, truncated, sources: Object.fromEntries(CONTEXT_SOURCES.map((s) => [s, kept.filter((k) => k.src === s).length])), found, hash: hash12(text), pitfalls: kept.filter((k) => k.pit).map((k) => k.pit), recall };
|
|
538
|
+
return { text, bytes: size(text), items: kept.length, truncated, sources: Object.fromEntries(CONTEXT_SOURCES.map((s) => [s, kept.filter((k) => k.src === s).length])), found, hash: hash12(text), pitfalls: kept.filter((k) => k.pit).map((k) => k.pit), recall, files: packFiles(facts) };
|
|
510
539
|
}
|
|
511
540
|
|
|
512
541
|
/** The pack text without its pitfalls section (#4375: pitfalls are local only and never posted). */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { describe, it } from "node:test";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
5
|
import { normaliseFacts, renderFactsRecord, FACTS_MARKER } from "./facts.mjs";
|
|
6
|
-
import { closedResult, gatherContextFacts, compileContextPack, contextPackFor, contextArm, contextPackCacheKey, linkStateStamp, LINK_STAMP_MAX, parseContextPackConfig, laneType, priorAttempts, issueSymbols, bodyLinks, parentOf, renderContextRecord, DEFAULT_CONTEXT_BYTES, noComments, subjectTerms, subjectHistory, MAX_SUBJECT_ITEMS, MAX_SUBJECT_QUERIES } from "./context.mjs";
|
|
6
|
+
import { closedResult, gatherContextFacts, compileContextPack, contextPackFor, contextArm, contextPackCacheKey, linkStateStamp, LINK_STAMP_MAX, parseContextPackConfig, resolveContextMode, laneType, priorAttempts, issueSymbols, bodyLinks, parentOf, renderContextRecord, DEFAULT_CONTEXT_BYTES, noComments, subjectTerms, subjectHistory, MAX_SUBJECT_ITEMS, MAX_SUBJECT_QUERIES } from "./context.mjs";
|
|
7
7
|
|
|
8
8
|
const REPO = "o/r";
|
|
9
9
|
const BOT = { author_association: "NONE", user: { type: "Bot", login: "forge[bot]" } };
|
|
@@ -35,6 +35,7 @@ function fakes(o = {}) {
|
|
|
35
35
|
102: [],
|
|
36
36
|
103: [{ id: 3, body: "<!-- FORGE:DECISION -->\nUnrelated decision about logging.", ...BOT }],
|
|
37
37
|
33: [{ id: 4, body: "<!-- FORGE:CONTRACT -->\nx", ...BOT }, ...(o.facts33 ?? [])],
|
|
38
|
+
51: o.facts51 ?? [],
|
|
38
39
|
};
|
|
39
40
|
const prs = { 101: { title: "feat: ranking", body: "Closes #33", head: "feat/issue-33-lean" }, 102: { title: "feat: speedup", body: "", head: "feat/issue-34-lean" }, 103: { title: "chore: logs", body: "", head: "x" } };
|
|
40
41
|
const log = [
|
|
@@ -595,3 +596,28 @@ describe("#5152 builder context: delivered or moved scope never reads as dropped
|
|
|
595
596
|
assert.equal(closedResult({ stateReason: null }), "closed");
|
|
596
597
|
});
|
|
597
598
|
});
|
|
599
|
+
|
|
600
|
+
describe("#5340 sibling-aware context", () => {
|
|
601
|
+
const base = (raw) => parseContextPackConfig(raw ?? {});
|
|
602
|
+
it("a milestone or parent lane defaults to on; explicit modes win; other lanes stay shadow; the parse default is unchanged", () => {
|
|
603
|
+
assert.equal(parseContextPackConfig({}).mode, "shadow");
|
|
604
|
+
assert.equal(resolveContextMode(undefined, base(), { milestone: "M1" }), "on");
|
|
605
|
+
assert.equal(resolveContextMode({}, base(), { parent: 7 }), "on");
|
|
606
|
+
assert.equal(resolveContextMode(undefined, base(), {}), "shadow");
|
|
607
|
+
for (const mode of ["shadow", "off", "ab"]) assert.equal(resolveContextMode({ mode }, base({ mode }), { milestone: "M1" }), mode);
|
|
608
|
+
});
|
|
609
|
+
it("sibling facts and in-flight declarations rank before other lanes' facts; milestone issues are read", async () => {
|
|
610
|
+
const rec = (file, approach) => `<!-- ${FACTS_MARKER} -->\n${renderFactsRecord(normaliseFacts({ facts: { rejected: [{ approach, why: "w" }], hotspots: [{ at: `${file}:1`, why: "h" }] } }, { files: [file] }))}`;
|
|
611
|
+
const BOTC = { author: { login: "forge[bot]" }, authorAssociation: "NONE" };
|
|
612
|
+
const f = fakes({ facts33: [{ id: 5, body: rec("bin/lean/context.mjs", "overlap approach"), ...BOTC }], facts51: [{ id: 6, body: rec("other/file.md", "sibling approach"), ...BOTC }] });
|
|
613
|
+
const gh = f.io.gh;
|
|
614
|
+
f.io.gh = async (a) => (a[0] === "issue" && a[1] === "list" ? JSON.stringify([{ number: 52 }]) : gh(a));
|
|
615
|
+
f.io.declared = async () => [{ issue: 62, surfaces: ["api/routes.ts"], paths: ["api/routes.ts"] }];
|
|
616
|
+
const facts = await gather(f, { milestone: "M1" });
|
|
617
|
+
assert.ok(facts.siblings.includes(51) && facts.siblings.includes(52));
|
|
618
|
+
const t = compileContextPack(facts).text;
|
|
619
|
+
const at = (s) => { const i = t.indexOf(s); assert.ok(i >= 0, `missing ${s}\n${t}`); return i; };
|
|
620
|
+
assert.ok(at("#62 (in flight, sibling) will touch shared surface api/routes.ts") < at("sibling approach"));
|
|
621
|
+
assert.ok(at("sibling approach") < at("overlap approach"), t);
|
|
622
|
+
});
|
|
623
|
+
});
|
package/bin/lean/depcache.mjs
CHANGED
|
@@ -57,6 +57,26 @@ function detect(fs, wt) {
|
|
|
57
57
|
}
|
|
58
58
|
if (has("uv.lock")) out.push({ eco: "uv", lock: "uv.lock" });
|
|
59
59
|
else if (has("poetry.lock")) out.push({ eco: "poetry", lock: "poetry.lock" });
|
|
60
|
+
else out.push(...serviceLocks(fs, wt));
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const SERVICE_ROOTS = ["services", "packages", "apps"];
|
|
65
|
+
const SERVICE_CAP = 8;
|
|
66
|
+
/** #5331: Python lockfiles one level down (services/<name>/uv.lock|poetry.lock) when the root has none; each is prepared in its own dir. */
|
|
67
|
+
function serviceLocks(fs, wt) {
|
|
68
|
+
const out = [];
|
|
69
|
+
for (const root of SERVICE_ROOTS) {
|
|
70
|
+
let names = [];
|
|
71
|
+
try { names = fs.readdirSync(join(wt, root)).sort(); } catch { continue; }
|
|
72
|
+
for (const n of names) {
|
|
73
|
+
const dir = `${root}/${n}`;
|
|
74
|
+
for (const [eco, lock] of [["uv", "uv.lock"], ["poetry", "poetry.lock"]]) {
|
|
75
|
+
if (out.length >= SERVICE_CAP) return out;
|
|
76
|
+
try { if (fs.existsSync(join(wt, dir, lock))) { out.push({ eco, lock, dir }); break; } } catch { /* unreadable: skip */ }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
60
80
|
return out;
|
|
61
81
|
}
|
|
62
82
|
|
|
@@ -108,6 +128,7 @@ export function makeDepCache({ root = depcacheRoot(), exec, fs = nodeFs, now = (
|
|
|
108
128
|
|
|
109
129
|
async function keyOf(wt, d, pkgs) {
|
|
110
130
|
const h = createHash("sha256").update(`v1\0${d.eco}\0${process.platform}-${process.arch}\0`);
|
|
131
|
+
if (d.dir) h.update(`${d.dir}\0`);
|
|
111
132
|
h.update(await runtime(JS.has(d.eco) ? "node" : "python3")).update("\0");
|
|
112
133
|
const files = JS.has(d.eco) ? [d.lock, ...pkgs, "pnpm-workspace.yaml", ".npmrc", ".yarnrc.yml"] : [d.lock, "pyproject.toml", ".python-version"];
|
|
113
134
|
for (const f of files) {
|
|
@@ -281,7 +302,10 @@ export function makeDepCache({ root = depcacheRoot(), exec, fs = nodeFs, now = (
|
|
|
281
302
|
const keyRoot = join(root, safeSegment(repoKey ?? "repo"));
|
|
282
303
|
const out = [];
|
|
283
304
|
for (const d of found) {
|
|
284
|
-
try {
|
|
305
|
+
try {
|
|
306
|
+
const r = await prepareOne(d.dir ? join(wt, d.dir) : wt, keyRoot, d, laneEnv && typeof laneEnv === "object" ? laneEnv : undefined);
|
|
307
|
+
out.push(d.dir ? { ...r, dir: d.dir } : r);
|
|
308
|
+
} catch (e) { out.push({ status: "failed", eco: d.eco, key: null, ms: 0, reason: msg(e) }); }
|
|
285
309
|
}
|
|
286
310
|
return out;
|
|
287
311
|
}
|
|
@@ -423,3 +423,29 @@ describe("depcache (#4347): installs and repairs run with the lane toolchain env
|
|
|
423
423
|
assert.equal(seen[1].env.npm_config_cache, cache.env().npm_config_cache);
|
|
424
424
|
});
|
|
425
425
|
});
|
|
426
|
+
|
|
427
|
+
describe("depcache (#5331): per-service Python lockfiles", () => {
|
|
428
|
+
for (const eco of ["poetry", "uv"]) {
|
|
429
|
+
it(`services/<name>/${eco === "uv" ? "uv" : "poetry"}.lock is prepared in its own dir, never "skipped: no lockfile"`, async () => {
|
|
430
|
+
const { cache, lane, base } = setup(eco);
|
|
431
|
+
const wt = join(base, "wt", "svc");
|
|
432
|
+
mkdirSync(wt, { recursive: true });
|
|
433
|
+
FIXTURES[eco](join(wt, "services/api"));
|
|
434
|
+
const res = await cache.prepare({ wt, repoKey: "repo-svc" });
|
|
435
|
+
assert.equal(res.length, 1, JSON.stringify(res));
|
|
436
|
+
assert.notEqual(res[0].reason, "no lockfile");
|
|
437
|
+
assert.equal(res[0].eco, eco);
|
|
438
|
+
assert.equal(res[0].dir, "services/api");
|
|
439
|
+
assert.ok(["miss-installed", "hit"].includes(res[0].status), JSON.stringify(res[0]));
|
|
440
|
+
assert.ok(existsSync(join(wt, "services/api/.venv")));
|
|
441
|
+
void lane;
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
it("a repo with no lockfile anywhere is still skipped", async () => {
|
|
445
|
+
const { cache, base } = setup("poetry");
|
|
446
|
+
const wt = join(base, "wt", "none");
|
|
447
|
+
mkdirSync(join(wt, "services/api"), { recursive: true });
|
|
448
|
+
const [r] = await cache.prepare({ wt, repoKey: "repo-none" });
|
|
449
|
+
assert.equal(r.reason, "no lockfile");
|
|
450
|
+
});
|
|
451
|
+
});
|