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 at 8210d48.

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 at
8210d48 first 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:
DongHyeonka
2026-11-12 08:28:54 +09:00
parent 585c62431a
commit c80320dfc7
738 changed files with 55027 additions and 13567 deletions
+448
View File
@@ -5,6 +5,11 @@ import {
createTelemetryAdapter,
safeTraceparent,
} from "../../src/adapters/telemetry/best-effort-telemetry.ts";
import {
createFeatureTelemetry,
createFetchTelemetryTransport,
} from "../../src/adapters/telemetry/feature-telemetry.ts";
import { createTelemetryCollector } from "../../src/adapters/telemetry/telemetry-collector.ts";
import {
TELEMETRY_REGISTRY,
projectTelemetryEvent,
@@ -356,3 +361,446 @@ describe("best-effort telemetry adapter", () => {
},
);
});
describe("telemetry collector payloads (Q-6.9-4)", () => {
function recordingFetcher() {
const calls: Array<Readonly<{ url: string; init: RequestInit }>> = [];
const fetcher = vi.fn(async (url: RequestInfo | URL, init?: RequestInit) => {
calls.push({ url: String(url), init: init ?? {} });
return new Response(null, { status: 204 });
});
return { calls, fetcher: fetcher as unknown as typeof fetch };
}
it("posts the contract projection for the application port", async () => {
const { calls, fetcher } = recordingFetcher();
const adapter = createTelemetryAdapter({
enabled: true,
endpoint: "https://telemetry.test/events",
schedule: () => {},
now: () => Date.parse("2026-09-24T00:00:00.000Z"),
fetcher,
});
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
expect(calls).toHaveLength(1);
expect(calls[0]?.url).toBe("https://telemetry.test/events");
expect(calls[0]?.init).toMatchObject({
method: "POST",
headers: { "Content-Type": "application/json" },
keepalive: true,
});
expect(JSON.parse(String(calls[0]?.init.body))).toEqual({
events: [
{
eventName: "api.request.failed",
timestamp: "2026-09-24T00:00:00.000Z",
attributes: validAttributes,
},
],
});
adapter.dispose();
});
it("posts the pipeline projection for the feature port", async () => {
const { calls, fetcher } = recordingFetcher();
const transport = createFetchTelemetryTransport({
endpoint: "https://telemetry.test/events",
fetcher,
});
await transport.send([
{
event: { kind: "catalog.load.failed", severity: "error", featureId: "catalog" },
fingerprint: "fp-1",
occurrences: 3,
},
]);
expect(calls).toHaveLength(1);
expect(calls[0]?.url).toBe("https://telemetry.test/events");
expect(calls[0]?.init).toMatchObject({
method: "POST",
headers: { "Content-Type": "application/json" },
keepalive: true,
credentials: "omit",
cache: "no-store",
});
expect(JSON.parse(String(calls[0]?.init.body))).toEqual({
events: [
{
kind: "catalog.load.failed",
severity: "error",
featureId: "catalog",
fingerprint: "fp-1",
occurrences: 3,
},
],
});
});
it("rejects a feature batch the collector refuses", async () => {
const transport = createFetchTelemetryTransport({
endpoint: "https://telemetry.test/events",
fetcher: (async () => new Response(null, { status: 503 })) as typeof fetch,
});
await expect(transport.send([])).rejects.toThrow();
});
});
describe("one collector transport for both telemetry ports (Q-6.9-4)", () => {
const featureEvent = {
kind: "catalog.load.failed",
severity: "error",
featureId: "catalog",
} as const;
const hungFetcher = () => {
const signals: AbortSignal[] = [];
// Never settles and ignores its signal: only the collector can end it.
const fetcher = vi.fn((_url: RequestInfo | URL, init?: RequestInit) => {
if (init?.signal) signals.push(init.signal);
return new Promise<Response>(() => {});
});
return { signals, fetcher: fetcher as unknown as typeof fetch, calls: fetcher };
};
it("sends application telemetry without cookies or HTTP cache", async () => {
const fetcher = vi.fn(async () => new Response(null, { status: 204 }));
const adapter = createTelemetryAdapter({
enabled: true,
endpoint: "https://telemetry.test/events",
schedule: () => {},
fetcher: fetcher as unknown as typeof fetch,
});
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
expect(fetcher).toHaveBeenCalledWith(
"https://telemetry.test/events",
expect.objectContaining({ credentials: "omit", cache: "no-store" }),
);
adapter.dispose();
});
it("times out a hung collector so later application flushes still send", async () => {
const { fetcher, calls } = hungFetcher();
const collector = createTelemetryCollector({
endpoint: "https://telemetry.test/events",
fetcher,
timeoutMs: 5,
});
const adapter = createTelemetryAdapter({
enabled: true,
endpoint: "https://telemetry.test/events",
schedule: () => {},
collector,
});
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
expect(adapter.dropReasons()).toEqual({ "sink-failure": 1 });
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
expect(calls).toHaveBeenCalledTimes(2);
adapter.dispose();
});
it("times out a hung collector for feature telemetry", async () => {
const { fetcher } = hungFetcher();
const telemetry = createFeatureTelemetry({
enabled: true,
endpoint: "https://telemetry.test/events",
collector: createTelemetryCollector({
endpoint: "https://telemetry.test/events",
fetcher,
timeoutMs: 5,
}),
});
await telemetry.emit(featureEvent);
await telemetry.flush();
expect(telemetry.stats()).toMatchObject({ sends: 1, failedSends: 1 });
telemetry.dispose();
});
it("shares one send-rate window between the two ports", async () => {
const fetcher = vi.fn(async () => new Response(null, { status: 204 }));
const collector = createTelemetryCollector({
endpoint: "https://telemetry.test/events",
fetcher: fetcher as unknown as typeof fetch,
maxSendsPerMinute: 1,
});
const adapter = createTelemetryAdapter({
enabled: true,
endpoint: "https://telemetry.test/events",
schedule: () => {},
setTimer: () => 0,
clearTimer: () => {},
collector,
});
const telemetry = createFeatureTelemetry({
enabled: true,
endpoint: "https://telemetry.test/events",
collector,
});
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
await telemetry.emit(featureEvent);
await telemetry.flush();
expect(fetcher).toHaveBeenCalledOnce();
expect(telemetry.stats().buffered).toBe(1);
adapter.dispose();
telemetry.dispose();
});
it("flushes feature telemetry on page exit and stops listening on dispose", async () => {
const lifecycle = new EventTarget();
const remove = vi.spyOn(lifecycle, "removeEventListener");
const fetcher = vi.fn(async () => new Response(null, { status: 204 }));
const telemetry = createFeatureTelemetry({
enabled: true,
endpoint: "https://telemetry.test/events",
collector: createTelemetryCollector({
endpoint: "https://telemetry.test/events",
fetcher: fetcher as unknown as typeof fetch,
lifecycle,
}),
});
await telemetry.emit(featureEvent);
await vi.waitFor(() => expect(fetcher).toHaveBeenCalledOnce());
// A duplicate is held until the next flush; page exit is that flush.
await telemetry.emit(featureEvent);
expect(fetcher).toHaveBeenCalledOnce();
lifecycle.dispatchEvent(new Event("pagehide"));
await vi.waitFor(() => expect(fetcher).toHaveBeenCalledTimes(2));
telemetry.dispose();
expect(remove).toHaveBeenCalledWith("pagehide", expect.any(Function));
});
it("aborts an in-flight feature batch on dispose", async () => {
const { fetcher, signals } = hungFetcher();
const telemetry = createFeatureTelemetry({
enabled: true,
endpoint: "https://telemetry.test/events",
fetcher,
});
await telemetry.emit(featureEvent);
await vi.waitFor(() => expect(signals).toHaveLength(1));
telemetry.dispose();
expect(signals[0]?.aborted).toBe(true);
});
});
/**
* 13-11. Failures must be attributable to a release while old and new tabs
* coexist, so every event the collector sends carries both identities.
*/
describe("collector release identity (13-11)", () => {
it("stamps build_id and release_id on every event of both ports", async () => {
const bodies: { events: Record<string, unknown>[] }[] = [];
const fetcher = vi.fn(async (_url: RequestInfo | URL, init?: RequestInit) => {
bodies.push(JSON.parse(String(init?.body)));
return new Response(null, { status: 204 });
});
const collector = createTelemetryCollector({
endpoint: "https://telemetry.test/events",
fetcher: fetcher as unknown as typeof fetch,
release: { buildId: "build-a", releaseId: "release-a" },
});
const adapter = createTelemetryAdapter({
enabled: true,
endpoint: "https://telemetry.test/events",
schedule: () => {},
collector,
});
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
await createFetchTelemetryTransport({
endpoint: "https://telemetry.test/events",
collector,
}).send([
{
event: { kind: "catalog.load.failed", severity: "error", featureId: "catalog" },
fingerprint: "fp-1",
occurrences: 1,
},
]);
// A split batch keeps the identity on every part.
await collector.post(
Array.from({ length: 70 }, (_, index) => ({ index, padding: "x".repeat(1_000) })),
);
const events = bodies.flatMap((body) => body.events);
expect(bodies.length).toBeGreaterThan(3);
expect(events).toHaveLength(72);
for (const sent of events) {
expect(sent).toMatchObject({ build_id: "build-a", release_id: "release-a" });
}
adapter.dispose();
});
});
/**
* 03-05. Fetch fails every keepalive request once the in-flight keepalive
* bodies exceed 64KiB, so a large queue must be split and the collector must
* never have more than that in flight with keepalive.
*/
describe("collector keepalive budget (03-05)", () => {
const KEEPALIVE_QUOTA = 64 * 1024;
const utf8 = new TextEncoder();
function recordingFetcher() {
const sent: { bytes: number; keepalive: boolean; events: number }[] = [];
let inflightKeepalive = 0;
let peakKeepalive = 0;
const releases: Array<() => void> = [];
const fetcher = vi.fn((_url: RequestInfo | URL, init?: RequestInit) => {
const body = String(init?.body);
const bytes = utf8.encode(body).byteLength;
const keepalive = init?.keepalive === true;
sent.push({
bytes,
keepalive,
events: (JSON.parse(body) as { events: unknown[] }).events.length,
});
if (keepalive) inflightKeepalive += bytes;
peakKeepalive = Math.max(peakKeepalive, inflightKeepalive);
return new Promise<Response>((resolve) => {
releases.push(() => {
if (keepalive) inflightKeepalive -= bytes;
resolve(new Response(null, { status: 204 }));
});
});
});
return {
sent,
peak: () => peakKeepalive,
releaseAll: () => releases.splice(0).forEach((release) => release()),
fetcher: fetcher as unknown as typeof fetch,
};
}
const bigEvents = (count: number) =>
Array.from({ length: count }, (_, index) => ({
index,
padding: "x".repeat(1_000),
}));
it("splits a queue over the keepalive limit into posts that all arrive", async () => {
const recording = recordingFetcher();
const collector = createTelemetryCollector({
endpoint: "https://telemetry.test/events",
fetcher: recording.fetcher,
});
const delivered = collector.post(bigEvents(70));
await vi.waitFor(() => expect(recording.sent.length).toBeGreaterThan(1));
recording.releaseAll();
await delivered;
expect(recording.sent.every((post) => post.bytes <= KEEPALIVE_QUOTA)).toBe(
true,
);
expect(recording.sent.reduce((sum, post) => sum + post.events, 0)).toBe(70);
expect(recording.peak()).toBeLessThanOrEqual(KEEPALIVE_QUOTA);
});
it("keeps concurrent posts under one keepalive quota", async () => {
const recording = recordingFetcher();
const collector = createTelemetryCollector({
endpoint: "https://telemetry.test/events",
fetcher: recording.fetcher,
});
// Two queues flushing together, as on pagehide.
const first = collector.post(bigEvents(40));
const second = collector.post(bigEvents(40));
await vi.waitFor(() => expect(recording.sent.length).toBeGreaterThan(1));
recording.releaseAll();
await Promise.all([first, second]);
expect(recording.peak()).toBeLessThanOrEqual(KEEPALIVE_QUOTA);
expect(recording.sent.some((post) => post.keepalive)).toBe(true);
expect(recording.sent.reduce((sum, post) => sum + post.events, 0)).toBe(80);
});
});
describe("telemetry adapter send-rate limit (spec §27)", () => {
function harness(maxSendsPerMinute = 3) {
let now = 0;
const timers: Array<() => void> = [];
const lifecycle = new EventTarget();
const fetcher = vi.fn(async () => new Response(null, { status: 204 }));
const adapter = createTelemetryAdapter({
enabled: true,
endpoint: "https://telemetry.test/events",
schedule: () => {},
fetcher,
lifecycle,
maxSendsPerMinute,
monotonicNow: () => now,
setTimer: (callback) => {
timers.push(callback);
return timers.length;
},
clearTimer: () => {},
});
return {
adapter,
fetcher,
lifecycle,
timers,
advance(ms: number) {
now += ms;
},
};
}
it("caps collector sends per minute during a sustained failure storm", async () => {
const { adapter, fetcher } = harness(3);
for (let i = 0; i < 25; i += 1) {
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
}
expect(fetcher).toHaveBeenCalledTimes(3);
expect(adapter.pendingCount()).toBeLessThanOrEqual(100);
});
it("delivers held events once the window reopens", async () => {
const { adapter, fetcher, timers, advance } = harness(1);
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
expect(fetcher).toHaveBeenCalledTimes(1);
expect(timers).toHaveLength(1);
advance(60_000);
timers.shift()?.();
await vi.waitFor(() => expect(fetcher).toHaveBeenCalledTimes(2));
expect(adapter.pendingCount()).toBe(0);
});
it("still delivers once on page exit when the window is exhausted", async () => {
const { adapter, fetcher, lifecycle } = harness(1);
adapter.emit("api.request.failed", validAttributes);
await adapter.flush();
adapter.emit("api.request.failed", validAttributes);
lifecycle.dispatchEvent(new Event("pagehide"));
await vi.waitFor(() => expect(fetcher).toHaveBeenCalledTimes(2));
adapter.dispose();
});
it("rejects an unbounded send rate", () => {
expect(() =>
createTelemetryAdapter({
enabled: true,
endpoint: "https://telemetry.test/events",
maxSendsPerMinute: Number.POSITIVE_INFINITY,
}),
).toThrow(TypeError);
});
});