acpmux: a peer counts an enrolled Mac's signed one-time Allow (peer-route approvals 1/3)
Peer-route approvals, part 1 of 3: the daemon side.
The problem. A chat opened through a peer (acpmux new --host, cmux agent open-tab --host, --group with --host) shows its tool prompts on the Mac, but the Mac can never approve one from the card. The Allow reaches the peer through the Mac's own daemon, the peer's person gate wants the person's proof, and the app has no key bound for that machine. The card says "Remote approvals are off" and offers no way to turn them on.
The fix. An enrolled Mac's own P-256 key signs a one-time Allow, and the peer checks the signature against the key it has on file. The private key never leaves the Mac. Only the signed answer crosses the peer link.
This PR adds the peer's half:
hub/mac_approvers.rsreads the Macs that may allow fromACPMUX_HOME/mac-approvers.json, in the form{"macs":[{id, publicKey, name}]}.- No RPC writes that file.
acpmux host approvals addwrites it (part 2), so an agent that can only reach the daemon's socket cannot enroll a key. - The daemon reads it as private state: a symlink, or a file that others may write, enrolls no Mac.
- No RPC writes that file.
- The Mac's
permission_respondcarries_meta.acpmux = {decisionNonce, approverDecision: {approver, expiresAt, signature}}. This is the phone approvers' shape, under a domain of its own:acpmux-mac-approver-decision-v1. - The person gate's approver path checks the phone approvers or an enrolled Mac. The nonce is spent inside the Mac set's lock.
_acpmux/mac_approver_set {id, publicKey, name}: the app gives the daemon this Mac's own public key. Only the person may call it, and the daemon keeps the key in memory only.host enroll(part 2) reads it._acpmux/mac_approvers {reload?}: lists the enrolled Macs and this Mac's own key. It is refused for Web and peer origins.- The new methods are in
spec/acpmux-protocol.jsonand the generatedmethods.ts.
Part 2 adds acpmux host approvals and the step in host enroll that enrolls the Mac's key. Part 3 makes the app sign and adds the card hint.
The five conditions from the brief
- The proof binds session, prompt, tool-call id and decision, with a short expiry, and is single-use. The Mac signs this message: the domain, then, each after a NUL, the daemon run (
personInstance), the Mac id, the session, the permission id,toolCall.toolCallId, the option, the prompt'sdecisionNonce,expiresAt, and the digest of any answers.expiresAtmust fall between now and now + 300 s.- The nonce is spent in the person gate's spent-nonce store, inside
commit. - Tests:
a_macs_signature_counts_for_its_one_time_allow_and_every_change_failschanges each bound part in turn. In the integration test, a replay of the same signature on the next prompt is refused.
- A one-time allow only, never upgraded to always or session, and the mode never changes.
may_allowaccepts only an option offered exactly once whose kind isallow_once, on a plain tool ask or an agent question.- It never accepts
switch_mode, a folder-trust card, orExitPlanMode. - Tests:
a_mac_never_allows_a_plan_a_mode_switch_or_a_folder_trust, plus the signedalwayscase refused in the test above. The integration test checks that the peer's policy and modes are unchanged afterwards.
- It never accepts
- An unsigned Allow is still refused, and a Deny from any client still counts. The person gate is unchanged for answers without a proof. In the integration test, an unsigned Allow from the person on A is refused, and a deny relayed from A counts.
- Unenrolling the Mac's key stops its Allows at once.
host approvals rmrewrites the file, then calls_acpmux/mac_approvers {reload:true}.- The reload takes the set's lock, so it returns only after any answer being committed finishes. Every check after that refuses.
- A hand edit counts on the next check, through the file's (len, mtime) stamp.
- Tests:
removing_a_mac_from_the_file_stops_its_signatures,a_reload_during_a_commit_waits_for_it_and_then_the_signature_counts_nothing, and the last leg of the integration test.
- The key stays where another agent on the Mac can't sign with it. Nothing in this PR holds a private key. The daemon sees only public keys. Part 3 keeps the Mac's key in the Secure Enclave under the app's keychain access.
Tests (they fail before the fix and pass after)
They ran remotely through cmux-ci test (32 vCPU Linux).
Before: the Mac check is taken out (verifies_then returns false), which is what base does, since base has no Mac check.
test hub::mac_approvers::tests::removing_a_mac_from_the_file_stops_its_signatures ... FAILED
test hub::mac_approvers::tests::a_macs_signature_counts_for_its_one_time_allow_and_every_change_fails ... FAILED
test hub::mac_approvers::tests::a_macs_signed_answer_covers_exactly_its_answers ... FAILED
test hub::mac_approvers::tests::a_reload_during_a_commit_waits_for_it_and_then_the_signature_counts_nothing ... FAILED
test a_peer_counts_an_enrolled_macs_signed_one_time_allow_until_it_is_unenrolled ... FAILED
After:
test hub::mac_approvers::tests::a_mac_never_allows_a_plan_a_mode_switch_or_a_folder_trust ... ok
test hub::mac_approvers::tests::the_wire_payload_is_fixed ... ok
test hub::mac_approvers::tests::only_a_valid_key_is_this_machines_own ... ok
test hub::mac_approvers::tests::a_file_others_may_write_enrolls_no_mac ... ok
test hub::mac_approvers::tests::a_macs_signed_answer_covers_exactly_its_answers ... ok
test hub::mac_approvers::tests::removing_a_mac_from_the_file_stops_its_signatures ... ok
test hub::mac_approvers::tests::a_macs_signature_counts_for_its_one_time_allow_and_every_change_fails ... ok
test hub::mac_approvers::tests::a_reload_during_a_commit_waits_for_it_and_then_the_signature_counts_nothing ... ok
test a_peer_counts_an_enrolled_macs_signed_one_time_allow_until_it_is_unenrolled ... ok
peer_integration: 49 passed; person_allow: 25 passed; protocol_ir_is_current ok; clippy -D warnings clean
No capture: the only webview path is the generated protocol method list (methods.ts, two new method names); nothing on screen changes. Part 3 (the app) carries the before/after card captures.
Risk. This is a second way to prove the person on a peer. It is limited to one-time allows of plain tool asks and questions. It is off until a Mac is enrolled in a file that only this user can write.
Agent session: agent session
🤖 Generated with Claude Code