paperclip/server/src/routes
Dotta 1cc45086d3
feat: use the responsible person's GitHub for shared agent operations (#13005)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Several people can send instructions to the same agent and task.
> - A fixed GitHub token in the provider process can keep the first
person's access after another person's message is accepted.
> - Task ownership cannot select credentials for each accepted
instruction or preserve the identity of an operation already in
progress.
> - This pull request records ordered execution identity contexts and
resolves credentials when managed Git, gh, or GitHub tools start.
> - The benefit is automatic personal GitHub access for shared agents,
with durable continuation rules and no teammate credential fallback.

## Linked Issues or Issue Description

**Subsystem affected**

Cross-cutting: orchestration, connection grants, database, runtime
adapters, native runners, and run details.

**Problem or motivation**

A shared agent must use the person whose instructions it has accepted. A
queued message must retain its author. A retry or approval without new
instructions must retain the originating identity. GitHub must remain
optional for ordinary work.

**Proposed solution**

Persist execution identity separately from task ownership. Give new
processes a run-scoped broker capability and token-free managed
launchers. Capture identity at operation start. Keep an explicit
dedicated-agent grant as an override. Show redacted diagnostics in run
details.

**Alternatives considered**

Per-task ownership, fixed provider tokens, and mutable repository author
configuration do not handle accepted steering or concurrent operations.
A manual account-selection action would add unnecessary setup to each
turn.

**Roadmap alignment**

This completes the existing Multiple Human Users, MCP Tool Gateway &
Apps, Secrets Manager, and Self-healing Runs capabilities. The
implementation follows the maintainer-approved plan.

Related work: Refs #12843, Refs #12907. Existing proposals #4618 and
#8945 cover per-agent or per-worktree author configuration. This change
instead follows the accepted human instruction across runtime types.
Refs #11831 for governed personal connection delegation; this change
preserves connection audience checks and does not use standing
delegation as a personal credential fallback.

## What Changed

- Add durable, ordered identity contexts and active run references.
Preserve message authors through consolidation, steering, retries,
delegation, approvals, routines, and restart.
- Add an authenticated operation-time GitHub credential broker and
local/remote managed git and gh launchers. Keep personal tokens out of
the long-lived provider process.
- Resolve GitHub gateway and server-side Git operations through the same
responsible-person or dedicated-grant selection rules.
- Make absent and unavailable GitHub credentials non-blocking at generic
startup. Clear host and prior-person credentials. Keep anonymous Git
access where supported.
- Add run-detail identity history and the dedicated-account warning.
Keep task ownership and queue-versus-steer decisions unchanged.
- Preserve personal OAuth declarations through connection edits. Retain
exact selected grants in the gateway.
- Fix continuation races found during real acceptance: verify a warm
owner before credential rotation, and wait for bounded durable runner
suspension before the next run starts.
- Make migrations replay-safe. Retain identity through agent/run
deletion, remove it with its company, and clean terminal launcher
directories before releasing execution environments. Document
coordinated release and rollback.

## Verification

- Full workspace typecheck, build, and token gates passed. The complete
local suite passed in its normal test groups: 17,120 passing tests,
including all 143 serialized server suites. After integrating the newly
merged runner API work, full local typecheck and build passed again,
along with 890 focused integration tests. All 31 checks on the
integrated revision passed, including build, browser E2E, release
registry, canary dry run, typecheck, security and all test suites.
Greptile is 5/5 with all review threads resolved.
- Current focused checks passed: 142 native executor tests, 67 runtime
lifecycle tests, 9 durable identity tests, 75 credential/routine tests,
19 low-trust/resumption tests, and the executable migration replay test.
- Authenticated browser acceptance with two Paperclip users and two
GitHub accounts on one shared native agent passed. Real commits and
pushes followed A → B accepted steering → queued A continuation in the
same saved conversation. GitHub commit author and committer identities
matched all three operations. Both runs succeeded and task ownership
stayed unchanged.
- Real GitHub MCP calls switched from A to B after accepted steering. A
delegated subtask retained its originating identity across a server
restart.
- Disabling B's GitHub connection left ordinary work successful. Managed
gh was unauthenticated and the provider had no inherited GH_TOKEN or
GITHUB_TOKEN.
- The browser displayed run-detail diagnostics and the exact
dedicated-account warning. A final controller-restart check followed by
another-person continuation retained the conversation, selected the
correct GitHub login and Git author, and removed each terminal launcher
directory.
- Company-lifetime migration and all five previously failing CI suites
passed locally (167 tests). Same-token gateway A → B → A and six
broker/launcher boundary tests passed.
- Remote callback, launcher, sandbox, and runtime contract tests passed.
Both native and legacy Codex completed actual Daytona executions on the
integrated revision ([campaign
results](https://github.com/paperclipai/paperclip/actions/runs/34155056509)).
The remote package-manager shim staging regression also passed locally.

## Risks

- Deploy the migrations, server broker, launchers, and runner artifacts
together. Existing processes finish with their original contract. New
managed processes need the broker endpoint for GitHub operations.
- Finish or stop new managed executions before rolling application code
back. Keep the additive schema and identity history during rollback.
- Scripts that require a persistent raw GH_TOKEN must use managed git,
gh, or GitHub gateway tools. Run capabilities authorize code executing
within that run to acquire its current identity; this is not
hostile-code isolation within one execution principal. Managed commands
prevent automatic credential carryover; arbitrary code deliberately
copying a credential is outside that boundary.
- Uncertain steering acknowledgement deliberately holds new credential
acquisition until reconciliation. Already-started operations retain
their captured identity.
- GitHub private access and provider outages can still fail the specific
operation that needs them. Dedicated grant failure does not fall back to
personal access.

## Model Used

OpenAI GPT-6 through Codex assisted implementation, review, shell
execution, and browser acceptance. The exact model variant and
context-window size are not exposed in this session. Tool use included
TypeScript and Rust tests, database integration tests, GitHub CLI, and
authenticated browser control.

## 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-07 14:32:20 -05:00
..
access.ts Secure Cloud canonical runtime identity (#12766) 2026-09-03 12:01:47 -05:00
activity.ts build(deps): bump zod from 3.25.76 to 4.4.3 (#11719) 2026-08-21 00:04:14 -07:00
adapter-login-route-spine.ts feat(auth): normalize agent login in the sandbox onto one session table and a capability contract (#11730) 2026-08-19 11:51:31 -07:00
adapters.test.ts feat: add Grok device login to the sandbox login panel (#12469) 2026-08-28 21:48:34 -07:00
adapters.ts Remove cheap model profiles (#12683) 2026-09-01 14:57:38 -05:00
agents.ts feat: use the responsible person's GitHub for shared agent operations (#13005) 2026-09-07 14:32:20 -05:00
approvals.ts Remove cheap model profiles (#12683) 2026-09-01 14:57:38 -05:00
assets.ts fix(security): harden privileged server boundaries (#12776) 2026-09-03 14:15:32 -05:00
attention.ts feat(decisions): improve desk triage and queue parity (#10785) 2026-08-03 21:31:45 -05:00
auth.ts feat(server): split the Sentry DSN into front-end and backend variables (#12678) 2026-09-01 11:02:04 -07:00
authz.ts feat(secrets): thread the acting user into user-scoped secret resolution (#10115) 2026-07-23 13:30:26 -07:00
board-chat.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
built-in-agents.ts [codex] Add built-in agents and Reflection Coach bundle (#9206) 2026-07-09 16:29:30 -05:00
cases-schemas.ts feat(runner): add guarded API search and call fallback (#13003) 2026-09-07 14:14:43 -05:00
cases.ts feat(runner): add guarded API search and call fallback (#13003) 2026-09-07 14:14:43 -05:00
cloud.ts feat: make in-app features cloud-aware (#10850) 2026-08-04 23:00:14 -05:00
companies.ts fix(security): harden privileged server boundaries (#12776) 2026-09-03 14:15:32 -05:00
company-import-paths.ts [codex] Runtime control-plane fixes (#6380) 2026-05-20 10:37:11 -05:00
company-skill-policy.ts feat(skills): open-by-default company skill policy and core UX (#9564) 2026-07-15 11:42:40 -05:00
company-skills.ts Add project folder browsing to skill imports (#9930) 2026-08-02 10:55:36 -05:00
connection-intents.test.ts feat(connections): add self-serve intent runtime (#12345) 2026-08-29 12:08:34 -05:00
connection-intents.ts feat: use the responsible person's GitHub for shared agent operations (#13005) 2026-09-07 14:32:20 -05:00
costs.ts security(server): close cross-tenant existence oracle (404 instead of 403) (#3967) 2026-07-14 15:53:09 -07:00
dashboard.ts feat(server): recovery observability report and rate alert (#9644) 2026-07-16 02:34:00 -05:00
decision-queues.ts feat(decisions): add desk workflow and retention (#10672) 2026-08-02 10:47:03 -05:00
decision-training.ts build(deps): bump zod from 3.25.76 to 4.4.3 (#11719) 2026-08-21 00:04:14 -07:00
decisions.ts build(deps): bump zod from 3.25.76 to 4.4.3 (#11719) 2026-08-21 00:04:14 -07:00
environment-selection.ts refactor(environments): make execution environments instance-scoped (#8375) 2026-06-20 09:42:53 -07:00
environments.ts fix(runner): persist warm Daytona workspaces across turns (#12904) 2026-09-06 08:16:12 -05:00
execution-workspaces.ts feat(apps): improve gateway and workspace connection UX (#12340) 2026-08-29 12:08:32 -05:00
experimental-api-metadata.ts feat(runner): add guarded API search and call fallback (#13003) 2026-09-07 14:14:43 -05:00
experimental-api-paths.ts feat(runner): add guarded API search and call fallback (#13003) 2026-09-07 14:14:43 -05:00
file-resources.ts build(deps): bump zod from 3.25.76 to 4.4.3 (#11719) 2026-08-21 00:04:14 -07:00
folders.ts feat: stamp responsible users on activity logs (#9731) 2026-07-16 20:54:55 -05:00
goals.ts security(server): close cross-tenant existence oracle (404 instead of 403) (#3967) 2026-07-14 15:53:09 -07:00
health.ts fix(runner): recover native sessions across restarts (#12845) 2026-09-04 15:03:53 -05:00
inbox-agent-policy.ts feat: stamp responsible users on activity logs (#9731) 2026-07-16 20:54:55 -05:00
inbox-dismissals.ts feat: stamp responsible users on activity logs (#9731) 2026-07-16 20:54:55 -05:00
index.ts feat(runner): add managed provider backends (#12699) 2026-09-02 00:48:30 -05:00
instance-database-backups.ts feat: make in-app features cloud-aware (#10850) 2026-08-04 23:00:14 -05:00
instance-settings.ts Clean up experimental settings features (#12681) 2026-09-01 14:23:05 -05:00
issue-tree-control.ts feat: stamp responsible users on activity logs (#9731) 2026-07-16 20:54:55 -05:00
issues-checkout-wakeup.ts Cut over OpenClaw adapter to strict SSE streaming 2026-03-05 15:54:55 -06:00
issues.ts feat: use the responsible person's GitHub for shared agent operations (#13005) 2026-09-07 14:32:20 -05:00
llms.ts [codex] Add built-in Hermes adapters (#8543) 2026-06-26 16:04:58 -05:00
managed-agent-profiles.ts feat(runner): add managed provider backends (#12699) 2026-09-02 00:48:30 -05:00
onboarding-seed.ts feat(server): receive and apply the Paperclip Cloud onboarding seed (#11098) 2026-08-12 22:54:07 -07:00
openapi.ts feat: use the responsible person's GitHub for shared agent operations (#13005) 2026-09-07 14:32:20 -05:00
org-chart-svg.ts Improve generated company org chart assets 2026-03-23 16:58:07 -05:00
pipelines-schemas.ts feat(runner): add guarded API search and call fallback (#13003) 2026-09-07 14:14:43 -05:00
pipelines.ts feat(runner): add guarded API search and call fallback (#13003) 2026-09-07 14:14:43 -05:00
plugin-ui-static.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
plugins.ts feat: operator-configurable settings visibility via PAPERCLIP_HIDDEN_SETTINGS (#11823) 2026-08-20 17:54:44 -07:00
projects.ts fix(security): harden privileged server boundaries (#12776) 2026-09-03 14:15:32 -05:00
remote-agent-profiles.ts feat(runner): add managed provider backends (#12699) 2026-09-02 00:48:30 -05:00
resource-memberships.ts feat(server): add per-user document stars (#9952) 2026-07-27 19:13:35 -05:00
routines.ts fix(workspaces): attach PR preparation to existing branches (#11703) 2026-08-21 17:23:18 -05:00
secrets.ts fix(security): harden privileged server boundaries (#12776) 2026-09-03 14:15:32 -05:00
setup-token-route.test.ts feat(agent-login): resume an active login session and permit concurrent login terminals (#12861) 2026-09-05 10:03:13 -07:00
sidebar-badges.ts feat: add attention queue and Decisions surface (#9380) 2026-07-10 17:09:57 -05:00
sidebar-preferences.ts feat: stamp responsible users on activity logs (#9731) 2026-07-16 20:54:55 -05:00
smoke-lab.ts feat: stamp responsible users on activity logs (#9731) 2026-07-16 20:54:55 -05:00
status-cards.ts feat(status-cards): join summary-mentioned issues to watched set (#10205) 2026-07-24 16:44:56 -05:00
summary-slots.ts feat: add built-in summarizer and summary slots (#9713) 2026-07-17 11:03:07 -05:00
teams-catalog.ts [codex] Add teams catalog extraction (#7550) 2026-06-05 12:55:49 -05:00
tool-access-connection-intent.test.ts Simplify app connections and enable managed Google access (#12728) 2026-09-02 14:05:53 -05:00
tool-access.ts feat(connections): add durable GitHub identities and webhooks (#12843) 2026-09-04 18:02:52 -05:00
tool-gateway.ts feat(runner): add Codex-native application integration (#12591) 2026-08-31 14:38:38 -05:00
user-profiles.ts Skill Studio: three-pane skill IDE with sandboxed test runs (#9241) 2026-07-09 13:08:56 -05:00
workspace-command-authz.ts fix(security): harden privileged server boundaries (#12776) 2026-09-03 14:15:32 -05:00
workspace-runtime-service-authz.ts feat(runtime): managed Tailscale HTTPS lifecycle, durable runtime leases, and bounded control recovery (#11525) 2026-08-17 06:23:33 -04:00