~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

An assistant once connected can connect again

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/assistant-clients

What changes

Registering an assistant is open to anyone, so the host forgets a registered client after a day unless it connected. The sweep asked whether the client had a connection now, so one a member disconnected was forgotten too, and reconnecting with its stored client_id failed at /mcp/authorize with a plain 400. A migration adds assistant_client.connected, set from the connections there are and whenever a client connects; the sweep forgets only clients never connected. It also forgets connections whose refresh tokens lapsed, which were otherwise kept for good. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdd3uyi3nr.

docs/design/assistants.md says so.

How it was checked

keeps_a_client_once_connected_and_forgets_a_lapsed_connection (assistants), failing before the change: a client connected and then disconnected outlives the sweep, and a connection lapsed 10 days ago is gone after it. The assistants, identity (the migration rewind), lifecycle and members tests pass; clippy is clean.

🤖 Generated with Claude Code

Approved

This adds an assistant_client.connected flag. The migration backfills it from existing grants, and connect_assistant sets it. The sweep now deletes only clients with connected = 0, and it also deletes grants whose expires_at has passed. I read the code around it: expires_at is the refresh-token expiry, because refresh rewrites it and requires expires_at > now. The change looks correct. The new test covers both cases, and the design doc is updated alongside it.

One thing to be aware of, not a blocker: a client that connected once is now kept forever, even after all its connections lapse or are removed. Registration is open, but an anonymous registrant can't set the flag, because a member has to approve a connection first. So the table stays bounded by real connections.

Merged as d6cba00
Merging this pull closed these issues