Skip to content

iPhone: retire Approve Requests and Stop Approving (#342) - #354

Merged
sudoHG merged 2 commits into
mainfrom
sudoHG/quizzical-sanderson-cf69ad
Nov 16, 2026
Merged

sudoHG merged 2 commits into
mainfrom
sudoHG/quizzical-sanderson-cf69ad

Conversation

@sudoHG

@sudoHG sudoHG commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #342

Summary

Pairing makes the iPhone an approver (ADR 0014, amendment for #336), so the iPhone app retires Approve Requests from This Mac, Enter a New Approval Code and Stop Approving for This Mac. Removed: ApproverConfirmationFlow, ApproverProblem, startApproverConfirmation, closeApproverConfirmation, confirmApprover, confirmationSaved, stopApproving, approverConfirmation, the outbox's confirmation purpose (OutgoingMessage now carries only a receipt's request), revocationCount (its only reader was confirmationSaved), Views/ApproverConfirmationView.swift, and the approver.*, mac.approve*, mac.stop* and list.approver strings (22 keys).

Mac detail now shows a status line, Rename and Remove. A flagged Mac says this iPhone can approve agents' requests to use credentials on it; an entry without the flag (a pre-#336 pairing) says to remove the Mac and pair it again, and only such a row is marked on the list. Remove's confirmation says this iPhone stops at once, drops the pending requests and tells the Mac, which stops trusting this iPhone only when it next checks, so ending approval on the Mac at once means removing the iPhone there too (decision 3). removeMac now revokes the pairing and drops its requests, decisions, receipts and notifications before its first suspension, as the retired Stop Approving did (the removal hook does it again before the list write), and returns whether the Mac was removed. A Mac whose removal failed shows as not approving until it is removed or the app restarts, and the detail screen, which stays open, says the removal failed.

The .confirmation arm of handleApproval stays: kind 14 and ApprovalMessage.confirmation are #343's.

Strings (maintainer approves the wording from the renders)

Key English 简体中文
mac.status.approving (changed) This iPhone can approve agents' requests to use credentials on this Mac. Allowing always needs Face ID or Touch ID. 这台 iPhone 可以审批 Agent 使用这台 Mac 上凭证的请求。允许时始终需要面容 ID 或触控 ID。
mac.status.notApproving (changed) This iPhone can't approve agents' requests to use credentials on this Mac. To approve them, remove this Mac and pair it again. 这台 iPhone 不能审批 Agent 使用这台 Mac 上凭证的请求。如需审批,请移除这台 Mac 后重新配对。
list.remove.confirmMessage (changed) This iPhone stops approving this Mac's requests at once and drops the pending ones. Ask Key also tells the Mac, which stops trusting this iPhone only when it receives that notice; until then, a decision already sent can still apply. To end approval on the Mac at once, remove this iPhone there too. 这台 iPhone 会立即停止审批这台 Mac 的请求,并丢弃待处理的请求。请旨也会通知 Mac,Mac 收到通知后才会不再信任这台 iPhone,在此之前已发出的决定仍可能生效。如需立即在 Mac 上结束审批,请也在 Mac 上的请旨中移除这台 iPhone。
list.notApprover (new) Can't approve its requests. Remove it and pair again. 不能审批它的请求。请移除后重新配对。

Renders (askkey-ios-screens, each -en and -zh-Hans)

  • 34-mac-detail-approving
  • 35-mac-detail-without-approval-flag
  • 36-mac-detail-remove-confirmation: iOS draws confirmationDialog itself and ImageRenderer cannot capture it, so the test lays out the dialog's own texts (MacRemovalText, shared with the real dialog) as an action sheet over the detail screen.
  • 37-mac-detail-rename-and-removal-failed (a failed removal leaves the entry, which this process refuses)
  • Updated: 11-paired-macs-one-mac and 12-paired-macs-reached (flagged rows, unmarked), 15-requests-home (the second Mac has no flag and is the only marked row).
  • Dropped: 34-mac-detail-not-approving, 35-mac-detail-approving, 36–39-approver-confirmation*.

Diff stat

20 files changed, 323 insertions(+), 924 deletions(-), all under iOS/AskKeyiOSKit and iOS/AskKeyiOSKitTests; the catalog accounts for most of the deletions.

Tests

bash scripts/build-ios.sh test (local, iPhone simulator, head b778f99): AskKeyiOSKitTests 163 passed, 0 failed (main after #341: 163); AskKeyiOSNotificationServiceTests 44 passed, 0 failed; 88 screens rendered (main: 92). With the early revocation in removeMac removed, testRemovalStopsThisIPhoneBeforeTheMessengerReadsTheList fails (the stored decision is sent again), so the test covers the fix.

  • Removed (7): the four approver confirmation tests and testStopApprovingClearsTheFlagAndDropsTheMacsCards in ApproverTests; testStopApprovingReportsAFlagThatCouldNotBeCleared and testAnAccountChangeWhileAConfirmationIsSendingResetsTheSheet in ApprovalRaceTests; plus ScreenRenderTests.testApproverConfirmation.
  • Added (8): ApprovalRaceTests.testRemovalStopsThisIPhoneBeforeTheMessengerReadsTheList, testRemovingTheMacDropsItsUnsentReceipts; ApproverTests.testPairingIsAllItTakesToApproveTheMacsRequests, testAMacPairedBeforeTheRuleWithoutApprovalIsMarkedAndRefused, testPairingAMacWithoutTheFlagAgainMakesThisIPhoneApproveIt, testRemovingTheMacStopsThisIPhoneAtOnceAndTellsTheMac (the Mac keeps its entry until it polls the unpair notice), testARemovalWhoseListWriteFailsStillStopsThisIPhone (stored request, notification, the row's status, retry); LocalizationTests.testNoRetiredApproverStringRemains (both tables).
  • Converted from Stop Approving to removal: ApprovalRaceTests.testRemovingTheMacDuringASendKeepsTheNextStoredDecisionFromLeaving, ApprovalDecisionTests.testAMacRemovedDuringThePromptGetsNothing, OpenedRequestTests.testARequestFromARemovedMacShowsUnavailable and testRemovingTheMacDuringTheFetchKeepsTheRequestFromBecomingACard.
  • TestWorld.approveMac, pairAndApprove and approverCode are gone; tests rely on pairing. TestWorld.storeWithoutApprovalFlag(_:) stays for the tests of a Mac without the flag (ApprovalRequestTests, OpenedRequestTests, ApproverTests); its calls in ApproverTests.setUp are gone.

Checks

  • python3 scripts/check_hygiene.py: passed (size=0, test-support=0, debug=0, local-path=0, non-ascii-name=0, multica=0, cjk=0).
  • The catalog check in build-ios.sh passed; a scan finds no catalog key unused by the kit's sources.
  • CI: see the checks on this PR.

Deviations and questions

  • App/AppStates.swift (doc comment of PairedMacRow.isApprover) and Fakes/TestWorld.swift (a comment) are touched beyond the ADR's file list; both are comment-only.
  • The removal-failed notice on Mac detail is new; it replaces mac.stop.failed and reuses list.notice.removalFailed.
  • From the cross review: removeMac revokes before it waits and returns its outcome, and rows reflect an in-process revocation (see the review comment).
  • Not touched, as scoped: AskKeyDevices (AskKeyDevices: reserve kind 14 and remove the approver code #343), the extension's NotificationProcessor.swift, and the tabs (Give the iPhone app Requests, History and Macs tabs #346).

Pairing makes the iPhone an approver (ADR 0014, amended by #336), so the
iPhone app drops the approver confirmation flow (ApproverConfirmationFlow,
startApproverConfirmation, confirmApprover, confirmationSaved and its
screen), Stop Approving for This Mac, the outbox's confirmation purpose and
revocationCount, whose only reader was confirmationSaved.

Mac detail shows a status line, Rename and Remove. A Mac paired before
#336 without the flag says to remove it and pair again, and only such a row
is marked on the list. Remove's confirmation says this iPhone stops at
once, drops the pending requests and tells the Mac, which stops trusting
the iPhone only when it processes the unpair notice. A removal whose list
write fails is reported on the detail screen.

Tests replace Stop Approving with removal in the race tests and cover the
status, re-pairing a Mac without the flag and a failed removal. Renders
add the Mac detail states and the removal confirmation and drop the
approver screens.
Cross review of #354 found that removeMac revoked the pairing only in the
removal hook, after the messenger's list reads, so a stored decision due
for resend could still leave in between. removeMac now revokes the pairing
and drops its requests before the first suspension, as the retired Stop
Approving did; the hook does the same again.

- Remove's confirmation says the Mac stops trusting this iPhone only when
  it receives the unpair notice, and that an earlier decision can apply
  until then.
- Mac rows reflect an in-process revocation, so a removal whose list write
  failed no longer shows the Mac as approving.
- removeMac returns whether the Mac was removed; the detail screen no
  longer reads the shared list notice, and a failed removal no longer hides
  a later unpair notice from that Mac.
- Tests for the early revocation, unsent receipts on removal, the failed
  removal's status, and the Chinese table's retired term.
@luoji-bot

luoji-bot Bot commented Nov 15, 2026

Copy link
Copy Markdown

Cross adversarial review (#342)

Reviewers: GPT-6 Astra (xhigh) and Opus 5.5 (xhigh), read-only, two rounds each (round 2: each ruled on the other's report). Baseline e5ed7c0. Neither found a P0, any remnant of the approver code, approver confirmation or Stop Approving path, authority for an entry without the flag, or a claim that a fake Mac on the list is genuine.

Fixed in b778f99

  1. Decisions could still leave between Remove and the removal hook (Astra P1, Opus P2 in round 2; both must-fix). removeMac only marked the Mac locally removed before awaiting the messenger, which revokes the pairing in the hook after two list reads; a stored decision due for resend could go out in that window. The retired stopApproving revoked before any suspension. removeMac now revokes the pairing and drops its requests, decisions, receipts and notifications before the first await (revoke(_:), shared with the hook, idempotent). Test: ApprovalRaceTests.testRemovalStopsThisIPhoneBeforeTheMessengerReadsTheList (the messenger fails at the list read, so only the early revocation can stop the resend).
  2. Remove's copy promised the Mac stops trusting the iPhone "when it next checks" (both, P2, must-fix). A deleted or lost unpair notice leaves the Mac trusting the iPhone after it checks. Now: "…which stops trusting this iPhone only when it receives that notice; until then, a decision already sent can still apply. To end approval on the Mac at once, remove this iPhone there too." (zh: "…Mac 收到通知后才会不再信任这台 iPhone,在此之前已发出的决定仍可能生效。…")
  3. After a removal whose list write failed, Mac detail still said this iPhone can approve (both, P2). Rows now reflect the in-process revocation (PairedMacRow(_:revoked:)), so the entry shows the unflagged status until it is removed or the app restarts. Test: ApproverTests.testARemovalWhoseListWriteFailsStillStopsThisIPhone now starts with a stored request and a delivered notification and checks the row. Render 37 shows that state.
  4. Mac detail read the removal outcome from the shared listNotice (Opus P3, Astra P2). removeMac now returns whether the Mac was removed; a failed removal no longer keeps the Mac in locallyRemoved, so a later unpair notice from that Mac is reported.
  5. Tests added from the coverage findings: ApprovalRaceTests.testRemovingTheMacDropsItsUnsentReceipts; LocalizationTests.testNoRetiredApproverStringRemains also checks the Chinese table for the approver-code term. The two status lines now use the same phrasing.

Declined

  • Separate Remove wording for an entry without the flag (Opus P3): such entries exist only in development and test pairings made before Amend ADR 0014: pairing an iPhone makes it an approver #336, which ADR 0014's Migration says to remove anyway.
  • Green shield on the approving status as a trust badge for a fake Mac (Opus P3; Astra ruled it invalid): the line states this iPhone's capability, not the Mac's authenticity, and the visual style is kept for Give the iPhone app Requests, History and Macs tabs #346/Decide requests on a full-screen request page #347.
  • A test of a local removal racing the same Mac's unpair notice (.unknownDevice): that path is unchanged by this PR.
  • The extension still shows detailed notifications for a Mac whose removal failed, until it is removed: it needs a keychain write failure, and NotificationProcessor.swift is out of scope.

Review directories deleted.

@sudoHG
sudoHG merged commit ed5326e into main Nov 16, 2026
4 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.

iPhone: retire Approve Requests from This Mac and Stop Approving

1 participant