Release Schema Tools v0.1.1

This commit is contained in:
2026-09-01 14:58:06 +02:00
parent 236b9e62c4
commit 2f60a6d0a7
21 changed files with 264 additions and 65 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ test("serves release identity and hardened headers", async ({ request }) => {
const manifest = await request.get("/deep/nested/schema/toolbox-app.json");
await expect(manifest.json()).resolves.toMatchObject({
id: "de.add-ideas.schema-tools",
version: "0.1.0",
version: "0.1.1",
entry: "./",
privacy: { processing: "local", telemetry: false },
});
+46
View File
@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import {
SCHEMA_LIMITS,
compareSchemas,
generateSample,
inspectWorkspace,
@@ -60,6 +61,51 @@ describe("schema workspace", () => {
expect(invalid.diagnostics[0]?.message).toContain("required");
});
it("bounds repeated large literal samples reached through local references", () => {
const properties = Object.fromEntries(
Array.from({ length: 100 }, (_, index) => [
`value${index}`,
{ $ref: "literal.json#/$defs/large" },
]),
);
const workspace = inspectWorkspace([
{
name: "root.json",
source: JSON.stringify({
type: "object",
required: Object.keys(properties),
properties,
}),
},
{
name: "literal.json",
source: JSON.stringify({
$defs: { large: { default: "x".repeat(100_000) } },
}),
},
]);
const sample = generateSample(workspace);
const values = Object.values(JSON.parse(sample.output) as object);
expect(sample.output.length).toBeLessThanOrEqual(
SCHEMA_LIMITS.sampleOutputChars,
);
expect(values).toHaveLength(100);
expect(
values.every(
(value) => String(value).length <= SCHEMA_LIMITS.sampleValueChars,
),
).toBe(true);
expect(sample.notices.join("\n")).toMatch(/truncated.*safety bound/iu);
});
it("refuses to claim a sample for the always-invalid false schema", () => {
const workspace = inspectWorkspace([
{ name: "impossible.json", source: "false" },
]);
expect(() => generateSample(workspace)).toThrow(/no valid sample/iu);
});
it("blocks remote and missing references without attempting resolution", () => {
const workspace = inspectWorkspace([
{