paperclip/packages/db/src/schema
Dotta 8d1f0c20af
fix: let responsible users choose either AI subscription or API key (#13351)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - AI Connections select the account used for each run.
> - A responsible-user binding must follow the person whose work the
agent performs.
> - The saved sign-in method currently blocks users with another method
for the same provider.
> - This pull request resolves a personal default by company, user, and
provider.
> - Each user can use a subscription or API key with the same bot and
model.

## Linked Issues or Issue Description

Refs #13247, #13248, #13346, #13347.

**What happened?**
A bot configured with a Claude subscription rejects another responsible
user’s Claude API key. Inline repair also limits that person to the
original sign-in method.

**Expected behavior**
The same bot uses each responsible user’s default Claude account,
whether it is a subscription or API key. Explicit shared account
selections remain fixed.

**Steps to reproduce**
1. User A connects a Claude subscription and creates a bot using the
responsible user’s connection.
2. User C connects a personal Claude API key.
3. User C runs the same bot. Before this fix, credential resolution
fails.

## What Changed

- Add a personal provider-default table. Preserve legacy per-method
preferences and backfill the most recently updated preference, including
unavailable defaults. Repeated migration does not replace a selection. A
database trigger propagates old-server default updates without treating
new accounts as replacement defaults.
- Resolve responsible-user bindings by provider. Retain the method as a
wire compatibility hint for old servers. Explicit selections still
require the exact method and grant.
- Use the selected account’s method for credential isolation, refresh
locking, and run attribution.
- Update onboarding, agent setup, the picker, and inline task repair.
Keep existing authentication components and harness/model settings.
- Add mixed-method runtime, migration, repair, and Storybook coverage.
Include upstream’s duplicate Anthropic option fix through the base
branch.

## Verification

- Focused resolver, migration, connection-intent, onboarding, agent
setup, model, and connector UI suites: 331 tests passed.
- Onboarding and new-agent regression suites passed during the initial
focused run.
- UI typecheck, token gates, and Storybook build passed.
- Live browser checks passed for Claude and Codex API-default execution,
switching both back to subscriptions, and both existing shared-account
bots. Bot configuration remained unchanged.
- One Daytona startup command stalled before Claude launched. The test
run was cancelled, its sandbox stopped, and the same account/task passed
on retry. Startup cancellation remains a separate environment finding;
this PR does not change that command transport.
- Browser review: all eight assertions passed in the new mixed-method
story, including shared selection, return to responsible-user selection,
and unchanged harness/model.
- Repository build and typecheck passed after refreshing upstream
dependencies. Final resolver and historical rollback verification: 38
tests passed. All latest-head CI gates passed, including
server/workspace/serialized suites, browser E2E, build, typecheck, and
runner verification. The extra serial local full-suite run was stopped
after equivalent CI passed; focused local checks completed.

## Risks

- Users with both historical method defaults get their most recently
updated preference as the initial provider default. They can change it
explicitly in Connections.
- A revoked or unavailable default blocks. Connecting an additional
account does not silently replace it.
- Existing legacy authentication is unchanged. Managed responsible-user
bindings intentionally stop pinning a method.
- Live staging: the same Claude and Codex bots completed real API-key
runs after changing only the personal default, then completed
subscription runs after restoring the original defaults. Read-only
database verification confirms unchanged bot configuration and actual
method attribution. Distinct-user concurrency is covered by automated
real-database tests with synthetic credentials, not two live human
logins.

## Model Used

OpenAI GPT-6 (Codex), with reasoning, repository tools, code execution,
and browser interaction. The runtime does not expose a more specific
model ID or context-window size.

## 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
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-09-12 20:27:26 -05: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: manage AI runtime credentials through Connections (#13247) 2026-09-12 16:30:10 -05: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
ai_connection_defaults.ts feat: manage AI runtime credentials through Connections (#13247) 2026-09-12 16:30:10 -05:00
ai_provider_defaults.ts fix: let responsible users choose either AI subscription or API key (#13351) 2026-09-12 20:27:26 -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(channels): add experimental iMessage Photon (#13299) 2026-09-12 15:23:50 -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
email.ts feat(connections): add AgentMail inboxes and email tasks (#13256) 2026-09-11 16:56:38 -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 fix: preserve NUL characters in run-event payloads (#13325) 2026-09-12 13:34:45 -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: protect starting runs during overlapping deployments (#13285) 2026-09-11 16:55:44 -07:00
inbox_dismissals.ts feat: add attention queue and Decisions surface (#9380) 2026-07-10 17:09:57 -05:00
index.ts fix: let responsible users choose either AI subscription or API key (#13351) 2026-09-12 20:27:26 -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 experimental persistent agent chat (#13284) 2026-09-12 08:56:04 -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: add experimental persistent agent chat (#13284) 2026-09-12 08:56:04 -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: manage AI runtime credentials through Connections (#13247) 2026-09-12 16:30:10 -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