Files
rea/experiments/atomic-codemode/function-facts.mjs
T
15d75ea1ea fix(experiment): preserve cached fact ownership for SDK callers
Freeze parsed inventories once at their owning boundary and share the rule with native IR and function views. Verify the real SDK mutation regression and retain corrected equal-depth SQLite model costs, including persistent-cache limitations.

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 06:07:46 +00:00

34 lines
1.1 KiB
JavaScript

import { parseKunaInventory } from "../../dist/kuna/KunaProjectFiles.js";
import { requireResult } from "./fact-error.mjs";
import { freezeFacts, pageFacts } from "./fact-reads.mjs";
export const parseFunctionFacts = (text) =>
freezeFacts(
requireResult(parseKunaInventory(text), "invalid_provider_output"),
);
export function selectFunctionFacts(functions, input) {
const addresses = input.addresses && new Set(input.addresses);
const normalize = (name) =>
input.case_sensitive ? name : name.toLowerCase();
const query = normalize(input.query);
const matches = functions.filter(
(entry) =>
(!addresses || addresses.has(entry.address)) &&
[entry.name, ...entry.aliases].some((name) =>
input.exact
? normalize(name) === query
: normalize(name).includes(query),
),
);
return {
...pageFacts(matches, input, ["address"]),
coverage: {
scope: "native callable-entry inventory, including import stubs",
discovery: "unknown",
extents: "upper bounds clipped at the next entry; zero means unmeasured",
symbol_binding_at_runtime: "unknown",
},
};
}