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:
@@ -1,97 +0,0 @@
|
||||
import type {
|
||||
BrowserDataResult,
|
||||
IndexedDbRepositoryPort,
|
||||
} from "../../../../src/application/ports/browser-file-storage/index.ts";
|
||||
|
||||
export type LocalDraft = Readonly<{
|
||||
draftId: string;
|
||||
title: string;
|
||||
body: string;
|
||||
}>;
|
||||
|
||||
export type SaveLocalDraftCommand = Readonly<{
|
||||
draft: LocalDraft;
|
||||
expectedRevision: number | null;
|
||||
idempotencyKey: string;
|
||||
}>;
|
||||
|
||||
export type RemoveLocalDraftCommand = Readonly<{
|
||||
draftId: string;
|
||||
expectedRevision: number;
|
||||
idempotencyKey: string;
|
||||
}>;
|
||||
|
||||
export type LocalDraftRecord = Readonly<{
|
||||
draft: LocalDraft;
|
||||
revision: number;
|
||||
}>;
|
||||
|
||||
export interface LocalDraftStore {
|
||||
save(
|
||||
command: SaveLocalDraftCommand,
|
||||
signal?: AbortSignal,
|
||||
): Promise<BrowserDataResult<Readonly<{ revision: number }>>>;
|
||||
find(
|
||||
draftId: string,
|
||||
signal?: AbortSignal,
|
||||
): Promise<BrowserDataResult<LocalDraftRecord | null>>;
|
||||
remove(
|
||||
command: RemoveLocalDraftCommand,
|
||||
signal?: AbortSignal,
|
||||
): Promise<BrowserDataResult<void>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Feature-owned binding over the technology-neutral IndexedDB application port.
|
||||
*
|
||||
* The feature knows its domain type and optimistic concurrency inputs. It does
|
||||
* not know database names, stores, transactions, native IDB objects, codecs,
|
||||
* migrations, quota handling or connection lifecycle.
|
||||
*/
|
||||
export function createLocalDraftStore(
|
||||
repository: IndexedDbRepositoryPort<LocalDraft, never>,
|
||||
): LocalDraftStore {
|
||||
const store: LocalDraftStore = {
|
||||
async save(command, signal) {
|
||||
const result = await repository.compareAndSwap({
|
||||
key: command.draft.draftId,
|
||||
value: command.draft,
|
||||
expectedRevision: command.expectedRevision,
|
||||
idempotencyKey: command.idempotencyKey,
|
||||
signal,
|
||||
});
|
||||
if (!result.ok) return result;
|
||||
return Object.freeze({
|
||||
ok: true as const,
|
||||
value: Object.freeze({ revision: result.value.revision }),
|
||||
});
|
||||
},
|
||||
|
||||
async find(draftId, signal) {
|
||||
const result = await repository.read(draftId, signal);
|
||||
if (!result.ok) return result;
|
||||
return Object.freeze({
|
||||
ok: true as const,
|
||||
value:
|
||||
result.value === null
|
||||
? null
|
||||
: Object.freeze({
|
||||
draft: result.value.value,
|
||||
revision: result.value.revision,
|
||||
}),
|
||||
});
|
||||
},
|
||||
|
||||
async remove(command, signal) {
|
||||
const result = await repository.remove({
|
||||
key: command.draftId,
|
||||
expectedRevision: command.expectedRevision,
|
||||
idempotencyKey: command.idempotencyKey,
|
||||
signal,
|
||||
});
|
||||
if (!result.ok) return result;
|
||||
return Object.freeze({ ok: true as const, value: undefined });
|
||||
},
|
||||
};
|
||||
return Object.freeze(store);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { readdir, readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
@@ -6,10 +7,25 @@ import type {
|
||||
BrowserDataResult,
|
||||
IndexedDbRepositoryPort,
|
||||
} from "../../../src/application/ports/browser-file-storage/index.ts";
|
||||
import {
|
||||
createLocalDraftStore,
|
||||
type LocalDraft,
|
||||
} from "./fixtures/local-draft-feature.ts";
|
||||
import { createLocalDraftStore } from "../../../src/features/local-draft-feature/adapters/local-draft-indexeddb-store.ts";
|
||||
import type { LocalDraft } from "../../../src/features/local-draft-feature/domain/local-draft.ts";
|
||||
|
||||
// 09-12. This probe used to exercise a copy of the feature under fixtures/,
|
||||
// which had drifted from src (it returned raw storage failures). It now reads
|
||||
// and runs the one implementation.
|
||||
const FEATURE_ROOT = "src/features/local-draft-feature";
|
||||
|
||||
async function featureSources(directory: string): Promise<string[]> {
|
||||
const entries = await readdir(directory, { withFileTypes: true });
|
||||
const nested = await Promise.all(
|
||||
entries.map((entry) => {
|
||||
const target = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) return featureSources(target);
|
||||
return /\.tsx?$/u.test(entry.name) ? [target] : [];
|
||||
}),
|
||||
);
|
||||
return nested.flat();
|
||||
}
|
||||
|
||||
function success<Value>(value: Value): BrowserDataResult<Value> {
|
||||
return Object.freeze({ ok: true as const, value });
|
||||
@@ -133,29 +149,26 @@ describe("IndexedDB local-draft consumer experience", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps native IndexedDB and runtime internals out of feature-owned code", async () => {
|
||||
const source = await readFile(
|
||||
new URL("./fixtures/local-draft-feature.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const importLines = source
|
||||
.split("\n")
|
||||
.filter((line) => line.startsWith("import "));
|
||||
expect(importLines).toHaveLength(1);
|
||||
expect(source).toContain(
|
||||
"src/application/ports/browser-file-storage/index.ts",
|
||||
);
|
||||
|
||||
for (const forbidden of [
|
||||
"src/adapters/storage/indexeddb",
|
||||
"globalThis.indexedDB",
|
||||
"IDBFactory",
|
||||
"IDBDatabase",
|
||||
"IDBTransaction",
|
||||
"IDBObjectStore",
|
||||
]) {
|
||||
expect(source).not.toContain(forbidden);
|
||||
it("keeps native IndexedDB and the storage runtime out of feature-owned code", async () => {
|
||||
const files = await featureSources(FEATURE_ROOT);
|
||||
expect(files.length).toBeGreaterThan(0);
|
||||
for (const file of files) {
|
||||
const source = await readFile(file, "utf8");
|
||||
for (const forbidden of [
|
||||
"adapters/storage/indexeddb",
|
||||
"application/ports/browser-file-storage",
|
||||
"globalThis.indexedDB",
|
||||
"IDBFactory",
|
||||
"IDBDatabase",
|
||||
"IDBTransaction",
|
||||
"IDBObjectStore",
|
||||
]) {
|
||||
const importsOrUses = source
|
||||
.split("\n")
|
||||
.filter((line) => !/^\s*(?:\*|\/\/)/u.test(line))
|
||||
.some((line) => line.includes(forbidden));
|
||||
expect(importsOrUses, `${file} uses ${forbidden}`).toBe(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -119,4 +119,66 @@ describe("feature adapter composition", () => {
|
||||
value: { draft, revision: 1 },
|
||||
});
|
||||
});
|
||||
|
||||
const http = Object.freeze({
|
||||
execute: async () => {
|
||||
throw new Error("HTTP should not execute during composition");
|
||||
},
|
||||
}) as unknown as InstalledHttpOperationExecutor;
|
||||
|
||||
it("rejects two contributions for the same feature id (Q-6.9-6)", () => {
|
||||
// A feature copied from another without renaming its id.
|
||||
const copied = defineFeatureAdapterContribution({
|
||||
...TEST_HTTP_FEATURE_ADAPTER_CONTRIBUTION,
|
||||
});
|
||||
expect(() =>
|
||||
composeFeatureAdapterInputs(
|
||||
Object.freeze([TEST_HTTP_FEATURE_ADAPTER_CONTRIBUTION, copied] as const),
|
||||
Object.freeze(["test-http-feature"]),
|
||||
Object.freeze({ http }),
|
||||
),
|
||||
).toThrow(/duplicate.*test-http-feature/u);
|
||||
});
|
||||
|
||||
it("names the feature and the capability the host did not provide (09-05)", () => {
|
||||
const withoutIndexedDb = Object.freeze({ http }) as unknown as Parameters<
|
||||
typeof composeFeatureAdapterInputs<
|
||||
readonly [typeof LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION]
|
||||
>
|
||||
>[2];
|
||||
expect(() =>
|
||||
composeFeatureAdapterInputs(
|
||||
Object.freeze([LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION] as const),
|
||||
Object.freeze(["local-draft"]),
|
||||
withoutIndexedDb,
|
||||
),
|
||||
).toThrow("feature local-draft needs indexedDb, which the host did not provide");
|
||||
// A feature switched off gets no input, so its needs are not asked for.
|
||||
expect(
|
||||
composeFeatureAdapterInputs(
|
||||
Object.freeze([LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION] as const),
|
||||
Object.freeze([]),
|
||||
withoutIndexedDb,
|
||||
),
|
||||
).toEqual({});
|
||||
});
|
||||
|
||||
it("rejects an input installed under another feature's id (Q-6.9-6)", () => {
|
||||
const wrongId = defineFeatureAdapterContribution({
|
||||
featureId: "test-http-feature",
|
||||
needs: ["http"] as const,
|
||||
createInput: () =>
|
||||
Object.freeze({
|
||||
featureId: "local-draft",
|
||||
input: {},
|
||||
}) as never,
|
||||
});
|
||||
expect(() =>
|
||||
composeFeatureAdapterInputs(
|
||||
Object.freeze([wrongId] as const),
|
||||
Object.freeze(["test-http-feature"]),
|
||||
Object.freeze({ http }),
|
||||
),
|
||||
).toThrow(/test-http-feature.*local-draft/u);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,7 +18,6 @@ import type {
|
||||
type ResourceInput = Readonly<{ resourceId: string }>;
|
||||
type ResourceWire = Readonly<{ id: string; title: string }>;
|
||||
type ResourceProblem = Readonly<{ code?: string }>;
|
||||
type Resource = Readonly<{ id: string; title: string }>;
|
||||
|
||||
function validator<T>(schemaId: string): RuntimeValidator<T> {
|
||||
return Object.freeze({
|
||||
@@ -189,6 +188,87 @@ describe("feature HTTP binding", () => {
|
||||
expect(result.error.code).toBe("MAPPING_INVARIANT_REJECTED");
|
||||
});
|
||||
|
||||
it.each([
|
||||
"FINAL_REQUEST_INVARIANT_FAILED",
|
||||
"MISSING_IDEMPOTENCY_KEY",
|
||||
"UNEXPECTED_IDEMPOTENCY_KEY",
|
||||
] as const)(
|
||||
"does not report the request-side violation %s as a server envelope mismatch",
|
||||
async (violationKind) => {
|
||||
const scripted = scriptedExecutor<ResourceWire, ResourceProblem>(
|
||||
Object.freeze({
|
||||
kind: "CONTRACT_VIOLATION" as const,
|
||||
violation: Object.freeze({
|
||||
kind: violationKind,
|
||||
operation: "REQUEST" as const,
|
||||
}),
|
||||
effect: "NOT_APPLICABLE" as const,
|
||||
}),
|
||||
);
|
||||
const binding = createFeatureHttpBinding(scripted.executor, OPERATIONS);
|
||||
|
||||
const result = await binding.execute("LOAD_RESOURCE", {
|
||||
resourceId: "resource-1",
|
||||
});
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: { kind: "VALIDATION_REJECTED", code: violationKind },
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
[
|
||||
"mapSuccess",
|
||||
Object.freeze({
|
||||
kind: "SUCCESS" as const,
|
||||
value: Object.freeze({ id: "resource-1", title: "Reference" }),
|
||||
metadata: Object.freeze({ status: 201 }),
|
||||
effect: "APPLIED_CONFIRMED" as const,
|
||||
}),
|
||||
],
|
||||
[
|
||||
"mapProblem",
|
||||
Object.freeze({
|
||||
kind: "PROBLEM" as const,
|
||||
problem: Object.freeze({ code: "RESOURCE_NAME_EXISTS" }),
|
||||
metadata: Object.freeze({ status: 409 }),
|
||||
effect: "APPLIED_CONFIRMED" as const,
|
||||
}),
|
||||
],
|
||||
])(
|
||||
"returns a mapping failure with the server effect when %s throws",
|
||||
async (_mapper, outcome) => {
|
||||
const scripted = scriptedExecutor<ResourceWire, ResourceProblem>(outcome);
|
||||
const binding = createFeatureHttpBinding(scripted.executor, {
|
||||
LOAD_RESOURCE: defineFeatureHttpOperation({
|
||||
contract: LOAD_RESOURCE_CONTRACT,
|
||||
routeId: "RESOURCE_DETAIL",
|
||||
mapSuccess(): never {
|
||||
throw new TypeError("mapper defect");
|
||||
},
|
||||
mapProblem(): never {
|
||||
throw new TypeError("mapper defect");
|
||||
},
|
||||
}),
|
||||
} as const);
|
||||
|
||||
const result = await binding.execute("LOAD_RESOURCE", {
|
||||
resourceId: "resource-1",
|
||||
});
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
kind: "MAPPING_CONTRACT_VIOLATION",
|
||||
code: "MAPPING_CONTRACT_VIOLATION",
|
||||
effect: "APPLIED_CONFIRMED",
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("lets the feature interpret a typed business problem", async () => {
|
||||
const scripted = scriptedExecutor<ResourceWire, ResourceProblem>(
|
||||
Object.freeze({
|
||||
|
||||
Reference in New Issue
Block a user