Skip to content

fix(native): report every slice of a signed universal Mach-O signature - #4359

Closed
Ambar-13 wants to merge 15 commits into
morluto:mainfrom
Ambar-13:fix/signature-universal-slices
Closed

Ambar-13 wants to merge 15 commits into
morluto:mainfrom
Ambar-13:fix/signature-universal-slices

Conversation

@Ambar-13

@Ambar-13 Ambar-13 commented Oct 16, 2026 •

Copy link
Copy Markdown

Summary

Fixes #4293.

On a universal Mach-O where every slice is signed, inspect_signature returned the identity of one slice and said nothing about the others. Now the fields describe the requested architecture (main's -a binding, since the 2026-10-24 merge below), and the result lists the other slices and their CDHashes, says which slices are signed differently and how, and explains why designated_requirement can list CDHashes that cdhashes doesn't. No schema change; the new facts are limitations plus per-slice provenance entries.

Problem and expected behavior

Build a two-slice file where the arm64 slice is ad hoc signed as com.example.armslice with the hardened runtime and disable-library-validation, and the x86_64 slice as com.example.x86slice with no hardened runtime and get-task-allow (commands in tests/fixtures/native-macos/codesign-universal-signed/README.md). On main, rea inspect-signature fixture --json reports com.example.armslice, one CDHash, hardened_runtime: true and only disable-library-validation, with no mention of slices, while designated_requirement lists both CDHashes.

Each slice of a universal binary carries its own signature (Apple TN3126), and codesign -d without -a describes one slice. Presenting one slice's facts as the file's facts gets the x86_64 slice exactly wrong on the two facts that decide whether it can be debugged.

Change and scope

src/native/NativeMacOSProvider.ts: when the aggregate display reports a signed Mach-O universal (…) with more than one slice, run codesign -d -a <slice> --verbose=4 for each slice (before, this only happened once an aggregate query had already hit an unsigned slice). Parse each signed slice with the existing parseCodeSignature. A slice whose CDHash differs from the aggregate is also asked for its entitlements, since they're sealed per code directory. Unsigned slices keep the Unsigned Mach-O slices: … limitation. Slice names come from codesign's own Format= line with no allow-list, so arm64e.x1 on macOS 27 is queried too.

src/native/signatureSlices.ts (new, pure): finds the described slice by CDHash, lists the others, names the differing fields (identifier, team, authorities, hardened runtime, entitlement keys), and reports CDHashes that appear in the requirement but not in cdhashes. An unmatched default slice is reported as unmatched, not guessed. Empty and absent entitlements compare equal, since codesign prints nothing for either.

docs/native-investigation.md: a paragraph on what the fields describe for universal files.

Not included: a structured per-slice field (agents that want the full record still run codesign -d -a themselves; the limitation tells them which slices and what differs), and the case where codesign's default slice is the unsigned one, which stays signed: false as in #3583.

Overlap with #3583: it also queries every slice and renames #inspectMixedSignatureSlices to #inspectSignatureSlices, but only to report unsigned slices; its own test asserts no limitation when all slices are signed. This PR adds the comparison on top. If #3583 lands first, I'll rebase.

Ordinary fix inside the existing inspect_signature boundary. All added commands are read-only codesign -d runs on the registered snapshot.

Review follow-up (second commit)

Codex and Greptile raised four points; all are in the second commit.

  • Default slice unsigned: codesign's display then says "not signed at all" and nothing queried the other slices. The slices are now queried from the bound target's architecture list, and a limitation names the signed ones with identifier, CDHash and hardened-runtime state. signed stays false for the default slice, as fix(native): check every slice of a signed universal Mach-O #3583 left it. Verified on a real file (arm64 slice unsigned, x86_64 ad hoc signed) on this Mac.
  • Slice entitlements with <data> or <date>: jsonValueSchema rejected them and the exception took the whole result down. parseEntitlements now falls back to the plist projection inspect_plist uses (typed $plist_type objects) with a limitation, and reports an undecodable plist as null instead of throwing. This also hardens the aggregate path, which had the same gap.
  • Omitted __proto__ keys in a slice's entitlements are now reported as Entitlements of the <slice> slice: …, same as the aggregate.
  • Requirement CDHashes are matched against the queried slices: names CDHashes of other slices (x86_64 2696…), and any hash matching no slice is listed separately as unmatched rather than attributed.
  • Also: the two "mixed signing states" limitations now need a signed slice to have been observed, so a fully unsigned universal file no longer calls itself mixed.

Tests added: unit tests for the unmatched-hash case and the unsigned-default description; golden tests for an unsigned default slice with a signed sibling (exact provenance) and for a non-default slice whose entitlements hold a data value and a __proto__ key. Re-ran: the signature test set (111 passed), every native test file (49 files), npm run check, npm run docs:check.

Review follow-up, round two (third commit)

  • Exact slice names for an unsigned default: the bound target names slices by CPU family, which merges arm64, arm64e and arm64e.x1. The unsigned path now asks lipo -archs for the names codesign accepts and falls back to the target's families only if lipo cannot answer. The golden test covers a signed arm64e.x1 sibling behind an unsigned x86_64 default; the real-file run above still works and gains the lipo -archs provenance entry.
  • Unreadable or undecodable slice entitlements are no longer compared. parseEntitlements reports whether it decoded anything; a slice whose plist could not be decoded keeps its entitlements unobserved and is named in Entitlements could not be read for Mach-O slices, so the comparison can no longer say entitlements none for it. The same flag stops slice entitlement queries when the aggregate plist itself did not decode. New golden test with a malformed plist on the non-default slice.
  • Projection notes are carried: non-finite reals, unknown dates and exact-integer notes from the plist projection now reach the result, prefixed with the slice; the plutil framing sentence and the __proto__ count are replaced by the entitlement-specific ones.
  • Round five (seventh commit): each slice's entitlements are compared as soon as they are decoded and only the outcome is kept, so parsed trees from many slices are never live together; entitlement plists holding integers beyond the exact range go through the XML projection so 9007199254740992 and 9007199254740993 compare as different (golden test); long values are cut at 80 characters but carry their length and a SHA-256 prefix so two long values that differ past the cut still read as different (unit test).
  • Sixth commit: entitlement keys are read as own properties when comparing slices, so a key named constructor or toString cannot reach a prototype property and throw inside the rendering; unit test added.
  • Round four (fifth commit): lipo is only consulted for mach-o-universal targets, so unsigned thin files never depend on it; the missing-lipo fallback is narrowed to the exact lipo is unavailable through xcrun reason with complete cleanup, so a closed client or cleanup failure still propagates; signed slices behind an unsigned default now report team identifier and authorities too; and entitlement differences carry values (get-task-allow: true (described slice false), … absent) instead of key names only, with a unit test for the same-key-different-value case.
  • Missing lipo (fourth commit): if lipo is unavailable through xcrun, the unsigned path falls back to the target's CPU families with a limitation instead of failing the result; cancellation, target-change and cleanup errors still propagate. Golden test added.
  • Memory: slice captures are projected to provenance entries as they arrive instead of being held until the end, so a 128-slice file no longer retains every raw codesign output at once.

Re-ran: signature test set (7 files, 130 passed), every native test file (49 files), npm run check, npm run docs:check, and the three CLI runs (fixture, /bin/ls, the real default-unsigned file).

Merge with main (2026-10-18)

Main rewrote parseEntitlements to project entitlement scalars through the plist owners (shared value and exact-number projections). The merge takes that version, which also covers the integer and data cases earlier commits here handled separately, and keeps only the decoded flag so an undecodable slice plist stays unobserved. After the merge: signature test set 122 passed, every native test file (60 files, 785 passed), npm run check and npm run docs:check ok.

Review follow-up after CassieFox23's triage (2026-10-19)

One commit (adae09e) for the five items marked real: a plist with an XML header but no closing tag is now undecodable rather than "no entitlements"; the echoed snapshot path is stripped before the per-slice not-signed verdict is matched, as the main parser already does; identifiers, team, authorities and entitlement keys are JSON-quoted in the limitation sentences; and entitlements are compared on a type-tagged form of the decoded plist as well as the projected JSON, so a <data> value and a dictionary shaped like its wrapper read as different. Each has a test. Left alone with a note on the thread: 21 (retained text size, unmeasured) and 28 (carrying codesign's diagnostic for a failed per-slice query, a design call); 20 is outdated and 22 resolved by the merge with main. Re-ran: signature test set 128 passed, every native test file (62 files, 809 passed), npm run check, npm run docs:check, and the CLI on the two real fixtures.

Merge with main (2026-10-22)

Main threaded a per-command deadline through the native provider; the slice and lipo captures now pass it along. Main also added a real-codesign CLI test that runs inspect-signature on a universal copy of /usr/bin/true with forged text in the file name and asserted the limitations list exactly; it now accepts the two slice sentences this PR adds beside the snapshot note, and additionally checks that none of the forged text (authority, identifier, entitlement, requirement) reaches any limitation. On the merged tree: signature test set 143 passed, every native test file (75 files, 987 passed), npm run check and npm run docs:check ok.

Merges with main (2026-10-21)

Two more merges. Main adopted an exact snapshot-framed unsigned verdict (isNonzeroUnsignedObservation now requires codesign's diagnostic for the bound snapshot and nothing else), which supersedes the echoed-path handling from adae09e; both the aggregate and the per-slice checks use it. Main's #5765 then added partial-observation retention for slice inspection: this merge keeps that, so provenance and limitations accumulate on the shared observation as slices arrive, a slice query that fails for a reason other than being unsigned is a failure that retains the facts collected so far (the earlier "could not be classified" limitation is gone), and the mixed-state notes are recorded before the slice loop. The echoed-file-name test now asserts that failure path. After the merge: signature test set 142 passed, every native test file (71 files, 913 passed), npm run docs:check ok; npm run check fails only on knip's unlisted g++ binary in src/windows/WindowsHandleClose.test.ts, a file from main (43ac3d1) that this branch does not touch.

Merge with main (2026-10-24)

Main's 2721650 now asks codesign for the selected architecture with -a on all three inspect_signature queries and probes the other slices only for their signing state, with a limitation saying their metadata is not returned. The merge keeps the -a binding, so the result's fields describe the requested slice by name instead of codesign's host default, and runs this PR's per-slice comparison on top; the limitation now ends "other slices are queried separately" and is followed by Other signed Mach-O slices, the differing fields, and the requirement-hash note. Main's two "unavailable because codesign reported it unsigned" notes replace this branch's mixed-signing notes.

One thing surfaced while merging: with -a, codesign reports the requested slice as Format=Mach-O thin (<arch>) even for a universal file (checked on /usr/bin/true, macOS 27), so main's probe loop, which takes slice names from the Format line and treats a thin format as no slices, finds nothing on a real universal file; its tests substitute a universal Format line. Here a universal target's slice names come from lipo -archs (the path this branch already had for the unsigned case), with the target's CPU families as the fallback when lipo is unavailable. Main's real-codesign binding test, which expected the probes to follow the target's CPU families, now expects lipo's exact slice names. On the merged tree: signature test set 91 passed, every native test file (87 files, 1239 passed), npm run check and npm run docs:check ok, with Node 26.12.1 as main now requires.

Contract and boundary impact

  • Semantic owner and earliest changed stage: #inspectBoundSignature / #inspectSignatureSlices in the native macOS provider, plus the new describeSignatureSlices.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. New limitation sentences for signed universal files; provenance gains one -d -a <slice> --verbose=4 entry per slice and one --entitlements :- per differing slice.
  • Provider, bridge, target-format, or platform compatibility: native macOS provider only. Thin and fully unsigned files are unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: every per-slice query is in provenance with its exit status; described slice, differing slices, unmatched default and unreadable slice entitlements are all stated as limitations.
  • Target selection, authority, upstream behavior, and cleanup details: each extra call goes through #captureSignature, so it reads the digest-verified snapshot and re-verifies the target before and after, like the existing calls.
  • 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/native/signatureSlices.test.ts (new, 7 tests): differing slices, slices signed alike, unmatched default slice, slices not asked for entitlements, empty vs absent entitlements, case-insensitive CDHash match, no slices.
    • tests/boundary/providers/native/nativeInventory.golden.test.ts: a real-capture case from the issue's fixture asserting the three new limitations and the exact six-command provenance; a signed-alike control (described-slice note only); a thin control (three commands, no slice note, runner throws on any -a). Existing mixed-signature tests pass unchanged.
    • tests/boundary/providers/native/nativeSignatureTargetBinding.test.ts: the real-codesign swap test copies /usr/bin/true, which is universal, so it now checks that every call, including per-slice ones, reads $ARTIFACT instead of expecting exactly three.
  • Base reproduction: built main 42fc6c5 and ran the CLI on the fixture; output as described above, three provenance entries, no slice limitation. The new golden test fails on main.

  • CLI output on this branch (macOS 27.0.1 arm64):

    fixture (x86_64 + arm64, signed differently)
     - Signature fields describe the arm64 slice that codesign displayed by default; other signed slices: x86_64 (CDHash 269615ed3412eb7a8c0945e51c76355412db4b12).
     - Mach-O slices signed differently from the arm64 slice: x86_64 (identifier com.example.x86slice; hardened runtime off; entitlements com.apple.security.get-task-allow).
     - designated_requirement covers the whole file and names CDHashes of other slices (269615ed3412eb7a8c0945e51c76355412db4b12); cdhashes lists only the described slice.
     provenance: -d --verbose=4 · -d -r- · -d --entitlements :- · -d -a x86_64 --verbose=4 · -d -a x86_64 --entitlements :- · -d -a arm64 --verbose=4 (all exit 0)
    
    /bin/ls (x86_64 arm64e arm64e.x1, Apple-signed alike)
     - Signature fields describe the arm64e.x1 slice that codesign displayed by default; other signed slices: x86_64 (CDHash 61afc1ca…), arm64e (CDHash 54097a16…).
     (no "signed differently" line; 8 codesign runs)
    
  • Remaining proof gaps: one Apple Silicon Mac. On Intel the default slice differs, so the fields describe a different slice (the limitation names it). Slice names beyond x86_64, arm64, arm64e, arm64e.x1 weren't tried against real codesign. Extra run time not measured: one codesign -d -a per slice and one --entitlements per differing slice, only for signed universal files.

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

macOS 27.0.1 arm64, Node 26.7.0, npm 11.19.0, on top of main 42fc6c5.

  • npm ci --ignore-scripts — ok
  • npm run test:focused on the 7 signature-related files (new unit test, golden, target binding, nativeProvider, nativeSignatureCli, nativeSignatureTargetBindingMcp, appleApplication) — 127 passed
  • npm run test:focused on every test file under tests/boundary/providers/native and src/native (49 files) — 625 passed
  • npm run check:fast — ok
  • npm run check — ok
  • npm run docs:check — ok
  • npm run verify:test-discovery — all 1401 test files found once
  • npm run build:cached, then the CLI runs above before and after
  • Not run: the full suite (test:fast), Linux, Intel macOS

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: real codesign on macOS 27.0.1 arm64 (CLI runs and the /usr/bin/true test).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: added commands are read-only codesign -d on the registered snapshot; no target execution.

Author readiness

Human owner: @Ambar-13

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

🤖 Generated with Claude Code

inspect_signature described one slice of a universal file (codesign's
default for the host) as if it were the whole file. It now queries each
slice, names the slice the identity fields describe, lists the other
slices with their CDHashes, names slices signed with another identifier,
team, authorities, hardened-runtime state or entitlements, and explains
when designated_requirement lists CDHashes that cdhashes does not.

Fixes morluto#4293

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Ambar-13
Ambar-13 marked this pull request as ready for review October 16, 2026 03:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T02:35:57.357142Z 6dc8d4d 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: 24e5c08974

ℹ️ 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 src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/signatureSlices.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge, with no new blocking finding.

Summary

inspect_signature now reports signing differences across universal Mach-O slices without changing its result schema.

  • Universal Mach-O results now show how their signatures differ by slice.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Digest-verified snapshot] --> B[Read default signing facts]
  B --> C{Universal file?}
  C -->|No| G[Return signature observation]
  C -->|Yes| D[Name and query slices]
  D --> E[Read other slice entitlements when comparable]
  E --> F[Describe slices and signing differences]
  F --> G
  D -->|Command fails| H[Return error with partial observation]
Loading

Reviews (13) · Last reviewed commit: "Merge origin/main into fix/signature-uni..." · Reviewed by Greptile

Comment thread src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/signatureSlices.ts Resolved
… entitlement facts

Address the first review round. Query the slices of a universal file whose
host-default slice is unsigned and name the signed ones. Decode slice
entitlements that hold data or date values instead of failing the result,
and report omitted __proto__ keys per slice. Attribute requirement CDHashes
to the queried slice that carries them, and say when none does.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment thread src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/NativeMacOSProvider.ts Resolved

@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: b160d44f64

ℹ️ 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 src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/NativeMacOSProvider.ts Resolved
…read entitlements unobserved

Ask lipo for the slice names codesign accepts when the default slice is
unsigned, since the target merges CPU subtypes. Keep slice entitlements that
could not be read or decoded out of the comparison, carry the plist
projection's notes, and project slice captures to provenance as they arrive.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment thread src/native/NativeMacOSProvider.ts Resolved
Fall back to the target's CPU families, with a limitation, when lipo cannot
name the slices of an unsigned universal file; cancellation, target-change
and cleanup errors still propagate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@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: c8365731b3

ℹ️ 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 src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/signatureSlices.ts Resolved
Comment thread src/native/signatureSlices.ts Resolved
Ambar-13 and others added 2 commits October 16, 2026 12:50
…full

Consult lipo only for universal targets, and fall back only on the exact
missing-lipo condition with complete cleanup. Name team identifier and
authorities for signed slices behind an unsigned default, and list differing
entitlements with their values instead of key names.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…lices

An entitlement key such as "constructor" or "toString" must not read the
other dictionary's prototype, where a function value would make the
canonical rendering throw and fail the whole signature result.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@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: ed75ca7afe

ℹ️ 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 src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/signatureSlices.ts Resolved
… integers

Compare each slice's entitlements with the described slice's as soon as they
decode and retain only the outcome. Route entitlement plists with integers
beyond the exact range through the XML projection so their digits compare.
Carry length and a SHA-256 prefix on cut values so long values that differ
past the cut still read as different.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment thread src/native/NativeMacOSProvider.ts Resolved

@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: 52bea8b1d0

ℹ️ 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 on lines +831 to +834
entitlementDifferences: describeEntitlementDifferences(
decoded.value,
aggregate.entitlementValue,
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bound retained per-slice difference text

When a FAT target has many signed slices with mutually different large entitlement dictionaries, this stores the full describeEntitlementDifferences sentence in every SliceSignature until the loop finishes. The 80-character cap only bounds each value; key count and key length remain unbounded up to each 64 MiB command budget, so 128 admitted slices can still retain gigabytes and OOM before describeSignatureSlices and result serialization run. Apply an aggregate budget or emit bounded summaries as each slice arrives.

AGENTS.md reference: AGENTS.md:L51-L52

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not changed: the per-value cap bounds each rendered value; key count follows the plist, which codesign already caps per command. Measuring an aggregate budget is a separate change if a maintainer wants one.

🤖 Addressed by Claude Code

Comment thread src/native/NativeMacOSProvider.ts Resolved
Comment thread src/native/signatureSlices.ts Resolved
Take main's plist-owner projection for entitlements (shared value and exact
number projections) and keep the decoded flag so an undecodable slice plist
stays unobserved rather than failing the result.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment thread src/native/NativeMacOSProvider.ts Resolved

@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: e17beb5212

ℹ️ 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 src/native/signatureSlices.ts Resolved
Comment thread src/native/NativeMacOSProvider.ts Resolved
Keep main's unknown-scalar entitlement limitation beside the omitted
prototype-key one, and the per-slice provenance assertion in the real
codesign binding test.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

ghost 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: 9308314441

ℹ️ 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 src/native/signatureSlices.ts Resolved
Comment on lines +834 to +837
const decoded =
sliceEntitlements.value.exitCode === 0
? parseEntitlements(sliceEntitlements.value.stdout)
: null;

ghost Oct 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve per-slice entitlement failure reasons

When a per-slice --entitlements invocation exits nonzero, this assigns null; the later generic unavailable limitation and provenance retain only the exit code and byte counts, so codesign's diagnostic—the only reason the entitlement is unknown—is lost while the operation returns success. Retain a bounded diagnostic or classified failure reason for that slice.

AGENTS.md reference: AGENTS.md:L31-L31

Useful? React with 👍 / 👎.

ghost Oct 19, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not changed: whether to carry codesign's diagnostic text for a failed per-slice entitlement query into the result is a design call; the exit code and byte counts are in provenance. Happy to add it if a maintainer wants it.

🤖 Addressed by Claude Code

Comment thread src/native/NativeMacOSProvider.ts Resolved

ghost left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TL;DR: I checked the 10 open bot threads at head 9308314. Only two things were run: the PR's three test files, which pass on Node 22, 24 and 26, and a probe for threads 24 and 27, which is real. The other eight threads I only read in the code, so treat them as readings.

Edit: I retested on head adae09e. The five findings I marked real are fixed there. Four bot threads are still open, all left by the author. New results are here.

The probe found a different shape than the thread described. A <data> value and a plain dict with keys 0, 1 and 2 compare as equal. The dict with $plist_type and base64 keys does not.

Findings and verdicts

Head 9308314. "Read, not run" means I read the code and it does what the thread says. It is not a run. Only threads 24 and 27 were run.

# Thread Sev Verdict What the code shows
23 Quote entitlement keys P2 Read, not run: real Keys are printed unquoted and joined with commas, so x: true, y and two keys x and y print the same
24 Changed entitlements look unchanged P2 Real, tested (other shape) <data>AQID</data> and a dict with keys 0, 1, 2 holding 1, 2, 3 give the same JSON, and the compare returns null. The thread's own example (keys $plist_type and base64) does give a difference
27 Compare source types P2 Real, tested (same probe) Same cause as the thread above
25 Quote slice identity values P2 Read, not run: real Identifier, team and authorities are printed unquoted and joined with ;
26 Partial entitlement XML P2 Read, not run: real With <?xml but no </plist> the parser returns decoded with a null value, before the error path
29 Echoed paths in unsigned check P2 Read, not run: real The check scans stdout and stderr, and the snapshot keeps the target's file name
21 Bound retained difference text P1 Read, not run: partly Values are capped at 80 characters but key count is not. The size of any memory problem is not measured
28 Keep failure reasons P2 Read, not run: partly The codesign message is dropped, only the exit code and byte counts stay. Whether to keep it is a design call
20 Unchanged integers look different P2 Read, not run: real The exact-integer form depends on the whole plist, so one slice can differ from another. Marked outdated, and the bot calls it non-blocking
22 Encoded unsafe integers P2 Read, not run: probably fixed The regex it names is gone from the file. I did not check entity-encoded digits

Test results, the three test files this PR touches (src/native/signatureSlices.test.ts, tests/boundary/providers/native/nativeInventory.golden.test.ts, tests/boundary/providers/native/nativeSignatureTargetBinding.test.ts):

Node Result
24.18.0 3 files passed, 69 passed, 1 skipped
22.23.1 3 files passed, 69 passed, 1 skipped
26.11.1 3 files passed, 69 passed, 1 skipped

Threads 24 and 27 are one issue. Threads 23 and 25 are the same kind of issue in different fields.

Not run

  • Probes for threads 20, 21, 22, 23, 25, 26, 28 and 29. Those are readings only.
  • Real codesign output. The box is Linux.
  • Main may have moved on. The base is 22ddd82 and main was d6ca7b3 when I looked. The native files are the same on both.

Thanks, Ambar-13, for the work on this.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head / base: 9308314 / 22ddd82 (main d6ca7b3)
  • Other: the tests and the probe ran on a separate build of the head; the rest is reading
Commands
git archive 930831444 | tar -x   (read-only mirror)
npm ci --ignore-scripts; npm run build:cached; npm run test:prepare   (exit 0)
npm run test:focused -- <3 files>   (once each on Node 24, 22, 26)
probe: parseXmlPropertyList then describeEntitlementDifferences, key com.x
git grep -n doctor 930831444 -- <3 test files>   (exit 1, no match)

Files read: src/native/signatureSlices.ts, src/native/NativeMacOSProvider.ts, src/domain/apple/plistNumbers.ts, src/domain/apple/plistValue.ts, src/domain/propertyListXml.ts, src/native/SignatureTargetBinding.ts.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

… plists unknown

Address the five review items CassieFox23 confirmed: a plist with an XML
header but no closing tag is undecodable rather than "no entitlements"; the
echoed snapshot path is removed before matching codesign's not-signed
verdict for a slice; identifiers, team, authorities and entitlement keys are
JSON-quoted in the limitation sentences; and entitlements are also compared
on a type-tagged form of the decoded plist, so a data value and a dictionary
shaped like its wrapper no longer read as equal.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Ambar-13

ghost commented Oct 19, 2026

Copy link
Copy Markdown
Author

@CassieFox23 thanks for taking the time to run this and sort the threads; the table was more useful than the ten threads it summarises.

I've pushed one commit (adae09e) covering the five you marked real: a plist with an XML header but no closing tag now counts as undecodable rather than "no entitlements"; the unsigned-slice check strips the echoed snapshot path before matching codesign's verdict, as the main parser already does; identifiers, team, authorities and entitlement keys are JSON-quoted in the limitation sentences; and entitlements are compared on a type-tagged form of the decoded plist, so a data value and a dictionary shaped like its wrapper now read as a difference. Each has a test. Your <data> vs {0,1,2} shape is already told apart by main's number-and-value projection after the merge, so the test uses the wrapper-shaped dictionary that still collided.

Left alone on purpose: 21 (retained text size, unmeasured and bounded per value already) and 28 (keeping codesign's diagnostic for a failed per-slice query, which I'd rather a maintainer rule on), with a note on each. 20 is outdated since the merge took main's number projection, and 22 went with it.

Would you mind a re-review when you have a moment? It'll need a CI approval again, sorry about that.

@Ambar-13
Ambar-13 requested a review from CassieFox23 October 19, 2026 07:44

ghost 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: adae09ed08

ℹ️ 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 src/native/NativeMacOSProvider.ts Outdated
? codeSignArchitectures(parsed.format, this.target)
: universalCodeSignArchitectures(parsed.format)
: sliceNames.value.names;
if (mixedSigning || architectures.length > 1) {

ghost Oct 19, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Inspect a universal fallback even when one family remains

When lipo is unavailable or returns no accepted names and an unsigned universal FAT's slices all collapse to one target CPU family, #unsignedSliceNames falls back to a one-element array; because unsigned also forces mixedSigning false, this guard skips #inspectSignatureSlices even though target.format already proves a universal container. Thus no codesign -a observation runs and a signed non-default slice can be omitted; fresh evidence after the earlier exact-lipo fix is that its normalized fallback is still gated by count rather than sliceNames !== null. Enter this path for any proven unsigned universal target while retaining the fallback ambiguity limitation.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

ghost Oct 19, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not changed for now: this needs lipo unavailable and an unsigned universal file whose slices all share one CPU family, then the fallback's single name skips the per-slice query. Entering the slice path whenever the target format proves a universal container is a small change; I'd rather a maintainer confirm they want the extra codesign call in that case, since the fallback name is already marked ambiguous.

🤖 Addressed by Claude Code

Comment on lines +309 to +310
return canonicalJson(value) === canonicalJson(theirs)
? []

ghost Oct 19, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retain type-only differences beside value changes

When a source-type collision (for example <data>AQID</data> versus an ordinary dictionary equal to its $plist_type projection) appears alongside any second entitlement change, the whole dictionaries differ so the shape fallback is bypassed; this per-key projected-JSON equality then drops the colliding entry and only reports the second change before the raw plist is discarded. Fresh evidence after the prior data-wrapper fix is that source shape is checked only for the whole-tree equality case. Compare per-entry source-aware shapes, or retain a source-aware diff, so all signed differences remain visible.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

ghost Oct 19, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not changed for now: the type-tagged comparison runs on the whole plist, so a data-vs-wrapper collision is reported only when nothing else differs; alongside another change, that entry is folded into the dictionary-level difference. A per-entry shape diff is possible, but the raw plist is deliberately not retained and I'd like a maintainer's view before widening the sentence format again.

🤖 Addressed by Claude Code

ghost left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TL;DR: At adae09e, all five findings I marked real are fixed, and I checked each with its own small fixture. The PR's three test files pass on Node 22, 24 and 26. Four bot threads are still open, and the author left all four on purpose.

Edit: Ambar-13 has merged main since. I read the new head bc36fdf: the five fixes still stand, and the new notes are here.

I ran fixtures and named test files only. I did not run real codesign output. Thanks, Ambar-13, for the fast fixes and the clear replies.

My earlier findings

"Old" is my result at 9308314 from my first review. "Now" is my result at adae09e. Node 22.23.1, 24.18.0 and 26.11.1 gave the same text on every probe below.

# Finding Old Now
23 Quote entitlement keys Read, not run: real Fixed. A key named x: true, y prints as "x: true, y": true. Two keys x and y print as "x": true, "y": true. A key holding quotes prints with them escaped.
24 and 27 Changed entitlements look unchanged and Compare source types Real, tested (other shape) Fixed. A <data> value against a dictionary shaped like its wrapper now reads "same projected values, but the plist value types differ", in both directions. Two equal <data> values give no difference. My old shape, <data> against a dictionary with keys 0, 1 and 2, also shows as a difference.
25 Quote slice identity values Read, not run: real Fixed. An identifier of a; team identifier "T"; hardened runtime on plus a line break prints as one quoted string. It no longer reads as extra fields. Authorities A, B and C print as two quoted items.
26 Partial entitlement XML Read, not run: real Fixed. Four cut-off shapes now say "cut off before its closing tag; entitlements are unavailable". The limitation "Entitlements could not be read for Mach-O slices: x86_64" follows. Empty output still reads "entitlements none".
29 Echoed paths in unsigned check Read, not run: real Fixed. A file named not signed at all with an unrelated error stays unclassified. The same file name in front of the real message code object is not signed at all is still read as unsigned.

Threads 20 and 22 are marked resolved. The author says they are outdated since the merge took main's number projection. I did not run them.

Threads open at adae09e

Thread Sev Result at adae09e
Bound retained difference text P1 Author's reply: not changed, a maintainer's call. I read the code only: values are still cut at 80 characters, with no cap on key count. I did not measure memory.
Keep failure reasons P2 Author's reply: not changed, a maintainer's call. Still as described. A slice whose entitlements call exits 1 with a codesign message gives only "Entitlements could not be read for Mach-O slices: x86_64". The message text is not in the limitations. I did not check the provenance entry.
Inspect a universal fallback when one family remains P2 Author's call, left open. Not run.
Retain type-only differences beside value changes P2 Author's call, left open. Not run.

Tests

The three files this PR touches, run once each on Node 22.23.1, 24.18.0 and 26.11.1: 3 files passed, 74 passed, 1 skipped, on all three. At 9308314 the same files gave 69 passed, 1 skipped. That is five more tests than before.

Not run

  • Real codesign or lipo output. The box is Linux, so every result comes from hand-made fixtures and the PR's own fixtures.
  • The two threads the author left for a maintainer (the lipo fallback and the per-entry type diff).
  • Memory use for the retained-text thread.
  • Threads 20 and 22, which are resolved.
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.11
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head / base: adae09e / 22ddd82
  • Other: the box was shared with other test jobs
Commands
git archive adae09ed0 into a fresh folder   (read-only mirror)
npm ci --ignore-scripts; npm run build:cached; npm run test:prepare   (Node 24, exit 0)
grep -n doctor <each test file>   (no match)
npm run test:focused -- src/native/signatureSlices.test.ts tests/boundary/providers/native/nativeInventory.golden.test.ts tests/boundary/providers/native/nativeSignatureTargetBinding.test.ts   (Node 22, 24, 26; exit 0 each)
npm run test:focused -- <one probe file>   (Node 22, 24, 26; exit 0 each)

The probe file builds the PR's own universal fixture with a fake codesign runner, in the same shape as the PR's golden test. It changes one answer per probe. Quoting probes call describeSignatureSlices and describeEntitlementDifferences directly with hand-built slice objects.

Cut-off plist shapes: header plus an open dict; header only; header plus an open plist; a closing tag before the header. The same cut-off text on the default slice gives entitlements null and the same "cut off" limitation.

Data against wrapper (the entitlement com.x on the x86_64 slice against the default slice):

<data>AQID</data>
<dict><key>$plist_type</key><string>data</string><key>base64</key><string>AQID</string></dict>

Unsigned verdict: the snapshot file is named not signed at all, and the x86_64 call exits 1 with stderr <snapshot path>: code object is not signed at all. Result: "Unsigned Mach-O slices: x86_64." With stderr <snapshot path>: invalid or unsupported format, the result is "Signature state could not be classified for Mach-O slices: x86_64."

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

Adopt main's exact snapshot-framed unsigned verdict for the aggregate and
per-slice checks; the slice inspection and entitlement comparison keep
their behaviour on top of it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

ghost 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: 88349c03d7

ℹ️ 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 on lines +877 to +881
team_identifier: parsed.team_identifier,
cdhashes: parsed.cdhashes,
authorities: parsed.authorities,
hardened_runtime: parsed.hardened_runtime,
};

ghost Oct 21, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve each slice's timestamp and hash algorithms

When a universal file is assembled from separately signed slices whose identifier, team, authorities, runtime, and entitlements match but whose Hash choices or Timestamp differ, parseCodeSignature observes those fields for every codesign -a result, but this projection ends without retaining either. The top-level hash_algorithms and timestamp describe only the default slice, while provenance retains no command output, so callers cannot discover a weaker hash choice or different signing time on another slice; carry both fields through SliceSignature and the difference report.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

ghost Oct 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not changed for now: per-slice hash choices and timestamps are parsed but not carried into the sentence, by design to keep the limitation readable. Adding them is a small extension of SliceSignature; I'd like a maintainer to say whether they want those fields reported before the sentence grows again.

🤖 Addressed by Claude Code

return `data:${Buffer.from(value).toString("base64")}`;
if (value instanceof Date)
return `date:${Number.isNaN(value.getTime()) ? "invalid" : value.toISOString()}`;
if (typeof value === "number") return `number:${String(value)}`;

ghost Oct 21, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Distinguish integer and real entitlement shapes

When one slice signs <integer>1</integer> and the described slice signs <real>1</real> for the same entitlement, the XML decoder produces the number 1 for both and their JSON projections are equal; this branch also gives both the shape number:1, so describeEntitlementDifferences returns null and the source-type difference disappears when the raw slice output is discarded. Carry the XML numeric element kind into the comparison shape rather than deriving it solely from the decoded JavaScript value.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

ghost Oct 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not changed for now: the shape is derived from the decoded value, so <integer>1</integer> and <real>1</real> do collapse. Telling them apart means threading the XML element kind out of the plist decoder, which is the decoder's owner to decide; happy to follow if a maintainer wants it.

🤖 Addressed by Claude Code

Comment on lines +921 to +925
entitlementDifferences: describeEntitlementDifferences(
decoded.value,
aggregate.entitlementValue,
{ slice: decoded.shape, described: aggregate.entitlementShape },
),

ghost Oct 21, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep ambiguous exact integers out of equality checks

When each plist contains 9007199254740992 and 9007199254740993 under different keys and the slices swap those values, both literals round to the same JavaScript number; createPlistNumberProjection deliberately leaves both occurrences ambiguous because the rounded value maps to two decimals, and entitlementShape sees the same rounded tree. This comparison can therefore return null even though the signed policies differ; fresh evidence beyond the fixed single-literal case is the two-literal collision, so propagate numeric ambiguity and leave the slice comparison unknown (or retain occurrence-aware exact literals) instead of treating the projected trees as aligned.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

ghost Oct 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not changed for now: when two literals in one plist round to the same number, the number projection already marks both ambiguous. Propagating that ambiguity into the slice comparison (reporting it as unknown rather than equal) is reasonable; I'd rather have a maintainer confirm that direction than widen the comparison on my own.

🤖 Addressed by Claude Code

Combine main's partial-observation retention for slice inspection (morluto#5765)
with the per-slice comparison: provenance and limitations accumulate on the
shared observation as slices arrive, a slice query that fails for a reason
other than being unsigned is a failure that keeps the facts collected so
far, and the mixed-state notes are recorded before the slice loop.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
["-d", "-a", architecture, "--verbose=4"],
signal,
);
if (!slice.ok) return slice;

ghost Oct 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Completed slice facts disappear

#inspectSignatureSlices keeps completed signed-slice facts only in its local signed array. If a later query fails or is cancelled, the caller returns partialObservation before adding those slice descriptions. Earlier differences in identifiers or entitlements disappear, and provenance records only commands and byte counts—not their output.

This is non-blocking, but makes partial results less useful. Add completed slice descriptions to the shared observation before returning an error.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/native/NativeMacOSProvider.ts
Line: 908

Comment:
**Completed slice facts disappear**

`#inspectSignatureSlices` keeps completed signed-slice facts only in its local `signed` array. If a later query fails or is cancelled, the caller returns `partialObservation` before adding those slice descriptions. Earlier differences in identifiers or entitlements disappear, and provenance records only commands and byte counts—not their output.

This is non-blocking, but makes partial results less useful. Add completed slice descriptions to the shared observation before returning an error.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

ghost Oct 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed on the gap: completed slice facts live in the helper's local array until the loop ends, so a failure part way retains provenance and limitations but not the per-slice descriptions. The fix is small (describe the slices seen so far into the shared limitations before returning the error). I'll do it if a maintainer wants partial observations to carry it; leaving the thread open for that call.

🤖 Addressed by Claude Code

ghost 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: ab0c82e6f1

ℹ️ 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 on lines +1698 to +1699
if (start < 0)
return { value: null, limitations: [], decoded: true, shape: null };

ghost Oct 21, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat nonempty declaration-less entitlements as unknown

When a successful --entitlements capture is nonempty but lacks <?xml—for example, an otherwise valid <plist>...</plist> document with the optional XML declaration omitted—this branch marks it decoded with value null; the slice comparison can then report entitlements none or no difference instead of unavailable. Fresh evidence beyond the fixed missing-closing-tag case is that this pre-parser return still conflates every nonempty unframed body with codesign's genuinely empty no-entitlements output; only empty/whitespace output should mean none, while other unframed output should remain unknown.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

ghost Oct 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fair: the pre-parser check keys on <?xml, so a nonempty body without the optional declaration reads as no entitlements. The tighter rule is: empty or whitespace output means none, anything else without a parseable plist stays unavailable. Small change; leaving the thread open for a maintainer to say whether they want it in this PR or alongside the other open entitlement-parsing threads.

🤖 Addressed by Claude Code

Adjacency only: main's new plist observation helper sits beside the
entitlement parser.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

ghost 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: c531497234

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

@@ -787,72 +834,258 @@ class NativeMacOSClient implements AnalysisClient {
);
return err(slices.error.retainPartialObservation(observation()));

ghost Oct 21, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retain completed slice facts on later failures

When one architecture has been parsed (and possibly had entitlements compared) but a later slice display or entitlement command fails or is cancelled, this branch builds the partial observation before describeSignatureSlices ever runs. The completed SliceSignature and entitlementsUnavailable entries live only in the callee's local arrays, while provenance contains just command metadata, so the retained error loses the successful slice's identifier, CDHashes, differences, and unknown-entitlement fact; project these entries into limitations as each slice finishes or attach them to the error before returning.

AGENTS.md reference: AGENTS.md:L31-L31

Useful? React with 👍 / 👎.

ghost Oct 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Same gap Greptile raised above (completed slice facts stay in the helper's local arrays until the loop ends, so a later failure retains provenance and limitations but not the per-slice descriptions). The fix is to describe the slices seen so far into the shared limitations before returning the error; small, and I'll do it on a maintainer's word rather than reshape the sentences again on my own. Leaving open for that call.

🤖 Addressed by Claude Code

Thread main's command deadline through the slice and lipo captures. The
real-codesign CLI test on a universal file now accepts the slice sentences
beside the snapshot note while still rejecting any forged text in them.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@chatgpt-codex-connector

ghost commented Oct 22, 2026

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@Ambar-13

ghost commented Oct 22, 2026

Copy link
Copy Markdown
Author

@CassieFox23 quick note so the new commits don't look like more changes: everything since adae09e is merge-conflict resolution with main (four merges, the latest bc36fdf). Main rewrote the unsigned verdict and added partial-observation retention in this same function, so the slice code now sits on top of those; the only test edit is the new real-codesign CLI test, which asserted the limitations list exactly and now accepts the slice sentences while still checking that no forged text reaches them. No new behaviour.

Each push reset the workflow approval, so the checks for bc36fdf are waiting again. I'll re-request your review so it shows up for you; if you can approve the workflows when you look, that would unblock CI. Thanks again.

@Ambar-13
Ambar-13 requested a review from CassieFox23 October 22, 2026 07:27

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TL;DR: Since my last review at adae09e, Ambar-13 has only merged main. I read the new head bc36fdf, and the five fixes I confirmed still stand. One behaviour changed. A slice whose codesign call fails for an unknown reason now fails the whole call. Before, it added a limitation. Four old threads and six new bot threads are still open, and CI is waiting for a maintainer to approve it.

I read the code only this round. I ran no tests and no probes.

What changed since adae09e

  • Four merges of main. The PR's own files src/native/signatureSlices.ts and src/native/signatureSlices.test.ts are byte-identical to adae09e. So my fixed findings still hold by reading. Two are on quoting entitlement keys and quoting slice identity values. One is on the <data> against dictionary compare.
  • src/native/NativeMacOSProvider.ts was reworked to sit on top of main's new "keep what was seen when a call fails" code. Ambar-13 says there is no new behaviour. That is true for the five fixes, with one exception below.
  • The only test edit besides adapting to main is in tests/boundary/cli/nativeSignatureCli.test.ts. The limitations check now accepts the slice sentences. It still checks that no forged text reaches them.

My five earlier findings at bc36fdf

Finding Result at bc36fdf (read, not run)
Quote entitlement keys Still fixed. Same signatureSlices.ts as adae09e.
Changed entitlements look unchanged and Compare source types Still fixed. Same file as adae09e.
Quote slice identity values Still fixed. Same file as adae09e.
Partial entitlement XML Still fixed. parseEntitlements at NativeMacOSProvider.ts:1885 still returns "cut off before its closing tag; entitlements are unavailable".
Echoed paths in unsigned check Fixed another way. Main replaced the path-stripping check. isNonzeroUnsignedObservation (NativeMacOSProvider.ts:1733) now accepts only the exact line <snapshot path>: code object is not signed at all, so a file name that says "not signed at all" cannot pass.

One behaviour change to know about

A slice call that failed for another reason gave the limitation Signature state could not be classified for Mach-O slices: x86_64. at adae09e. That sentence is gone from src/ at bc36fdf. NativeMacOSProvider.ts:1010 now returns the failure, and the call fails with the facts seen so far kept (:913-915). The updated test in nativeInventory.golden.test.ts expects exactly that. This matches how the aggregate queries already behave, so it looks intended. My earlier check of that case would now show an error, not a limitation.

Still open

Old threads, all left for a maintainer by Ambar-13. None changed:

Six bot threads opened after my review, on heads 88349c0 to c531497. Ambar-13 replied to each and left each open for a maintainer. I read the code for two of them:

None of the ten undoes the five fixes. Ambar-13 asked a maintainer to decide on all of them, which seems right to me.

CI

On bc36fdf, the CI and PR title workflow runs show action_required, and PR readiness passed. Ambar-13 asked me to approve the workflows. I can't: my account has read access only on this repo, so a maintainer has to approve them.

Not run

  • Any test or probe at bc36fdf. Everything above is a reading of the code and the compare between the two heads.
  • Real codesign or lipo output. This box is Linux.
  • The three bot threads marked "Not checked".

🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

Main (morluto#6315 area, commit 2721650) now asks codesign for the selected
architecture with -a on every inspect_signature query and probes the other
slices only for their signing state. This merge keeps that binding: the
result's fields describe the requested slice, and the per-slice comparison
from this branch runs on top of it.

With -a, codesign reports the requested slice as "Mach-O thin (<arch>)" even
for a universal file (checked against /usr/bin/true on macOS 27), so the
Format line no longer names the other slices. A universal target's slice
names therefore come from lipo -archs, with the target's CPU families as the
fallback when lipo is unavailable; main's own probe loop found no slices on a
real universal file for this reason.

Wording follows main: "Partial signature coverage: ... describe the requested
<arch> architecture; other slices are queried separately", and main's two
"unavailable because codesign reported it unsigned" notes replace this
branch's mixed-signing notes. Other signed slices, differing fields,
requirement hashes and the unsigned-requested-slice case keep their
limitations, now phrased against the requested slice.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Ambar-13

ghost commented Oct 24, 2026

Copy link
Copy Markdown
Author

@CassieFox23 thanks for the triage and for taking the time on this one.

The new push (6dc8d4d) is a merge with main, no new behaviour of its own: main's 2721650 now binds inspect_signature to the requested architecture with -a, so the per-slice comparison here sits on top of that. One thing the merge surfaced: with -a, codesign prints Format=Mach-O thin (<arch>) even for a universal file, so slice names now come from lipo -archs (details in the body under "Merge with main (2026-10-24)"). Checks and the native suite pass locally. I'll re-request review; the CI run still needs a maintainer's approval.

ghost 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: 6dc8d4df67

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

// The aggregate entitlements belong to the requested slice; another
// slice's entitlements are hashed into its own code directory.
if (
!requested.entitlementsComparable ||

ghost Oct 24, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report skipped slice entitlements as unknown

When a signed requested slice's entitlement plist is undecodable, entitlementsComparable is false, so this branch skips the --entitlements command for every other signed slice. It pushes each slice as ordinary facts without either entitlementDifferences or an entitlementsUnavailable entry, and the final limitations therefore do not say that those slices' entitlements were unexamined; a slice with a different policy is indistinguishable from one that matched. Record the skipped slices as unknown, or emit a comparison-unavailable limitation, instead of silently omitting the fact.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

ghost Oct 24, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Noted, and the observation is right: when the requested slice's entitlements could not be read or decoded, the other slices are not asked for theirs and no limitation says so, though the requested slice's own "Entitlements: …" or "unavailable because codesign reported it unsigned" note is present. A one-line "entitlements of the other slices were not compared" limitation would close it. Leaving it for the maintainers to decide, as with the other open design items on this PR; happy to add it if wanted.

@Ambar-13

ghost commented Oct 24, 2026

Copy link
Copy Markdown
Author

Closing: #4293 was fixed on main by 2721650 with a different boundary (the result describes the requested architecture; other slices are not described), and the filer verified and closed it. Thanks CassieFox23 for the review time. One note for whoever touches this next: with -a, codesign prints Format=Mach-O thin () even for a universal file (try codesign -d -a arm64e --verbose=1 /usr/bin/true), so the probe loop in main that reads slice names from the Format line finds no other slices on a real universal binary; lipo -archs gives the names.

@Ambar-13 Ambar-13 closed this Oct 24, 2026
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Universal Mach-O signatures report one slice as the whole file

3 participants