Skip to content

fix(hopper): name the failing fields when a bridge reply misses its contract - #10713

Merged
morluto merged 3 commits into
mainfrom
fix/hopper-reply-contract-diagnostics
Nov 15, 2026
Merged

morluto merged 3 commits into
mainfrom
fix/hopper-reply-contract-diagnostics

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

main fails "Native package baseline (darwin arm64)" (run 43656106187). The packaged rea analyze <node> --provider hopper --json returns unreadable_output "Hopper bridge output did not match the list_segments contract". That job runs the packaged CLI against the fake Hopper bridge (tests/fixtures/fakeLauncher.mjs -> fakeHopper.mjs), not real Hopper. #10662 began validating list_segments against nativeSegmentListSchema, and the fake's reply lacked permissions, provenance and sections. The refusal did not say which fields failed, and neither the contracts nor the fake were in the package lane's CI scope, so the mismatch reached main.

The fake's replies are fixed in #10734. This PR fixes the two reasons the failure was hard to see and reached main:

  1. Reply-contract refusals name the failing fields. outputContractDiagnostics (in src/domain/native/nativeProviderOutput.ts, the shared native-output owner) projects each Zod issue to its field path, issue code, expected kind and observed JSON kind. No reported text is included. Both parseHopperReply and invalidNativeOutput attach it as details.diagnostics.
  2. The package CI scope covers the fake bridge (tests/fixtures/fakeLauncher.mjs, tests/fixtures/fakeHopper*.mjs), the real bridge, the reply contract table and every non-test native domain module (src/domain/native/!(*.test).ts), since the contracts import those schemas transitively. A change on either side runs the darwin package baseline before merge.

Depends on #10734: this PR's own darwin package job runs the stale fake until #10734 merges and this branch is rebased.

Problem and expected behavior

A Hopper reply outside its contract must stay an AnalysisOutputError, and the error must say which fields failed so the producer can be fixed. Before this PR it said only "did not match the list_segments contract".

Change and scope

  • Not included: any change to the contracts or coercion of replies. The real bridge (bridge/hopper_bridge.py) already emits every field the list_segments contract requires; only the fake was stale.
  • Not included: the fake's replies (fix(test): serve fake Hopper segments in the bridge's reply contract #10734).
  • Not included: the Ghidra contract-refusal sites (GhidraInventoryValues.ts, GhidraFunctionValues.ts). They build their own errors; follow-up.
  • Contribution scope: not applicable (fix within existing boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: outputContractDiagnostics owns how a native reply's contract failure is described. Its consumers are parseHopperReply and invalidNativeOutput.

  • CLI and MCP/tool-catalog contract: unreadable_output errors from these two producers now carry details.diagnostics.contract_issue_count and contract_issues[], each {path, code, union_branches?, expected?, received?}, capped at 16 issues. A failed union is replaced by the issues of every option it tried, at their full path; union_branches gives the option index at each union level. This is additive.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: none.

  • Generated metadata, package, or installation impact: CI scope only.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated: HopperReplyContracts.test.ts "names each failing field without echoing reported text" and "names the nested field of each option a failed union tried". ciChangeScope.test.ts routes tests/fixtures/fakeHopper.mjs, tests/fixtures/fakeHopperReplies.mjs, src/hopper/HopperReplyContracts.ts, nativeSegments.ts, functionBody.ts and nativeSymbol.ts to the package lane, and functionBody.test.ts not.
  • Base reproduction: with this branch built and the pre-fix(test): serve fake Hopper segments in the bridge's reply contract #10734 fake, node scripts/rea.mjs analyze <node> --provider hopper --json (with HOPPER_LAUNCHER_PATH/HOPPER_LOADER_ARGS_JSON set as scripts/verify-package-environment.mjs sets them) reproduces main's failure, now with details.diagnostics.contract_issues naming [0, "permissions"] (invalid_union), [0, "provenance"] (invalid_value) and [0, "sections"] (invalid_type, received missing).
  • Remaining proof gaps: this PR's darwin package job is green only after fix(test): serve fake Hopper segments in the bridge's reply contract #10734 merges and this branch is rebased.

Validation performed

  • npm run test:local -- src/hopper/HopperReplyContracts.test.ts: 12 passed.
  • npm run test:focused -- tests/boundary/filesystem/ciChangeScope.test.ts tests/boundary/filesystem/ciRequiredLanes.test.ts: 399 passed.
  • npm run check:fast: passed.
  • Earlier commit: npm run test:focused -- tests/boundary/filesystem/ciChangeScope.test.ts tests/boundary/filesystem/ciRequiredLanes.test.ts src/hopper/HopperReplyContracts.test.ts: 403 passed; npm run test:focused -- tests/boundary/mcp/enhancedTools.06-rejects-incomplete-function-dossiers-at.test.ts: 7 passed; npm run check:fast: passed.
  • npx oxlint and npx oxfmt on the two files changed in the latest commit: no errors.
  • Local run of the packaged-baseline commands described above (built from source, not an installed tarball).

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Error details are additive.
  • Real Hopper/Ghidra, browser, or OS coverage: none; the darwin package baseline uses the fake bridge.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: diagnostics carry field paths and JSON kinds only, never reported names or values.

Author readiness

Human owner:

  • 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

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T01:55:48.318788Z 2430b15 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 Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge once the stated dependency is included and required checks pass.

Summary

The PR adds field-level details to native reply failures and expands package checks to cover Hopper’s bridge and native schemas.

  • Invalid Hopper replies now point to the fields that failed.
  • Hopper bridge and schema edits now select the package CI lane.

Reviews (5) · Last reviewed commit: "fix(hopper): name nested union failures ..." · Reviewed by Greptile

Comment thread scripts/ci/scopes.mjs Resolved
@morluto
morluto merged commit cd5ea9a into main Nov 15, 2026
15 of 17 checks passed
@morluto
morluto deleted the fix/hopper-reply-contract-diagnostics branch November 15, 2026 02:11
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working provider: hopper Analysis provider / engine: hopper labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working provider: hopper Analysis provider / engine: hopper

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant