Repository navigation
Connect approved agent apps when the Agent tab is open (#31) - #34
Conversation
Opening the Agent tab turns draft receipt on unless the user turned it off, and posts a content-free ready signal. Live helpers listen for it and run the normal status/hello/prove exchange again, so approved apps connect without a click or tool call; unreachable apps are retried with backoff. Closing the tab keeps connections. New apps still need one approval. Receipt saved off by an older version stays off with a one-time notice. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
Darwin does not re-export the notify module with the macOS 26.5 SDK, so the app and helper failed to compile. Mechanical fix; no behavior change. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 * (0.8 + 0.4) is 12.000000000000002 in IEEE doubles, so the exact equality precondition trapped. Test-only change. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reload the trust file before every change and when taking the pairing socket, opening the tab, proving or approving, so a revocation or receipt-off saved by another app instance is adopted and never written back over. - Helper listens for the ready signal before its first pairing; signal-driven attempts are limited to one per second with up to 250 ms jitter, and it stops listening after a terminal status. - Post the ready signal also when a vanished helper is found before its exit watcher fires; opening the tab posts it once. - The tab's retry button reconnects as opening the tab does; the Preview window counts as the Agent tab. - Fixture: check that a helper's own timed retry reaches the app. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
Second review found that re-reading the trust file before each change still let two instances overwrite each other. Instead: - Only the instance that holds the pairing socket changes approvals or receipt; a second instance refuses with a message and a policy log line. - A standby that takes the socket over adopts the saved file once (unreadable file: no trust, receipt off) and drops leases of revoked apps. - The tab can never turn on receipt the user turned off, also in the store. - A tab left open while locked connects again on unlock. - Helper: the first pairing result is not scheduled after a newer signal attempt, signal attempts start at least 1 s apart measured after the previous one, a signal during an attempt gets one more attempt, a failed registration is not marked listening, and the signal name includes the uid. - Fixture: tab open, unlock, restart and receipt-on reconnect within 2 s. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
…rs (#31) Third review (Codex objected, Antigravity agreed): - The socket holder notices when the approvals file changed since its own last read or write (for example an older app version running beside it) and adopts it before proving, approving or any change. A missing or unreadable file after approvals were known means no trust and receipt off; revocations are kept, and an unsaved denial is merged on top of what is on disk. - A change attempted without the socket first tries to take it over, so a window left after the previous holder quit works; the refusal message clears once it holds the socket. - Screen lock and an inactive console session are tracked separately; receipt resumes only when neither holds. - Retry restarts the "no session" check. Docs and comments say the old-version notice stays until the user turns receipt on or off. - Fixture reconnect waits: 3 s (one signal interval plus jitter and margin). Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3ddb9abe2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let loaded = Self.read(url) { | ||
| guard hasUnsavedDenial else { file = loaded; return } | ||
| var merged = loaded | ||
| merged.revoked = loaded.revoked + file.revoked.filter { !loaded.revoked.contains($0) } |
There was a problem hiding this comment.
Preserve saved revocations when adopting external policy
When an older app instance overwrites the trust file using its stale client list, this branch discards even revocations successfully saved by the current instance: hasUnsavedDenial is false after a successful forget. For example, forget an approved app in the socket-owning instance, then toggle receipt in an already-running older instance and enable receipt in the owner. adoptIfChanged() reloads the stale approval and removes its tombstone, allowing a fresh helper process holding the forgotten key to reconnect without approval. Preserve locally known revoked keys and exclude their clients during every adoption, not only after failed denial writes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in a7aeb83. Whenever this instance adopts the file, it now merges in its own revoked keys, drops their clients, and writes the tombstones back to disk. This happens on every adoption, not only after a denial that failed to save. I added a unit test for this case to AgentTrustStoreTests: forget the client, write back the stale pre-revocation file, then adopt. After that the key stays revoked, both in memory and on disk. The build and test runs on the Mac are next.
Generated by Claude Code
…#31) Codex bot P1 on #34: a stale file written by an older app instance could remove a tombstone this instance had saved, letting the forgotten key reconnect. Adoption now always unions the local revoked keys, drops their clients and writes the tombstones back. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
…t overwriting (#31) - connectionStatus adopts a changed trust file, so a bound helper sees an external revoke or receipt-off before each receive or share. - Trust file stamp comes from the fd that was read and includes ctime and mode. - An unreadable file is adopted as no trust but never written over; it is adopted again once readable. A read failure no longer marks a denial. - A failed write-back of tombstones or denials keeps them pending. - When the revoked list is full, the disk's newer entries are kept. - Launch while another user has the console counts as session-locked. - Docs: old-version concurrent writer race (no file lock) as a known limit. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
`try` inside precondition's autoclosure does not compile; read the file into a local first. Test-only change. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unreadable trust files (#31) - Read the console flag under its real key string (kCGSSessionOnConsoleKey). - At the 64-entry revoked cap the disk's oldest entries make room; this instance's revocations are all kept. - After a write, remember the file only if a re-read shows what was written; otherwise the next check adopts the other writer's version. - A failed write-back clears the stamp so the next check retries it. - An unreadable file records the stamp of the file that failed (or none when it cannot be opened), so recovery is noticed. Only a user's change replaces it; automatic writes still never do. Launch on an unreadable file is the same state, and the Agent tab explains it. - An unsaved denial that meets an unreadable file is applied against what was held before, not against the empty closed state. - An older version's "on" (no receipt choice in its file) does not undo the user's off here. - Bound helpers dropped by an unreadable file are not blocked; they get a ready signal when the file is readable again. - prove() adopts external changes before returning an existing binding. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
…r own file (#31) The adoption merge (tombstone union, intersection with an unsaved denial, old-writer receipt guard) kept producing edge cases. It is replaced by two simpler rules: - Approvals live in agent-approvals.json. The #13 builds' agent-clients.json is imported once when the new file does not exist and renamed to .migrated. No released version ever wrote either file, so earlier builds running beside this one no longer share a file with it. - A user's denial (receipt off, one app's receipt off, revoke) that cannot be saved is kept as a pending operation and replayed on top of whatever the file holds when it is next read, then written. Only the user's own actions are replayed, so revocations at the 64 cap and apps approved elsewhere are kept. Also: - needsAdopt flag instead of a nil stamp, so a pending write-back still notices the file vanishing; a read error after open keeps no stamp. - Over an unreadable file only the user turning receipt on writes (a new, empty list); denials there stay pending. The tab notice says so. - disconnect/forget capture what was clicked before re-reading the file and record the denial even if the row is not loaded right now. - Opening the tab checks the file again. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
… file shows them (#31) - No import of the #13 builds' agent-clients.json (never released): nothing writes the approvals file outside socket ownership, and those builds never share a file with this one. Apps approved there are approved again once. - A denial that fails to save sets needsAdopt, so the next check replays and writes it even if nothing else changed the file. - Pending denials are cleared only when a re-read shows the written file; on a mismatch they stay and are applied to whatever is read next. - Replay that changes nothing does not write. - A user's "turn receipt on" that is the first to find the file unreadable does not overwrite it; the next click does, after the notice. - Docs: policy_readable and policy_unreadable log values. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
…l gaps (#31) - turnOnReceive reads readFailed before startPairing, whose takeover re-reads the file, so the first click that finds it unreadable never overwrites it. - Unsaved denials while the file is missing are written to a new file, or retried at the next check. - A user's later on removes an unsaved receipt-off (or that app's off) from the pending list, so it cannot be replayed over the on. - A denial whose re-read does not show it is reported as unsaved. - The unreadable notice clears once receipt is turned on. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
…only after a save (#31) - Adopting the file clears a remembered instruction choice whose app record was removed or now holds a different key, even with no live binding, so a rotated key never inherits an earlier instruction share. - A pending receipt-off (or one app's off) is removed only after the user's on is saved; a failed on leaves the off in effect. - Nothing is written in place of a missing file; unsaved denials stay and apply to the file if it is restored. - A denial counts as saved when the re-read file holds it, even if unrelated rows differ. - The unreadable notice is kept while other denials are still unsaved. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
#31) Pending denials are removed only when the file holds them (receipt off, the app's row present and off, the key revoked and absent). An app's off for a row the file lacks stays pending and applies when the row comes back. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
…ng (#31) - setReceiptEnabled(false) for a row that is not loaded (file vanished or unreadable) records the off as pending and writes nothing. - A matching commit reports a denial as saved only if the written file holds it. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
Closes the class "denial reported saved but held by neither the file nor the pending list" instead of single instances: - Every denial (receipt off, one app's off, revoke, and the key replaced by a rotation approval) is added to the pending list first and removed only when a write is read back unchanged and holds it. - Nothing is written in place of a file that vanished or cannot be read; denials made then apply when it is back. - An off for a row missing from a readable file stays pending as well. - The "nothing changed" shortcut applies only when memory reflects a file this instance read or wrote and nothing is pending. - A user's on removes a pending off only if the write was read back. - A failed rotation approval still revokes the replaced key in memory. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
…, end a replaced key's lease on failure (#31) - Turning receipt on, resuming an app, and approving a key count only when the written file is read back unchanged; otherwise the file is read again with pending denials applied and the grant is refused. - A file written where the previous one vanished does not settle pending denials, since the original may be restored over it. - A rotation approval that fails to save re-adopts at once, so the replaced key's live lease and share end. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
… denials across later writes to a re-created file (#31) - resume, approve (existing key) and turning receipt on run the controller's adoption when the store refuses a grant, so leases revoked by the file it read end at once. - A refused grant leaves nothing granted in memory, even if the file vanished. - Writes to a file this run created where the previous one vanished never settle pending denials until another file appears there. Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
…ated (#31) Agent: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh
Requested by 이성주 · project thread
Closes the implementation part of #31. Base
integration/issue-31=0d961e0(integration/issue-13). 최종 HEAD9b0703c.바뀐 동작
<앱 ID>.agent.ready.<uid>)를 보냅니다.receiptChoice: auto|off: 사용자가 끈 받기는 탭을 열어도 켜지지 않습니다.agent-approvals.json이고, 페어링 소켓을 가진 인스턴스만 씁니다. 에이전트 앱별 독립 연결과 승인 관리 #13 빌드의agent-clients.json은 배포된 적이 없어 가져오지 않습니다(그 빌드에서 승인한 앱은 한 번 다시 승인).presence,receipt,ready post,policy adopt|change refused,helper attempt|retry|wait. 수집법은docs/mcp-explanation-drafts.md에 있습니다.참여 에이전트
운영 로그 (요약)
환경: macOS 27.2.1, Swift 6.4.2, SDK MacOSX26.5, 애드혹 서명. fixture는 rcodesign과 일회용 인증서로 실행했습니다.
17차: 매 HEAD에서 build exit 0, test exit 0(5차 컴파일 수정 1회, 9차 이 브랜치와 무관한 불안정 1회), fixture 20/20입니다. 위조 신호 구간의 도우미별1.15초였습니다. 전체 표는 에이전트 탭이 열려 있으면 별도 조작 없이 연결 #31 댓글에 있습니다.trigger=ready최소 간격은 1.06검토 결과
알려진 한계·후속
미검증
되돌리기
이 PR의 병합 커밋을 revert합니다. 새 파일
agent-approvals.json은 지워도 됩니다(승인 없음으로 시작).🤖 Generated with Claude Code
https://claude.ai/code/session_015LJG7KnMPqFcfTZ8A1C2qh