Add reusable OAuth lifecycle custody - #2602
Conversation
|
Here's a visual recap of what changed: Open the full interactive recap |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@3mdistal should we get this in? also some agent review stuff if you agree w/ it: Review summaryThe overall OAuth custody design looks solid, but I found four remaining issues:
The latest Postgres bot comment also appears stale: this head writes seconds to |
…-foundation # Conflicts: # packages/core/src/oauth-tokens/migrations.spec.ts # packages/core/src/oauth-tokens/migrations.ts # packages/core/src/server/release-migrations.ts
|
Addressed all four findings on the refreshed head:
The timestamp concern remains stale: Local exact-head evidence: 96 focused tests plus the Node 22 SQLite migration test, Core typecheck, all 51 guards, and a fresh independent security review with no remaining blocker. GitHub CI is rerunning now.
|
…-foundation # Conflicts: # scripts/qa-standalone-chat-dev-smoke.ts
There was a problem hiding this comment.
Builder reviewed your changes — looks good ✅
Review Details
Incremental Code Review Summary
I reviewed the latest PR #2602 head with two parallel agents. Previously reported issues covering lease recovery, private-origin revocation, legacy Postgres timestamps, and MCP removal races were not reposted and remain addressed.
The current OAuth custody implementation continues to hold up across lifecycle transitions, owner/resource handling, refresh and revocation fencing, migration compatibility, SSRF protections, MCP integration, and the standalone smoke adjustment. Focused agent verification passed 83–99 tests across OAuth, token-store, migration, MCP, and URL-safety suites. No new or regressed confirmed bugs or security issues were found.
This remains a high-risk authentication and credential-lifecycle change.
🧪 Browser testing: Skipped — PR only modifies backend/config/docs/tests, no UI impact.

Problem
Agent Native already supports OAuth-enabled remote MCP providers such as Linear. What it lacked was one reusable credential lifecycle that later integrations can trust when tokens expire, multiple server processes race to refresh them, a user reconnects, or a provider revokes access.
Without this foundation, later managed-AI and Fusion lanes would duplicate security-sensitive logic or drift back toward the obsolete installation-key design from closed PR #2515.
Approach
Add a provider-, resource-, and owner-scoped lifecycle over the encrypted OAuth token store, then route the existing MCP OAuth adapter through it without changing the visible connection journey.
The product can eventually present one Builder sign-in while retaining separate capability grants underneath. This PR deliberately adds no Builder connection UI, managed-AI or Fusion consumer, BuilderSync migration, feature enablement, credential, or deployment change.
What changed
missing,malformed,connected,expired, andreconnect_requiredcredential states./agentdependency graph before strict browser assertions and retries only recognized transient dev-server database restarts.Safety and product boundary
Verification
Current exact head:
3d925f6a7.Passed locally against this exact head:
git diff --check.The full GitHub Actions matrix passed on
3d925f6a7, including build, fast tests, Core integration, Postgres locking, security guards, scaffold E2E, and the repaired standalone Chat smoke.Additional acceptance evidence on the same lifecycle design before the current-main refresh:
Review focus
Follow-ups (separate lanes)