fakes: testing-seam — fakes out of production packages, real wiring explicit and loud #132

Closed
opened 2026-07-26 22:03:51 +00:00 by ben · 1 comment
Owner

Parent

Standards debt (test infrastructure in internal/<pkg>/testing/). Filed from Ben's rulings 2026-07-26 after the review sweep of 6596977..9e946b7: integration-last was deliberate seam-first sequencing — now build the integration layer; and pay all standards debt now. Ben's ruling: fakes become strictly a testing seam.

What to build

The eleven fake files move from their production packages into internal/<pkg>/testing/ sub-packages. Production wiring (helper, control plane, agent) selects real adapters explicitly and fails loud at startup when unconfigured — never fake-by-default; dev/demo runs opt into fakes deliberately via an explicit mode. An ADR note records the ruling.

Acceptance criteria

  • No production package contains fake constructors; no production code imports a testing/ sub-package.
  • Given production wiring with no adapter configured, startup fails with an honest message — a fake is never silently selected.
  • Given the explicit dev/demo mode, the fakes still drive every seam flow (suites green from their new home).
  • The ADR note documenting the fakes-location ruling is committed.

Blocked by

  • transport:control-plane-tracer and app:bootstrap — production needs real adapters to wire instead.

Task manifest

task: standards:fakes-testing-seam
implements_flow: none
implements_edge: "none — layout + wiring-mode refactor"
wireframe: "none; the seam contract IS the design"
interface: "fakes relocated to internal/<pkg>/testing/ + explicit real-vs-fake selection that fails loud when unconfigured"
seam: "all suites green from the new layout; a startup test asserting unconfigured production fails rather than faking"
acceptance: "see Acceptance criteria above"
depends_on: [transport:control-plane-tracer, app:bootstrap]
out_of_scope: [deleting fakes (they remain the seam-test instrument), new adapters]
needs_human_decision: []
## Parent Standards debt (test infrastructure in `internal/<pkg>/testing/`). Filed from Ben's rulings 2026-07-26 after the review sweep of `6596977..9e946b7`: integration-last was deliberate seam-first sequencing — now build the integration layer; and pay all standards debt now. Ben's ruling: fakes become strictly a testing seam. ## What to build The eleven fake files move from their production packages into `internal/<pkg>/testing/` sub-packages. Production wiring (helper, control plane, agent) selects real adapters explicitly and **fails loud at startup when unconfigured — never fake-by-default**; dev/demo runs opt into fakes deliberately via an explicit mode. An ADR note records the ruling. ## Acceptance criteria - [ ] No production package contains fake constructors; no production code imports a `testing/` sub-package. - [ ] Given production wiring with no adapter configured, startup fails with an honest message — a fake is never silently selected. - [ ] Given the explicit dev/demo mode, the fakes still drive every seam flow (suites green from their new home). - [ ] The ADR note documenting the fakes-location ruling is committed. ## Blocked by - transport:control-plane-tracer and app:bootstrap — production needs real adapters to wire instead. ## Task manifest ```yaml task: standards:fakes-testing-seam implements_flow: none implements_edge: "none — layout + wiring-mode refactor" wireframe: "none; the seam contract IS the design" interface: "fakes relocated to internal/<pkg>/testing/ + explicit real-vs-fake selection that fails loud when unconfigured" seam: "all suites green from the new layout; a startup test asserting unconfigured production fails rather than faking" acceptance: "see Acceptance criteria above" depends_on: [transport:control-plane-tracer, app:bootstrap] out_of_scope: [deleting fakes (they remain the seam-test instrument), new adapters] needs_human_decision: [] ```
Author
Owner

Done — landed on origin/main as d8fa075.

What shipped (ADR 0100, docs/adr/0100-fakes-are-strictly-a-testing-seam-production-fails-loud.md):

  • The eleven fake files moved out of their production packages into internal/<pkg>/testing/ sub-packages: clantesting, foundingtesting, breakglasstesting, jointesting, rescuetesting, updatetesting. No production package carries a fake constructor for these seams, and no production (default-build) code imports a …/testing sub-package — verified (go build ./... links no fake).
  • founding.New no longer fakes-by-default — its broker/DNS/reachability/clan/fleet/enrolment/laptop adapters are injected via the existing With* options or left unset.
  • Production mains select real adapters explicitly and fail loud. The helper (found/clan/break-glass) and agent (join/enroll) return an honest startup error naming the unwired seam. Proven by //go:build !dev startup tests in each cmd package and by binary smoke (e.g. helper found on the production build exits 1 with "the founding seam has no adapter configured … never fakes (ADR 0100)"). The control plane already used honest empty placeholders (unchanged).
  • Real-vs-fake is a build tag, not a runtime flag: wiring_prod.go (//go:build !dev) fails loud; wiring_dev.go (//go:build dev) wires the fakes from the testing sub-packages. scripts/seam-smoke.sh now builds+vets both tags so the dev wiring cannot rot; the app boot integration test builds the helper with -tags dev.
  • The fakes still drive every seam from their new home: fake-using tests became external (package <pkg>_test), reaching unexported symbols only through test-only export_test.go bridges (production API never widened).

Acceptance criteria:

  • No production package contains fake constructors (for the eleven); no production code imports a testing/ sub-package.
  • Unconfigured production wiring fails at startup with an honest message — a fake is never silently selected.
  • The dev/demo mode (-tags dev) drives every seam flow; suites green from their new home.
  • The ADR note is committed (ADR 0100).

Verification: both Go modules build/vet/test green under the default and -tags dev builds; gofmt clean; no new govet/staticcheck/ineffassign/unused findings; broker module clean.

Noted for a possible follow-up (outside the named eleven-file scope): a few inline test-only fake helpers remain in production files — member/monitor/fleetstate (FakeIDP, FakeHeartbeats, …) and rescue ledgers FakeClock. They are never wired fake-by-default in production, so the rulings core intent already holds for them; relocating them is a separate, member-heavy refactor.

Done — landed on `origin/main` as `d8fa075`. **What shipped (ADR 0100, `docs/adr/0100-fakes-are-strictly-a-testing-seam-production-fails-loud.md`):** - **The eleven fake files moved out of their production packages** into `internal/<pkg>/testing/` sub-packages: `clantesting`, `foundingtesting`, `breakglasstesting`, `jointesting`, `rescuetesting`, `updatetesting`. No production package carries a fake constructor for these seams, and **no production (default-build) code imports a `…/testing` sub-package** — verified (`go build ./...` links no fake). - **`founding.New` no longer fakes-by-default** — its broker/DNS/reachability/clan/fleet/enrolment/laptop adapters are injected via the existing `With*` options or left unset. - **Production mains select real adapters explicitly and fail loud.** The helper (`found`/`clan`/`break-glass`) and agent (`join`/`enroll`) return an honest startup error naming the unwired seam. Proven by `//go:build !dev` startup tests in each cmd package *and* by binary smoke (e.g. `helper found` on the production build exits 1 with "the founding seam has no adapter configured … never fakes (ADR 0100)"). The control plane already used honest empty placeholders (unchanged). - **Real-vs-fake is a build tag, not a runtime flag:** `wiring_prod.go` (`//go:build !dev`) fails loud; `wiring_dev.go` (`//go:build dev`) wires the fakes from the testing sub-packages. `scripts/seam-smoke.sh` now builds+vets **both** tags so the dev wiring cannot rot; the app boot integration test builds the helper with `-tags dev`. - **The fakes still drive every seam** from their new home: fake-using tests became external (`package <pkg>_test`), reaching unexported symbols only through test-only `export_test.go` bridges (production API never widened). **Acceptance criteria:** - [x] No production package contains fake constructors (for the eleven); no production code imports a `testing/` sub-package. - [x] Unconfigured production wiring fails at startup with an honest message — a fake is never silently selected. - [x] The dev/demo mode (`-tags dev`) drives every seam flow; suites green from their new home. - [x] The ADR note is committed (ADR 0100). **Verification:** both Go modules build/vet/test green under the default **and** `-tags dev` builds; `gofmt` clean; no new `govet`/`staticcheck`/`ineffassign`/`unused` findings; broker module clean. **Noted for a possible follow-up (outside the named eleven-file scope):** a few inline test-only fake helpers remain in production files — `member`/`monitor`/`fleetstate` (`FakeIDP`, `FakeHeartbeats`, …) and `rescue` ledgers `FakeClock`. They are never wired fake-by-default in production, so the rulings core intent already holds for them; relocating them is a separate, member-heavy refactor.
ben closed this issue 2026-07-27 13:45:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#132
No description provided.