Skip to content

test: retire hook and installer cases whose guards or arithmetic cannot fail - #23981

Merged
nwparker merged 1 commit into
mainfrom
nwparker/test-audit-wave15
Sep 30, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/test-audit-wave15

Conversation

@nwparker

@nwparker nwparker commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

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 is 120 < 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 are throttledBytes < legacyBytes / 40 and THROTTLED_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 asserts status === 204. Timings are logged, not asserted. No production change can fail it.

Negative controls refused by a different guard than the name claims

case what actually refused it
"keeps permission visible for unpreviewable tool input with another tool use id" blocked by !hasConflictingToolUseId and the entire 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" nextToolUseId !== undefined (server-claude-status-rules.ts:133) — never the collision
"pane key present but no endpoint" the same -z PORT || -z TOKEN || -z PANE_KEY guard as its sibling; setting ORCA_PANE_KEY changes nothing while PORT and TOKEN stay empty

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. The test's own comment concedes nothing is observable.
  • "keeps the event loop responsive…" — asserted settled === false, which restates promise pendingness; the sibling "no synchronous HOME filesystem calls" catches a readFileSync regression strictly harder.
  • getSharedManagedScriptPath "does not depend on app.getPath" — expect(a).toBe(b) on one pure function; the join(homedir(), …) sibling is the real contract.

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 — POSIX always single-quotes and Windows base64-encodes the whole payload, so 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 directly above it.

A provider loop drops prime-agent — a pure fall-through of every pi arm with no server-side special case (provider-event-routing.ts:63-66,173-176). omp stays: source === 'omp' genuinely diverges in the retirement path.

Normalization-suite duplicates, each owned elsewhere

Eight server-escape-navigation-inference cases went because isNavigationEscapeIntent (agent-interrupt-intent.ts:33) reads only agentType and intent, while those cases varied hookEventName and toolName — inputs the predicate never consults. Their real owners are the omp case, the it.each(['pi','prime-agent']) block, a loopback it.each row at the HTTP boundary, and server-interrupt-inference-guards.test.ts.

Two route cases (/hook/hermes, /hook/amp) were inventory restatements of AGENT_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 in server-ingest-remote.test.ts — and notably three of the five actually refuse via the legacy-numeric !parsedPaneKey guard rather than the guard they name.

Two cases monkeypatched the protected scheduleStatusPersist; the real boundary is owned by a sibling that reads last-status.json on disk.

Why

Two keeps in this wave were justified by history rather than structure, and that distinction matters.

  • remote-hook-service-registry-coverage.test.ts reads 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 shipped installRemote but were never registered, so SSH status silently vanished. Nothing else catches an unregistered installer.
  • A HOME-ordering source grep stays, despite an earlier PR in this series deleting ~84 files of that shape. Its behavioural sibling (<2000ms with a bogus HOME) 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 input cases as the two disjuncts of the toolInput clear (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 || at first-work-workspace-title-rename.ts:54 short-circuits left-first so each row exercises one disjunct; and manual-compact-hook-stream.test.ts whole, since it documents its own vacuity traps — it asserts the triggerless-replay arm from a finished pane precisely because asserting working on a working pane 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:

  • All 20 modified test files: 310 passed, 3 skipped.
  • node config/scripts/check-reliability-gates.mjs — passes, 140 gates; the deleted file is named in no gate, cloud/package.json, or mobile/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-existing as assertion onto a changed line; it was resolved by typing the vi.hoisted return rather than suppressing the rule.
  • pnpm tc not required — zero production files changed.
  • Independently re-derived the bench-test claim before accepting a 137-line deletion: confirmed both constants are declared in the test file and that the assertion reduces to 120 < 134.33.

Not run locally: e2e and the Windows/Linux/SSH jobs — left to CI.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security / bounds: no limit, bound or guard removed. The branch-rename LRU cap cases and the 200-char install-telemetry truncation were explicitly kept.
  • Cross-platform / SSH: the Windows caret/percent escaping case ([Bug]: Codex hooks fail on Windows when user path contains spaces #6078) and the Grok Windows ordering grep were kept as the only coverage of their paths; the macOS-only HOME stall guard was kept for the same reason. The prime-agent loop row went only after confirming it has no server-side special case.
  • Performance / back-compat: no runtime behavior changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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.
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Low risk] Test cases removed for guards that cannot fail.

The PR appears safe to merge, with a non-blocking loss of Hermes and Amp HTTP listener regression coverage.

Findings

  1. P2 Hermes and Amp coverage lost ▶

Summary

The PR removes hook and installer tests judged redundant or unable to detect production regressions, without changing runtime code.

  • Most examined deletions retain coverage of the relevant guard or behavior.
  • The Hermes and Amp live HTTP-to-listener checks have no equivalent remaining test.

Reviews (1) · Last reviewed commit: "test: retire hook and installer cases wh..."

server.stop()
}
})
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The 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 prime-agent. The script-refresh tests remove a stalled-read test and its related mock state.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 33957

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)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the change as removing hook and installer tests whose guards or arithmetic cannot provide meaningful coverage. It is concise and aligned with the pull request scope.
Description check ✅ Passed The description is complete and well aligned with the repository template. It explains the changes, rationale, testing, platform coverage, retained cases, and checklist status. It also states why no l…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/main/agent-hooks/managed-hook-script-refresh-main-thread.test.ts (1)

69-72: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Keep the pending-read completion test.

Each registry refresher awaits refreshManagedScriptIfPresent, which awaits the HOME readFile. installManagedAgentHooks then 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 win

Restore a POSIX path-with-spaces assertion.

wrapPosixHookCommand must preserve script paths derived from homedir(). 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

📥 Commits

Reviewing files that changed from the base of the PR and between 45c63a6 and 3395715.

📒 Files selected for processing (21)
  • src/main/agent-hooks/ended-process-reconciliation.test.ts
  • src/main/agent-hooks/first-work-branch-rename.test.ts
  • src/main/agent-hooks/hook-script-outside-orca.test.ts
  • src/main/agent-hooks/installer-utils-remote.test.ts
  • src/main/agent-hooks/installer-utils.test.ts
  • src/main/agent-hooks/managed-agent-hook-controls.test.ts
  • src/main/agent-hooks/managed-hook-script-refresh-main-thread.test.ts
  • src/main/agent-hooks/opencode-message-part-flood-bench.test.ts
  • src/main/agent-hooks/server-claude-normalization.test.ts
  • src/main/agent-hooks/server-claude-permission-visibility.test.ts
  • src/main/agent-hooks/server-closed-tab-suppression.test.ts
  • src/main/agent-hooks/server-copilot-normalization.test.ts
  • src/main/agent-hooks/server-cursor-normalization.test.ts
  • src/main/agent-hooks/server-droid-normalization.test.ts
  • src/main/agent-hooks/server-endpoint-file-lifecycle.test.ts
  • src/main/agent-hooks/server-escape-navigation-inference.test.ts
  • src/main/agent-hooks/server-gemini-normalization.test.ts
  • src/main/agent-hooks/server-hook-http-ingest.test.ts
  • src/main/agent-hooks/server-ingest-remote.test.ts
  • src/main/agent-hooks/server-ingest-structured-status.test.ts
  • src/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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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, Gemini AfterAgent state=done, Copilot camelCase elicitation_dialog, Cursor tool-heavy chain, Claude TaskUpdate preview — each behavior is pinned by a surviving sibling or hits a shared production branch (e.g. TaskUpdate is absent from TOOL_INPUT_KEYS_BY_TOOL, so it takes the same if (!keys) arm as the unknown-tool sibling).
  • Interrupt / escape-navigation: the removed cases varied only hookEventName/toolName, which isNavigationEscapeIntent never reads; the surviving server-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 against server-claude-status-rules.ts.
  • Installer / endpoint / misc: no-op write, spaces-in-path, getSharedManagedScriptPath a===b, namespaced buildPtyEnv, the ingestRemote envelope battery, empty/whitespace connectionId, structured-status drop/persist, and the settings-toggle removal — each has a surviving owner or was itself tautological.
  • prime-agent loop row: confirmed no server-side special case — provider-event-routing.ts:63-66 and :173-176 route prime-agent to the same pi arm, and /hook/prime-agent + agent_end→done stay pinned by agent-hook-listener-transport.test.ts:272 and agent-hook-listener-extraction-characterization.test.ts:69-70; restorePaneAuthority remains covered by the surviving pi/omp iterations.

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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 33351b0 into main Sep 30, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant