chore: sync the frontend template from ebea300 to af3d8e6
Carries 359 template commits, tag v0.2.0 plus one documentation commit: the generator-built feature index with its app, bounded-context and feature declarations, the src/platform kernel and scale tooling, the 2026-09-24 src review fixes, and the 2026-09-25 maturity review round with its CHANGELOG [보안]/[계약] rows. 691 of the 824 template paths are applied, 85 of them merged with product changes; 127 are not carried. Product identity is unchanged: name, version 0.1.0, routes, design and the TechLog domain. Three decisions worth naming. TechLog stays composed directly, as the last two syncs recorded; its directory carries a NOT_INSTALLED marker that says so, and every installed-* composer takes the template's projection with TechLog added on top. The reference sample is no longer installed: the template now installs a feature only through feature-module.ts and context-routes.ts, which load the screens this product deleted, so its three operations, six schemas and one topic leave the registries, recorded as registry change evidence. And AppRouter mounts the platform and TechLog routes only; the template's bounded-context route gateway waits for a generator-installed feature. Required fixes: readSubject on the BFF session owner (without it every HTTP Studio session would close as integration-failed), zod through the facade in nine TechLog files, noUnusedLocals, and public/config.json written out to match the local profile. Derived baselines were recomputed after reproducing both sides' values: CI contract 101 commands / 106 references / 141 artifacts, gate shape c9adcf85; registry approval 2dc6c3a3; the runtime config schema baseline equals the schema at8210d48. Verified here: types, lint, architecture, adapter inventory, CI contract, i18n, design system, diagnostics, browser security, dev release manifest, TechLog contract and build pass; 220 component, 155 integration, 15 contract, 418 TechLog, 43 reference-feature, 18 recipe and 46 release-coherence tests pass, and 2381 of 2383 unit tests. Reproduced at8210d48first and unchanged: check:registries (byte-identical), test:runtime-schema, verify:documentation. Brought by the template and escalated rather than suppressed: check:request-fanout on TechLog's cursor pagination, check:remediation-ledger (fails upstream too), the shared-chunk hash test, and the registry-dependent sample removal and second-feature tests. Playwright suites were not run. Full record, the five open questions and the follow-ups in docs/operations/template-sync-2026-09-29.md. (cherry picked from commit b2170cf265dea45dc9cc05d3c61e627e97f31cdb)
This commit is contained in:
@@ -6,7 +6,7 @@ import type {
|
||||
IndexedDbObservation,
|
||||
IndexedDbRuntimeDependencies,
|
||||
} from "../../src/adapters/storage/indexeddb/indexeddb-types.ts";
|
||||
import { mapIndexedDbException } from "../../src/adapters/storage/indexeddb/indexeddb-failure.ts";
|
||||
import { mapIndexedDbException } from "../../src/adapters/browser-file-storage/result.ts";
|
||||
import { MemoryIndexedDbFactory } from "../helpers/memory-indexeddb.ts";
|
||||
|
||||
type Item = Readonly<{
|
||||
@@ -449,7 +449,7 @@ describe("IndexedDB runtime", () => {
|
||||
expect(runtime.getStatus()).toEqual({ kind: "READY", schemaVersion: 1 });
|
||||
});
|
||||
|
||||
it("times out a blocked upgrade, then closes a late successful connection", async () => {
|
||||
it("times out a blocked upgrade, then aborts the late upgrade instead of committing it", async () => {
|
||||
const memory = new MemoryIndexedDbFactory();
|
||||
memory.blockNextOpen();
|
||||
let timeout: (() => void) | undefined;
|
||||
@@ -484,7 +484,10 @@ describe("IndexedDB runtime", () => {
|
||||
|
||||
memory.releaseBlockedOpen();
|
||||
await Promise.resolve();
|
||||
expect(memory.isConnectionClosed()).toBe(true);
|
||||
// Q-6.5-10. The upgrade that starts after the deadline is aborted, so no
|
||||
// schema commits and no connection exists to leak. (This test used to
|
||||
// expect the late upgrade to commit and its connection to be closed.)
|
||||
expect(memory.hasStore("records")).toBe(false);
|
||||
expect(runtime.getStatus()).toEqual({
|
||||
kind: "CLOSED",
|
||||
reason: "NOT_OPENED",
|
||||
@@ -1032,9 +1035,10 @@ describe("IndexedDB runtime", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("aborts a sweep whose budget row cannot account for the deleted bytes", async () => {
|
||||
it("05-05 sweeps a row the budget cannot account for and leaves the budget high", async () => {
|
||||
const memory = new MemoryIndexedDbFactory();
|
||||
let epochMs = 1_000;
|
||||
const observations: IndexedDbObservation[] = [];
|
||||
const runtime = createIndexedDbRuntime(
|
||||
dependencies(memory, {
|
||||
storagePolicy: {
|
||||
@@ -1051,6 +1055,7 @@ describe("IndexedDB runtime", () => {
|
||||
authorized: true,
|
||||
proofToken: "sweep_authority_proof_001",
|
||||
}),
|
||||
observe: (event) => observations.push(event),
|
||||
}),
|
||||
);
|
||||
expect(await runtime.open()).toMatchObject({ ok: true });
|
||||
@@ -1063,9 +1068,8 @@ describe("IndexedDB runtime", () => {
|
||||
}),
|
||||
).toMatchObject({ ok: true });
|
||||
|
||||
// A budget that cannot account for the record's bytes is corrupt, and the
|
||||
// sweep only discovers it after both deletions have already succeeded
|
||||
// inside the transaction.
|
||||
// A budget that cannot account for the record's bytes is corrupt. The
|
||||
// sweep finds it only after both deletions succeeded in the transaction.
|
||||
memory.seed("governance", {
|
||||
bindingKey: "dataset-budget",
|
||||
budgetVersion: 1,
|
||||
@@ -1082,15 +1086,20 @@ describe("IndexedDB runtime", () => {
|
||||
maxDurationMs: 1_000,
|
||||
}),
|
||||
).toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "CORRUPT_DATA" },
|
||||
ok: true,
|
||||
value: { state: "COMPLETE", deletedRows: 1 },
|
||||
});
|
||||
// `fail` aborts. Recording the failure without aborting would report the
|
||||
// same code while letting the two deletions commit against a budget that
|
||||
// never moved.
|
||||
expect(aborts.count).toBe(1);
|
||||
expect(memory.readRaw("records", "sweep-record")).toBeDefined();
|
||||
expect(memory.readRaw("retention", "sweep-record")).toBeDefined();
|
||||
expect(aborts.count).toBe(0);
|
||||
expect(memory.readRaw("records", "sweep-record")).toBeUndefined();
|
||||
expect(memory.readRaw("retention", "sweep-record")).toBeUndefined();
|
||||
// Not lowered below what it cannot account for: a budget that reads high
|
||||
// blocks writes, one that reads low would admit them.
|
||||
expect(memory.readRaw("governance", "dataset-budget")).toMatchObject({
|
||||
usedBytes: 0,
|
||||
});
|
||||
expect(observations).toContainEqual(
|
||||
expect.objectContaining({ failureCode: "CORRUPT_DATA" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("requires lifecycle authority and only deletes sync-confirmed rows", async () => {
|
||||
@@ -1240,6 +1249,127 @@ describe("IndexedDB runtime", () => {
|
||||
).toMatchObject({ usedBytes: 0, receiptCount: 0 });
|
||||
});
|
||||
|
||||
it.each(["LOGOUT", "ACCOUNT_DELETION"] as const)(
|
||||
"R-5.4 completes a %s purge past corrupt rows, reports them, and leaves other partitions alone",
|
||||
async (action) => {
|
||||
const partitionScope = {
|
||||
...TEST_SCOPE,
|
||||
accountScope: "OPAQUE_PARTITION" as const,
|
||||
};
|
||||
const otherScope = {
|
||||
...partitionScope,
|
||||
partitionToken: "partitiontoken_002",
|
||||
};
|
||||
const partitionPolicy = {
|
||||
...TEST_STORAGE_POLICY,
|
||||
accountScope: "OPAQUE_PARTITION" as const,
|
||||
logoutAction: "PURGE_PARTITION" as const,
|
||||
accountDeletionAction: "PURGE_PARTITION" as const,
|
||||
};
|
||||
// One factory, routed by the physical database name the runtime derives
|
||||
// from its partition, the way the browser keeps databases apart.
|
||||
const purged = new MemoryIndexedDbFactory();
|
||||
const other = new MemoryIndexedDbFactory();
|
||||
const otherName = indexedDbPhysicalDatabaseName(otherScope);
|
||||
const factory = {
|
||||
open: (name: string, version?: number) =>
|
||||
(name === otherName ? other : purged).factory.open(name, version),
|
||||
cmp: purged.factory.cmp,
|
||||
} as IDBFactory;
|
||||
const observations: IndexedDbObservation[] = [];
|
||||
const runtime = createIndexedDbRuntime(
|
||||
dependencies(purged, {
|
||||
scope: partitionScope,
|
||||
storagePolicy: partitionPolicy,
|
||||
factory,
|
||||
nowMonotonicMilliseconds: () => 0,
|
||||
observe: (event) => observations.push(event),
|
||||
}),
|
||||
);
|
||||
const otherRuntime = createIndexedDbRuntime(
|
||||
dependencies(other, {
|
||||
scope: otherScope,
|
||||
storagePolicy: partitionPolicy,
|
||||
factory,
|
||||
nowMonotonicMilliseconds: () => 0,
|
||||
}),
|
||||
);
|
||||
expect(await runtime.open()).toMatchObject({ ok: true });
|
||||
expect(await otherRuntime.open()).toMatchObject({ ok: true });
|
||||
for (const key of ["healthy", "bad-record", "bad-sidecar"]) {
|
||||
expect(
|
||||
await runtime.compareAndSwap({
|
||||
key,
|
||||
value: { label: key, rank: 1 },
|
||||
expectedRevision: null,
|
||||
idempotencyKey: `${key}-create`,
|
||||
}),
|
||||
).toMatchObject({ ok: true });
|
||||
}
|
||||
expect(
|
||||
await otherRuntime.compareAndSwap({
|
||||
key: "other-partition",
|
||||
value: { label: "kept", rank: 1 },
|
||||
expectedRevision: null,
|
||||
idempotencyKey: "other-create",
|
||||
}),
|
||||
).toMatchObject({ ok: true });
|
||||
|
||||
// Four corrupt rows and a budget that no longer matches the data.
|
||||
purged.seed("records", { key: "bad-record", codecVersion: 0 });
|
||||
purged.seed("retention", { recordKey: "bad-sidecar", measuredBytes: -1 });
|
||||
purged.seed("retention", { recordKey: "orphan-sidecar" });
|
||||
purged.seed("receipts", { idempotencyKey: "bad-receipt" });
|
||||
purged.seed("governance", {
|
||||
bindingKey: "dataset-budget",
|
||||
budgetVersion: 1,
|
||||
usedBytes: 1,
|
||||
receiptCount: 0,
|
||||
});
|
||||
|
||||
const receipts = [];
|
||||
for (let batch = 0; batch < 5; batch += 1) {
|
||||
const receipt = await runtime.enforceLifecycleBatch({
|
||||
action,
|
||||
maxRows: 2,
|
||||
maxDurationMs: 1_000,
|
||||
});
|
||||
receipts.push(receipt);
|
||||
if (!receipt.ok || receipt.value.state === "COMPLETE") break;
|
||||
}
|
||||
|
||||
expect(receipts.at(-1)).toMatchObject({
|
||||
ok: true,
|
||||
value: { state: "COMPLETE" },
|
||||
});
|
||||
for (const key of ["healthy", "bad-record", "bad-sidecar"]) {
|
||||
expect(purged.readRaw("records", key)).toBeUndefined();
|
||||
expect(purged.readRaw("retention", key)).toBeUndefined();
|
||||
expect(purged.readRaw("receipts", `${key}-create`)).toBeUndefined();
|
||||
}
|
||||
expect(purged.readRaw("retention", "orphan-sidecar")).toBeUndefined();
|
||||
expect(purged.readRaw("receipts", "bad-receipt")).toBeUndefined();
|
||||
expect(purged.readRaw("governance", "dataset-budget")).toEqual({
|
||||
bindingKey: "dataset-budget",
|
||||
budgetVersion: 1,
|
||||
usedBytes: 0,
|
||||
receiptCount: 0,
|
||||
});
|
||||
// Corruption is reported, never a reason to stop deleting.
|
||||
const corrupt = observations.filter(
|
||||
(event) => event.failureCode === "CORRUPT_DATA",
|
||||
);
|
||||
expect(corrupt.length).toBeGreaterThan(0);
|
||||
expect(observations.at(-1)).toMatchObject({ outcome: "SUCCESS" });
|
||||
|
||||
expect(other.readRaw("records", "other-partition")).toBeDefined();
|
||||
expect(await otherRuntime.read("other-partition")).toMatchObject({
|
||||
ok: true,
|
||||
value: { value: { label: "kept" } },
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("rejects invalid measurements, byte overage, and receipt-count overage atomically", async () => {
|
||||
const invalidMemory = new MemoryIndexedDbFactory();
|
||||
const invalidBase = dependencies(invalidMemory);
|
||||
@@ -1329,3 +1459,260 @@ describe("IndexedDB runtime", () => {
|
||||
expect(hardMemory.readRaw("records", "x")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("05-03 a LOGOUT or ACCOUNT_DELETION purge survives corrupt governance", () => {
|
||||
const partitionScope = {
|
||||
...TEST_SCOPE,
|
||||
accountScope: "OPAQUE_PARTITION" as const,
|
||||
};
|
||||
const otherScope = {
|
||||
...partitionScope,
|
||||
partitionToken: "partitiontoken_002",
|
||||
};
|
||||
const partitionPolicy = {
|
||||
...TEST_STORAGE_POLICY,
|
||||
accountScope: "OPAQUE_PARTITION" as const,
|
||||
logoutAction: "PURGE_PARTITION" as const,
|
||||
accountDeletionAction: "PURGE_PARTITION" as const,
|
||||
};
|
||||
const batch = { maxRows: 100, maxDurationMs: 1_000 } as const;
|
||||
|
||||
/**
|
||||
* Another partition and this one each hold a record in one factory; this
|
||||
* partition's budget row is then corrupted, so a fresh runtime cannot pass
|
||||
* admission (E1).
|
||||
*/
|
||||
async function corruptedPartition(
|
||||
authorizeLifecycle: IndexedDbRuntimeDependencies<
|
||||
Item,
|
||||
Item,
|
||||
Query
|
||||
>["authorizeLifecycle"] = () => ({
|
||||
authorized: true,
|
||||
proofToken: "authorityproof_001",
|
||||
}),
|
||||
) {
|
||||
const memory = new MemoryIndexedDbFactory();
|
||||
const other = createIndexedDbRuntime(
|
||||
dependencies(memory, {
|
||||
scope: otherScope,
|
||||
storagePolicy: partitionPolicy,
|
||||
}),
|
||||
);
|
||||
expect(await other.open()).toMatchObject({ ok: true });
|
||||
await other.compareAndSwap({
|
||||
key: "kept",
|
||||
value: { label: "other", rank: 1 },
|
||||
expectedRevision: null,
|
||||
idempotencyKey: "kept-create",
|
||||
});
|
||||
const writer = createIndexedDbRuntime(
|
||||
dependencies(memory, {
|
||||
scope: partitionScope,
|
||||
storagePolicy: partitionPolicy,
|
||||
}),
|
||||
);
|
||||
expect(await writer.open()).toMatchObject({ ok: true });
|
||||
await writer.compareAndSwap({
|
||||
key: "personal-1",
|
||||
value: { label: "mine", rank: 1 },
|
||||
expectedRevision: null,
|
||||
idempotencyKey: "personal-create",
|
||||
});
|
||||
writer.close();
|
||||
memory.seed("governance", {
|
||||
bindingKey: "dataset-budget",
|
||||
budgetVersion: 1,
|
||||
usedBytes: -5,
|
||||
receiptCount: 1,
|
||||
});
|
||||
const deleteDatabase = vi.spyOn(memory.factory, "deleteDatabase");
|
||||
const fresh = createIndexedDbRuntime(
|
||||
dependencies(memory, {
|
||||
scope: partitionScope,
|
||||
storagePolicy: partitionPolicy,
|
||||
authorizeLifecycle,
|
||||
}),
|
||||
);
|
||||
expect(await fresh.open()).toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "POLICY_REJECTED" },
|
||||
});
|
||||
return { memory, other, fresh, deleteDatabase };
|
||||
}
|
||||
|
||||
it.each(["LOGOUT", "ACCOUNT_DELETION"] as const)(
|
||||
"deletes the partition's whole dataset for an authorized %s and leaves other partitions alone",
|
||||
async (action) => {
|
||||
const { memory, other, fresh, deleteDatabase } =
|
||||
await corruptedPartition();
|
||||
|
||||
expect(
|
||||
await fresh.enforceLifecycleBatch({ action, ...batch }),
|
||||
).toMatchObject({
|
||||
ok: true,
|
||||
value: { state: "COMPLETE", datasetDeleted: true },
|
||||
});
|
||||
expect(deleteDatabase).toHaveBeenCalledTimes(1);
|
||||
expect(deleteDatabase).toHaveBeenCalledWith(
|
||||
indexedDbPhysicalDatabaseName(partitionScope),
|
||||
);
|
||||
expect(memory.hasStore("records")).toBe(false);
|
||||
expect(await other.read("kept")).toMatchObject({
|
||||
ok: true,
|
||||
value: { value: { label: "other", rank: 1 } },
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps the dataset when the authority does not approve", async () => {
|
||||
const { memory, fresh, deleteDatabase } = await corruptedPartition(
|
||||
() => ({ authorized: false }),
|
||||
);
|
||||
|
||||
expect(
|
||||
await fresh.enforceLifecycleBatch({ action: "ACCOUNT_DELETION", ...batch }),
|
||||
).toMatchObject({ ok: false, error: { code: "POLICY_REJECTED" } });
|
||||
expect(deleteDatabase).not.toHaveBeenCalled();
|
||||
expect(memory.readRaw("records", "personal-1")).toBeDefined();
|
||||
});
|
||||
|
||||
it("purges row by row, never the database, when governance is healthy", async () => {
|
||||
const memory = new MemoryIndexedDbFactory();
|
||||
const deleteDatabase = vi.spyOn(memory.factory, "deleteDatabase");
|
||||
const runtime = createIndexedDbRuntime(
|
||||
dependencies(memory, {
|
||||
scope: partitionScope,
|
||||
storagePolicy: partitionPolicy,
|
||||
}),
|
||||
);
|
||||
expect(await runtime.open()).toMatchObject({ ok: true });
|
||||
await runtime.compareAndSwap({
|
||||
key: "personal-1",
|
||||
value: { label: "mine", rank: 1 },
|
||||
expectedRevision: null,
|
||||
idempotencyKey: "personal-create",
|
||||
});
|
||||
runtime.close();
|
||||
const fresh = createIndexedDbRuntime(
|
||||
dependencies(memory, {
|
||||
scope: partitionScope,
|
||||
storagePolicy: partitionPolicy,
|
||||
}),
|
||||
);
|
||||
|
||||
const purged = await fresh.enforceLifecycleBatch({
|
||||
action: "LOGOUT",
|
||||
...batch,
|
||||
});
|
||||
expect(purged).toMatchObject({ ok: true, value: { state: "COMPLETE" } });
|
||||
expect(purged.ok && purged.value).not.toHaveProperty("datasetDeleted");
|
||||
expect(deleteDatabase).not.toHaveBeenCalled();
|
||||
expect(memory.hasStore("records")).toBe(true);
|
||||
expect(memory.readRaw("records", "personal-1")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("05-05 a retention sweep steps over a corrupt row", () => {
|
||||
it("deletes every expired healthy row, leaves the corrupt sidecar and reports it", async () => {
|
||||
const memory = new MemoryIndexedDbFactory();
|
||||
let epochMs = 1_000;
|
||||
const observations: IndexedDbObservation[] = [];
|
||||
const runtime = createIndexedDbRuntime(
|
||||
dependencies(memory, {
|
||||
storagePolicy: {
|
||||
...TEST_STORAGE_POLICY,
|
||||
retention: { kind: "TTL", maxAgeMs: 10 },
|
||||
},
|
||||
keyRange:
|
||||
memory.keyRange as NonNullable<
|
||||
IndexedDbRuntimeDependencies<Item, Item, Query>["keyRange"]
|
||||
>,
|
||||
nowEpochMilliseconds: () => epochMs,
|
||||
nowMonotonicMilliseconds: () => 0,
|
||||
observe: (event) => observations.push(event),
|
||||
}),
|
||||
);
|
||||
expect(await runtime.open()).toMatchObject({ ok: true });
|
||||
for (const key of ["a", "b", "c"]) {
|
||||
await runtime.compareAndSwap({
|
||||
key,
|
||||
value: { label: key, rank: 1 },
|
||||
expectedRevision: null,
|
||||
idempotencyKey: `create-${key}`,
|
||||
});
|
||||
}
|
||||
// Sorts first on the eligibility index and names a record it is not keyed by.
|
||||
memory.seed("retention", {
|
||||
recordKey: "zzz",
|
||||
writtenAtEpochMs: 0,
|
||||
synchronization: "NONE",
|
||||
measuredBytes: 0,
|
||||
eligibleAtEpochMs: 0,
|
||||
});
|
||||
epochMs = 5_000;
|
||||
|
||||
for (let attempt = 0; attempt < 2; attempt += 1) {
|
||||
expect(
|
||||
await runtime.enforceLifecycleBatch({
|
||||
action: "RETENTION_SWEEP",
|
||||
maxRows: 100,
|
||||
maxDurationMs: 1_000,
|
||||
}),
|
||||
).toMatchObject({ ok: true, value: { state: "COMPLETE" } });
|
||||
}
|
||||
expect(
|
||||
["a", "b", "c"].filter(
|
||||
(key) => memory.readRaw("records", key) !== undefined,
|
||||
),
|
||||
).toEqual([]);
|
||||
expect(memory.readRaw("retention", "zzz")).toBeDefined();
|
||||
expect(observations).toContainEqual(
|
||||
expect.objectContaining({
|
||||
operation: "INDEXEDDB_WRITE",
|
||||
outcome: "FAILED",
|
||||
failureCode: "CORRUPT_DATA",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("05-06 an older tab that meets a newer schema", () => {
|
||||
it("reports INCOMPATIBLE and online-only, not a migration failure", async () => {
|
||||
const memory = new MemoryIndexedDbFactory();
|
||||
const base = dependencies(memory);
|
||||
const newer = createIndexedDbRuntime({
|
||||
...base,
|
||||
schemaVersion: 2,
|
||||
migrations: [
|
||||
...base.migrations,
|
||||
{
|
||||
id: "schema-v2",
|
||||
fromVersion: 1,
|
||||
toVersion: 2,
|
||||
operations: [{ kind: "CREATE_STORE", name: "extra", keyPath: "k" }],
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(await newer.open()).toMatchObject({ ok: true });
|
||||
newer.close();
|
||||
const older = createIndexedDbRuntime(dependencies(memory));
|
||||
|
||||
expect(await older.open()).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
code: "UNSUPPORTED",
|
||||
operation: "INDEXEDDB_OPEN",
|
||||
recovery: "ONLINE_ONLY",
|
||||
},
|
||||
});
|
||||
expect(older.getStatus()).toEqual({
|
||||
kind: "INCOMPATIBLE",
|
||||
schemaVersion: 1,
|
||||
});
|
||||
expect(await older.read("x")).toMatchObject({
|
||||
ok: false,
|
||||
error: { code: "UNSUPPORTED", recovery: "ONLINE_ONLY" },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user