chore: sync the frontend template from 4dc033c to 8157ad4
The product was materialized from the template at `4dc033c` and has stayed on it through 43 template commits, so it was missing all three rounds of adapter remediation — including files it never had, such as the shared `abortable-operation` primitive and the `exact-snapshot` decoder that later fixes are written against. Taking only the newest round was not possible for that reason: the delta is coherent only as a whole. The product had not touched `src/adapters` at all since materialization, so the 140-file delta applied with a three-way merge and no conflicts. `package.json` was the single overlap and merged cleanly: the product owns `name`, the template contributed `check:adapter-inventory`, `check:remediation-ledger` and the image-resolve-signal type fixture. All 24 product-owned files — README, index.html, CI workflow, i18n catalog, home page, generated schemas, evidence scripts, component and visual snapshots — are byte-identical to `main`. `template.lock.json` now pins the synced revision and tree. Verified in this repository, not inherited from the template: six type projects, lint, nine gates (adapter inventory, remediation ledger, registries, diagnostics, realtime boundaries, architecture, browser file/storage boundaries, optional recipes, documentation), the production build, and 2,054 of 2,073 tests. The 19 failures are all in `tests/unit/ci-artifact-contract.test.ts` and are the same pre-existing sandbox RLIMIT, EMFILE, umask and `/tmp` permission behaviour the template records; four suites that failed once under parallel load pass in isolation. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
002ba3624e
commit
4bff9ca151
@@ -203,6 +203,7 @@ describe("production image CDN runtime", () => {
|
||||
const resolved = await runtime.presentation.resolve({
|
||||
asset: accepted.value,
|
||||
preset,
|
||||
signal: new AbortController().signal,
|
||||
});
|
||||
expect(resolved.ok).toBe(true);
|
||||
if (!resolved.ok) return;
|
||||
@@ -317,10 +318,11 @@ describe("production image CDN runtime", () => {
|
||||
runtime.presentation.resolve({
|
||||
asset: accepted.value,
|
||||
preset,
|
||||
signal: new AbortController().signal,
|
||||
width: 9_999,
|
||||
query: "format=svg",
|
||||
src: "data:text/html,active",
|
||||
} as Parameters<typeof runtime.presentation.resolve>[0]),
|
||||
} as unknown as Parameters<typeof runtime.presentation.resolve>[0]),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "INVALID_INPUT" },
|
||||
@@ -332,6 +334,7 @@ describe("production image CDN runtime", () => {
|
||||
"card-landscape",
|
||||
"render-public-product-image",
|
||||
),
|
||||
signal: new AbortController().signal,
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
@@ -341,6 +344,7 @@ describe("production image CDN runtime", () => {
|
||||
runtime.presentation.resolve({
|
||||
asset: {} as typeof accepted.value,
|
||||
preset,
|
||||
signal: new AbortController().signal,
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
@@ -385,6 +389,7 @@ describe("production image CDN runtime", () => {
|
||||
const resolved = await runtime.presentation.resolve({
|
||||
asset: accepted.value,
|
||||
preset: presetReference,
|
||||
signal: new AbortController().signal,
|
||||
});
|
||||
expect(resolved.ok).toBe(true);
|
||||
if (!resolved.ok) return;
|
||||
@@ -782,6 +787,7 @@ describe("production image CDN runtime", () => {
|
||||
runtime.presentation.resolve({
|
||||
asset: accepted.value,
|
||||
preset,
|
||||
signal: new AbortController().signal,
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
@@ -840,6 +846,7 @@ describe("production image CDN runtime", () => {
|
||||
runtime.presentation.resolve({
|
||||
asset: accepted.value,
|
||||
preset: lazy,
|
||||
signal: new AbortController().signal,
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
@@ -999,7 +1006,13 @@ describe("production image CDN runtime", () => {
|
||||
expect(abortDeadline.clearTimeout).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("bounds concurrent capability verification and releases the slot after abort", async () => {
|
||||
/**
|
||||
* TR-RR-07. The concurrency cap exists to bound *physical* verification work.
|
||||
* Releasing the slot when the wrapper's abort resolved let an abandoned
|
||||
* verifier keep running while a new one was admitted, so repeated aborts
|
||||
* produced more concurrent work than the configured cap allows.
|
||||
*/
|
||||
it("holds the verification slot until the raw verifier settles", async () => {
|
||||
const preset = imageCdnPresetReference(
|
||||
"verification-concurrency",
|
||||
"bound-image-verification-concurrency",
|
||||
@@ -1011,10 +1024,13 @@ describe("production image CDN runtime", () => {
|
||||
},
|
||||
});
|
||||
let verificationAttempt = 0;
|
||||
let releaseFirst: ((value: boolean) => void) | undefined;
|
||||
const verify = vi.fn(() => {
|
||||
verificationAttempt += 1;
|
||||
return verificationAttempt === 1
|
||||
? new Promise<boolean>(() => undefined)
|
||||
? new Promise<boolean>((resolve) => {
|
||||
releaseFirst = resolve;
|
||||
})
|
||||
: Promise.resolve(true);
|
||||
});
|
||||
const runtime = createImageCdnRuntime({
|
||||
@@ -1047,9 +1063,24 @@ describe("production image CDN runtime", () => {
|
||||
ok: false,
|
||||
error: { code: "ABORTED" },
|
||||
});
|
||||
|
||||
// The caller's wait ended, but the raw verifier has not. Admitting a second
|
||||
// one here would put two physical verifications under a cap of one.
|
||||
await expect(
|
||||
runtime.assets.acceptBackendIssued(issued),
|
||||
).resolves.toMatchObject({ ok: true });
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "LIMIT_EXCEEDED" },
|
||||
});
|
||||
expect(verify).toHaveBeenCalledOnce();
|
||||
|
||||
// Once the raw verifier settles the slot is free again.
|
||||
releaseFirst?.(true);
|
||||
await vi.waitFor(async () => {
|
||||
await expect(
|
||||
runtime.assets.acceptBackendIssued(issued),
|
||||
).resolves.toMatchObject({ ok: true });
|
||||
});
|
||||
expect(verify).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
@@ -1110,6 +1141,7 @@ describe("production image CDN runtime", () => {
|
||||
runtime.presentation.resolve({
|
||||
asset: accepted.value,
|
||||
preset,
|
||||
signal: new AbortController().signal,
|
||||
}),
|
||||
).resolves.toMatchObject({ ok: true });
|
||||
const acceptedPrivate =
|
||||
@@ -1125,6 +1157,7 @@ describe("production image CDN runtime", () => {
|
||||
runtime.presentation.resolve({
|
||||
asset: accepted.value,
|
||||
preset,
|
||||
signal: new AbortController().signal,
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
@@ -1479,6 +1512,10 @@ describe("browser image probe", () => {
|
||||
close: vi.fn(),
|
||||
}));
|
||||
for (const cacheControl of [
|
||||
// BT-IMG-02. Unmatched quotes must not be unwrapped into a bare number.
|
||||
'public, max-age="31536000, immutable',
|
||||
'public, max-age=31536000", immutable',
|
||||
'public, max-age="31536000\\", immutable',
|
||||
"public, public, max-age=31536000, immutable",
|
||||
"public, max-age=31536000, s-maxage=60, immutable",
|
||||
"public, max-age=31536000, immutable, must-revalidate",
|
||||
@@ -1645,7 +1682,9 @@ describe("browser image probe", () => {
|
||||
responseAt(imageUrl, png, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"cache-control": "private, no-store",
|
||||
// TR-RR-09. A private response carries `no-store` and nothing else
|
||||
// that describes cacheability.
|
||||
"cache-control": "no-store",
|
||||
"content-type": "image/png",
|
||||
},
|
||||
}),
|
||||
@@ -1735,6 +1774,67 @@ describe("browser image probe", () => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* TR-RR-09. The recorded BT-IMG-02 contract for a private response is a
|
||||
* fail-closed matrix. Accepting `no-store` next to a directive that describes
|
||||
* cacheability lets a self-contradictory policy read as acceptable.
|
||||
*/
|
||||
it("applies the full private Cache-Control matrix", async () => {
|
||||
const png = pngBytes(640, 360);
|
||||
const probeWith = async (cacheControl: string) => {
|
||||
const probe = createBrowserImageProbe({
|
||||
fetcher: (async () =>
|
||||
responseAt(imageUrl, png, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"cache-control": cacheControl,
|
||||
"content-type": "image/png",
|
||||
},
|
||||
})) as typeof fetch,
|
||||
createBitmap: async () => ({
|
||||
width: 640,
|
||||
height: 360,
|
||||
close: vi.fn(),
|
||||
}),
|
||||
});
|
||||
return await probe.probe(
|
||||
request({
|
||||
delivery: "PRIVATE_SIGNED",
|
||||
minimumPublicMaxAgeSeconds: 0,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
// Only `no-store`, plus a syntactically valid unknown extension.
|
||||
expect(await probeWith("no-store")).toMatchObject({ ok: true });
|
||||
expect(await probeWith('no-store, x-vendor="a,b"')).toMatchObject({
|
||||
ok: true,
|
||||
});
|
||||
|
||||
for (const companion of [
|
||||
"public",
|
||||
"private",
|
||||
"immutable",
|
||||
"max-age=60",
|
||||
"s-maxage=60",
|
||||
"no-cache",
|
||||
"must-revalidate",
|
||||
"proxy-revalidate",
|
||||
]) {
|
||||
expect(await probeWith(`no-store, ${companion}`)).toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "POLICY_REJECTED" },
|
||||
});
|
||||
}
|
||||
|
||||
for (const withoutNoStore of ["private", "no-cache", "max-age=0"]) {
|
||||
expect(await probeWith(withoutNoStore)).toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "POLICY_REJECTED" },
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it("times out a stalled body, aborts the composed signal and cancels its reader", async () => {
|
||||
const manual = manualImageProbeScheduler();
|
||||
const cancel = vi.fn(async () => undefined);
|
||||
@@ -1836,6 +1936,115 @@ describe("browser image probe", () => {
|
||||
expect(close).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* X-AUDIT-02. `probe()` promises a `BrowserDataResult`. A scheduler that
|
||||
* cannot install the probe deadline must close the probe inside that contract
|
||||
* rather than rejecting it, and must not leave the caller's listener behind.
|
||||
*/
|
||||
describe("scheduler boundary", () => {
|
||||
const trackedSignal = () => {
|
||||
const controller = new AbortController();
|
||||
const added: string[] = [];
|
||||
const removed: string[] = [];
|
||||
const add = controller.signal.addEventListener.bind(controller.signal);
|
||||
const remove = controller.signal.removeEventListener.bind(
|
||||
controller.signal,
|
||||
);
|
||||
Object.defineProperty(controller.signal, "addEventListener", {
|
||||
configurable: true,
|
||||
value: (type: string, ...rest: readonly unknown[]) => {
|
||||
added.push(type);
|
||||
return (add as (...args: readonly unknown[]) => unknown)(
|
||||
type,
|
||||
...rest,
|
||||
);
|
||||
},
|
||||
});
|
||||
Object.defineProperty(controller.signal, "removeEventListener", {
|
||||
configurable: true,
|
||||
value: (type: string, ...rest: readonly unknown[]) => {
|
||||
removed.push(type);
|
||||
return (remove as (...args: readonly unknown[]) => unknown)(
|
||||
type,
|
||||
...rest,
|
||||
);
|
||||
},
|
||||
});
|
||||
return { controller, added, removed };
|
||||
};
|
||||
|
||||
it("closes the probe when the scheduler cannot install the deadline", async () => {
|
||||
const fetcher = vi.fn(async () => new Response(null, { status: 200 }));
|
||||
const { controller, added, removed } = trackedSignal();
|
||||
const probe = createBrowserImageProbe({
|
||||
fetcher: fetcher as unknown as typeof fetch,
|
||||
createBitmap: vi.fn(),
|
||||
timeoutMs: 1_000,
|
||||
scheduler: {
|
||||
setTimeout: () => {
|
||||
throw new TypeError("image scheduler install exploded");
|
||||
},
|
||||
clearTimeout: vi.fn(),
|
||||
},
|
||||
});
|
||||
|
||||
await expect(
|
||||
probe.probe({ ...request(), signal: controller.signal }),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "UNAVAILABLE", retryable: true, recovery: "RETRY" },
|
||||
});
|
||||
expect(fetcher).not.toHaveBeenCalled();
|
||||
expect(added.filter((type) => type === "abort")).toHaveLength(1);
|
||||
expect(removed.filter((type) => type === "abort")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("starts no timer and no fetch for an already aborted caller", async () => {
|
||||
const fetcher = vi.fn(async () => new Response(null, { status: 200 }));
|
||||
const setTimeout_ = vi.fn(() => 1);
|
||||
const controller = new AbortController();
|
||||
controller.abort();
|
||||
const probe = createBrowserImageProbe({
|
||||
fetcher: fetcher as unknown as typeof fetch,
|
||||
createBitmap: vi.fn(),
|
||||
timeoutMs: 1_000,
|
||||
scheduler: { setTimeout: setTimeout_, clearTimeout: vi.fn() },
|
||||
});
|
||||
|
||||
await expect(
|
||||
probe.probe({ ...request(), signal: controller.signal }),
|
||||
).resolves.toMatchObject({ ok: false, error: { code: "ABORTED" } });
|
||||
expect(fetcher).not.toHaveBeenCalled();
|
||||
expect(setTimeout_).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps the classified outcome when clearing the deadline throws", async () => {
|
||||
const png = pngBytes(640, 360);
|
||||
const probe = createBrowserImageProbe({
|
||||
fetcher: (async () =>
|
||||
responseAt(imageUrl, png, {
|
||||
status: 200,
|
||||
headers: publicImageHeaders("image/png", png.byteLength),
|
||||
})) as typeof fetch,
|
||||
createBitmap: vi.fn(async () => ({
|
||||
width: 640,
|
||||
height: 360,
|
||||
close: vi.fn(),
|
||||
})),
|
||||
timeoutMs: 1_000,
|
||||
scheduler: {
|
||||
setTimeout: (callback: () => void, milliseconds: number) =>
|
||||
setTimeout(callback, milliseconds),
|
||||
clearTimeout: () => {
|
||||
throw new TypeError("image scheduler clear exploded");
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await expect(probe.probe(request())).resolves.toMatchObject({ ok: true });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("P-256 image capability verifier", () => {
|
||||
|
||||
Reference in New Issue
Block a user