paperclip/packages/db/src/schema
Devin Foley bce976d60d
feat: bind an agent to a Codex login whose account differs from the company default (#13067)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The `codex_local` adapter signs agents in to OpenAI, and a company
keeps one default Codex identity in its shared company home
> - A login with a DIFFERENT account than the company default is
deliberately kept out of the shared home — one agent's sign-in must not
switch every unbound agent's credentials — but that left the
cross-account login inert: nothing connected the agent the operator was
configuring to the credential the login stored
> - The stored credential and its company secret already exist; only the
last mile — an agent actually using them — was missing
> - This pull request reports a non-secret binding claim on the
authenticated login and lets the agent page bind that one agent's
`CODEX_HOME` to the account's secret, exactly and only when the
identities differ
> - The benefit is that multi-account Codex becomes one click on the
agent that needs it, with company-wide identity untouched

## Linked Issues or Issue Description

**What happened?**

On an agent's detail page, "Sign in with Codex" using a different OpenAI
account than the company default succeeds but changes nothing for that
agent. The credential lands in the per-identity store and a company
secret names it, but the agent keeps using the company default. The Test
keeps reporting that authentication is needed, and no repeat login
helps.

**Expected behavior**

When the operator deliberately signs an agent's page in with a different
account, that agent starts using that account. Agents that were not part
of the action keep the company default. A same-account login keeps
working through the shared company home with no per-agent pinning.

**Steps to reproduce**

1. Configure a company whose Codex home holds account A.
2. Open a `codex_local` agent's detail page with a sandbox environment
and complete "Sign in with Codex" using account B.
3. Press Test. Before this change the agent still resolves account A and
the authentication-needed check returns.

## What Changed

- `packages/adapters/codex-local` — the prerequisite shield:
`isCodexAuthCachePath` recognizes per-identity credential-store entries,
and `seedManagedCodexHome` refuses to symlink, heal, or
API-key-overwrite an entry's `auth.json`. The seeding pass runs before
every probe and execute; without the shield, an agent bound to an entry
would have its stored login silently swapped for the host credential.
Static shared config files still copy in. Rotation already survives
binding: the sandbox copy-back writes rotated credentials into the
identity-keyed store slot.
- `server` — the promotion records whether the company default home
ended on a different account than the login (any read failure degrades
to `false`, so the client can never be told to bind wrongly). After the
terminal commit, the routes layer remembers a non-secret claim — the
opaque account-home secret id plus that verdict — in a bounded in-memory
map, and merges it into the owner read of an `authenticated`
`codex_local` session. A restart drops the claim; the panel then shows
plain success.
- `packages/shared` — `CodexAccountBindingClaim` on the owner session
response. It carries no account identifier and no credential byte.
- `ui` — the login panel reports the claim upward once. The edit-mode
form binds the agent's `CODEX_HOME` to the secret and saves in one step,
only when `companyIdentityDiffers` is true. Same-account logins bind
nothing on purpose: the company-home refresh already carried them, and
an unbound agent keeps following the company default across rotations.
Create mode is unchanged.

## Verification

- Adapter suite: 381 passed, 1 skipped (includes the new store-entry
shield tests and the path-predicate cases).
- Server suites (8 files): 130 passed, 15 skipped — including two new
route tests that drive a login to `authenticated` and assert the claim
with both identity verdicts.
- UI render suite: 85 passed — including a panel test that the claim is
reported upward exactly once.
- `tsc --noEmit` clean in `packages/shared`, the adapter package, and
`ui`; `server` clean for the touched file.

## Risks

- The bind changes one agent's configuration through the normal
agent-update patch, initiated by the operator's own login on that
agent's page. The failure direction of every fallback is "offer
nothing": a missing claim, a restart, or an unreadable company home all
degrade to no bind.
- The seed shield narrows what the seeding pass may touch; homes outside
the credential store behave exactly as before, covered by the existing
seed tests.
- Builds on the sign-in credential-resolution fix (#13064), now merged;
this branch is rebased onto master and the diff contains only the
binding feature. Supersedes #13066, which GitHub auto-closed when its
stacked base branch was deleted on merge.

## Model Used

Claude (Anthropic) — Claude Fable 5 (`claude-fable-5`), extended
thinking, agentic tool use in Claude Code (terminal).

**Related PRs (searched; no duplicates found):** #12740, #12082, and
#9621 touch adjacent Codex credential sync paths; #8495 is the standing
hardening effort for probe auth seeding.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes (no
standalone docs cover this flow; the behavioral contracts are documented
in-line at each changed site)
- [x] I have considered and documented any risks above
2026-09-10 07:15:01 -07:00
..
activity_log.ts feat: stamp responsible users on activity logs (#9731) 2026-07-16 20:54:55 -05:00
adapter_auth_sessions.ts feat: bind an agent to a Codex login whose account differs from the company default (#13067) 2026-09-10 07:15:01 -07:00
agent_api_keys.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
agent_config_revisions.ts Add agent config revisions, issue-approval links, and robust migration reconciliation 2026-02-19 13:02:14 -06:00
agent_memberships.ts [codex] Add starred resource sidebar controls (#9085) 2026-07-06 14:09:11 -05:00
agent_runtime_state.ts Add agent runtime DB schemas and expand shared types 2026-02-17 12:24:38 -06:00
agent_task_sessions.ts Add end-to-end session goals to Paperclip Runner 2026-09-08 16:18:47 -05:00
agent_wakeup_requests.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
agents.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
approval_comments.ts Scaffold agent permissions, approval comments, and hiring governance types 2026-02-19 09:10:48 -06:00
approvals.ts Expand data model with companies, approvals, costs, and heartbeats 2026-02-17 09:07:22 -06:00
assets.ts feat: add storage system with local disk and S3 providers 2026-02-20 10:31:56 -06:00
auth.ts Add the Better Auth issuer column so signup and sign-in work (#12396) 2026-08-27 22:31:35 -07:00
board_api_keys.ts Address Greptile review on board CLI auth 2026-03-23 08:46:05 -05:00
budget_incidents.ts Fix budget incident resolution edge cases 2026-03-16 16:48:13 -05:00
budget_policies.ts feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
built_in_managed_resources.ts [codex] Add built-in agents and Reflection Coach bundle (#9206) 2026-07-09 16:29:30 -05:00
cases.ts Cases: experimental first-class case object (#9198) 2026-07-09 22:11:03 -05:00
chat_channels.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
chat_discord_command_owners.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
chat_teams_file_transfers.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
chat_telegram_draft_ids.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
cli_auth_challenges.ts Add browser-based board CLI auth flow 2026-03-23 08:46:05 -05:00
companies.ts Remove the company brand color and per-company attachment limit (#12291) 2026-08-27 12:11:05 -07:00
company_logos.ts Use asset-backed company logos 2026-03-16 09:25:39 -05:00
company_memberships.ts feat: add auth/access foundation - deps, DB schema, shared types, and config 2026-02-23 14:40:16 -06:00
company_onboarding_seeds.ts feat(server): receive and apply the Paperclip Cloud onboarding seed (#11098) 2026-08-12 22:54:07 -07:00
company_secret_bindings.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
company_secret_proposals.ts Add governed secret alias confirmation cards (#11486) 2026-08-18 09:44:24 -05:00
company_secret_provider_configs.ts Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
company_secret_versions.ts Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
company_secrets.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
company_skill_policies.ts feat(skills): open-by-default company skill policy and core UX (#9564) 2026-07-15 11:42:40 -05:00
company_skills.ts feat(skills): add beta releases for the core Paperclip skill (#10228) 2026-07-27 19:45:59 -05:00
company_transfer_runs.ts feat(server): chunked resumable company import transfers (#11223) 2026-08-11 15:25:07 -07:00
company_user_sidebar_preferences.ts [codex] Improve workspace runtime and navigation ergonomics (#3680) 2026-04-14 12:57:11 -05:00
completion_contracts.ts feat(runner): add native persistence contracts (#12169) 2026-08-25 13:08:39 -05:00
connection_event_deliveries.ts feat(connections): add durable GitHub identities and webhooks (#12843) 2026-09-04 18:02:52 -05:00
connection_intent_deliveries.ts feat(connections): connect services from native task feeds (#13058) 2026-09-08 15:55:26 -05:00
cost_events.ts fix(issues): make DELETE /api/issues/:id succeed for issues with dependents (#11331) 2026-08-13 12:02:15 -07:00
decision_queues.ts feat(decisions): add desk workflow and retention (#10672) 2026-08-02 10:47:03 -05:00
decision_training_examples.ts feat: add decision training snapshot foundation (#9702) 2026-07-17 12:17:34 -05:00
decisions.ts feat(decisions): add first-class propose mode (#10010) 2026-07-31 19:17:02 -07:00
document_annotation_anchor_snapshots.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
document_annotation_comments.ts Cases: experimental first-class case object (#9198) 2026-07-09 22:11:03 -05:00
document_annotation_threads.ts Cases: experimental first-class case object (#9198) 2026-07-09 22:11:03 -05:00
document_memberships.ts feat(server): add per-user document stars (#9952) 2026-07-27 19:13:35 -05:00
document_revisions.ts fix: upstream deployed document-comment, routine-annotation, workspace & board-polling fixes (#8536) 2026-06-23 09:00:14 -05:00
documents.ts fix: upstream deployed document-comment, routine-annotation, workspace & board-polling fixes (#8536) 2026-06-23 09:00:14 -05:00
environment_custom_image_setup_sessions.ts Scope environment custom images to instance environments (#8850) 2026-07-01 23:57:31 -07:00
environment_custom_image_templates.ts Scope environment custom images to instance environments (#8850) 2026-07-01 23:57:31 -07:00
environment_leases.ts feat: Claude login on the new-agent page before agent creation (#11347) 2026-08-17 13:42:51 -07:00
environments.ts refactor(environments): make execution environments instance-scoped (#8375) 2026-06-20 09:42:53 -07:00
execution_workspace_runtime_leases.ts feat(runtime-exposure): least-privilege Tailscale HTTPS broker, shared contract, and persisted exposure state (#11524) 2026-08-17 05:54:12 -04:00
execution_workspaces.ts PAPA-430: workspace finalize gates + no-remote-git enforcement (#6969) 2026-05-29 08:25:29 -07:00
external_object_mentions.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
external_objects.ts fix(external-objects): refresh PR status labels (#10704) 2026-08-02 20:24:52 -07:00
feedback_exports.ts Add feedback voting and thumbs capture flow 2026-04-02 09:11:49 -05:00
feedback_votes.ts fix(issues): make DELETE /api/issues/:id succeed for issues with dependents (#11331) 2026-08-13 12:02:15 -07:00
finance_events.ts fix(issues): make DELETE /api/issues/:id succeed for issues with dependents (#11331) 2026-08-13 12:02:15 -07:00
folders.ts feat: organize skills with nested folders and My Skills (#9633) 2026-07-16 15:50:45 -05:00
goals.ts Expand data model with companies, approvals, costs, and heartbeats 2026-02-17 09:07:22 -06:00
heartbeat_run_events.ts feat(runner): add Codex-native application integration (#12591) 2026-08-31 14:38:38 -05:00
heartbeat_run_watchdog_decisions.ts [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
heartbeat_runs.ts fix: make task recovery durable and preserve current requests (#13075) 2026-09-09 09:14:25 -05:00
inbox_dismissals.ts feat: add attention queue and Decisions surface (#9380) 2026-07-10 17:09:57 -05:00
index.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
instance_settings.ts refactor(environments): make execution environments instance-scoped (#8375) 2026-06-20 09:42:53 -07:00
instance_user_roles.ts feat: add auth/access foundation - deps, DB schema, shared types, and config 2026-02-23 14:40:16 -06:00
invites.ts feat: add auth/access foundation - deps, DB schema, shared types, and config 2026-02-23 14:40:16 -06:00
issue_approvals.ts Add agent config revisions, issue-approval links, and robust migration reconciliation 2026-02-19 13:02:14 -06:00
issue_attachments.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
issue_comments.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
issue_create_idempotency_keys.ts fix: prevent duplicate task creation and recovery loops (#9648) 2026-07-16 17:00:53 -05:00
issue_documents.ts feat(issues): add issue documents and inline editing 2026-03-13 21:30:48 -05:00
issue_execution_decisions.ts Add issue review policy and comment retry 2026-04-07 17:43:10 -05:00
issue_inbox_archives.ts fix(issues): make DELETE /api/issues/:id succeed for issues with dependents (#11331) 2026-08-13 12:02:15 -07:00
issue_labels.ts feat: add issue labels (DB schema, API, and service) 2026-02-25 08:38:37 -06:00
issue_plan_decompositions.ts Add accepted-plan decomposition exact-once guards and UI state (#6831) 2026-05-28 23:30:18 -07:00
issue_question_response_deliveries.ts fix(interactions): deliver question answers durably (#12307) 2026-08-27 12:12:21 -05:00
issue_read_states.ts fix(issues): make DELETE /api/issues/:id succeed for issues with dependents (#11331) 2026-08-13 12:02:15 -07:00
issue_recovery_actions.ts [codex] Add source-scoped recovery actions (#5599) 2026-05-12 09:37:15 -05:00
issue_reference_mentions.ts Add first-class issue references (#4214) 2026-04-21 10:02:52 -05:00
issue_relations.ts fix: address greptile feedback for blocker dependencies 2026-04-06 09:03:13 -05:00
issue_thread_interactions.ts fix: make task recovery durable and preserve current requests (#13075) 2026-09-09 09:14:25 -05:00
issue_tree_hold_members.ts [codex] Add issue subtree pause, cancel, and restore controls (#4332) 2026-04-23 14:51:46 -05:00
issue_tree_holds.ts [codex] Add issue subtree pause, cancel, and restore controls (#4332) 2026-04-23 14:51:46 -05:00
issue_watchdogs.ts fix(task-watchdogs): deduplicate unchanged stopped-state wakes (#10207) 2026-07-25 08:34:41 -05:00
issue_work_products.ts Add low-trust review containment (#7530) 2026-06-05 16:48:02 -05:00
issues.ts feat: use the responsible person's GitHub for shared agent operations (#13005) 2026-09-07 14:32:20 -05:00
join_requests.ts feat: implement multi-user access and invite flows (#3784) 2026-04-17 09:44:19 -05:00
labels.ts feat: add issue labels (DB schema, API, and service) 2026-02-25 08:38:37 -06:00
managed_agent_profiles.ts feat(runner): add managed provider backends (#12699) 2026-09-02 00:48:30 -05:00
native_run_finalizations.ts fix: make task recovery durable and preserve current requests (#13075) 2026-09-09 09:14:25 -05:00
native_run_results.ts feat(runner): add native persistence contracts (#12169) 2026-08-25 13:08:39 -05:00
pipeline_case_events.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
pipeline_cases.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
pipelines.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
plugin_company_settings.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
plugin_config.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
plugin_database.ts [codex] Add plugin orchestration host APIs (#4114) 2026-04-20 08:52:51 -05:00
plugin_entities.ts feat(security): plugin tables get company_id FK for tenant isolation (#5865) 2026-06-12 10:17:19 -07:00
plugin_jobs.ts feat(security): plugin tables get company_id FK for tenant isolation (#5865) 2026-06-12 10:17:19 -07:00
plugin_logs.ts feat(security): plugin tables get company_id FK for tenant isolation (#5865) 2026-06-12 10:17:19 -07:00
plugin_managed_resources.ts Expand plugin host surface (#5205) 2026-05-05 07:42:57 -05:00
plugin_state.ts Add plugin framework and settings UI 2026-03-13 16:22:34 -05:00
plugin_webhooks.ts feat(security): plugin tables get company_id FK for tenant isolation (#5865) 2026-06-12 10:17:19 -07:00
plugins.ts Add plugin framework and settings UI 2026-03-13 16:22:34 -05:00
principal_permission_grants.ts feat: add auth/access foundation - deps, DB schema, shared types, and config 2026-02-23 14:40:16 -06:00
project_goals.ts feat: add project_goals many-to-many join table 2026-02-20 13:43:25 -06:00
project_memberships.ts [codex] Add starred resource sidebar controls (#9085) 2026-07-06 14:09:11 -05:00
project_workspaces.ts Implement execution workspaces and work products 2026-03-13 17:12:25 -05:00
projects.ts Information Architecture + project/agent visual refresh (experimental) (#7543) 2026-06-06 09:17:27 -05:00
provider_trace_records.ts feat(runner): add Codex-native application integration (#12591) 2026-08-31 14:38:38 -05:00
remote_agent_profiles.ts feat(runner): add managed provider backends (#12699) 2026-09-02 00:48:30 -05:00
routine_documents.ts fix: upstream deployed document-comment, routine-annotation, workspace & board-polling fixes (#8536) 2026-06-23 09:00:14 -05:00
routines.ts feat: organize skills with nested folders and My Skills (#9633) 2026-07-16 15:50:45 -05:00
run_identity_contexts.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
secret_access_events.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
smoke_lab.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
status_cards.ts feat(status-cards): join summary-mentioned issues to watched set (#10205) 2026-07-24 16:44:56 -05:00
status_decision_effects.ts feat(runner): add native persistence contracts (#12169) 2026-08-25 13:08:39 -05:00
status_decisions.ts feat(runner): add native persistence contracts (#12169) 2026-08-25 13:08:39 -05:00
summary_slots.ts feat: add built-in summarizer and summary slots (#9713) 2026-07-17 11:03:07 -05:00
tool_access.ts feat: add opt-in chat provider and data foundation (#13100) 2026-09-09 13:49:12 -05:00
tool_action_deliveries.ts feat: review connection actions from tasks (#13063) 2026-09-08 19:37:13 -05:00
user_inbox_agent_policies.ts feat(authz): govern agent inbox archive access (#9658) 2026-07-16 09:51:48 -05:00
user_secret_declarations.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
user_secret_definitions.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
user_sidebar_preferences.ts [codex] Improve workspace runtime and navigation ergonomics (#3680) 2026-04-14 12:57:11 -05:00
work_assessments.ts feat(runner): add native persistence contracts (#12169) 2026-08-25 13:08:39 -05:00
workspace_operations.ts fix: upstream deployed document-comment, routine-annotation, workspace & board-polling fixes (#8536) 2026-06-23 09:00:14 -05:00
workspace_runtime_services.ts feat(runtime-exposure): least-privilege Tailscale HTTPS broker, shared contract, and persisted exposure state (#11524) 2026-08-17 05:54:12 -04:00