[GH-ISSUE #5783] [Bug] Keyed archives report a truncated integer when object offsets alias its payload #3508

Closed
opened 2026-10-31 00:41:18 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @morluto on GitHub (Oct 21, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/5783

Before submitting

  • I searched open and closed issues and PRs for a related report.
  • The reproduction contains only generated public fixture bytes.

Area

Evidence, artifacts, or reconstruction

Observed behavior

inspect-keyed-archive reports a source integer 242016218615821083930112 as scalar value: 13119, status: "observed", when a valid date object-table entry points inside its 16-byte payload. Its only numeric caveat is a generic incomplete-metadata limitation. Compiled CLI and named, SDK-validated stdio MCP agree.

The paired ordinary archive returns the full exact decimal. Both files pass this host's plutil -lint, and Python reads the same full integer from both. The alias changes an object-table offset, not the integer payload. This is a distinct overlap case left after #4292/#4324; #4422 concerns the ordinary case.

Reproduction

From a built source checkout with locked dependencies, generate the controls:

work_dir="$(mktemp -d)"
python3 -I - "$work_dir" <<'PY_FIXTURE'
import datetime, pathlib, plistlib, struct, sys
root=pathlib.Path(sys.argv[1]);root.mkdir(parents=True,exist_ok=True)
payload=bytes(6)+b'\x33'+struct.pack('>d',.1005)+b'\x00'
value=int.from_bytes(payload,'big',signed=True)
source=plistlib.dumps({'$archiver':'NSKeyedArchiver','$version':100000,'$top':{'root':plistlib.UID(1)},'$objects':['$null',(1<<64)-1,datetime.datetime(2001,1,1,0,0,0,100500)]},fmt=plistlib.FMT_BINARY)
t=len(source)-32;width=source[t+6];count=int.from_bytes(source[t+8:t+16],'big');table=int.from_bytes(source[t+24:t+32],'big')
offsets=[int.from_bytes(source[table+i*width:table+(i+1)*width],'big')for i in range(count)]
integer=next(o for o in offsets if source[o:o+17]==b'\x14'+((1<<64)-1).to_bytes(16,'big'))
date_id=next(i for i,o in enumerate(offsets)if source[o:o+9]==b'\x33'+struct.pack('>d',.1005))
for alias in [False,True]:
 b=bytearray(source)
 b[integer+1:integer+17]=payload
 if alias:b[table+date_id*width:table+(date_id+1)*width]=(integer+7).to_bytes(width,'big')
 p=root/('alias.plist'if alias else'ordinary.plist');p.write_bytes(b)
 assert plistlib.loads(b)['$objects'][1]==value
 print(p.name,'source integer',value)
PY_FIXTURE
plutil -lint "$work_dir/ordinary.plist" "$work_dir/alias.plist"
node scripts/rea.mjs inspect-keyed-archive "$work_dir/ordinary.plist" --json
node scripts/rea.mjs inspect-keyed-archive "$work_dir/alias.plist" --json

Replayed: ordinary object 1 is { "$plist_type": "integer", "decimal": "242016218615821083930112" }; aliased object 1 is 13119 and remains observed. Both exit 0. Python assertions and lint pass. All input bytes/hashes remain unchanged.

Expected behavior

Preserve the source integer and sibling facts across a valid object-table alias, or explicitly mark an unrepresentable value unknown/inexact. Do not label a high-word fragment as the observed integer. Retain exactness for the ordinary control.

Impact and scope

Incorrect numerical Evidence from this demonstrated static keyed archive. Real-world frequency is NOT_ENOUGH_INFO. This report concerns integer projection; the date precision loss is separately tracked in #5770. No target execution, file mutation, or runtime-native linking was performed.

REA version

6.7.0; compiled baseline 3b67b362aa2cd79eac5af57d0965e81a7d0b8c2b. Relevant scalar scanner/reader source was compared with current main; the runtime replay is at the stated baseline, not a rebuilt current main.

Runtime and platform

Node.js v24.18.0; macOS 26.3; arm64. System plutil; Python 3.14 standard-library reader.

Target and artifact context

Generated binary NSKeyedArchiver dictionaries with real UID records and paired ordinary/aliased object tables.

Interface

CLI and MCP

Earliest failure stage

Native analysis or reconstruction

Relevant output or evidence

The same public request (open_binary on each generated archive, then inspect_keyed_archive {}) returns exact decimal for the ordinary file and observed 13119 for the alias. Named advertised output schemas were validated by the SDK. Source-derived cause: the numeric metadata scanner excludes overlapped records; the pinned binary decoder reads the first eight bytes of a 16-byte integer. That matches the observed fragment. A generic precision caveat does not identify this source integer as truncated.

Originally created by @morluto on GitHub (Oct 21, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/5783 ### Before submitting - [x] I searched open and closed issues and PRs for a related report. - [x] The reproduction contains only generated public fixture bytes. ### Area Evidence, artifacts, or reconstruction ### Observed behavior `inspect-keyed-archive` reports a source integer `242016218615821083930112` as scalar `value: 13119`, `status: "observed"`, when a valid date object-table entry points inside its 16-byte payload. Its only numeric caveat is a generic incomplete-metadata limitation. Compiled CLI and named, SDK-validated stdio MCP agree. The paired ordinary archive returns the full exact decimal. Both files pass this host's `plutil -lint`, and Python reads the same full integer from both. The alias changes an object-table offset, not the integer payload. This is a distinct overlap case left after #4292/#4324; #4422 concerns the ordinary case. ### Reproduction From a built source checkout with locked dependencies, generate the controls: ```sh work_dir="$(mktemp -d)" python3 -I - "$work_dir" <<'PY_FIXTURE' import datetime, pathlib, plistlib, struct, sys root=pathlib.Path(sys.argv[1]);root.mkdir(parents=True,exist_ok=True) payload=bytes(6)+b'\x33'+struct.pack('>d',.1005)+b'\x00' value=int.from_bytes(payload,'big',signed=True) source=plistlib.dumps({'$archiver':'NSKeyedArchiver','$version':100000,'$top':{'root':plistlib.UID(1)},'$objects':['$null',(1<<64)-1,datetime.datetime(2001,1,1,0,0,0,100500)]},fmt=plistlib.FMT_BINARY) t=len(source)-32;width=source[t+6];count=int.from_bytes(source[t+8:t+16],'big');table=int.from_bytes(source[t+24:t+32],'big') offsets=[int.from_bytes(source[table+i*width:table+(i+1)*width],'big')for i in range(count)] integer=next(o for o in offsets if source[o:o+17]==b'\x14'+((1<<64)-1).to_bytes(16,'big')) date_id=next(i for i,o in enumerate(offsets)if source[o:o+9]==b'\x33'+struct.pack('>d',.1005)) for alias in [False,True]: b=bytearray(source) b[integer+1:integer+17]=payload if alias:b[table+date_id*width:table+(date_id+1)*width]=(integer+7).to_bytes(width,'big') p=root/('alias.plist'if alias else'ordinary.plist');p.write_bytes(b) assert plistlib.loads(b)['$objects'][1]==value print(p.name,'source integer',value) PY_FIXTURE plutil -lint "$work_dir/ordinary.plist" "$work_dir/alias.plist" node scripts/rea.mjs inspect-keyed-archive "$work_dir/ordinary.plist" --json node scripts/rea.mjs inspect-keyed-archive "$work_dir/alias.plist" --json ``` Replayed: ordinary object 1 is `{ "$plist_type": "integer", "decimal": "242016218615821083930112" }`; aliased object 1 is `13119` and remains `observed`. Both exit 0. Python assertions and lint pass. All input bytes/hashes remain unchanged. ### Expected behavior Preserve the source integer and sibling facts across a valid object-table alias, or explicitly mark an unrepresentable value unknown/inexact. Do not label a high-word fragment as the observed integer. Retain exactness for the ordinary control. ### Impact and scope Incorrect numerical Evidence from this demonstrated static keyed archive. Real-world frequency is `NOT_ENOUGH_INFO`. This report concerns integer projection; the date precision loss is separately tracked in #5770. No target execution, file mutation, or runtime-native linking was performed. ### REA version 6.7.0; compiled baseline `3b67b362aa2cd79eac5af57d0965e81a7d0b8c2b`. Relevant scalar scanner/reader source was compared with current main; the runtime replay is at the stated baseline, not a rebuilt current main. ### Runtime and platform Node.js v24.18.0; macOS 26.3; arm64. System `plutil`; Python 3.14 standard-library reader. ### Target and artifact context Generated binary `NSKeyedArchiver` dictionaries with real UID records and paired ordinary/aliased object tables. ### Interface CLI and MCP ### Earliest failure stage Native analysis or reconstruction ### Relevant output or evidence The same public request (`open_binary` on each generated archive, then `inspect_keyed_archive {}`) returns exact decimal for the ordinary file and observed `13119` for the alias. Named advertised output schemas were validated by the SDK. Source-derived cause: the numeric metadata scanner excludes overlapped records; the pinned binary decoder reads the first eight bytes of a 16-byte integer. That matches the observed fragment. A generic precision caveat does not identify this source integer as truncated.
bsakaguchi 2026-10-31 00:41:18 +00:00
  • closed this issue
  • added the
    bug
    triage
    labels
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#3508
No description provided.