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
@@ -0,0 +1,149 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { createCursorPaginationRuntime } from "../../src/adapters/query-cache/cursor-pagination-runtime.ts";
|
||||
import {
|
||||
defineMutationIntent,
|
||||
isValidIdempotencyKey,
|
||||
} from "../../src/contracts/mutation-intent.ts";
|
||||
import type {
|
||||
CursorPage,
|
||||
CursorPaginationProfile,
|
||||
} from "../../src/contracts/cursor-pagination.ts";
|
||||
import type { Result } from "../../src/application/result.ts";
|
||||
|
||||
const PROFILE: CursorPaginationProfile = Object.freeze({
|
||||
profileId: "TEST_PAGINATION_V1",
|
||||
maxPages: 3,
|
||||
maxTotalItems: 30,
|
||||
maxEstimatedBytes: 32_768,
|
||||
maxCursorBytes: 512,
|
||||
allowSparsePage: false,
|
||||
});
|
||||
|
||||
function page(
|
||||
items: readonly number[],
|
||||
nextCursor: string | null,
|
||||
): CursorPage<number> {
|
||||
return Object.freeze({
|
||||
items: Object.freeze([...items]),
|
||||
nextCursor,
|
||||
hasMore: nextCursor !== null,
|
||||
snapshotToken: "snapshot-1",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* OPT-NET-01. A loader rejection is evidence about the data source. Reporting
|
||||
* it as `PAGINATION_ABORTED` because a signal merely *exists* erases a real
|
||||
* network or contract failure and files it under a user decision nobody made.
|
||||
*/
|
||||
describe("OPT-NET-01 cursor pagination abort classification", () => {
|
||||
it("preserves a loader rejection while the signal is still live", async () => {
|
||||
const controller = new AbortController();
|
||||
const runtime = createCursorPaginationRuntime<number>({
|
||||
definitionId: "TEST_PAGINATION",
|
||||
profile: PROFILE,
|
||||
loadPage: async () => {
|
||||
throw new TypeError("upstream exploded");
|
||||
},
|
||||
});
|
||||
|
||||
await expect(
|
||||
runtime.loadAll({ signal: controller.signal }),
|
||||
).rejects.toThrow("upstream exploded");
|
||||
});
|
||||
|
||||
it("keeps the same rejection when no signal is supplied", async () => {
|
||||
const runtime = createCursorPaginationRuntime<number>({
|
||||
definitionId: "TEST_PAGINATION",
|
||||
profile: PROFILE,
|
||||
loadPage: async () => {
|
||||
throw new TypeError("upstream exploded");
|
||||
},
|
||||
});
|
||||
|
||||
await expect(runtime.loadAll({})).rejects.toThrow("upstream exploded");
|
||||
});
|
||||
|
||||
it("classifies a rejection during a real abort as PAGINATION_ABORTED", async () => {
|
||||
const controller = new AbortController();
|
||||
const runtime = createCursorPaginationRuntime<number>({
|
||||
definitionId: "TEST_PAGINATION",
|
||||
profile: PROFILE,
|
||||
loadPage: async () => {
|
||||
controller.abort();
|
||||
throw new TypeError("cancelled upstream");
|
||||
},
|
||||
});
|
||||
|
||||
const result = await runtime.loadAll({ signal: controller.signal });
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.ok ? null : result.error.code).toBe("PAGINATION_ABORTED");
|
||||
});
|
||||
|
||||
it("does not admit a page that resolves after the abort", async () => {
|
||||
const controller = new AbortController();
|
||||
const loadPage = vi.fn(
|
||||
async (): Promise<Result<CursorPage<number>>> => {
|
||||
controller.abort();
|
||||
await new Promise((resolve) => setTimeout(resolve, 5));
|
||||
return { ok: true, value: page([1, 2], null) };
|
||||
},
|
||||
);
|
||||
const runtime = createCursorPaginationRuntime<number>({
|
||||
definitionId: "TEST_PAGINATION",
|
||||
profile: PROFILE,
|
||||
loadPage,
|
||||
});
|
||||
|
||||
const result = await runtime.loadAll({ signal: controller.signal });
|
||||
expect(result.ok).toBe(false);
|
||||
expect(result.ok ? null : result.error.code).toBe("PAGINATION_ABORTED");
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* OPT-NET-02. One idempotency-key authority. Two validators drift, and the
|
||||
* looser one becomes the way a control character reaches a request header.
|
||||
*/
|
||||
describe("OPT-NET-02 shared idempotency key validation", () => {
|
||||
const rejected = [
|
||||
"",
|
||||
" ",
|
||||
"key\nwith-newline",
|
||||
"key\u0000null",
|
||||
"key\u007fdelete",
|
||||
"key\u009fc1",
|
||||
"a".repeat(257),
|
||||
];
|
||||
|
||||
it("rejects the same values at intent definition and at admission", () => {
|
||||
for (const value of rejected) {
|
||||
expect(isValidIdempotencyKey(value)).toBe(false);
|
||||
expect(() =>
|
||||
defineMutationIntent({
|
||||
intentId: "intent-1",
|
||||
operationId: "OP",
|
||||
canonicalInputIdentity: "identity",
|
||||
idempotencyKey: value,
|
||||
createdAtMonotonicMs: 1,
|
||||
}),
|
||||
).toThrow(TypeError);
|
||||
}
|
||||
});
|
||||
|
||||
it("accepts the bounded printable and Unicode values both sides allow", () => {
|
||||
for (const value of ["key-1", "a".repeat(256), "키-값", "ключ"]) {
|
||||
expect(isValidIdempotencyKey(value)).toBe(true);
|
||||
expect(
|
||||
defineMutationIntent({
|
||||
intentId: "intent-1",
|
||||
operationId: "OP",
|
||||
canonicalInputIdentity: "identity",
|
||||
idempotencyKey: value,
|
||||
createdAtMonotonicMs: 1,
|
||||
}).idempotencyKey,
|
||||
).toBe(value);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user