Skip to content

test(reverse): enforce complete coverage and mutation gate - #2005

Closed
dandgabr wants to merge 125 commits into
morluto:mainfrom
dandgabr:feat/reverse-tools-coverage-gate
Closed

dandgabr wants to merge 125 commits into
morluto:mainfrom
dandgabr:feat/reverse-tools-coverage-gate

Conversation

@dandgabr

Copy link
Copy Markdown
Contributor

Summary

Add an aggregate coverage and mutation gate for the reverse engineering tool integrations. This branch currently includes the integration work tracked by #1959, #1960, and #1961, together with the gate configuration and CI wiring. The three focused PRs remain the review units for their respective integrations.

Gate

  • Enforce 100% statement and branch coverage for the scoped reverse-tool test suites.
  • Report and track function and line coverage as well.
  • Run Stryker mutation testing, including semantic mutation checks, with no surviving valid mutants in scope.
  • Integrate the scoped checks into the repository CI plan.

Validation recorded for this branch

These are local results recorded during implementation; this draft should receive a fresh CI run against the current base and review after the three focused integration PRs are reconciled.

…cycle' into feat/reverse-tools-coverage-gate
…nto feat/reverse-tools-coverage-gate

# Conflicts:
#	src/server/createServer.ts
… into feat/reverse-tools-coverage-gate

# Conflicts:
#	scripts/lib/catalog-builders.mjs
#	scripts/lib/catalog-core.mjs
#	src/cli/reverseEngineeringCommands.ts
#	src/cliCommandNames.ts
#	src/contracts/toolContracts.ts
#	src/contracts/toolEffects.ts
#	src/server/createServer.ts
# Conflicts:
#	docs/reverse-engineering-tools.md
# Conflicts:
#	src/application/reverse/ReverseEngineeringService.ts
#	tests/composition/reverseEngineering.test.ts
@dandgabr
dandgabr marked this pull request as ready for review October 12, 2026 01:51
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@dandgabr

Copy link
Copy Markdown
Contributor Author

Thanks for the notice. The required CI aggregator now includes the reverse-tools quality lane, and the scope tests cover inputs declared by the coverage and mutation configurations. Focused tests, coverage, and both mutation suites passed locally.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 0/5 Tier: apex

[High impact] Adds reverse-engineering tool integrations and test infrastructure.

Do not merge yet: Rizin can run queued commands after a timeout, and binary analysis can resume before an external writer stops.

Findings

  1. P1 Rizin ignores selected settings ▶
  2. P1 Cleanup retries forget detach state ▶
  3. P1 Queued commands run after timeout ▶
  4. P1 Analysis resumes before writers stop ▶
  5. P1 Failed startup skips cleanup ▶
  6. P1 Cutter workflow calls missing script ▶
  7. P1 Cutter smoke expects wrong shape ▶
  8. P1 Mutation gate checks wrong lines ▶
  9. P1 Tests assume Linux terminals ▶
  10. P2 Rizin work has no limits ▶
  11. P2 Mutation checker skips test files ▶
  12. P2 Rizin output loses bytes silently ▶
Fix with agent prompt
### Issue 1
src/rizin/RizinDebugSessionManager.ts:261-267
`createServer` passes `providerEnvironment`, but this spawn call supplies neither `hostEnvironment` nor `env`. The launcher therefore falls back to `process.env`. A caller that selects Rizin through a different `PATH` can launch the wrong executable or get a missing-command error. Store a copy of the supplied environment and pass it to the child, as `GdbSessionManager` does.

### Issue 2
src/rizin/RizinDebugSessionManager.ts:792-799
`#stopDebuggerOnly` creates a new object on every cleanup attempt. The shared stop helper uses that object's identity to remember pending and failed detach attempts. After a detach fails or times out, a later close sees none of that history. If the debugger has since exited and its output pipes have closed, the retry can release the session despite the unconfirmed detach. Keep one stable cleanup owner per session and share its active stop attempt.

### Issue 3
src/rizin/RizinDebugSessionManager.ts:402-405
A queued Rizin command checks only cancellation after acquiring its turn. When the preceding command times out, it sets `protocolError`; cleanup then refuses to signal the debugger because detach cannot be verified. The queued command still writes to the live child's `stdin` before checking `protocolError` at line 448. Recheck the session before writing, so a waiting command cannot change the target after the session becomes unusable.

### Issue 4
src/application/binary/BinarySession.ts:384-387
`withAdmittedExternalMutation` reopens the binary session even when `execute_rizin_command` returns an error with incomplete process cleanup. The reverse-tool service skips the final digest in that case because a remaining process may still change the file. Reopening here captures a new fixed digest and releases waiting analysis calls while that writer is alive. Keep the binary session unbound until external cleanup succeeds.

### Issue 5
src/cli/reverseEngineeringCommands.ts:302-303
`debug-with-rizin` returns when startup fails, before entering its cleanup `finally`. Startup can retain an owned debugger when its first cleanup attempt fails. This return drops the CLI's only handle to the manager without retrying `closeAll`, leaving the child and its pipes alive. Put startup inside the cleanup scope, as the GDB command already does.

### Issue 6
.github/workflows/real-cutter.yml:67
The workflow runs `npm run verify:cutter`, but `package.json` defines no such script. Every matrix job therefore stops before running the verifier. Add the script with its build prerequisite: `scripts/verify-real-cutter.mjs` imports from `dist`, and the Linux/macOS jobs do not otherwise build it.

### Issue 7
scripts/verify-real-cutter.mjs:131
`cutter_command` returns the Evidence record directly in `structuredContent`. This check instead reads `structuredContent.evidence.normalized_result`, so a successful command throws because `evidence` is undefined. Read `structuredContent.normalized_result`. Also update the nearby `createServer` call to its current two-argument form with a `{ kind: "fixed", analysis: unavailableAnalysis }` source.

### Issue 8
stryker.semantics.config.json:15-18
The ranges miss corrections this gate claims to protect:

- The Cutter ranges select Windows descriptor reads, not the `current_file` null checks at lines 168 and 251.
- `stryker.config.json` selects no `ReverseEngineeringService` code after line 417, so it never mutates the signal check at line 681.

Update both configurations against the current source and check that each intended correction produces mutants. Otherwise, a perfect score does not cover those corrections.

### Issue 9
tests/boundary/providers/RizinTestInferiorTty.ts:24
`rizinTestInferiorTty` accepts only Linux `/dev/pts/...` names, but its callers generally skip Windows rather than require Linux. On macOS, `tty` reports `/dev/ttys...`, so these tests time out before their assertions. The Windows-unavailability test also calls this helper unconditionally and tries to start `sh` on Windows. Make the helper host-aware and avoid acquiring a terminal in tests that reject before using one.

### Issue 10
src/rizin/RizinDebugSessionManager.ts:178-182
Every `start` can launch another debugger, and every `execute` can add another waiting request behind a command that runs for up to two minutes. Frame limits bound each session's output, not the number of processes or waiting requests. Add session reservations and a bounded command queue, including cancelled placeholders, as the GDB manager does.

### Issue 11
tsconfig.reverse-tools-mutation.json:17-20
The checker still lists removed names such as `DebuggerSessionManagers.test.ts`, `DebuggerSessionReviewRegressions.test.ts`, and `RizinDebugSessionCoverage.test.ts`. The suites now use GDB/Rizin-specific names and numbered parts. TypeScript silently ignores the missing entries, so Stryker's checker does not cover the same test files that Vitest runs. Replace the stale entries and keep both selections in sync.

### Issue 12
src/rizin/RizinDebugSessionManager.ts:731-736
Rizin frames use `toString("utf8")` without recording invalid bytes. An unrestricted command such as `!cat` can return non-UTF-8 data. The decoder replaces those bytes, but the Evidence still reports untruncated raw output with no warning. Carry an invalid-UTF-8 flag into the Evidence limitations, as the one-shot command path already does.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds objdump, Cutter, GDB, and Rizin tools alongside focused coverage and mutation checks.

  • Callers can inspect binaries with objdump or run a chosen Rizin command.
  • GDB sessions let callers start, control, and close a debugger through REA.
  • Callers can keep a Rizin debugger session open and control it through MCP.
  • Cutter callers can discover a running instance and send it commands through REA.
  • CI runs focused reverse-tool coverage and two mutation-testing passes.
  • Owned process and session paths preserve captured output and cleanup state across commands.

dandgabr explicitly states that this branch includes the three focused integration PRs; that scope was treated as intentional. Superseded status could not be verified because GitHub access was unavailable. Tests and mutation runs were not executed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Clients["CLI and MCP callers"] --> Static["Objdump and one-shot Rizin"]
  Clients --> Debuggers["Persistent GDB and Rizin sessions"]
  Clients --> Cutter["Authenticated Cutter bridge"]
  Static --> Owned["Owned command process"]
  Owned --> Evidence["Evidence and completion state"]
  Static --> Rebind["Refresh active binary session"]
  Debuggers --> Queue["Per-session command order"]
  Queue --> Detach["Verify target detach"]
  Detach --> Stop["Stop owned debugger"]
  Cutter --> Evidence
  Queue --> Evidence
Loading

Reviews (1) · Last reviewed commit: "ci: align duplication ceiling with expan..." · Reviewed by Greptile

Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
Comment thread src/application/binary/BinarySession.ts Resolved
Comment thread src/cli/reverseEngineeringCommands.ts Resolved
Comment on lines +15 to +18
"src/cutter/CutterBridgeClient.ts:337-337",
"src/cutter/CutterBridgeClient.ts:341-341",
"src/cutter/CutterBridgeClient.ts:349-349",
"src/cutter/CutterBridgeClient.ts:382-382",

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.

P1 Mutation gate checks wrong lines

The ranges miss corrections this gate claims to protect:

  • The Cutter ranges select Windows descriptor reads, not the current_file null checks at lines 168 and 251.
  • stryker.config.json selects no ReverseEngineeringService code after line 417, so it never mutates the signal check at line 681.

Update both configurations against the current source and check that each intended correction produces mutants. Otherwise, a perfect score does not cover those corrections.

Prompt To Fix With AI
This is a comment left during a code review.
Path: stryker.semantics.config.json
Line: 15-18

Comment:
**Mutation gate checks wrong lines**

The ranges miss corrections this gate claims to protect:

- The Cutter ranges select Windows descriptor reads, not the `current_file` null checks at lines 168 and 251.
- `stryker.config.json` selects no `ReverseEngineeringService` code after line 417, so it never mutates the signal check at line 681.

Update both configurations against the current source and check that each intended correction produces mutants. Otherwise, a perfect score does not cover those corrections.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
Comment thread tsconfig.reverse-tools-mutation.json Resolved
Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Continued in #2799. The fork rejected the maintainer push; the follow-up preserves the original contribution, commit history, and attribution, with the review fixes on a writable branch. Latest tests and provider runs were skipped at the maintainer's request.

@morluto morluto closed this Oct 13, 2026
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Addressed in #2799, which preserves @dandgabr's original commits and attribution. The verifier used an obsolete server constructor and nested Evidence envelope. It now uses a fixed analysis source and reads structuredContent.normalized_result directly.

The source fix is published in the follow-up. The producing boundary and affected consumers were inspected. Tests, builds, and CI reruns were skipped at the user's explicit request; no new real-provider verification is claimed.

  1. thread 1

Partially addressed in #2799, preserving @dandgabr's original commits and attribution. Numerical mutation ranges drifted away from the named corrections. Reviewed Cutter, signal and timeout targets use semantic AST selectors resolved at each run, with missing or ambiguous selectors failing closed. Mutation generation and scores remain unverified, and other older numerical ranges remain a documented qualification/cleanup gap.

The reviewed Cutter, signal, and timeout corrections now use fail-closed semantic AST selectors. Other older numeric mutation ranges remain unchanged. Intended mutant production and mutation scores have not been established because the user explicitly requested no tests or CI reruns. This thread remains open for that selector cleanup and mutation proof; publishing the follow-up does not establish a passing mutation gate.

  1. thread 1

Addressed in #2799, which preserves @dandgabr's original commits and attribution. The fixture accepted only Linux terminal names and started a shell for a platform rejection case. The TTY fixture recognizes macOS names; unsupported platform tests use an unused path without acquiring a terminal.

The source fix is published in the follow-up. The producing boundary and affected consumers were inspected. Tests, builds, and CI reruns were skipped at the user's explicit request; no new real-provider verification is claimed.

  1. thread 1

Addressed in #2799, which preserves @dandgabr's original commits and attribution. Starts and command waits had no admission capacity. Eight session reservations and sixteen active/queued commands bound retained work; cancelled placeholders keep their charge until their queue turn settles.

The source fix is published in the follow-up. The producing boundary and affected consumers were inspected. Tests, builds, and CI reruns were skipped at the user's explicit request; no new real-provider verification is claimed.

  1. thread 1

Addressed in #2799, which preserves @dandgabr's original commits and attribution. The checker listed removed test filenames. Its include list now contains existing source paths and the actual focused Vitest test selections, including split GDB/Rizin suites.

The source fix is published in the follow-up. The producing boundary and affected consumers were inspected. Tests, builds, and CI reruns were skipped at the user's explicit request; no new real-provider verification is claimed.

  1. thread 1

Addressed in #2799, which preserves @dandgabr's original commits and attribution. Frame decoding replaced invalid bytes without recording the loss. isUtf8 checks retained frames before decoding; command Evidence records output_invalid_utf8 and limitations on normal, timeout and early-exit observations.

The source fix is published in the follow-up. The producing boundary and affected consumers were inspected. Tests, builds, and CI reruns were skipped at the user's explicit request; no new real-provider verification is claimed.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Source selector cleanup is complete in #2799 at c9cdfe3a3f49c90dcb4d4fa59b9447d728175788. Remaining hand-maintained numeric ranges were replaced with named class methods/constructors, scoped declarations, guards, command callbacks, and reviewed expressions. Each source is parsed once per selector batch; missing, ambiguous, malformed, or ownerless scoped targets fail configuration closed. The 100% score thresholds and existing concurrency/time limits are unchanged.

The source mapping was inspected against the historical selections and current producing owners. No tests or mutation runs were performed at the user's explicit request. Intended mutant generation and actual mutation scores remain unverified, so this proof thread stays open. No further numeric-selector cleanup is outstanding.

@morluto morluto added the area: tests Test suite and verification label Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants