Skip to content

feat(investigation)!: retain records across engine cleanup - #8361

Merged
gensokyo-dev merged 11 commits into
mainfrom
refactor/investigation-lifecycle
Oct 31, 2026
Merged

gensokyo-dev merged 11 commits into
mainfrom
refactor/investigation-lifecycle

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

close_binary used to erase investigation Evidence and Unknown history, including target-free closes and cleanup failures. It now releases engine/replay state while retaining investigation references. reset_investigation explicitly ends that history, optionally acknowledging a complete checkpoint before clearing.

Fixes #8347.

Problem and expected behavior

A/B comparison and resumed investigations should reuse authenticated facts after engine cleanup. Closing an engine must preserve their IDs and full Unknown revision chains. Explicit reset must drain earlier work, block later work, retain a healthy target, and preserve records on save/cancellation/cleanup failure.

Change and scope

Separate engine, investigation and terminal runtime cleanup in the shared application layer. Add atomic retention admission with a heap-derived representation allowance, O(1) status counters and no eviction. Reuse canonical authenticated bundle import and synchronized atomic publication for explicit checkpoints.

Breaking: callers that used close_binary to discard records should call reset_investigation. Automatic journaling remains #4809.

Contract and boundary impact

  • Semantic owner: InvestigationRecords/EvidenceLedger; BinarySession serializes reset and retirement. Remove the old combined record-clearing close path and redundant authenticated-payload reserialization.
  • Contribution scope: existing lifecycle/Evidence capability; additional maintainer scope decision not applicable.
  • CLI/MCP: shared record/admission implementation; long-lived MCP adds reset_investigation and compact binary_session.investigation statistics.
  • Provider/platform: existing provider protocols, target selection and authority. Merge latest main's conditional cleanup-retry guidance and include candidate/process cleanup owners before reset.
  • Evidence/provenance: stable identities, complete source closure and Unknown histories survive close and explicit checkpoint/import. Engine snapshots remain target/profile bound.
  • Filesystem effects: caller-selected checkpoint reads/writes and existing owned resource cleanup; ordinary close retains in-memory investigation data.
  • Generated metadata/install: regenerate ignored catalogs/packaged skills; authored skill guidance updated. Package/toolchain/installers unchanged.

Evidence and regression coverage

Executed verification, measurements, model partials and limitations.

  • Final runtime 40ec9fe79 / manifest f4e55abd…: 9 genuine source cases across 8 families, 313 MCP calls and 19 CLI checks, complete original results and Unknown histories restored into fresh processes.
  • Actual Ghidra reset repeated on the final runtime (49 calls): same owned JVM start identity and analysis run; healthy target retained. Earlier real Ghidra→archive and Rectangle→NewPipe switches also qualified.
  • Local Codex CLI requested gpt-6.1-terra/high: 9 actual runs, default full discovery plus scoped multi-domain tasks; independent bundle/result/answer audits. All failed/partial attempts and continuation costs are included.
  • Review corrections: originating request admission now covers handler cleanup and successful/error response publication; reset retries both artifact and process owners. All 9 publication cases pass; both success cases fail with the old admission factory. Existing lifecycle tests pass 79/79 and full HTTP tests 74/74. The 1500-file timeout fixture keeps its full assertions under a finite parent budget; its worker and the separate pressure test keep their original limits.
  • Unknown/partial facts and provenance remain explicit. Automatic unsaved-state durability, parent-directory power-loss recovery, Windows and a second real deep engine remain outside verified scope.

Selected fields from the full-discovery native Codex task’s reset_investigation reply: {"cleared_evidence_records":14,"cleared_unknown_revisions":3,"cleared_unknown_heads":2,"retained_target":false}. Import restored the original comparison ID and both Unknown heads.

Validation performed

  • Focused tests: 43 files / 533 distinct tests, latest passing run per file; 61 lifecycle/retry tests rerun after integrating main, plus current schema/error checks.
  • Typecheck, bounded whole-repo lint plus changed-main checks, formatting, module/architecture guards, Python 93 tests, docs checks and production reachability — passed.
  • Heavy local work ran serially with 1 CPU, 4 GiB hard / 3 GiB early-stop memory and verified cleanup; no OOM. Equivalent pre-sync completed-task pairs remove two MCP calls. Actual model usage and kernel process-family measurements are recorded without claiming paired model-token savings.
  • Local hooks were disabled for the already-run bounded checks; the unbatched lint hook exceeded the session resource ceiling in prior work. CI runs the repository gates.

Author readiness

Human owner: @gensokyo-dev

The owner explicitly delegated readiness completion and review submission to Codex for this task. Codex performed implementation, diff review and validation under that delegation.

  • 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

  • Scope, authority and verification requirements are resolved for this change.
  • CI and actionable review findings are resolved.

Keep authenticated investigation facts and complete Unknown histories across
engine cleanup. Add explicit serialized checkpoint/reset and terminal runtime
disposal, with bounded atomic record retention and consistent admission.

BREAKING CHANGE: close_binary preserves in-memory investigation records. Use
reset_investigation to clear them; save_path checkpoints the complete bundle
before clearing. Engine replay snapshots remain target/profile bound.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
Allow the existing binary_session query in isolated lifecycle trials so a
checkpoint continuation can inspect session state before restoring facts.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
Merge main d54a466 while preserving retained investigation records and the
new conditional close cleanup retry. Reset also drains candidate-owned cleanup
without retiring a healthy client. Align recovery guidance and native workflow
instructions with explicit investigation reset.

Validated upstream cleanup retry and investigation boundaries (61 tests),
registry reset controls, typing, lint, formatting, architecture and docs.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
Pin real application coverage, healthy Ghidra reset, independent bundle and
Unknown history audits, whole-task measurements and all model partial runs.
Distinguish latest-main qualification from earlier performance comparisons.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 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-31T21:18:28.147767Z 5f263c0 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 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[High impact] The reviewed changes appear safe to merge; no actionable issue remains from this review.

Summary

This PR separates engine cleanup from investigation history. close_binary retains Evidence and Unknown revisions; reset_investigation explicitly clears them, optionally after saving a complete checkpoint.

  • Closing an engine keeps investigation history, while explicit reset ends it.
  • Investigation history has a fixed memory allowance and visible counts.
  • MCP reset waits for each earlier request and its reply to finish.

Diagram

sequenceDiagram
  participant Client
  participant Request as MCP request
  participant Session
  participant File as Checkpoint
  Client->>Request: Run analysis
  Request->>Session: Hold original admission
  Session-->>Request: Result
  Client->>Session: reset_investigation
  Session->>Session: Wait for earlier admissions
  Request-->>Client: Send reply
  Request->>Session: Release admission after cleanup and send
  opt save_path supplied
    Session->>File: Save complete bundle
    File-->>Session: Publication and cleanup complete
  end
  Session->>Session: Clear investigation records
  Session-->>Client: Reset receipt
Loading

Reviews (6) · Last reviewed commit: "docs(investigation): qualify final reque..." · Reviewed by Greptile

Comment thread src/application/binary/BinarySession.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83ba265cfc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Keep oversized SDK error retention and publication inside the shared session admission. Retry both server-owned artifact and process cleanup before reset, preserving failed owners and investigation records.

Bound controlled lifecycle waits, use canonical error facts and formatter delivery, and update CLI/Go lifecycle assertions.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
Keep retained prompt identifiers available after engine cleanup and clear them after explicit investigation reset. Record current-runtime multi-domain, Codex CLI and healthy Ghidra verification, with separate historical measurements and verification limits.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
@gensokyo-dev

Copy link
Copy Markdown
Collaborator Author

@greptileai please review the latest commit a809ff4. The previous transport-admission, artifact-cleanup, bounded-wait and wording findings were fixed in 6d875b3, with regression evidence replied in each thread. The final verification report also records current-runtime multi-domain, local Codex CLI and real Ghidra checks. Please check the final changes for remaining issues.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0f99adb2a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/server/EvidenceMcpServerCore.ts Resolved
Own handler cleanup and physical response publication in one request scope.
Borrow its original session admission across nested work so a queued reset cannot
clear successful or error Evidence before the reply settles. Distinguish outgoing
server request IDs and handle SDK-suppressed cancellation without releasing an
already-started send.

Cover blocked successful sends, SDK/handler failures and cancellation. Keep the
1500-file JavaScript timeout case within a measured finite parent retention
budget while preserving the separate memory-pressure case and worker limit.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
Pin the final runtime and genuine multi-domain, local Codex terra/high,
fresh-process checkpoint and Ghidra session-reuse results. Preserve earlier
measurements, partial attempts, bounded regression evidence and resource limits.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
@gensokyo-dev
gensokyo-dev merged commit f72638f into main Oct 31, 2026
54 of 56 checks passed
@gensokyo-dev
gensokyo-dev deleted the refactor/investigation-lifecycle branch October 31, 2026 21:34
Entrpi added a commit to Entrpi/rea that referenced this pull request Oct 31, 2026
Take main 6e9ee97. morluto#8228's ESP flash inputs join D1's load selection:
resolver, session and CLI options carry `loadSelection` and `espFlash`,
and `formatHint` comes from the selection. `inspect-artifact` and
`extract-artifact` now pass `--target-format esp-flash-image` as a load
selection; built from spreads, the old `formatHint` key compiled but was
dropped. The open_binary description keeps D1's M-profile sentence and
morluto#8361's investigation-record ending. Tests from main move to D1's inputs,
as embedded-integration did: morluto#7481's raw vocabulary target carries
`rawLoad`, morluto#8228's flash resolver tests pass `loadSelection`, morluto#8229's raw
scope case names its entry, and the pairing grid adds esp-flash-image's
four rows while the other sixteen keep d6f88be's hash.
coyoteXujie pushed a commit to coyoteXujie/rea that referenced this pull request Nov 2, 2026
)

Separate engine cleanup, investigation reset and terminal disposal in the shared application owner. Keep stable Evidence IDs and full Unknown revision history through engine close and target changes; serialize reset with all record writers and cleanup owners, optionally acknowledging a complete checkpoint before clearing. Bound retained representation without eviction.

Validation: 43 focused files / 533 distinct tests, source/type/lint/schema/documentation checks, nine genuine source cases across eight families, real Ghidra session identity and cleanup, and nine actual local Codex CLI terra/high runs with independent full-result and checkpoint audits. See docs/verification/investigation-lifecycle.md for measurements, partial attempts and verification limits.

Fixes morluto#8347.

BREAKING CHANGE: close_binary retains investigation records. Use reset_investigation to clear them. Cross-process recovery requires an explicitly acknowledged Evidence bundle checkpoint.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
@morluto morluto added the enhancement New feature or request label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(investigation): separate record lifetime from engine cleanup

2 participants