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:
DongHyeonka
2026-08-15 12:04:58 +09:00
co-authored by Claude Opus 5
parent 002ba3624e
commit 4bff9ca151
142 changed files with 23010 additions and 1544 deletions
@@ -67,6 +67,56 @@ function createTransport(
}
describe("resumable upload fetch transport", () => {
it.each([
{ label: "delta-seconds", header: "2", now: 1_000, expected: 2_000 },
{ label: "HTTP-date ahead", header: "Thu, 01 Jan 1970 00:00:03 GMT", now: 1_000, expected: 2_000 },
{ label: "HTTP-date behind (clock rollback)", header: "Thu, 01 Jan 1970 00:00:01 GMT", now: 9_000, expected: 0 },
])(
"resolves Retry-After against the injected clock ($label)",
async ({ header, now, expected }) => {
// BT-UP-02. Both branches use the same captured `now`, so boundaries and
// clock rollback are deterministic.
const transport = createTransport(
(async () =>
responseAt(ENDPOINTS.GET_STATUS, null, {
status: 429,
headers: { "retry-after": header },
})) as unknown as typeof fetch,
{ nowEpochMs: () => now },
);
const result = await transport.execute({
operation: "GET_STATUS",
body: { sessionId: "session_01" },
signal: new AbortController().signal,
});
expect(result).toMatchObject({
ok: false,
error: { code: "UNAVAILABLE", retryAfterMs: expected },
});
},
);
it("ignores an invalid Retry-After date instead of guessing", async () => {
const transport = createTransport(
(async () =>
responseAt(ENDPOINTS.GET_STATUS, null, {
status: 429,
headers: { "retry-after": "not-a-date" },
})) as unknown as typeof fetch,
{ nowEpochMs: () => 1_000 },
);
const result = await transport.execute({
operation: "GET_STATUS",
body: { sessionId: "session_01" },
signal: new AbortController().signal,
});
expect(result).toMatchObject({ ok: false });
if (result.ok) return;
expect(result.error.retryAfterMs).toBeUndefined();
});
it("uses a closed operation map and fixed production fetch policy", async () => {
let receivedUrl = "";
let receivedInit: RequestInit | undefined;
@@ -444,4 +494,158 @@ describe("resumable upload Web Lock", () => {
},
]);
});
/**
* X-AUDIT-02. The public port promises a `UploadProviderResult`. A scheduler
* that cannot install the attempt deadline must close the attempt inside that
* contract instead of rejecting it, and must not leave the caller listener
* attached to the parent signal.
*/
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 attempt when the scheduler cannot install the deadline", async () => {
const fetcher = vi.fn(async () => new Response(null, { status: 200 }));
const { controller, added, removed } = trackedSignal();
const transport = createTransport(fetcher as unknown as typeof fetch, {
scheduler: {
setTimeout: () => {
throw new TypeError("upload scheduler install exploded");
},
clearTimeout: () => {},
},
});
const result = await transport.execute({
operation: "GET_STATUS",
body: { sessionId: "session_01" },
signal: controller.signal,
});
expect(result.ok).toBe(false);
if (!result.ok) {
expect(result.error.code).toBe("UNAVAILABLE");
expect(result.error.retryable).toBe(true);
}
expect(fetcher).not.toHaveBeenCalled();
expect(added.filter((type) => type === "abort")).toHaveLength(1);
expect(removed.filter((type) => type === "abort")).toHaveLength(1);
});
it("keeps the classified outcome when clearing the deadline throws", async () => {
const fetcher = vi.fn(
async () =>
jsonResponseAt(ENDPOINTS.GET_STATUS, { sessionId: "session_01" }),
);
const { controller, added, removed } = trackedSignal();
const transport = createTransport(fetcher as unknown as typeof fetch, {
scheduler: {
setTimeout: (callback: () => void, delayMs: number) =>
setTimeout(callback, delayMs),
clearTimeout: () => {
throw new TypeError("upload scheduler clear exploded");
},
},
});
const result = await transport.execute({
operation: "GET_STATUS",
body: { sessionId: "session_01" },
signal: controller.signal,
});
expect(result.ok).toBe(true);
expect(added.filter((type) => type === "abort")).toHaveLength(1);
expect(removed.filter((type) => type === "abort")).toHaveLength(1);
});
it("uses the scheduler methods captured at construction", async () => {
const fetcher = vi.fn(
async () =>
jsonResponseAt(ENDPOINTS.GET_STATUS, { sessionId: "session_01" }),
);
const scheduler = {
setTimeout: (callback: () => void, delayMs: number) =>
setTimeout(callback, delayMs),
clearTimeout: (handle: unknown) => {
clearTimeout(handle as ReturnType<typeof setTimeout>);
},
};
const transport = createTransport(fetcher as unknown as typeof fetch, {
scheduler,
});
scheduler.setTimeout = () => {
throw new TypeError("mutated upload setTimeout");
};
scheduler.clearTimeout = () => {
throw new TypeError("mutated upload clearTimeout");
};
await expect(
transport.execute({
operation: "GET_STATUS",
body: { sessionId: "session_01" },
signal: new AbortController().signal,
}),
).resolves.toMatchObject({ ok: true });
});
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(
(callback: () => void, delayMs: number) =>
setTimeout(callback, delayMs) as unknown,
);
const controller = new AbortController();
controller.abort();
const transport = createTransport(fetcher as unknown as typeof fetch, {
scheduler: {
setTimeout: setTimeout_,
clearTimeout: (handle: unknown) => {
clearTimeout(handle as ReturnType<typeof setTimeout>);
},
},
});
const result = await transport.execute({
operation: "GET_STATUS",
body: { sessionId: "session_01" },
signal: controller.signal,
});
expect(result.ok).toBe(false);
if (!result.ok) expect(result.error.code).toBe("ABORTED");
expect(fetcher).not.toHaveBeenCalled();
expect(setTimeout_).not.toHaveBeenCalled();
});
});
});