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:
@@ -0,0 +1,154 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { createQueryClient } from "../../../src/adapters/query-cache/tanstack-query-cache.ts";
|
||||
import { createTelemetryPipeline } from "../../../src/platform/telemetry/telemetry-pipeline.ts";
|
||||
import type { InstalledHttpContract } from "../../../src/contracts/external-contract-runtime.ts";
|
||||
import { TEST_CREATE_HTTP_CONTRACT } from "../../helpers/external-contract-fixture.ts";
|
||||
import {
|
||||
jsonRows,
|
||||
networkFailure,
|
||||
testExecutionContext,
|
||||
testExecutor,
|
||||
type Transport,
|
||||
} from "../../helpers/traffic-test-kit.ts";
|
||||
import { classifyCounterSeries } from "../../../scripts/scale/memory-slope.ts";
|
||||
import { TEST_QUERY } from "../traffic/synthetic-traffic.ts";
|
||||
import { recordScaleMetrics } from "../scale-artifact.ts";
|
||||
|
||||
const TEST_COMMAND = TEST_CREATE_HTTP_CONTRACT as InstalledHttpContract<
|
||||
unknown,
|
||||
unknown,
|
||||
unknown
|
||||
>;
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
/**
|
||||
* A long-lived scope signal that counts its listeners, standing in for the
|
||||
* session-wide server-state scope every execution subscribes to.
|
||||
*/
|
||||
function countingScope() {
|
||||
const controller = new AbortController();
|
||||
let listeners = 0;
|
||||
const signal = controller.signal;
|
||||
const add = signal.addEventListener.bind(signal);
|
||||
const remove = signal.removeEventListener.bind(signal);
|
||||
Object.defineProperty(signal, "addEventListener", {
|
||||
value: (...args: Parameters<AbortSignal["addEventListener"]>) => {
|
||||
listeners += 1;
|
||||
add(...args);
|
||||
},
|
||||
});
|
||||
Object.defineProperty(signal, "removeEventListener", {
|
||||
value: (...args: Parameters<AbortSignal["removeEventListener"]>) => {
|
||||
listeners -= 1;
|
||||
remove(...args);
|
||||
},
|
||||
});
|
||||
let generation = 1;
|
||||
return {
|
||||
scope: () =>
|
||||
Object.freeze({
|
||||
generation,
|
||||
fingerprint: `scope-${generation}`,
|
||||
identities: Object.freeze({}) as never,
|
||||
signal,
|
||||
isCurrent: () => true,
|
||||
}),
|
||||
listeners: () => listeners,
|
||||
nextGeneration() {
|
||||
generation += 1;
|
||||
},
|
||||
generation: () => generation,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Spec §33 / §44. Thousands of login/navigation/query/mutation/logout cycles.
|
||||
* Every long-lived resource must return to (or stabilize at) its post-warm-up
|
||||
* bound rather than grow with the number of cycles.
|
||||
*/
|
||||
describe("long-session logical leak checks", () => {
|
||||
it("returns timers, listeners, leases, buffers and cache entries to a stable bound", async () => {
|
||||
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
|
||||
const session = countingScope();
|
||||
let cycle = 0;
|
||||
const transport: Transport = () => (cycle % 7 === 0 ? networkFailure() : Promise.resolve(jsonRows(2)));
|
||||
const executor = testExecutor(transport, { maxRetryAttempts: 1 });
|
||||
const telemetry = createTelemetryPipeline({
|
||||
transport: { send: () => {} },
|
||||
schedule: () => {},
|
||||
setTimer: () => 0,
|
||||
clearTimer: () => {},
|
||||
});
|
||||
const queryClient = createQueryClient();
|
||||
|
||||
const series = { timers: [] as number[], listeners: [] as number[], buffered: [] as number[], cache: [] as number[] };
|
||||
const CYCLES = 3_000;
|
||||
for (cycle = 0; cycle < CYCLES; cycle += 1) {
|
||||
// login: a new session scope generation every 250 cycles
|
||||
if (cycle % 250 === 0) session.nextGeneration();
|
||||
const execution = testExecutionContext({
|
||||
maxPhysicalRequests: 3,
|
||||
maxRetries: 1,
|
||||
maxConcurrentRequests: 2,
|
||||
});
|
||||
const context = { routeId: "TEST_ROUTE", scope: session.scope(), execution };
|
||||
// navigation + query through the query cache (bounded key cardinality)
|
||||
const queryKey = ["session", session.generation(), cycle % 25];
|
||||
const query = queryClient.fetchQuery({
|
||||
queryKey,
|
||||
queryFn: () => executor.execute(TEST_QUERY, { limit: 1 }, context),
|
||||
});
|
||||
// mutation
|
||||
const mutation = executor.execute(TEST_COMMAND, { name: `c${cycle}` }, {
|
||||
...context,
|
||||
intent: Object.freeze({
|
||||
intentId: `intent-${cycle}`,
|
||||
operationId: "TEST_CREATE_ENTITY",
|
||||
canonicalInputIdentity: `input-${cycle}`,
|
||||
idempotencyKey: `key-${cycle.toString().padStart(6, "0")}`,
|
||||
createdAtMonotonicMs: cycle,
|
||||
}),
|
||||
});
|
||||
const [queryOutcome, mutationOutcome] = await Promise.all([query, mutation]);
|
||||
if (queryOutcome.kind !== "SUCCESS" || mutationOutcome.kind !== "SUCCESS") {
|
||||
await telemetry.emit({
|
||||
kind: "session.operation.failed",
|
||||
severity: "warning",
|
||||
interactionId: execution.interaction.id,
|
||||
payload: { query: queryOutcome.kind, mutation: mutationOutcome.kind },
|
||||
});
|
||||
}
|
||||
// logout: the interaction ends
|
||||
execution.cancellation.cancel();
|
||||
expect(execution.traffic.concurrency.active).toBe(0);
|
||||
|
||||
if (cycle % 100 === 99) {
|
||||
await telemetry.flush();
|
||||
series.timers.push(vi.getTimerCount());
|
||||
series.listeners.push(session.listeners());
|
||||
series.buffered.push(telemetry.stats().buffered);
|
||||
series.cache.push(queryClient.getQueryCache().getAll().length);
|
||||
}
|
||||
if (cycle % 250 === 249) {
|
||||
// Scope generation changed: the previous generation's entries are garbage.
|
||||
queryClient.removeQueries({ queryKey: ["session", session.generation()] });
|
||||
}
|
||||
}
|
||||
|
||||
await recordScaleMetrics("long-session", { cycles: CYCLES, ...series });
|
||||
|
||||
expect(vi.getTimerCount()).toBe(0);
|
||||
expect(session.listeners()).toBe(0);
|
||||
expect(classifyCounterSeries(series.timers, { warmupSamples: 3 })).toBe("stable");
|
||||
expect(classifyCounterSeries(series.listeners, { warmupSamples: 3 })).toBe("stable");
|
||||
expect(classifyCounterSeries(series.buffered, { warmupSamples: 3 })).toBe("stable");
|
||||
expect(Math.max(...series.cache)).toBeLessThanOrEqual(25);
|
||||
expect(Math.max(...series.buffered)).toBeLessThanOrEqual(200);
|
||||
queryClient.clear();
|
||||
telemetry.dispose();
|
||||
}, 120_000);
|
||||
});
|
||||
@@ -0,0 +1,128 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { InstalledHttpContract } from "../../../src/contracts/external-contract-runtime.ts";
|
||||
import { TEST_CREATE_HTTP_CONTRACT } from "../../helpers/external-contract-fixture.ts";
|
||||
import {
|
||||
jsonRows,
|
||||
scopeSnapshot,
|
||||
testExecutionContext,
|
||||
testExecutor,
|
||||
type Transport,
|
||||
} from "../../helpers/traffic-test-kit.ts";
|
||||
import { TEST_QUERY } from "../traffic/synthetic-traffic.ts";
|
||||
|
||||
const TEST_COMMAND = TEST_CREATE_HTTP_CONTRACT as InstalledHttpContract<
|
||||
unknown,
|
||||
unknown,
|
||||
unknown
|
||||
>;
|
||||
|
||||
/**
|
||||
* Spec §42 (network flap). The network alternates online/offline. An
|
||||
* offline attempt that reached `fetch` is a dispatched attempt whose effect is
|
||||
* unknown; the executor must never replay a keyed command automatically.
|
||||
*/
|
||||
function flappingNetwork() {
|
||||
let online = true;
|
||||
const commandDispatches = new Map<string, number>();
|
||||
const inFlight = new Set<AbortSignal>();
|
||||
const transport: Transport = (_input, init) => {
|
||||
const key = new Headers(init?.headers).get("idempotency-key");
|
||||
if (key) commandDispatches.set(key, (commandDispatches.get(key) ?? 0) + 1);
|
||||
if (!online) return Promise.reject(new TypeError("offline"));
|
||||
if (key) {
|
||||
return Promise.resolve(
|
||||
Response.json({ id: key, name: "created" }, { status: 201 }),
|
||||
);
|
||||
}
|
||||
return Promise.resolve(jsonRows(1));
|
||||
};
|
||||
return {
|
||||
transport,
|
||||
commandDispatches,
|
||||
inFlight,
|
||||
setOnline(value: boolean) {
|
||||
online = value;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function intent(index: number) {
|
||||
return Object.freeze({
|
||||
intentId: `intent-${index}`,
|
||||
operationId: "TEST_CREATE_ENTITY",
|
||||
canonicalInputIdentity: `input-${index}`,
|
||||
idempotencyKey: `key-${index.toString().padStart(6, "0")}`,
|
||||
createdAtMonotonicMs: index,
|
||||
});
|
||||
}
|
||||
|
||||
describe("network flap", () => {
|
||||
it("never replays an unsafe mutation and keeps queues bounded across flaps", async () => {
|
||||
const network = flappingNetwork();
|
||||
const executor = testExecutor(network.transport, { maxRetryAttempts: 2 });
|
||||
let peakQueued = 0;
|
||||
|
||||
for (let cycle = 0; cycle < 400; cycle += 1) {
|
||||
network.setOnline(cycle % 2 === 0);
|
||||
const execution = testExecutionContext({
|
||||
maxPhysicalRequests: 4,
|
||||
maxRetries: 2,
|
||||
maxConcurrentRequests: 1,
|
||||
maxQueuedRequests: 2,
|
||||
});
|
||||
const context = { routeId: "TEST_ROUTE", scope: scopeSnapshot(), execution };
|
||||
const work = Promise.all([
|
||||
executor.execute(TEST_COMMAND, { name: `n${cycle}` }, { ...context, intent: intent(cycle) }),
|
||||
executor.execute(TEST_QUERY, { limit: 1 }, context),
|
||||
executor.execute(TEST_QUERY, { limit: 1 }, context),
|
||||
]);
|
||||
peakQueued = Math.max(peakQueued, execution.traffic.concurrency.queued);
|
||||
await work;
|
||||
expect(execution.traffic.concurrency.active).toBe(0);
|
||||
expect(execution.traffic.concurrency.queued).toBe(0);
|
||||
}
|
||||
|
||||
expect(Math.max(...network.commandDispatches.values())).toBe(1);
|
||||
expect(network.commandDispatches.size).toBe(400);
|
||||
expect(peakQueued).toBeLessThanOrEqual(2);
|
||||
});
|
||||
|
||||
it("completes cancellation of stale interactions when the network drops", async () => {
|
||||
const pendingSignals: AbortSignal[] = [];
|
||||
const transport: Transport = (_input, init) =>
|
||||
new Promise<Response>((_resolve, reject) => {
|
||||
if (init?.signal) pendingSignals.push(init.signal);
|
||||
init?.signal?.addEventListener(
|
||||
"abort",
|
||||
() => reject(new DOMException("aborted", "AbortError")),
|
||||
{ once: true },
|
||||
);
|
||||
});
|
||||
const executor = testExecutor(transport);
|
||||
const interactions = Array.from({ length: 50 }, () =>
|
||||
testExecutionContext({ maxConcurrentRequests: 1, maxQueuedRequests: 2 }),
|
||||
);
|
||||
const running = interactions.flatMap((execution) =>
|
||||
[0, 1, 2].map(() =>
|
||||
executor.execute(TEST_QUERY, { limit: 1 }, {
|
||||
routeId: "TEST_ROUTE",
|
||||
scope: scopeSnapshot(),
|
||||
execution,
|
||||
}),
|
||||
),
|
||||
);
|
||||
await vi.waitFor(() => expect(pendingSignals).toHaveLength(50));
|
||||
|
||||
// "offline" event: the session cancels every interaction started online.
|
||||
for (const execution of interactions) execution.cancellation.cancel();
|
||||
const outcomes = await Promise.all(running);
|
||||
|
||||
expect(outcomes.every((outcome) => outcome.kind === "CANCELLED")).toBe(true);
|
||||
expect(pendingSignals.every((signal) => signal.aborted)).toBe(true);
|
||||
for (const execution of interactions) {
|
||||
expect(execution.traffic.concurrency.active).toBe(0);
|
||||
expect(execution.traffic.concurrency.queued).toBe(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user