Skip to content

fix(session): preserve investigation records after failed target opens - #2754

Merged
morluto merged 2 commits into
morluto:mainfrom
Adkid-Zephyr:fix/session-preserve-records-on-open-failure
Oct 13, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
Adkid-Zephyr:fix/session-preserve-records-on-open-failure

Conversation

@Adkid-Zephyr

Copy link
Copy Markdown
Contributor

Summary

Preserve the investigation's Evidence and Unknown history when open_binary fails to retire the previous provider. Both target switching and same-target restart currently turn a bundle with 4 records/2 revisions into an empty bundle. Fixes #2753.

Follow-up to the unresolved P1 finding on #1776; original finding credited there. Implemented and verified with OpenAI Codex assistance.

Problem and expected behavior

A provider cleanup failure is returned correctly, but BinarySession.#open also calls clearSessionRecords(). A subsequent export cannot recover the lost investigation. Target opens must preserve records; explicit close_binary remains the operation that clears them.

Change and scope

Use the existing clearSnapshot() owner to discard the retired provider's replay cache without clearing the investigation ledger. Keep the pending cleanup owner, unavailable target, retry gate, and explicit-close behavior. Clarify this lifetime in the MCP guide.

Contract and boundary impact

  • Semantic owner and earliest changed stage: BinarySession.#open, after failed retirement.
  • Contribution scope fit and linked maintainer decision: ordinary reliability fix within existing lifecycle boundaries; advance scope decision not applicable.
  • CLI and MCP/tool-catalog contract: no schema or catalog changes; previously returned Evidence references remain usable after a failed open.
  • Provider, bridge, target-format, or platform compatibility: provider-neutral; no adapter/protocol changes.
  • Evidence, artifact, provenance, or reconstruction contract: preserve exact Evidence, Unknown revisions and bundle metadata; invalidate only the retired provider cache.
  • Target selection, authority, upstream behavior, and cleanup details: existing selection and cleanup unchanged; replacement remains blocked until cleanup succeeds.
  • Generated metadata, package, or installation impact: none.

Expected effects exercised by the regression workflow (production adds no new target interaction):

  • Read existing files or captured data (test-owned fixtures).
  • 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.

Production adds no target interaction. Tests also write temporary fixtures/exports and launch REA's JavaScript analysis worker; they never execute the analyzed JavaScript or a native target.

Evidence and regression coverage

  • Two public MCP boundary regressions exercise a target switch and same-target restart through the production provider composition, with controlled provider failure/health.

  • Exact final tests on main ab02f3c8d665ead35391c94db74cd0fb0cfed0ed: 2 failed, observing all 4 records and both Unknown revisions disappear. With the fix: 2 passed.

  • Check repeated failed cleanup, exact bundle preservation and file export, successful retry, fresh provider queries instead of stale cache replay, retained JavaScript Evidence views, and explicit close clearing.

  • User-visible failure remains cleanup_incomplete; get_evidence_bundle and export retain the original records instead of empty collections.

  • Proof gaps: provider cleanup/health are fixtures. No new real Hopper/Ghidra/IDA failure or native Windows/Linux run; no incidence-rate claim.

  • 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

Pinned Node 24.18.0/npm 11.16.0 on macOS arm64, final head f603947 rebased onto main 2995ec6:

  • npm run test:focused -- tests/boundary/mcp/sessionEvidenceRecovery.test.ts tests/boundary/mcp/sessionMcp.test.ts tests/boundary/mcp/retainedApplicationEvidenceMcp.test.ts tests/composition/analysis-sessions/binarySessionCleanupRetry.test.ts tests/composition/analysis-sessions/binarySession.test.ts src/application/binary/BinarySessionLiveness.test.ts tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts — 76 passed, 7 files.
  • npm run check — passed after shortening the new test helper; the initial run caught its function-length lint error.
  • npm run docs:check — passed, including 2 consistency tests.
  • npm run verify:test-discovery — all 1,055 files discovered once.
  • git diff --check — passed.

Full deterministic suite not run locally; remote CI is separate. verify:package passed while scouting the untouched baseline; packaging checks were not rerun for this lifecycle-only diff.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; explicit close keeps its existing lifetime.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS tests with actual static JavaScript analysis; native provider failure behavior unverified.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no security research or new authority; cleanup ownership and startup ordering remain covered.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved; no new capability needs a scope decision.
  • One focused outcome and a Conventional Commit title.
  • Related issue linked and prior finding credited.
  • Tests cover observable behavior and meaningful failure paths.
  • Owning documentation updated; schemas/generated metadata unchanged.
  • Representative MCP behavior and verification limits described.
  • Final diff checked for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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-10-13T12:22:42.962131Z 41c0ce5 New commits
ℹ️ 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 Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the fix preserves investigation history without allowing use of the retired provider.

Summary

Failed target switches and same-target restarts now preserve investigation records while discarding the retired provider’s cache.

  • Failed target opens preserve the investigation history.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Open or restart target] --> B[Retire previous provider]
  B -->|Cleanup fails| C[Keep pending cleanup owner]
  C --> D[Clear provider cache]
  D --> E[Keep Evidence and Unknown history]
  E --> F[Return cleanup_incomplete]
  F --> G[Retry open]
  G --> H{Cleanup succeeds?}
  H -->|No| F
  H -->|Yes| I[Start replacement provider]
  J[Explicit close_binary] --> K[Clear investigation records and cache]
Loading

Reviews (2) · Last reviewed commit: "chore(ci): merge current main verificati..." · Reviewed by Greptile

@morluto morluto added bug Something isn't working area: runtime Process capture and runtime observation area: domain Domain logic, errors, and pure functions P2: medium Medium priority issue labels Oct 13, 2026
@morluto
morluto merged commit af7638f into morluto:main Oct 13, 2026
35 checks passed
@morluto

morluto commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Thank you @Adkid-Zephyr for following through on the failed-open recovery issue. Preserving Evidence and Unknown records when provider cleanup fails means an investigation remains exportable and recoverable until the caller explicitly closes it.

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 area: runtime Process capture and runtime observation bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Failed open_binary cleanup clears all retained Evidence and Unknown history

2 participants