[PR #4839] [MERGED] fix(plist): keep negative-zero reals distinct from positive zero #6437

Closed
opened 2026-10-31 01:14:27 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4839
Author: @pablodiazjorge
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @morluto

Base: main ← Head: fix/plist-negative-zero-real


📝 Commits (2)

  • d16dfaf fix(plist): keep negative-zero reals distinct from positive zero
  • e3292a6 Merge upstream main into fix/plist-negative-zero-real

📊 Changes

10 files changed (+218 additions, -10 deletions)

View changed files

📝 docs/native-investigation.md (+6 -0)
📝 src/artifacts/apple/KeyedArchiveReader.ts (+13 -5)
📝 src/domain/apple/keyedArchive.ts (+1 -0)
📝 src/domain/apple/plistValue.test.ts (+23 -0)
📝 src/domain/apple/plistValue.ts (+26 -2)
📝 src/domain/propertyListXml.test.ts (+15 -0)
📝 src/domain/propertyListXml.ts (+3 -1)
📝 src/native/parsers/plist.test.ts (+25 -0)
📝 src/native/parsers/plist.ts (+19 -2)
📝 tests/acceptance/applications/keyedArchiveScalarKinds.test.ts (+87 -0)

📄 Description

Summary

Fixes #4834. Plist inspection reported a serialized negative-zero real as the JSON number 0 with status observed, the same as positive zero, and no limitation disclosed the lost sign. The shared plist projection now reports it as { "$plist_type": "real", "value": "-0" } with a counted limitation; positive zero and integer zero stay 0.

Thanks to @xu91102 for the precise report and for locating the projection boundary.

Problem and expected behavior

projectPlistValue passed finite numbers through unchanged. A -0 decoded from <real>-0.0</real>, or from a binary float64 0x8000000000000000, reached JSON serialization, which writes 0. A serialized IEEE value must not be reported as a different observed value.

Change and scope

  • projectPlistValue, which owns the JSON-safe plist scalar representation, wraps -0 as { "$plist_type": "real", "value": "-0" }, reports it through the existing generated-wrapper callback (so keyed archive objects stay scalar, and a lookalike dictionary stays dictionary), and counts it. The spelling follows the existing { "$plist_type": "real", "value": null } unknown real and the "-0" that SQLite inspection already uses for reals.
  • inspect_keyed_archive and the inspect_plist XML fallback add the count as a limitation through one shared helper. Interface Builder node attributes get the same value from the shared projection; as with non-finite reals there, no separate limitation.
  • The inspect_plist JSON path never runs the shared projection, so its JSON reviver applies the same wrapper and limitation when plutil JSON holds -0. A plist integer has no signed zero.
  • The XML decoder's fallback for mixed integer content (Number.parseInt) returned -0 for <integer>-0<!-- c --></integer>; it now returns 0, so the projection's rule that -0 is a real holds for every decoder. Exact integer literals already decode through BigInt, which has no signed zero.
  • Behavior note: a negative-zero real in a CF$UID position is a real, not a UID. Like a non-finite real there, it is now projected as a typed value inside an ordinary dictionary rather than read as a reference to object 0.
  • Scope: an ordinary fix within the existing read-only plist boundary; a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: projectPlistValue in src/domain/apple/plistValue.ts, before consumers classify the JSON tree; the plutil JSON decode boundary in src/native/parsers/plist.ts.
  • Contribution scope fit and linked maintainer decision: existing boundary; not applicable.
  • CLI and MCP/tool-catalog contract: only negative-zero real values change, from the number 0 to the typed object above, with one new limitation line. Result schemas already carry JSON values; no catalog change.
  • Provider, bridge, target-format, or platform compatibility: none; decoding only.
  • Evidence, artifact, provenance, or reconstruction contract: reported values now match the serialized bytes; archive digests and input files are 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:
    • tests/acceptance/applications/keyedArchiveScalarKinds.test.ts: XML and binary keyed archives with -0.0, 0.0 and 1.25 reals through the public CLI and MCP (equal results), checking the wrapper, scalar/observed, positive zero, the serialized JSON and the limitation.
    • src/domain/apple/plistValue.test.ts: projection and count; only the generated wrapper reaches the callback.
    • src/native/parsers/plist.test.ts: the inspect_plist JSON and XML parsers with -0.0, -0, 0.0, <integer>-0</integer> and 1.25; no limitation for positive zero.
    • src/domain/propertyListXml.test.ts: a signed integer zero, exact or with mixed content, decodes as 0; the real keeps its sign.
  • Base reproduction: the same tests on unpatched main 63c65a224: both new acceptance cases and the new projection, parser and XML decoder tests fail (the existing date test also fails there, only because of the new count field). All pass with the change.
  • User-visible CLI output: the issue's XML fixture through the compiled source CLI, inspect-keyed-archive <file> --json, object 1:
    • before: {"id":1,"kind":"scalar","status":"observed","value":0} (other fields omitted), no limitation;
    • after: "value":{"$plist_type":"real","value":"-0"}, kind scalar, status observed, plus 1 negative-zero real value(s) are reported as { "$plist_type": "real", "value": "-0" } because a JSON number cannot carry the sign of zero.
    • The binary form of the same archive gives the same results; the 0.0 and 1.25 controls are unchanged before and after.
  • Remaining proof gaps:
    • The macOS plutil path of inspect_plist was not run (no macOS host); its darwin-only CLI tests skip here. Whether plutil -convert json writes -0 for a negative-zero real is unverified, so the JSON parser is covered with literal JSON input.
    • No Foundation-generated archive (that needs macOS); the binary fixtures are plist@5 output with a patched float64.
    • Interface Builder was not exercised with a negative-zero attribute.
    • npm run docs:check was not run; it needs the built runtime, which build:cached cannot produce on this host without the 6.5.0 Windows native artifact.

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

Windows 11 Pro 10.0.26300, Node 24.18.0, on main 63c65a224:

  • npx vitest run src/domain/apple/plistValue.test.ts src/domain/propertyListXml.test.ts src/native/parsers/plist.test.ts tests/acceptance/applications/keyedArchiveScalarKinds.test.ts: 4 files, 37 tests passed.
  • npx vitest run on the 40 tracked files matching src/domain/apple/*.test.ts, src/artifacts/apple/*.test.ts, src/domain/propertyList*.test.ts, src/native/parsers/plist*.test.ts, tests/boundary/filesystem/keyedArchive*.test.ts, tests/boundary/filesystem/nativeArtifactGoldens.test.ts, tests/acceptance/applications/keyedArchive*.test.ts, tests/**/*nterfaceBuilder*.test.ts and tests/**/*[Pp]list*.test.ts: 489 passed, 52 skipped (macOS-only), 2 failed. Both failures are AppleAssetCatalogAnalysis.test.ts cases that cannot create symlinks on Windows without developer mode (EPERM); they fail the same way on unpatched main.
  • npm run check:fast: typecheck and lint pass.
  • npx oxfmt --check on the changed files: pass.
  • npm run compile, then the CLI runs above with and without the change. npm run build:cached needs the 6.5.0 Windows native artifact, which this host does not have.

Compatibility, safety, and release

  • Breaking changes or migration steps: none intended. A consumer reading these values as numbers sees a typed object only for negative-zero reals, as it already does for non-finite reals.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable to the change; Windows only, the macOS plutil path was not run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; read-only decoding of caller-selected files.

Author readiness

Human owner: @pablodiazjorge

  • 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/4839 **Author:** [@pablodiazjorge](https://github.com/pablodiazjorge) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/plist-negative-zero-real` --- ### 📝 Commits (2) - [`d16dfaf`](https://github.com/morluto/rea/commit/d16dfaff7347fb132b9fcff5df271a77bd8c65b2) fix(plist): keep negative-zero reals distinct from positive zero - [`e3292a6`](https://github.com/morluto/rea/commit/e3292a68c79ce4f3510a0f23519d7dd6da2033c7) Merge upstream main into fix/plist-negative-zero-real ### 📊 Changes **10 files changed** (+218 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `docs/native-investigation.md` (+6 -0) 📝 `src/artifacts/apple/KeyedArchiveReader.ts` (+13 -5) 📝 `src/domain/apple/keyedArchive.ts` (+1 -0) 📝 `src/domain/apple/plistValue.test.ts` (+23 -0) 📝 `src/domain/apple/plistValue.ts` (+26 -2) 📝 `src/domain/propertyListXml.test.ts` (+15 -0) 📝 `src/domain/propertyListXml.ts` (+3 -1) 📝 `src/native/parsers/plist.test.ts` (+25 -0) 📝 `src/native/parsers/plist.ts` (+19 -2) 📝 `tests/acceptance/applications/keyedArchiveScalarKinds.test.ts` (+87 -0) </details> ### 📄 Description ## Summary Fixes #4834. Plist inspection reported a serialized negative-zero real as the JSON number `0` with status `observed`, the same as positive zero, and no limitation disclosed the lost sign. The shared plist projection now reports it as `{ "$plist_type": "real", "value": "-0" }` with a counted limitation; positive zero and integer zero stay `0`. Thanks to @xu91102 for the precise report and for locating the projection boundary. ## Problem and expected behavior `projectPlistValue` passed finite numbers through unchanged. A `-0` decoded from `<real>-0.0</real>`, or from a binary float64 `0x8000000000000000`, reached JSON serialization, which writes `0`. A serialized IEEE value must not be reported as a different observed value. ## Change and scope - `projectPlistValue`, which owns the JSON-safe plist scalar representation, wraps `-0` as `{ "$plist_type": "real", "value": "-0" }`, reports it through the existing generated-wrapper callback (so keyed archive objects stay `scalar`, and a lookalike dictionary stays `dictionary`), and counts it. The spelling follows the existing `{ "$plist_type": "real", "value": null }` unknown real and the `"-0"` that SQLite inspection already uses for reals. - `inspect_keyed_archive` and the `inspect_plist` XML fallback add the count as a limitation through one shared helper. Interface Builder node attributes get the same value from the shared projection; as with non-finite reals there, no separate limitation. - The `inspect_plist` JSON path never runs the shared projection, so its JSON reviver applies the same wrapper and limitation when plutil JSON holds `-0`. A plist integer has no signed zero. - The XML decoder's fallback for mixed integer content (`Number.parseInt`) returned `-0` for `<integer>-0<!-- c --></integer>`; it now returns `0`, so the projection's rule that `-0` is a real holds for every decoder. Exact integer literals already decode through BigInt, which has no signed zero. - Behavior note: a negative-zero real in a `CF$UID` position is a real, not a UID. Like a non-finite real there, it is now projected as a typed value inside an ordinary dictionary rather than read as a reference to object 0. - Scope: an ordinary fix within the existing read-only plist boundary; a maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: `projectPlistValue` in `src/domain/apple/plistValue.ts`, before consumers classify the JSON tree; the plutil JSON decode boundary in `src/native/parsers/plist.ts`. - Contribution scope fit and linked maintainer decision: existing boundary; not applicable. - CLI and MCP/tool-catalog contract: only negative-zero real values change, from the number `0` to the typed object above, with one new limitation line. Result schemas already carry JSON values; no catalog change. - Provider, bridge, target-format, or platform compatibility: none; decoding only. - Evidence, artifact, provenance, or reconstruction contract: reported values now match the serialized bytes; archive digests and input files are 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: - `tests/acceptance/applications/keyedArchiveScalarKinds.test.ts`: XML and binary keyed archives with `-0.0`, `0.0` and `1.25` reals through the public CLI and MCP (equal results), checking the wrapper, `scalar`/`observed`, positive zero, the serialized JSON and the limitation. - `src/domain/apple/plistValue.test.ts`: projection and count; only the generated wrapper reaches the callback. - `src/native/parsers/plist.test.ts`: the `inspect_plist` JSON and XML parsers with `-0.0`, `-0`, `0.0`, `<integer>-0</integer>` and `1.25`; no limitation for positive zero. - `src/domain/propertyListXml.test.ts`: a signed integer zero, exact or with mixed content, decodes as `0`; the real keeps its sign. - Base reproduction: the same tests on unpatched main `63c65a224`: both new acceptance cases and the new projection, parser and XML decoder tests fail (the existing date test also fails there, only because of the new count field). All pass with the change. - User-visible CLI output: the issue's XML fixture through the compiled source CLI, `inspect-keyed-archive <file> --json`, object 1: - before: `{"id":1,"kind":"scalar","status":"observed","value":0}` (other fields omitted), no limitation; - after: `"value":{"$plist_type":"real","value":"-0"}`, `kind` `scalar`, `status` `observed`, plus `1 negative-zero real value(s) are reported as { "$plist_type": "real", "value": "-0" } because a JSON number cannot carry the sign of zero.` - The binary form of the same archive gives the same results; the `0.0` and `1.25` controls are unchanged before and after. - Remaining proof gaps: - The macOS `plutil` path of `inspect_plist` was not run (no macOS host); its darwin-only CLI tests skip here. Whether `plutil -convert json` writes `-0` for a negative-zero real is unverified, so the JSON parser is covered with literal JSON input. - No Foundation-generated archive (that needs macOS); the binary fixtures are plist@5 output with a patched float64. - Interface Builder was not exercised with a negative-zero attribute. - `npm run docs:check` was not run; it needs the built runtime, which `build:cached` cannot produce on this host without the 6.5.0 Windows native artifact. 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 Windows 11 Pro 10.0.26300, Node 24.18.0, on main `63c65a224`: - `npx vitest run src/domain/apple/plistValue.test.ts src/domain/propertyListXml.test.ts src/native/parsers/plist.test.ts tests/acceptance/applications/keyedArchiveScalarKinds.test.ts`: 4 files, 37 tests passed. - `npx vitest run` on the 40 tracked files matching `src/domain/apple/*.test.ts`, `src/artifacts/apple/*.test.ts`, `src/domain/propertyList*.test.ts`, `src/native/parsers/plist*.test.ts`, `tests/boundary/filesystem/keyedArchive*.test.ts`, `tests/boundary/filesystem/nativeArtifactGoldens.test.ts`, `tests/acceptance/applications/keyedArchive*.test.ts`, `tests/**/*nterfaceBuilder*.test.ts` and `tests/**/*[Pp]list*.test.ts`: 489 passed, 52 skipped (macOS-only), 2 failed. Both failures are `AppleAssetCatalogAnalysis.test.ts` cases that cannot create symlinks on Windows without developer mode (`EPERM`); they fail the same way on unpatched main. - `npm run check:fast`: typecheck and lint pass. - `npx oxfmt --check` on the changed files: pass. - `npm run compile`, then the CLI runs above with and without the change. `npm run build:cached` needs the 6.5.0 Windows native artifact, which this host does not have. ## Compatibility, safety, and release - Breaking changes or migration steps: none intended. A consumer reading these values as numbers sees a typed object only for negative-zero reals, as it already does for non-finite reals. - Real Hopper/Ghidra, browser, or OS coverage: not applicable to the change; Windows only, the macOS `plutil` path was not run. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; read-only decoding of caller-selected files. ## Author readiness Human owner: @pablodiazjorge - [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-10-31 01:14:27 +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#6437
No description provided.