mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 21:53:51 +00:00
* fix(desktop): resolve needed origins before library deduplication
* fix(desktop): resolve library paths through filesystem
* fix(desktop): retain package ownership of required library links
* fix(desktop): traverse hard-linked dependencies once
* fix(ci): isolate expensive capacity regressions from parallel workers
(cherry picked from commit a1f762d1139f51d97130f8c20cfb12d567cced72)
* fix(desktop): preserve complete library lookup semantics
* fix(desktop): retain required directory alias owners
* fix(desktop): preserve ownership across complete library link routes
* fix(desktop): share merged-system ownership lookup for link entries
* test(mcp): observe cleanup failures at their current delivery boundary
* fix(mcp): preserve workflow completion progress through delivery
* test(setup): keep the Windows Kimi profile fixture on a supported profile
The Windows-only case at `clientConfigurationEnvironment.test.ts:226` wrote
`rea_mcp_input_schema_profile: "full"`. That profile was retired: the reader
now refuses it ("REA_MCP_INPUT_SCHEMA_PROFILE accepts only \"compact\" …"),
so `configureClientConfiguration` returned `failed/readback` before writing
and the case failed on every Windows run, including main's own
`Windows capability and package lane`.
The case has no Windows dependency — it passes an explicit `configPath` and
the Kimi write dialect is the same everywhere — so it now runs on every
platform, which is what let the stale value rot unnoticed. The fixture keeps
the lowercase explicit key the case is about, with the supported value.
Verified on `main` `d6bcfc10`: the same fixture driven through
`configureClientConfiguration(..., "win32")` on this host reproduced
`{"status":"failed","reason":"readback"}` with the retired value and now
returns `{"status":"configured"}` with `compact`. The file's 75 cases pass
here (66 run, 9 platform-conditioned skips) and `check:fast` passes.
* test(ci): restore verifier and MCP contract regressions
* test(captures): assert adapter-owned input issue field names
* fix(ghidra): avoid Java probes for missing installations
* fix(desktop): retain all selected leaf ownership spellings
* fix(desktop): retain link target ownership contexts
* fix(desktop): retain successful lookup retries and cancellation
* fix(desktop): preserve library probe failures and cancellation
* fix(desktop): preserve cancellation after lookup refusals
* docs(desktop): clarify library lookup error precedence
* fix(desktop): check library budget before absolute path lookup
* fix(desktop): report each unowned library path once
---------
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
Co-authored-by: g0at <50488370+g1at@users.noreply.github.com>
Co-authored-by: IvenKooLab <276572622@qq.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
182 lines
6.1 KiB
TypeScript
182 lines
6.1 KiB
TypeScript
import * as fs from "node:fs/promises";
|
|
import { dirname, join } from "node:path";
|
|
import { afterEach, expect, it, vi } from "vitest";
|
|
import { inspectLibraryPackages } from "../../../src/desktop/LibraryPackageInventory.js";
|
|
import { elfImage } from "../../../src/domain/desktop/elfImage.fixture.js";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
|
|
vi.mock("node:fs/promises", async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import("node:fs/promises")>();
|
|
return {
|
|
...actual,
|
|
lstat: vi.fn(actual.lstat),
|
|
readlink: vi.fn(actual.readlink),
|
|
realpath: vi.fn(actual.realpath),
|
|
};
|
|
});
|
|
const actual =
|
|
await vi.importActual<typeof import("node:fs/promises")>("node:fs/promises");
|
|
afterEach(() => {
|
|
vi.mocked(fs.lstat).mockReset().mockImplementation(actual.lstat);
|
|
vi.mocked(fs.readlink).mockReset().mockImplementation(actual.readlink);
|
|
vi.mocked(fs.realpath).mockReset().mockImplementation(actual.realpath);
|
|
});
|
|
const fixture = async () => {
|
|
const root = await createTestTempDirectory("rea-library-cancel-lookup-");
|
|
const bin = join(root, "bin"),
|
|
lib = join(root, "lib"),
|
|
alias = join(root, "alias");
|
|
await Promise.all([fs.mkdir(bin), fs.mkdir(lib)]);
|
|
await Promise.all([
|
|
fs.mkdir(join(lib, "sub")),
|
|
fs.mkdir(join(lib, "nested")),
|
|
]);
|
|
await fs.symlink("lib", alias);
|
|
await fs.writeFile(join(lib, "nested", "libchoice.so"), elfImage({}));
|
|
const executable = join(bin, "app");
|
|
await fs.writeFile(
|
|
executable,
|
|
elfImage({ needed: [`${alias}/sub/../nested/libchoice.so`] }),
|
|
);
|
|
return { executable, alias, dotLookup: `${alias}/sub/..` };
|
|
};
|
|
|
|
it
|
|
.skipIf(process.platform === "win32")
|
|
.each(
|
|
(["realpath", "lstat", "readlink"] as const).flatMap((stage) =>
|
|
["EACCES", "EPERM", "EIO"].flatMap((code) =>
|
|
[false, true].map((cancel) => ({ stage, code, cancel })),
|
|
),
|
|
),
|
|
)(
|
|
"preserves executable lookup refusal semantics: %j",
|
|
async ({ stage, code, cancel }) => {
|
|
const { executable } = await fixture();
|
|
const selected = join(dirname(dirname(executable)), "entry");
|
|
// Keep the selected executable itself a link, so every metadata stage can
|
|
// fail before the closure contains any located libraries or package queries.
|
|
await fs.symlink("bin/app", selected);
|
|
const controller = new AbortController(),
|
|
reason = new Error("cancel refusal");
|
|
const failure = Object.assign(new Error("metadata failure"), { code });
|
|
let injected = false;
|
|
const inject = (path: unknown) => {
|
|
if (path !== selected) return;
|
|
injected = true;
|
|
if (cancel) controller.abort(reason);
|
|
throw failure;
|
|
};
|
|
if (stage === "realpath")
|
|
vi.mocked(fs.realpath).mockImplementation(async (...args) => {
|
|
inject(args[0]);
|
|
return actual.realpath(...args);
|
|
});
|
|
else if (stage === "lstat")
|
|
vi.mocked(fs.lstat).mockImplementation(async (...args) => {
|
|
inject(args[0]);
|
|
return actual.lstat(...args);
|
|
});
|
|
else
|
|
vi.mocked(fs.readlink).mockImplementation(async (...args) => {
|
|
inject(args[0]);
|
|
return actual.readlink(...args);
|
|
});
|
|
const query = vi.fn(async (_command: string, _args: readonly string[]) => ({
|
|
stdout: "",
|
|
exitCode: 0,
|
|
}));
|
|
const operation = inspectLibraryPackages(
|
|
selected,
|
|
"app",
|
|
query,
|
|
controller.signal,
|
|
);
|
|
if (code === "EIO") await expect(operation).rejects.toBe(failure);
|
|
else if (cancel)
|
|
await expect(operation).rejects.toMatchObject({
|
|
reason: "cancelled",
|
|
cause: reason,
|
|
});
|
|
else {
|
|
const report = await operation;
|
|
expect(report.library_packages).toEqual([]);
|
|
expect(report.library_packages_reason).toBeDefined();
|
|
}
|
|
expect(injected).toBe(true);
|
|
expect(query.mock.calls.every(([command]) => command === "ldconfig")).toBe(
|
|
true,
|
|
);
|
|
},
|
|
);
|
|
|
|
it
|
|
.skipIf(process.platform === "win32")
|
|
.each(["lstat", "readlink", "realpath"] as const)(
|
|
"stops lookup reads after cancellation delivered with %s completion",
|
|
async (stage) => {
|
|
const { executable, alias, dotLookup } = await fixture();
|
|
const controller = new AbortController();
|
|
const reason = new Error("stop lookup");
|
|
let readsAtAbort = -1;
|
|
const cancel = () => {
|
|
readsAtAbort = vi.mocked(fs.lstat).mock.calls.length;
|
|
controller.abort(reason);
|
|
};
|
|
if (stage === "lstat")
|
|
vi.mocked(fs.lstat).mockImplementation(async (...args) => {
|
|
const value = await actual.lstat(...args);
|
|
if (args[0] === alias) cancel();
|
|
return value;
|
|
});
|
|
else if (stage === "readlink")
|
|
vi.mocked(fs.readlink).mockImplementation(async (...args) => {
|
|
const value = await actual.readlink(...args);
|
|
if (args[0] === alias) cancel();
|
|
return value;
|
|
});
|
|
else
|
|
vi.mocked(fs.realpath).mockImplementation(async (...args) => {
|
|
const value = await actual.realpath(...args);
|
|
if (args[0] === dotLookup) cancel();
|
|
return value;
|
|
});
|
|
await expect(
|
|
inspectLibraryPackages(
|
|
executable,
|
|
"app",
|
|
async () => ({ stdout: "", exitCode: 0 }),
|
|
controller.signal,
|
|
),
|
|
).rejects.toMatchObject({ reason: "cancelled", cause: reason });
|
|
expect(readsAtAbort).toBeGreaterThanOrEqual(0);
|
|
expect(vi.mocked(fs.lstat).mock.calls.length).toBe(readsAtAbort);
|
|
},
|
|
);
|
|
|
|
it.skipIf(process.platform === "win32")(
|
|
"preserves a physical link-read failure racing cancellation",
|
|
async () => {
|
|
const { executable, alias } = await fixture();
|
|
const controller = new AbortController();
|
|
const failure = Object.assign(new Error("readlink I/O failure"), {
|
|
code: "EIO",
|
|
});
|
|
vi.mocked(fs.readlink).mockImplementation(async (...args) => {
|
|
if (args[0] === alias) {
|
|
controller.abort(new Error("cancel while reading"));
|
|
throw failure;
|
|
}
|
|
return actual.readlink(...args);
|
|
});
|
|
await expect(
|
|
inspectLibraryPackages(
|
|
executable,
|
|
"app",
|
|
async () => ({ stdout: "", exitCode: 0 }),
|
|
controller.signal,
|
|
),
|
|
).rejects.toBe(failure);
|
|
},
|
|
);
|