Repository navigation
fix(hopper): validate every bridge reply against one contract table - #10662
Conversation
…e provider edge Hopper validated only the response envelope. list_names replies outside the inventory contract were returned unchanged (projectHopperNameInventory passed them through), and the regex search re-parsed its inventory with its own policy. A per-method reply contract table built from the shared native inventory schemas now validates list_names, list_procedures, list_strings, search_procedures and search_strings once; a reply outside the contract is an AnalysisOutputError. The remaining 31 operations are a counted pending list that may only shrink.
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. |
[Medium impact] The reviewed changes appear safe to merge. SummaryAdds one reply-contract table for all advertised Hopper operations and the private methods used by caller scans.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Hopper bridge reply] --> B[Method reply contract]
B -->|Invalid| C[AnalysisOutputError]
B -->|Valid source preserved| D[Direct reply or checked projection]
D --> E[Analysis result and Evidence]
Reviews (3) · Last reviewed commit: "fix(hopper): apply reply contracts on th..." · Reviewed by Greptile |
… operations Twenty-two more Hopper operations are validated against reply contracts built from the shared native schemas. The pending list shrinks from 31 to 9 operations.
The reply table now covers every bridge method REA reads, including the private caller-reconciliation methods. HopperFileOffset receives a validated observation and HopperCallerReconciliation reads typed replies instead of keeping its own schemas and re-parsing the native result. The segment list schema moves from contracts into its domain owner.
…ntry path executeIfReady validated only list_procedures, so a malformed list_documents reply could reach the completion path. Every contracted operation is now validated there, and provider-level tests cover the direct and ready paths for each inventory and document operation.
|
I've pushed changes for all three Greptile findings.
Related work in the same PR: the contract table now covers every bridge method REA reads. That includes the caller-reconciliation methods ( Validation:
|
#10662 validates every Hopper bridge reply. The fake Hopper behind the darwin packaged-CLI baseline still served list_segments without permissions, provenance and sections, so 'rea analyze --provider hopper' failed as unreadable output on every PR that ran that lane. The fixture's replies move to fakeHopperReplies.mjs, list_segments takes the real bridge's shape, and a test checks every served reply against the contract table.
…10734) * fix(test): serve fake Hopper segments in the bridge's reply contract #10662 validates every Hopper bridge reply. The fake Hopper behind the darwin packaged-CLI baseline still served list_segments without permissions, provenance and sections, so 'rea analyze --provider hopper' failed as unreadable output on every PR that ran that lane. The fixture's replies move to fakeHopperReplies.mjs, list_segments takes the real bridge's shape, and a test checks every served reply against the contract table. * test(hopper): derive the fake reply method list from one keyed factory object The contract test iterated a hand-kept method list beside the reply switch, so a reply added without updating the list would go unchecked. Replies are now factories in one keyed object; fakeHopperReply looks them up by key and FAKE_HOPPER_REPLY_METHODS is the object's keys, so every served reply is validated against its contract. * test(hopper): serve containing-procedure and reference replies from the keyed factories
Summary
Hopper validated only the bridge response envelope. Operation replies passed through as untyped
JsonValue, and later readers applied contract schemas, each with its own policy. One of them,projectHopperNameInventory, returned a malformedlist_namesreply unchanged.This PR adds the owner, as Ghidra already has: a reply-contract table that covers every bridge method REA reads and is built from the shared
src/domain/nativeschemas. Each reply is validated once, at the provider edge or by the reconciler that reads it.Refs #8067. Structural audit 2026-11, report 16 finding F1 (Run P1).
Problem and expected behavior
list_namesreturns{"unexpected":"shape"}, rows withoutvalue, or an out-of-contractobjc_class_label. The same applies to a drifted reply from any other Hopper method.AnalysisOutputError("Hopper bridge output did not match the contract").executeandexecuteIfReady.Change and scope
src/hopper/HopperReplyContracts.ts:hopperReplySchemasis typedsatisfies Record<HopperBridgeMethod, ZodType>, so a new bridge method cannot compile without a contract.hopperBridgeMethod(operation)is the one mapping from an operation to its bridge method, e.g.procedure_callers→rea_caller_base. It replaces the provider's inline ternary.parseHopperReplyvalidates a reply and returns the source value unchanged.HopperProvider: validates each reply that reconciliation and regex search don't read.list_namesandaddress_to_file_offsetare passed to their projections as typed values.executeIfReadyvalidates every contracted operation.HopperFileOffset.mapHopperFileOffsettakes the validated observation; its local schema and malformed branch are deleted.HopperCallerReconciliation: its local schemas (page, target, base, references) move into the table. The native reply is now parsed once, not three times (the old flow ransafeParseand then.parseagain).projectHopperNameInventory: its pass-through branch is deleted.HopperRegexSearch: its own inventory schema check is deleted.src/contracts/toolOutputSchemaPrimitives.tsinto its domain owner,src/domain/native/nativeSegments.ts(nativeSegmentListSchema). The contracts module reuses it.Intentionally not included: the cross-provider readers (
nativeInventoryView,functionInventory,NativeDispatchMetadataInspection,EnhancedLiteralTracing), which also serve Ghidra and IDA. TypingHopperClient.callToolby method is also not done.Contribution scope: not applicable. This is a fix within existing boundaries.
Contract and boundary impact
HopperNameInventory.ts, and the inventory schema check inHopperRegexSearch.ts.bridge/hopper_bridge.pyemits{address, value}names and{address, value, provider_value, string|decoding}strings, which satisfy the contracts. A drifted or foreign bridge reply now fails instead of passing through.rawResultis still retained when the class-label projection changes rows.Expected effects:
Evidence and regression coverage
src/hopper/HopperNameInventory.test.ts: malformedlist_namesreplies are rejected through the real provider client.src/hopper/HopperReplyContracts.test.ts:execute(list_procedures,list_strings,search_procedures,search_strings,list_documents) andexecuteIfReady(list_procedures,list_documents).tests/boundary/filesystem/hopperFatCoordinates.test.tsroutes its observations through the contract.list_namesrejection cases fail againstorigin/main(3 failed, 3 passed).bridge/hopper_bridge.pyand the existing fakes.Validation performed
npm run test:local -- src/hopper/HopperReplyContracts.test.ts src/hopper/HopperNameInventory.test.ts src/hopper/HopperCallerReconciliation.test.ts src/hopper/HopperProvider.test.ts src/hopper/HopperRegexSearch.test.ts: 54 passed, before the latest test additionsnpm run test:local -- src/hopper/HopperReplyContracts.test.ts: 10 passed, after the Greptile fixesnpm run test:focused -- tests/boundary/providers/hopper/hopperCallerReconciliation.test.ts tests/boundary/providers/hopper/hopperFileOffsetClose.test.ts tests/boundary/providers/hopper/hopperBookmarks.test.ts tests/boundary/providers/hopper/hopperInstructions.test.ts tests/boundary/filesystem/hopperFatCoordinates.test.ts: 34 passed, 8 snpm run check:fastand pre-push typecheck/lint: passedCompatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.