Files
rea/tests/boundary/process/regexMatcher.test.ts
T
morluto d8a9673fc4 fix(process): name the Swift compile deadline (#6071)
Name REA_SWIFTC_COMPILE_TIMEOUT_MS, its effective milliseconds, the
1..2147483647 range, and the omitted 120000 ms default when a Darwin
ownership-helper compile times out. A change applies after REA restarts,
on the next ownership-helper compile.

Producer SIGXCPU and SIGXFSZ recovery says REA retains the tighter
inherited limit. Agent-visible fixed caps in this theme say this release
has no runtime override. Numbers are unchanged.

Refs #5910

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-10-21 23:46:29 +08:00

87 lines
2.9 KiB
TypeScript

import { expect, it } from "vitest";
import { ok } from "../../../src/domain/result.js";
import { HopperRegexSearch } from "../../../src/hopper/HopperRegexSearch.js";
import { OFFICIAL_TOOL_CONTRACTS } from "../../../src/contracts/officialToolContracts.js";
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
import {
matchRegexValues,
REGEX_MATCHING_LIMITATION,
regexMatchingDeadlineError,
regexWorkerHeapError,
} from "../../../src/process/RegexMatcher.js";
it("names the fixed regex deadline and heap and says neither has an override", () => {
expect(REGEX_MATCHING_LIMITATION).toContain("5-second matching deadline");
expect(REGEX_MATCHING_LIMITATION).toContain("128 MiB");
expect(REGEX_MATCHING_LIMITATION).toContain(
"This release has no runtime override",
);
const deadline = projectAnalysisError(
regexMatchingDeadlineError("search_procedures"),
);
expect(deadline.message).toContain("5000 ms");
expect(deadline.remediation.action).toContain(
"this release has no runtime override",
);
const heap = projectAnalysisError(
regexWorkerHeapError("search_procedures", new Error("heap")),
);
expect(heap.message).toContain("128 MiB");
expect(heap.remediation.action).toContain(
"additional host memory do not raise it",
);
for (const name of ["search_procedures", "search_strings"] as const) {
const description = OFFICIAL_TOOL_CONTRACTS.find(
(tool) => tool.name === name,
)?.description;
expect(description).toContain("5000 ms");
expect(description).toContain("no runtime override");
}
});
it("preserves Unicode matching order and refuses a pre-cancelled match", async () => {
expect(
await matchRegexValues({
operation: "search_procedures",
pattern: "^δ",
caseSensitive: false,
values: ["Δelta", "delta", "δίκη"],
}),
).toEqual(ok([0, 2]));
expect(
await matchRegexValues({
operation: "search_procedures",
pattern: ".",
caseSensitive: true,
values: ["value"],
signal: AbortSignal.abort(),
}),
).toMatchObject({ ok: false, error: { _tag: "AnalysisCancelledError" } });
});
it("keeps Hopper's result projection and invalid-pattern contract with the shared worker", async () => {
const search = new HopperRegexSearch({
callTool: async () =>
ok([
{ address: "0x10", value: "Δelta" },
{ address: "0x20", value: "other" },
]),
});
expect(
await search.execute("search_strings", { pattern: "^δ", mode: "regex" }),
).toEqual(ok([{ address: "0x10", value: "Δelta" }]));
expect(
await search.execute("search_strings", { pattern: "[", mode: "regex" }),
).toMatchObject({
ok: false,
error: {
_tag: "HopperRemoteError",
code: -32000,
diagnosticType: "invalid_request",
operation: "search_strings",
},
});
await search.close();
});