mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 13:45:30 +00:00
* fix(artifacts): preserve iNES shutdown ownership and I/O failures
* test(cli): publish complete doctor readiness before cancellation
* test(mcp): observe cleanup failures at their current delivery boundary
* fix(mcp): preserve workflow completion progress through delivery
* test(ci): assert current MCP and evidence ownership contracts
* 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
* test(capture): retain final cleanup progress assertions
* fix(artifacts): keep iNES shutdown ownership free of unrelated edits
The doctor readiness fixture and process-capture progress assertions
are not required by descriptor retirement or I/O failure precedence.
Restoring them, and the Ghidra installation test already merged in
#11732, leaves this change on the iNES reader, chunk reader, and
their regressions. The unused artifact chunk helper import is removed.
Co-authored-by: morluto <morluto@users.noreply.github.com>
* test(artifacts): age the iNES header race before same-size rewrites
Identity checks observe mtime, and a same-size overwrite inside one
clock tick is indistinguishable from the original file. The admission
test then reports a format error instead of source integrity. Age the
fixture the same way the prefix race already does.
* test(go): assert truncated Mach-O command tables by typed failure
An unstored oversized command table is a truncated Mach-O load-command
parse, projected as invalid_format. The old message lock named a
sentence the parser no longer produces.
Co-authored-by: morluto <morluto@users.noreply.github.com>
* test(artifacts): fold the paused iNES inventory close into the existing case
The standalone close test repeated the paused entries() refusal already
covered by the close/cancel pair. The borrowed-descriptor stat stays on
that close case.
Co-authored-by: morluto <morluto@users.noreply.github.com>
* fix(artifacts): preserve first iNES stream interruption
---------
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: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
177 lines
6.1 KiB
TypeScript
177 lines
6.1 KiB
TypeScript
import type { FileHandle } from "node:fs/promises";
|
|
import { open, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { buffer } from "node:stream/consumers";
|
|
import { expect, it, vi } from "vitest";
|
|
import { withVerifierCleanup } from "../../../scripts/lib/verifier-cleanup.mjs";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { phaseGate } from "../../support/lifecycleHarness.js";
|
|
import {
|
|
FileReadCancelled,
|
|
readFileHandleChunks,
|
|
} from "../../../src/filesystem/readFileHandleChunks.js";
|
|
|
|
it.each(["complete", "fail"])(
|
|
"settles the pending descriptor read before cancellation: %s",
|
|
async (outcome) => {
|
|
const descriptorRead = phaseGate<
|
|
void,
|
|
{ bytesRead: number; buffer: Buffer }
|
|
>();
|
|
const read = vi.fn(() =>
|
|
descriptorRead.hold(),
|
|
) as unknown as FileHandle["read"];
|
|
const controller = new AbortController();
|
|
const source = readFileHandleChunks(
|
|
{ read },
|
|
{ signal: controller.signal },
|
|
);
|
|
let settled = false;
|
|
const result = buffer(source)
|
|
.catch((cause: unknown) => cause)
|
|
.finally(() => {
|
|
settled = true;
|
|
});
|
|
await withVerifierCleanup(async () => {
|
|
await descriptorRead.reached(result, "descriptor read");
|
|
controller.abort(null);
|
|
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
expect(settled).toBe(false);
|
|
expect(source.destroyed).toBe(false);
|
|
const failure = new Error("controlled native read failure");
|
|
if (outcome === "fail") descriptorRead.reject(failure);
|
|
else descriptorRead.release({ bytesRead: 0, buffer: Buffer.alloc(0) });
|
|
const error = await result;
|
|
if (outcome === "fail") expect(error).toBe(failure);
|
|
else {
|
|
expect(error).toBeInstanceOf(FileReadCancelled);
|
|
if (error instanceof FileReadCancelled) expect(error.reason).toBeNull();
|
|
}
|
|
expect(read).toHaveBeenCalledTimes(1);
|
|
}, [
|
|
() => controller.abort(null),
|
|
() => descriptorRead.release({ bytesRead: 0, buffer: Buffer.alloc(0) }),
|
|
async () => {
|
|
await result;
|
|
},
|
|
]);
|
|
},
|
|
);
|
|
|
|
it.each([false, true])(
|
|
"cancels an unconsumed stream without admitting a read (already aborted: %s)",
|
|
async (alreadyAborted) => {
|
|
const controller = new AbortController();
|
|
const reason = new Error("caller cancellation");
|
|
const read = vi.fn() as unknown as FileHandle["read"];
|
|
if (alreadyAborted) controller.abort(reason);
|
|
const source = readFileHandleChunks(
|
|
{ read },
|
|
{ signal: controller.signal },
|
|
);
|
|
const failed = new Promise<Error>((resolve) =>
|
|
source.once("error", resolve),
|
|
);
|
|
if (!alreadyAborted) controller.abort(reason);
|
|
const error = await failed;
|
|
expect(error).toBeInstanceOf(FileReadCancelled);
|
|
if (error instanceof FileReadCancelled) expect(error.reason).toBe(reason);
|
|
expect(read).not.toHaveBeenCalled();
|
|
},
|
|
);
|
|
|
|
it("removes cancellation observation after normal stream completion", async () => {
|
|
const controller = new AbortController();
|
|
const remove = vi.spyOn(controller.signal, "removeEventListener");
|
|
const read = vi.fn(async () => ({
|
|
bytesRead: 0,
|
|
buffer: Buffer.alloc(0),
|
|
})) as unknown as FileHandle["read"];
|
|
const source = readFileHandleChunks({ read }, { signal: controller.signal });
|
|
expect(Buffer.compare(await buffer(source), Buffer.alloc(0))).toBe(0);
|
|
expect(remove).toHaveBeenCalledWith("abort", expect.any(Function));
|
|
controller.abort(null);
|
|
expect(source.errored).toBeNull();
|
|
});
|
|
|
|
it.each([false, true])(
|
|
"preserves a rejected descriptor read before error forwarding (same reason: %s)",
|
|
async (sameReason) => {
|
|
const root = await createTestTempDirectory("rea-read-rejection-forward-");
|
|
const path = join(root, "write-only");
|
|
await writeFile(path, "inert bytes");
|
|
const handle = await open(path, "w");
|
|
const controller = new AbortController();
|
|
const original = handle.read.bind(handle);
|
|
const reason = new Error("caller cancelled after read rejection");
|
|
let physical: unknown;
|
|
const read = vi
|
|
.spyOn(handle, "read")
|
|
.mockImplementationOnce(async (...args) => {
|
|
try {
|
|
return await original(...args);
|
|
} catch (cause: unknown) {
|
|
physical = cause;
|
|
queueMicrotask(() =>
|
|
queueMicrotask(() => controller.abort(sameReason ? cause : reason)),
|
|
);
|
|
throw cause;
|
|
}
|
|
});
|
|
try {
|
|
const source = readFileHandleChunks(handle, {
|
|
signal: controller.signal,
|
|
});
|
|
const outcome: unknown = await buffer(source).catch(
|
|
(cause: unknown) => cause,
|
|
);
|
|
expect(physical).toBeInstanceOf(Error);
|
|
expect(outcome).toBe(physical);
|
|
expect(controller.signal.aborted).toBe(true);
|
|
expect(source.readCoverage()).toEqual({ kind: "incomplete", bytes: 0n });
|
|
expect(read).toHaveBeenCalledOnce();
|
|
} finally {
|
|
read.mockRestore();
|
|
await handle.close();
|
|
}
|
|
},
|
|
);
|
|
|
|
it.each(["range", "eof"])(
|
|
"retains physical %s coverage independently of stream delivery",
|
|
async (boundary) => {
|
|
let calls = 0;
|
|
const read = (async (
|
|
target: Buffer,
|
|
_offset: number,
|
|
length: number,
|
|
position: bigint,
|
|
) => {
|
|
calls++;
|
|
expect(position).toBe(calls === 1 ? 5n : 6n);
|
|
if (boundary === "eof" && calls === 2)
|
|
return { bytesRead: 0, buffer: target };
|
|
const bytes = boundary === "range" ? 3 : 1;
|
|
target.fill(0x61, 0, bytes);
|
|
expect(length).toBe(3);
|
|
return { bytesRead: bytes, buffer: target };
|
|
}) as FileHandle["read"];
|
|
const source = readFileHandleChunks({ read }, { start: 5, end: 7 });
|
|
expect(source.readCoverage()).toEqual({ kind: "incomplete", bytes: 0n });
|
|
expect(
|
|
Buffer.compare(
|
|
await buffer(source),
|
|
Buffer.alloc(boundary === "range" ? 3 : 1, 0x61),
|
|
),
|
|
).toBe(0);
|
|
const coverage = source.readCoverage();
|
|
expect(coverage).toEqual({
|
|
kind: "complete",
|
|
bytes: boundary === "range" ? 3n : 1n,
|
|
boundary,
|
|
});
|
|
expect(Object.isFrozen(coverage)).toBe(true);
|
|
expect(calls).toBe(boundary === "range" ? 1 : 2);
|
|
},
|
|
);
|