Repository navigation
fix(evidence): admit bundle imports across session transitions - #2303
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
TL;DR: I tested this fix over a real MCP connection, and it works. With the fix, close_binary waits for an import that is still reading its file. An import sent after close waits for close too. I sent each group of calls in the same tick over stdio. The bundle was a 31 MB file with 20,000 records, so the read took about 1.4 seconds. A named pipe did not work, because REA only reads regular files. ResultsEach cell counts the runs that showed the behaviour this PR describes, out of 3.
What base did:
TimingsA normal import took about 1.4 s on both. With no binary open, the median was 1,358 ms on head and 1,375 ms on base. With a binary open, it was 1,420 ms and 1,402 ms. With the fix, close now waits as long as the import. Here that was 1.3 to 1.8 s. On base with no binary open, close took 3 ms. The PR's own test file, copied into the base tree for the base row:
Not run
Thanks, rohitg00, for the fix, and for tests that hold the file read open on purpose. Test setup
Commands🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
@greptileai review |
|
This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on. |
|
Summary
Keep
import_evidence_bundleadmitted until its file read, validation, session mutation, and result delivery finish. A concurrentclose_binarynow drains an earlier import before clearing the session, and an import submitted after close waits for that transition.Problem and expected behavior
If a bundle read is still pending when
close_binaryruns, close currently succeeds with an empty ledger, then the import appends its records to the closed session. An import must follow the same session transition ordering as other admitted workflows. The regression is reproduced onaeee5074; the affected implementation is unchanged in upstream0043d9b1.No existing issue or competing PR for this ordering defect was found in the upstream recheck. The earlier import cancellation fix remains intact.
Change and scope
Wrap the complete import workflow with the existing
withAdmittedAnalysisandrunAdmittedToolOperationhelpers. The session remains the sole owner of lifecycle ordering. Add two actual MCP SDK regressions with real bundle files and a controlled file-close boundary.Contract and boundary impact
Expected effects:
Evidence and regression coverage
Both new regressions fail on the affected base: the first records
closebeforeimport, and the second returns an incorrect total of2. After the fix, the first import returns{ imported: 1, unknowns_added: 0, total: 1 }and close leaves no records. A later import returns total1, retaining only its own bundle.The second request is explicitly observed at the MCP transport before the first read is released. Existing cancellation, persistent and transient file-close failures, target-free workflows, and session admission cancellation also pass.
Validation performed
Using pinned Node 24.18.0 and npm 11.16.0 on macOS arm64:
npm run build:cached: passed.npm run test:focused -- tests/boundary/mcp/evidenceImportLifecycle.test.ts tests/boundary/mcp/evidenceImportCancellation.test.ts tests/boundary/mcp/sessionMcp.test.ts tests/composition/analysis-sessions/binarySession.test.ts: 43 tests passed across four files.npm run check: passed, including typecheck, lint, format, unused-code, metadata, module-boundary, and architecture checks.npm run verify:test-discovery: all 962 test files discovered exactly once.git diff --check: passed.Compatibility, safety, and release
No breaking changes, migrations, new process authority, or release metadata changes. The tests exercise the real MCP SDK and filesystem with deterministic scheduling; a binary provider is deliberately unavailable, proving this remains a target-free operation. Other host platforms remain CI coverage.
Before merge