Repository navigation
test: retire src/main/runtime cases that re-prove an owned contract - #24043
Conversation
Completes the `src/main` audit. Sweep over `src/main/runtime` (flat, rpc,
orchestration, relay, push) and flat `src/main`. 42 case declarations removed
across 24 files, 783 lines gone. No file deleted whole, no production code touched.
Highest-yield area by far was `runtime/orchestration` (21 cases from 151 files);
the rest of runtime measured under 1%.
What went, by pattern:
- Tests whose subject is the test itself: a source-scanning boundary test with no
production import at all, three of whose cases checked its own regex against
strings it declares; and a benchmark whose own simulation contains the
short-circuit it asserts, with `expect(wouldHaveBeen).toBe(60000)` comparing the
test's own arithmetic.
- Identity copiers: seven db cases where every asserted value is the literal input
(`type: 'question'` in, `type === 'question'` out).
- Permanently skipped tests for behavior that does not exist — two cases carrying
`// TODO: inline restore on re-subscribe not yet implemented`. A skipped test for
an unimplemented feature can never fail; it is a note in test syntax.
- Duplicate invocations of a contract owned at a stronger boundary, including three
reset scopes and two dependency-promotion cases owned by dedicated suites.
- Registration manifests whose every entry is referenced by other tests.
- Table rows and cases varying a field production never reads: a mobile tab-restore
case varying `clientCapabilities`, which the mobile branch does not consult, and
a Windows worker case in a module with no platform input at all.
- Names promising more than the input exercises: a case titled for forged AppImage
variables whose body only removes `AppRun`, byte-identical to a row of the
`it.each` table twenty lines above.
- Negative controls passing for an unrelated reason: a foreign-pane rejection whose
fixture also differs in sender handle, so the handle guard can reject it.
- Self-comparisons, including `format(m, { authority: 'current' }) === format(m)`.
Two deletions were justified by the wrong argument and kept only after checking a
better one. "A generated-catalog check gates registration" is false: that script
prevents the catalog and dispatcher from drifting apart, so a developer who removes
a method regenerates the catalog and the check passes. Like a type annotation over
an interface and its implementing class, it verifies internal consistency and
cannot see a declaration and its use removed together. Both inventories go on
per-entry evidence instead — every name is referenced by other tests.
The same rule kept a 37-entry terminal-method inventory in the same wave, because
some of its entries are pinned solely by it. An inventory is a ratchet if and only
if at least one entry is pinned solely by it; that is evidence per entry, not a
verdict by shape.
Kept deliberately: everything a gate cites, checked by case title and not only by
file path; source-scanning ratchets that pair their negative assertion with a
positive one against real source (the surviving boundary case asserts the pattern
still matches the writer module, so a silently-broken regex goes red); a
destructive-delete PTY waiver guard; `it.fails` markers, which go red if the bug is
fixed; and `it.skipIf(platform)` cases, which do run on other hosts.
Coverage is partial and stated as such: 1,195 files in scope, roughly 660 read
case-by-case, the remainder title-scanned and mechanically triaged. Unread paths are
recorded for a later sweep rather than assumed clean.
Verified: `check-reliability-gates.mjs` (140 gates), `check:code-quality:changed`
(0 new findings). No `pnpm tc` needed since no production file changed. A local run
of `src/main` surfaced 42 failures in three files this change does not touch
(`browser-manager-tab-identity`, `browser-manager-viewport-ownership`,
`session-scanner-codex-workers`); all 42 reproduce on a pristine `origin/main`
worktree, so they predate this wave and are environment-dependent locally — CI was
green on main at `2d85fdc753e2`.
|
| expect(ptySize).toEqual({ cols: 120, rows: 35 }) | ||
| expect(resizes).toEqual(['pty-1:42x18', 'pty-1:120x35']) | ||
| }) | ||
|
|
||
| it('disconnect auto-restore also resizes PTY (when auto-restore is configured)', async () => { | ||
| // Why: indefinite hold (mobileAutoRestoreFitMs=null) is the default and | ||
| // intentionally suppresses disconnect-driven auto-restore so the desktop | ||
| // banner stays mounted after the phone leaves. This test verifies the | ||
| // legacy auto-restore path still works when the user opts into a finite | ||
| // window. See docs/mobile-fit-hold.md. | ||
| const finiteRestoreStore = { | ||
| ...store, | ||
| getSettings: () => ({ ...store.getSettings(), mobileAutoRestoreFitMs: 5_000 }) | ||
| } | ||
| const runtime = new OrcaRuntimeService(finiteRestoreStore) | ||
| let ptySize = { cols: 100, rows: 30 } | ||
|
|
||
| runtime.setPtyController({ | ||
| write: () => true, | ||
| kill: () => true, | ||
| getForegroundProcess: async () => null, | ||
| resize: (_ptyId, cols, rows) => { | ||
| ptySize = { cols, rows } | ||
| return true | ||
| }, | ||
| getSize: () => ({ ...ptySize }) | ||
| }) | ||
| runtime.setNotifier({ | ||
| worktreesChanged: vi.fn(), | ||
| reposChanged: vi.fn(), | ||
| activateWorktree: vi.fn(), | ||
| createTerminal: vi.fn(), | ||
| splitTerminal: vi.fn(), | ||
| renameTerminal: vi.fn(), | ||
| focusTerminal: vi.fn(), | ||
| closeTerminal: vi.fn(), | ||
| sleepWorktree: vi.fn(), | ||
| terminalFitOverrideChanged: vi.fn(), | ||
| terminalDriverChanged: vi.fn() | ||
| }) | ||
|
|
||
| await runtime.resizeForClient('pty-1', 'mobile-fit', 'phone-disconnect', 45, 20) | ||
| expect(ptySize).toEqual({ cols: 45, rows: 20 }) | ||
|
|
||
| // Simulate WS disconnect | ||
| runtime.onClientDisconnected('phone-disconnect') | ||
| // onClientDisconnected enqueues fire-and-forget; flush microtasks | ||
| await new Promise((r) => setTimeout(r, 0)) | ||
| expect(ptySize).toEqual({ cols: 100, rows: 30 }) | ||
| expect(runtime.getTerminalFitOverride('pty-1')).toBeNull() | ||
| }) | ||
|
|
||
| it('disconnect with indefinite hold (default) keeps PTY at phone dims', async () => { | ||
| const runtime = new OrcaRuntimeService(store) | ||
| let ptySize = { cols: 100, rows: 30 } | ||
|
|
||
| runtime.setPtyController({ | ||
| write: () => true, | ||
| kill: () => true, | ||
| getForegroundProcess: async () => null, | ||
| resize: (_ptyId, cols, rows) => { | ||
| ptySize = { cols, rows } | ||
| return true | ||
| }, | ||
| getSize: () => ({ ...ptySize }) | ||
| }) | ||
| runtime.setNotifier({ | ||
| worktreesChanged: vi.fn(), | ||
| reposChanged: vi.fn(), | ||
| activateWorktree: vi.fn(), | ||
| createTerminal: vi.fn(), | ||
| splitTerminal: vi.fn(), | ||
| renameTerminal: vi.fn(), | ||
| focusTerminal: vi.fn(), | ||
| closeTerminal: vi.fn(), | ||
| sleepWorktree: vi.fn(), | ||
| terminalFitOverrideChanged: vi.fn(), | ||
| terminalDriverChanged: vi.fn() | ||
| }) | ||
|
|
||
| // Default mobileAutoRestoreFitMs is null (indefinite hold). | ||
| await runtime.resizeForClient('pty-1', 'mobile-fit', 'phone-disconnect', 45, 20) | ||
| expect(ptySize).toEqual({ cols: 45, rows: 20 }) | ||
|
|
||
| runtime.onClientDisconnected('phone-disconnect') | ||
| await new Promise((r) => setTimeout(r, 0)) | ||
|
|
||
| // PTY stays at phone dims and override persists — desktop banner remains. | ||
| expect(ptySize).toEqual({ cols: 45, rows: 20 }) | ||
| expect(runtime.getTerminalFitOverride('pty-1')).not.toBeNull() | ||
| }) | ||
| }) |
There was a problem hiding this comment.
Legacy disconnect coverage removed
Older mobile builds still use resizeForClient('mobile-fit'), which has its own disconnect handling. The remaining test restores explicitly, while the remaining disconnect tests use subscriptions. Without the removed cases, a change that leaves a PTY at phone size despite finite auto-restore—or restores it despite an indefinite hold—could pass unnoticed. Please keep tests for both settings on this legacy path.
Knowledge Base Used: Terminal runtime and interaction
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Comments Outside DiffThese findings could not be posted inline.
|
There was a problem hiding this comment.
Important
One deleted case is the only test of a real production contract — the task-decomposition parent/parentId path. Removing it leaves the parent param of orchestration.taskCreate / orchestration.workerStart with no owner, which contradicts the PR's core claim that every retired case's contract is owned at a stronger boundary. Details inline.
Reviewed changes
- Retired registration inventories —
runs.test.ts,computer.test.ts,browser-client-host.test.ts,browser-network-tunnel.test.tsdropALL_RPC_METHODS/ registry dumps; spot-checked names are exercised by dedicated suites. - Retired self-tests of test-owned helpers — the empty-dispatch benchmark's
simulateGraphPublishcontained its own short-circuit, and the dispatch-row-writer regex was asserted against strings the test defined. - Retired identity copiers / self-comparisons — message payload,
format(m) === format(m, { authority: 'current' }), same-referenceeraseRpcMethods,devMode: false, AppImage duplicate, and the star-nag/pasteText variants now owned by survivingit.eachtables. - Retired skipped TODOs, fake platform cases, and duplicate disconnect/restore cases — owned by the fit-hold suite,
db-task-create-readiness, andorchestration-reset-db. - Deleted a whole file —
runtime-rpc-mobile-native-chat-settings.test.ts; its allowlist assertion is covered bymobile-rpc-allowlist.test.ts. - One unique-coverage loss —
db.test.tssupports parent_id for task decomposition(see inline).
ℹ️ PR description overstates the deletion policy
The body says "No file deleted whole" and "42 test case declarations across 24 files", but src/main/runtime/runtime-rpc-mobile-native-chat-settings.test.ts is removed entirely (the 25th file). I verified its single contract — settings.mutateNativeChatSessionOptions being in MOBILE_RPC_METHOD_ALLOWLIST — is genuinely owned by mobile-rpc-allowlist.test.ts, so there is no code concern here; the description just does not match the diff, which matters for a change whose entire value is the accuracy of its coverage claims.
Technical details
# Whole-file deletion not reflected in the PR description
## Affected sites
- `src/main/runtime/runtime-rpc-mobile-native-chat-settings.test.ts` — deleted whole (was 8 lines, one test).
- PR body — "No file deleted whole" and "24 files".
## Required outcome
- Description should state that one file is deleted whole and that the 42-case/24-file count excludes it. No code change required.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| it('supports parent_id for task decomposition', () => { | ||
| const d = createDb() | ||
| const parent = d.createTask({ runId, spec: 'parent' }) | ||
| const child = d.createTask({ runId, spec: 'child', parentId: parent.id }) | ||
| expect(child.parent_id).toBe(parent.id) | ||
| }) |
There was a problem hiding this comment.
This is the only test anywhere that passes parentId to createTask (and the only one that exercises parent on orchestration.taskCreate / orchestration.workerStart). That parameter is live production input: message-methods.ts:189 forwards parentId: params.parent, local-worker-start.ts:115 and federated-worker-start.ts:129 forward taskParentId: params.parent, and task-store.ts:32-36 carries a Parent task … must belong to run … guard. After this PR nothing covers the task-decomposition path, so the body's "each of those contracts has one test that owns it" does not hold for this one. Consider restoring the case or adding a parent assertion to an existing tasks-dispatch.test.ts taskCreate case.
Technical details
# `parent`/`parentId` task-decomposition path loses its only test
## Affected sites
- `src/main/runtime/orchestration/db.test.ts` — `it('supports parent_id for task decomposition')` deleted (old lines 174-179).
- `src/main/runtime/rpc/methods/orchestration/messaging/message-methods.ts:189` — `orchestration.taskCreate` passes `parentId: params.parent`.
- `src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts:115`, `.../federation/federated-worker-start.ts:129` — `orchestration.workerStart` passes `taskParentId: params.parent`.
- `src/main/runtime/orchestration/db/tasks/task-store.ts:32-36` — parent-belongs-to-run guard.
## Required outcome
- The `parent` → `parent_id` wiring (and the guard) remains covered by at least one test at a caller-reachable boundary, per the PR's stated ownership rule.
## Suggested approach
- Restore the deleted `db.test.ts` case, or add a `parent` argument to `tasks-dispatch.test.ts`'s `orchestration.taskCreate` suite and assert the returned/persisted `parent_id`.|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (25)
💤 Files with no reviewable changes (22)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe pull request removes or revises tests across runtime, orchestration, and RPC suites. Changes include removing integration and database tests, deleting several RPC registration checks, and splitting checks for forbidden UI fields into separate tests. One mobile restore test now covers clients without advertised capabilities. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to This change only trims redundant tests and does not alter runtime behavior. No concrete merge-blocking risk was identified. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |

Summary
Completes the audit of
src/main— the repository's largest test area at 4,490files. This wave covers
src/main/runtime(flat,rpc,orchestration,relay,push) and the flat files insrc/main: 1,195 files swept by six parallelauditors. Removes 42 test case declarations across 24 files, 783 lines. No file
deleted whole, no production code touched.
Before / after as a developer experiences it
Before: parts of these suites reported coverage they did not have. Two cases were
permanently skipped with a comment saying the feature does not exist yet — they
could never fail. One benchmark's own simulation contained the optimization it
claimed to measure. One boundary test imported no production code at all and spent
three cases checking its own regular expression against strings it defined itself.
Several database cases asserted a value equal to the literal they had just passed in.
After: each of those contracts has one test that owns it, at a boundary a real
caller reaches.
What was removed, and why each is not coverage
production import, three of whose cases checked its own regex against its own
strings; and a benchmark whose
simulateGraphPublishhelper contains theshort-circuit it asserts, with
expect(wouldHaveBeen).toBe(60000)comparing thetest's own arithmetic to itself.
// TODO: inline restore on re-subscribe not yet implemented. A skipped test fora feature that does not exist is a note written in test syntax.
literal input (
type: 'question'in,type === 'question'out).scopes and two dependency-promotion cases, each owned by a dedicated suite with
strictly stronger assertions.
clientCapabilities; the mobile branch consults only the feature setting, and themodule's own docblock explains why capability gating was deliberately dropped. A
"Windows worker" case sat in a module with no platform input at all.
AppImage variables" whose body only removes
AppRun, byte-identical to a row ofthe
it.eachtable twenty lines above it.whose fixture also differed in sender handle, so the handle guard could reject it
before the pane check was ever reached.
format(m, { authority: 'current' }) === format(m).Two deletions kept only after discarding the stated reason
Twice an auditor justified deleting an inventory test by pointing at an automated
gate, and both times the gate could not catch the regression the inventory guards:
verify:rpc-params-catalog, which regenerates thecatalog during
pnpm lint." The script's own header says it stops the catalog anddispatcher from drifting apart — it is a staleness check. A developer who
deliberately removes a method regenerates the catalog and
--checkpasses.conformance at compile time," which is false when an interface and its
implementing class change together.
The general form: generated-artifact checks, type annotations and schemas verify
internal consistency between a declaration and its use. None of them notices when
the declaration and its use are removed together — which is exactly what an
intentional deletion looks like. Consistency gates are not coverage.
Both inventories still go, on per-entry evidence: every method name is referenced by
other tests. In the same wave the same rule kept a 37-entry terminal-method
inventory, because some of its entries are pinned solely by it. Two auditors reached
opposite verdicts on registration manifests and both were right, because the rule is
evidence per entry rather than a verdict by shape.
Why this approach
Repairing a weak case in place means authoring a new test under the heading of
cleanup, and a test invented to justify its own existence encodes today's
implementation rather than a contract someone depends on. A deleted redundant case
is recoverable from history; a fabricated one is maintained forever.
Kept deliberately:
path, because
check-reliability-gates.mjsresolves paths and never verifies anamed assertion still exists.
against real source. The surviving boundary case asserts the pattern still matches
the writer module for every guarded table, so a silently-broken regex goes red —
which is what makes its synthetic-string self-tests redundant rather than load-bearing.
it.failsmarkers, which go red if the bug they document is fixed, andit.skipIf(platform)cases, which do run on other hosts.Honest limits
Of 1,195 files in scope, roughly 660 were read case-by-case; the remainder were
title-scanned and mechanically triaged. Every auditor disclosed its own unread set
and those paths are tracked for a later sweep rather than assumed clean. One auditor
also calibrated its duplicate-body detector against a known positive before trusting
its zero result — worth noting, because several detectors in this effort returned a
confident zero while being silently broken.
Verification
node config/scripts/check-reliability-gates.mjs— 140 gates pass.pnpm run check:code-quality:changed— 0 new findings.pnpm tcgate needed: zero production files changed.src/mainrun surfaced 42 failures across three files this change does nottouch (
browser-manager-tab-identity,browser-manager-viewport-ownership,session-scanner-codex-workers). All 42 reproduce in a pristineorigin/mainworktree, so they predate this wave and are environment-dependent locally — CI
was green on main at
2d85fdc753e2.