mirror of
https://github.com/morluto/rea
synced 2026-10-27 06:33:32 -04:00
7054bbb9ab
Add cached, reference-free Kuna string inventories through existing CLI/MCP operations. Preserve exact addresses, typed facts, selected Evidence and bounded query lifecycles; validate native fields and caller-specific failures. Verified with real Linux SQLite, zlib, printf and Unicode/empty ELF targets, 194 focused regressions and all 38 CI checks. Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { KunaQueryWork } from "../../../../src/kuna/KunaQueryWork.js";
|
|
import { KunaRunSlots } from "../../../../src/kuna/KunaRunSlots.js";
|
|
import { KunaTargetCommands } from "../../../../src/kuna/KunaTargetCommands.js";
|
|
|
|
it("does not materialize values for a cancelled queued regex query", async () => {
|
|
const lifetime = new AbortController();
|
|
// This test exercises worker admission only; no native command reads this target.
|
|
const commands = new KunaTargetCommands(
|
|
{
|
|
path: "/unused/program",
|
|
sha256: "a".repeat(64),
|
|
kind: "executable",
|
|
format: "elf",
|
|
architecture: "x86_64",
|
|
availableArchitectures: ["x86_64"],
|
|
},
|
|
{ signal: lifetime.signal },
|
|
);
|
|
const work = new KunaQueryWork(commands, {
|
|
signal: lifetime.signal,
|
|
own: (promise) => promise,
|
|
runSlots: new KunaRunSlots(1),
|
|
});
|
|
let admitted!: () => void;
|
|
const ready = new Promise<void>((resolve) => {
|
|
admitted = resolve;
|
|
});
|
|
const slow = work.match({
|
|
operation: "search_strings",
|
|
pattern: "^(a+)+$",
|
|
caseSensitive: true,
|
|
values: () => {
|
|
admitted();
|
|
return [`${"a".repeat(40)}!`];
|
|
},
|
|
});
|
|
try {
|
|
await ready;
|
|
const cancelled = new AbortController();
|
|
let materialized = false;
|
|
const queued = work.match({
|
|
operation: "search_procedures",
|
|
pattern: "value",
|
|
caseSensitive: true,
|
|
signal: cancelled.signal,
|
|
values: () => {
|
|
materialized = true;
|
|
return ["value"];
|
|
},
|
|
});
|
|
cancelled.abort();
|
|
expect(await queued).toMatchObject({
|
|
ok: false,
|
|
error: { _tag: "AnalysisCancelledError" },
|
|
});
|
|
expect(materialized).toBe(false);
|
|
lifetime.abort();
|
|
expect(await slow).toMatchObject({
|
|
ok: false,
|
|
error: { _tag: "AnalysisCancelledError" },
|
|
});
|
|
} finally {
|
|
lifetime.abort();
|
|
await slow;
|
|
expect(await commands.close()).toEqual({ ok: true, value: null });
|
|
}
|
|
});
|