Skip to content

feat(platform): end coding agents when their sign-in is unsound - #4912

Merged
yannickmonney merged 1 commit into
mainfrom
feat/agent-lifecycle
Oct 13, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
feat/agent-lifecycle

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Summary

A coding agent's connection (#4899) ends when what signed it in is no longer sound, and a daily job cleans up after agents. Sign-in stays off unless an operator turns it on, so no deployment changes until then.

  • A refresh token used twice. The sign-in server answers a retry in the few seconds after a refresh with the same result; anything later is a copy of a spent token, and the server then ends the app's whole sign-in for the person. Tale reads the presented token before the server takes it from its table, and ends the person's connections of that app — in every organization, as the platform's act, with the reason refresh_reuse — only when the server did. A refusal for any other reason, a retry inside the window and a lookup that fails end nothing and never change the agent's answer.
  • A password changed, a sign-in method removed. The person's own change (Better Auth's endpoint, which the app's route reaches, and the forced rotation that replaces an expired or admin-set password — that one writes the credential itself, so it ends the agents in the same transaction), an admin's password seizure, the owner reset, an admin's removed passkey or reset second factor: the person's agents end with their sessions, with the reason account_security, and the admin who did it is named in the trail. One door (auth/account-security.ts) does it, and a source guard holds every session sweep and every credential write to it, so the next place that takes a person's access back cannot forget their agents.
  • An erasure deletes the person's connections in that organization (live and ended, with their consent and tokens) and scrubs the audit rows that name them; other organizations' stay.
  • maintenance.agent_connections_gc, daily: removes connections that ended 90 days ago, apps that registered themselves or identified by a document and that nobody connected a day after they appeared, and refresh and access tokens that expired or were retired a month ago. An app with a live connection or a working refresh token is never removed, nor an organization's own sign-in application.

Rules: AGCONN-R16–R19 (agent connections) and MEMBER-R8 widened (members). Not in this PR: the notice a person finds in their bell when an agent is disconnected for a reason that is not theirs — it comes next, with the consent page and the Connected agents tab.

Checklist

  • bun run check passes — the gate ran locally on the committed tree. The one red is app/routes/dashboard.test.tsx ("takes a signed-in tab to sign-in on a lapsed-session answer"), which fails identically on main (715dc15) and does not touch this change.
  • bun run lint:sast — runs in the commit hook.
  • Translations — the erasure report's new category label agentConnections in en/de/fr.
  • Docs — N/A here: the user-facing pages come with the slice that turns sign-in on, so they never describe a door that is off. The domain spec carries the rules.
  • README — N/A.

Test plan

  • Real Postgres + HTTP lane checkAgentLifecycle (the real sign-in server's own tables): a refresh used twice ends Ada's connections to two organizations as the platform's doing with their consent and tokens, a retry inside the window answers again and ends nothing, a made-up token ends nothing, and Mia's connection is untouched; Mia's own password change, a refused change (wrong current password) ending nothing, an admin's password seizure and 2FA reset naming the admin, and the forced rotation of a temporary password; an erasure of Eve (two connections in one organization gone, the other organization's kept, the audit rows scrubbed, Ada untouched); the daily job run as the scheduled task over stale, fresh, live, working-token, SSO, owned and plain apps and old and recent tokens. 14 related lanes (files, oauth, consent, door, lifecycle, connections, erasure, member authority, member password policy, two-factor, account authorization, stale-session reauthentication, password confirmation throttle, key owners) 177/178 on the rebased tree; the one red is the object-store seeding probe finding my reused MinIO bucket non-empty.
  • Unit tests for each piece (token request parsing at the exact 64 KiB boundary, the replay window, the provider-refusal judgement, the hook's success / refusal / other-path / no-person / failure cases, the door's statements, the erasure pass, the GC statements, the admin audit rows, the forced rotation, the owner reset), plus the source guard; mutation rounds on each (every mutant killed except behaviour-equivalent ones), and lane-level mutations of the seizure, 2FA, erasure, GC and forced-rotation statements.

A coding agent's connection ends when what signed it in is no longer
sound, and Tale cleans up after agents every day.

- A refresh token used twice: the sign-in server ends the app's sign-in
  for the person everywhere. Tale reads the presented token before the
  provider takes it from its table and ends the person's connections of
  that app, in every organization, only when it did - as the platform's
  act, with the reason refresh reuse.
- A password the person changed (Better Auth's endpoint, or the forced
  rotation that replaces an expired or admin-set one), an admin's
  password seizure, the owner reset, an admin's removed passkey or reset
  second factor: the person's agents end with their sessions. One door
  does it and a guard holds every session sweep and credential write to
  it; an admin who did it is named in the trail.
- An erasure deletes the person's connections in that organization and
  scrubs the audit rows that name them.
- maintenance.agent_connections_gc removes connections ended 90 days
  ago, apps nobody connected after a day and tokens retired a month ago.
@yannickmonney
yannickmonney merged commit da7aa50 into main Oct 13, 2026
@yannickmonney
yannickmonney deleted the feat/agent-lifecycle branch October 13, 2026 07:19
tale-code-bot added a commit that referenced this pull request Nov 1, 2026
The fixture "See [Triggers](https://docs.tale.dev/platform/automations/
triggers#4912)." proves that a number in a link's fragment is no
citation. lint:links judges every docs.tale.dev address in the tree and
refused it: the Triggers page renders no heading "#4912"
(fragment-missing), so the Checks workflow's Format job fails. The
fixture now links docs.example.com, which the link check does not
judge. The validator reads its fragment the same way, and the test still
fails when the citation pattern loses its word-character guard.

Refs #4785
tale-code-bot added a commit that referenced this pull request Nov 1, 2026
The fixture "See [Triggers](https://docs.tale.dev/platform/automations/
triggers#4912)." proves that a number in a link's fragment is no
citation. lint:links judges every docs.tale.dev address in the tree and
refused it: the Triggers page renders no heading "#4912"
(fragment-missing), so the Checks workflow's Format job fails. The
fixture now links docs.example.com, which the link check does not
judge. The validator reads its fragment the same way, and the test still
fails when the citation pattern loses its word-character guard.

Refs #4785
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.

1 participant