Skip to content

feat(ghidra): set function signatures and define the types they use - #14859

Merged
morluto merged 17 commits into
mainfrom
feat/ghidra-signature-and-type-edits
Nov 27, 2026
Merged

morluto merged 17 commits into
mainfrom
feat/ghidra-signature-and-type-edits

Conversation

@morluto

@morluto morluto commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs #14831 (design discussion; the maintainer approved the scope there and in a comment on this PR: signature edits and caller-defined data types, with local-variable retyping left as a follow-up).

On a target without debug information, Ghidra pseudocode reads fixed offsets from an untyped pointer. Nothing in REA could assert a type, so an agent re-derived the layout in every function. This PR lets a caller set one function's prototype and define the structure types it needs:

  • annotate_native_function gains an optional signature.
  • A new tool, define_native_data_types, adds caller-authored C types to the analysis database.
  • inspect_native_data_type reports those types as source: "caller-defined".

Retyping or renaming individual local variables (HighFunctionDBUtil) is not included.

Problem and expected behavior

Use case, on a stripped x86-64 ELF where 0x1001800 is double session_total(const struct session *s, unsigned mask):

define_native_data_types { declarations: "struct session { int id; char name[32]; unsigned flags; double score; struct session *next; };" }
annotate_native_function { procedure: "0x1001800", name: "session_total", signature: "double total(const struct session *s, unsigned mask)" }

Observed procedure_pseudo_code before:

double FUN_01001800(long param_1,uint param_2)
  ...
    if ((*(uint *)(param_1 + 0x24) & param_2) != 0) {
      dVar1 = dVar1 + *(double *)(param_1 + 0x28);
    }
    param_1 = *(long *)(param_1 + 0x30);

and after:

double session_total(session *s,uint mask)
  ...
    if ((s->flags & mask) != 0) {
      dVar1 = dVar1 + s->score;
    }
    s = s->next;

Change and scope

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the Author readiness and
Author checklist unchecked. Maintainers can help resolve open questions.

Scope decision: approved in #14831 for signature edits through annotate_native_function and caller-defined data types through define_native_data_types. Local-variable retyping is a follow-up and not in this PR. This adds a mutation capability (analysis metadata in the session database, never executable bytes).

What the existing path does (read before designing):

  • Contract annotate_native_function (src/contracts/officialToolContracts.ts) → Ghidra input/result schemas (src/ghidra/GhidraFunctionValues.ts) → bridge annotateNativeFunction. The bridge ends the GhidraScript outer transaction before serving, so each edit owns a real outer transaction; it validates text, applies comments then name with SourceType.USER_DEFINED, reads back, rebuilds the dossier inside the transaction, and rolls back on any failure. Both outcomes flush the name inventories and the decompiler cache.
  • Snapshot invalidation is not per tool: BinarySession invalidates the immutable snapshot before dispatching any capability whose effects.mutatesArtifact is true, which GHIDRA_MUTATING_OPERATIONS drives. Checkpoint mode saves on normal close when the Program modification number changed.
  • Windows P0 and existing-project sessions are read-only in three places: the bridge dispatch refuses the method, the handshake omits it from capabilities, and parseGhidraSessionInfo requires exactly that set.
  • Caller authorship of a name is visible as symbol.source: "user_defined". Prototypes had signature_source only in inspect_native_api; data types have no SourceType at all.

What this PR adds:

  • signature on annotate_native_function (same intent, result contract and authority as the existing tool). Parsed with Ghidra's CParser against the Program's data type manager with storeDataType=false, before the transaction, so a refused prototype writes nothing. Applied inside the existing transaction with ApplyFunctionSignatureCmd, SourceType.USER_DEFINED, Ghidra-assigned storage and FunctionRenameOption.NO_CHANGE. The prototype's own function name is a placeholder; name remains the only rename. Readback compares return type, parameter count, types, names, varargs, _Noreturn and any named calling convention against what Ghidra applied; a difference rolls the call back. annotations gains signature (the formal prototype, accepted back as input when its function and type names are C identifiers), signature_source and calling_convention. When the function has no calling convention and the prototype names none, the compiler specification's default convention is recorded; see "Unknown calling convention" below.
  • define_native_data_types (a different object, so a separate tool paired with inspect_native_data_type). Accepts C struct, union, enum and typedef definitions; all are stored in one transaction or none. Types go to the category /rea_caller_defined, which is the persisted mark of caller authorship. A name the database already holds in any category is refused; an equivalent caller definition reports unchanged. Declared additive (mayDiscardData: false), so it is not in the destructive baseline.
  • Refusals are typed input errors naming signature or declarations with the bridge's reason. Refused: thunks (Ghidra redirects the prototype to the thunked function), undefined types, function-pointer parameters and members, repeated parameter and member names, structs without members, unnamed nested struct/union/enum members, and any prototype Ghidra would apply differently (array parameters, a parameter name another symbol holds, a calling convention the compiler specification lacks).
  • Fail closed on what Ghidra's parser drops. One bridge tokenizer reads caller C once before CParser sees it. It owns positions (CR, LF and CRLF each end a line, as in Ghidra's parser), comments (read as whitespace, including on #pragma pack lines) and directives (admitted from its tokens). Its decisions come from one table, UNAPPLIED_C_TOKENS, audited against every token and production of Ghidra 12.2's C.jj and checked on Ghidra 12.2: it refuses tokens whose meaning would be lost (__ptr32/__ptr64, which Ghidra stores as a native-width pointer; __near/__far; every attribute and declspec spelling including [[...]] and a trailing packed; __pragma; _Static_assert; Objective-C @ blocks, whose whole text Ghidra skips; backslashes) and reports pure qualifiers (const, volatile, restrict, __unaligned, __w64 in every C.jj spelling) in dropped_qualifiers. #pragma pack is admitted only in the operand forms Ghidra applies as written, with a decimal value, and a pop only when it matches an admitted push (Ghidra ignores a bare push). Enum values, array sizes and bit-field widths are admitted only as one decimal or hex integer literal within int, optionally negated, without suffixes: Ghidra evaluates C constant expressions with its own rules (names, casts and sizeof default, values outside int truncate, comparisons and unsigned arithmetic differ), so the caller writes the computed value. Every parsed type is refused beyond a fixed 256-level chain through pointers, arrays, typedefs and members, because Ghidra 12.2's recursive type code exhausts the stack near 2048 levels while holding its database lock; the tokenizer and dependency walks are iterative. An enum tag nothing defines makes Ghidra invent an empty enum, which is refused like an invented struct or union. It refuses, with line and column, every construct that parser accepts without applying: __attribute__ in every spelling, __declspec, _Alignas, __packed, asm labels, __extension__; static/extern/inline/register/auto/_Thread_local; variable declarations and any statement that is not a struct, union, enum or typedef definition; directives other than #pragma pack (#line silently changed the type's category); string and character literals (char a['b'] was stored as char[0]); a function body, default argument or second declaration in a signature; unnamed enums (stored under a generated name). Applied as written and proven by stored layout in the verifier: #pragma pack including push/pop, bit-fields, flexible and zero-length array members, enum values, several typedef declarators, _Noreturn, named calling conventions. Any diagnostic Ghidra's parser records while still reporting success, such as a repeated enumerator it drops, is refused with Ghidra's message. Parsing runs inside each edit's own transaction, because the parser fills an existing empty composite of the same name in place (for example a DWARF placeholder), so a refused edit leaves the program unchanged. const and volatile are accepted and not recorded, because Ghidra's type system has no representation for them and they affect neither layout nor storage. Both edits return dropped_qualifiers, listing each one with its line and column and, for a signature, its zero-based parameter_index (null for the return type), so the omission is reported rather than silent.
  • A type name in several categories. Ghidra's parser picks one silently. The bridge accepts the name only when every type of that name is equivalent, and otherwise refuses with the candidates' category paths (ambiguous_data_type), because C text cannot select a category.
  • Unknown calling convention. Cause, established on real Ghidra: a USER_DEFINED prototype locks parameter storage while the function's convention stays unknown, and the decompiler then prefixes pseudocode with Unknown calling convention -- yet parameter storage is locked. The applied storage was already what the caller's prototype implies under the default convention (observed RDI:8, ESI:4, return XMM0_Qa:8, identical with unknown and with __stdcall). The bridge now records the compiler specification's default convention in that case only; the warning is gone and annotations.calling_convention reports the result.

Decisions that need the maintainer's view:

  1. Bounds on the uncancellable parser. CParser cannot be cancelled and Ghidra requests have no deadline, so REA bounds the text before parsing it. Following choose the limit's control, a one-off structural limit is per-call. Each length, and nesting, whose cost doubles per level, is therefore an optional per-call parameter. The earlier launch-only REA_ controls are removed: an agent that hit one could only recover by restarting REA.

    Bound Default Floor Maximum Slowest measured parse at the maximum
    signature_max_utf16 (annotate_native_function) 2048 16 4096 0.8 s
    declarations_max_utf16 (define_native_data_types) 4096 16 8192 6.8 s
    parenthesis_max_depth (both tools) 8 1 12 2.2 s (8192 units filled with 12-level expressions)

    Measured on Ghidra 12.2, macOS arm64. The slowest shape per character is one chain of pointer declarators, cubic in length: 0.3 s at 2048 units, 0.8 s at 4096, 6.3–6.8 s at 8192, 24 s at 12288, 100 s at 16384. Nesting doubles the time per level and repeats per occurrence: 8192 units at depth 8 took 0.2 s, depth 10 0.7 s, depth 12 2.2 s.

    A length refusal is resource_constraint with details.limit carrying control_kind: "parameter", the parameter, its effective value, range, default and required_value, which the bridge measures and sends on the wire failure: the text's length, or its deepest nesting over the whole text. The generated recovery names the value to pass, or asks for shorter text when the length is above the maximum. The text fields have no schema maximum, so every over-length text gets this typed refusal rather than a schema error. A nesting refusal has the same shape with parenthesis_max_depth. The bridge validates each per-call value against the same range.

  2. /rea_caller_defined as provenance. Data types have no source field, so the category path carries it and survives a checkpoint. inspect_native_data_type.source widens from the literal analysis-database to an enum with caller-defined.

  3. Required readback fields. annotations.signature, annotations.signature_source and annotations.calling_convention are required in the output contract, not optional. Only the Ghidra adapter produces annotate_native_function; no Hopper, IDA or other provider implements it. They therefore stay required, and would become nullable if a second provider is added.

Not included: local-variable retyping or renaming; replacing or deleting a type; function-pointer types; any change to effects.persists_after_close, which is still the literal false in checkpoint mode as before.

Other open PRs edit bridge/ghidra/ReaGhidraBridge.java (#14843, #14847). This branch is based on origin/main only; expect a merge conflict in that file with whichever lands second.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the Java bridge owns C parsing, the transaction, readback and the ceilings on parser shape; GhidraSessionErrorProjection owns attributing the four new remote codes to an argument, and shares their classification with GhidraSessionError (request-scoped diagnostics). Consumers: MCP and CLI through the existing official-tool path.
  • Contribution scope fit and linked maintainer decision: static analysis metadata editing in an ephemeral or owned-checkpoint Ghidra database; no execution, injection or protection recovery. Approved in [Design] Let agents set signatures, retype locals and define structures in a Ghidra session #14831 for signature edits and caller-defined data types; local-variable retyping is a follow-up.
  • CLI and MCP/tool-catalog contract: one new tool (define_native_data_types, CLI define-native-data-types); new optional inputs signature and signature_max_utf16, three new required output fields and an optional dropped_qualifiers on annotate_native_function (CLI --signature); define_native_data_types takes an optional declarations_max_utf16 and returns an optional dropped_qualifiers; inspect_native_data_type.source gains a value. The tool catalog grows by one entry. No environment controls and no runtime analysis settings.
  • Provider, bridge, target-format, or platform compatibility: Ghidra on Linux/macOS fresh-import and owned-checkpoint sessions. Windows P0 and existing-project sessions refuse both edits exactly as they refuse names. The bridge advertises one more capability, so the handshake set changes with the packaged bridge. No other provider implements either operation.
  • Evidence, artifact, provenance, or reconstruction contract: caller-authored prototypes read signature_source: "user_defined"; caller-authored types read source: "caller-defined" and live under /rea_caller_defined. Both edits invalidate immutable analysis snapshots through the existing mutatesArtifact rule. Limitation text states that the types are the caller's assertions, not observations.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): the active session's Program only. Upstream behavior relied on: CParser with storeDataType=false stores nothing (observed: type count unchanged after parses); it invents an empty composite for an undefined struct tag (detected and refused); it accepts and drops attributes, storage classes, variable declarations and other constructs (now refused before parsing, see above). No new process, file or cleanup path.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): authored skill reference edited and the tracked .cursor-plugin copy regenerated with npm run cursor-plugin:generate. New npm script verify:ghidra:type-edits.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

The checked change effect is limited to analysis metadata: function prototypes and data types in Ghidra's temporary working database, saved to the caller's REA_GHIDRA_CHECKPOINT_DIR on normal close when checkpoint mode is on. Executable bytes, process memory, registers and REA configuration are not changed; the verifier asserts the target's SHA-256 is unchanged. The Ghidra process is the one the session already launched.

Evidence and regression coverage

  • Tests added or updated:

    • tests/boundary/mcp/ghidraTypeEditsMcp.test.ts (simulated bridge, real MCP boundary): type readback contract and rejection of out-of-contract replies; prototype readback with source and calling convention; each refusal code attributed to its field with the bridge's reason, recovery and a still-usable session; the ambiguous-name refusal for both tools; each length refusal binds its per-call parameter with effective value, range, default and required_value, covering the default bound, the caller's bound, and text above the maximum; a per-call value out of range, or signature_max_utf16 without signature, is refused before the bridge, and long text reaches the bridge; each nesting refusal binds parenthesis_max_depth with the measured required_value (default bound, caller's bound, need above the maximum); dropped_qualifiers passes through both results.
    • src/ghidra/GhidraSnapshotCache.test.ts: a dispatched define_native_data_types or signature edit stops snapshot replay and blocks snapshot export even when the bridge refuses it.
    • tests/boundary/providers/ghidra/ghidraCheckpointLifecycle.test.ts (fake Ghidra process over a real socket): after a signature edit or a type definition, a failed closing checkpoint is reported, leaves the previous checkpoint intact and the Program editable, and saves on retry; cancelling an active edit stops the Program without saving, and the next start is a new Program restored from the unchanged checkpoint.
    • scripts/verify-real-ghidra-type-edits.mjs (npm run verify:ghidra:type-edits), real Ghidra over MCP on a self-built fixture without debug information: nine phases, including maximum-length bracket, parenthesis, array, pointer and typedef floods that are refused while the session survives and still saves on close, a refused definition against a DWARF placeholder leaving it unchanged, a refused parser diagnostic, refusals for every audited C.jj token class and unapplied #pragma pack form, pure qualifiers reported with exact columns, every refused construct with its position, the stored layout of every applied construct, parameter storage and calling convention after a signature edit, a nesting bypass through comments, the deepest nesting reported under a lower bound, a raised bound admitting 10 levels, #pragma pack with trailing comments, CR and CRLF positions, dropped_qualifiers positions for const and volatile in both edits, and per-call bounds reaching the bridge.
    • Expectations changed, and why: src/ghidra/GhidraSessionValues.test.ts (databaseEdits) and tests/fixtures/fakeGhidraReplies.mjs (capability and mutating-method lists) list the new operation, because the handshake requires the exact capability set and the read-only (Windows P0, existing-project) set must omit it. Annotation reply fixtures in GhidraProvider.behavior.test.ts, GhidraSnapshotCache.test.ts, ghidraEvidenceMcp.test.ts and officialArguments.test.ts gained the three required readback fields. scripts/lib/real-ghidra-boundaries.mjs compared the whole annotations object to four fields; that comparison is now the exported assertNameAndCommentReadback, which compares those four and asserts the untouched prototype is not user_defined. tests/fixtures/fakeGhidra.mjs gained a checkpoint_hang_edit mode and marks the checkpoint dirty after either edit. No assertion was removed or loosened otherwise.
  • Base reproduction or other evidence: executed by hand over MCP (node scripts/rea.mjs mcp) on a stripped x86-64 ELF with Ghidra 12.2. The before/after pseudocode above is that output. In the same session: a signature naming an undefined struct, and one with a syntax error, each sent with name and comment, left procedure_info at undefined FUN_01001800() with symbol.source: "default" and address_name at FUN_01001800; a conflicting redefinition sent together with a new struct stored neither; the applied prototype's readback, passed back as signature, returned identical annotations. With a fresh mode-0700 REA_GHIDRA_CHECKPOINT_DIR, after close_binary a new MCP process showed s->flags, s->score, s->next, inspect_native_data_type source: "caller-defined", and the same definition reported unchanged.

  • User-visible CLI/MCP output (if applicable):

    {"types":[{"id":"/rea_caller_defined/session","name":"session","kind":"struct","size_bytes":56,"status":"defined"}],"effects":{"scope":"session-analysis-database","source_bytes_modified":false}}
    {"address":"0x1001800","name":"session_total","comment":"sums scores","inline_comment":null,"signature":"double session_total(session * s, uint mask)","signature_source":"user_defined","calling_convention":"__stdcall"}

    Over-length refusal, with the fields the boundary test asserts; this was composed from the code, not captured:

    {"code":"resource_constraint","message":"signature has 2063 UTF-16 code units; signature_max_utf16 admits at most 2048 UTF-16 code units. Ghidra's C parser cannot be cancelled, so REA bounds the text it parses. Nothing in this call was applied","limit":{"control_kind":"parameter","parameter":"signature_max_utf16","effective_value":2048,"unit":"count","minimum":16,"maximum":4096,"default_value":2048,"applies_at":"next_call","required_value":2063}}
    {"issues":[{"path":["declarations"],"reason":"invalid_value","message":"declarations contains the attribute or extension __attribute__ (use #pragma pack for packing) at line 1, column 30; Ghidra's C parser would not apply it as written, so nothing was changed"}]}
    {"issues":[{"path":["signature"],"reason":"invalid_value","message":"The type name FILE names different types in the database: /DWARF/FILE.h/FILE, /stdio.h/FILE"}]}
    {"code":"invalid_request","issues":[{"path":["signature"],"reason":"invalid_value","message":"signature uses types the database does not define: session"}],"remediation":"Define the named types first (MCP define_native_data_types; CLI rea define-native-data-types), then repeat this call. Nothing in this call was applied."}
    {"issues":[{"path":["signature"],"reason":"invalid_value","message":"Ghidra applied a different prototype at 0x1001800 than requested: double FUN_01001800(int * a); requested double f(int[4] a)"}]}
  • Remaining proof gaps:

    • Real Ghidra was run on macOS arm64 only (x86-64 ELFs by hand; arm64 Mach-O object in the verifier). No Linux run. The Windows P0 refusal is covered by the handshake unit test and by reading the bridge dispatch, not by a Windows run.
    • npm run verify:ghidra fails on this host at scripts/lib/native-value-e2e.mjs:313 before the annotation section; the same failure occurs on the base commit of main on this machine, so it is pre-existing and not addressed here. The edited assertion was executed separately: a driver sent the section's own request to real Ghidra and passed the reply to the exported assertNameAndCommentReadback, which passed, and failed as intended on a caller-authored prototype. The rest of that section remains unexecuted with this change.
    • The ambiguous-name refusal was executed by hand on a debug ELF (FILE refused in a signature and as a member with nothing stored; size_t, whose two definitions are equivalent, accepted). The verifier fixture has no duplicate names, so the automated coverage of this rule is the simulated-bridge projection test only.
    • Cancellation and checkpoint-save failure are tested against the fake Ghidra process, where all-or-nothing follows from the client stopping the Program without a save. Cancellation inside the Java transaction on real Ghidra was not exercised.
    • Any diagnostic Ghidra's parser records while still reporting success, such as a repeated enumerator it drops, is refused with Ghidra's message. Parsing runs inside each edit's own transaction, because the parser fills an existing empty composite of the same name in place (for example a DWARF placeholder), so a refused edit leaves the program unchanged. const and volatile are accepted and not recorded, because Ghidra cannot store them; the real verifier asserts the reported dropped_qualifiers positions instead.
    • Parse times were measured on one machine. The maxima bound the shapes measured (declarator chains, array dimensions, nested expressions, member and type counts, nested structs, comma lists, casts, sizeof); another superlinear shape under 8192 units is not excluded.
    • The calling-convention fix was verified on x86-64 ELF (by hand) and arm64 Mach-O (verifier: x0:8, w1:4, return d0:8). Other architectures were not run.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

Covered: malformed input (syntax error, undefined type, over-length, over-nested, dropped constructs), conflict with existing state, atomicity across fields and across definitions, readback mismatch, snapshot invalidation on refused dispatch, read-only authority, persistence across processes, cancellation of an active edit, and a failed closing checkpoint with retry (the last two against the fake Ghidra process). Not covered: cancellation inside the bridge transaction on real Ghidra.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Node v24.22.1, Ghidra 12.2, macOS arm64. On the current head (71ac4c9f6b), targeted runs only:

  • npm run check:fast — typecheck and lint succeeded (including fixed-ceilings.mjs); architecture guards passed across 3239 source files.
  • npm run docs:check — readmeConsistency 8 passed.
  • npm run verify:advertised-schemas -- --update-summary — annotate_native_function and define_native_data_types input summaries refreshed.
  • npx oxfmt --check . — all matched files use the correct format.
  • Bridge compiled with javac against the Ghidra 12.2 jars, with no errors.
  • npm run test:local -- src/ghidra/GhidraLaunchFailure.test.ts src/ghidra/GhidraClientWire.test.ts src/ghidra/GhidraSessionError.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/ghidra/GhidraSnapshotCache.test.ts src/ghidra/GhidraSessionValues.test.ts src/domain/analysisRefusal.test.ts — 7 files, 418 passed.
  • npm run test:local -- src/config.test.ts src/contracts/toolEffects.test.ts tests/evaluation/numericLimitCheck.test.ts src/doctorRuntime.test.ts — 4 files, 174 passed, 1 skipped.
  • npm run test:focused -- tests/boundary/mcp/ghidraTypeEditsMcp.test.ts tests/boundary/mcp/ghidraEvidenceMcp.test.ts tests/boundary/mcp/officialArguments.test.ts tests/boundary/mcp/ghidraFailureDiagnostics.test.ts tests/boundary/providers/ghidra/ghidraJavaLaunch.test.ts tests/boundary/providers/ghidra/ghidraCheckpointLifecycle.test.ts — 6 files, 98 passed.
  • npm run test:focused -- tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/providers/ghidra/ghidraClient.test.ts tests/boundary/providers/ghidra/fakeGhidraReplyContracts.test.ts tests/boundary/providers/ghidra/ghidraLauncher.test.ts tests/boundary/cli/cliContractSchemaParity.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts — 7 files, 1252 passed, 3 skipped.
  • node scripts/verify-real-ghidra-type-edits.mjs — verified; all nine phases verified; process lineage cleanup verified.
  • By hand over MCP on a debug x86-64 ELF, earlier head: the ambiguous-name cases above.

On the first commit only, not repeated: the broad source run (406 files, 7614 passed), 80 boundary files (2458 passed) and 4 acceptance files (108 passed).

Compatibility, safety, and release

  • Breaking changes or migration steps: these are schema changes to two existing result contracts: annotate_native_function results gain three required fields (annotations.signature, signature_source, calling_convention) and inspect_native_data_type.source gains the value caller-defined. Under the convention in docs/development/releasing.md, a change is marked breaking when a previously valid call or configuration fails or changes meaning. No previously valid call or configuration does: the new input is optional, the new tool is additive, and existing calls return the same facts plus new ones. The title and commits are therefore not marked !. A consumer that validates these results against a closed copy of the old schema must accept the new fields and value. In-repo holders of the old shape were checked by searching for the result fields: the annotation fixtures listed above were updated, no tracked catalog or recorded fixture holds a copy, docs/error-contract.schema.json and docs/user-visible-errors.csv are unchanged by their generator, and the ignored catalogs are regenerated by the build.
  • Real Hopper/Ghidra, browser, or OS coverage: real Ghidra 12.2 on macOS arm64 as listed. Hopper not involved and not started.
  • Package or release metadata impact: one new verifier script and npm script; the bridge source changes, so the producer sources_sha256 and therefore the analysis profile digest change, as with any bridge edit. Existing owned checkpoints key on that profile.
  • Security, privacy, process, or containment review: caller text is parsed by Ghidra's C parser in the existing bridge JVM. The parser reads no files (every directive except #pragma pack is refused before parsing); StackOverflowError and lexer errors are caught so they cannot end the bridge; the per-call length and nesting bounds above bound its uncancellable work. No network, no new process, no executable-byte writes.

Author readiness

Human owner: @morluto

  • 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.

Author checklist (completed by the PR author before requesting review)

  • 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.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.

annotate_native_function accepts an optional C prototype, applied with
USER_DEFINED source in the same transaction as the name and comments,
verified by readback and rolled back with them on refusal.
define_native_data_types stores caller-authored struct, union, enum and
typedef definitions atomically under /rea_caller_defined and refuses
existing names. inspect_native_data_type reports those types with source
caller-defined, and annotation readback reports the applied prototype
and its source.

Refs #14831
@morluto

morluto commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Maintainer scope decision recorded for #14831: approved. Setting a function signature through annotate_native_function and defining caller types through define_native_data_types are accepted as analysis-metadata edits under the existing Ghidra mutation authority (never executable bytes; unavailable on Windows P0 and caller-selected projects). Local-variable retyping stays a follow-up.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The reviewed update appears safe to merge; no new actionable issue was found.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed update appears safe to merge; no new actionable issue was found.

Summary

The PR adds caller-defined C types and function signatures to Ghidra. This update fixes the verifier’s outdated expectation for a refused replacement of an empty DWARF type.

  • Ghidra functions can use caller-supplied C prototypes.
  • Ghidra can store caller-defined C types for later analysis.
  • Ghidra reports when caller C text exceeds its limits or supported forms.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Caller submits signature or type definitions] --> B[Begin database transaction]
  B --> C[Check text and parse C]
  C --> D{Edit kind}
  D -->|Signature| E[Apply prototype]
  D -->|Types| F[Check conflicts and store types]
  E --> G[Check readback]
  F --> G
  G --> H[Commit]
  C -->|Refusal| I[Roll back]
  E -->|Mismatch| I
  F -->|Conflict| I
  G -->|Mismatch| I
Loading

Reviews (13) · Last reviewed commit: "test(ghidra): assert the empty-composite..." · Reviewed by Greptile

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
…pplied constructs

The lengths of a signature and of type declarations and the nesting depth
of parentheses are launch-only REA_ controls with measured defaults, floors
and maxima, written into the bridge's session descriptor. A refusal names
the control, its effective value, source and range.

The bridge tokenizes caller C before Ghidra's parser sees it and refuses
what that parser accepts without applying: attributes, storage-class
specifiers, variable declarations, directives other than #pragma pack,
literals, function bodies, default arguments, unnamed enums and repeated
member names. A type name that names different types is refused.

When a function has no calling convention and the prototype names none,
the compiler specification's default convention, which Ghidra already uses
to assign the locked storage, is recorded, and annotation readback reports
the convention.

Refs #14831
The bridge appended the semicolon its parser needs before checking the
length, so a prototype of exactly the admitted length was refused. The
readback prototype is documented as reusable only when its function and
type names are C identifiers.

Refs #14831
@morluto

morluto commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Follow-up to the scope approval, in commits 38e4f4ba7c and da6bebd288. The description is updated to match. Real Ghidra was 12.2 on macOS arm64; only targeted tests were run.

What changed, and why

1. Description. The three "pending" statements now say the scope is approved for signature edits and caller-defined data types, with local-variable retyping as a follow-up.

2. The three hardcoded limits are launch-only REA_ controls.

Control Default Floor Maximum Slowest measured parse at the maximum
REA_GHIDRA_SIGNATURE_MAX_UTF16 2048 16 4096 0.8 s
REA_GHIDRA_TYPE_DECLARATIONS_MAX_UTF16 4096 16 8192 6.8 s
REA_GHIDRA_C_MAX_PARENTHESIS_DEPTH 8 1 12 2.2 s (8192 units of 12-level expressions)
  • They are parsed in src/config/environment.ts with the other Ghidra seeds, registered restart-only in numericLimitRegistry.ts, written into the bridge's session descriptor at start, and not in ANALYSIS_SETTINGS, so the tool catalog is unchanged. The numeric-limit guard did not require registering them as runtime settings.
  • Measurements: one chain of pointer declarators is the slowest shape per character and is cubic (0.3 s at 2048 units, 0.8 s at 4096, 6.3–6.8 s at 8192, 24 s at 12288, 100 s at 16384). Nesting doubles per level and repeats per occurrence (8192 units: 0.2 s at depth 8, 0.7 s at 10, 2.2 s at 12).
  • The defaults dropped from 4096/16384 because the old 16384 admitted the 100 s case.
  • A refusal is resource_constraint with details.limit (control_kind: "environment", control, effective value, range, default) and details.reported_limits.source.
  • Tension to note: the registry's header says limits checked on each call belong in ANALYSIS_SETTINGS. These are checked per call but fixed per bridge process.

3. Silently dropped input is refused before parsing. The bridge tokenizes the text once, skipping comments, and names the construct with its line and column.

  • Refused: every attribute spelling, __declspec, _Alignas, __packed, asm labels, __extension__; storage-class and inline specifiers; variable declarations and any non-type statement; directives other than #pragma pack; string and character literals; function body, default argument or second declaration in a signature; unnamed enums; repeated member names.
  • Two of these were stored wrongly rather than dropped: #line moved the type to another category, and char a['b'] became char[0].
  • Applied as written, proven by stored layout in the verifier: #pragma pack with push/pop, bit-fields, flexible and zero-length arrays, enum constant expressions, several typedef declarators, _Noreturn, named calling conventions.
  • packed is refused rather than honored: the message points to #pragma pack, which Ghidra applies and the verifier checks.
  • Decision for review: const and volatile are still accepted and not recorded. Ghidra has no representation for them and they change neither layout nor storage; refusing them would reject the issue's own example prototype. The limitation text and guide say so.
  • A type name in several categories: accepted only when all types of that name are equivalent, otherwise refused with the candidates' paths, because C text cannot pick a category. By hand on a debug ELF, FILE was refused in a signature and as a member with nothing stored, and size_t (two equivalent typedefs) was accepted.
  • While testing this I found the member dependency walk skipped pointees, because Ghidra's pointer type is a built-in class. Fixed.

4. "Unknown calling convention -- yet parameter storage is locked".

  • Cause: a USER_DEFINED prototype locks parameter storage while the function's convention stays unknown. It appears in the same session, not only after restore.
  • The storage was already what the caller asked for: RDI:8, ESI:4, return XMM0_Qa:8, identical with unknown and with __stdcall.
  • Fix: when the function has no convention and the prototype names none, record the compiler specification's default convention, which is the one Ghidra already used to assign that storage. A convention the function already has is kept.
  • annotations.calling_convention reports the result. The verifier asserts the warning is absent in-session and after restore, and checks parameter and return storage through dossier.native_api.

5. The edited assertion in real-ghidra-boundaries.mjs. The full verifier was not run. The assertion is now the exported assertNameAndCommentReadback. A driver sent the section's own request to real Ghidra and passed the reply to it: it passed, and it failed as intended on a caller-authored prototype. The rest of that 900-line section could not be isolated cheaply and remains unexecuted with this change.

6. Lifecycle. Four new cases in ghidraCheckpointLifecycle.test.ts, against the fake Ghidra process over a real socket, for both a signature edit and a type definition:

  • a failed closing checkpoint is reported, leaves the previous checkpoint and the live Program intact, and saves on retry;
  • cancelling an active edit stops the Program without saving, and the next start restores the unchanged checkpoint.

Cancellation inside the Java transaction on real Ghidra was not exercised.

7. Contract changes. annotate_native_function results gain three required fields (the third, calling_convention, comes from item 4) and inspect_native_data_type.source gains caller-defined. No previously valid call or configuration fails or changes meaning, so under docs/development/releasing.md these are schema changes not marked !. A consumer validating against a closed copy of the old result schema must accept them. No tracked catalog or recorded fixture held the old shape beyond the test fixtures I updated; the tracked error schema and CSV are unchanged by their generator.

Automated review findings

  • Comments bypassing the nesting guard: fixed by the tokenizer; the verifier sends the reported ( /*)*/ shape and gets the limit refusal.
  • A prototype of exactly the admitted length was refused because the parser's semicolon was appended before the length check: fixed; the verifier applies a 64-unit prototype under a 64-unit control.
  • Readback prototypes of functions whose names are not C identifiers cannot be replayed: not changed in code. The contract text now says the readback is reusable when its function and type names are C identifiers; substituting a placeholder only for some names would make the field inconsistent.

Commands and results

  • npm run check:fast — typecheck and lint succeeded; architecture guards passed across 3240 files.
  • npm run docs:check — 6 tasks successful, 8 tests passed.
  • npm run verify:test-discovery — 4011 files discovered exactly once.
  • npx oxfmt --check . — clean.
  • node scripts/generate-error-schema.mjs --check, node scripts/generate-package-metadata.mjs --check — no differences.
  • npm run test:local -- src/config/ghidraCParserLimits.test.ts src/config.test.ts src/ghidra/GhidraSnapshotCache.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/ghidra/GhidraSessionValues.test.ts src/contracts/toolEffects.test.ts — 495 passed.
  • npm run test:local -- tests/evaluation/numericLimitCheck.test.ts src/doctorRuntime.test.ts — 71 passed, 1 skipped.
  • npm run test:focused -- eleven files (ghidraTypeEditsMcp, ghidraEvidenceMcp, officialArguments, toolSchemaValidity, ghidraCheckpointLifecycle, ghidraClient, fakeGhidraReplyContracts, ghidraLauncher, cliContractSchemaParity, cliContractCommandParity, cliInputSchemaRequired) — 1292 passed, 3 skipped, before the last commit; ghidraTypeEditsMcp and toolSchemaValidity again on the head — 26 passed.
  • node scripts/verify-real-ghidra-type-edits.mjs on the head — verified, seven phases, cleanup verified.

Still open

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Ghidra's C parser cannot be cancelled, so REA bounds the text it parses.
The three launch-only environment controls left an agent that hit them
with a restart as its only recovery. The two length bounds are now
per-call parameters, signature_max_utf16 on annotate_native_function and
declarations_max_utf16 on define_native_data_types, with the same defaults
and measured maxima. A refusal reports details.limit with
control_kind "parameter" and required_value, the text's length, so the
generated recovery names the value to pass or asks for shorter text. The
text fields no longer carry a schema maximum, so every over-length
refusal is typed. Parenthesis nesting is a fixed ceiling of 8 levels,
registered as a representation bound, because each level doubles parse
time. The session descriptor no longer carries C parser limits, and the
config module, environment entries and restart-only registry rows are
removed.

const and volatile are still applied without effect, because Ghidra's
types have no representation for them. Both edits now return
dropped_qualifiers with each qualifier's line and column, and for a
signature its parameter index, null for the return type, instead of
dropping them silently.
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
@morluto
morluto marked this pull request as ready for review November 27, 2026 08:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 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-27T10:58:03.078585Z 9564757 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71ac4c9f6b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
…r call

The C admission scan tracked lines only at LF and read directives as raw
lines matched by a regular expression, so a CR-only line break shifted
dropped-qualifier positions and a trailing comment on #pragma pack was
refused. One tokenizer now owns caller C positions, comments and literals:
CR, LF and CRLF each end a line as in Ghidra's parser, and directives are
admitted from its tokens, so comments read as whitespace there too. A block
comment that would carry a directive onto another line is refused.

Parenthesis nesting was a fixed ceiling justified by parse time, a resource
limit. It is now the per-call parenthesis_max_depth (default 8, range
1..12) on both type-edit tools. The bridge measures the deepest nesting
over the whole text and sends it, with a text's length, as the wire
failure's required_value, so details.limit reports the bridge's own
measurement instead of the adapter re-reading the request.

The tokenizer also decides whether a prototype is terminated, so the parser
sees the caller's text unchanged: no leading whitespace is stripped, and a
trailing line comment no longer swallows the appended terminator.
…ser diagnostics

Ghidra's C parser writes the type database even with storeDataType false:
a definition whose name matches an existing empty composite fills that
type in place, in the parser's own nested transaction. Both type edits
parsed before opening their transaction, so a refused definition, such as
one conflicting with a DWARF placeholder, left that placeholder filled.
Parsing, validation and storage now share the edit's one transaction, and
parseCallerC refuses to run outside one.

The parser also records diagnostics it cannot apply, such as a repeated
enumerator it drops, and still reports success. Both edits now refuse any
diagnostic with Ghidra's message, before anything is stored.

The real-Ghidra verifier gains a phase with an ELF object whose DWARF
declares an opaque struct, proving a refused definition leaves that empty
composite unchanged, and refuses a repeated enumerator.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fa87573a6

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
…rops

Review kept finding one more construct Ghidra's C parser consumes without
applying, because admission listed spellings piecemeal. The tokenizer now
owns one table, audited against every token and production of Ghidra
12.2's C.jj and checked on Ghidra 12.2, in that grammar's own spellings:

- Refused, because meaning is lost: __ptr32 and __ptr64 (stored as a
  native-width pointer), __near and __far, every attribute, declspec,
  __readableTo, alignas, packed and asm spelling, [[...]] attributes,
  storage and inline specifiers including __forceinline, __pragma and
  _Pragma, _Static_assert, Objective-C @ blocks (Ghidra skips their whole
  text), and backslashes.
- Reported in dropped_qualifiers as pure qualifiers: every const and
  volatile spelling, restrict, __unaligned and __w64.

#pragma pack is admitted only in the operand forms Ghidra applies as
written with a decimal value; (0x1), (010), (show) and (pop, n) were
ignored or read differently, and "# pragma" is a line marker Ghidra
skips. An enum tag that neither the text nor the database defines made
Ghidra invent an empty enum without a diagnostic; declarations now refuse
it as they do an invented struct or union. Identifiers admit $, as C.jj's
do, and the tokenizer reads numbers and [[ as single tokens.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0fda78841

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
… Ghidra evaluates, refuse unmatched pack pops

Recursion: the tokenizer's [[ lookahead re-entered next() for each "[",
and the dependency walk recursed per pointer, array and member level.
Both are iterative now. Ghidra 12.2's own data-type code recurses too:
1024 pointer or array levels resolve, 2048 exhaust the stack inside
addDataType while its database lock is held, leaving the Program unable
to save. Every parsed type's chain through pointers, arrays, typedefs and
members, including existing database types, is now measured iteratively
and refused beyond a fixed 256-level ceiling before Ghidra walks it. An
unexpected StackOverflowError ends the session with a reason instead of
being caught by the parser call, since Ghidra's lock may then be held.

Constant expressions: Ghidra leaves names, casts, sizeof, floating and
binary literals unevaluated and substitutes a default, so
"MASK = FIRST << 4" was stored as 2, and it truncates values outside int.
Enum values, array sizes and bit-field widths are admitted only as integer
literals with arithmetic, shift, comparison, bitwise and logical
operators, checked iteratively with C's rules to stay in int, including
implicit enumerator values; anything else is refused at its position.

Pragma pack: Ghidra ignores a bare (push), a pop with nothing pushed keeps
the current packing, and a plain pop pops past labelled entries. The
tokenizer tracks admitted pushes and admits a pop only when Ghidra's
result matches C's.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8f0d304ad

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
…ent pointer targets, state the type-depth recovery truthfully

Constant expressions: emulating C against Ghidra's own evaluator is an
open-ended class of mismatches (comparisons, unsigned arithmetic such as
~0U >> 1 giving -1, names, casts, truncation). The evaluator is removed.
Enum values, array sizes and bit-field widths are admitted only as one
decimal or hex integer literal within int, optionally negated, without
suffixes; anything else is refused at the first token that leaves that
form, and the refusal says to write the computed value. Implicit
enumerator values are still checked against int.

Dependency walk: Ghidra's generic pointer has a null pointed-to type, and
pushing it onto the ArrayDeque threw. Both the dependency and depth walks
now take children from one cTypeChildren and skip an absent child.

Type depth: the depth is measured over the whole chain before comparing it
with the limit, so the refusal reports the depth it used, and it names
the type from the parser's table rather than walking the type for a name.
The recovery no longer suggests splitting into named types, which cannot
help because depth counts through typedefs and existing types; it says
only fewer nested levels do.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12685eb33b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
…-and-type-edits

# Conflicts:
#	src/ghidra/GhidraSessionErrorProjection.ts
morluto and others added 2 commits November 27, 2026 05:22
…sis_max_depth on signatures only

Under the literal-only rule for constant expressions, every parenthesis in
a define_native_data_types text already ended in a refusal (function
declarators, attributes, casts, sizeof, or a Ghidra diagnostic for a
grouped declarator), so parenthesis_max_depth changed only which refusal
a caller saw. A definition now refuses its first parenthesis at its
position, and the parameter is removed from that tool's schema; it stays
on annotate_native_function, whose prototype has a parameter list.
Ghidra keeps struct tags, enum tags and typedefs in separate maps.
Combining those maps dropped a typedef such as typedef int item when
struct item was also defined, and the call still succeeded. Overlapping
names are stored only when the definitions are equivalent, which keeps
typedef struct s { ... } s as one struct. Any other overlap is refused
with conflicting_type_definitions before the transaction stores anything.

Co-authored-by: morluto <[email protected]>
@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

@greptileai

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70aa45f780

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Ghidra's parser replaces an empty composite during parsing and returns
that same object. A later same-path check would store the fill as
unchanged. Record those empty composites before parsing and refuse if
parsing fills one, so the open transaction restores them. A different
layout of a non-empty caller type still conflicts and leaves the stored
type in place.

Co-authored-by: morluto <[email protected]>
@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

@greptileai

…-and-type-edits

Co-authored-by: morluto <[email protected]>

# Conflicts:
#	bridge/ghidra/ReaGhidraBridge.java
@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

@greptileai

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8df5ba7e0b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
…alues

Ghidra's // skip token requires a line break, so a comment at the end of
declarations or of an already-terminated signature was rejected. A newline
is appended whenever the text ends in a line comment, before any semicolon
added for an unterminated prototype.

Integer.parseInt drops a pack operand outside a Java int and leaves the
previous packing, so #pragma pack(2147483648) stored a natural layout.
Decimal pack operands are admitted only when that parse succeeds.

Co-authored-by: morluto <[email protected]>
@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

@greptileai

Defining a struct over the DWARF placeholder fills that empty composite
during parsing, so the refusal is data_type_conflict before the old
name-conflict message. The verifier checks that code and that the
placeholder still has no fields.

Co-authored-by: morluto <[email protected]>
@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

@greptileai

@morluto
morluto merged commit 3a8a717 into main Nov 27, 2026
58 checks passed
@morluto
morluto deleted the feat/ghidra-signature-and-type-edits branch November 27, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants