Skip to content

Keep native fingerprint presentation across system sleep - #14

Closed
watli01 wants to merge 1 commit into
macintog:mainfrom
watli01:perf/resume-presentation-cache
Closed

watli01 wants to merge 1 commit into
macintog:mainfrom
watli01:perf/resume-presentation-cache

Conversation

@watli01

@watli01 watli01 commented Oct 27, 2026

Copy link
Copy Markdown

What changed

T2Backend.system_sleep_changed() used to call invalidate_inventory("system_sleep") on both sleep edges. That dropped the cached native presentation projection, so the resume warmup (already started on logind PrepareForSleep(false)) had to repeat the full hardware inventory before it could prepare the verifier. That inventory runs its own AKS/ACM authorization, Bridge inventory and Catacomb restore. The inventory collector and the match worker both take /run/t2-touchid/operation.lock with LOCK_NB and both open AKS/ACM, so the two steps can only run one after the other. On the reference machine that cost about 2 s of the time from resume to the lock-screen prompt.

The sleep edge now only advances inventory_generation. A read that straddles the edge still cannot publish, and a completed native projection is kept. Nothing else changes:

  • runtime_projection() still checks the account-authority token and the committed Catacomb / mutation-journal state token before any reuse.
  • Compatibility authority still never caches.
  • Native matching still repeats per-user and global SEP inventory reconciliation, reloads the committed Catacomb and post-attests. A match failure still invalidates the cache.
  • Verifier preparation (retained AKS keybag and ACM contexts) is still released on sleep and rebuilt after resume. No authorization state crosses a suspend.

This matches the existing contract in docs/FPRINT_INTEGRATION.md §1: presentation metadata may stay cached while authority, Catacomb and journal metadata are unchanged. That section now also says explicitly how sleep is handled.

Measurements

MacBookPro16,1, Linux 7.2.11-arch1-Watanare-T2-1-t2-amdoff, deep sleep started by a lid close, timed from user.slice thaw. Full table in docs/evaluations/touchid-resume-presentation-cache-2026-10-27.md.

Before (3 resumes, preceding boot) After (1 resume)
Thaw → "Place your finger" prompt 4.34 / 4.44 / 4.52 s 2.42 s
Inventory on resume path collected, 2.10–2.25 s cached, 0.0 ms
Verifier preparation starts +2.11–2.30 s +0.044 s

The verifier's AKS phases did not change (keybag retain, ACM context authorization, identity unlock). There is only one candidate resume, so this is not a latency distribution.

Review notes

  • Requirement served: Touch ID readiness after resume (fprintd integration). No new files, settings or installed artifacts. Upgrade, failure and removal behave as before.
  • Hardware risk level: low. The change is a daemon-side cache-lifetime rule. Nothing changes in the transport, protocol, PAM, polkit or the enrollment/deletion paths.
  • User-visible failure mode: if the T2 transport is unusable after resume, fingerprint unlock now fails at VerifyStart instead of at ListEnrolledFingers. Both fail closed, and password fallback is unchanged.
  • Recovery: reinstall the previous src/t2-fprintd.py and restart fprintd.
  • External problems: the machine carried local, out-of-tree platform resume repairs (kernel, ACPI and Wi-Fi/Thunderbolt sleep hooks). They are not part of T2Touch and are not imported here. Suspend/resume remains unqualified, per docs/SLEEP_POLICY.md.

Tests

  • New tests in tests/test_t2_fprintd.py:
    • the cache is reused across sleep only while the tokens match;
    • an authority change across sleep forces a refresh;
    • a collection that straddles sleep does not publish;
    • the resume warmup prepares the worker without collecting again.
  • The existing sleep test is updated to the new contract.
  • The new behaviour tests fail against main.
  • Full suite: python -m unittest discover -s tests, 1654 tests OK (1 skipped).
  • tools/privacy-check.sh and enrollment_research/scripts/check-public-tree.sh pass.
  • Hardware: one lid-close resume on the reference machine. The match attested, PAM succeeded and the session unlocked.
  • Not exercised: negative control, enrollment, deletion, password fallback, other hardware.

🤖 Generated with Claude Code

system_sleep_changed() discarded the cached native projection on both
sleep edges, so the resume warmup repeated the full hardware inventory
(its own AKS/ACM authorization, Bridge inventory and Catacomb restore)
before it could prepare the verifier. Both take the machine-wide
operation lock without blocking, so they could only run in sequence.

The sleep edge now only advances the inventory generation, so a read
straddling it cannot publish, and keeps a completed native projection.
runtime_projection() still rechecks the authority and Catacomb/journal
state tokens before reuse, native matching still repeats live SEP
inventory reconciliation and attestation, and verifier preparation is
still released on sleep.

On the MacBookPro16,1 reference machine one lid-close resume reached the
lock-screen fingerprint prompt 2.42 s after thaw, versus 4.34-4.52 s for
the three preceding resumes on the old code.

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

Copy link
Copy Markdown
Owner

Thanks for this, and for measuring it: on your MacBookPro16,1, the time from resume to the prompt went from about 4.4 s (three resumes before) to 2.4 s (one resume after). We're closing it as superseded, because t2-fprintd is going away. T2Touch is moving its Touch ID support into Omarchy itself, on stock fprintd with a libfprint driver.

Resume time matters there too, and we've recorded your result and evaluation for that work, with credit. When that path is ready to test on a 16,1, we'd like to ask you to measure it.

@macintog macintog closed this Oct 28, 2026
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.

2 participants