Repository navigation
fix(server): admit investigation tools into session lifecycle (#4002) - #4174
Swatantra-66 wants to merge 1 commit into
Conversation
…ent dangling records on close Admit differential investigation workflows (build_call_path, find_changed_behavior, correlate_static_and_runtime, verify_reconstruction) into session analysis via runAdmittedToolOperation. This ensures close_binary drains in-flight workflows before clearing retained records, and re-validates source evidence closure before publishing results. Fixes morluto#4002
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[High impact] The PR appears safe to merge; no actionable issues were found. SummaryThe PR brings four investigation tools into the existing session lifecycle.
No actionable issues were found. Supersession could not be checked because GitHub access required authentication. Tests were inspected, not run. DiagramsequenceDiagram
participant Client
participant Tool as Investigation tool
participant Session
participant Ledger
Client->>Tool: Start investigation
Tool->>Session: Register admitted work
Tool->>Tool: Compute derived result
Client->>Session: close_binary
Session->>Session: Wait for admitted work
Tool->>Ledger: Recheck source links
alt Sources still exist
Tool->>Ledger: Save derived evidence
Tool-->>Client: Return evidence
else Source is missing
Tool-->>Client: Return EvidenceIntegrityError
end
Session->>Ledger: Clear retained records
Session-->>Client: Close completes
Reviews (1) · Last reviewed commit: "fix(server): admit investigation tools i..." · Reviewed by Greptile |
Admit all four derived investigation workflows until Evidence recording settles, so close drains earlier work before clearing the ledger. Honor cancellation after awaited terminal progress before publishing a result. Refs #4002, #4174 Co-authored-by: Swatantra Yadav <[email protected]>
|
Integrated the session-ownership fix on main in 663d07f. All four investigation handlers hold existing session admission through derivation and Evidence recording, so close_binary drains earlier operations before clearing records. Redundant post-derivation closure repairs and private-state clearing tests were not retained. A related publication guard now honors cancellation arriving during awaited terminal progress. The public MCP race failed on the original registration with close settling first; fixed ordering and an empty post-close ledger pass. The terminal-cancellation regression also failed before its guard and passes afterward. Main CI passed all36 jobs: https://github.com/morluto/rea/actions/runs/38792163880. Closing as addressed. |
Summary
Admit differential investigation workflows into the session analysis lifecycle so that
close_binarywaits for in-flight requests before clearing retained records, and re-validates source evidence closure prior to publishing derived records.Fixes #4002
Problem and expected behavior
When differential investigation workflows (
build_call_path,find_changed_behavior,correlate_static_and_runtime,verify_reconstruction) were registered directly on the MCP server without session admission (runAdmittedToolOperation/withAdmittedAnalysis),session.#callswas unaware of in-flight work.If a caller invoked
close_binarywhile an investigation workflow was computing,close_binaryimmediately proceeded through#drainCalls(), closed the underlying engine, and cleared retained session records (clearSessionRecords()). When the investigation workflow subsequently finished, it minted new derived Evidence referencing previously retained source Evidence IDs and recorded it into the emptied session ledger, resulting in danglingevidence_links.Expected behavior:
close_binarymust wait for in-flight investigation workflows to settle before draining records and closing session engines.EvidenceIntegrityErrorrather than publishing orphaned records to the ledger.Change and scope
src/server/registerInvestigationTools.ts:find_changed_behavior,build_call_path,correlate_static_and_runtime, andverify_reconstructionwithrunAdmittedToolOperation(server, admission, contract.name, context.mcpReq.signal, ...).evidenceClosure(session, links)checks inbuild_call_pathandcorrelate_static_and_runtimebefore committing derived evidence viarecordWorkflowEvidence.find_changed_behaviorandverify_reconstruction.tests/boundary/mcp/investigationAnalysisMcp.test.ts:awaits in-flight call-path derivation before close drains records (#4002)tracking settlement order (build_call_paththenclose_binary) and validating inline evidence retention before session draining.rejects call-path recording when source Evidence is cleared before publishing (#4002)validating that clearing source records before publishing triggers fail-closedEvidenceIntegrityError("dangling Evidence link") and leaves the ledger clean.Contract and boundary impact
src/server/registerInvestigationTools.ts(MCP tool registration boundary).evidence_linksexist in the active session ledger when recording.Expected effects:
Evidence and regression coverage
tests/boundary/mcp/investigationAnalysisMcp.test.tsclose_binaryduring pausedbuild_call_pathand simulated clear before publishing.EvidenceIntegrityErrorif source closure is broken.For evidence-bearing changes:
Validation performed
npm run test:focused -- tests/boundary/mcp/investigationAnalysisMcp.test.ts— 14/14 tests passednpm run typecheck(tsc --noEmit) — passed (0 errors)npm run lint— passed (0 errors)npm run docs:check— 6/6 build tasks passed; readmeConsistency passed (5/5)Compatibility, safety, and release
Author readiness
Human owner: @Swatantra-66
Before merge
type(scope): outcome.