Carries 21 template commits: the shared IndexedDB connection/transaction
kernel and the four runtimes moved onto it, the adapter barrel boundary and
the architecture rule that enforces it, the feature adapter contribution
model, `feature-http-binding`, the split of several oversized test files,
and the release identity now derived from the package name.
Product identity is unchanged. The three hard-coded `tech-log-frontend/…`
verifier ids are gone because the template derives them from the package
name and this package is `tech-log-frontend`.
Two decisions worth naming. The platform HTTP executor is the template's
verbatim — it now takes the installed contract so a feature's types flow
through the binding — and TechLog's four gateways, which address operations
by id, reach it through one adapter at the composition root instead of being
rewritten here. And the three derived CI baselines were recomputed from the
merged `config/ci/gates.json` rather than taken from either side: 94 command
definitions, 106 references, 141 artifacts, gate shape `629e5898…`. The
method was checked by first reproducing the pre-merge values from the
pre-merge file.
Verified here: types, lint, architecture, adapter inventory, CI contract,
design system, diagnostics, remediation ledger, browser security and build
all pass; 1789 unit, 152 component, 415 TechLog, 102 integration, 19
reference-feature, 17 recipe and 7 contract tests pass. Five gates stay
red and every one was reproduced at b297d65 first: `check:i18n`,
`check:registries`, `test:runtime-schema`, `verify:documentation` and
`test:sample-removal`.
Full decision record, including what was deliberately not carried and the
five open follow-ups, in `docs/operations/template-sync-2026-09-21.md`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
136 lines
3.8 KiB
TypeScript
136 lines
3.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
createFeatureHttpBinding,
|
|
type InstalledHttpOperationExecutor,
|
|
} from "../../../src/adapters/http/index.ts";
|
|
import {
|
|
createReferenceHttpGateway,
|
|
REFERENCE_HTTP_OPERATIONS,
|
|
} from "../../../src/features/reference-feature/adapters/reference-http-gateway.ts";
|
|
|
|
function executorReturning(
|
|
outcome: Readonly<Record<string, unknown>>,
|
|
): InstalledHttpOperationExecutor {
|
|
const execute = (async () => outcome) as unknown as
|
|
InstalledHttpOperationExecutor["execute"];
|
|
return Object.freeze({ execute });
|
|
}
|
|
|
|
describe("reference HTTP business problem mapping", () => {
|
|
it("maps a typed 409 reference problem to the feature-owned business code", async () => {
|
|
const executor = executorReturning(
|
|
Object.freeze({
|
|
kind: "PROBLEM",
|
|
problem: Object.freeze({
|
|
type: "https://example.test/problems/reference-conflict",
|
|
title: "Reference conflict",
|
|
status: 409,
|
|
code: "REFERENCE_NAME_ALREADY_EXISTS",
|
|
}),
|
|
metadata: Object.freeze({ status: 409 }),
|
|
effect: "NOT_APPLIED",
|
|
}),
|
|
);
|
|
const gateway = createReferenceHttpGateway(
|
|
createFeatureHttpBinding(executor, REFERENCE_HTTP_OPERATIONS),
|
|
);
|
|
|
|
await expect(
|
|
gateway.create({ name: "duplicate" }),
|
|
).resolves.toMatchObject({
|
|
ok: false,
|
|
error: {
|
|
kind: "CONFLICT",
|
|
code: "REFERENCE_NAME_ALREADY_EXISTS",
|
|
httpStatus: 409,
|
|
},
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
{
|
|
status: 409,
|
|
code: undefined,
|
|
expectedKind: "CONFLICT",
|
|
expectedCode: "REFERENCE_RESOURCE_CONFLICT",
|
|
},
|
|
{
|
|
status: 422,
|
|
code: "REFERENCE_NAME_REJECTED",
|
|
expectedKind: "VALIDATION_REJECTED",
|
|
expectedCode: "REFERENCE_NAME_REJECTED",
|
|
},
|
|
{
|
|
status: 422,
|
|
code: undefined,
|
|
expectedKind: "VALIDATION_REJECTED",
|
|
expectedCode: "REFERENCE_RESOURCE_REJECTED",
|
|
},
|
|
{
|
|
status: 400,
|
|
code: "REFERENCE_BAD_REQUEST",
|
|
expectedKind: "UNKNOWN_CLIENT_FAILURE",
|
|
expectedCode: "CONTRACT_PROBLEM",
|
|
},
|
|
] as const)(
|
|
"projects create problem status $status through the feature-owned mapper/fallback",
|
|
async ({ status, code, expectedKind, expectedCode }) => {
|
|
const executor = executorReturning(
|
|
Object.freeze({
|
|
kind: "PROBLEM",
|
|
problem: Object.freeze({
|
|
type: "https://example.test/problems/reference-" + status,
|
|
title: "Reference request rejected",
|
|
status,
|
|
...(code === undefined ? {} : { code }),
|
|
}),
|
|
metadata: Object.freeze({ status }),
|
|
effect: "NOT_APPLIED",
|
|
}),
|
|
);
|
|
const gateway = createReferenceHttpGateway(
|
|
createFeatureHttpBinding(executor, REFERENCE_HTTP_OPERATIONS),
|
|
);
|
|
|
|
await expect(
|
|
gateway.create({ name: "rejected" }),
|
|
).resolves.toMatchObject({
|
|
ok: false,
|
|
error: {
|
|
kind: expectedKind,
|
|
code: expectedCode,
|
|
httpStatus: status,
|
|
},
|
|
});
|
|
},
|
|
);
|
|
|
|
it("keeps the platform status fallback when the operation has no problem mapper", async () => {
|
|
const executor = executorReturning(
|
|
Object.freeze({
|
|
kind: "PROBLEM",
|
|
problem: Object.freeze({
|
|
type: "https://example.test/problems/not-found",
|
|
title: "Not found",
|
|
status: 404,
|
|
}),
|
|
metadata: Object.freeze({ status: 404 }),
|
|
effect: "NOT_APPLIED",
|
|
}),
|
|
);
|
|
const gateway = createReferenceHttpGateway(
|
|
createFeatureHttpBinding(executor, REFERENCE_HTTP_OPERATIONS),
|
|
);
|
|
|
|
await expect(gateway.get("missing")).resolves.toMatchObject({
|
|
ok: false,
|
|
error: {
|
|
kind: "NOT_FOUND",
|
|
code: "CONTRACT_PROBLEM",
|
|
httpStatus: 404,
|
|
},
|
|
});
|
|
});
|
|
});
|