Skip to content

fix(ghidra): report byte-search cursor mismatches without schema repair - #8420

Closed
blake-andrews1 wants to merge 1 commit into
morluto:mainfrom
blake-andrews1:fix/8366-cursor-profile-mismatch-error
Closed

blake-andrews1 wants to merge 1 commit into
morluto:mainfrom
blake-andrews1:fix/8366-cursor-profile-mismatch-error

Conversation

@blake-andrews1

@blake-andrews1 blake-andrews1 commented Nov 1, 2026 •

Copy link
Copy Markdown

Summary

A byte-search continuation whose cursor does not match the current binding was rejected as generic invalid input and told the caller to repair the schema. The request already matches the schema. The cursor is a one-way digest, so the refusal now names every bound value, including the analysis profile and selected Ghidra project, and says which value differs is unknown.

Closes #8366.

Problem and expected behavior

Reusing a search_bytes cursor after the target, analysis profile or project, pattern, mask, bounds, or document changed returned:

{
  "code": "invalid_request",
  "message": "Analysis input is invalid. Check the arguments and try again.",
  "recovery": { "kind": "inspect_input_contract", "operation": "search_bytes" },
  "details": {
    "issues": [
      {
        "path": [],
        "reason": "invalid_value",
        "message": "Byte search cursor does not match the target and query"
      }
    ]
  }
}

The same refusal is still returned. The headline now states that the cursor is bound to the target, analysis profile (including a selected Ghidra project), pattern, mask, bounds, and document, and that it does not identify which of those differs. details.issues[0].path is cursor, observed.differing_component is unknown, and there is no inspect_input_contract recovery. Remediation says to select the original context, including REA_GHIDRA_PROJECT_PATH and REA_GHIDRA_PROGRAM_NAME when a saved project was used, or to start a new search without the cursor.

Change and scope

The Ghidra bridge reports this mismatch as byte_search_cursor_mismatch instead of a generic invalid_request. The provider projection treats that code like the existing file-offset outcomes: the bridge reason is the headline, the request is marked as conforming to the input contract, and schema-repair recovery is omitted. Ordinary search_bytes input failures still use schema recovery. Session diagnostics for this code stay request-scoped.

Not included: live metadata freshness across accepted pages (#8365), and any claim that a hash mismatch proves the project or target changed.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: The Ghidra bridge owns the cursor binding and its failure code. GhidraProviderClient projects that code for CLI and MCP. No superseded path was removed.
  • Contribution scope fit and linked maintainer decision: not applicable. This is an error-reporting fix inside the existing read-only byte-search refusal.
  • CLI and MCP/tool-catalog contract: Public code stays invalid_request. The headline, issue path, observed facts, remediation, and absence of inspect_input_contract recovery change for this mismatch only. The input schema is unchanged.
  • Provider, bridge, target-format, or platform compatibility: Ghidra bridge code byte_search_cursor_mismatch is new. An older bridge that still emits invalid_request with the previous message keeps the old projection.
  • Evidence, artifact, provenance, or reconstruction contract: none. The refusal still creates no Evidence.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable. No target is opened, executed, or modified.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none. Tool schemas are unchanged.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/ghidra/GhidraProvider.behavior.test.ts projects the mismatch and keeps schema recovery for an ordinary search_bytes invalid_request. src/ghidra/GhidraSessionError.test.ts checks request-scoped diagnostics. The projection test also reads bridge/ghidra/ReaGhidraBridge.java and requires the new code and message.

  • Base reproduction or other evidence: Executed. Before the projection change, npm run test:local -- src/ghidra/GhidraProvider.behavior.test.ts on Node 24.22.1 failed the new test: the injected byte_search_cursor_mismatch was execution_failure and told the caller to run rea doctor. The issue's previous public shape, quoted above, is source-derived from the old invalid_request message and AnalysisInputError schema recovery.

  • User-visible CLI/MCP output (if applicable): The shared projection, not a live CLI or MCP process. Headline:

    Byte search cursor does not match this search. It is bound to the target, analysis profile (including a selected Ghidra project), pattern, mask, bounds, and document, and does not identify which of those differs.

    Remediation: select the original target, analysis profile or Ghidra project, pattern, mask, bounds, and document; when a saved project was used, start REA with the same REA_GHIDRA_PROJECT_PATH and REA_GHIDRA_PROGRAM_NAME; or start a new search without the cursor.

  • Remaining proof gaps: The real Ghidra CLI and MCP controls below cover a changed pattern on one fixture and host; project, target, mask, bounds, and document mismatches were not separately re-executed. A cursor that lies outside initialized memory is unchanged.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

Public error delivery is covered at the provider projection that CLI and MCP share. Lifecycle regressions are not applicable: no resource ownership or finalization changes.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm ci — completed with Node 24.22.1 (.nvmrc); 739 packages installed.
  • npm run test:local -- src/ghidra/GhidraProvider.behavior.test.ts — before the fix: 1 failed, 184 passed. The new test expected invalid_request with the binding message and no recovery; it received execution_failure and rea doctor remediation.
  • npm run test:local -- src/ghidra/GhidraProvider.behavior.test.ts src/ghidra/GhidraSessionError.test.ts — after the fix: 197 passed (186 + 11).
  • npm run test:local -- src/main/messages.test.ts — 1 passed. The error catalog still contains the published recovery strings.
  • npm run check:fast — deps:check, typecheck, and lint succeeded (Node 24.22.1).
  • Real Ghidra 12.1.4 / JDK 21 on macOS arm64, compact and full stdio MCP: a two-match byte search paged with limit: 1 and returned both matches in order, with the first page incomplete and the second complete. Reusing the first cursor with a different pattern returned the new binding-specific message, cursor issue path, unknown differing component and restart guidance without schema-repair recovery. The self-built Mach-O hash stayed unchanged. In separate CLI invocations, the cursor continued the original query, the changed pattern exited 1 with the same binding-specific recovery, and restarting the changed query without a cursor succeeded.

Compatibility, safety, and release

  • Breaking changes or migration steps: Callers that matched the old issue text or depended on inspect_input_contract for this mismatch need to follow the new remediation. The public error code remains invalid_request. No migration of saved data.
  • Real Ghidra 12.1.4 CLI and MCP were exercised on macOS arm64 as described above. Real Hopper, browser and other platforms were not run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none. The cursor is not echoed. The error does not claim which bound value changed.

Author readiness

Human owner: @blake-andrews1

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

A cursor for another target, profile, pattern, mask, bounds, or document
was reported as invalid input and pointed at schema repair. Name the
binding, attribute the issue to the cursor, and leave the differing
component unknown.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T02:24:26.990746Z 728600a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no actionable defect was found in the changed refusal path.

Summary

This PR gives byte-search cursor mismatches a distinct bridge code while keeping the public error code as invalid_request.

  • Byte-search cursor errors now name the bound search context.

Reviews (1) · Last reviewed commit: "fix(ghidra): report byte-search cursor m..." · Reviewed by Greptile

@morluto

morluto commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Hey @blake-andrews1, thanks for this! The fix looks good. What's left: it has merge conflicts with main in docs/native-investigation.md (merging main into the branch is fine). Happy to get this in once that's sorted out.

gensokyo-dev added a commit that referenced this pull request Nov 14, 2026
A cursor for another target, profile, pattern, mask, bounds, or document
was reported as invalid input and pointed at schema repair. Name the
binding, attribute the issue to the cursor, and leave the differing
component unknown.

Fixes #8366
Supersedes #8420

Co-Authored-By: gensokyo-dev <[email protected]>
gensokyo-dev added a commit that referenced this pull request Nov 14, 2026
A cursor for another target, profile, pattern, mask, bounds, or document
was reported as invalid input and pointed at schema repair. Name the
binding, attribute the issue to the cursor, and leave the differing
component unknown.

Fixes #8366
Supersedes #8420

Co-Authored-By: gensokyo-dev <[email protected]>
N0zoM1z0 pushed a commit that referenced this pull request Nov 14, 2026
A cursor for another target, profile, pattern, mask, bounds, or document
was reported as invalid input and pointed at schema repair. Name the
binding, attribute the issue to the cursor, and leave the differing
component unknown.

Fixes #8366
Supersedes #8420

Co-Authored-By: gensokyo-dev <[email protected]>
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thank you for this fix. It landed in #10499 with your authorship kept on the commit (adapted where noted in the PR), so I'm closing this PR as superseded.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Byte-search cursor mismatch hides project profile and suggests schema repair

4 participants