Skip to content

[3512 by Claude Opus 5.5] OAuth sign-in for MCP servers: connect from Settings in the browser, tokens held and refreshed by Core - #3536

Merged
integry merged 7 commits into
3509-epic-extensions-library-14jfrom
3512/claude-opus-5-5-oauth-sign-in-for-mcp-ser-20261113-1145-czn
Nov 13, 2026
Merged

integry merged 7 commits into
3509-epic-extensions-library-14jfrom
3512/claude-opus-5-5-oauth-sign-in-for-mcp-ser-20261113-1145-czn

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3512

Branch: 3512/claude-opus-5-5-oauth-sign-in-for-mcp-ser-20261113-1145-czn
Commits: ✅ Changes committed (5d09009)


AI Processing Completed

Execution Details:

Summary:
I've implemented OAuth sign-in for library MCP servers, from the shared contract through Core, the API, Settings and the docs. The new and related tests pass. I didn't run the full repository suite, and nothing has been tried against a real OAuth provider: all OAuth tests use a synthetic authorization server and MCP server.

What it does

  • Contract: an https server can use authentication: 'oauth', with optional scopes, a clientId and a write-only client secret. The secret is stored like a Bearer token, and changing the URL, authentication type or client id never carries it over.
  • Discovery: ProPR reads the server's 401 challenge, falling back to the well-known location, then the authorization server's metadata, and requires PKCE S256. Every discovery, registration, token and revocation request goes through the existing endpoint policy, so private and loopback addresses are refused.
  • Sign-in: authorization code with PKCE and the resource parameter. The state is single-use, expires after 10 minutes and is bound to the session, the administrator, the item and its endpoint. The callback checks iss and stores nothing unless the code exchange succeeds. The redirect URI and the public client metadata URL come from the same public base URL ProPR's own MCP server uses; without one, Connect is disabled with an explanation.
  • Token custody: tokens are sealed in a new extension_oauth_connections table, with pending sign-ins and an audit trail in their own tables. Connecting, refreshing and disconnecting create no library revision. Native exports erase connections and pending sign-ins and keep the audit trail.
  • Refresh: tokens are refreshed a minute before they expire and after an upstream 401. Refresh is single-flight within a process and across processes, and a rotated refresh token is saved together with the new access token. A refused refresh moves the item to Needs sign-in once and sends one notification; network errors are retried and change nothing.
  • Gateway and launch: the gateway asks Core for the current token on every call, refreshes and retries once on 401, and redacts the token from output. Unconnected or Needs-sign-in servers are skipped with the reason oauth_not_connected or oauth_needs_sign_in, and the run continues. Changing the URL, authentication or client id, or renaming or removing the server, discards the connection; disabling it keeps the connection.
  • API: check, start, callback, disconnect and audit routes, plus the public client metadata document. The OpenAPI spec and client types are regenerated.
  • Settings: the server form adds OAuth sign-in with scopes, client id and secret, the redirect URI, the shared-identity warning and Check. Server rows show the connection state, who connected and when, the granted scopes, and Connect, Reconnect and Disconnect. Connect opens the provider in a new tab, and the row refreshes when you come back to Settings.
  • Docs: agent-extensions.md has a new "OAuth servers" section covering everything the issue asked for.

Two choices that differ from the issue's wording

  • Registration order: if an administrator enters a client id, ProPR uses that pre-registered client even when the server also supports a metadata document or dynamic registration. Otherwise it tries the metadata document, then dynamic registration. Ignoring a client id someone typed in seemed wrong; the Check result and the docs both say which method will be used.
  • Notification category: the Needs-sign-in notification uses the existing system_failure kind with component extensions.oauth. A new kind would need schema changes, because the allowed kinds are fixed in the notification tables. I checked that the event passes the notification validator.

Tests

  • Core: 8 tests cover every backend acceptance criterion except API admin-only access and the callback's session binding, which the API route test covers. The sentinel test also captures logger calls, and the existing export test now includes OAuth data. The existing extension suites pass, 131 tests in total.
  • API: one route test covers administrator-only access, the session-bound callback, the public metadata document, token-free responses and the case with no public base URL.
  • UI: 7 new component tests cover the three states and the actions, and all 286 Settings and extension UI tests pass.
  • Playwright: a new spec drives Connect through the synthetic provider page and the callback; it and the existing extension spec pass (8 tests).
  • Checks: typecheck and zero-warning lint pass on the touched packages, and the OpenAPI up-to-date check passes.
  • Two root tests (test/claudeExtensionEnvironment.test.ts and test/extensionLaunchIntegration.test.ts) failed when run together with others because they share one test database file. Each passes when run on its own database.

Screenshots of the connected server row and the OAuth server form are attached as previews.

Detailed Logs:

  • Conversation: 113 messages
  • Session: 443ef1f8-774e-47f2-a507-c36bb8ca3869

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3512-2026-11-13T12-29-11-448Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3512-2026-11-13T12-29-11-448Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: I've implemented OAuth sign-in for library MCP servers, from the shared contract through Core, the API, Settings and the docs. The new and related tests pass. I didn't run the full repository suite, a...


This PR was created automatically by ProPR after processing issue #3512.


💡 Need changes?

Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!


Visual preview

OAuth MCP server connected

OAuth MCP server connected

Settings → Skills & MCP servers after Connect: the OAuth server row shows Connected, who connected it and when, the granted scopes, and Reconnect / Disconnect. Captured by the Playwright spec against the synthetic provider.

Connect sign-in required. Original retained until 2027-02-11T12:29:16.661Z.

View the full-resolution original in ProPR Connect

OAuth sign-in settings in the server form

OAuth sign-in settings in the server form

Authentication: OAuth sign-in with the shared-identity warning, scopes, a pre-registered client id and write-only client secret, the redirect URI to register, and Check.

Connect sign-in required. Original retained until 2027-02-11T12:29:17.999Z.

View the full-resolution original in ProPR Connect

…ed contract through Core, the API, Settings and the docs. The new and related tests pass. I didn't run the full repository suite, and nothing has been tried against a real OAuth provider: all OAuth tests use a synthetic authorization server and MCP server.

What it does
- Contract: an `https` server can use `authentication: 'oauth'`, with optional `scopes`, a `clientId` and a write-only client secret. The secret is stored like a Bearer token, and changing the URL, authentication type or client id never carries it over.
- Discovery: ProPR reads the server's `401` challenge, falling back to the well-known location, then the authorization server's metadata, and requires PKCE `S256`. Every discovery, registration, token and revocation request goes through the existing endpoint policy, so private and loopback addresses are refused.
- Sign-in: authorization code with PKCE and the `resource` parameter. The `state` is single-use, expires after 10 minutes and is bound to the session, the administrator, the item and its endpoint. The callback checks `iss` and stores nothing unless the code exchange succeeds. The redirect URI and the public client metadata URL come from the same public base URL ProPR's own MCP server uses; without one, Connect is disabled with an explanation.
- Token custody: tokens are sealed in a new `extension_oauth_connections` table, with pending sign-ins and an audit trail in their own tables. Connecting, refreshing and disconnecting create no library revision. Native exports erase connections and pending sign-ins and keep the audit trail.
- Refresh: tokens are refreshed a minute before they expire and after an upstream `401`. Refresh is single-flight within a process and across processes, and a rotated refresh token is saved together with the new access token. A refused refresh moves the item to Needs sign-in once and sends one notification; network errors are retried and change nothing.
- Gateway and launch: the gateway asks Core for the current token on every call, refreshes and retries once on `401`, and redacts the token from output. Unconnected or Needs-sign-in servers are skipped with the reason `oauth_not_connected` or `oauth_needs_sign_in`, and the run continues. Changing the URL, authentication or client id, or renaming or removing the server, discards the connection; disabling it keeps the connection.
- API: check, start, callback, disconnect and audit routes, plus the public client metadata document. The OpenAPI spec and client types are regenerated.
- Settings: the server form adds OAuth sign-in with scopes, client id and secret, the redirect URI, the shared-identity warning and Check. Server rows show the connection state, who connected and when, the granted scopes, and Connect, Reconnect and Disconnect. Connect opens the provider in a new tab, and the row refreshes when you come back to Settings.
- Docs: `agent-extensions.md` has a new "OAuth servers" section covering everything the issue asked for.

Two choices that differ from the issue's wording
- Registration order: if an administrator enters a client id, ProPR uses that pre-registered client even when the server also supports a metadata document or dynamic registration. Otherwise it tries the metadata document, then dynamic registration. Ignoring a client id someone typed in seemed wrong; the Check result and the docs both say which method will be used.
- Notification category: the Needs-sign-in notification uses the existing `system_failure` kind with component `extensions.oauth`. A new kind would need schema changes, because the allowed kinds are fixed in the notification tables. I checked that the event passes the notification validator.

Tests
- Core: 8 tests cover every backend acceptance criterion except API admin-only access and the callback's session binding, which the API route test covers. The sentinel test also captures logger calls, and the existing export test now includes OAuth data. The existing extension suites pass, 131 tests in total.
- API: one route test covers administrator-only access, the session-bound callback, the public metadata document, token-free responses and the case with no public base URL.
- UI: 7 new component tests cover the three states and the actions, and all 286 Settings and extension UI tests pass.
- Playwright: a new spec drives Connect through the synthetic provider page and the callback; it and the existing extension spec pass (8 tests).
- Checks: typecheck and zero-warning lint pass on the touched packages, and the OpenAPI up-to-date check passes.
- Two root tests (`test/claudeExtensionEnvironment.test.ts` and `test/extensionLaunchIntegration.test.ts`) failed when run together with others because they share one test database file. Each passes when run on its own database.

Screenshots of the connected server row and the OAuth server form are attached as previews.
@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

/ultrafix goal=8 max=10
Triggered automatically by the requested execution settings.

@propr-dev propr-dev Bot added the ultrafix label Nov 13, 2026
@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 10)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

This PR implements OAuth discovery, sign-in, token custody, refresh, gateway integration, Settings controls and documentation. It needs significant rework around concurrent credential lifecycle operations before merge.

✅ Credential isolation — Tokens and PKCE verifiers are sealed with identity bindings, and native exports explicitly erase connections and pending sign-ins.

✅ Session-bound sign-in — Callback handling checks single-use state, expiry, administrator identity, browser session and issuer before exchanging the code.

✅ Gateway integration — Each OAuth call obtains a current token, retries once after an upstream 401, and redacts the tokens used.

This is a static review of the supplied code; no commands or tests were run. The authoritative checks show no failures and two pending checks.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 In-flight callbacks can undo Disconnect

  • Required behavior: Disconnect must remove the connection and cancel pending sign-ins; configuration changes must prevent an old sign-in from restoring discarded credentials.

  • Evidence: packages/core/src/extensions/extensionOAuthStore.ts, completeSignIn and disconnect.

    1. A callback consumes its pending row, validates the current server and awaits exchangeAuthorizationCode.
    2. While that request is outstanding, an administrator disconnects the server. disconnect deletes its connection and pending rows and returns successfully.
    3. The exchange completes. The callback's final transaction checks only administrator authority, then inserts a connected row.
    4. The disconnected server becomes connected again without another Connect action.

    The same window permits a callback to insert stale credentials after saveLibrary changes or removes the server and discards its connection. The pending row has already been deleted, so deleting pending rows cannot cancel this callback. The final transaction rechecks neither cancellation nor the server binding.

    static trace: Followed the callback's exchange await through its final insert, alongside the disconnect transaction and discardStaleOAuthConnections. No execution was performed.

  • Minimum fix: Retain a sign-in attempt or generation that disconnect and binding changes invalidate. In the final transaction, require that attempt to remain valid and recheck the current server binding before storing tokens.

F2: 🔴 Old refreshes can overwrite new connections

  • Required behavior: Refresh completion must update only the connection generation that initiated it; reconnecting must preserve the newly authorized identity and credentials.

  • Evidence: packages/core/src/extensions/extensionOAuthStore.ts, refreshOnce, disconnect and completeSignIn.

    1. A connection at version 1 begins refreshing. The provider issues a response, but delivery remains outstanding at the refreshTokens await.
    2. Disconnect deletes that connection. A subsequent sign-in for the same server completes and inserts a new connection at version 1.
    3. The old refresh resumes. Its update matches only instance, server name and version 1, so it overwrites the new connection's sealed tokens.
    4. The row retains the new connection's public metadata and administrator attribution while holding credentials from the previous connection. With a different dynamically registered client ID, the old sealing identity also makes the replacement blob undecryptable under the new row.

    The version predicate does not distinguish deleted and recreated rows. Disconnect and reconnect do not invalidate the process-wide inFlight entry either, allowing callers of the new connection to join old refresh work.

    static trace: Verified that new rows reset to version 1, refresh writes use only the reused key/version, and single-flight keys contain only instance ID and server name. The response-delivery interruption is outside any database transaction.

  • Minimum fix: Give every connection generation a unique identity. Include it in refresh updates, failure transitions, lease release and single-flight keys, and reject results belonging to a replaced generation.

F3: 🔴 Refresh retries can disclose replacement secrets

  • Required behavior: Changing a server URL or client ID must never transfer its new client secret to the previous authorization server.

  • Evidence: packages/core/src/extensions/extensionOAuthStore.ts, refreshOnce and clientFor.

    1. A pre-registered connection starts refreshing against its stored authorization-server metadata.
    2. The first request fails transiently, and refreshOnce awaits its retry delay.
    3. During that delay, an administrator changes the server URL or client ID and supplies a replacement client secret. Saving correctly discards the old connection.
    4. The old refresh retries. clientFor reads the current library secret by server name, ignores the returned server binding, and combines that new secret with the old row's client ID and token endpoint.
    5. The replacement secret is sent to the previous authorization server.

    Deleting the connection and the final version check cannot prevent this disclosure: the retry sends credentials before checking whether its eventual database update succeeds. The disconnect revocation path also obtains credentials through the same binding-blind helper.

    static trace: Traced the retry delay, repeated clientFor invocation, currentServerCredential return value and construction of the outgoing token request.

  • Minimum fix: Resolve pre-registered credentials only when the current server still matches the connection's endpoint, authentication and client ID. Revalidate connection ownership before retries, and apply the same binding check to revocation.

F4: 🔴 Refresh lease expires during supported retries

  • Required behavior: Refresh must remain single-flight across processes and preserve rotated refresh tokens.

  • Evidence: packages/core/src/extensions/extensionOAuthStore.ts, LEASE_MS and refreshOnce; packages/core/src/extensions/extensionOAuthHttp.ts, createOAuthHttpsTransport.

    1. Process A acquires the fixed 30-second lease. Its first two requests each return a transient failure after 9.9 seconds.
    2. Including the configured 250 ms and 500 ms retry delays, its third request starts around 20.55 seconds. The provider rotates the refresh token immediately but delays its response until 30.45 seconds—within that request's ten-second timeout.
    3. At 30.1 seconds, process B starts a refresh and acquires the expired lease. Acquisition neither changes the version nor establishes a distinct owner.
    4. B submits the old refresh token, receives a refusal, and marks the connection needs_sign_in, incrementing its version.
    5. A receives the successful rotation response, but its version-guarded write now fails. The valid rotated token is lost, and the administrator must reconnect.

    This ordering fits the production timeout and retry settings. There is no lease renewal; the in-memory single-flight map cannot coordinate separate processes. Version checks prevent A's final write but do not prevent B's duplicate exchange or incorrect failure transition.

    static trace: Calculated the permitted request durations and retry delays against the lease lifetime, then traced lease acquisition and needsSignIn.

  • Minimum fix: Keep the lease valid throughout the bounded retry operation, using renewal or a total operation deadline safely inside its lifetime. Fence completion, failure transitions and release with a unique lease owner.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Exercise the real browser callback

The Playwright test intercepts both the start endpoint and callback, while the API test supplies session identity through test headers. A browser integration test using the actual session middleware and callback would strengthen confidence in cookie and route composition. This is additional coverage, separate from the demonstrated lifecycle defects.

Score

The implementation covers the feature broadly and includes useful tests, but credential disclosure and concurrent lifecycle failures prevent merging. Passing checks do not cover these demonstrated interleavings.

Score: 5/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 56s
  • Tokens: 109,585 (106,850 in / 2,735 out)
  • Cost: $1.10

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 F2 F3 F4 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 7b0bb08

Addressed 1 AI review comment (IDs: 6853397861)

Addressed findings F1, F2, F3, F4

Summary of Changes

I've fixed F1–F4 in Core's OAuth store and added a regression test for each. All 12 tests in packages/core/test/extensionOAuth.test.ts pass, and the 4 new ones all fail when run against the original code. Typecheck and zero-warning lint pass on Core. I didn't run the full repository suite. Nothing here has been tried against a real OAuth provider, only the synthetic one.

F1 – A sign-in still in progress can no longer undo Disconnect

  • The callback no longer deletes its pending row when it starts. It marks the row as claimed and keeps it until it finishes, so the row now stands for that sign-in attempt.
  • Disconnect and library saves that change or remove the server delete that row, which cancels the attempt.
  • The final transaction first deletes the claimed row and refuses with "The sign-in was cancelled; connect again" if it is already gone. It then reads the current library inside the same transaction and checks the server's URL, authentication and client id again before storing anything.
  • Library saves now also cancel pending sign-ins when only the client id changes; before, they only reacted to URL and authentication changes. Disconnect now cancels pending rows before deleting the connection.
  • Expiry cleanup leaves a claimed row alone for one extra minute, so cleanup can't cancel an exchange that is still running.

F2 – An old refresh can no longer overwrite a new connection

  • Every sign-in gives the connection a new random generation. Refresh writes, the Needs-sign-in change, lease release and the in-process single-flight key all include it.
  • A refresh result for a replaced connection is thrown away with a new error type. The gateway also no longer falls back to the old connection's token after a network error once the connection has been replaced.

F3 – A retry can no longer send a replacement secret to the old server

  • Refresh and revocation now get the client only if the current server still matches the connection's URL, authentication and client id. Otherwise they stop before sending anything.
  • Before each retry, the refresh also renews its lease, and that renewal only succeeds if the connection is still the same one. A connection discarded during the retry delay therefore never gets the retry.

F4 – The refresh lease now lasts through every retry

  • Each lease has its own owner id. Completion, the Needs-sign-in change and release only apply to the owner's lease.
  • The lease is renewed to 30 seconds before every token request.
  • The HTTPS transport now counts DNS lookup within its 10-second limit and won't send a request once that limit has passed. So no single request can outlast a renewed lease.

Schema: the PR's own migration, 20261113120000_extension_oauth.js, gains generation and refresh_lease_owner on connections and claim on pending sign-ins. I edited it in place because it hasn't been released. A database that already ran the earlier version of this migration won't get the new columns.

New tests (in packages/core/test/extensionOAuth.test.ts):

  • Disconnect, a URL change, removing the server and a client id change during the code exchange each cancel the sign-in and leave nothing stored.
  • An old refresh neither overwrites a new connection that restarted at version 1 nor holds up that connection's own refresh.
  • For both a client id change and a URL change during a transient failure, the replacement secret is never sent.
  • The finding's timing (two slow failures, then a rotating response that arrives late) runs against a second copy of the module standing in for another process. The second process waits and uses the first one's result, without a second token exchange or a Needs-sign-in change.

Other results:

  • The API route test for OAuth passes.
  • In extensionProfiles.test.ts, the test "catalog stdio is callable through both selected authorized launcher policies…" fails, and it fails the same way on the original code.
  • All tests in extensionTaskAutoApply.test.ts pass, but the process never exits; I stopped it with a time limit.
  • Both suites need PROPR_DEMO_MODE=true to run here.

Not tested: the revocation side of F3, meaning a mismatched connection reaching Disconnect. It uses the same check as refresh. I couldn't set it up without forcing an inconsistent database row.

Nothing visible changed, so there are no previews.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 24m 20s
  • Tokens: 3,693,322 (3,692,943 in / 379 out)
  • Cost: $1.32

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…on test for each. All 12 tests in `packages/core/test/extensionOAuth.test.ts` pass, and the 4 new ones all fail when run against the original code. Typecheck and zero-warning lint pass on Core. I didn't run the full repository suite. Nothing here has been tried against a real OAuth provider, only the synthetic one.

I've fixed F1–F4 in Core's OAuth store and added a regression test for each. All 12 tests in `packages/core/test/extensionOAuth.test.ts` pass, and the 4 new ones all fail when run against the original code. Typecheck and zero-warning lint pass on Core. I didn't run the full repository suite. Nothing here has been tried against a real OAuth provider, only the synthetic one.

**F1 – A sign-in still in progress can no longer undo Disconnect**
- The callback no longer deletes its pending row when it starts. It marks the row as claimed and keeps it until it finishes, so the row now stands for that sign-in attempt.
- Disconnect and library saves that change or remove the server delete that row, which cancels the attempt.
- The final transaction first deletes the claimed row and refuses with "The sign-in was cancelled; connect again" if it is already gone. It then reads the current library inside the same transaction and checks the server's URL, authentication and client id again before storing anything.
- Library saves now also cancel pending sign-ins when only the client id changes; before, they only reacted to URL and authentication changes. Disconnect now cancels pending rows before deleting the connection.
- Expiry cleanup leaves a claimed row alone for one extra minute, so cleanup can't cancel an exchange that is still running.

**F2 – An old refresh can no longer overwrite a new connection**
- Every sign-in gives the connection a new random `generation`. Refresh writes, the Needs-sign-in change, lease release and the in-process single-flight key all include it.
- A refresh result for a replaced connection is thrown away with a new error type. The gateway also no longer falls back to the old connection's token after a network error once the connection has been replaced.

**F3 – A retry can no longer send a replacement secret to the old server**
- Refresh and revocation now get the client only if the current server still matches the connection's URL, authentication and client id. Otherwise they stop before sending anything.
- Before each retry, the refresh also renews its lease, and that renewal only succeeds if the connection is still the same one. A connection discarded during the retry delay therefore never gets the retry.

**F4 – The refresh lease now lasts through every retry**
- Each lease has its own owner id. Completion, the Needs-sign-in change and release only apply to the owner's lease.
- The lease is renewed to 30 seconds before every token request.
- The HTTPS transport now counts DNS lookup within its 10-second limit and won't send a request once that limit has passed. So no single request can outlast a renewed lease.

**Schema:** the PR's own migration, `20261113120000_extension_oauth.js`, gains `generation` and `refresh_lease_owner` on connections and `claim` on pending sign-ins. I edited it in place because it hasn't been released. A database that already ran the earlier version of this migration won't get the new columns.

**New tests** (in `packages/core/test/extensionOAuth.test.ts`):
- Disconnect, a URL change, removing the server and a client id change during the code exchange each cancel the sign-in and leave nothing stored.
- An old refresh neither overwrites a new connection that restarted at version 1 nor holds up that connection's own refresh.
- For both a client id change and a URL change during a transient failure, the replacement secret is never sent.
- The finding's timing (two slow failures, then a rotating response that arrives late) runs against a second copy of the module standing in for another process. The second process waits and uses the first one's result, without a second token exchange or a Needs-sign-in change.

**Other results:**
- The API route test for OAuth passes.
- In `extensionProfiles.test.ts`, the test "catalog stdio is callable through both selected authorized launcher policies…" fails, and it fails the same way on the original code.
- All tests in `extensionTaskAutoApply.test.ts` pass, but the process never exits; I stopped it with a time limit.
- Both suites need `PROPR_DEMO_MODE=true` to run here.

**Not tested:** the revocation side of F3, meaning a mismatched connection reaching Disconnect. It uses the same check as refresh. I couldn't set it up without forcing an inconsistent database row.

Nothing visible changed, so there are no previews.

PR: #3536
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@integry

integry commented Nov 13, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

This PR adds OAuth discovery, sign-in, encrypted token custody, refresh, API routes and Settings controls. The implementation is substantial, but needs changes before merge because proactive refresh can immediately invalidate a usable connection that has no refresh token.

✅ Session-bound sign-in — Pending authorization binds the state to the administrator, session and server configuration; completion rechecks authorization and configuration before committing.

✅ Refresh fencing — Connection generations, versions and lease owners prevent an outstanding refresh from overwriting a replacement connection.

✅ Export custody — Native exports explicitly delete OAuth connections and pending sign-ins while preserving audit records.

This review uses static tracing of the supplied code; no commands or tests were run. The authoritative checks report 28 passed, five pending and no failures.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F5: 🔴 Keep valid tokens without refresh tokens

  • Required behavior: A connected OAuth server must remain usable while its access token is valid. Proactive refresh must not prematurely turn a usable connection into Needs sign-in.

  • Evidence: packages/core/src/extensions/extensionOAuthStore.ts, accessToken and refreshOnce.

    1. An authorization server successfully issues an access token with expires_in: 30 and no refresh token. requestTokens accepts this response, and completeClaimed persists the connection as connected.
    2. A run launches with that connected server and makes its first gateway call. accessToken finds that the token is inside the fixed 60-second refresh margin and calls refresh.
    3. refreshOnce acquires the lease, finds no refresh token, and immediately calls needsSignIn, despite the access token still being valid.
    4. The gateway returns a connection failure without sending the valid token upstream. The connection remains Needs sign-in, administrators are notified, and subsequent runs skip it. Reconnecting produces the same failure when the provider again issues a short-lived access token without a refresh token.

    The same premature transition affects longer-lived tokens during their final minute. The fallback in accessToken only handles OAuthNetworkError; this path throws an authorization-marked OAuthProtocolError, so it cannot preserve the valid token. The synthetic fixture always issues refresh tokens and therefore does not exercise this case.

    static trace: Followed token parsing, callback persistence, launch resolution, gateway credential acquisition and the durable Needs-sign-in transition in the supplied diff. proposed regression: Issue a 30-second access token without a refresh token and assert that gateway calls succeed until expiration or an upstream rejection.

  • Minimum fix: When no refresh token exists, return an unexpired access token instead of proactively refreshing. Transition to Needs sign-in upon actual expiration or upstream rejection; retain proactive refresh for connections that have refresh tokens.

Suggestions

These are optional follow-ups and are not sent to /fix.

S2: 🟢 Exercise the real browser boundary

The Playwright test mocks the start route, provider and callback, while the API test injects session identity directly. A follow-up integration test using the real session middleware and callback would validate cookie delivery and session continuity across browser navigation. This would strengthen coverage beyond the existing component and protocol tests; no additional session defect is established by the supplied code.

Score

The implementation has strong credential custody and concurrency protections, but a supported token-response shape can produce an unusable connection immediately after successful sign-in. The remaining checks are pending, with no reported current-head failures.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 3s
  • Tokens: 112,426 (110,684 in / 1,742 out)
  • Cost: $1.08

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F5 S2

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR implements OAuth across credential storage, discovery, gateway calls, Settings, and documentation. It needs changes before merge: token expiry handling and disconnect coordination leave two reachable correctness defects.

✅ Credential custody — Tokens and PKCE verifiers are sealed; native exports explicitly erase connections and pending sign-ins.

✅ Callback binding — Single-use state checks bind completion to the initiating administrator, session, server endpoint, and client.

✅ Refresh fencing — Generation, version, and lease-owner checks prevent an old refresh result from overwriting a replacement connection.

This review used static tracing only; no commands were run. The supplied current checks show 34 passed, none failed, and one pending.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F6: 🔴 Keep unrefreshable tokens usable until expiry

  • Required behavior: A successfully connected server must remain usable while its access token is valid; proactive refresh must not invalidate a usable connection merely because no refresh token was issued.

  • Evidence: packages/core/src/extensions/extensionOAuthStore.ts, accessToken and refreshOnce.

    1. A provider successfully issues an access token with expires_in: 30 and no refresh token. requestTokens explicitly accepts this response, and completion persists a connected row.
    2. The first gateway call invokes accessToken. Because expiry is within the 60-second refresh margin, it calls refresh.
    3. refreshOnce finds no refresh token and immediately invokes needsSignIn, despite the access token still being valid.
    4. The gateway fails without sending the valid token, and subsequent runs skip the server. Reconnecting produces the same failure for another short-lived token.

    The lease prevents competing refreshes but does not check whether the token has actually expired. static trace: The accepted optional refresh token, expiry-margin branch, and unconditional missing-refresh-token transition establish this sequence.

  • Minimum fix: When no refresh token exists, return the access token until its actual expiry. Transition to Needs sign-in after expiry or an upstream rejection, retaining proactive refresh for connections that have refresh tokens.

F7: 🔴 Coordinate disconnect with token rotation

  • Required behavior: Disconnect must revoke the connection’s current tokens when revocation is supported before discarding their custody; concurrent refresh must not leave newly issued tokens active and untracked.

  • Evidence: packages/core/src/extensions/extensionOAuthStore.ts, disconnect, refreshOnce, and completeClaimed.

    1. Disconnect reads connection A and its tokens, then awaits the refresh-token revocation request.
    2. While that request is outstanding, a gateway call acquires the refresh lease. Disconnect has neither changed the connection state nor acquired its lease.
    3. Refresh rotates A’s tokens and persists the new access and refresh tokens. The old refresh token is now invalid.
    4. Revocation of the old tokens completes. Disconnect then deletes the connection by instance and server name, without rereading the rotated credentials.
    5. The new tokens remain active at the provider, but ProPR has deleted the only stored credentials needed to revoke them.

    The same unconditional deletion also removes a replacement connection completed by completeClaimed during the revocation awaits, although only the previous connection’s tokens were submitted for revocation. Refresh’s generation/version fencing does not prevent either sequence because disconnect does not participate in that fencing.

    static trace: These interleavings follow the explicit network awaits and unconditional final deletion. The supplied synthetic provider also models rotation invalidating the old refresh token and revocation deleting only the submitted token. proposed regression: Hold revocation, complete a rotation or replacement sign-in, then verify disconnect cannot silently discard unrevoked successor credentials.

  • Minimum fix: Establish a durable disconnect fence before revocation, coordinate with any refresh already in flight, and revoke the resulting current credentials. Fence final deletion to the claimed connection and prevent a concurrent callback from being silently deleted without revocation.

Suggestions

These are optional follow-ups and are not sent to /fix.

S3: 🟢 Exercise the actual browser session

The Playwright test mocks both the start endpoint and callback, while the API test injects session identity through headers. A browser integration test using the actual session middleware would strengthen confidence in cookie-bound callbacks. This is additional coverage, not a demonstrated authentication defect.

Score

The implementation has substantial security controls and broad passing coverage, but the two credential lifecycle defects require correction before merge.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 45s
  • Tokens: 111,570 (109,549 in / 2,021 out)
  • Cost: $1.09

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F6 F7 S3

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 6c9e796

Addressed 2 AI review comments (IDs: 6854396519, 6854627684)

Addressed findings F5, F6, F7

Summary of Changes

I've fixed F5, F6 and F7 in Core's OAuth store (packages/core/src/extensions/extensionOAuthStore.ts) and added a regression test for each. The 3 new tests fail against the previous code and pass now. All 15 tests in packages/core/test/extensionOAuth.test.ts pass. So do 198 tests across the Core extension suites, the database export test and the API OAuth route test, which I ran with PROPR_DEMO_MODE=true because without it two suites fail on the GitHub-auth check. Core typecheck and zero-warning lint pass. I didn't run the full repository suite, and nothing has been tried against a real OAuth provider.

F5 / F6 (tokens without a refresh token): when a connection has no refresh token, accessToken now keeps using the access token until it actually expires. It no longer tries to refresh during the last minute. After expiry, or when the upstream server refuses the token, the connection moves to Needs sign-in as before. Connections that have a refresh token still refresh a minute early. The new test uses a 30-second token with no refresh token: gateway calls work, nothing is refreshed and no one is notified. Then, both after real expiry and after an upstream rejection, it checks the move to Needs sign-in with one notification.

F7 (disconnect during token rotation):

  • Fence before revoking. Disconnect now takes the connection's refresh lease and marks it disconnecting before contacting the provider. If a refresh holds the lease, Disconnect waits for it, then revokes the tokens that are current after it finishes. The wait is bounded; if it runs out, Disconnect returns a 409 asking to try again.
  • No new refresh. While a connection is disconnecting, the gateway can't get a token and no refresh can start.
  • No replacement by a callback. A sign-in callback refuses with a 409 instead of overwriting a disconnecting connection. It checks before exchanging the code, and again inside the save transaction. Pending sign-ins are cancelled both when Disconnect starts and when it finishes.
  • Fenced deletion. The final delete only removes the connection Disconnect fenced, and the audit entry is written only if that delete happened.
  • What Settings shows. A disconnecting connection appears as Needs sign-in, so if a Disconnect stops halfway, Disconnect is still available to finish it.

Two tests cover this:

  • Refresh already in flight: Disconnect waits and revokes the rotated tokens.
  • Revocation held open: no refresh reaches the provider, and a callback is refused without exchanging its code. In both cases only the fenced tokens are revoked and nothing is left behind.

Existing test I changed: "a refresh of a replaced connection…" used Disconnect to replace a connection while a refresh was still outstanding. With F7, Disconnect now waits for that refresh, so the test would hang. It now replaces the connection through a library change, which still exercises the successor fencing it was written for.

Problems I found but didn't fix (outside the selected findings):

  • When a sign-in callback is cancelled after its code exchange (by Disconnect or a server change), the tokens the provider just issued are never revoked. This was already true before this change.
  • When a library save discards a connection (new URL, authentication type, client id, rename or removal), it deletes the tokens without revoking them.

This change has no visible effect in the UI, so I didn't create previews.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 10m 16s
  • Tokens: 1,619,948 (1,603,165 in / 16,783 out)
  • Cost: $1.03
  • Subscription usage: Weekly +1%, Fable +1%

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…ore/src/extensions/extensionOAuthStore.ts`) and added a regression test for each. The 3 new tests fail against the previous code and pass now. All 15 tests in `packages/core/test/extensionOAuth.test.ts` pass. So do 198 tests across the Core extension suites, the database export test and the API OAuth route test, which I ran with `PROPR_DEMO_MODE=true` because without it two suites fail on the GitHub-auth check. Core typecheck and zero-warning lint pass. I didn't run the full repository suite, and nothing has been tried against a real OAuth provider.

I've fixed F5, F6 and F7 in Core's OAuth store (`packages/core/src/extensions/extensionOAuthStore.ts`) and added a regression test for each. The 3 new tests fail against the previous code and pass now. All 15 tests in `packages/core/test/extensionOAuth.test.ts` pass. So do 198 tests across the Core extension suites, the database export test and the API OAuth route test, which I ran with `PROPR_DEMO_MODE=true` because without it two suites fail on the GitHub-auth check. Core typecheck and zero-warning lint pass. I didn't run the full repository suite, and nothing has been tried against a real OAuth provider.

**F5 / F6 (tokens without a refresh token):** when a connection has no refresh token, `accessToken` now keeps using the access token until it actually expires. It no longer tries to refresh during the last minute. After expiry, or when the upstream server refuses the token, the connection moves to Needs sign-in as before. Connections that have a refresh token still refresh a minute early. The new test uses a 30-second token with no refresh token: gateway calls work, nothing is refreshed and no one is notified. Then, both after real expiry and after an upstream rejection, it checks the move to Needs sign-in with one notification.

**F7 (disconnect during token rotation):**
- **Fence before revoking.** Disconnect now takes the connection's refresh lease and marks it `disconnecting` before contacting the provider. If a refresh holds the lease, Disconnect waits for it, then revokes the tokens that are current after it finishes. The wait is bounded; if it runs out, Disconnect returns a 409 asking to try again.
- **No new refresh.** While a connection is `disconnecting`, the gateway can't get a token and no refresh can start.
- **No replacement by a callback.** A sign-in callback refuses with a 409 instead of overwriting a `disconnecting` connection. It checks before exchanging the code, and again inside the save transaction. Pending sign-ins are cancelled both when Disconnect starts and when it finishes.
- **Fenced deletion.** The final delete only removes the connection Disconnect fenced, and the audit entry is written only if that delete happened.
- **What Settings shows.** A `disconnecting` connection appears as Needs sign-in, so if a Disconnect stops halfway, Disconnect is still available to finish it.

Two tests cover this:
- **Refresh already in flight:** Disconnect waits and revokes the rotated tokens.
- **Revocation held open:** no refresh reaches the provider, and a callback is refused without exchanging its code. In both cases only the fenced tokens are revoked and nothing is left behind.

**Existing test I changed:** "a refresh of a replaced connection…" used Disconnect to replace a connection while a refresh was still outstanding. With F7, Disconnect now waits for that refresh, so the test would hang. It now replaces the connection through a library change, which still exercises the successor fencing it was written for.

**Problems I found but didn't fix (outside the selected findings):**
- When a sign-in callback is cancelled after its code exchange (by Disconnect or a server change), the tokens the provider just issued are never revoked. This was already true before this change.
- When a library save discards a connection (new URL, authentication type, client id, rename or removal), it deletes the tokens without revoking them.

This change has no visible effect in the UI, so I didn't create previews.

PR: #3536
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR implements OAuth across storage, discovery, gateway calls, API routes, Settings, and documentation. It needs localized corrections before merge.

✅ Credential custody — Tokens and pending verifiers are sealed with identity bindings, and native exports remove both custody tables.

✅ Refresh fencing — Generation, version, and lease-owner checks prevent an obsolete refresh from overwriting a replacement connection.

✅ Callback validation — Completion checks session, administrator, expiry, single-use state, server binding, and issuer before storing a connection.

This review is a static trace of the supplied code; no commands or tests were run. Current checks report 31 passed, none failed, and three pending.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F8: 🔴 Clear draft secrets when changing clients

  • Required behavior: Changing an OAuth client ID must not silently carry its credential to the replacement client.

  • Evidence: propr-ui/src/pages/SettingsPage/extensions/ExtensionServerForm.tsx, change and submit; propr-ui/src/pages/SettingsPage/extensions/ExtensionOAuthFields.tsx, client-ID input handler.

    1. An administrator enters client ID A and its client secret in the server form.
    2. They replace A with another nonempty client ID B.
    3. change clears the draft secret for URL or authentication changes, but not client-ID changes. The client-ID handler only clears it when the ID becomes empty.
    4. Saving submits A’s secret as an explicit replacement for B. The backend consequently stores it for B, and subsequent sign-in uses the wrong credential.

    credentialDropped changes the presence indicator but does not clear the draft value. Backend credential-binding checks cannot prevent this because the UI supplies the retained value as an explicit replacement. static trace: the input handlers, submit path, and saveLibrary replacement precedence demonstrate the carryover.

  • Minimum fix: Clear the draft secret whenever the client ID changes, including transitions between two nonempty IDs. Add a component regression covering entry of A’s secret followed by changing to B and saving.

F9: 🔴 Keep reconnect refresh listeners active

  • Required behavior: Completing Reconnect must refresh the Settings row with the resulting connection identity, time, and scopes.

  • Evidence: propr-ui/src/pages/SettingsPage/extensions/useExtensionLibrary.ts, refreshConnections and the signingIn effect.

    1. An already-connected server starts Reconnect, adding its name to signingIn while its existing connection remains connected.
    2. Before completing provider consent, the administrator returns to Settings.
    3. The focus handler calls refreshConnections, which removes every name whose current state is connected; this removes the unfinished reconnect.
    4. With no remaining names, the effect removes the focus, visibility, and BroadcastChannel listeners.
    5. The administrator completes consent with another account or different scopes and returns. No listener refreshes the row, so it continues displaying the previous connection details until another reload.

    The existing connection’s state cannot distinguish an unfinished reconnect from its successful completion. The detached tab also has no opener, and this hook installs no fallback message listener. static trace: the filtering predicate and effect cleanup establish this sequence; the supplied UI test exercises initial Connect only.

  • Minimum fix: Keep reconnect tracking active until completion is distinguishable from the original connection, or retain connection-refresh listeners while Settings is mounted. Cover returning to Settings before finishing Reconnect in a component test.

Suggestions

These are optional follow-ups and are not sent to /fix.

S4: 🟢 Exercise the composed browser flow

The Playwright fixture mocks start, provider consent, and callback processing, while the API test injects session identity directly. A browser test against the actual API and session middleware would strengthen confidence in cookies, callback routing, and refresh notifications. This is additional integration coverage rather than a separately demonstrated blocker.

Score

The implementation has substantial custody and concurrency protections, but two reproducible Settings defects remain. Both appear fixable without changing the backend architecture.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 57s
  • Tokens: 114,079 (111,618 in / 2,461 out)
  • Cost: $1.13

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F8 F9 S4

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 3d80f8f

Addressed 1 AI review comment (IDs: 6855361588)

Addressed findings F8, F9

Summary of Changes

I fixed F8 and F9 and added a regression test for each. Both new tests fail on the previous code and pass now. All 288 Settings UI tests pass, and typecheck and zero-warning lint on the UI package are clean. I only ran UI tests, not Core, API or Playwright, and nothing has been tried against a real OAuth provider.

F8: the secret no longer carries over to a new client id

  • In ExtensionServerForm.tsx, change now clears the typed token or client secret whenever the client id changes, including from one non-empty id to another. It already did this for URL and authentication changes.
  • The client-id input in ExtensionOAuthFields.tsx no longer clears the secret itself, so all the clearing happens in one place.
  • Test: enter client client-a and its secret, change the id to client-b, save. The secret field is empty and A's secret is not sent.
  • I checked the other places that can change the client id. Switching authentication or picking a catalog entry already cleared the secret. Renaming keeps the secret you typed, since you typed it for this server; the "won't carry over" notice is about the secret already stored under the old name.

F9: Reconnect keeps refreshing until the new connection arrives

  • When a sign-in starts, useExtensionLibrary.ts now records the server's connection time at that moment (connectedAt, or none if it has no connection). The server only counts as signed in once Settings shows a connection with a different time.
  • Core sets that time only when a sign-in completes, not when tokens are refreshed. So coming back to Settings before finishing consent no longer drops the server from tracking, and the focus, visibility and BroadcastChannel listeners stay on.
  • Test: start Reconnect on a connected server and come back to Settings before finishing. The row still shows the old connection and tracking continues. Then come back again after the provider reports another account and other scopes: the row shows them, and the listeners are removed.
  • If an administrator abandons a Reconnect, the listeners stay on until they leave Settings. Each one only re-reads the library when the tab regains focus.

Found separately, not changed: none.

There are no previews: the only visible change is that the client-secret field empties when the client id changes.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 4m 53s
  • Tokens: 576,519 (569,543 in / 6,976 out)
  • Cost: $0.48

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…h new tests fail on the previous code and pass now. All 288 Settings UI tests pass, and typecheck and zero-warning lint on the UI package are clean. I only ran UI tests, not Core, API or Playwright, and nothing has been tried against a real OAuth provider.

I fixed F8 and F9 and added a regression test for each. Both new tests fail on the previous code and pass now. All 288 Settings UI tests pass, and typecheck and zero-warning lint on the UI package are clean. I only ran UI tests, not Core, API or Playwright, and nothing has been tried against a real OAuth provider.

**F8: the secret no longer carries over to a new client id**
- In `ExtensionServerForm.tsx`, `change` now clears the typed token or client secret whenever the client id changes, including from one non-empty id to another. It already did this for URL and authentication changes.
- The client-id input in `ExtensionOAuthFields.tsx` no longer clears the secret itself, so all the clearing happens in one place.
- **Test:** enter client `client-a` and its secret, change the id to `client-b`, save. The secret field is empty and A's secret is not sent.
- I checked the other places that can change the client id. Switching authentication or picking a catalog entry already cleared the secret. Renaming keeps the secret you typed, since you typed it for this server; the "won't carry over" notice is about the secret already stored under the old name.

**F9: Reconnect keeps refreshing until the new connection arrives**
- When a sign-in starts, `useExtensionLibrary.ts` now records the server's connection time at that moment (`connectedAt`, or none if it has no connection). The server only counts as signed in once Settings shows a connection with a different time.
- Core sets that time only when a sign-in completes, not when tokens are refreshed. So coming back to Settings before finishing consent no longer drops the server from tracking, and the focus, visibility and BroadcastChannel listeners stay on.
- **Test:** start Reconnect on a connected server and come back to Settings before finishing. The row still shows the old connection and tracking continues. Then come back again after the provider reports another account and other scopes: the row shows them, and the listeners are removed.
- If an administrator abandons a Reconnect, the listeners stay on until they leave Settings. Each one only re-reads the library when the tab regains focus.

**Found separately, not changed:** none.

There are no previews: the only visible change is that the client-secret field empties when the client id changes.

PR: #3536
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

This PR implements OAuth discovery, browser sign-in, encrypted token custody, refresh, gateway integration and Settings controls. It needs a localized recovery fix before merge.

✅ Credential isolation — OAuth tokens remain outside library revisions, and native exports explicitly erase connections and pending sign-ins.

✅ Callback fencing — Session binding, single-use state and transactional checks prevent a cancelled code exchange from restoring a connection.

✅ Refresh coordination — Generation and owner checks prevent an outstanding refresh from overwriting a replacement connection.

This review used static tracing of the supplied code; no commands were run. Current checks report zero failures, with five still pending.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F10: 🔴 Reconnect cannot recover invalid dynamic clients

  • Required behavior: A connection whose refresh is refused must be recoverable through Reconnect, including when the authorization server rejects its dynamically registered client.

  • Evidence: packages/core/src/extensions/extensionOAuthStore.ts, dynamicClient, needsSignIn and startSignIn; packages/core/src/extensions/extensionOAuth.ts, requestTokens.

    1. A server is connected using dynamic registration, and its authorization server subsequently invalidates that client registration.
    2. Refresh returns HTTP 401 with invalid_client. requestTokens classifies this as an authorization failure, and needsSignIn retains the connection and its client credentials while changing its state.
    3. The administrator clicks Reconnect. dynamicClient finds the retained row with the same issuer, endpoint and redirect URI, successfully decrypts it, and returns the rejected client ID and secret.
    4. No registration request occurs. The new authorization attempt therefore uses the invalid client again and fails; subsequent Reconnect attempts repeat the same sequence.

    The reuse condition does not examine connection state or the reason for the refresh refusal. Its catch only handles local decoding failures, so provider rejection never activates registration fallback. Administrators cannot recover through the advertised Reconnect action without separately discarding the connection.

    static trace: Followed the dynamic-registration reuse branch through refresh refusal and subsequent sign-in. proposed regression: Invalidate a synthetic provider’s registered client, refuse refresh with invalid_client, then assert Reconnect obtains a new registration and completes successfully.

  • Minimum fix: Re-register when a dynamic client has been rejected. Either preserve the refusal category and invalidate that registration, or conservatively create a fresh registration when reconnecting a dynamic connection in Needs-sign-in state.

Suggestions

These are optional follow-ups and are not sent to /fix.

S5: 🟢 Exercise the actual browser callback

The Playwright test intercepts both the start API and callback, while the API test injects session identity through test headers. A browser test using the actual session middleware and callback would strengthen confidence in cookie delivery and session continuity across provider redirects. This is additional integration coverage, not a demonstrated defect.

Score

The implementation has substantial security and concurrency coverage, but the dynamic-client recovery failure prevents merge readiness. The supplied current checks show no failures; five remain pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 33s
  • Tokens: 114,082 (112,389 in / 1,693 out)
  • Cost: $1.10

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F10 S5

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 8224945

Addressed 1 AI review comment (IDs: 6855916372)

Addressed finding F10

Summary of Changes

I fixed F10: Reconnect now gets a new client registration when the connection is in Needs sign-in, so a server whose provider deleted its dynamic client can be recovered without disconnecting it first. The new regression test fails on the previous code and passes now.

The fix (packages/core/src/extensions/extensionOAuthStore.ts, dynamicClient): the stored dynamic client is reused only while its connection is Connected. A refused refresh doesn't record whether the provider rejected the refresh token or the client itself, so I took the cautious option from the finding. Any dynamic connection in Needs sign-in registers again on Reconnect, and the callback then saves the new client id over the old row. When the client was still valid (for example, the refresh token had simply expired), this leaves one unused registration with the provider. Reconnecting a server that is still Connected keeps reusing its registration.

Other paths checked:

  • Both ways a refused refresh reaches Needs sign-in go through the same code: a refresh before expiry, and a refresh after the server returns 401. The fix covers both.
  • A connection whose stored tokens can't be decrypted already registered again.
  • The pre-registered and metadata-document methods aren't affected: the first uses the client id the administrator entered, and the second uses ProPR's own URL as the client id.

Regression test (in packages/core/test/extensionOAuth.test.ts): it runs once for each of those two refresh paths. The synthetic provider deletes the registered client and refuses the refresh with 401 invalid_client, and the test checks the server moves to Needs sign-in. Reconnect must then create a second registration with a different client id, complete sign-in, serve a run and refresh with the new client. A further Reconnect while Connected must create no extra registration. Against the old code it fails because the provider refuses the reused client ("Unregistered redirect URI").

To support the test, I added invalidateClient to the synthetic provider in test/fixtures/extensionOAuthFixture.ts. It now returns 401 invalid_client for an unknown client at the token endpoint, as a strict provider does; it used to return 400 invalid_grant. I also updated the dynamic-registration row in docs/docs/features/agent-extensions.md to describe the new behaviour.

Verification:

  • All 16 tests in packages/core/test/extensionOAuth.test.ts pass.
  • The API OAuth route test, which shares the fixture, passes.
  • Core typecheck and zero-warning lint pass. The test and fixture files are outside the lint configuration, so lint skips them.
  • I didn't run the full repository suite, and nothing was tried against a real OAuth provider.

Separate finding, not changed: if a provider deletes a dynamic client while the connection still shows Connected, the first Reconnect reuses the dead client. The provider rejects it on its own page and never redirects back, so ProPR has nothing to detect. The connection recovers once the access token expires or the server returns 401, which moves it to Needs sign-in and makes the next Reconnect work. Re-registering on every Reconnect would close this gap but would leave more unused registrations with the provider.

There's no visible UI change, so I didn't capture previews.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 4m 56s
  • Tokens: 1,275,757 (1,266,251 in / 9,506 out)
  • Cost: $0.78

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…hen the connection is in **Needs sign-in**, so a server whose provider deleted its dynamic client can be recovered without disconnecting it first. The new regression test fails on the previous code and passes now.

I fixed F10: Reconnect now gets a new client registration when the connection is in **Needs sign-in**, so a server whose provider deleted its dynamic client can be recovered without disconnecting it first. The new regression test fails on the previous code and passes now.

**The fix** (`packages/core/src/extensions/extensionOAuthStore.ts`, `dynamicClient`): the stored dynamic client is reused only while its connection is **Connected**. A refused refresh doesn't record whether the provider rejected the refresh token or the client itself, so I took the cautious option from the finding. Any dynamic connection in Needs sign-in registers again on Reconnect, and the callback then saves the new client id over the old row. When the client was still valid (for example, the refresh token had simply expired), this leaves one unused registration with the provider. Reconnecting a server that is still Connected keeps reusing its registration.

**Other paths checked:**
- Both ways a refused refresh reaches Needs sign-in go through the same code: a refresh before expiry, and a refresh after the server returns 401. The fix covers both.
- A connection whose stored tokens can't be decrypted already registered again.
- The pre-registered and metadata-document methods aren't affected: the first uses the client id the administrator entered, and the second uses ProPR's own URL as the client id.

**Regression test** (in `packages/core/test/extensionOAuth.test.ts`): it runs once for each of those two refresh paths. The synthetic provider deletes the registered client and refuses the refresh with `401 invalid_client`, and the test checks the server moves to Needs sign-in. Reconnect must then create a second registration with a different client id, complete sign-in, serve a run and refresh with the new client. A further Reconnect while Connected must create no extra registration. Against the old code it fails because the provider refuses the reused client ("Unregistered redirect URI").

To support the test, I added `invalidateClient` to the synthetic provider in `test/fixtures/extensionOAuthFixture.ts`. It now returns `401 invalid_client` for an unknown client at the token endpoint, as a strict provider does; it used to return `400 invalid_grant`. I also updated the dynamic-registration row in `docs/docs/features/agent-extensions.md` to describe the new behaviour.

**Verification:**
- All 16 tests in `packages/core/test/extensionOAuth.test.ts` pass.
- The API OAuth route test, which shares the fixture, passes.
- Core typecheck and zero-warning lint pass. The test and fixture files are outside the lint configuration, so lint skips them.
- I didn't run the full repository suite, and nothing was tried against a real OAuth provider.

**Separate finding, not changed:** if a provider deletes a dynamic client while the connection still shows **Connected**, the first Reconnect reuses the dead client. The provider rejects it on its own page and never redirects back, so ProPR has nothing to detect. The connection recovers once the access token expires or the server returns 401, which moves it to Needs sign-in and makes the next Reconnect work. Re-registering on every Reconnect would close this gap but would leave more unused registrations with the provider.

There's no visible UI change, so I didn't capture previews.

PR: #3536
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR implements OAuth across credential storage, discovery, refresh, gateway calls, Settings, and documentation. It needs a localized protocol correction before merge.

✅ Credential custody — Tokens and PKCE verifiers are sealed, public projections exclude credentials, and native exports erase connections and pending sign-ins.

✅ Refresh fencing — Connection generations, versions, and lease owners prevent an old refresh from overwriting a replacement connection.

✅ Failure coverage — The added tests exercise callback binding, refresh rotation, disconnect interleavings, and credential redaction.

This review used static analysis only, as requested. The supplied current checks show no failures and two pending checks.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F11: 🔴 Preserve the discovered resource identifier

  • Required behavior: OAuth authorization and token requests must consistently identify the protected resource discovered from its metadata.

  • Evidence: packages/core/src/extensions/extensionOAuth.ts, discoverOAuth; packages/core/src/extensions/extensionOAuthStore.ts, startSignIn, completeClaimed, and refreshOnce.

    1. Configure an MCP endpoint such as https://tools.example.com/mcp whose protected-resource metadata declares resource: "https://tools.example.com".
    2. discoverOAuth explicitly accepts this same-origin path-prefix resource, but returns resource: serverUrl, discarding the declared identifier.
    3. startSignIn independently sets both the authorization request and pending details to server.url. The code exchange consequently requests the endpoint URL as its resource.
    4. An authorization server enforcing the resource identifier declared in that metadata rejects the request with an invalid target, so this accepted discovery configuration cannot connect. Refresh likewise uses row.endpoint, perpetuating the mismatch.

    The endpoint validation checks ownership of the metadata but does not preserve its resource identity. The synthetic fixture always makes the metadata resource equal to the endpoint, so its tests cannot expose this case. static trace: the accepted prefix branch and all subsequent resource assignments in the supplied diff. proposed regression: publish a parent resource identifier and require that exact identifier during authorization, exchange, and refresh.

  • Minimum fix: Return the validated metadata resource, use it in authorization and code exchange, and persist it separately from the MCP endpoint for refresh requests. Retain endpoint binding for credential custody and upstream routing.

Suggestions

These are optional follow-ups and are not sent to /fix.

S6: 🟢 Exercise the real browser callback

The Playwright test intercepts both OAuth start and callback, while the API test injects session identity through headers. A browser integration test against the actual session middleware and callback would strengthen confidence in cookie handling and deployment-origin behavior. This is optional additional coverage; the supplied code does not establish a separate session defect.

Score

The implementation has substantial credential safeguards and targeted tests, but the resource-identifier mismatch blocks valid discovered configurations. The supplied checks have no current failures, with two still pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 37s
  • Tokens: 115,436 (113,541 in / 1,895 out)
  • Cost: $1.12

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F11 S6

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit a66a6c8

Addressed 1 AI review comment (IDs: 6856649644)

Addressed finding F11

Summary of Changes

F11 is fixed. When a server's metadata names a parent resource (for example https://tools.example.com for https://tools.example.com/mcp), ProPR now sends that same identifier in the sign-in request, the code exchange and every refresh. Previously all three sent the endpoint URL. The endpoint stays the binding for credential custody, gateway routing and deciding when a connection is stale.

What changed

  • Discovery (extensionOAuth.ts): discoverOAuth returns the resource the metadata declares instead of serverUrl. The same-origin check is unchanged, so a resource on another origin or a non-parent path is still refused.
  • Sign-in (extensionOAuthStore.ts): startSignIn uses that resource for both the authorization URL and the pending details. The code exchange already read the pending details, so it now sends it too.
  • Refresh: the connection row has a new resource column, written when sign-in completes. refreshOnce uses row.resource, not row.endpoint.
  • Migration: I added the column to this PR's own unreleased OAuth migration rather than a new one, so it only exists on fresh databases. A dev database that already ran this branch's migration won't get it; drop the three extension_oauth_* tables there to recreate them.
  • Check: the Check result now reports the declared resource.
  • Docs: agent-extensions.md now says which resource is sent and that a refresh sends the same one as the sign-in.

Same defect elsewhere: none. These are the only places that build a resource value. Revocation and the gateway's upstream calls don't send one.

Regression test

  • The test fixture can now declare a parent resource. It then accepts only that exact value in the sign-in request, the code exchange and refresh, and answers a mismatch with invalid_target. By default it still declares the endpoint, so existing tests behave the same.
  • The new test in packages/core/test/extensionOAuth.test.ts covers both discovery paths, the 401 challenge and the well-known location. For each, it checks the resource the Check reports, the authorization URL, the resource sent in the code exchange and in refresh, and the stored row (resource is the parent, endpoint is unchanged). It also checks that the refreshed call still reaches the endpoint, and that resources on another path or origin are still refused.
  • It fails against the previous source files. With only the refresh line reverted it also fails, so the refresh part is checked on its own.

Verification

  • All 17 tests in the OAuth file pass.
  • So do the other Core extension suites (96 tests), the database export test (103) and the API OAuth route test, all run with PROPR_DEMO_MODE=true.
  • Core typecheck passes, and zero-warning lint passes on the changed source files.
  • I didn't run the full repository suite or Playwright, and nothing has been tried against a real OAuth provider.

Nothing visible changed in the UI, so there are no previews. I found no separate problems to report.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 8m 37s
  • Tokens: 2,395,363 (2,382,848 in / 12,515 out)
  • Cost: $1.12

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…rce (for example `https://tools.example.com` for `https://tools.example.com/mcp`), ProPR now sends that same identifier in the sign-in request, the code exchange and every refresh. Previously all three sent the endpoint URL. The endpoint stays the binding for credential custody, gateway routing and deciding when a connection is stale.

F11 is fixed. When a server's metadata names a parent resource (for example `https://tools.example.com` for `https://tools.example.com/mcp`), ProPR now sends that same identifier in the sign-in request, the code exchange and every refresh. Previously all three sent the endpoint URL. The endpoint stays the binding for credential custody, gateway routing and deciding when a connection is stale.

**What changed**
- **Discovery** (`extensionOAuth.ts`): `discoverOAuth` returns the resource the metadata declares instead of `serverUrl`. The same-origin check is unchanged, so a resource on another origin or a non-parent path is still refused.
- **Sign-in** (`extensionOAuthStore.ts`): `startSignIn` uses that resource for both the authorization URL and the pending details. The code exchange already read the pending details, so it now sends it too.
- **Refresh**: the connection row has a new `resource` column, written when sign-in completes. `refreshOnce` uses `row.resource`, not `row.endpoint`.
- **Migration**: I added the column to this PR's own unreleased OAuth migration rather than a new one, so it only exists on fresh databases. A dev database that already ran this branch's migration won't get it; drop the three `extension_oauth_*` tables there to recreate them.
- **Check**: the Check result now reports the declared resource.
- **Docs**: `agent-extensions.md` now says which resource is sent and that a refresh sends the same one as the sign-in.

**Same defect elsewhere:** none. These are the only places that build a `resource` value. Revocation and the gateway's upstream calls don't send one.

**Regression test**
- The test fixture can now declare a parent resource. It then accepts only that exact value in the sign-in request, the code exchange and refresh, and answers a mismatch with `invalid_target`. By default it still declares the endpoint, so existing tests behave the same.
- The new test in `packages/core/test/extensionOAuth.test.ts` covers both discovery paths, the 401 challenge and the well-known location. For each, it checks the resource the Check reports, the authorization URL, the `resource` sent in the code exchange and in refresh, and the stored row (`resource` is the parent, `endpoint` is unchanged). It also checks that the refreshed call still reaches the endpoint, and that resources on another path or origin are still refused.
- It fails against the previous source files. With only the refresh line reverted it also fails, so the refresh part is checked on its own.

**Verification**
- All 17 tests in the OAuth file pass.
- So do the other Core extension suites (96 tests), the database export test (103) and the API OAuth route test, all run with `PROPR_DEMO_MODE=true`.
- Core typecheck passes, and zero-warning lint passes on the changed source files.
- I didn't run the full repository suite or Playwright, and nothing has been tried against a real OAuth provider.

Nothing visible changed in the UI, so there are no previews. I found no separate problems to report.

PR: #3536
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR implements OAuth discovery, sign-in, encrypted token custody, refresh, gateway integration, and Settings controls comprehensively. It needs changes before merge because an in-progress sign-in can escape Disconnect’s cancellation.

✅ Credential isolation — OAuth tokens are sealed separately from library revisions, removed from native exports, and included in gateway output redaction.

✅ Refresh fencing — Generation, version, and lease-owner checks prevent an old refresh from overwriting a replacement connection.

✅ Callback validation — Completion checks session, administrator, expiry, issuer, PKCE exchange, and current server binding.

This review used static analysis only; no commands were run. The supplied current-head status reports 32 passed checks, two pending, and no failures.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F12: 🔴 Register sign-in attempts before discovery

  • Required behavior: Disconnect must cancel pending sign-ins so an attempt already underway cannot restore the connection after Disconnect succeeds.

  • Evidence: packages/core/src/extensions/extensionOAuthStore.ts, startSignIn, fenceDisconnect, and completeClaimed.

    1. A connected server starts Reconnect. startSignIn reads its configuration and awaits discoverOAuth; it has not yet inserted an OAUTH_PENDING row.
    2. While discovery is outstanding, an administrator disconnects the same server. fenceDisconnect deletes existing pending rows, fences the connection, and revocation completes. The final transaction deletes the connection and pending rows, then Disconnect returns successfully.
    3. Discovery resumes. startSignIn authorizes the administrator again, obtains its client registration, and inserts a new pending row for the attempt that began before Disconnect.
    4. Consent completes. The server configuration still matches, the pending row exists, and there is no disconnecting connection. completeClaimed therefore stores a new connected row.

    The observable result is that a previously started sign-in reconnects a server after successful Disconnect. The awaited discovery request provides the interleaving window; no transaction or cancellation generation spans that request. Callback checks protect attempts already recorded when Disconnect runs, but cannot detect this late insertion. The same gap exists during awaited dynamic registration.

    static trace: verified from the ordering of pending-row insertion, both Disconnect deletion passes, and callback acceptance checks. Existing cancellation tests hold the code exchange, which occurs after pending-row insertion, so they do not cover this sequence.

  • Minimum fix: Record a cancellable attempt before discovery or registration begins, and condition finalizing that attempt on its continued existence. Disconnect must invalidate that record, and a cancelled start must fail instead of inserting a replacement pending row. Apply the same protection to library binding changes.

Suggestions

These are optional follow-ups and are not sent to /fix.

S7: 🟢 Exercise real browser session handling

The Playwright test mocks the start endpoint and callback, while the API test injects session identity through headers. A browser integration test using the actual session middleware and callback would strengthen confidence in cookie delivery and session binding across the provider redirect. This is additional coverage, not a separately demonstrated blocker.

Score

The implementation has substantial safeguards and focused coverage, but the sign-in cancellation gap requires correction. Pending checks alone do not reduce the score.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 26s
  • Tokens: 116,186 (114,446 in / 1,740 out)
  • Cost: $1.12

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F12 S7

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 7f4fb7a

Addressed 1 AI review comment (IDs: 6857437301)

Addressed finding F12

Summary of Changes

F12 is fixed: a Disconnect or a library change that happens while a sign-in is still discovering or registering now cancels that sign-in, so it can no longer reconnect the server afterwards. The new regression test fails on the previous code and passes now.

What was wrong. I confirmed the bug on the previous code by running each case through to the callback:

Change made while discovery or registration was waiting Previous code Now
Disconnect during discovery (the Reconnect case in the finding) server reconnected sign-in cancelled
Disconnect during dynamic registration server reconnected sign-in cancelled
URL changed and then changed back server reconnected sign-in cancelled
New URL, server removed, or new client id refused only later, at the callback sign-in cancelled at the start

The fix is in startSignIn in packages/core/src/extensions/extensionOAuthStore.ts:

  • Record first: the sign-in now writes its pending row before it sends any discovery request. It does this in the same transaction that reads the server's settings.
  • Not usable yet: while discovery and registration run, the row is marked as owned by the start, so no callback can use it. It already holds the endpoint and client id that a library save compares against.
  • Finish only if it still exists: at the end, the start fills in the sign-in details and releases the row for the callback, but only if the row is still there. If it's gone, the start fails with "The sign-in was cancelled; connect again", so it never writes a replacement row.
  • Clean up on failure: a start that fails for any reason deletes its row.

Disconnect and library saves didn't need changing. Both already delete pending rows, and those now include sign-ins still in progress. That covers the library binding changes too. I also updated the comment on the claim column in the migration.

Tests

  • New test: covers each row of the table above. A control case checks that a save which doesn't change the server's binding leaves the sign-in intact and lets it complete.
  • Runs: all 18 tests in extensionOAuth.test.ts pass. So do 201 tests across the Core extension suites, the database export test and the API OAuth route test, run with PROPR_DEMO_MODE=true.
  • Checks: Core typecheck and zero-warning lint on Core src are clean.
  • Not run: the full repository suite, UI, Playwright, and anything against a real OAuth provider.

There is no visual change, so I made no preview.

Two things I noticed but didn't change, since neither is a defect I can fix here:

  • Leftover registration at the provider: if a sign-in is cancelled after dynamic registration has finished, the client stays registered at the provider. Removing it would need a deregistration call, which isn't part of this flow.
  • Ordering: a Connect whose first write lands after Disconnect has finished is treated as a new Connect. That ordering can't be avoided.

🤖 Implementation Details

  • Model: Claude Opus 5.5 (xhigh)
  • Requested By: @propr-ultrafix
  • Time: 9m 28s
  • Tokens: 2,903,389 (2,873,875 in / 29,514 out)
  • Cost: $1.69

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

… while a sign-in is still discovering or registering now cancels that sign-in, so it can no longer reconnect the server afterwards. The new regression test fails on the previous code and passes now.

F12 is fixed: a Disconnect or a library change that happens while a sign-in is still discovering or registering now cancels that sign-in, so it can no longer reconnect the server afterwards. The new regression test fails on the previous code and passes now.

**What was wrong.** I confirmed the bug on the previous code by running each case through to the callback:

| Change made while discovery or registration was waiting | Previous code | Now |
|---|---|---|
| Disconnect during discovery (the Reconnect case in the finding) | server reconnected | sign-in cancelled |
| Disconnect during dynamic registration | server reconnected | sign-in cancelled |
| URL changed and then changed back | server reconnected | sign-in cancelled |
| New URL, server removed, or new client id | refused only later, at the callback | sign-in cancelled at the start |

**The fix** is in `startSignIn` in `packages/core/src/extensions/extensionOAuthStore.ts`:
- **Record first:** the sign-in now writes its pending row before it sends any discovery request. It does this in the same transaction that reads the server's settings.
- **Not usable yet:** while discovery and registration run, the row is marked as owned by the start, so no callback can use it. It already holds the endpoint and client id that a library save compares against.
- **Finish only if it still exists:** at the end, the start fills in the sign-in details and releases the row for the callback, but only if the row is still there. If it's gone, the start fails with "The sign-in was cancelled; connect again", so it never writes a replacement row.
- **Clean up on failure:** a start that fails for any reason deletes its row.

Disconnect and library saves didn't need changing. Both already delete pending rows, and those now include sign-ins still in progress. That covers the library binding changes too. I also updated the comment on the `claim` column in the migration.

**Tests**
- **New test:** covers each row of the table above. A control case checks that a save which doesn't change the server's binding leaves the sign-in intact and lets it complete.
- **Runs:** all 18 tests in `extensionOAuth.test.ts` pass. So do 201 tests across the Core extension suites, the database export test and the API OAuth route test, run with `PROPR_DEMO_MODE=true`.
- **Checks:** Core typecheck and zero-warning lint on Core `src` are clean.
- **Not run:** the full repository suite, UI, Playwright, and anything against a real OAuth provider.

There is no visual change, so I made no preview.

Two things I noticed but didn't change, since neither is a defect I can fix here:
- **Leftover registration at the provider:** if a sign-in is cancelled after dynamic registration has finished, the client stays registered at the provider. Removing it would need a deregistration call, which isn't part of this flow.
- **Ordering:** a Connect whose first write lands after Disconnect has finished is treated as a new Connect. That ordering can't be avoided.

PR: #3536
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR implements OAuth sign-in across credential storage, discovery, refresh, gateway calls, API routes and Settings. Based on static review of the supplied diff and surrounding context, it is merge-ready within scope, conditional on the remaining checks passing.

✅ Credential isolation — Tokens and dynamic client secrets are sealed outside library revisions; database exports explicitly remove connections and pending sign-ins.

✅ Concurrent-operation protection — Pending-attempt claims, connection generations and conditional refresh leases prevent cancelled callbacks and superseded refreshes from overwriting newer connections.

✅ Bounded gateway recovery — OAuth calls obtain current credentials, refresh after an upstream 401, retry once and redact both access tokens used.

No commands or tests were run during this review. The supplied current-head status reports 32 passed checks, two pending and no failures.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S8: 🟢 Exercise the complete browser-to-server flow

The Playwright test intercepts the extension API, provider and callback, while backend tests inject the transport and session identity. These provide useful coverage of individual layers, but do not exercise their production composition together. A follow-up integration test using the actual routes, session middleware and HTTPS transport would improve confidence in cookie handling, callback authentication and transport behavior. This is additional validation, not a demonstrated merge blocker.

Score

The implementation has substantial security and concurrency protections, with focused regression coverage. No actionable defect was established from the supplied code; production integration remains less directly tested than the individual layers.

Score: 8/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 44s
  • Tokens: 118,306 (116,518 in / 1,788 out)
  • Cost: $1.15

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S8

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 13, 2026
@integry
integry merged commit e85ea82 into 3509-epic-extensions-library-14j Nov 13, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant