mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 04:34:13 +00:00
fix: isolate concurrent doctor cleanup scopes, trace JS fixture helpers, and share MCP/home lifecycles
Address all four PR review findings structurally: - Isolate concurrent Doctor probes and host subsystems in child ArtifactResourceScope instances tracked via resources.track() so a failed cleanup on one probe cannot deadlock or abort sibling reads before close(). - Include tests/ JS/TS helper modules and fixture path literals in throughHelpers() and named() so changes to JS fixtures such as fakeHopperReplies.mjs reach transitive helper and socket tests. - Extract generic createSharedMcpSession() and reuse it in lazyLocalToolsMcp() to preserve retryable cleanup draining and startup-failure attribution. - Replace test-scoped createTestTempDirectory() with a file-scoped workspace in jsonInputStatus.test.ts so the shared isolated home persists across tests.
This commit is contained in:
1 parent
455c269566
commit
116f159a8a
10 files changed
+443
-289
No files matched your search
@@ -97,7 +97,8 @@ const isModule = (path) =>
|
||||
// Production importers never widen the selection transitively.
|
||||
const isHelper = (path) =>
|
||||
!isTest(path) &&
|
||||
(/^tests\/.+\.m?ts$/u.test(path) ||
|
||||
!isCheckerInput(path) &&
|
||||
(/^tests\/.+\.(?:[cm]?[jt]s|d\.m?ts)$/u.test(path) ||
|
||||
/^src\/.+\.fixture[^/]*\.ts$/u.test(path) ||
|
||||
isVerifier(path) ||
|
||||
isScriptLibrary(path));
|
||||
@@ -199,19 +200,25 @@ export function traceAffectedTests({ files, snapshot }) {
|
||||
}
|
||||
}
|
||||
|
||||
// A seed and every helper that imports it, directly or through another.
|
||||
const isNamedTarget = (path) =>
|
||||
path.startsWith("scripts/") || path.startsWith("tests/fixtures/");
|
||||
// A seed and every helper that imports or names it, directly or through another.
|
||||
const throughHelpers = (seed) => {
|
||||
const reached = new Set(seed);
|
||||
for (let grew = true; grew;) {
|
||||
grew = false;
|
||||
for (const helper of helpers)
|
||||
const namedReached = [...reached].filter(isNamedTarget);
|
||||
for (const helper of helpers) {
|
||||
if (reached.has(helper)) continue;
|
||||
const source = sources.get(helper) ?? "";
|
||||
if (
|
||||
!reached.has(helper) &&
|
||||
imports.get(helper).some((target) => reached.has(target))
|
||||
imports.get(helper).some((target) => reached.has(target)) ||
|
||||
namedReached.some((target) => source.includes(target))
|
||||
) {
|
||||
reached.add(helper);
|
||||
grew = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return reached;
|
||||
};
|
||||
@@ -224,13 +231,10 @@ export function traceAffectedTests({ files, snapshot }) {
|
||||
for (const test of tests)
|
||||
if (imports.get(test).some((target) => affected.has(target)))
|
||||
select(test, "imports");
|
||||
// Script paths a test can start or read by name: changed files, plus the
|
||||
// verifiers and shared modules a change reaches.
|
||||
// Script and fixture paths a test can start or read by name: changed files,
|
||||
// plus the verifiers, shared modules and fixtures a change reaches.
|
||||
const named = (reached) => [
|
||||
...new Set([
|
||||
...files,
|
||||
...[...reached].filter((path) => path.startsWith("scripts/")),
|
||||
]),
|
||||
...new Set([...files, ...[...reached].filter(isNamedTarget)]),
|
||||
];
|
||||
const names = (test, paths) =>
|
||||
paths.some((path) => (sources.get(test) ?? "").includes(path));
|
||||
@@ -240,10 +244,7 @@ export function traceAffectedTests({ files, snapshot }) {
|
||||
// fails closed to the complete suite.
|
||||
for (const fixture of changedNonModuleFixtures) {
|
||||
const reached = throughHelpers([fixture]);
|
||||
const paths = [
|
||||
fixture,
|
||||
...[...reached].filter((path) => path.startsWith("scripts/")),
|
||||
];
|
||||
const paths = [fixture, ...[...reached].filter(isNamedTarget)];
|
||||
if (
|
||||
!tests.some(
|
||||
(test) =>
|
||||
|
||||
Reference in new issue
Block a user