fix: address Phase 1 code-quality review findings

- Generator feature templates emit ctx-arg signatures + updated checklist
- signUpUseCase test for bus=undefined path
- di-explainer.html: bind-dev-seed no-arg → ctx
- data-flow-explainer.html: tradeoff card → ctx
- BindContextBase no longer exported
- CLAUDE.md binder bullet: drop vestigial cast guidance

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-09 13:17:04 +02:00
parent ca2e7d8c10
commit 723729dd9e
8 changed files with 34 additions and 19 deletions

View File

@@ -303,8 +303,8 @@ export default function generator(plop: PlopTypes.NodePlopAPI): void {
` 2. apps/web-next/src/server/bind-production.ts:`,
` - import { bindProduction${cap(a.name)} } from "${pkg}/di/bind-production";`,
` - import { bindDevSeed${cap(a.name)} } from "${pkg}/di/bind-dev-seed";`,
` - call bindProduction${cap(a.name)}(config, tracer, logger) (production branch)`,
` - call await bindDevSeed${cap(a.name)}(tracer, logger) (dev-seed branch)`,
` - call bindProduction${cap(a.name)}(ctx) (production branch, ctx: BindProductionContext)`,
` - call await bindDevSeed${cap(a.name)}(ctx) (dev-seed branch, ctx: BindContext)`,
"",
` 3. packages/core-api/src/root.ts:`,
` - import { ${camel(a.name)}Router } from "${pkg}/api";`,

View File

@@ -5,6 +5,7 @@ import {
type ITracer,
type ILogger,
} from "@repo/core-shared/instrumentation";
import type { BindContext } from "@repo/core-shared/di";
import { {{camelCase name}}Container } from "./container.js";
import { {{constantCase name}}_SYMBOLS } from "./symbols.js";
import { Mock{{pascalCase entity}}Repository } from "../infrastructure/repositories/{{kebabCase entity}}.repository.mock.js";
@@ -16,17 +17,17 @@ import type { I{{pascalCase entity}}Repository } from "../application/repositori
/**
* Replace the default mock with a populated one for dev mode + storybook.
*
* Mutually exclusive with `bindProduction{{pascalCase name}}(config, tracer, logger)`.
* Mutually exclusive with `bindProduction{{pascalCase name}}(ctx)`.
* Tests must NOT call this — they construct `new Mock{{pascalCase entity}}Repository()`
* directly and seed via factories per-test.
*
* Idempotent: safe to call multiple times; each call rebuilds a fresh
* populated repo and rebinds the symbol.
*/
export async function bindDevSeed{{pascalCase name}}(
tracer: ITracer,
logger: ILogger,
): Promise<void> {
export async function bindDevSeed{{pascalCase name}}(ctx: BindContext): Promise<void> {
const { tracer, logger, bus, queue, realtime, realtimeRegistry } = ctx;
void bus; void queue; void realtime; void realtimeRegistry;
// Bind shared instrumentation into feature container
if ({{camelCase name}}Container.isBound(INSTRUMENTATION_SYMBOLS.TRACER)) {
{{camelCase name}}Container.unbind(INSTRUMENTATION_SYMBOLS.TRACER);

View File

@@ -1,4 +1,3 @@
import type { SanitizedConfig } from "payload";
import {
withSpan,
withCapture,
@@ -6,17 +5,17 @@ import {
type ITracer,
type ILogger,
} from "@repo/core-shared/instrumentation";
import type { BindProductionContext } from "@repo/core-shared/di";
import { {{camelCase name}}Container } from "./container";
import { {{constantCase name}}_SYMBOLS } from "./symbols";
import { {{pascalCase entity}}Repository } from "../infrastructure/repositories/{{kebabCase entity}}.repository";
import { get{{pascalCase entity}}UseCase } from "../application/use-cases/get-{{kebabCase entity}}.use-case";
import { get{{pascalCase entity}}Controller } from "../interface-adapters/controllers/get-{{kebabCase entity}}.controller";
export function bindProduction{{pascalCase name}}(
config: SanitizedConfig,
tracer: ITracer,
logger: ILogger,
): void {
export function bindProduction{{pascalCase name}}(ctx: BindProductionContext): void {
const { config, tracer, logger, bus, queue, realtime, realtimeRegistry } = ctx;
void bus; void queue; void realtime; void realtimeRegistry;
// Bind shared instrumentation into feature container
if ({{camelCase name}}Container.isBound(INSTRUMENTATION_SYMBOLS.TRACER)) {
{{camelCase name}}Container.unbind(INSTRUMENTATION_SYMBOLS.TRACER);