Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4d3b7a1
feat(ghidra): admit caller-selected matching dSYM companions
jimpablo Oct 12, 2026
f0eb9c4
fix(targets): partition dSYM identity and match the selected slice
jimpablo Oct 12, 2026
104601e
fix(targets): keep legacy query ids and bound companion admission
jimpablo Oct 12, 2026
c219cb9
fix(targets): bound uuid walking and carry companion provenance
jimpablo Oct 12, 2026
ab3bf42
fix(contracts): budget command spans and partition companions by path
jimpablo Oct 12, 2026
11e1002
fix(ghidra): commit companion identity in the analysis profile
jimpablo Oct 12, 2026
731f243
fix(targets): carry companion identity through split mach-o variants
jimpablo Oct 12, 2026
03f9058
fix(targets): charge traversal reads and bound staged member copies
jimpablo Oct 13, 2026
d3fe4a0
fix(ghidra): document and enforce dSYM admission resource budgets
morluto Oct 13, 2026
dbf8d2c
fix(ghidra): preserve dSYM resource refusals and staging coverage
morluto Oct 13, 2026
dea1571
fix(ghidra): stream dSYM UUID commands through their format owner
morluto Oct 13, 2026
437eb2d
fix(ghidra): retain dSYM input ownership and shared format semantics
morluto Oct 13, 2026
26effd7
fix(ghidra): preserve dSYM companion admission facts
morluto Oct 13, 2026
0ab02a0
fix(ghidra): retain failed source copy owners
morluto Oct 13, 2026
58af2fb
fix(targets): settle merged companion types and heap stub props
jimpablo Oct 14, 2026
7bafafc
fix(macho): retain dSYM admission resources
morluto Oct 13, 2026
71cee08
fix(ghidra): preserve dSYM identity and cleanup failures
morluto Oct 13, 2026
7e7d3d2
fix(targets): settle merged types, heap stub props, and split oversiz…
jimpablo Oct 14, 2026
b735fd3
fix(ghidra): rebase onto main, drop hanging copy helper, restore staging
jimpablo Oct 27, 2026
529d444
fix(targets): settle second rebase: weave dsym admission into new res…
jimpablo Oct 28, 2026
07da6f1
fix(targets): restore upstream code dropped during rebase
jimpablo Oct 28, 2026
1a2fa6a
fix(contracts): omit debug_companion from bare Mach-O summaries
jimpablo Oct 28, 2026
0b4ae16
fix(targets): address companion admission review findings
jimpablo Oct 28, 2026
aa20d1d
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
6b32456
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
4483d21
fix(ghidra): harden dSYM companion admission, staging ownership, and …
jimpablo Nov 5, 2026
a7e17e6
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
d90dcca
fix(ghidra): preserve dSYM cleanup primary causes and reuse Mach-O lo…
jimpablo Nov 5, 2026
8bec33a
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
c50d6f5
fix(ghidra): reject dsym_path in existing-project mode and enforce de…
jimpablo Nov 5, 2026
636d664
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
30e21fa
fix(macho): separate companion EOF truncation from traversal budget a…
jimpablo Nov 5, 2026
97a2e09
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 5, 2026
fbef489
fix(cli): reuse absoluteLocalPathStringSchema for --dsym-path option
jimpablo Nov 5, 2026
f51fb61
fix(macho): clamp initial UUID prefix reads to remaining traversal bu…
jimpablo Nov 5, 2026
2c150cb
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 8, 2026
417b628
fix(dsym): enforce .dSYM bundle directory naming and pin companion di…
jimpablo Nov 8, 2026
0988275
fix(dsym): preserve close cancellation, reject ambiguous FAT slices, …
jimpablo Nov 8, 2026
390918f
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 8, 2026
a0cac2a
fix(dsym): preserve close cancellation during directory and staging c…
jimpablo Nov 8, 2026
a84c8a8
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 8, 2026
6a32f35
fix(dsym): preserve member and directory refusals over final-close ca…
jimpablo Nov 8, 2026
c72fb30
docs(specs): add Mach-O dSYM companion feature specification
jimpablo Nov 8, 2026
dd33451
docs(specs): align module and checkpoint test paths in dsym plan
jimpablo Nov 8, 2026
a6f3b94
docs(specs): match symlink policy and saved-project error contract
jimpablo Nov 8, 2026
ca7d919
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 8, 2026
c50bf0d
fix(dsym): skip checkpoint restaging and harden companion identity
jimpablo Nov 8, 2026
2152709
test(mcp): validate session dsym_path outputs via toolContract
jimpablo Nov 8, 2026
4d3ad8f
fix(dsym): retain both companion and target cleanup owners on dual cl…
jimpablo Nov 8, 2026
57f2edc
fix(dsym): reject duplicate FAT target CPU identities before slice na…
jimpablo Nov 8, 2026
9560a44
fix(dsym): keep post-admission member read faults fatal across close …
jimpablo Nov 9, 2026
9f36e1f
fix(dsym): use tagged member failure union and guard opaque abort rea…
jimpablo Nov 9, 2026
bdd456e
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 10, 2026
616d5dc
chore(dsym): merge upstream/main and remove unused imports
jimpablo Nov 10, 2026
3f8c9ce
chore(dsym): restore upstream files modified by lint-staged during merge
jimpablo Nov 10, 2026
92d9d79
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 11, 2026
b244242
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 15, 2026
ea7612b
fix(contracts): preserve headerless issues alongside dsym_path and ex…
jimpablo Nov 15, 2026
03b3ff8
chore(dsym): restore upstream javascriptStaticAnalysis modified by li…
jimpablo Nov 15, 2026
4d761f9
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 16, 2026
858d124
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 16, 2026
65d40a3
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 17, 2026
b32d1bf
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo Nov 21, 2026
cbddb9d
test(target): verify dsym_path rejection on Hopper and IDA databases
jimpablo Nov 21, 2026
336d28c
fix(ghidra): preserve dSYM parse failures, refusals, and staging owne…
jimpablo Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs(specs): add Mach-O dSYM companion feature specification
  • Loading branch information
jimpablo committed Nov 8, 2026
commit c72fb30bcc2e97bba82ce83b7b6591bef8d3d473
5 changes: 5 additions & 0 deletions docs/specs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ for the specification lifecycle, roadmap granularity and producer-owned contract

- [Organization](documentation/organization/spec.md)
([plan](documentation/organization/plan.md), [tasks](documentation/organization/tasks.md))

## Native

- [Mach-O dSYM companion admission](native/macho-dsym-companion/spec.md)
([plan](native/macho-dsym-companion/plan.md), [tasks](native/macho-dsym-companion/tasks.md))
59 changes: 59 additions & 0 deletions docs/specs/native/macho-dsym-companion/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Implementation plan

## Boundary and contracts

- `src/domain/machoDebugCompanion.ts`: own pure incremental `machoUuidReads`,
thin and universal `readMachoUuidEntries` (delegating container and
load-command framing to `src/domain/apple/machoContainer.ts` and
`src/domain/apple/machoLoadCommands.ts`), and CPU-scoped `(uuid, cpuType,
cpuSubtypeBase)` matching in `matchMachOCompanionEntries`.
- `src/application/DebugCompanionAdmission.ts` and
`src/application/BinaryTargetResolver.ts`: admit the caller-selected bundle at
target resolution before any provider starts. Reuse the resolver's open target
handle, enforce normalized `.dSYM` directory naming, enumerate
`Contents/Resources/DWARF` through `OwnedDirectoryHandle` and
`withRegularFileCompletion`, deduplicate `(dev, ino)` digests, and attach
`MachODebugCompanion` to Mach-O `BinaryTarget` variants or project
`debug_companion_rejected` refusals via `src/domain/targetDiagnostics.ts`.
- `src/contracts/sessionLifecycleInputs.ts`,
`src/contracts/sessionToolContracts.ts`, `src/cli/coreNativeCommands.ts`,
`src/application/DirectAnalysis.ts`, and
`src/application/binary/BinarySessionOpen.ts`: expose optional absolute
`dsym_path` / `--dsym-path` across MCP `open_binary` and one-shot native CLI
commands with contract-level headerless-format pairing rejection.
- `src/ghidra/GhidraDebugCompanion.ts`, `src/ghidra/GhidraClient.ts`,
`src/ghidra/GhidraAnalysisProfile.ts`, and
`src/domain/liveBinaryTargetSummary.ts`: reject `REA_GHIDRA_PROJECT_PATH`
pairing before headless launch, commit `debug_companion` into the Ghidra
analysis profile so saved Program checkpoints stay isolated from bare imports,
stage the verified member beside the private snapshot, and project `dsym`
facts into target-admission evidence.

## Incremental work and validation

1. Add pure Mach-O `LC_UUID` decoding, shared FAT container validation, and
CPU-scoped matching rules with unit coverage in
`src/domain/machoDebugCompanion.test.ts`.
2. Implement bounded `.dSYM` bundle admission, structured refusal diagnostics,
and close-failure/cancellation handle ownership with boundary and
process-global regression suites (`tests/boundary/filesystem/targetDiagnostics.test.ts`,
`tests/process-global/debugCompanionAdmissionFailures.test.ts`).
3. Thread `dsym_path` / `--dsym-path` through MCP and CLI contracts, session
open, and direct analysis; regenerate tool catalog projections.
4. Add private Ghidra staging, `REA_GHIDRA_PROJECT_PATH` refusal,
analysis-profile/checkpoint isolation, and target-admission evidence
(`tests/boundary/filesystem/ghidraDebugCompanion.test.ts`,
`tests/process-global/ghidraDebugCompanionStagingLifetime.test.ts`,
`src/ghidra/GhidraProvider.behavior.test.ts`,
`src/ghidra/GhidraCheckpointStore.test.ts`).
5. Author [provider documentation](../../../providers/dsym.md), register public
navigation and route entries, and run documentation, route, static, and deep
verification checks.

## Effects and compatibility

All new inputs are optional; omitting `dsym_path` preserves existing target
resolution, analysis-profile digests, Program checkpoints, and Evidence shapes.
Staging writes only inside REA's private runtime root (`0600` files, `0700`
directories) and cleans up with the ephemeral session root. Neither the caller's
executable nor `.dSYM` bundle is modified or executed.
83 changes: 83 additions & 0 deletions docs/specs/native/macho-dsym-companion/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Mach-O dSYM companion admission

Issue: https://github.com/morluto/rea/issues/1193

## Problem and outcome

REA imports an immutable private executable snapshot into its ephemeral Ghidra
project, so an adjacent `.dSYM` bundle beside the caller's original Mach-O
executable is never visible to Ghidra's `DSymSectionProvider`. Stripped or
linked Mach-O binaries consequently lose DWARF parameter names, structured data
types, and source-anchored type paths unless the analyst manually prepares an
external Ghidra project.

Admit an explicitly caller-selected `.dSYM` bundle (`dsym_path` on MCP
`open_binary`, `--dsym-path` on native CLI commands), prove before provider
startup that a bundle member's `LC_UUID` and CPU identity match the selected
Mach-O target image, stage only the verified DWARF member beside the private
Ghidra snapshot, and record companion provenance in target-admission evidence
and the committed Ghidra analysis profile.

## Requirements

- **Explicit caller selection**: accept optional absolute `dsym_path` /
`--dsym-path`; never infer or auto-discover adjacent `.dSYM` bundles.
Omitting `dsym_path` preserves existing executable-only behavior.
- **Bundle shape and target applicability**: the resolved path must name a
`.dSYM` bundle directory (`*.dSYM`, including trailing `/` or `/.`) containing
regular-file DWARF members under `Contents/Resources/DWARF`, opened without
following symlinks on bundle components or members where the host supports
`O_NOFOLLOW`. Pairings with headerless formats (`raw-binary`, `dos-com`),
Comment thread
jimpablo marked this conversation as resolved.
Resolved
non-Mach-O targets, or pre-imported `REA_GHIDRA_PROJECT_PATH` sessions
(`-process -noanalysis`) fail closed as caller input (`invalid_request` /
`invalid_input`) with constraint `debug_companion_rejected`.
Comment thread
jimpablo marked this conversation as resolved.
Resolved
- **Mandatory `LC_UUID` and CPU matching**: thin and universal containers
validate Mach-O header/load-command framing and universal slice bounds,
alignment, overlap, and header-versus-table CPU agreement. Placeholder
all-zero UUIDs never match. Reject targets without a usable `LC_UUID`,
universal targets or members with duplicate `(cpuType, cpuSubtypeBase)` slices
(`ambiguous_target_slice` / `ambiguous_member_slice`), bundles with no
matching `(uuid, cpuType, cpuSubtypeBase)` member (`uuid_mismatch`), and
distinct matching members whose SHA-256 digests disagree
(`conflicting_matching_members`).
- **Bounded admission and handle ownership**: examine at most 16 entries in
`Contents/Resources/DWARF`, cap matched member size and cumulative
matching-member digest reads at 1 GiB (deduplicating hard links sharing one
`(dev, ino)` file identity), and bound incremental header/UUID traversal to a
64 KiB read window and 64 MiB total header I/O across target and candidates.
Preserve refusal diagnostics ahead of final-close cancellation, retain failed
handles when descriptor or directory close fails, and honor cancellation
across member reads, staging copies, and cleanup retries.
- **Private staging and provenance**: stage only the matched DWARF member inside
REA's private runtime root at
`<snapshot>.dSYM/Contents/Resources/DWARF/<snapshot>` with `0600` file
permissions (`0700` directories) and post-copy size/SHA-256 verification,
leaving the caller's bundle untouched. Record
`dsym { source_path, member_sha256, uuid, staged_member }` in target-admission
evidence and `debug_companion { source_path, uuid, member_sha256 }` in
`GhidraAnalysisProfile` so companion-selected and bare runs never share an
analysis-profile digest or Program checkpoint.

## Acceptance

- Domain tests cover thin and universal `LC_UUID` decoding, shared FAT container
validation delegation, placeholder zero UUIDs, CPU/subtype matching, and
duplicate-slice ambiguity.
- Boundary and process-global lifecycle tests cover `.dSYM` directory naming,
symlink rejection, entry/size/I/O limits, mismatch and conflict diagnostics,
staging digest verification, analysis-profile and checkpoint isolation, and
close-failure/cancellation invariants across directory, member, and staging
handles.
- Real macOS `clang -g` + `dsymutil` fixtures verify CLI and MCP admission of
matching bundles, caller-input rejection of mismatched bundles, and Ghidra
DWARF recovery of imported signatures and structured types where Ghidra is
available.
- User-facing prerequisites, CLI/MCP usage, and limits are documented in
[Mach-O debug companion analysis with Ghidra](../../../providers/dsym.md).

## Out of scope

Implicit `.dSYM` discovery, DWARF source-file content acquisition, per-slice
companion overrides independent of target architecture selection, staging into
pre-existing `REA_GHIDRA_PROJECT_PATH` projects, Hopper/IDA companion staging,
and non-Mach-O debug companion formats.
7 changes: 7 additions & 0 deletions docs/specs/native/macho-dsym-companion/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tasks

- [x] Define Mach-O `LC_UUID` decoding, shared FAT slice validation, and CPU-scoped companion matching rules (`src/domain/machoDebugCompanion.ts`, `src/domain/machoDebugCompanion.test.ts`).
- [x] Implement bounded `.dSYM` bundle admission, refusal diagnostics, and cancellation/cleanup handle ownership at target resolution (`src/application/DebugCompanionAdmission.ts`, `tests/boundary/filesystem/targetDiagnostics.test.ts`, `tests/process-global/debugCompanionAdmissionFailures.test.ts`).
- [x] Expose optional `dsym_path` / `--dsym-path` across MCP `open_binary` and native CLI commands, and regenerate catalog projections.
- [x] Stage verified DWARF members into private Ghidra runtime roots, isolate `GhidraAnalysisProfile` and Program checkpoints, reject `REA_GHIDRA_PROJECT_PATH` pairing, and record `dsym` admission evidence (`src/ghidra/GhidraDebugCompanion.ts`, `src/ghidra/GhidraAnalysisProfile.ts`, `src/ghidra/GhidraProvider.behavior.test.ts`).
- [x] Author [provider documentation](../../../providers/dsym.md) and pass route, catalog, static, and deep verification gates.
Loading