[PR #5806] [MERGED] fix(apple): keep scalar facts when object-table entries share a record #7074

Closed
opened 2026-11-01 21:45:10 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5806
Author: @Shreyash021104
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @morluto

Base: main ← Head: fix/plist-shared-object-table-entries


📝 Commits (1)

  • 40beec3 fix(apple): keep scalar facts when object-table entries share a record

📊 Changes

4 files changed (+232 additions, -2 deletions)

View changed files

📝 src/artifacts/apple/PlistScalars.test.ts (+121 -0)
📝 src/artifacts/apple/PlistScalars.ts (+4 -1)
📝 tests/boundary/filesystem/keyedArchiveNumberMetadata.test.ts (+55 -1)
📝 tests/fixtures/keyedArchiveWideIntegers.ts (+52 -0)

📄 Description

Summary

Fixes #5805.

Binary plist object tables may list one object offset more than once, and readers decode each entry independently. The scalar scanner treated any repeated offset as incomplete metadata, so the number projection dropped every exact decimal in the archive. A keyed archive whose entries share an Int64 9007199254740993 reported it as observed 9007199254740992 and rounded an unrelated 2^60+3 sibling. Both values are now exact.

Problem and expected behavior

Smallest trigger: two $objects entries whose object-table offsets are equal. Violated invariant: an observed integer is reported either exactly or with a value-specific uncertainty, and a fact about one record must not erase facts about unrelated records.

Change and scope

In scanBinaryPlistScalars, a repeated valid offset is observed once and skipped instead of marking metadata incomplete. Offsets that fail to parse still mark it incomplete. Shared 16-byte integers and dates are rewritten once in the decoder copy, which every sharing entry then reads. The decode plan already collapses a shared offset into one span, so overlap isolation is unchanged.

Not included: no change to overlap handling, date projection, or output contracts.

Follow the contribution scope. Ordinary fix within existing boundaries: maintainer scope decision not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/artifacts/apple/PlistScalars.ts, binary scalar scan before plist.parseBinary.
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing behavior).
  • CLI and MCP/tool-catalog contract: unchanged schemas; affected archives now return exact { "$plist_type": "integer", "decimal" } values instead of rounded numbers.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: exact integer Evidence is restored for archives with shared entries; input bytes stay unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

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

Evidence and regression coverage

  • Tests added or updated:
    • src/artifacts/apple/PlistScalars.test.ts: shared Int64 record; shared 16-byte integer rewritten once; shared sub-millisecond date recorded once; an out-of-range entry still reports metadata incomplete.
    • tests/boundary/filesystem/keyedArchiveNumberMetadata.test.ts: archive reader and compiled CLI with a keyed archive whose entries 10 and 11 share one Int64 record (fixture in tests/fixtures/keyedArchiveWideIntegers.ts, checked against Python plistlib).
  • Base reproduction: on d672cc2, the compiled CLI reports 9007199254740992, 9007199254740992, 1152921504606847000. With this change: exact decimals for all three. Running the new tests against unmodified PlistScalars.ts: 6 fail, including both boundary tests.
  • Differential check: 1,600 generated keyed archives (random Int64/16-byte integers, reals, dates, aliased payloads, shared entries) compared against plistlib. No wrong values. The 8 remaining non-exact large integers each share their rounded double with a real in the same archive, the existing ambiguity rule.
  • Remaining proof gaps: no macOS host, so plutil -lint acceptance of shared entries and the MCP stdio path were not run; Interface Builder shares the scanner but has no dedicated shared-entry test.

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

  • npm run test:focused -- <25 Apple plist, keyed-archive and Interface Builder test files>: 453 passed, 3 skipped.
  • npm run test:focused -- tests/boundary/filesystem/keyedArchiveNumberMetadata.test.ts src/artifacts/apple/PlistScalars.test.ts: 58 passed; 6 fail with the source change reverted.
  • npm run check:fast: typecheck and lint passed.
  • npm run verify:test-discovery: all 1901 test files discovered exactly once.
  • Compiled CLI replay of the issue reproduction on Linux x64, Node 24.18.0.
  • Re-run of all of the above after rebasing onto main 5241597: same results.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Output schemas are unchanged; affected archives now report exact decimals where they previously reported rounded numbers.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (static plist decoding). Linux x64 only; macOS plutil and MCP stdio not run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: reads caller-selected bytes only; no new execution, network, or mutation.

Author readiness

Human owner: @Shreyash021104

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5806 **Author:** [@Shreyash021104](https://github.com/Shreyash021104) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/plist-shared-object-table-entries` --- ### 📝 Commits (1) - [`40beec3`](https://github.com/morluto/rea/commit/40beec34e86fce895649e1718de72643d736bc27) fix(apple): keep scalar facts when object-table entries share a record ### 📊 Changes **4 files changed** (+232 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/artifacts/apple/PlistScalars.test.ts` (+121 -0) 📝 `src/artifacts/apple/PlistScalars.ts` (+4 -1) 📝 `tests/boundary/filesystem/keyedArchiveNumberMetadata.test.ts` (+55 -1) 📝 `tests/fixtures/keyedArchiveWideIntegers.ts` (+52 -0) </details> ### 📄 Description ## Summary Fixes #5805. Binary plist object tables may list one object offset more than once, and readers decode each entry independently. The scalar scanner treated any repeated offset as incomplete metadata, so the number projection dropped every exact decimal in the archive. A keyed archive whose entries share an Int64 `9007199254740993` reported it as observed `9007199254740992` and rounded an unrelated `2^60+3` sibling. Both values are now exact. ## Problem and expected behavior Smallest trigger: two `$objects` entries whose object-table offsets are equal. Violated invariant: an observed integer is reported either exactly or with a value-specific uncertainty, and a fact about one record must not erase facts about unrelated records. ## Change and scope In `scanBinaryPlistScalars`, a repeated valid offset is observed once and skipped instead of marking metadata incomplete. Offsets that fail to parse still mark it incomplete. Shared 16-byte integers and dates are rewritten once in the decoder copy, which every sharing entry then reads. The decode plan already collapses a shared offset into one span, so overlap isolation is unchanged. Not included: no change to overlap handling, date projection, or output contracts. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Ordinary fix within existing boundaries: maintainer scope decision not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/artifacts/apple/PlistScalars.ts`, binary scalar scan before `plist.parseBinary`. - Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing behavior). - CLI and MCP/tool-catalog contract: unchanged schemas; affected archives now return exact `{ "$plist_type": "integer", "decimal" }` values instead of rounded numbers. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: exact integer Evidence is restored for archives with shared entries; input bytes stay unchanged. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none. Expected effects: - [x] 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. ## Evidence and regression coverage - Tests added or updated: - `src/artifacts/apple/PlistScalars.test.ts`: shared Int64 record; shared 16-byte integer rewritten once; shared sub-millisecond date recorded once; an out-of-range entry still reports metadata incomplete. - `tests/boundary/filesystem/keyedArchiveNumberMetadata.test.ts`: archive reader and compiled CLI with a keyed archive whose entries 10 and 11 share one Int64 record (fixture in `tests/fixtures/keyedArchiveWideIntegers.ts`, checked against Python `plistlib`). - Base reproduction: on `d672cc2`, the compiled CLI reports `9007199254740992`, `9007199254740992`, `1152921504606847000`. With this change: exact decimals for all three. Running the new tests against unmodified `PlistScalars.ts`: 6 fail, including both boundary tests. - Differential check: 1,600 generated keyed archives (random Int64/16-byte integers, reals, dates, aliased payloads, shared entries) compared against `plistlib`. No wrong values. The 8 remaining non-exact large integers each share their rounded double with a real in the same archive, the existing ambiguity rule. - Remaining proof gaps: no macOS host, so `plutil -lint` acceptance of shared entries and the MCP stdio path were not run; Interface Builder shares the scanner but has no dedicated shared-entry test. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:focused -- <25 Apple plist, keyed-archive and Interface Builder test files>`: 453 passed, 3 skipped. - `npm run test:focused -- tests/boundary/filesystem/keyedArchiveNumberMetadata.test.ts src/artifacts/apple/PlistScalars.test.ts`: 58 passed; 6 fail with the source change reverted. - `npm run check:fast`: typecheck and lint passed. - `npm run verify:test-discovery`: all 1901 test files discovered exactly once. - Compiled CLI replay of the issue reproduction on Linux x64, Node 24.18.0. - Re-run of all of the above after rebasing onto `main` `5241597`: same results. ## Compatibility, safety, and release - Breaking changes or migration steps: none. Output schemas are unchanged; affected archives now report exact decimals where they previously reported rounded numbers. - Real Hopper/Ghidra, browser, or OS coverage: not applicable (static plist decoding). Linux x64 only; macOS `plutil` and MCP stdio not run. - Package or release metadata impact: none. - Security, privacy, process, or containment review: reads caller-selected bytes only; no new execution, network, or mutation. ## Author readiness Human owner: @Shreyash021104 - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:45:10 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7074
No description provided.