Skip to content

Pendant app shell: pair and signed writes - #11

Merged
VirtualMachinist merged 30 commits into
mainfrom
feat/pendant-shell
Nov 14, 2026
Merged

VirtualMachinist merged 30 commits into
mainfrom
feat/pendant-shell

Conversation

@VirtualMachinist

Copy link
Copy Markdown
Member

Summary

Pendant app shell, pair and write (pack 2a, G2). The nsh app pairs through the tailnet proxy, signs every write with a biometric-gated device key, and sends prompt, Approve, Deny and worktree create to a scratch session. A host revoke refuses the next write.

  • Device keys: app/src/platform/keystore.rs.
    • iOS device builds keep the Secure Enclave path only.
    • The aarch64-apple-ios-sim target alone gets a Keychain P-256 key with a biometric access control, plus a LocalAuthentication check before each signature. Its entitlements come from sim-entitlements.plist, sim target only.
    • Android gets an Android Keystore P-256 key that needs a strong biometric on each use, through BiometricPrompt. The callback is Java source (app/android/PendantKey.java), compiled to dex by build.rs only for Android and loaded in memory.
  • Manifest: add-biometric-permission.py adds exactly USE_BIOMETRIC, because nsh 0.5.0 writes a fixed manifest template. It fails unless the aapt2 permission dump gains exactly that one entry.
  • Pairing and writes: app/src/net/pair.rs and live.rs.
    • Pairing takes a payload from paste or a pendant://pair link.
    • Every pairing creates a fresh device key, so a revoked id never returns.
    • A grant is opened with one biometric, and each write is signed with another.
    • An unpaired or revoked reply drops the pairing and closes the grant.
    • The paired id is kept in a file in the app data dir, because nsh 0.5.0 keeps storage in memory on iOS.
  • Screens: app/src/agents/.
    • A pairing screen and an unpaired banner.
    • A prompt field, a sticky Approve/Deny bar with a confirm before Deny, and worktree create with a branch field.
    • Write errors are shown on screen.
    • Detached tasks outlive the page, and bottom controls pad by the system inset.
  • Bridge: /v1/pair logs one info line with via_serve and forwarded as presence booleans only. A test asserts that no header value appears in it.
  • Scratch session: scripts/scratch/ runs a fixture agent in each pane (no model, no network) so herdr accepts prompts and keys. It has a made-up git repo for worktrees, and session names are guarded.

Not changed

  • No direct tokio or reqwest, and no tokio in app/src.
  • Takeover stays off. Prompt and keys go through herdr's agent API only; there is no fallback to raw pane input.

Test plan

  • CI: check (workspace and app cargo deny), banned-names, cargo-deny
  • App fmt, clippy with warnings denied on host, sim and Android, and tests on the build host
  • aarch64-apple-ios build has no software-key symbol
  • Sim and emulator: pair through the proxy, then grant, prompt, Approve, Deny and worktree create, each visible in the scratch session
  • Host revoke: the next write is refused and the app shows unpaired

🤖 Generated with Claude Code

VirtualMachinist and others added 30 commits November 14, 2026 11:37
Worktree create needs a repository, and the scratch workspace sat in /tmp with
none. seed.sh now creates /tmp/pendant-scratch-repo (one fixture file, one
commit, a scratch identity) and starts the workspace there, so worktree.create
and worktree.list resolve a repo. Fixture content only.
net/pair.rs speaks the bridge's pairing protocol:

- Payload parses pendant-pair:v1:<32 hex> and never prints the nonce.
- pair signs pendant-pair:v1 over the device id, public key and nonce;
  open_grant signs pendant-grant:v1 over a fresh challenge.
- prompt, approve/deny and worktree create each take their own
  challenge and sign pendant-sign:v1, sent in the x-pendant-device,
  x-pendant-signature and x-pendant-challenge headers. The worktree body
  is the bridge's CreateWorktree in its field order, since the bridge
  signs its own re-serialization.
- The device id derives from the public key. Every signature runs on a
  worker thread, because the device key asks for a biometric each time.

net::live::Live gains pairing (Unpaired, Pairing, Paired) and
grant_until signals and the calls the screens make: pair / pair_with,
open_grant, prompt, approve, deny and worktree_create. A refusal that
says unpaired or revoked drops the stored pairing and shows the app as
unpaired; a grant refusal closes the grant.

lib.rs adds Route::Pair, reached by PENDANT_START=pair or a
pendant://pair?code=<payload> link (nsh.json claims the pendant scheme).
agents::pairing is a placeholder page for the screens to replace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The simulator has no Secure Enclave, so for target_abi = "sim" only the
device key is a Keychain P-256 key with the BiometryCurrentSet access
control. Device targets keep the Secure Enclave key as their only stored
protection: the simulator variant, its constants and its dependencies
are compiled for the simulator target alone.

- The simulator reads entitlements from the executable's
  __TEXT,__entitlements section, as Xcode links them; an ad hoc
  signature carrying keychain groups is refused at launch. The key code
  embeds sim-entitlements.plist (an application identifier and a
  keychain group under it) there.
- The simulator's Keychain signed with the key without asking for Face
  ID, so on the simulator each signature first passes LocalAuthentication
  (deviceOwnerAuthenticationWithBiometrics) with the signature's reason.
- nsh.json adds NSFaceIDUsageDescription.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
keystore.rs gets an Android implementation in place of Unsupported: an
AndroidKeyStore P-256 key that needs a strong biometric for every use
(timeout 0, invalidated by a new enrollment), and signs only after a
BiometricPrompt match bound to the signature through a CryptoObject.

- android/PendantKey.java holds the Keystore and BiometricPrompt calls,
  since the prompt needs a subclass of its AuthenticationCallback and
  nsh 0.5.0 has no hook for an app's Java. build.rs compiles it to dex
  with javac and d8 for Android builds only (nothing for other targets,
  so a host build needs no JDK); no dex, class or jar is committed.
- The library embeds that dex and loads it once with
  InMemoryDexClassLoader under the app's class loader, finding the VM
  with JNI_GetCreatedJavaVMs. Nothing is fetched at run time.
- android/add-biometric-permission.py adds the one permission
  BiometricPrompt requires, USE_BIOMETRIC, to the manifest nsh packaged,
  then zipaligns and re-signs with the same local debug key using SDK
  build-tools. It fails unless aapt2 shows that permission as the only
  change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pairing had no request log, so a proxied pair could not be evidenced. The
handler now logs method, path, via_serve and forwarded (presence of a
Forwarding or X-Forwarded-For header) as booleans and fixed strings only: no
header value, address, nonce, device id or key. A test captures the emitted
line and asserts none of those values appear.
The iOS runner of nsh 0.5.0 keeps nsh Storage in memory only, so the
paired device id was gone after a relaunch and the app showed itself
unpaired. The id (not a secret; the key stays in the Keychain or
Keystore) now goes in a small file in the app's data directory: nsh's
data_dir when the host sets one, else the platform's per-app place
(Application Support in the iOS container, the package's files
directory on Android). It is written beside and renamed into place, and
read back only when it is a well-formed device id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A UI test launches the app without keeping its stderr, so the pairing
and write lines were lost on the simulator. trace() on iOS now also
writes each line to syslog, which the unified log keeps (log stream /
log show). The lines carry no payload, key or signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
open_grant and each write now log a "requesting" line first, and
open_grant logs its refusal, so a device log tells a call that never
started from one refused before the biometric (not paired here, no
challenge). The lines name the call and the agent only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
herdr only prompts a pane whose foreground process matches a known harness, so
scripted reported agents could not be prompted or sent keys. Each pane now runs
agent.sh: a bash fixture, no model, no network, no tokens, which reads input,
prints PENDANT-SCRATCH-INPUT, shows an approve bar with a decision line on the
blocked pane, and keeps re-reporting its state.

seed.sh makes a fresh mktemp dir holding one symlink to agent.sh named after a
supported agent, prepends only that dir inside the pane's env -i PATH, waits for
detection and renames the agents scratch-<n>. teardown.sh removes the dir. No
fixture file is named after a harness in the repo.
Reports now carry the detected agent label; a foreign label stops herdr from
treating the pane as a promptable agent, so the seed no longer renames agents.
The agent reads single keys in non-canonical mode, so the approve bar reacts to
y and n without an Enter, and a buffered line with no newline is reported on the
next idle tick so a prompt still shows up.

Verified on the scratch session: agent prompt on w1:p3 prints
PENDANT-SCRATCH-INPUT, agent send-keys y/n on w1:p2 print the decision lines,
pane text is fixture-only, and /v1/snapshot still shows four agents, one blocked.
net::live::spawn_detached (and Live::spawn_detached) runs a future under
the root owner the live link was started in, the scope whose tasks are
known to run, and keeps its task handle until the future ends, since
dropping an nsh task handle cancels the task. A write started from a
page can use it so leaving the page does not cancel the write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
detached_write and detached_pair made their task under a fresh
create_root; under the engine that task was never polled (the press and
its handler fired, but the write's first line never ran), so busy stayed
set and every write button stayed disabled. Both now hand the task to
net::live::spawn_detached, which runs it under the app root and keeps
its handle until it ends; detached_write still settles only while its
page lives. The press and layout traces stay as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The live link's start now traces "build <sha>" from PENDANT_BUILD_SHA,
given at build time ("dev" when unset), so a device run's log names the
exact app it tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pair() reused the stored key, so after a host revoke a new payload
paired the revoked device id again and the bridge refused it. A pairing
now deletes any stored key and creates a new one first: each pairing is
a new device identity, and a revoked key never comes back. The pair page
is only reached while unpaired, so no live pairing is lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@VirtualMachinist
VirtualMachinist merged commit 8ce0db5 into main Nov 14, 2026
3 checks passed
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