Skip to content

Commit 818b2a4

Browse files
committed
ci: ratchet against test-only exports
Three exported-and-unit-tested-but-unreferenced-in-production incidents this week (#1166 getNearestCommandNames, #1167 buildSettleTail, #1199 clearMetroSessionHints) — the first two were caught by fallow's dead-code check because they had zero importers anywhere; #1199 was missed because a test file imports the export, and fallow's default reachability graph counts a test import as "used". Adds a second, stricter pass reusing fallow's own --production mode (entry.exclude test/story/dev files) via scripts/test-only-exports/check.ts: an export alive in fallow's default graph but dead in its production graph, with no other reference anywhere in its own file, has no production call site — exactly the #1199 shape. Ratchets against a checked-in baseline (scripts/test-only-exports-baseline.json, 77 entries); new findings fail `pnpm check:test-only-exports` (wired into CI's Fallow job and check:tooling). A `// test-seam: <reason>` comment above an export is the escape hatch for intentional test seams. Also extends .fallowrc.json's ignoreExports for seven daemon route handlers (src/daemon/handlers/*.ts) that are genuinely production-reachable through request-handler-chain.ts's `typeof import()` lazy-load pattern, which fallow's static import graph can't trace as a named-export consumer — without this they were false positives in the production-mode pass.
1 parent ae74c51 commit 818b2a4

6 files changed

Lines changed: 625 additions & 1 deletion

File tree

‎.fallowrc.json‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,34 @@
8787
{
8888
"file": "src/cloud-webdriver.ts",
8989
"exports": ["CLOUD_WEBDRIVER_PROVIDERS"]
90+
},
91+
{
92+
"file": "src/daemon/handlers/lease.ts",
93+
"exports": ["handleLeaseCommands"]
94+
},
95+
{
96+
"file": "src/daemon/handlers/session.ts",
97+
"exports": ["handleSessionCommands"]
98+
},
99+
{
100+
"file": "src/daemon/handlers/snapshot.ts",
101+
"exports": ["handleSnapshotCommands"]
102+
},
103+
{
104+
"file": "src/daemon/handlers/react-native.ts",
105+
"exports": ["handleReactNativeCommands"]
106+
},
107+
{
108+
"file": "src/daemon/handlers/record-trace.ts",
109+
"exports": ["handleRecordTraceCommands"]
110+
},
111+
{
112+
"file": "src/daemon/handlers/find.ts",
113+
"exports": ["handleFindCommands"]
114+
},
115+
{
116+
"file": "src/daemon/handlers/interaction.ts",
117+
"exports": ["handleInteractionCommands"]
90118
}
91119
],
92120
"usedClassMembers": ["name", "listActiveLeases", "delete", "values", "elapsedMs", "isExpired"],

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ jobs:
168168
FALLOW_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
169169
run: pnpm check:fallow --base "$FALLOW_BASE"
170170

171+
- name: Check for test-only exports
172+
run: pnpm check:test-only-exports
173+
171174
coverage:
172175
# Runs the full unit + provider-integration suites under coverage with
173176
# thresholds, so a separate unit-tests job would rerun the same tests.

‎CONTRIBUTING.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ intentionally accepting a finding.
5656
- `pnpm fallow:all` — full-tree summary, includes grandfathered legacy findings
5757
- `pnpm fallow:baseline` — regenerate baselines (only to intentionally accept a finding)
5858

59+
Code quality (test-only exports): `pnpm check:test-only-exports` catches exports that only a
60+
test file imports — `fallow`'s default dead-code check treats a test import as a live consumer,
61+
so a function can be exported, unit-tested, and never actually called by production code without
62+
tripping it (this shipped in #1199's first revision). The check diffs fallow's default dead-code
63+
graph against its `--production` graph (which excludes test files); an export alive in the first
64+
and dead in the second has no production call site. New findings fail CI against the checked-in
65+
`scripts/test-only-exports-baseline.json`. Fix a finding by wiring the export into a real call
66+
site, deleting it, or — if it is an intentional test seam — adding `// test-seam: <reason>`
67+
directly above the export, which removes it from the check. Run
68+
`pnpm check:test-only-exports:baseline` to regenerate the baseline after fixing or intentionally
69+
accepting findings.
70+
5971
Optional device selectors for tests:
6072

6173
- `ANDROID_DEVICE=Pixel_9_Pro_XL` or `ANDROID_SERIAL=emulator-5554`

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@
113113
"check:fallow": "fallow audit",
114114
"check:layering": "node --experimental-strip-types --test scripts/layering/model.test.ts && node --experimental-strip-types scripts/layering/check.ts",
115115
"check:layering:baseline": "node --experimental-strip-types scripts/layering/check.ts --update-baseline",
116+
"check:test-only-exports": "node --experimental-strip-types scripts/test-only-exports/check.ts",
117+
"check:test-only-exports:baseline": "node --experimental-strip-types scripts/test-only-exports/check.ts --update-baseline",
116118
"check:quick": "pnpm lint && pnpm typecheck",
117119
"sync:mcp-metadata": "node scripts/sync-mcp-metadata.mjs",
118120
"check:mcp-metadata": "node scripts/sync-mcp-metadata.mjs --check",
119121
"version": "node scripts/sync-mcp-metadata.mjs && git add server.json",
120-
"check:tooling": "pnpm lint && pnpm typecheck && pnpm check:layering && pnpm check:mcp-metadata && pnpm build",
122+
"check:tooling": "pnpm lint && pnpm typecheck && pnpm check:layering && pnpm check:test-only-exports && pnpm check:mcp-metadata && pnpm build",
121123
"check:unit": "pnpm test:unit && pnpm test:smoke",
122124
"check": "pnpm check:tooling && pnpm check:fallow && pnpm check:unit",
123125
"prepack": "pnpm check:mcp-metadata && pnpm build:all && pnpm package:apple-runner:npm && pnpm package:android-snapshot-helper:npm && pnpm package:android-multitouch-helper:npm",

0 commit comments

Comments
 (0)