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,8 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { describe, expect, it } from "vitest";
|
||||
const files=["installed-product-manifest.ts","installed-feature-adapters.ts","installed-feature-runtimes.tsx","installed-feature-messages.ts","installed-contract-contributions.ts","installed-feature-contracts.ts"];
|
||||
describe("feature installation surface", () => {
|
||||
it("contains no reference-specific central imports", async () => {
|
||||
for(const name of files){const source=await readFile(new URL(`../../src/features/${name}`,import.meta.url),"utf8"); expect(source).not.toMatch(/REFERENCE_FEATURE_(ADAPTER|RUNTIME|CONTRACT)/); expect(source).not.toMatch(/REFERENCE_MESSAGE_CATALOGS/);}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { defineFeatureModule } from "../../src/features/feature-module.ts";
|
||||
|
||||
describe("defineFeatureModule", () => {
|
||||
it("keeps one stable feature id and freezes the descriptor", () => {
|
||||
const module = defineFeatureModule({
|
||||
id: "feature-a",
|
||||
contracts: { featureId: "feature-a" },
|
||||
routes: {}, adapters: [], runtimes: [], messages: {}, contractContributions: [],
|
||||
});
|
||||
expect(module.id).toBe("feature-a");
|
||||
expect(Object.isFrozen(module)).toBe(true);
|
||||
});
|
||||
|
||||
// 09-11: the one check defineFeatureModule makes at runtime.
|
||||
it("rejects a module whose id differs from its contract featureId", () => {
|
||||
expect(() =>
|
||||
defineFeatureModule({
|
||||
id: "feature-a",
|
||||
contracts: { featureId: "feature-b" },
|
||||
routes: {}, adapters: [], runtimes: [], messages: {}, contractContributions: [],
|
||||
}),
|
||||
).toThrow("Feature module id feature-a does not match contract featureId feature-b");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveProductFeatures, selectCompiledProductFeatures } from "../../src/contracts/product-features.ts";
|
||||
describe("product feature membership", () => {
|
||||
it("preserves selection semantics", () => {
|
||||
const compiled = [{featureId:"reference"},{featureId:"local-draft"}] as const;
|
||||
expect(selectCompiledProductFeatures(compiled,"reference").map(x=>x.featureId)).toEqual(["reference"]);
|
||||
});
|
||||
it("resolves installed state", () => {
|
||||
expect(resolveProductFeatures(["reference","local-draft"],["reference"]).map(x=>x.state)).toEqual(["NOT_INSTALLED","ACTIVE"]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
import { readFile, readdir } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createFailure } from "../../../src/contracts/errors.ts";
|
||||
import { isAppError } from "../../../src/platform/errors/app-error.ts";
|
||||
import {
|
||||
REFERENCE_ERRORS,
|
||||
toReferenceError,
|
||||
type ReferenceError,
|
||||
} from "../../../src/features/reference-feature/application/reference-error.ts";
|
||||
|
||||
describe("reference feature-local errors", () => {
|
||||
it("keeps concrete error kinds feature-local", () => {
|
||||
const error: ReferenceError = {
|
||||
kind: "reference.not-found",
|
||||
category: "domain",
|
||||
severity: "warning",
|
||||
retryability: "never",
|
||||
};
|
||||
|
||||
expect(isAppError(error)).toBe(true);
|
||||
for (const known of Object.values(REFERENCE_ERRORS)) {
|
||||
expect(isAppError(known)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("interprets only its own domain outcomes", () => {
|
||||
expect(toReferenceError(createFailure("NOT_FOUND", "GET_REFERENCE_RESOURCE", 0))).toBe(
|
||||
REFERENCE_ERRORS.NOT_FOUND,
|
||||
);
|
||||
expect(toReferenceError(createFailure("CONFLICT", "CREATE_REFERENCE_RESOURCE", 0))).toBe(
|
||||
REFERENCE_ERRORS.CONFLICT,
|
||||
);
|
||||
expect(
|
||||
toReferenceError(createFailure("NETWORK_UNREACHABLE", "GET_REFERENCE_RESOURCE", 0)),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("is not referenced by any global or central error union", async () => {
|
||||
const offenders: string[] = [];
|
||||
const walk = async (directory: string): Promise<void> => {
|
||||
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
||||
const target = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
if (!target.endsWith(path.join("features", "reference-feature"))) {
|
||||
await walk(target);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!/\.tsx?$/u.test(entry.name)) continue;
|
||||
const source = await readFile(target, "utf8");
|
||||
if (/reference-error\.ts|ReferenceError\b(?!Boundary)/u.test(source)) {
|
||||
offenders.push(target);
|
||||
}
|
||||
}
|
||||
};
|
||||
await walk(path.resolve("src"));
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
createQueryClient,
|
||||
QUERY_CACHE_DEFAULTS,
|
||||
} from "../../../src/adapters/query-cache/tanstack-query-cache.ts";
|
||||
import {
|
||||
jsonRows,
|
||||
networkFailure,
|
||||
type Transport,
|
||||
} from "../../helpers/traffic-test-kit.ts";
|
||||
import { referenceFeatureOver } from "./reference-traffic-kit.ts";
|
||||
|
||||
/**
|
||||
* Spec §16. Multiple consumers of one query identity must not imply multiple
|
||||
* physical requests. TanStack Query owns in-flight coalescing; this suite pins
|
||||
* that the installed query client plus the real V3 executor keep it that way.
|
||||
*/
|
||||
describe("request deduplication and coalescing", () => {
|
||||
function loadSameQuery(
|
||||
client: ReturnType<typeof createQueryClient>,
|
||||
reference: ReturnType<typeof referenceFeatureOver>,
|
||||
key: readonly unknown[] = ["reference", "list", { limit: 20 }],
|
||||
) {
|
||||
return client.fetchQuery({
|
||||
queryKey: key,
|
||||
queryFn: ({ signal }) => reference.listResources({ limit: 20 }, { signal }),
|
||||
});
|
||||
}
|
||||
|
||||
it("coalesces concurrent consumers of the same query identity", async () => {
|
||||
const transport = vi.fn<Transport>(async () => jsonRows(3));
|
||||
const reference = referenceFeatureOver(transport);
|
||||
const client = createQueryClient();
|
||||
|
||||
const results = await Promise.all([
|
||||
loadSameQuery(client, reference),
|
||||
loadSameQuery(client, reference),
|
||||
loadSameQuery(client, reference),
|
||||
]);
|
||||
|
||||
expect(transport).toHaveBeenCalledTimes(1);
|
||||
expect(results.every((result) => result.ok)).toBe(true);
|
||||
client.clear();
|
||||
});
|
||||
|
||||
it("keeps distinct query identities as distinct physical requests", async () => {
|
||||
const transport = vi.fn<Transport>(async () => jsonRows(1));
|
||||
const reference = referenceFeatureOver(transport);
|
||||
const client = createQueryClient();
|
||||
|
||||
await Promise.all([
|
||||
loadSameQuery(client, reference, ["reference", "list", 1]),
|
||||
loadSameQuery(client, reference, ["reference", "list", 2]),
|
||||
]);
|
||||
|
||||
expect(transport).toHaveBeenCalledTimes(2);
|
||||
client.clear();
|
||||
});
|
||||
|
||||
it("does not stack a query-layer retry on top of the executor retry budget", async () => {
|
||||
expect(QUERY_CACHE_DEFAULTS.retry).toBe(false);
|
||||
expect(QUERY_CACHE_DEFAULTS.mutationRetry).toBe(false);
|
||||
|
||||
const transport = vi.fn<Transport>(networkFailure);
|
||||
const reference = referenceFeatureOver(transport, { maxRetryAttempts: 2 });
|
||||
const client = createQueryClient();
|
||||
|
||||
await Promise.all([
|
||||
loadSameQuery(client, reference),
|
||||
loadSameQuery(client, reference),
|
||||
]);
|
||||
|
||||
// One coalesced logical execution: 1 attempt + at most 2 executor retries.
|
||||
expect(transport.mock.calls.length).toBeLessThanOrEqual(3);
|
||||
client.clear();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
assertRequestFanoutWithinBudget,
|
||||
RequestFanoutExceededError,
|
||||
} from "../../../src/platform/traffic/request-fanout.ts";
|
||||
import {
|
||||
jsonRows,
|
||||
paginatedCollection,
|
||||
testExecutionContext,
|
||||
type Transport,
|
||||
} from "../../helpers/traffic-test-kit.ts";
|
||||
import { referenceFeatureOver } from "./reference-traffic-kit.ts";
|
||||
|
||||
/** Physical requests one representative collection load may cost. */
|
||||
const COLLECTION_LOAD_FANOUT_BUDGET = 1;
|
||||
|
||||
describe("request fan-out budget", () => {
|
||||
it.each([10, 50, 100, 1_000])(
|
||||
"loads the first page of a %i-row collection with one physical request",
|
||||
async (totalRows) => {
|
||||
const transport = paginatedCollection(totalRows);
|
||||
const reference = referenceFeatureOver(transport);
|
||||
|
||||
const result = await reference.listResources({ limit: 100 });
|
||||
|
||||
expect(result).toMatchObject({ ok: true });
|
||||
expect(result.ok && result.value).toHaveLength(Math.min(totalRows, 100));
|
||||
expect(() =>
|
||||
assertRequestFanoutWithinBudget(transport.calls, COLLECTION_LOAD_FANOUT_BUDGET),
|
||||
).not.toThrow();
|
||||
},
|
||||
);
|
||||
|
||||
it("walks a 1,000-row collection in page-sized bulk requests, never one per row", async () => {
|
||||
const transport = paginatedCollection(1_000);
|
||||
const reference = referenceFeatureOver(transport);
|
||||
const rows: unknown[] = [];
|
||||
for (let cursor = 0; ; cursor += 100) {
|
||||
const page = await reference.listResources({
|
||||
limit: 100,
|
||||
...(cursor === 0 ? {} : { cursor: String(cursor) }),
|
||||
});
|
||||
expect(page.ok).toBe(true);
|
||||
if (!page.ok || page.value.length === 0) break;
|
||||
rows.push(...page.value);
|
||||
if (page.value.length < 100) break;
|
||||
}
|
||||
expect(rows).toHaveLength(1_000);
|
||||
// ceil(N / pageSize) + one empty terminal page, versus N per-row calls.
|
||||
expect(transport.calls).toBeLessThanOrEqual(Math.ceil(1_000 / 100) + 1);
|
||||
});
|
||||
|
||||
it("rejects a single oversized response in one request without row-proportional fan-out", async () => {
|
||||
const transport = vi.fn<Transport>(async () => jsonRows(1_000));
|
||||
const reference = referenceFeatureOver(transport);
|
||||
|
||||
const result = await reference.listResources({ limit: 100 });
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(transport).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("keeps a whole interaction's request count bounded while cardinality grows", async () => {
|
||||
const counts: number[] = [];
|
||||
for (const rows of [10, 100, 1_000]) {
|
||||
const transport = vi.fn<Transport>(paginatedCollection(rows));
|
||||
const reference = referenceFeatureOver(transport);
|
||||
const execution = testExecutionContext({ maxPhysicalRequests: 3 });
|
||||
await reference.listResources({ limit: 100 }, { execution });
|
||||
counts.push(transport.mock.calls.length);
|
||||
expect(execution.traffic.requests.consumed).toBe(transport.mock.calls.length);
|
||||
}
|
||||
expect(new Set(counts)).toEqual(new Set([1]));
|
||||
});
|
||||
|
||||
it("fails loudly when a flow exceeds its fan-out budget", () => {
|
||||
expect(() => assertRequestFanoutWithinBudget(4, 3)).toThrow(
|
||||
RequestFanoutExceededError,
|
||||
);
|
||||
expect(() => assertRequestFanoutWithinBudget(4, 3)).toThrow(
|
||||
/fan-out 4 exceeds 3/,
|
||||
);
|
||||
expect(() => assertRequestFanoutWithinBudget(1, 0)).toThrow(TypeError);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { DemoSessionAdapter } from "../../../src/adapters/auth/external-session-adapter.ts";
|
||||
import { createRuntimeAdapters } from "../../../src/bootstrap/runtime-adapters.ts";
|
||||
import { createRuntimeIdentityRegistry } from "../../../src/contracts/query-keys.ts";
|
||||
import { bindQuery } from "../../../src/contracts/server-state.ts";
|
||||
@@ -9,6 +10,41 @@ import {
|
||||
REFERENCE_RESOURCE_INVALIDATION_TOPIC,
|
||||
} from "../../../src/features/reference-feature/contracts/reference-feature-contract.ts";
|
||||
|
||||
// Template sync (af3d8e6). This product leaves the sample uninstalled
|
||||
// (src/features/reference-feature/NOT_INSTALLED): its feature-module.ts would
|
||||
// load the screens this product deleted. These tests exercise the production
|
||||
// graph with a real feature, so they install the sample themselves, the way
|
||||
// the template's platform tests install their test-only feature: through the
|
||||
// generated index, with the upstream descriptor minus its route runtime.
|
||||
vi.mock("../../../src/.generated/product-feature-index.ts", async () => {
|
||||
const { defineFeatureModule } = await import("../../../src/features/feature-module.ts");
|
||||
const { REFERENCE_FEATURE_ADAPTER_CONTRIBUTION } = await import(
|
||||
"../../../src/features/reference-feature/adapters/create-reference-feature-input.ts"
|
||||
);
|
||||
const { REFERENCE_FEATURE_CONTRACT } = await import(
|
||||
"../../../src/features/reference-feature/contracts/reference-feature-contract.ts"
|
||||
);
|
||||
const { REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION } = await import(
|
||||
"../../../src/features/reference-feature/contracts/reference-feature-contract-contribution.ts"
|
||||
);
|
||||
const { REFERENCE_MESSAGE_CATALOGS } = await import(
|
||||
"../../../src/features/reference-feature/contracts/reference-message-catalog.ts"
|
||||
);
|
||||
const module = defineFeatureModule({
|
||||
id: REFERENCE_FEATURE_CONTRACT.featureId,
|
||||
contracts: REFERENCE_FEATURE_CONTRACT,
|
||||
routes: REFERENCE_FEATURE_CONTRACT.routes,
|
||||
adapters: [REFERENCE_FEATURE_ADAPTER_CONTRIBUTION],
|
||||
runtimes: [],
|
||||
messages: REFERENCE_MESSAGE_CATALOGS,
|
||||
contractContributions: [REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION],
|
||||
});
|
||||
return {
|
||||
DECLARED_PRODUCT_FEATURE_IDS: [module.id],
|
||||
PRODUCT_FEATURE_MODULES: [module],
|
||||
};
|
||||
});
|
||||
|
||||
type Runtime = Parameters<typeof createRuntimeAdapters>[0]["runtime"];
|
||||
type Release = Parameters<typeof createRuntimeAdapters>[0]["release"];
|
||||
|
||||
@@ -44,7 +80,7 @@ const runtime: Runtime = {
|
||||
|
||||
const release: Release = {
|
||||
schemaVersion: 2,
|
||||
appVersion: "0.1.0",
|
||||
appVersion: "0.2.0",
|
||||
buildId: "build-a",
|
||||
commitSha: "abc123",
|
||||
configSchemaVersion: "2.0",
|
||||
@@ -212,4 +248,59 @@ describe("reference feature runtime composition", () => {
|
||||
expect(safeEvidence).not.toContain("private-idempotency-key");
|
||||
adapters.infrastructure.dispose();
|
||||
});
|
||||
|
||||
/**
|
||||
* R-3.2. A request refused before dispatch because no credential exists is
|
||||
* not a session verdict. Reporting it to the owner overwrote a recovering
|
||||
* session and could loop through the scope fence; only a server 401 may.
|
||||
*/
|
||||
it("does not report a request refused before dispatch as a sign-out", async () => {
|
||||
const fetcher = vi.fn(async () => Response.json([]));
|
||||
const adapters = await createRuntimeAdapters({
|
||||
runtime,
|
||||
release,
|
||||
host: {},
|
||||
fetcher,
|
||||
});
|
||||
const session = adapters.outputPorts.session as DemoSessionAdapter;
|
||||
session.setState("recovery-pending");
|
||||
await vi.waitFor(() =>
|
||||
expect(adapters.infrastructure.serverStateScope.getPhase()).toBe("READY"),
|
||||
);
|
||||
const notifications = vi.fn();
|
||||
session.subscribe(notifications);
|
||||
|
||||
await expect(
|
||||
referenceInput(adapters).listResources({ limit: 20 }),
|
||||
).resolves.toMatchObject({ ok: false });
|
||||
|
||||
expect(fetcher).not.toHaveBeenCalled();
|
||||
expect(session.getState()).toBe("recovery-pending");
|
||||
expect(notifications).not.toHaveBeenCalled();
|
||||
adapters.infrastructure.dispose();
|
||||
});
|
||||
|
||||
it("still signs out when the server answers 401", async () => {
|
||||
const fetcher = vi.fn(
|
||||
async () => new Response(null, { status: 401 }),
|
||||
);
|
||||
const adapters = await createRuntimeAdapters({
|
||||
runtime,
|
||||
release,
|
||||
host: {},
|
||||
fetcher,
|
||||
});
|
||||
await adapters.outputPorts.session.beginSignIn();
|
||||
await vi.waitFor(() =>
|
||||
expect(adapters.infrastructure.serverStateScope.getPhase()).toBe("READY"),
|
||||
);
|
||||
|
||||
await expect(
|
||||
referenceInput(adapters).listResources({ limit: 20 }),
|
||||
).resolves.toMatchObject({ ok: false });
|
||||
|
||||
expect(fetcher).toHaveBeenCalledOnce();
|
||||
expect(adapters.outputPorts.session.getState()).toBe("unauthenticated");
|
||||
adapters.infrastructure.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { createReferenceFeatureInput } from "../../../src/features/reference-feature/application/reference-feature-api.ts";
|
||||
import { createFailure } from "../../../src/contracts/errors.ts";
|
||||
import type { TelemetryPort } from "../../../src/platform/telemetry/telemetry-port.ts";
|
||||
import {
|
||||
createTelemetryPipeline,
|
||||
type TelemetryTransport,
|
||||
} from "../../../src/platform/telemetry/telemetry-pipeline.ts";
|
||||
import { REFERENCE_FEATURE_ADAPTER_CONTRIBUTION } from "../../../src/features/reference-feature/adapters/create-reference-feature-input.ts";
|
||||
|
||||
function failingGateway() {
|
||||
const failure = Object.freeze({
|
||||
ok: false as const,
|
||||
error: createFailure("REQUEST_TIMEOUT", "LIST_REFERENCE_RESOURCES", 0),
|
||||
});
|
||||
return Object.freeze({
|
||||
list: vi.fn(async () => failure),
|
||||
get: vi.fn(async () => failure),
|
||||
create: vi.fn(async () => failure),
|
||||
});
|
||||
}
|
||||
|
||||
describe("reference feature telemetry through the platform port", () => {
|
||||
it("declares the provider-neutral telemetry capability", () => {
|
||||
expect(REFERENCE_FEATURE_ADAPTER_CONTRIBUTION.needs).toContain("telemetry");
|
||||
});
|
||||
|
||||
it("emits a feature-owned event with a bounded payload on load failure", async () => {
|
||||
const emit = vi.fn<TelemetryPort["emit"]>();
|
||||
const input = createReferenceFeatureInput(failingGateway(), { telemetry: { emit } });
|
||||
|
||||
const result = await input.listResources({ limit: 20 });
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
kind: "reference.load.failed",
|
||||
severity: "warning",
|
||||
featureId: "reference-feature",
|
||||
payload: { operation: "list", reason: "REQUEST_TIMEOUT" },
|
||||
});
|
||||
});
|
||||
|
||||
it("returns the business result even when the port throws or rejects", async () => {
|
||||
const throwing = createReferenceFeatureInput(failingGateway(), {
|
||||
telemetry: {
|
||||
emit() {
|
||||
throw new Error("port broken");
|
||||
},
|
||||
},
|
||||
});
|
||||
const rejecting = createReferenceFeatureInput(failingGateway(), {
|
||||
telemetry: { emit: () => Promise.reject(new Error("collector down")) },
|
||||
});
|
||||
|
||||
await expect(throwing.getResource("id-1")).resolves.toMatchObject({ ok: false });
|
||||
await expect(rejecting.getResource("id-1")).resolves.toMatchObject({ ok: false });
|
||||
});
|
||||
|
||||
it("collapses a failure storm into bounded sends via the pipeline", async () => {
|
||||
const send = vi.fn<TelemetryTransport["send"]>();
|
||||
const pipeline = createTelemetryPipeline({ transport: { send } });
|
||||
const input = createReferenceFeatureInput(failingGateway(), { telemetry: pipeline });
|
||||
|
||||
for (let i = 0; i < 500; i += 1) await input.listResources({ limit: 20 });
|
||||
await pipeline.flush();
|
||||
|
||||
// The first failure goes out at once; the 499 duplicates ride on the flush.
|
||||
expect(send).toHaveBeenCalledTimes(2);
|
||||
const occurrences = send.mock.calls
|
||||
.flatMap(([batch]) => batch)
|
||||
.reduce((sum, item) => sum + item.occurrences, 0);
|
||||
expect(occurrences).toBe(500);
|
||||
expect(pipeline.stats().deduplicated).toBe(499);
|
||||
pipeline.dispose();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
import { createReferenceFeatureInstalledInput } from "../../../src/features/reference-feature/adapters/create-reference-feature-input.ts";
|
||||
import {
|
||||
scopeSnapshot,
|
||||
testExecutor,
|
||||
type Transport,
|
||||
} from "../../helpers/traffic-test-kit.ts";
|
||||
|
||||
/**
|
||||
* The reference feature's real application input, wired to the real V3
|
||||
* executor over an injected transport. Used to prove collection loads and
|
||||
* multi-operation interactions stay bounded end to end.
|
||||
*/
|
||||
export function referenceFeatureOver(
|
||||
transport: Transport,
|
||||
options: Parameters<typeof testExecutor>[1] = {},
|
||||
) {
|
||||
const executor = testExecutor(transport, {
|
||||
credentialHeaders: { authorization: "Bearer traffic-test-token" },
|
||||
...options,
|
||||
});
|
||||
return createReferenceFeatureInstalledInput({
|
||||
http: Object.freeze({
|
||||
execute(operation, input, context) {
|
||||
return executor.execute(operation, input, {
|
||||
routeId: context.routeId,
|
||||
scope: scopeSnapshot(),
|
||||
...(context.signal === undefined ? {} : { signal: context.signal }),
|
||||
...(context.intent === undefined ? {} : { intent: context.intent }),
|
||||
...(context.execution === undefined
|
||||
? {}
|
||||
: { execution: context.execution }),
|
||||
});
|
||||
},
|
||||
}),
|
||||
}).input;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { composeContractContributions } from "../../../src/contracts/external-contract-runtime.ts";
|
||||
import { REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION } from "../../../src/features/reference-feature/contracts/reference-feature-contract-contribution.ts";
|
||||
|
||||
describe("reference operation traffic policy", () => {
|
||||
it("declares explicit bounded traffic on every representative reference operation", () => {
|
||||
const composed = composeContractContributions([
|
||||
REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION,
|
||||
]);
|
||||
for (const operationId of [
|
||||
"LIST_REFERENCE_RESOURCES",
|
||||
"GET_REFERENCE_RESOURCE",
|
||||
"CREATE_REFERENCE_RESOURCE",
|
||||
]) {
|
||||
const traffic = composed.httpByOperationId.get(operationId)?.frontend.traffic;
|
||||
expect(traffic, operationId).toBeDefined();
|
||||
expect(Number.isSafeInteger(traffic?.maxPhysicalRequests)).toBe(true);
|
||||
}
|
||||
// A KEYED command never retries automatically; its policy says so too.
|
||||
expect(
|
||||
composed.httpByOperationId.get("CREATE_REFERENCE_RESOURCE")?.frontend
|
||||
.traffic,
|
||||
).toMatchObject({ maxPhysicalRequests: 1, maxRetries: 0 });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
CREATE_REFERENCE_RESOURCE_CONTRACT,
|
||||
LIST_REFERENCE_RESOURCES_CONTRACT,
|
||||
} from "../../../src/features/reference-feature/contracts/reference-feature-contract-contribution.ts";
|
||||
import {
|
||||
REFERENCE_RUNTIME_SCHEMA_CODECS,
|
||||
validateReferencePayload,
|
||||
validateReferenceRequest,
|
||||
} from "../../../src/features/reference-feature/contracts/reference-schemas.ts";
|
||||
|
||||
/**
|
||||
* Q-6.7-8 characterization. The reference feature exposes one schema through
|
||||
* two protocols: the canonical `RuntimeValidator` (array paths) for the HTTP
|
||||
* contract and the registry-facing `RuntimeSchemaCodec` (dotted paths). Both
|
||||
* must keep answering exactly this after they share one zod wrapper.
|
||||
*/
|
||||
describe("reference validator protocols", () => {
|
||||
const badList = [{ id: "unsafe", name: 42 }];
|
||||
|
||||
it("answers the canonical validator with array paths", () => {
|
||||
expect(
|
||||
LIST_REFERENCE_RESOURCES_CONTRACT.contract.outputValidator.safeParse(
|
||||
badList,
|
||||
),
|
||||
).toEqual({
|
||||
success: false,
|
||||
issues: [{ path: [0, "name"], code: "invalid_type" }],
|
||||
});
|
||||
expect(
|
||||
CREATE_REFERENCE_RESOURCE_CONTRACT.contract.inputValidator.safeParse({
|
||||
name: " Example ",
|
||||
}),
|
||||
).toEqual({ success: true, data: { name: "Example" } });
|
||||
});
|
||||
|
||||
it("answers the schema codec with dotted paths", () => {
|
||||
const codecs = REFERENCE_RUNTIME_SCHEMA_CODECS;
|
||||
expect(codecs.ReferenceResourceListPayload.parse(badList)).toEqual({
|
||||
success: false,
|
||||
issues: [{ path: "0.name", code: "invalid_type" }],
|
||||
});
|
||||
expect(
|
||||
codecs.CreateReferenceResourceCommand.parse({ name: "a", extra: 1 }),
|
||||
).toEqual({
|
||||
success: false,
|
||||
issues: [{ path: "", code: "unrecognized_keys" }],
|
||||
});
|
||||
expect(
|
||||
codecs.ReferenceResourceListQuery.parse({ limit: "5", tags: "open" }),
|
||||
).toEqual({ success: true, data: { limit: 5, tags: ["open"] } });
|
||||
expect(Object.keys(codecs)).toEqual([
|
||||
"ReferenceResourceParams",
|
||||
"ReferenceResourceListQuery",
|
||||
"NoRequest",
|
||||
"CreateReferenceResourceCommand",
|
||||
"ReferenceResourceListPayload",
|
||||
"ReferenceResourcePayload",
|
||||
]);
|
||||
for (const [schemaId, codec] of Object.entries(codecs)) {
|
||||
expect(codec.schemaId).toBe(schemaId);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps the payload and request lookups apart", () => {
|
||||
expect(validateReferencePayload("ReferenceResourceListPayload", badList))
|
||||
.toEqual({
|
||||
success: false,
|
||||
issues: [{ path: "0.name", code: "invalid_type" }],
|
||||
});
|
||||
expect(validateReferencePayload("NoRequest", {})).toEqual({
|
||||
success: false,
|
||||
issues: [{ path: "", code: "SCHEMA_NOT_REGISTERED" }],
|
||||
});
|
||||
expect(
|
||||
validateReferenceRequest("CreateReferenceResourceCommand", {
|
||||
name: " Example ",
|
||||
}),
|
||||
).toEqual({ success: true, data: { name: "Example" } });
|
||||
expect(
|
||||
validateReferenceRequest("ReferenceResourcePayload", {}),
|
||||
).toEqual({
|
||||
success: false,
|
||||
issues: [{ path: "", code: "SCHEMA_NOT_REGISTERED" }],
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createExternalAuthSessionAdapter } from "../../../src/adapters/auth/external-session-adapter.ts";
|
||||
import { createBffSessionOwner } from "../../../src/features/tech-log/adapters/http/bff-session-owner.ts";
|
||||
|
||||
// Template sync (af3d8e6). The runtime closes an external owner without
|
||||
// `readSubject` as `integration-failed`; the HTTP Studio's only owner is this one.
|
||||
describe("BFF session owner", () => {
|
||||
it("is a complete external owner and names no subject", async () => {
|
||||
const owner = createBffSessionOwner(
|
||||
"https://api.example.test/",
|
||||
async () => new Response(null, { status: 401 }),
|
||||
);
|
||||
// Compiles only while the owner has every method the adapter requires.
|
||||
const session = createExternalAuthSessionAdapter(owner);
|
||||
await owner.recoverSession();
|
||||
|
||||
expect(session.getState()).toBe("unauthenticated");
|
||||
expect(session.getSubject()).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
parseCaseContent,
|
||||
} from "../../../src/features/tech-log/domain/content-format/parse-case-content.ts";
|
||||
import {
|
||||
evidenceCatalogEntryFor,
|
||||
projectWorkingCopy,
|
||||
} from "../../../src/features/tech-log/domain/content-format/project-public-render-model.ts";
|
||||
import { serializeCaseContent } from "../../../src/features/tech-log/domain/content-format/serialize-case-content.ts";
|
||||
|
||||
@@ -13,14 +13,16 @@ type Equal<Left, Right> =
|
||||
: false;
|
||||
type Assert<Condition extends true> = Condition;
|
||||
|
||||
type TechLogFeatureInputExposesNoMissingOrAdditionalKeys = Assert<
|
||||
// Exported so noUnusedLocals keeps these compile-time checks rather than
|
||||
// flagging them; the `Assert` constraint is what fails the typecheck.
|
||||
export type TechLogFeatureInputExposesNoMissingOrAdditionalKeys = Assert<
|
||||
Equal<
|
||||
keyof ApplicationFeatureInputs["tech-log"],
|
||||
| "publicContent"
|
||||
| "createStudioApplication"
|
||||
>
|
||||
>;
|
||||
type TechLogFeatureInputRegistryValueMatchesFeatureContract = Assert<
|
||||
export type TechLogFeatureInputRegistryValueMatchesFeatureContract = Assert<
|
||||
Equal<ApplicationFeatureInputs["tech-log"], TechLogFeatureInput>
|
||||
>;
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import { MOCK_STUDIO_INSTALL_CONTEXT } from "../../helpers/studio-install-contex
|
||||
import {
|
||||
TECH_LOG_ROUTE_REGISTRY,
|
||||
TECH_LOG_ROUTE_RUNTIME_CONTRACT,
|
||||
type TechLogRouteId,
|
||||
} from "../../../src/features/tech-log/contracts/tech-log-route-contract.ts";
|
||||
import { PublicShell } from "../../../src/features/tech-log/presentation/public/public-shell.tsx";
|
||||
import { ExploreKindPage } from "../../../src/features/tech-log/presentation/public/pages/explore-kind-page.tsx";
|
||||
@@ -105,8 +104,15 @@ async function renderDiscoveryRoute<RouteId extends DiscoveryRouteId>(
|
||||
// 단언하도록 여기서 한 번 기다린다 — 각 테스트에 흩어 놓으면 빠뜨린 곳이 생긴다.
|
||||
// `main` 을 기다리지 않는다 — 이 파일에는 의도적으로 렌더에 실패하는 라우트도 있고,
|
||||
// 그때는 main 이 아예 없다. 로딩 표면이 사라지는 것이 두 경우 모두에 맞는 기준이다.
|
||||
// Template sync (af3d8e6): the route's own loading surface is now the shared
|
||||
// LoadingSurface too, so only a page's data loading is waited out here; a
|
||||
// route chunk a test holds pending stays on screen.
|
||||
await waitFor(() =>
|
||||
expect(document.querySelector(".state-surface--loading")).toBeNull(),
|
||||
expect(
|
||||
[...document.querySelectorAll(".state-surface--loading")].filter(
|
||||
(surface) => !surface.closest(".route-loading"),
|
||||
),
|
||||
).toEqual([]),
|
||||
);
|
||||
return { ...view, router } satisfies ReturnType<typeof render> & {
|
||||
router: RouterProviderProps["router"];
|
||||
@@ -391,7 +397,7 @@ describe("TechLog explore discovery", () => {
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByText("화면을 준비하고 있습니다.").closest("section"),
|
||||
screen.getByText("화면을 준비하고 있습니다.").closest(".route-loading"),
|
||||
).toHaveAttribute("data-surface", "none");
|
||||
await waitFor(() => expect(rejectNotFound).toBeTypeOf("function"));
|
||||
await act(async () => {
|
||||
@@ -423,9 +429,19 @@ describe("TechLog explore discovery", () => {
|
||||
}),
|
||||
}),
|
||||
]);
|
||||
// Template sync (af3d8e6, 08-07). An unrecovered chunk failure is now
|
||||
// recorded once, by the chunk boundary, under the not-found route's own
|
||||
// id and with the incident id its support reference shows. The route
|
||||
// render boundary still catches nothing.
|
||||
expect(
|
||||
record.mock.calls.some(([entry]) => entry.eventId === "ui.render.failed"),
|
||||
).toBe(false);
|
||||
record.mock.calls
|
||||
.map(([entry]) => entry)
|
||||
.filter((entry) => entry.eventId === "ui.render.failed"),
|
||||
).toEqual([
|
||||
expect.objectContaining({
|
||||
context: expect.objectContaining({ route_id: "NOT_FOUND" }),
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -65,8 +65,7 @@ function installedInputs(
|
||||
studioSource,
|
||||
publicSource,
|
||||
// Template sync (ebea300). The platform capability the manifest-governed
|
||||
// contributions declare in `needs`. Composition builds the reference
|
||||
// feature's gateway from it and never calls it here.
|
||||
// contributions declare in `needs`. Composition never calls it here.
|
||||
http: {
|
||||
async execute() {
|
||||
throw new Error("platform executor is not used by composition tests");
|
||||
@@ -82,10 +81,13 @@ function installedInputs(
|
||||
});
|
||||
}
|
||||
|
||||
test("installs TechLog beside the retained reference feature through application-facing inputs", async () => {
|
||||
test("installs TechLog through application-facing inputs", async () => {
|
||||
const installed = installedInputs();
|
||||
|
||||
assert.deepEqual(Object.keys(installed), ["reference-feature", "tech-log"]);
|
||||
// Template sync (af3d8e6). The reference sample is no longer installed
|
||||
// (src/features/reference-feature/NOT_INSTALLED), so TechLog is the only
|
||||
// input; it is composed directly and cannot be narrowed out.
|
||||
assert.deepEqual(Object.keys(installed), ["tech-log"]);
|
||||
assert.deepEqual(Object.keys(installed["tech-log"]).sort(), [
|
||||
"createStudioApplication",
|
||||
"publicContent",
|
||||
|
||||
@@ -77,7 +77,9 @@ type RequiredStudioGatewayOperation =
|
||||
| "getPublicationSnapshot"
|
||||
| "getCatalog";
|
||||
|
||||
type StudioGatewayExposesNoMissingOrAdditionalOperations = Assert<
|
||||
// Exported so noUnusedLocals keeps this compile-time check rather than
|
||||
// flagging it; the `Assert` constraint is what fails the typecheck.
|
||||
export type StudioGatewayExposesNoMissingOrAdditionalOperations = Assert<
|
||||
Equal<keyof StudioGateway, RequiredStudioGatewayOperation>
|
||||
>;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import { fireEvent, render as testingRender, screen, waitFor, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import type { ReactNode } from "react";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { fireEvent, render as testingRender, screen, waitFor } from "@testing-library/react";
|
||||
import { render as testingRender, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
import {
|
||||
@@ -188,7 +188,7 @@ describe("TechLog Studio publication flow", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the publish pending state, preserves gateway command order, and retries with a new key", async () => {
|
||||
it("keeps the publish pending state, preserves gateway command order, and retries with the original key", async () => {
|
||||
const user = userEvent.setup();
|
||||
const base = studioGatewayFromApplication(createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioApplication());
|
||||
const document = await warningReadyDocument(base);
|
||||
@@ -243,7 +243,9 @@ describe("TechLog Studio publication flow", () => {
|
||||
);
|
||||
await user.click(screen.getByRole("button", { name: "게시" }));
|
||||
await waitFor(() => expect(publishDocument).toHaveBeenCalledTimes(2));
|
||||
expect(keys[1]).not.toBe(keys[0]);
|
||||
// Template sync (af3d8e6, 03-01): a write whose outcome is unknown is sent
|
||||
// again with its original idempotency key, so the backend applies it once.
|
||||
expect(keys[1]).toBe(keys[0]);
|
||||
});
|
||||
|
||||
it("filters publication events and recovers a failed history read", async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { fireEvent, render as testingRender, screen, waitFor } from "@testing-library/react";
|
||||
import { render as testingRender, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { useEffect } from "react";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
@@ -176,7 +176,7 @@ describe("TechLog Studio save workflow", () => {
|
||||
expect(screen.getByRole("button", { name: "저장" })).toBeDisabled();
|
||||
});
|
||||
|
||||
it("surfaces a save error and retries with a new user-command key without losing input", async () => {
|
||||
it("surfaces a save error and retries with the original user-command key without losing input", async () => {
|
||||
const user = userEvent.setup();
|
||||
const base = studioGatewayFromApplication(createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioApplication());
|
||||
const keys: string[] = [];
|
||||
@@ -213,7 +213,9 @@ describe("TechLog Studio save workflow", () => {
|
||||
await user.click(screen.getByRole("button", { name: "저장" }));
|
||||
await waitFor(() => expect(screen.getByRole("status", { name: "편집 상태" })).toHaveTextContent("저장됨"));
|
||||
expect(saveDocument).toHaveBeenCalledTimes(2);
|
||||
expect(keys[1]).not.toBe(keys[0]);
|
||||
// Template sync (af3d8e6, 03-01): a write whose outcome is unknown is sent
|
||||
// again with its original idempotency key, so the backend applies it once.
|
||||
expect(keys[1]).toBe(keys[0]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ async function renderStudio(
|
||||
attachCredential: async () => ({ headers: {} }),
|
||||
recoverSession: async () => "restored" as const,
|
||||
notifyUnauthenticated: () => {},
|
||||
readSubject: () => "studio-shell-subject",
|
||||
}),
|
||||
featureInputs: {
|
||||
"tech-log": {
|
||||
|
||||
Reference in New Issue
Block a user