mirror of
https://github.com/morluto/rea.git
synced 2026-11-07 07:16:13 +00:00
* feat(python): query retained pyc code-object facts * test(python): bind complete pyc selection benchmark tasks * test(python): include server instructions in token accounting * docs(perf): record pyc selected-facts task measurements * test(python): keep oracle dependencies separate from selected targets * docs(perf): record guarded oracle requalification * test(python): narrow complete Evidence through its owning contract
59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
import { Ajv2020 } from "ajv/dist/2020.js";
|
|
import { Ajv } from "ajv";
|
|
import { expect, it } from "vitest";
|
|
import { toolContract } from "./toolContracts.js";
|
|
import { toolInputSchemaWithMetadata } from "./toolSchemaMetadata.js";
|
|
|
|
const view = {
|
|
kind: "python-pyc",
|
|
collection: "code_objects",
|
|
fields: ["name"],
|
|
};
|
|
|
|
it.each(["draft-2020-12", "draft-07"] as const)(
|
|
"advertises pyc delivery combinations in %s",
|
|
(target) => {
|
|
const contract = toolContract("inspect_python_pyc");
|
|
const projected = toolInputSchemaWithMetadata(contract)[
|
|
"~standard"
|
|
].jsonSchema.input({ target });
|
|
const ajv =
|
|
target === "draft-2020-12"
|
|
? new Ajv2020({ strict: false, validateFormats: false })
|
|
: new Ajv({ strict: false, validateFormats: false });
|
|
expect(ajv.validateSchema(projected)).toBe(true);
|
|
expect(projected).toMatchObject({ type: "object" });
|
|
for (const key of ["anyOf", "oneOf", "allOf", "x-rea-root-discriminator"])
|
|
expect(projected).not.toHaveProperty(key);
|
|
const validate = ajv.compile(projected);
|
|
for (const [delivery, valid] of [
|
|
[{}, true],
|
|
[{ detail: "complete" }, true],
|
|
[{ detail: "summary" }, true],
|
|
[{ detail: "summary", view }, true],
|
|
[
|
|
{
|
|
detail: "summary",
|
|
view: { ...view, names: [], fields: [], indices: [] },
|
|
},
|
|
true,
|
|
],
|
|
[{ view }, false],
|
|
[{ detail: "complete", view }, false],
|
|
[{ detail: "summary", view: { ...view, fields: ["missing"] } }, false],
|
|
[{ detail: "summary", view: { ...view, kind: "native-exports" } }, false],
|
|
[{ detail: "summary", view, unexpected: true }, false],
|
|
] as const) {
|
|
const input = { path: "/tmp/module.pyc", ...delivery };
|
|
expect(
|
|
contract.inputSchema.safeParse(input).success,
|
|
JSON.stringify(input),
|
|
).toBe(valid);
|
|
expect(
|
|
validate(input),
|
|
JSON.stringify({ input, errors: validate.errors }),
|
|
).toBe(valid);
|
|
}
|
|
},
|
|
);
|