Files
rea/experiments/atomic-re-tools/mapped-code.test.mjs
T
72b24433ea experiment(re): record native sharing and composition counterexamples
Measure twelve equivalent MCP navigation workflows, native reference plans on SQLite/zlib, a compiled interior-reference oracle and a failed exact code-mapping composition. Preserve failed attempts and measurement limits, including unavailable live-agent effectiveness evidence. Add bounded native probes and deterministic mapping tests. All 191 Kuna cases pass serially; nine experiment tests and one-checker typecheck pass.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
2026-10-16 02:59:46 +00:00

57 lines
1.8 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { mappedCode } from "./mapped-code.mjs";
const reference = {
functions: [{ address: "0x1000" }],
sites: [{ from: "0x2000" }, { from: "0x2001" }],
};
const document = () => ({
binary: "/private/input",
count: 1,
functions: [
{
address: 4096,
address_hex: "0x1000",
code: "one\ntwo\nthree\nfour\nfive",
error: null,
line_mappings: [{ line_number: 3, addresses: [8192] }],
},
],
});
const native = (value) => async () => ({
input: "/private/input",
stdout: { text: JSON.stringify(value) },
});
test("a mapped subset names unmapped sites instead of implying complete mapping", async () => {
const result = await mappedCode(native(document()), reference, 1);
assert.equal(result.status, "partial");
assert.deepEqual(result.unmapped_reference_sites, ["0x2001"]);
assert.deepEqual(result.slices, [
{ start_line: 2, end_line: 4, text: "two\nthree\nfour" },
]);
assert.equal(result.coverage.status, "partial");
});
test("unmapped locations never select a nearby printed line", async () => {
const result = await mappedCode(native(document()), {
...reference,
sites: [{ from: "0x1fff" }],
});
assert.equal(result.status, "unknown");
});
test("unsafe numeric address arrays stay unknown without lossy conversion", async () => {
const value = document();
value.functions[0].line_mappings[0].addresses = [Number.MAX_SAFE_INTEGER + 1];
const result = await mappedCode(native(value), reference);
assert.equal(result.status, "unknown");
});
test("malformed line locations reject the view before publishing fragments", async () => {
const value = document();
value.functions[0].line_mappings[0].line_number = 99;
await assert.rejects(mappedCode(native(value), reference));
});