ADR-088: Test-Tier Truthfulness
Status: Implemented Date: 2026-07-30 Sprint: 122 Version: 11.37.0 Deciders: Development Team Related: ADR-029 (TDD Test Framework, amended by this ADR — not superseded), ADR-014 (Testing Strategy), Sprint 122 PR 2 plan and spec
This record is for contributors who write, run or review Karmyq's automated tests.
We decided that a green test result must be evidence that the current code was tested. The team found four ways a test run could show green without proving that. Turbo, the tool that caches test runs, ignored changes to test files. It could replay an old pass after a test was edited or deleted. The script that promotes finished work-in-progress tests never looked inside the apps folders. The mobile app's test setup excused itself from having tests when it already had some. And a broken setup file for the automatic code-style checker was swallowed, so the job stayed green.
What it means for you: edit a test and the cached result no longer counts. New automatic checks fail if a test folder has files that no test command runs. The record says a later amendment, from a different work cycle, stopped work-in-progress tests from blocking a push in two services.
Does it still hold? Yes. The record is marked Implemented, and no later record replaces it. It amends ADR-029 and does not replace it. The record also names two gaps it left open, logged in the bug list. One is that the promotion script cannot see most frontend tests (BUG-033). The bug list still shows it open. The other is that the messaging service had no tests (BUG-034). The bug list now marks it fixed.
For builders: the full technical record
Trimmed in Sprint 149 for readability. Full earlier text: ADR-088 at d800110c
Context
A green test result is only useful if it is evidence that the current code was actually exercised. Four independent mechanisms in the repository let a green result be produced without that evidence, all measured 2026-07-30 on this branch before repair:
- Turbo cache keys did not include test files.
turbo.jsondeclared thetesttask'sinputsastest/**(singular), but every workspace stores its suites undertests/(plural). No#testtask hashed a single test file, jest config, or setup file.karmyq-auth-service#testhashed 15 inputs —package.jsonplus 14src/**files, zero tests. Three tasks hashed exactly one file (package.json):@karmyq/mobile#test,@karmyq/tests#test,geocoding-service#test. A developer could edit or delete a test, and Turbo would replay a cached "pass" from before the edit. - The TDD promoter never walked half the repo.
scripts/promote-tdd-tests.jsdeclared anAPPS_DIRconstant and never used it — onlySERVICES_DIRwas walked. Rootpackage.jsonruns the promoter asposttest.apps/landing/tests/tdd/sprint-99-network-visualization.test.tshad been passing and stranded in the WIP tier for that reason. apps/mobileclaimed an excuse that had gone stale. Its jest config setpassWithNoTests: trueunder the comment "until we write mobile tests," whileapps/mobile/tests/regression/notification-handler.test.tsalready existed and passed 2/2. A future deletion or rename of that file would have gone unnoticed.- Lint configuration failures are swallowed by design. CI runs lint as
npm run lint --if-present || echo "...", so any flat ESLint config that throws on load yields a green job. Four workspaces ship aneslint.config.js(frontend, landing, mobile, cleanup-service); as measured, all four resolve (frontend 112 rules, landing 112, mobile 442, cleanup-service 89).
Each defect has the same shape: a tier or gate that looks green for a reason unrelated to the code under test. None of the four is a test failure — each is a mechanism whose success signal had come unglued from the thing it claims to certify.
Decision
A green test result must be evidence that the current code was tested.
Operationally, this PR establishes and enforces four properties:
- Cache keys include the package's own files.
turbo.json'stesttask now declaresinputs: ["$TURBO_DEFAULT$"]instead of thetest/**glob. Measured input counts before → after:karmyq-auth-service#test15→38,@karmyq/mobile#test1→50,geocoding-service#test1→13,@karmyq/tests#test1→138,karmyq-frontend#test(apps/frontend) 225→377,karmyq-landing#test32→202.- This is still not a complete guarantee for
@karmyq/tests.$TURBO_DEFAULT$scopes a task's cache key to its own package directory. But the five new gates in this PR live in thetestsworkspace and audit other workspaces (Turbo's cache-key shape, tier-coverage parity, lint config loadability, Expo SDK alignment, the promoter's directory walk), so a change to a service or app they check does not appear in@karmyq/tests#test's own inputs.turbo.jsontherefore gives@karmyq/tests#testa package-specific override,"cache": false, so it always runs live. A localnpm testonly guarantees a task ran for real if the task either isn't cross-workspace, or is one of these fivetests-workspace gates.
- This is still not a complete guarantee for
- Every tier's jest invocation must list exactly the test files present on disk. A new
regression gate asserts, per workspace, that the resolved
testscript's tier invocations cover the files that exist under that workspace's test directories. It is tier-agnostic, because the repo has two legitimate layouts: tieredtest:unit/test:regression/test:tddscripts in most workspaces, and barejest— which runs every tier in one pass — incleanup-service,simulation-service,apps/landing, andapps/mobile. - Every workspace that can hold
tests/tdd/is walked by the promoter.promote-tdd-tests.jsnow walksAPPS_DIRas well asSERVICES_DIR. After the fix, 5 tests promoted fromtdd/toregression/: 4 inapps/frontend, 1 inapps/landing(the stranded sprint-99 test). apps/mobileno longer claims an excuse it doesn't have, and any configuration whose failure mode is silent gets a blocking gate proven non-vacuous at authoring time: new regression tests intests/regression/for the turbo cache-key shape, the per-workspace tier-coverage assertion, and the four flat ESLint configs' loadability, plus a blocking unit-tier test attests/unit/promote-tdd-targets.test.tsfor the promoter's directory coverage.
Why not bulk-delete --passWithNoTests
--passWithNoTests appears in 8 services plus apps/frontend and tests, generated in bulk by
scripts/add-tdd-scripts.js, and it is explicitly justified in ADR-029 ("Empty directories
initially… Requires --passWithNoTests"). Deleting it repo-wide would fight an Accepted ADR to
close a hazard the flag does not actually cause: the flag only changes jest's behavior when a tier
has zero matching files, which is a legitimate, common state. The real hazard was different in
kind — a tier that has files on disk whose jest invocation matches none of them (the
apps/mobile case in Context item 3). Removing --passWithNoTests would not have caught that;
asserting coverage does.
For that reason, ADR-088 amends ADR-029 rather than superseding it: ADR-029's three-tier structure, promotion model, and pre-push blocking behavior stand unchanged. This ADR adds the missing invariant ADR-029 didn't state — that a tier's script must actually cover the tier's files — and fixes the two places (Turbo's cache key, the promoter's directory walk) where that invariant silently failed to hold.
SDK_PINNED as the committed shadow of expo install --check
The Expo alignment gate's expoFamily() predicate matches only expo, expo-*, and @expo/*
packages. That predicate structurally excludes react, react-native, react-native-maps, and
react-native-safe-area-context — exactly the packages Sprint 122 PR 3 proposes moving off their
pinned versions. A gate that cannot see the packages about to change is another
green-for-the-wrong-reason mechanism. SDK_PINNED is a committed map that freezes those four
packages at the versions Sprint 121 PR 4 chose (the SDK's own compatibility matrix — what
npx expo install --check would assert live), so changing any of their versions requires editing
the map with a written reason.
Consequences
Positive Consequences
- A passing
#testtask, a passing tier invocation, a promoted TDD test, and a green lint job are all now evidence about the current code, not stale or structurally-blind signals. - Four new blocking gates in
tests/regression/, each proven non-vacuous by deliberate injection at authoring time (the oldtest/**glob restored and shown to produce blind tasks; a broken tier script shown to leave files uncovered; a missingeslint.config.jsscan shown to miss a new config; an off-pin Expo dependency shown to tripSDK_PINNED). apps/landing's previously-stranded sprint-99 test is now inregression/.
Negative Consequences
$TURBO_DEFAULT$widens the cache key. A README-only edit inside a package now misses that package's test cache. This is accepted deliberately: a false cache miss costs one extra test run; a false cache hit risks shipping a regression behind a cached "pass" that predates the change.- The TDD promoter is fixed but still
.ts-only.findTestFiles()inscripts/promote-tdd-tests.jsmatches only*.test.ts.apps/frontend/tests/tdd/holds 72.test.tsxfiles against 2.test.tsfiles, so roughly 97% of that directory remains invisible to the promoter. Measured: 67 of 74 frontendtdd/suites currently pass (442 tests) and would promote today if the filter were extended to.tsx. Maintainer decision (2026-07-30): not extended in this PR. Extending the filter would move ~442 tests into the blocking regression tier in a single change, a much larger and separately-reviewable decision. Logged asdocs/BUGS.mdBUG-033, not silently deferred. services/messaging-service— a Critical service — has zero test files and declares notestscript. No tier-coverage assertion can bite on a workspace with nothing to compare against, so the coverage gate is silent about messaging-service by construction, not by exemption. A "every Critical service has tests" gate cannot land as a blocking gate yet, because it would land red on day one. Logged asdocs/BUGS.mdBUG-034.
Neutral Consequences
- Workspaces using bare
jest(cleanup-service,simulation-service,apps/landing,apps/mobile) and workspaces using tieredtest:unit/test:regression/test:tddscripts are both legitimate layouts under the new coverage invariant; the gate is tier-agnostic.
Alternatives Considered
Alternative 1: Delete --passWithNoTests everywhere
- Would make every empty tier a hard failure, including the many legitimately-empty tiers ADR-029 already accounted for.
- Rejected: fights an Accepted ADR to solve a hazard the flag does not cause; the actual hazard (files present, none matched) needs a coverage assertion, not flag removal.
Alternative 2: Extend the TDD promoter to match .test.tsx in this PR
- Would immediately promote 67 of 74
apps/frontendtdd/suites (442 tests) into the blocking regression tier. - Rejected for this PR: the resulting blocking-tier size increase is a separate, larger decision that deserves its own review. Logged as a follow-up.
Alternative 3: Add a blocking "every Critical service has tests" gate now
- Would immediately fail on
services/messaging-service, which has zero test files today. - Rejected: a blocking gate cannot land red. This becomes addable once messaging-service has any test files to assert coverage over.
Alternative 4: Widen expoFamily() instead of adding SDK_PINNED
- Broadening the predicate to catch
react/react-native/react-native-maps/react-native-safe-area-contextwould require hardcoding non-expo-namespaced package names into a family matcher, which is fragile as the pinned set changes. - Rejected in favor of an explicit, committed map (
SDK_PINNED) that names exactly the packages and versions Sprint 121 PR 4 pinned, making future changes an explicit, reviewable edit.
Implementation Notes
- Files affected:
turbo.json;scripts/promote-tdd-tests.js;apps/mobile/jest.config.js; four new gates undertests/regression/—sprint-122-turbo-test-inputs.test.ts,sprint-122-tier-parity.test.ts,sprint-122-lint-config-gate.test.ts, andsprint-122-expo-sdk-alignment.test.ts(with its newSDK_PINNEDmap) — plus one new gate attests/unit/promote-tdd-targets.test.tsfor the promoter's directory coverage. - All four repaired mechanisms and their gates were verified non-vacuous by injecting the original defect and confirming the gate goes red, then restoring the file to a byte-identical state.
- Follow-ups logged in
docs/BUGS.md: BUG-033 (the.tsxgap in the TDD promoter's file filter) and BUG-034 (services/messaging-servicehas zero test coverage).
Amendment — Sprint 139 BUG-092: coverage is half the invariant (2026-11-09)
This ADR's tier-coverage gate proves every blocking file RUNS, and deliberately tolerates extra files — which is how
the bare-jest layout passed it. But a bare jest also selects tests/tdd/, so in cleanup-service and
simulation-service a red WIP test failed the default test and blocked a push, contrary to ADR-029 (cleanup's also
ran tests/integration/, through the spread root testMatch). The bare layout is legitimate only where a workspace
has no WIP tier to exclude.
Both services now use tiered scripts (test = test:unit && test:regression, plus test:tdd) and list their tier
patterns explicitly. The exclusion half is a separate gate, tests/regression/sprint-139-tdd-boundaries.test.ts: the
default selection is exactly the unit + regression files (real --listTests), a red tdd marker fails only an explicit
test:tdd run while red unit/regression markers still fail the default, and simulation's
sprint-134-demo-env-file suite — blocking until now only because of the sweep — moved to tests/regression/ and is
pinned by name. apps/landing and apps/mobile keep the bare layout; landing's tests/tdd/ is empty today.
References
- ADR-029: TDD Test Framework — amended by this ADR, not superseded
- ADR-014: Testing Strategy (Integration + E2E + Unit)
- Sprint 122 PR 2 plan and spec (
.superpowers/sdd/2026-07-30-sprint-122-pr2-test-tier-truthfulness/) scripts/promote-tdd-tests.jsturbo.jsondocs/guides/testing-guide.md