fix biometric session scoping for non-TTY processes#675
Merged
Conversation
When varlock is invoked from processes without a controlling TTY (e.g., Claude Code or other extensions in VSCode/Cursor), the daemon had no stable identity to cache the biometric session against, causing Touch ID prompts on every single decrypt call. Fix by walking the process tree when no TTY is available and using the "grandchild of the app root" as the session scope key. This picks a stable ancestor that is narrow enough to prevent cross-extension piggyback (e.g., the Claude binary PID) while being shared across all commands spawned by that tool. Algorithm: 1. Build ancestry chain from peer PID up to the app root (PPID=1) 2. Use the process at chain[count-3] (grandchild of app root) + start time 3. If tree is too shallow (<4 levels), return nil (no caching, safe default) Also applies the same logic to the WSL fallback path in the Node.js client.
061b080 to
e8db843
Compare
Contributor
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
…back The core bug: dev_t is Int32 on macOS, so NODEV is -1. Comparing Int32(-1) != UInt32.max evaluates to true in Swift's BinaryInteger, causing hasTty to always be true for no-TTY processes. The TTY code path then fails at devname() and returns nil, never reaching the ptree fallback. Fixed by using ttyDev > 0. Also renames ttyId to sessionId throughout Swift/Rust/TS since it now represents either a TTY or process-tree session identifier. Adds ptree fallback to the Rust Linux daemon (mirrors the macOS Swift logic), and includes start time in the WSL self-reported ptree key for PID-reuse resistance. Adds unit tests for the Rust proc-stat parsing and ptree walk.
- Add 30s timeout to sendMessage (5min for interactive biometric/picker) - Add withRetry wrapper: auto-reconnect and retry on timeout/disconnect - Add killDaemonProcess with SIGTERM→SIGKILL escalation, handles unkillable UE-state zombies - Verify socket responsiveness in spawnDaemon instead of blindly trusting PID - Reject all pending messages on socket close so callers don't hang - Add forceCleanup to kill daemon + remove stale files before respawn
commit: |
- Add 60s timeout to biometric semaphore.wait() in SessionManager - Use _exit() instead of exit() to skip LA framework cleanup hangs - Add BIOMETRIC_TIMEOUT_MS (90s) for decrypt/keychain-get operations - Centralize daemon state file cleanup (including lock file) - Clean stale PID files in checkDaemonBinaryStale when process is dead - Log spawn errors instead of swallowing them silently - Retry flock on fresh inode when lock held by unkillable process
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
patch-isolated/minor-isolateddocs from AGENTS.md.Algorithm
chain[count-3](grandchild of app root) + start time as session keyExample for Claude in Cursor:
Test plan
tty:)