Files
agentic-dev/docs/work/2026-05-13-binder-wrap-helper/01-wire-use-case-helper/_story.md
Danijel Martinek 317ec518aa docs(work): re-decompose binder-wrap-helper into vertical-slice stories
Re-decomposes the approved binder-wrap-helper PRD after the previous
8-story attempt (dropped in 71c04f5) sliced horizontally — its
"write test" / "write impl" splits would have left intermediate
commits red. The new shape obeys slice = task = PR = commit:

- 01-wire-use-case-helper — 1 task: ship the wireUseCase helper
  (factory composition + container bind + brand stack) with its
  unit tests and barrel export in one green commit. Blocks 02 + 03.
- 02-migrate-feature-binders — 5 tasks, one per feature
  (auth, blog, media, marketing-pages, navigation). Each task
  migrates that feature's bind-production.ts + bind-dev-seed.ts
  together and keeps all gates green.
- 03-update-generator-templates — 1 task: update the feature
  generator's bind-*.hbs so future scaffolds emit wireUseCase
  directly instead of inline withSpan + withCapture.

Output of the now-fixed sandcastle decompose dispatch — depends on
the completionSignal + maxIterations wiring (eadbb7e, 26aa97f).
2026-05-13 19:17:10 +02:00

2.9 KiB
Raw Blame History

id, epic, title, type, status, feature, depends-on, blocks
id epic title type status feature depends-on blocks
01-wire-use-case-helper 2026-05-13-binder-wrap-helper Introduce wireUseCase helper in core-shared technical-story in-progress core-shared
02-migrate-feature-binders
03-update-generator-templates

Goal

Add wire-use-case.ts + wire-use-case.test.ts to packages/core-shared/src/conformance/ and export the helper from the @repo/core-shared/conformance barrel. The helper encapsulates withSpan(withCapture(withAudit?(factory(deps)))) composition and performs the container bind step, so callers pass options and get back a brand-stacked wired value.

Why

Every feature binder currently inlines the same withSpan + withCapture wrapping per use case — 3079 lines of mechanical boilerplate per binder pair. A single helper in core-shared eliminates the structural clone groups and makes adjusting the wrapping shape a one-file change.

Done when

  • packages/core-shared/src/conformance/wire-use-case.ts exists and is exported from packages/core-shared/src/conformance/index.ts.
  • wire-use-case.test.ts covers: no-audit path (Instrumented + Captured brands present), audit path (Instrumented + Captured + Audited brands present), span-name derivation (<feature>.<name>), capture-tag structure ({ feature, layer, name }), container binding (symbol resolves to wired value), idempotent re-bind (unbind + bind when symbol already bound).
  • pnpm typecheck && pnpm test && pnpm lint && pnpm conformance && pnpm fallow:audit && pnpm coverage:diff all pass.
  • wire-use-case.ts reaches 100% statement/branch coverage (file is small; exhaustive test coverage is achievable).

In scope

  • packages/core-shared/src/conformance/wire-use-case.ts — the helper and its exported types.
  • packages/core-shared/src/conformance/wire-use-case.test.ts — unit tests using RecordingTracer / RecordingLogger / RecordingAuditLog (or equivalent mocks from core-shared/core-audit).
  • Export line added to packages/core-shared/src/conformance/index.ts.
  • No changes to withSpan, withCapture, or withAudit internals — the helper composes them as-is.

Out of scope

  • Feature binder changes (Story 02).
  • Generator template changes (Story 03).
  • wireController peer — the layer discriminator in wireUseCase covers controllers too if the shapes converge; a separate peer is a follow-up if needed.
  • Repository or service binding patterns.

Tasks

  • Add wire-use-case.ts + wire-use-case.test.ts to packages/core-shared/src/conformance/ and export from the conformance index — implement the helper (options object: container, symbol, factory, deps, feature, layer, name, tracer, logger, optional auditLog) with full unit tests covering both audit and no-audit paths, brand presence assertions via isInstrumented / isCaptured / isAudited, container binding, and idempotent re-bind; all gates pass on this single commit.