Skip to content

fix: low-level crates (review P0-C) - #198

Merged
Derrors merged 2 commits into
mainfrom
fix/p0-low-level
Nov 25, 2026
Merged

Derrors merged 2 commits into
mainfrom
fix/p0-low-level

Conversation

@Derrors

@Derrors Derrors commented Nov 25, 2026

Copy link
Copy Markdown
Owner

What and why

P0, third batch, from the full review of main after #195: the low-level crates.

  • ictl-ax archive (H6): only a depth limit guarded the NSKeyedArchiver decoder, so objects sharing children level after level (2^60 values from a few hundred bytes) or referring back to themselves kept the daemon decoding. Now an object that refers back to one being decoded reads as null, and an archive may decode to at most 8 values per byte (at least 10,000), past which it is refused as malformed. Real archives stay far below: each reference takes at least a byte.

  • HID entry points (H7): a duration that isn't finite panicked in Duration::from_secs_f64; a NaN point or a screen size of 0 was mapped to (0,0). Points, the screen size and durations that aren't finite (or a size ≤ 0) are refused with InvalidInput; durations are capped at 0–60 s (map_point, gesture_time).

  • Log stream (review item 6): log_stream asked for historical entries too. The WDA runner could take a past "Enabling Automation Mode" for a prompt now, and app_logs stamps entries with their arrival time, so old lines showed as just logged. Now oslog::flags::LIVE. Connecting to remoteAXService's port has a time limit too; a timeout there is the tunnel's (Timeout), not axauditd's (AxUnanswered).

  • ictl-sign (H9): the account directory is 0700, so the 0644 files inside weren't open to other users. Still:

    • login locks the tree down after writing the session;
    • sign_in does so as soon as a new certificate's key is written, and sign_ipa again even when signing failed;
    • the scratch directory is a WorkDir guard, removed also when a caller's timeout drops the future;
    • pack and from_app_zip write a temporary file beside the target, fsync it and rename it into place;
    • add_dir streams files with io::copy.

    The daemon already ran signing in spawn_blocking under RESIGN_TIMEOUT and renamed into place itself, so the sync work and the missing network timeout were covered there.

  • vt.rs (macOS) (H3): Decoder::decode held &mut DecodedSlot across VTDecompressionSessionDecodeFrame/WaitForAsynchronousFrames while on_decoded made another &mut to it. Now there are only short accesses through the raw pointer before and after the calls.

  • Touch ID iPad in other languages (H8): only 使用密码 / Use Passcode / Enter Passcode were known, so in another language the prompt after swiping up was CoverSheet::None: locked taken for unlocked, and lock_state_trusted set.

    • cover_sheet now also recognises the prompt by its structure: SBCoverSheetWindow without lockscreen-date-view and with exactly two buttons. The notification center has that window too, but with the date.
    • use_passcode_button, when no label matches: the first of exactly two buttons on one vertical line, unless the lock screen's own identifiers are there (its "press Home to unlock" is a button, with a notification above it on the same line). Taking Cancel by mistake only goes back to the lock screen.

Tests

1. Unit tests

  • cargo test --workspace --all-features --locked: 576 passed; clippy -D warnings; cargo fmt --check for all 11 packages; tests/check_regression_cases.py: 0 missing
  • New: a_cycle_reads_as_null, an_archive_built_to_blow_up_is_refused, only_finite_points_and_durations_reach_the_phone, the_stream_is_live_only, a_failed_pack_leaves_the_old_package, the_scratch_directory_is_removed_when_dropped, a_touch_id_prompt_in_any_language (the three real Touch ID samples translated to German; the iPad lock screen, home screen, notification center and Settings samples not taken for it)
  • No existing test removed, ignored or loosened
  • vt.rs is compiled by the macOS CI job only (no darwin target here)

2. Real-device regression

  • iPhone 15 Pro Max (iPhone16,2) iOS 27.2.1, native control; iPad mini 5 (iPad11,1) iPadOS 26.7.3, WDA, Touch ID, Chinese; Debian 12
  • tests/device/run.py on the iPhone: 16 calls, 0 failed

3. Regression cases

4. Real-device proof

  • iPhone: background-poll stress, 24 actions, 0 failed (all reads go through the archive decoder); lock, then a read: unlocked itself; app_logs fills as before
  • iPad: lock and auto-unlock twice through the Touch ID prompt (16.8 s, 15.6 s)
  • iPad: WDA ended and launched again. The live log stream (no historical entries) reported the runner waiting for the "Enable UI Automation" passcode 5 s after launch. The first attempt then ended "not ready within 120 s", as on earlier builds (event log 11-18, 11-22: the next attempt reports the prompt). The iPad now needs its passcode typed once on the device.
  • Not tried: a Touch ID iPad in another language (no such device; covered by the translated samples); re-signing (the iPad then needs the passcode typed by hand); old log lines replayed with the historical flag (none showed up either way on iOS 27.2.1); macOS

Checklist

  • MCP tool names, parameters and default outputs stay compatible (D10)
  • No new dependencies
  • CHANGELOG.md and CHANGELOG.zh-CN.md (Unreleased)
  • No private data in the outputs above

🤖 Generated with Claude Code

Derrors and others added 2 commits November 25, 2026 20:54
- ictl-ax: an archive object that refers back to itself decodes as null; an
  archive whose shared objects would expand past 8 values a byte is refused
  (a few hundred bytes could ask for 2^60)
- HID: points that aren't finite numbers, an unknown screen size and gesture
  durations that aren't finite are refused (NaN panicked in
  Duration::from_secs_f64 or tapped (0,0)); durations are capped at 60 s
- the phone's log stream no longer asks for historical entries: the WDA runner
  took a past "Enabling Automation Mode" for a prompt now, app_logs stamped old
  lines as new; connecting to the accessibility service's port has a time limit
- ictl-sign: the session and a new private key are locked down as soon as they
  are written; the scratch directory is removed by a guard (also when a caller's
  timeout drops the signing); packages are written to a temporary file and
  renamed into place
- vt.rs (macOS): no `&mut` to the decoder's slot is held across the
  VideoToolbox calls whose callback writes it
- Touch ID lock screen in any language: the prompt is known by its structure
  (SBCoverSheetWindow without the lock screen's date, two buttons), and its
  first button is tapped when the label isn't one we know

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l edges)

- native reads (the screen, the front app) that time out in the tunnel drop it
  and read once more on a new one; a stuck tunnel was kept and timed out every
  read after it
- a touch refused before anything was sent (InvalidInput) no longer tears the
  tunnel down
- Touch ID prompt: the upper of the two buttons, not the first listed; the
  SBCoverSheetWindow name only counts on a window
- archive: a budget used up exactly is enough; UIDs past usize aren't truncated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Derrors
Derrors merged commit 88b2f96 into main Nov 25, 2026
13 of 14 checks passed
@Derrors
Derrors deleted the fix/p0-low-level branch November 25, 2026 13:19
Derrors added a commit that referenced this pull request Nov 25, 2026
…r) (#199)

* test(maintenance): wait for the lock in the pending-journal test

pending_journal_blocks_other_installs_after_lock_owner_dies took the
shared lease right after dropping the exclusive one. Another test that
spawns a process meanwhile holds a copy of the dropped descriptor in the
child until it execs, and the lock with it, so the last shared_in failed
now and then (CI on #188). With a thread spawning `true` in a loop it
failed 37 times in 300.

The test now retries while the lock is held (as once_free does for the
other test in the file), and checks that the first refusal is for the
pending journal, not for the lock: before, a held lock passed that
assertion too. 0 failures in 300 under the same load.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* test(update): make the interrupted-worker test robust and say why it failed

recovers_after_process_death_using_only_durable_records failed now and then
(macOS CI on #198, Linux locally on 2026-11-24): the worker it starts ended
without being killed, and its output went to /dev/null, so why was lost.

- the worker's output goes to a file in the fixture directory and is shown
  when it isn't killed (a file, not a pipe: the fixture daemon it starts keeps
  the descriptor, and reading a pipe to its end would wait for that daemon)
- Store::open is retried while the updater lock is held: another test that
  spawns a process meanwhile keeps a copy of a dropped lock's descriptor in the
  child until it execs, the race fixed for maintenance in the previous commit
- the fixture daemon's spawn is retried on ETXTBSY (text file busy), the same
  race for the script just written, as archive.rs does for the real candidate

Neither race reproduced on Linux (60 runs under a process-spawning thread, 40
full test binaries at 32 threads); the output will tell if it is another cause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant