Skip to content

Bring agent app approval (#13) and Agent-tab auto connect (#31) into the promotion candidate (#4) - #36

Merged
lseongjoo merged 55 commits into
integration/issue-4from
integration/issue-31
Nov 28, 2026
Merged

lseongjoo merged 55 commits into
integration/issue-4from
integration/issue-31

Conversation

@lseongjoo

Copy link
Copy Markdown
Contributor

Requested by 이성주 · project thread

This merges integration/issue-31 (28ae9e8) into integration/issue-4, so that #33 can promote every current feature as a single candidate. It contains:

Evidence locations

Not yet verified

  • On a real agent app (Claude Code), whether opening the tab connects without a click. This needs one approval click from the user. The 에이전트 앱별 독립 연결과 승인 관리 #13 item "reconnect real Claude Code on the rebuilt review build" will be checked at the same time.

Conflicts

  • An earlier merge-tree check found no conflict between integration/issue-4 and integration/issue-13. GitHub's mergeability result for this PR is below.

Generated by Claude Code

lseongjoo and others added 30 commits November 21, 2026 18:34
- Pin editor actions (revert, close, playback) to the document they were
  issued for, keep manual drafts visible as tabs, and surface arrivals.
- Report every draft outcome with a structured status (editor_full,
  invalid, upgrade_required, unconfirmed) and distinguish busy from full.
- Show blocked receipt, peer identity, and shared instruction in the
  connection area; retry pairing when enabling receive.
- Treat an unreadable preset override as unreadable instead of falling
  back to built-ins; write instruction files 0600.
- Target macOS 14.0 for all variants, pick a usable SDK without Xcode,
  and stage installs so a failed swap restores the previous app.
- Add `./build.sh review`: the whole app with isolated identity, data,
  and sockets, without Services or global hotkeys.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
One approval in the app now remembers a client by its own signing key
instead of by one live helper process and a 600-second clock.

- The helper keeps a non-extractable P-256 key per MCP client in the
  login keychain and proves it on each reconnect against a fresh nonce.
  The app stores the public key, client name and launching program in
  agent-clients.json (0600) and binds a process only after that proof,
  on top of the existing signature and process checks.
- Receipt and instruction sharing no longer expire on a timer. Receipt
  ends when the user turns it off, the screen locks, the client is
  forgotten or its process exits; turning it off persists.
- A different key, a different launcher, a lost or replaced key, 30 idle
  days, or a forgotten client all require a new approval. Forgetting
  tombstones the key and refuses requests already in flight.
- Instruction reading stays separate: only the exact saved revision the
  user chose, only for the client it was chosen for, never across an app
  restart. An expired read proof is renewed by reading the same revision.
- Delivery keys are remembered per client (latest 128) across client
  restarts; the rate limit slides per minute and per hour.
- Oversized text is refused with too_large and byte counts, and every
  refusal carries a status code.
- Add Helpers/tts_mcp_client.py, which sends over pipes in single frames
  and reports confirmed / rejected / unconfirmed, and
  Tests/Fixtures/run_persistent_pairing.py with the fixed scenarios.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…uide

- Drafts accept an optional `title` on both submission tools. It names
  the draft in the list and editor header only and is never part of the
  text that is edited, copied, captioned or read. One line, up to 120
  characters and 512 UTF-8 bytes; longer is refused, never shortened.
  Without one, the first non-blank line of the body is shown.
- The same key with the same title, body and speech text is one draft;
  any difference is a conflict that changes nothing.
- Documents are stored in a private SQLite file instead of memory. The
  six-document and 256 KiB limits are gone, and the list, edits, received
  originals and open document come back after a restart. A draft that
  cannot be stored is refused without touching anything else. Stored
  drafts keep answering duplicate/conflict for their keys after restart.
- The horizontal tab strip is replaced by a collapsible vertical list
  beside the editor: newest first, selection, edited and unseen marks,
  date, title search, lazy rows. While the list is being searched, an
  arrival is listed without taking over the editor.
- Add the read-only get_tts_submission_guide tool. Tool schemas, argument
  checks and the guide are generated from one field definition.
- Add Tests/Fixtures/run_draft_titles.py and unit tests for the above.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…18)

Parking the editor's document now reports a failed write. Switching
documents and starting a new one stop instead of replacing the editor,
and an arrival is listed without taking the editor, with a notice.
A successful park records the document as the one to reopen, so a
manual draft comes back after a restart like a received one.

Addresses Codex review on PR #23 (P1 discussion_r4694214953, P2
discussion_r4694214961).

Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore pre-process agent features dropped from the review build (#22)
Bind remembered approval to a registered direct host and its protected key. Require explicit live-session approval when the host cannot be verified. Keep revocation, receipt and draft retry state scoped to each approved client.

Agent: Codex
…13)

Identify the agent app that launches the helper by its code signature:
team ID (or leaf certificate without a team) plus signing identifier.
Any hardened, certificate-signed, non-platform app now gets a durable
approval; the CodebasicTTSDirectMCPHost Info.plist key that no real
agent app carries is no longer required. Hosts may have entitlements
other than get-task-allow and dyld environment variables. Ad-hoc,
unsigned, shell or system-interpreter launchers still get a one-run
approval.

An approval no longer lapses after 30 idle days; it ends only on
revocation, a different signer or app, or a replaced helper key.

Add AgentTrustStoreTests to ./build.sh test.

Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LJG7MWqYoCZivtQ96kBhP
Add the [AGENT-CONN] category so the persistent per-app approval can be
verified from the unified log: which app identity reconnected, whether
it was recognized, and what it got. No draft text or key material.

Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LJG7MWqYoCZivtQ96kBhP
Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LJG7MWqYoCZivtQ96kBhP
Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LJG7MWqYoCZivtQ96kBhP
Manual testing with Claude Code (a 366 MB signed binary) showed no
approval request: validating the host signature takes about a second on
the main thread, past the 750 ms pairing deadline, so hello answered
unavailable. Compute the host identity on the socket thread before the
main-thread hop and cache it per running parent process (pid, start
time, executable path), so later checks, including the per-request
delivery verifier, are cheap. Drop the redundant second validity check;
process identity is re-checked instead. Log main-deadline timeouts.

Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LJG7MWqYoCZivtQ96kBhP
)

Manual testing found that a Keychain key created by a self-signed helper
(no Team ID) is bound to that build's cdhash. After any rebuild or
update the new helper gets errSecAuthFailed (-25293) on signing, and
since an inaccessible key is never replaced, the approved app could not
connect again. Store the key per identified app in
~/Library/Application Support/Codebasic TTS/agent-client-keys (0700 dir,
0600 file, no symlinks, single link, created atomically). Approval stays
bound to the launching app's code signature. --forget-key deletes the
file. Fixtures keep using their own key directory.

Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LJG7MWqYoCZivtQ96kBhP
Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LJG7MWqYoCZivtQ96kBhP
Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LJG7MWqYoCZivtQ96kBhP
claude and others added 25 commits November 25, 2026 17:41
…lusive rename (#13)

Turning receipt back on (master switch or per-client resume) clears the
client's rate state again, as the docs say and the earlier code did.
The helper key file is published with renamex_np(RENAME_EXCL) instead
of link()+unlink(), so a helper killed mid-creation can no longer leave
a key with st_nlink == 2 that the reader rejects forever.

Addresses Codex review on PR #15 (discussion_r4698613638,
discussion_r4698613629).

Agent: Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LJG7MWqYoCZivtQ96kBhP
Approve agent connections once per agent app (#13)
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
…#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
Both independent reviewers (Codex, Antigravity) agreed at 9b0703c; build/test exit 0, fixture 20/20. Evidence on #31.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T15:14:05.530913Z 28ae9e8 PR opened
🔒 Security Review ✅ Completed 2026-11-28T15:20:44.812394Z 28ae9e8 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lseongjoo
lseongjoo merged commit b3ebef2 into integration/issue-4 Nov 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28ae9e8747

ℹ️ 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".

Comment on lines +66 to +70
var current = try read(at: url)
let matches = current[selector].map { old in expectedOverride.map { AgentBytes.same($0, old) } == true }
?? (expectedOverride == nil)
guard matches else { throw AgentCatalog.Failure.conflict }
current[selector] = text

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Serialize preset read-modify-write transactions

When two running app instances save different preset instructions concurrently, both can read the same dictionary and pass the selector-specific conflict check. Each then replaces the entire file, so the last writer silently discards the other instance’s successfully saved instruction. Preset editing is not restricted to the pairing-socket owner in AppState.saveAgentPresetInstruction, so the approval-store ownership guard does not prevent this. Hold a shared cross-process lock across the read, conflict check, and write, as the custom instruction catalog already does; an atomic file replacement alone does not prevent lost updates.

Useful? React with 👍 / 👎.

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.

2 participants