Repository navigation
test: retire hook and installer cases whose guards or arithmetic cannot fail - #23981
Conversation
…ot fail Semantic sweep of src/main persistence, skills, agent-hooks and providers. 22 cases removed across 14 files, plus one file; no production code touched. `opencode-message-part-flood-bench.test.ts` is deleted (137 lines). Its headline assertion is `THROTTLED_POSTS < LEGACY_PART_UPDATES / 3 + 1`, i.e. `120 < 134.33` over two constants declared in the test file itself, and the second is arithmetic over two more. The throttle it is named for lives in the OpenCode plugin and is never invoked: the test hand-simulates both client behaviours and posts them to a server that only asserts `status === 204`. Timings are logged, not asserted. Negative controls whose refusal comes from a different guard than the name claims: - "keeps permission visible for unpreviewable tool input with another tool use id" is blocked by `!hasConflictingToolUseId` AND the whole input clause, making it strictly weaker than the sibling that shares the guard with that clause satisfied; - "keeps permission visible when unknown tool previews collide" refuses on `nextToolUseId !== undefined` (`server-claude-status-rules.ts:133`), never on the collision; - "pane key present but no endpoint" hits the same `-z PORT || -z TOKEN || -z PANE_KEY` guard as its sibling, since PORT and TOKEN stay empty either way. Cases that cannot fail: "skips a no-op write when contents already match" — writing identical content yields identical content whether or not a skip fired, and the comment concedes nothing is observable. "Keeps the event loop responsive" asserted `settled === false`, restating promise pendingness, while the sibling "no synchronous HOME filesystem calls" catches the regression harder. Inputs no production path reads: `reconcileEndedProcessForPaneKeys` gates on `paneHasStateClaims`, not `state`; `applyAgentStatusHooksEnabled(false, …)` returns before reading `settings`; nothing branches on spaces in a script path, since POSIX always single-quotes and Windows base64-encodes the payload (the caret/percent case is the stronger #6078 guard); `TaskUpdate` is absent from `TOOL_INPUT_KEYS_BY_TOOL`, so it takes the same `if (!keys) return undefined` arm as the unknown-tool sibling. A provider loop drops `prime-agent`, a pure fall-through of every `pi` arm with no server-side special case; `omp` stays because `source === 'omp'` genuinely diverges in the retirement path. Kept on history rather than structure: `remote-hook-service-registry-coverage.test.ts` reads like a copied inventory but is the ratchet for #7253, where Droid and Copilot shipped `installRemote` unregistered and SSH status silently vanished. A HOME-ordering source grep also stays — its behavioural sibling only reproduces the 6.6s Xcode-stub stall on macOS, so the grep is the only cross-platform guard.
|
| server.stop() | ||
| } | ||
| }) | ||
| }) |
There was a problem hiding this comment.
Hermes and Amp coverage lost Removing these tests leaves neither plugin’s HTTP route tested through a real
AgentHookServer listener. The remaining tests check routing or plugin-side posting separately. A future regression that accepts /hook/hermes or /hook/amp but fails to deliver its status to the listener could therefore pass the suite. Please retain an end-to-end listener assertion for both routes.
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!
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe pull request removes tests across agent-hook setup, server ingestion, agent normalization, and interrupt inference. It also changes interrupt-resurrection coverage to test Codex replay and same-prompt updates. One re-attachment test no longer includes Priority: ⬇️ Low Merge Risk: 🔵 Low · up to This test-only change does not alter current runtime behavior, but it removes protection for hook refresh ordering and POSIX paths with spaces. The merge risk is low; restoring the focused assertions would better protect those workflows. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/main/agent-hooks/managed-hook-script-refresh-main-thread.test.ts (1)
69-72: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winKeep the pending-read completion test.
Each registry refresher awaits
refreshManagedScriptIfPresent, which awaits the HOMEreadFile.installManagedAgentHooksthen awaits the refresher before CLI detection.The remaining main-thread test checks only synchronous filesystem calls. It would pass if a service refresher returned before its asynchronous read or write completed. The controls test uses a mocked refresher, so it does not cover this internal await chain.
Suggested fix
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' +import type * as NodeFsPromisesModule from 'node:fs/promises' @@ home: '', - syncCalls: [] + syncCalls: [], + blockAsyncReads: false })) @@ vi.mock('node:fs', async (importOriginal) => { @@ }) +vi.mock('node:fs/promises', async (importOriginal) => { + const actual = await importOriginal<typeof NodeFsPromisesModule>() + return { + ...actual, + default: actual, + readFile: (...args: Parameters<typeof actual.readFile>) => + state.blockAsyncReads && String(args[0]).startsWith(state.home) + ? new Promise<never>(() => {}) + : actual.readFile(...args) + } +}) + @@ state.home = await mkdtemp(join(tmpdir(), 'orca-hook-refresh-main-thread-')) state.syncCalls = [] + state.blockAsyncReads = false @@ afterEach(async () => { + state.blockAsyncReads = false await rm(state.home, { recursive: true, force: true }) }) @@ expect(syncCallsUnderHome()).toEqual([]) }) + + it('keeps the event loop responsive while a HOME read is stalled', async () => { + state.blockAsyncReads = true + const refresh = MANAGED_AGENT_HOOK_SCRIPT_REFRESHERS[0][1]() + let settled = false + void refresh.then(() => { + settled = true + }) + + await new Promise<void>((resolve) => setTimeout(resolve, 5)) + + expect(settled).toBe(false) + }) })src/main/agent-hooks/installer-utils.test.ts (1)
474-490: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winRestore a POSIX path-with-spaces assertion.
wrapPosixHookCommandmust preserve script paths derived fromhomedir(). The retained test covers embedded quotes, but it does not detect a regression that breaks paths containing spaces. Add a focused assertion for this reachable POSIX case.Suggested fix
it('produces a guarded command that no-ops when the script is missing', () => { const cmd = wrapPosixHookCommand('/does/not/exist.sh') expect(cmd).toBe( `if [ -f '/does/not/exist.sh' ] && [ -r '/does/not/exist.sh' ] && [ -x '/does/not/exist.sh' ]; then /bin/sh '/does/not/exist.sh'; else ${POSIX_HOOK_STDIN_DRAIN_COMMAND}; fi` ) }) + it('preserves spaces in the script path', () => { + const cmd = wrapPosixHookCommand('/path/with spaces/x.sh') + expect(cmd).toBe( + `if [ -f '/path/with spaces/x.sh' ] && [ -r '/path/with spaces/x.sh' ] && [ -x '/path/with spaces/x.sh' ]; then /bin/sh '/path/with spaces/x.sh'; else ${POSIX_HOOK_STDIN_DRAIN_COMMAND}; fi` + ) + }) + it('escapes embedded single quotes so the wrapped command stays well-formed', () => {
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 23bab8cb-743f-4f8c-ab43-fba5ca474ef2
📒 Files selected for processing (21)
src/main/agent-hooks/ended-process-reconciliation.test.tssrc/main/agent-hooks/first-work-branch-rename.test.tssrc/main/agent-hooks/hook-script-outside-orca.test.tssrc/main/agent-hooks/installer-utils-remote.test.tssrc/main/agent-hooks/installer-utils.test.tssrc/main/agent-hooks/managed-agent-hook-controls.test.tssrc/main/agent-hooks/managed-hook-script-refresh-main-thread.test.tssrc/main/agent-hooks/opencode-message-part-flood-bench.test.tssrc/main/agent-hooks/server-claude-normalization.test.tssrc/main/agent-hooks/server-claude-permission-visibility.test.tssrc/main/agent-hooks/server-closed-tab-suppression.test.tssrc/main/agent-hooks/server-copilot-normalization.test.tssrc/main/agent-hooks/server-cursor-normalization.test.tssrc/main/agent-hooks/server-droid-normalization.test.tssrc/main/agent-hooks/server-endpoint-file-lifecycle.test.tssrc/main/agent-hooks/server-escape-navigation-inference.test.tssrc/main/agent-hooks/server-gemini-normalization.test.tssrc/main/agent-hooks/server-hook-http-ingest.test.tssrc/main/agent-hooks/server-ingest-remote.test.tssrc/main/agent-hooks/server-ingest-structured-status.test.tssrc/main/agent-hooks/server-interrupt-inference-resurrection.test.ts
💤 Files with no reviewable changes (19)
- src/main/agent-hooks/server-cursor-normalization.test.ts
- src/main/agent-hooks/server-claude-normalization.test.ts
- src/main/agent-hooks/server-hook-http-ingest.test.ts
- src/main/agent-hooks/server-droid-normalization.test.ts
- src/main/agent-hooks/hook-script-outside-orca.test.ts
- src/main/agent-hooks/server-copilot-normalization.test.ts
- src/main/agent-hooks/first-work-branch-rename.test.ts
- src/main/agent-hooks/installer-utils.test.ts
- src/main/agent-hooks/server-gemini-normalization.test.ts
- src/main/agent-hooks/server-ingest-structured-status.test.ts
- src/main/agent-hooks/server-ingest-remote.test.ts
- src/main/agent-hooks/server-claude-permission-visibility.test.ts
- src/main/agent-hooks/ended-process-reconciliation.test.ts
- src/main/agent-hooks/installer-utils-remote.test.ts
- src/main/agent-hooks/managed-agent-hook-controls.test.ts
- src/main/agent-hooks/server-escape-navigation-inference.test.ts
- src/main/agent-hooks/server-endpoint-file-lifecycle.test.ts
- src/main/agent-hooks/server-interrupt-inference-resurrection.test.ts
- src/main/agent-hooks/opencode-message-part-flood-bench.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — verified the deletion-only test-audit wave across all 21 files at 3395715 against the surviving HEAD tree: for each removed case, whether a survivor pins the same production branch or guard.
- Whole-file deletion:
opencode-message-part-flood-bench.test.ts(137 lines) — both headline assertions are arithmetic over four constants declared in the file, and the throttle it names is never invoked. Correct to retire. - Normalization duplicates: Droid
SubagentStop→null, GeminiAfterAgentstate=done, Copilot camelCaseelicitation_dialog, Cursor tool-heavy chain, ClaudeTaskUpdatepreview — each behavior is pinned by a surviving sibling or hits a shared production branch (e.g.TaskUpdateis absent fromTOOL_INPUT_KEYS_BY_TOOL, so it takes the sameif (!keys)arm as the unknown-tool sibling). - Interrupt / escape-navigation: the removed cases varied only
hookEventName/toolName, whichisNavigationEscapeIntentnever reads; the survivingserver-interrupt-inference-guards.test.ts, the loopback rows, and the surviving Codex resurrection case own the branches. The two Claude permission-visibility negative controls are each decided by a different guard than their names claim — confirmed againstserver-claude-status-rules.ts. - Installer / endpoint / misc: no-op write, spaces-in-path,
getSharedManagedScriptPatha===b, namespacedbuildPtyEnv, theingestRemoteenvelope battery, empty/whitespaceconnectionId, structured-status drop/persist, and the settings-toggle removal — each has a surviving owner or was itself tautological. prime-agentloop row: confirmed no server-side special case —provider-event-routing.ts:63-66and:173-176routeprime-agentto the samepiarm, and/hook/prime-agent+agent_end→done stay pinned byagent-hook-listener-transport.test.ts:272andagent-hook-listener-extraction-characterization.test.ts:69-70;restorePaneAuthorityremains covered by the survivingpi/ompiterations.
Two cases are now covered only compositionally rather than by an exact replica (Gemini AfterAgent's toolName === undefined assertion, and the camelCase notificationType:'elicitation_dialog' combination). In both, production has no distinct branch for the combination — the Gemini extractor returns {} for AfterAgent, and Copilot reads both key spellings into one value with a single OR over the two dialog types — so no regression path is unguarded. Not flagging as issues.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Some of these tests compare two numbers that are both written in the test file. One reads
THROTTLED_POSTS < LEGACY_PART_UPDATES / 3 + 1— which is120 < 134.33. It passes because 120 is less than 134, not because anything in the app works. The throttling it is named after is never even called.Others say they check one thing but are actually stopped by a different guard entirely — a test called "keeps permission visible when unknown tool previews collide" is refused because a tool-use id is set, never because previews collided.
What Changed
−1,070 lines across 21 files. 30 cases removed, 1 file deleted, no production code touched.
A bench test asserting its own arithmetic
opencode-message-part-flood-bench.test.ts(137 lines) is deleted. Its two headline assertions arethrottledBytes < legacyBytes / 40andTHROTTLED_POSTS < LEGACY_PART_UPDATES / 3 + 1— pure arithmetic over four constants declared in the test file at lines 43-47. The throttle it names lives in the OpenCode plugin and is never invoked: the test hand-simulates both client behaviours and posts them to a server that only assertsstatus === 204. Timings are logged, not asserted. No production change can fail it.Negative controls refused by a different guard than the name claims
!hasConflictingToolUseIdand the entire input clause, making it strictly weaker than the sibling that shares the guard with that clause satisfiednextToolUseId !== undefined(server-claude-status-rules.ts:133) — never the collision-z PORT || -z TOKEN || -z PANE_KEYguard as its sibling; settingORCA_PANE_KEYchanges nothing while PORT and TOKEN stay emptyCases that cannot fail
settled === false, which restates promise pendingness; the sibling "no synchronous HOME filesystem calls" catches areadFileSyncregression strictly harder.getSharedManagedScriptPath"does not depend on app.getPath" —expect(a).toBe(b)on one pure function; thejoin(homedir(), …)sibling is the real contract.Inputs no production path reads
reconcileEndedProcessForPaneKeysgates onpaneHasStateClaims, notstate.applyAgentStatusHooksEnabled(false, …)returns before readingsettings. Nothing branches on spaces in a script path — POSIX always single-quotes and Windows base64-encodes the whole payload, so the caret/percent case is the stronger #6078 guard.TaskUpdateis absent fromTOOL_INPUT_KEYS_BY_TOOL, so it takes the sameif (!keys) return undefinedarm as the unknown-tool sibling directly above it.A provider loop drops
prime-agent— a pure fall-through of everypiarm with no server-side special case (provider-event-routing.ts:63-66,173-176).ompstays:source === 'omp'genuinely diverges in the retirement path.Normalization-suite duplicates, each owned elsewhere
Eight
server-escape-navigation-inferencecases went becauseisNavigationEscapeIntent(agent-interrupt-intent.ts:33) reads onlyagentTypeandintent, while those cases variedhookEventNameandtoolName— inputs the predicate never consults. Their real owners are the omp case, theit.each(['pi','prime-agent'])block, a loopbackit.eachrow at the HTTP boundary, andserver-interrupt-inference-guards.test.ts.Two route cases (
/hook/hermes,/hook/amp) were inventory restatements ofAGENT_HOOK_SOURCES(agent-hook-relay.ts:37), with normalization owned by the per-agent suites. A five-way malformed-envelope battery went because each sub-case is owned individually inserver-ingest-remote.test.ts— and notably three of the five actually refuse via the legacy-numeric!parsedPaneKeyguard rather than the guard they name.Two cases monkeypatched the protected
scheduleStatusPersist; the real boundary is owned by a sibling that readslast-status.jsonon disk.Why
Two keeps in this wave were justified by history rather than structure, and that distinction matters.
remote-hook-service-registry-coverage.test.tsreads exactly like the copied inventories this audit has deleted dozens of. It stays because it is the ratchet for issue [Bug]: Codex, Amp & Droid agent status not shown in task tree over SSH remote (works locally; Claude/Hermes OK over SSH) #7253: Droid and Copilot shippedinstallRemotebut were never registered, so SSH status silently vanished. Nothing else catches an unregistered installer.HOME-ordering source grep stays, despite an earlier PR in this series deleting ~84 files of that shape. Its behavioural sibling (<2000mswith a bogusHOME) only reproduces the 6.6 s Xcode-stub stall on macOS, so the ordering assertion is the only cross-platform guard.A pattern being usually-junk is not the same as always-junk, and the check is always "what else would catch this regression".
Other deliberate keeps: two
PermissionRequest … clears cached tool inputcases as the two disjuncts of thetoolInputclear (prompt-fields.ts:135-139), where only the same-tool case would fail a tool-name-keyed cache;preserves a manual folder name (pending=%s)rows, because the||atfirst-work-workspace-title-rename.ts:54short-circuits left-first so each row exercises one disjunct; andmanual-compact-hook-stream.test.tswhole, since it documents its own vacuity traps — it asserts the triggerless-replay arm from a finished pane precisely because assertingworkingon aworkingpane cannot fail.Linked Issue
N/A — test-suite hygiene, no pre-existing issue.
Visual Proof
N/A — no production code changes in this PR.
Testing
Verified locally on macOS after committing and rebasing onto current main:
node config/scripts/check-reliability-gates.mjs— passes, 140 gates; the deleted file is named in no gate,cloud/package.json, ormobile/tests-typecheck-baseline.txt.pnpm run check:code-quality:changed— passes, 0 findings. One finding did surface mid-sweep when an edit pulled a pre-existingasassertion onto a changed line; it was resolved by typing thevi.hoistedreturn rather than suppressing the rule.pnpm tcnot required — zero production files changed.120 < 134.33.Not run locally: e2e and the Windows/Linux/SSH jobs — left to CI.
Removal-only; no new tests.
Review
Each deletion cites the production line or sibling that owns it, so the reasoning is checkable directly. The two history-based keeps are the interesting judgement calls — if you think the #7253 registry ratchet or the macOS-only HOME ordering grep should go anyway, say so.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
prime-agentloop row went only after confirming it has no server-side special case.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)