Repository navigation
fix(cli): retain linked sources in function bundles - #8873
Merged
Merged
Conversation
Contributor
[Medium impact] The reviewed changes appear safe to merge; no new actionable issue was found. SummaryThe PR keeps linked source records available until a requested function bundle is delivered.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Run analysis or replay snapshot"] --> B["Capture linked source records"]
B --> C{"Every source available?"}
C -->|Yes| D["Admit parent and finish cleanup"]
C -->|No| E["Keep failure and available sources"]
D --> F{"Analysis and cleanup succeeded?"}
F -->|Yes| G["Publish requested bundle"]
F -->|No| E
E --> H["Return bounded recovery details"]
Reviews (7) · Last reviewed commit: "fix(cli): reconcile evidence closure wit..." · Reviewed by Greptile |
morluto
marked this pull request as ready for review
November 4, 2026 16:53
Codex Review Summary: ✅ CompletedThis 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. |
# Conflicts: # src/application/DirectAnalysis.ts # src/application/binary/AnalysisSnapshotCache.ts # src/application/binary/AnalysisSnapshotReplayBinding.ts # src/application/investigation/InvestigationEvidence.ts # tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts # tests/boundary/mcp/workflowSnapshotReplayMcp.test.ts
# Conflicts: # src/application/DirectAnalysis.ts # src/cli/analysisEvidenceDelivery.ts # tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts
3 tasks
morluto
enabled auto-merge (squash)
November 7, 2026 18:17
2 tasks done
9 of 11 tasks
3 tasks
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and outcome
rea function --evidence_outputcould report success while saving a parent that cited a missing Ghidra historical-analysis source. Capture the exact transitive source records while the one-shot session owns them, and include them in the requested bundle. A missing source fails before publication; missing transitive sources and finalization failures can report already captured records through the existing bounded recovery contract. Related: #8872.The snapshot replay path captures from the authenticated snapshot bundle before returning. This PR builds on merged #8870 and incorporates the source-delivery changes already merged in #8585. Default output without an Evidence bundle remains outside this change (#8590).
Integration and review follow-up
Merged main through
c928bb8d. The import conflict arose because main uses the shared closure resolver while this path needs the collector for partial sources; the merged file imports the collector and checker it actually uses, preserving the shared resolver for its other consumers. On Node 24.22.1,build:cached,check:fast,format:check, and five focused closure, replay, delivery, cleanup and limitations suites passed (84 tests, 2 skipped). Real-provider checks were not rerun for this merge.Merged main through
2e2f981c. The merge combined two versions of the closure traversal; the merged owner retains one traversal that can either stop on failure or collect reachable partial sources. Removed the duplicate source-list merge in CLI delivery so each supplied source is processed once. The Ghidra verifier now emitsPASSonly after its owned cleanup succeeds; failed cleanup retains its resources and cannot be reported as success.Node 24.22.1 focused source tests passed: closure, direct snapshot replay and CLI evidence delivery: 44 passed, 2 skipped; direct-analysis cleanup and limitations: 35 passed.
build:cached(3 tasks, 1 cached), uncachedcheck:fastand verifier syntax checks passed; fullformat:checkpassed after integrating upstream #9280. After building, the process-ownership test passed (1 test). Real Ghidra and a real cleanup failure were not rerun. Earlier real-provider observations below are historical and do not qualify the merged head.Validation
After merging the updated fix: preserve source closure during snapshot replay #8870 base and main,
check:fastpassed and six source-closure, snapshot, CLI and MCP suites passed (123 tests, 2 skipped). The real Ghidra 12.1.4/JDK 21 verifier passed complete, summary and no-overwrite checks; target and project contents remained unchanged (target SHA-256f2e37d3446e978b41a3111918a386065591eafa921a1e964626825acfb9e1d3f). Real provider cleanup failure was not exercised.Review follow-up: the Ghidra verifier now uses the shared process owner and retains its temporary directory if process cleanup fails; nonzero-exit output is read from the owner snapshot.
nativeVerifierCommandOwnership.test.tspassed (1 test), andnode --checkpassed. The updated verifier passed with real Ghidra 12.1.4 and JDK 21 on macOS arm64: complete, summary, and no-overwrite checks passed, and target and project contents remained unchanged (target SHA-256a1609877a6e080f31e04b7884bad21956299526e1774fea152d09a43bc168a12). Real provider cleanup failure was not exercised.Disposable integration with capacity-recovery fix!: preserve results when source publication fails #8444 head
6fd318a99: the merge was clean, the combined build succeeded, and five focused one-shot, MCP, snapshot, CLI and failure-recovery suites passed (84 tests, 2 skipped). The real Ghidra function-bundle verifier passed on the combined build. These are combined-checkout controls, not standalone verification or a merged change.Review follow-up: collection visits all reachable authenticated records even when one ancestor is missing; completed partial observations collect their sources before cleanup, and source capture precedes parent admission. Four focused suites passed (66 tests, 2 skipped). Cancellation-at-result and failed-parent-admission regressions failed against the previous PR head and pass now. The synthetic missing-ancestor/sibling control exercises the shared closure owner. The real Ghidra CLI verifier and
check:fastpassed after the change.scripts/verify-real-ghidra-function-bundle.mjsbuilds a source fixture and saved project with a synthetic history report, then exercises the public CLI for complete, summary and no-overwrite delivery. It hashes every original project file and the target. On macOS arm64 with Ghidra 12.1.4/JDK 21 it failed on the pre-fix build for a missing linked record and passed on this prototype. The target was not executed.docs:checkpassed.Real Ghidra no-overwrite control:
function --detail summary --evidence_outputagainst a pre-existing caller file exited 1 withinvalid_request, left its contents unchanged, and returned a complete failure source closure containing the linked historicalhealthrecord. This exercises one publication failure, not real provider cleanup failure.Combined prototype source-free control: real Kuna 1.990 produced successful summary bundles for both
functionandtraceon the same fixture, with no unresolved links. Neither result had a linked source, so this does not verify Kuna transitive-source capture. The target SHA-256 remained510a23fc3c152175b9977130b3b1711d580e47d22a085cdee6a4e0c9dea2c51a.Offline handoff on the combined prototype: after the real Ghidra CLI runs, a fresh target-free MCP server configured with unavailable Ghidra and Java imported both bundles in each schema profile. Exact-ID retrieval reproduced each linked source record; a trace-reference page matched the two retained rows and a function pseudocode view matched the retained text. Bundle hashes stayed unchanged. This tests offline consumption, not provider rediscovery or the standalone PRs in isolation.
Combined feat(native): page retained feature traces #8585 head
1fc86c45awith this PR in the integration prototype: five focused suites passed (64 tests, 2 skipped). Real Ghidra on the synthetic-history fixture saved bothfunctionandtraceresults with their linkedhealthsource; every link in the trace bundle resolved. This combined checkout is not standalone coverage for either PR.Real Ghidra 12.1.4/JDK 21 on macOS arm64, using a disposable existing project with a synthetic historical report: both complete and summary
rea function --evidence_outputcalls saved the parent and its linkedhealthrecord. The same fixture reproduced the missing source before this change. A snapshot was selected, but the documentless function calls did not replay; this is a live-provider control, not a real replay test. Target and selected project descriptor hashes were unchanged; project contents were not independently hashed as a whole.Three focused CLI, one-shot filesystem and failure-recovery suites passed (58 tests, 2 skipped), including cancellation, injected cleanup failure, and a missing transitive source. The missing-source regression failed before the partial-capture fix; afterward it preserved the available source, identified the missing ancestor, and wrote no bundle. A simulated-provider snapshot replay exported the parent and exact linked source without restarting the provider.
check:fastandgit diff --checkpassed. Real provider cleanup failure, other platforms, and other commands/providers were not exercised. The existing no-output behavior is unchanged.Author readiness
Human owner: