Files
rea/experiments/atomic-codemode/function-facts.mjs
T
f3f209d03f experiment(re)!: preserve partial captures and resolve function entries
Keep validated code available when native graph extraction is unavailable, bind output to the actual input/entry, preserve cancellation observations, and share batch source/error semantics. Add filtered function/alias reads and slice field selection across adapters.

Verified 38 focused tests, targeted lint, real stock/native MCP workflows, large SQLite graph-capacity fallback, and real cold/warm MCP reuse. Retain actual model costs and unequal-depth/selection limitations instead of claiming general superiority.

BREAKING CHANGE: Experimental native snapshots may succeed with readable code and an unavailable recovered_ir facet. Inspect facets before graph reads; unavailable graph counts are null/unknown.

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 05:48:03 +00:00

37 lines
1.2 KiB
JavaScript

import { parseKunaInventory } from "../../dist/kuna/KunaProjectFiles.js";
import { requireResult } from "./fact-error.mjs";
import { pageFacts } from "./fact-reads.mjs";
export const parseFunctionFacts = (text) =>
Object.freeze(
requireResult(parseKunaInventory(text), "invalid_provider_output").map(
(entry) =>
Object.freeze({ ...entry, aliases: Object.freeze([...entry.aliases]) }),
),
);
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",
},
};
}