Skip to content

[3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live - #3826

Merged
integry merged 16 commits into
3758-epic-runtime-abstraction-sc0from
3824/claude-opus-5-5-extension-library-url-mcp-20261126-2350-bz1
Nov 27, 2026
Merged

integry merged 16 commits into
3758-epic-runtime-abstraction-sc0from
3824/claude-opus-5-5-extension-library-url-mcp-20261126-2350-bz1

Conversation

@propr-dev

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

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3824

Branch: 3824/claude-opus-5-5-extension-library-url-mcp-20261126-2350-bz1
Commits: ✅ Changes committed (bef91c8)


AI Processing Completed

Execution Details:

Summary:
URL MCP servers now work with both stateless and stateful upstreams, and with no auth, Bearer or OAuth. The Fly smoke workflow now checks all four server types. I have not run the smoke: I don't have the Fly or Sprites credentials here. So the PR description doesn't yet have the run links, per-server modes or refresh counts the issue asks for. Someone needs to dispatch fly-e2e.yml with extensions checked, once with agent_runtime=sprites and once with fly-machines, and paste the step summaries.

What's verified

  • Live, from this container: using the new transport against the real public servers:
    • The mcptest echo server is stateful: a call in a session returned URL-STATEFUL-OK-… exactly, and the session was deleted at the end.
    • DeepWiki is stateless; Microsoft Learn and the mcptest Bearer server are stateful.
    • A wrong Bearer token is refused in about 110 ms, not a hang.
  • Unit tests (new): each item on the issue's acceptance list has a test in packages/core/test/extensionUpstreamSessions.test.ts, plus one in extensionOAuth.test.ts for a stateful OAuth server through a refresh and a 401. One test runs over a real TLS connection, covering event streams and a server that loses sessions on a new connection.
  • OAuth fixture: a test runs the new fixture against ProPR's own OAuth client and gateway: sign-in, a refresh during an open session, and the DELETE at the end.
  • Existing suites: the extension, task-history, OpenAPI, Settings and browser tests pass, and lint and typecheck are clean. I didn't run the full repository suite.

Gateway sessions (packages/core/src/extensions/mcpUpstreamSessions.ts, plus changes in mcpGateway.ts and endpointPolicy.ts)

  • The gateway runs initialize itself and keeps the session id inside ProPR, per run and server. It never reaches the agent and is hidden in tool output like a credential.
  • If a server refuses initialize, the gateway tries the stateless 2026 protocol. The mode comes from the server's answers, not from configuration.
  • Each session keeps one connection open to the address checked when it opened.
  • A lost session (404) is opened again once and the call repeated for read servers. A write server's call fails instead.
  • Requests from a server to the agent (sampling and similar) get an error reply and are never passed on.
  • When a run's access ends or expires, the API deletes its sessions within about 15 seconds. Sessions are capped (8 per run, 256 per API process) and expire after 10 idle minutes.
  • Existing limits are unchanged: tool allowlist, read/write checks, network policy, byte accounting and token redaction.

Behaviour changes

  • A run's first call to a URL server now makes two extra upstream requests (initialize and the initialized notification). Three existing tests that counted requests were updated.
  • To let the smoke sign in without a browser, the OAuth "start" endpoint now saves the session it is bound to. An API client using a bearer token and a cookie jar therefore gets a session cookie. That cookie doesn't sign anyone in: the callback still requires the same user.
  • Sessions live in the API process's memory, so restarting it ends them and the next call opens a new one.

Settings and docs

  • After "Test connections", each server shows whether it is stateful or stateless and which authentication it uses, for example "reachable (stateful session, Bearer token)".
  • "Discover tools" now works on stateful servers too.
  • The "intentionally unsupported" note in the docs is replaced with the new behaviour and its limits.
  • Previews are attached.

Smoke workflow (fly-e2e.yml, .github/fly-e2e/oauth-mcp-fixture.mjs)

  • The OAuth server is a small Node script, with no dependencies, on a disposable public Sprite. It issues 90-second access tokens. That fits the free plan's three-Machine limit, and the Sprite is deleted at teardown even on failure.
  • The extensions mode now needs FLY_E2E_SPRITES_TOKEN on Fly Machines runs too, for that Sprite.
  • The workflow first saves the Bearer server with a wrong token and checks it is refused quickly. It then saves the real token and signs in to the OAuth server through the Settings API.
  • The agent's file goes from 4 to 8 lines, including the exact stateful, Bearer and OAuth echo tokens.
  • The verify step checks the logged session and auth modes, that every server got at least one tool call, and that stateful sessions were deleted. It also checks the OAuth fixture reported at least one refresh.
  • The step summary shows urlServers=4 and a table of each server's session mode, auth, tool calls and refreshes.

Choices you may want to revisit

  • The OAuth fixture's tokens last 90 seconds rather than the 60 the issue suggests. ProPR refreshes a token one minute before it expires, so a 60-second token would be refreshed on every call.
  • The stateless check uses DeepWiki rather than Microsoft Learn: Learn returns a session id, so it counts as stateful.

Review digest

Risk-tiered paths

  • High risk (3 files)
    • .github/fly-e2e/oauth-mcp-fixture.mjs (added, +152/−0): auth-looking path
    • .github/workflows/fly-e2e.yml (+176/−13): CI or workflow file
    • packages/api/routes/extensionOAuthRoutes.ts (+13/−1): auth-looking path
  • Normal risk (8 files)
    • packages/api/openapi/routeDocsSystem.ts (+3/−3)
    • packages/api/routes/extensionProfileRoutes.ts (+10/−8)
    • packages/core/src/extensions/endpointPolicy.ts (+128/−15)
    • packages/core/src/extensions/mcpGateway.ts (+93/−11)
    • packages/core/src/extensions/mcpUpstreamSessions.ts (added, +256/−0)
    • propr-ui/src/api/extensionProfilesApi.ts (+9/−2)
    • propr-ui/src/pages/SettingsPage/AgentExtensionsSection.tsx (+10/−4)
    • propr-ui/src/pages/SettingsPage/extensions/ExtensionServerFields.tsx (+2/−1)
  • Low risk (11 files)
    • docs/docs/architecture/agent-runtime.md (+1/−1)
    • docs/docs/features/agent-extensions.md (+60/−6)
    • docs/docs/tutorials/setup-fly.md (+15/−5)
    • docs/static/openapi/propr-api.yaml (+3/−3)
    • packages/api/test/extensionDiscovery.test.ts (+9/−5)
    • packages/api/test/extensionProfileRoutes.test.ts (+4/−2)
    • packages/core/test/extensionOAuth.test.ts (+40/−0)
    • packages/core/test/extensionProfiles.test.ts (+6/−3)
    • packages/core/test/extensionUpstreamSessions.test.ts (added, +278/−0)
    • packages/core/test/flyOAuthMcpFixture.test.ts (added, +109/−0)
    • propr-ui/src/pages/SettingsPage/AgentExtensionsSection.test.tsx (+14/−1)

Diff size: 22 files changed, +1,391/−84 lines

View task for the run's logs and conversation.


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


💡 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

Discover tools on a stateful server

Discover tools on a stateful server

The server form after Discover tools on the mcptest.io stateful echo endpoint: tools are listed inside a session and the status says ProPR keeps the session for each run (mocked API response).

Full-size original

Test connections: session mode and authentication

Test connections: session mode and authentication

Settings → Skills & MCP servers after Test connections: each reached URL server shows whether it is stateful or stateless and which authentication it uses (mocked API responses).

Full-size original

Live verification (29dae8b)

Sprites, extensions mode: https://github.com/integry/propr/actions/runs/45985171163 ✅. The OAuth fixture ran on a Fly Machine, propr-e2e-oauth-<run> (Sprites runs keep the org's last Sprite for the agent). The agent's file had all 8 lines:

Line Content Server
2 FIGlet Copyright … runtime packages (#3816)
3 SKILL-OK-<run> skill bundle
4 Echo: MCP-OK-<run> package MCP server
5 URL-STATEFUL-OK-<run> https://mcptest.io/fixtures/echo/mcp: stateful, no auth
6 URL-STATELESS-OK-<run> DeepWiki: stateless, no auth
7 URL-BEARER-OK-<run> https://mcptest.io/fixtures/auth-bearer/mcp: stateful, Bearer
8 URL-OAUTH-OK-<run> OAuth fixture: stateful, OAuth
  • Every stateful session was closed at grant end with DELETE. The OAuth fixture reported 1 refresh, 2 sessions opened and 2 deleted, and 0 session-not-found replies.
  • urlServers=4. No token fragments in the log, and teardown was clean (no apps, Sprites or fixture branches left).

Final live verification (head 29bd6d4)

Known issue: intermittent hang from a Fly Machine to a Sprite-hosted MCP/OAuth server

In Fly Machines mode, 3 of the last 5 runs (46011054496, 46021934633, 46027327976) hit a request from ProPR's Machine to the fixture at *.sprites.app that hung for exactly 10 s after TCP connected (timeout after 10 s). The runner reached the same fixture fine. The Happy Eyeballs dialer (2337a9d) rules out connect-level failures. The diagnostics added in 29bd6d4 (the fixture's request log, a curl -4/-6 probe from ProPR's Machine, and connection-stage timing in the reason) run on every failure, so the next occurrence will show whether this is ProPR or the Fly → Sprites path. Real deployments that call a Sprite-hosted server from Fly Machines may hit it too.

URL MCP servers now work with both stateless and stateful upstreams, and with no auth, Bearer or OAuth. The Fly smoke workflow now checks all four server types. I have not run the smoke: I don't have the Fly or Sprites credentials here. So the PR description doesn't yet have the run links, per-server modes or refresh counts the issue asks for. Someone needs to dispatch `fly-e2e.yml` with `extensions` checked, once with `agent_runtime=sprites` and once with `fly-machines`, and paste the step summaries.

What's verified
- Live, from this container: using the new transport against the real public servers:
  - The mcptest echo server is stateful: a call in a session returned `URL-STATEFUL-OK-…` exactly, and the session was deleted at the end.
  - DeepWiki is stateless; Microsoft Learn and the mcptest Bearer server are stateful.
  - A wrong Bearer token is refused in about 110 ms, not a hang.
- Unit tests (new): each item on the issue's acceptance list has a test in `packages/core/test/extensionUpstreamSessions.test.ts`, plus one in `extensionOAuth.test.ts` for a stateful OAuth server through a refresh and a 401. One test runs over a real TLS connection, covering event streams and a server that loses sessions on a new connection.
- OAuth fixture: a test runs the new fixture against ProPR's own OAuth client and gateway: sign-in, a refresh during an open session, and the DELETE at the end.
- Existing suites: the extension, task-history, OpenAPI, Settings and browser tests pass, and lint and typecheck are clean. I didn't run the full repository suite.

Gateway sessions (`packages/core/src/extensions/mcpUpstreamSessions.ts`, plus changes in `mcpGateway.ts` and `endpointPolicy.ts`)
- The gateway runs `initialize` itself and keeps the session id inside ProPR, per run and server. It never reaches the agent and is hidden in tool output like a credential.
- If a server refuses `initialize`, the gateway tries the stateless 2026 protocol. The mode comes from the server's answers, not from configuration.
- Each session keeps one connection open to the address checked when it opened.
- A lost session (404) is opened again once and the call repeated for `read` servers. A `write` server's call fails instead.
- Requests from a server to the agent (sampling and similar) get an error reply and are never passed on.
- When a run's access ends or expires, the API deletes its sessions within about 15 seconds. Sessions are capped (8 per run, 256 per API process) and expire after 10 idle minutes.
- Existing limits are unchanged: tool allowlist, read/write checks, network policy, byte accounting and token redaction.

Behaviour changes
- A run's first call to a URL server now makes two extra upstream requests (`initialize` and the initialized notification). Three existing tests that counted requests were updated.
- To let the smoke sign in without a browser, the OAuth "start" endpoint now saves the session it is bound to. An API client using a bearer token and a cookie jar therefore gets a session cookie. That cookie doesn't sign anyone in: the callback still requires the same user.
- Sessions live in the API process's memory, so restarting it ends them and the next call opens a new one.

Settings and docs
- After "Test connections", each server shows whether it is stateful or stateless and which authentication it uses, for example "reachable (stateful session, Bearer token)".
- "Discover tools" now works on stateful servers too.
- The "intentionally unsupported" note in the docs is replaced with the new behaviour and its limits.
- Previews are attached.

Smoke workflow (`fly-e2e.yml`, `.github/fly-e2e/oauth-mcp-fixture.mjs`)
- The OAuth server is a small Node script, with no dependencies, on a disposable public Sprite. It issues 90-second access tokens. That fits the free plan's three-Machine limit, and the Sprite is deleted at teardown even on failure.
- The extensions mode now needs `FLY_E2E_SPRITES_TOKEN` on Fly Machines runs too, for that Sprite.
- The workflow first saves the Bearer server with a wrong token and checks it is refused quickly. It then saves the real token and signs in to the OAuth server through the Settings API.
- The agent's file goes from 4 to 8 lines, including the exact stateful, Bearer and OAuth echo tokens.
- The verify step checks the logged session and auth modes, that every server got at least one tool call, and that stateful sessions were deleted. It also checks the OAuth fixture reported at least one refresh.
- The step summary shows `urlServers=4` and a table of each server's session mode, auth, tool calls and refreshes.

Choices you may want to revisit
- The OAuth fixture's tokens last 90 seconds rather than the 60 the issue suggests. ProPR refreshes a token one minute before it expires, so a 60-second token would be refreshed on every call.
- The stateless check uses DeepWiki rather than Microsoft Learn: Learn returns a session id, so it counts as stateful.

ProPR-Agent: claude/claude-opus-5-5
@propr-dev propr-dev Bot changed the title 🔨 [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live ✅ [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live Nov 27, 2026

integry commented Nov 27, 2026

Copy link
Copy Markdown
Owner

/ultrafix goal=8 max=3

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

propr-dev Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

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

First action: /review

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

@propr-dev propr-dev Bot changed the title ✅ [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live 🔨 [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live Nov 27, 2026
@propr-dev

propr-dev Bot commented Nov 27, 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 27, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds gateway-owned MCP sessions, OAuth-compatible reuse, discovery support, and expanded smoke coverage. It needs changes before merge: transport completion, concurrent-call rejection, and failed-handshake cleanup have concrete lifecycle defects.

✅ Write replay protection — The 404 recovery path explicitly refuses to replay tools/call for write-capable servers.

✅ Session isolation — Sessions are keyed by grant and server; the gateway supplies session headers and redacts the current session ID from returned tool content.

✅ Focused coverage — Added tests cover session reuse, read recovery, write refusal, OAuth refresh, and real TLS transport. Current checks report 24 passed and no failures.

This review is a static analysis of the supplied code; no commands or tests were run.

Merge blockers

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

F1: 🔴 Capacity rejection closes active sessions

  • Category: correctness

  • Required behavior: Rejecting a call that exceeds concurrency limits must not invalidate other authorized, in-flight calls.

  • Evidence: packages/core/src/extensions/mcpGateway.ts, extensionGatewayCall grant-snapshot catch.

    1. A valid grant has an established upstream session and four admitted gateway calls in progress.
    2. A fifth call reaches grantSnapshot. Its conditional reservation fails because connections is already four, producing ExtensionError(401).
    3. The new catch treats every such 401 as grant termination and calls sessions.closeGrant.
    4. Cleanup deletes the session and destroys its pinned agent while admitted calls still use it, causing those calls to fail or encounter a lost session.

    The supplied grantSnapshot implementation uses the same 401 for concurrency exhaustion and actual expiration. The catch does not check whether the grant remains active and unexpired. For a write already executing upstream, the caller can lose its response despite the operation taking effect. static trace: the reservation predicate, unconditional 401 cleanup, and closeUpstreamSession agent destruction establish this sequence.

  • Minimum fix: Distinguish temporary admission rejection from grant termination, and close sessions only after establishing that the grant is revoked, missing, or expired.

F2: 🔴 Completed event streams retain the only socket

  • Category: correctness

  • Required behavior: Receiving a complete RPC response must leave subsequent session calls able to proceed without waiting for the previous request’s timeout.

  • Evidence: packages/core/src/extensions/endpointPolicy.ts, requestExtensionMcp response accept callback and extensionPinnedConnection.

    1. An upstream returns the matching JSON-RPC response over SSE but leaves the HTTP response stream open—the case explicitly anticipated by the new comment.
    2. accept resolves the transport promise but destroys the response only when there is no pinned connection.
    3. Gateway sessions always request a pinned connection, whose agent permits only one socket. The next call queues behind the still-open response.
    4. The previous request’s ten-second timer eventually destroys that connection. Subsequent calls incur the delay, and connection-bound sessions are lost; write calls can consequently fail on 404 without replay.

    Resolving the promise does not end the HTTP response or release the agent’s socket. The new TLS test uses res.end for every SSE response, so it cannot exercise this branch. static trace: completion leaves both the pinned response and its request timer active.

  • Minimum fix: Explicitly finalize transport ownership after the matching SSE response, clearing the timer and ensuring later requests have an available connection. Handle any necessary connection replacement consistently with session recovery, and add a regression with an SSE response that remains open.

F3: 🔴 Unauthorized handshakes abandon allocated resources

  • Category: correctness

  • Required behavior: Sessions and pinned connections allocated during a failed handshake must remain owned until cleanup or successful recovery.

  • Evidence: packages/core/src/extensions/mcpUpstreamSessions.ts, openUpstreamSession and ExtensionUpstreamSessions.open.

    1. initialize succeeds, assigning a session ID and pinned connection.
    2. The access token expires or is rejected when the gateway sends notifications/initialized.
    3. The local send helper rethrows ExtensionUpstreamUnauthorizedError, so openUpstreamSession exits before returning its constructed state.
    4. ExtensionUpstreamSessions.open clears entry.opening without storing that state. The gateway refreshes the OAuth token and starts another initialization.
    5. The first upstream session remains allocated, but grant cleanup can only delete the second session. The first pinned agent also escapes explicit cleanup.

    A 401 on the initial initialize or fallback discovery similarly escapes the connection-destruction statements. The entry cap cannot manage resources absent from an entry’s state. Existing OAuth tests inject rejection during an established tool call, not during the handshake. static trace: the unauthorized exception bypasses both state publication and cleanup; the gateway’s retry creates a new handshake.

  • Minimum fix: Preserve ownership of partially initialized state across credential refresh, allowing the initialized notification to retry in that session. Ensure every unsuccessful handshake path destroys its allocated agent and performs best-effort session cleanup where applicable.

Suggestions

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

S1: 🟢 Strengthen smoke lifecycle evidence

The workflow’s global OAuth counters can include refreshes before the agent opens its session and DELETEs from Settings validation. Recording counter baselines around the agent run, or checking session-specific fixture events, would make the smoke demonstrate refresh and deletion for that run more directly. This is an optional improvement to evidence quality; the added unit test already exercises refresh within an open session.

Score

The implementation has substantial focused coverage and passing current checks, but three session-lifecycle defects require correction before merge. The fixes can remain localized to admission handling and transport/session ownership.

Score: 5/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 14s
  • Tokens: 92,289 (90,547 in / 1,742 out)
  • Cost: $0.88

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 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit ca2bcda

Addressed 1 AI review comment (IDs: 7214044477)

Addressed findings F1, F2, F3

Summary of Changes

I fixed F1, F2 and F3. Each has a regression test that fails on the original code and passes now.

F1 – a call turned away for capacity no longer closes active sessions (mcpGateway.ts)

  • When grantSnapshot returns a 401, the gateway now checks the grant row. It closes the run's sessions only if the grant is inactive, missing or expired.
  • A call refused because the grant is at its concurrency or budget limit leaves the sessions alone. If the check itself fails, sessions are kept and the 15-second sweep handles them later.
  • The sweep's own liveness check now uses the same function, so the two can't drift apart.
  • Test: with connections = 4 and then with the call budget used up, the refused call leaves the session in place and the next call reuses it. Once the grant expires, the next refused call deletes it.

F2 – an event stream the server leaves open no longer holds the only connection (endpointPolicy.ts)

  • Once a response is settled on a pinned connection, the transport clears the 10-second request timer and reads out the rest of the response.
  • If the server hasn't closed the response within 1 second, the transport closes it. The next request then opens a new connection to the same vetted address.
  • A server that ties sessions to one connection will answer that next request with 404. The existing recovery handles it: read calls reopen the session and are replayed once, write calls fail without being replayed. That trade-off can't be avoided, because the client can't reuse a connection while a response is still open on it.
  • The same handling covers the drained responses on error, 202/204 and DELETE.
  • Test: a real TLS server sends each tool-call reply over an event stream and never closes it, on a write server. Three calls finish in about 2 seconds rather than 10 seconds each, the session is never reopened, and all three streams end up closed.
  • Decision for you: against such a server, each call after the first still waits up to that 1-second grace. A shorter grace makes those calls faster, but risks cutting off normal servers whose closing bytes arrive a moment after the reply.

F3 – a failed handshake no longer leaves a session or connection behind (mcpUpstreamSessions.ts, plus the gateway's handshake wrapper)

  • Refusal on the initialized notification: a new error type (ExtensionUpstreamHandshakeUnauthorizedError) carries the half-open session. The entry keeps it, and after the OAuth refresh the gateway resends only the notification, in that same session. If the entry was dropped in the meantime, the session is deleted. Grant end, the sweep, eviction and shutdown also delete a session still in this state.
  • Refusal on initialize or server/discover: the connection opened for that attempt is now closed before the error is passed on.
  • Same gap in the Settings check: "Test connections" and "Discover tools" don't refresh tokens, so they now delete a session left half-open and close its connection.
  • Byte-accounting failure: if recording the handshake's request bytes fails, the new session is closed. The bytes of a refused handshake are now recorded too.
  • Closing a session is now safe to repeat: a second close of the same session does nothing.
  • Tests: a bearer server refuses the notification once, and the next call finishes the same session with no second initialize. An OAuth server refuses it, then the token is refreshed, the notification retried and the session used for the tool call; only one session is ever deleted. There are also checks that refusals on initialize, server/discover and the Settings check close their connection, and that an entry dropped mid-handshake doesn't keep its session.

Checks run: core typecheck and lint on src/extensions are clean. These suites pass: extensionUpstreamSessions (11), extensionOAuth (20), flyOAuthMcpFixture, extensionProfiles, extensionTaskAutoApply, extensionLibraryUsage, extensionPinnedLookup, extensionRemoteRuntime, extensionPackageServers, and the API's extensionDiscovery and extensionProfileRoutes. Some of these only pass when run the way the repo's scripts run them (NODE_ENV=test, --experimental-test-module-mocks). Without those, extensionProfiles fails the same way on the original code. I didn't run the full repository suite.

Nothing here changes what users see, so there are no new previews.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (3 files)
    • packages/core/src/extensions/endpointPolicy.ts (+16/−3)
    • packages/core/src/extensions/mcpGateway.ts (+24/−7)
    • packages/core/src/extensions/mcpUpstreamSessions.ts (+59/−14)
  • Low risk (2 files)
    • packages/core/test/extensionOAuth.test.ts (+31/−0)
    • packages/core/test/extensionUpstreamSessions.test.ts (+156/−2)

Diff size: 5 files changed, +286/−26 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 9m 41s
  • Tokens: 2,983,788 (2,957,505 in / 26,283 out)
  • Cost: $1.61

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

@integry

integry commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Live Sprites run fails at "Start the OAuth MCP fixture on a disposable Sprite"

https://github.com/integry/propr/actions/runs/45968843244 (bef91c8, agent_runtime=sprites, extensions mode):

ExecError: Command failed with exit code 2
stderr: '-p: 1: Syntax error: Unterminated quoted string\n'

Cause: sprite.exec('sh -c "mkdir -p ~/oauth-fixture && cd ~/oauth-fixture && pwd"') (fly-e2e.yml, about line 324). The Sprites SDK's exec(string) splits the command on spaces without honouring quotes, so sh gets -c "mkdir -p ….

Fix: use execFile with an argument array, the way ProPR's runtime code does (spritesMcpForward.ts, spritesPackageBase.ts). For example sprite.execFile('sh', ['-c', 'mkdir -p ~/oauth-fixture && cd ~/oauth-fixture && pwd']). Check every other sprite.exec(...) string in the new fixture and teardown steps for the same problem, and use execFile for each.

Push this as soon as possible; I'll run the Sprites extensions mode again on the new head. Nothing was left behind: the teardown deleted the agent apps and the fixture Sprite.

I fixed F1, F2 and F3. Each has a regression test that fails on the original code and passes now.

**F1 – a call turned away for capacity no longer closes active sessions** (`mcpGateway.ts`)
- When `grantSnapshot` returns a 401, the gateway now checks the grant row. It closes the run's sessions only if the grant is inactive, missing or expired.
- A call refused because the grant is at its concurrency or budget limit leaves the sessions alone. If the check itself fails, sessions are kept and the 15-second sweep handles them later.
- The sweep's own liveness check now uses the same function, so the two can't drift apart.
- Test: with `connections = 4` and then with the call budget used up, the refused call leaves the session in place and the next call reuses it. Once the grant expires, the next refused call deletes it.

**F2 – an event stream the server leaves open no longer holds the only connection** (`endpointPolicy.ts`)
- Once a response is settled on a pinned connection, the transport clears the 10-second request timer and reads out the rest of the response.
- If the server hasn't closed the response within 1 second, the transport closes it. The next request then opens a new connection to the same vetted address.
- A server that ties sessions to one connection will answer that next request with 404. The existing recovery handles it: read calls reopen the session and are replayed once, write calls fail without being replayed. That trade-off can't be avoided, because the client can't reuse a connection while a response is still open on it.
- The same handling covers the drained responses on error, 202/204 and DELETE.
- Test: a real TLS server sends each tool-call reply over an event stream and never closes it, on a write server. Three calls finish in about 2 seconds rather than 10 seconds each, the session is never reopened, and all three streams end up closed.
- **Decision for you:** against such a server, each call after the first still waits up to that 1-second grace. A shorter grace makes those calls faster, but risks cutting off normal servers whose closing bytes arrive a moment after the reply.

**F3 – a failed handshake no longer leaves a session or connection behind** (`mcpUpstreamSessions.ts`, plus the gateway's handshake wrapper)
- **Refusal on the initialized notification:** a new error type (`ExtensionUpstreamHandshakeUnauthorizedError`) carries the half-open session. The entry keeps it, and after the OAuth refresh the gateway resends only the notification, in that same session. If the entry was dropped in the meantime, the session is deleted. Grant end, the sweep, eviction and shutdown also delete a session still in this state.
- **Refusal on `initialize` or `server/discover`:** the connection opened for that attempt is now closed before the error is passed on.
- **Same gap in the Settings check:** "Test connections" and "Discover tools" don't refresh tokens, so they now delete a session left half-open and close its connection.
- **Byte-accounting failure:** if recording the handshake's request bytes fails, the new session is closed. The bytes of a refused handshake are now recorded too.
- Closing a session is now safe to repeat: a second close of the same session does nothing.
- Tests: a bearer server refuses the notification once, and the next call finishes the same session with no second `initialize`. An OAuth server refuses it, then the token is refreshed, the notification retried and the session used for the tool call; only one session is ever deleted. There are also checks that refusals on `initialize`, `server/discover` and the Settings check close their connection, and that an entry dropped mid-handshake doesn't keep its session.

**Checks run:** core typecheck and lint on `src/extensions` are clean. These suites pass: `extensionUpstreamSessions` (11), `extensionOAuth` (20), `flyOAuthMcpFixture`, `extensionProfiles`, `extensionTaskAutoApply`, `extensionLibraryUsage`, `extensionPinnedLookup`, `extensionRemoteRuntime`, `extensionPackageServers`, and the API's `extensionDiscovery` and `extensionProfileRoutes`. Some of these only pass when run the way the repo's scripts run them (`NODE_ENV=test`, `--experimental-test-module-mocks`). Without those, `extensionProfiles` fails the same way on the original code. I didn't run the full repository suite.

Nothing here changes what users see, so there are no new previews.

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

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 27, 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 27, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 6991785

Summary of Changes

I fixed the "Start the OAuth MCP fixture on a disposable Sprite" step, but I couldn't test it against a real Sprite here, so your rerun is the first live check.

The fix: the call at .github/workflows/fly-e2e.yml:324 now passes the shell command as one argument:

sprite.execFile('sh', ['-c', 'mkdir -p ~/oauth-fixture && cd ~/oauth-fixture && pwd'])

The SDK no longer splits the string on spaces. sh expands ~ itself, so the directory it prints (used as home in the following lines) is the same as intended.

The other calls: that was the only sprite.exec(...) string in the workflow. The rest of the fixture step already takes argument arrays: createService gets cmd: 'bash', args: ['-lc', …]. The two teardown steps (reaping the agent's Sprites and deleting the fixture Sprite) only list and delete Sprites, so neither runs a command on one.

Checks:

  • The workflow file still parses as YAML.
  • One of the two tests in test/flyE2eMcpAutomation.test.ts fails: the REST-routes test under PROPR_SPRITES_MCP_TRANSPORT=forward expects ['acme/fixture'] and gets []. It fails the same way with the workflow file as it was at HEAD, so this change didn't cause it, but I haven't looked into why it fails.

This only changes the workflow, so there's no visual preview.

Review digest

Risk-tiered paths

  • High risk (1 file)
    • .github/workflows/fly-e2e.yml (+1/−1): CI or workflow file
  • Normal risk: none
  • Low risk: none

Diff size: 1 file changed, +1/−1 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 3m 53s
  • Tokens: 537,097 (534,503 in / 2,594 out)
  • Cost: $0.37

Undo Changes • 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
Processing comment ID: 7214162548✓

I fixed the "Start the OAuth MCP fixture on a disposable Sprite" step, but I couldn't test it against a real Sprite here, so your rerun is the first live check.

**The fix:** the call at `.github/workflows/fly-e2e.yml:324` now passes the shell command as one argument:

```js
sprite.execFile('sh', ['-c', 'mkdir -p ~/oauth-fixture && cd ~/oauth-fixture && pwd'])
```

The SDK no longer splits the string on spaces. `sh` expands `~` itself, so the directory it prints (used as `home` in the following lines) is the same as intended.

**The other calls:** that was the only `sprite.exec(...)` string in the workflow. The rest of the fixture step already takes argument arrays: `createService` gets `cmd: 'bash', args: ['-lc', …]`. The two teardown steps (reaping the agent's Sprites and deleting the fixture Sprite) only list and delete Sprites, so neither runs a command on one.

**Checks:**
- The workflow file still parses as YAML.
- One of the two tests in `test/flyE2eMcpAutomation.test.ts` fails: the REST-routes test under `PROPR_SPRITES_MCP_TRANSPORT=forward` expects `['acme/fixture']` and gets `[]`. It fails the same way with the workflow file as it was at HEAD, so this change didn't cause it, but I haven't looked into why it fails.

This only changes the workflow, so there's no visual preview.

PR: #3826
Comment by: @integry (ID: 7214162548)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

This PR adds upstream MCP session management, SSE transport support, OAuth session reuse, and expanded Fly smoke coverage. It needs changes before merge: handshake failures can leave unusable sessions cached, SSE parsing depends on network chunk boundaries, and handshake response bytes escape normal call accounting.

✅ Write replay protection — The 404 recovery path explicitly refuses to replay tool calls on write-capable servers.

✅ OAuth handshake recovery — Sessions assigned before an initialized-notification 401 are retained and resumed, with focused tests covering refresh and eventual cleanup.

✅ Runtime coverage — The workflow now exercises four URL-server configurations and checks their session modes, authentication, calls, and cleanup telemetry.

This review is based on static analysis of the supplied code; no commands or tests were run. The supplied current-head status shows 22 passed checks, one pending, and no failures. Live smoke evidence remains outstanding.

Merge blockers

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

F4: 🔴 Failed initialization notifications become cached sessions

  • Category: correctness

  • Required behavior: An upstream session must complete initialization before it is cached as ready for subsequent calls.

  • Evidence: packages/core/src/extensions/mcpUpstreamSessions.ts, openUpstreamSession → send and notify.

    1. An upstream successfully handles initialize and assigns a session ID.
    2. Its initialized-notification endpoint returns HTTP 503 without accepting the notification.
    3. The transport rejects, but send catches every non-401 error and returns undefined.
    4. notify consequently returns a successful state, and ExtensionUpstreamSessions.open caches it.
    5. Subsequent requests reach an upstream that is still awaiting initialization and are refused.

    The gateway never retries the notification for this cached state. Its recovery handles session-not-found responses, not an existing but uninitialized session, and ordinary calls keep updating its idle timestamp. Settings validation also incorrectly reports this handshake as reachable. static trace: the same error-swallowing helper is used for protocol discovery and notification completion; only unauthorized errors retain pending initialization state.

  • Minimum fix: Propagate initialized-notification failures instead of treating them as success. Retain a retryable pending state or close and discard the assigned session; report validation failure until initialization completes.

F5: 🔴 Split CRLF corrupts valid SSE events

  • Category: correctness

  • Required behavior: SSE responses must parse correctly regardless of how their bytes are divided into network chunks.

  • Evidence: packages/core/src/extensions/endpointPolicy.ts, eventStreamParser.push.

    1. A valid SSE response contains a JSON message across multiple data: lines, separated by CRLF.
    2. A network chunk ends immediately after the first line's \r.
    3. Splitting with /\r\n|\r|\n/ consumes that \r as a complete line ending.
    4. The next chunk begins with \n, which is interpreted as an empty line and prematurely dispatches the unfinished event.
    5. Parsing the incomplete JSON fails silently. The remaining data cannot reconstruct the original message, so the call fails or times out.

    TCP chunk boundaries are independent of SSE line boundaries. StringDecoder protects split UTF-8 characters but does not retain CRLF delimiter state. The added transport tests do not exercise this split. static trace: the parser immediately processes a trailing carriage return and carries no flag to consume its following line feed.

  • Minimum fix: Preserve delimiter state across chunks so a split CRLF counts as one line ending. Add a regression covering a multiline JSON event split between \r and \n.

F6: 🔴 Handshake responses bypass the run byte budget

  • Category: correctness

  • Required behavior: The existing run response-byte budget must continue to cover upstream traffic, including the newly added handshake.

  • Evidence: packages/core/src/extensions/mcpGateway.ts, post, handshakeBytes, and the LOCAL_INITIALIZE accounting branch.

    1. A run's first request to a server is tools/list or tools/call, a supported path covered by the new tests.
    2. The gateway receives a large but individually permitted initialize response, sends the initialized notification, and receives the requested tool response.
    3. post records the handshake response size in handshakeBytes.
    4. Because the agent request was not initialize, execution skips the only branch that applies handshakeBytes to responseBytes.
    5. Successful-call accounting charges the ordinary response while releasing the reservation covering the uncharged handshake traffic.

    A small tool response following a near-limit initialize response therefore substantially underreports actual upstream bytes. Repeating this across selected servers consumes traffic outside the grant budget. Individual transport limits constrain each response, while request_bytes records outbound traffic; neither accounts for these omitted inbound bytes. static trace: the added handshake accumulator is consumed only in the local initialize branch.

  • Minimum fix: Include handshake response bytes in every call's accounting and enforce a combined reservation or remaining budget before additional exchanges. Cover first-call tool requests and recovery handshakes.

Suggestions

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

S2: 🟢 Attach both runtime smoke results

The description explicitly acknowledges that the Fly smoke has not run. Attach the Sprites and Fly Machines summaries when credentials are available. This would provide deployment evidence beyond the supplied unit and TLS tests; it is a verification follow-up rather than a separately demonstrated code defect.

S3: 🟢 Verify refresh within an open session

The smoke checks the fixture's cumulative refresh counter, which can include a refresh before the run opens its session. A follow-up could require two OAuth calls separated by refresh and correlate them with one session. The focused OAuth tests already exercise session reuse across refresh, so this would strengthen live coverage.

Score

The implementation has substantial focused coverage and clear session ownership, but three correctness defects remain in initialization, stream parsing, and budget enforcement. Passing checks do not cover these failure paths.

Score: 5/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 33s
  • Tokens: 96,204 (94,078 in / 2,126 out)
  • Cost: $0.94

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 F4 F5 F6 S2 S3

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit ae6d03d

Addressed 1 AI review comment (IDs: 7214845375)

Addressed findings F4, F5, F6

Summary of Changes

I fixed F4, F5 and F6. Each has a regression test that fails on the original code and passes now. The upstream-sessions suite passes (14 tests), as do the other extension suites in core and the API (78 tests); lint and the core typecheck are clean. I didn't run the full repository suite.

F4 – a session is only kept once the initialized notification is accepted (mcpUpstreamSessions.ts, mcpGateway.ts)

  • Errors on the notification are no longer swallowed. A refused credential still keeps the session so it can resume after a token refresh, as before.
  • Any other failure (an error status, a timeout, a dropped connection) raises a new error, ExtensionUpstreamHandshakeIncompleteError, carrying the half-open session. I chose to close the session rather than keep a retryable state: a kept one could get stuck if the upstream had already lost it.
  • On that error the gateway deletes the session upstream, closes its connection and fails the call. The next call starts a fresh initialize. The same applies when a resumed notification fails after a refresh. The bytes the handshake sent are still charged.
  • "Test connections" and "Discover tools" now report the server as unavailable and delete the session they were given.
  • initialize and server/discover still treat a non-credential failure as "this protocol version isn't available", so the fallback between versions is unchanged.
  • I checked the mcptest echo, DeepWiki and Microsoft Learn servers live: all three answer the notification with 202, so this stricter check doesn't break them.

F5 – an event stream split between \r and \n parses correctly (endpointPolicy.ts)

  • The parser now remembers when a chunk ended with a carriage return. If the next chunk starts with a line feed, that line feed completes the same line ending instead of counting as an empty line.
  • Test: a real TLS server sends one JSON message over three data: lines, with every chunk boundary between a \r and its \n.

F6 – handshake responses count against the call's budget (mcpGateway.ts, endpointPolicy.ts)

  • Every upstream response in a gateway call now shares that call's single 1 MiB reservation. That covers the handshake, a new handshake after a lost session, and the call itself.
  • Each request can only read what the earlier ones left: the transport has a new per-request limit, maxBytes. The call is charged the total.
  • This applies to first tools/call and tools/list requests, calls replayed after a lost session, notifications, and the agent's own initialize. Before, the handshake was only charged on that last one. An agent initialize answered by the upstream directly is no longer counted twice.
  • If a response would go past what the handshake left, the call fails and is charged the full reservation, the same as any oversized response.
  • Test: a real TLS server sends a 900 KiB initialize response. It checks the charges on a first tool call, on a call in the open session, after a lost session and on an agent initialize, and that a 200 KiB tool response after it fails.

I also added two sentences on these behaviours to docs/docs/features/agent-extensions.md. There's no visible change, so no previews.

Found but not fixed (outside F4–F6):

  • When the upstream sends a server-to-client request, such as sampling, the gateway's error reply goes out in the background. The upstream's answer to that reply isn't counted against the run's budget.
  • When a response is drained after the call is settled, or a session is deleted, the transport reads the remaining bytes for up to the 1-second grace. Those bytes aren't counted either, and nothing caps them.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (3 files)
    • packages/core/src/extensions/endpointPolicy.ts (+10/−2)
    • packages/core/src/extensions/mcpGateway.ts (+18/−9)
    • packages/core/src/extensions/mcpUpstreamSessions.ts (+30/−8)
  • Low risk (2 files)
    • docs/docs/features/agent-extensions.md (+7/−2)
    • packages/core/test/extensionUpstreamSessions.test.ts (+142/−1)

Diff size: 5 files changed, +207/−22 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 9m 22s
  • Tokens: 2,634,088 (2,608,748 in / 25,340 out)
  • Cost: $1.57

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

I fixed F4, F5 and F6. Each has a regression test that fails on the original code and passes now. The upstream-sessions suite passes (14 tests), as do the other extension suites in core and the API (78 tests); lint and the core typecheck are clean. I didn't run the full repository suite.

**F4 – a session is only kept once the initialized notification is accepted** (`mcpUpstreamSessions.ts`, `mcpGateway.ts`)
- Errors on the notification are no longer swallowed. A refused credential still keeps the session so it can resume after a token refresh, as before.
- Any other failure (an error status, a timeout, a dropped connection) raises a new error, `ExtensionUpstreamHandshakeIncompleteError`, carrying the half-open session. I chose to close the session rather than keep a retryable state: a kept one could get stuck if the upstream had already lost it.
- On that error the gateway deletes the session upstream, closes its connection and fails the call. The next call starts a fresh `initialize`. The same applies when a resumed notification fails after a refresh. The bytes the handshake sent are still charged.
- "Test connections" and "Discover tools" now report the server as unavailable and delete the session they were given.
- `initialize` and `server/discover` still treat a non-credential failure as "this protocol version isn't available", so the fallback between versions is unchanged.
- I checked the mcptest echo, DeepWiki and Microsoft Learn servers live: all three answer the notification with 202, so this stricter check doesn't break them.

**F5 – an event stream split between `\r` and `\n` parses correctly** (`endpointPolicy.ts`)
- The parser now remembers when a chunk ended with a carriage return. If the next chunk starts with a line feed, that line feed completes the same line ending instead of counting as an empty line.
- Test: a real TLS server sends one JSON message over three `data:` lines, with every chunk boundary between a `\r` and its `\n`.

**F6 – handshake responses count against the call's budget** (`mcpGateway.ts`, `endpointPolicy.ts`)
- Every upstream response in a gateway call now shares that call's single 1 MiB reservation. That covers the handshake, a new handshake after a lost session, and the call itself.
- Each request can only read what the earlier ones left: the transport has a new per-request limit, `maxBytes`. The call is charged the total.
- This applies to first `tools/call` and `tools/list` requests, calls replayed after a lost session, notifications, and the agent's own `initialize`. Before, the handshake was only charged on that last one. An agent `initialize` answered by the upstream directly is no longer counted twice.
- If a response would go past what the handshake left, the call fails and is charged the full reservation, the same as any oversized response.
- Test: a real TLS server sends a 900 KiB `initialize` response. It checks the charges on a first tool call, on a call in the open session, after a lost session and on an agent `initialize`, and that a 200 KiB tool response after it fails.

I also added two sentences on these behaviours to `docs/docs/features/agent-extensions.md`. There's no visible change, so no previews.

**Found but not fixed** (outside F4–F6):
- When the upstream sends a server-to-client request, such as sampling, the gateway's error reply goes out in the background. The upstream's answer to that reply isn't counted against the run's budget.
- When a response is drained after the call is settled, or a session is deleted, the transport reads the remaining bytes for up to the 1-second grace. Those bytes aren't counted either, and nothing caps them.

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

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 27, 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 27, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

This PR adds gateway-owned MCP sessions, SSE support, OAuth refresh continuity, and expanded Fly smoke coverage. The implementation is substantial and generally cohesive, but response accounting needs correction before merge.

✅ Conservative write recovery — A session-loss response fails a write call without replaying it; dedicated tests cover that behavior.

✅ Handshake cleanup — Failed initialized notifications retain ownership of the assigned session so it can be resumed after authentication failure or closed.

✅ Transport coverage — Added TLS tests exercise connection reuse, split SSE framing, and streams left open after a reply.

The supplied current-head status reports 20 passed checks, three pending, and no failures. This review is a static analysis of the supplied code; no commands were run.

Merge blockers

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

F7: 🔴 Account for all upstream response traffic

  • Category: correctness

  • Required behavior: The changed gateway must preserve the per-call response reservation and per-run traffic budget, including handshake exchanges and server-to-client request handling.

  • Evidence: packages/core/src/extensions/mcpGateway.ts, post, answering, and remaining; packages/core/src/extensions/mcpUpstreamSessions.ts, openUpstreamSession.send; packages/core/src/extensions/endpointPolicy.ts, accept and release.

    1. An upstream sends an oversized initialize response. The transport reads up to its limit and rejects, but post increments inbound only after a successful await send(...).
    2. openUpstreamSession.send swallows that failure and attempts discovery. Successful discovery and a successful tool response allow the gateway call to finish normally.
    3. The failed initialize traffic is absent from inbound, so discovery receives an undiminished reservation and final accounting refunds bytes already consumed.

    Two sibling paths bypass the same accounting boundary:

    1. An SSE upstream sends the matching response first, followed by additional events during the one-second drain period. accept records wire bytes and resolves immediately; subsequent bytes are consumed without updating the recorded charge.
    2. An upstream sends server-to-client requests. answering launches up to eight separate requests per exchange without maxBytes or response accounting. Each can receive a response independently of the original call’s remaining reservation.

    These paths let upstream traffic exceed the reservation and leave the durable run byte total understated. Per-exchange limits and the eight-answer cap bound individual operations but do not enforce the shared budget. The added accounting test covers successful handshake responses, not swallowed failures, post-reply traffic, or reverse-request answers.

    static trace: Verified from the supplied transport, handshake, and gateway control flow. proposed regression: Exercise each sequence and assert that all consumed response bytes are charged or that the call fails with its full reservation retained.

  • Minimum fix: Track consumed bytes independently of successful parsed responses and share the reservation across every exchange, including reverse-request replies. Ensure fallback cannot erase failed-exchange consumption, and stop or account for traffic consumed after the matching SSE reply.

Suggestions

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

S4: 🟢 Strengthen smoke refresh evidence

The smoke checks cumulative fixture refreshes, which can include refreshes before the agent opens its session. Recording a baseline and requiring a refresh between two calls in the same agent session would demonstrate the intended live behavior more directly. This is optional additional integration evidence because the new unit test already exercises refresh within an open session.

S5: 🟢 Attach both runtime smoke results

The supplied description explicitly says the Fly smoke was not run. Attach results for Sprites and Fly Machines when credentials are available, including the per-server summaries. This would substantiate the deployment claims beyond the local transport and fixture tests.

Score

The session lifecycle and tests are strong, but the new transport paths undermine an existing resource boundary. That requires correction before merge; live runtime verification also remains outstanding.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 17s
  • Tokens: 98,936 (97,454 in / 1,482 out)
  • Cost: $0.94

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 F7 S4 S5

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit f0d8879

Addressed 1 AI review comment (IDs: 7215484686)

Addressed finding F7

Summary of Changes

I fixed F7. The gateway now counts every upstream response byte as it is read, so all three paths the finding describes are charged against the call's one reservation. Three new regression tests fail on the original code and pass now.

What changed

  • Transport (endpointPolicy.ts):
    • Each exchange can now be given a callback that gets every chunk read from the upstream, whether the exchange later succeeds or fails, including error bodies drained on a pinned connection. If the callback says the reservation is spent, the response is ended and the exchange fails.
    • Once the matching event-stream reply has arrived, the next data from the upstream is counted and the stream is ended right away. Before, the gateway kept reading for the one-second grace without counting anything. A stream that just closes after the reply still keeps the pinned socket.
  • Gateway (mcpGateway.ts):
    • The handshake, recovery handshake, the call itself and the answers to server-to-client requests all report to one counter.
    • So a swallowed initialize failure stays charged when the gateway falls back to server/discover, and the discovery request only gets what is left.
    • The answers now have a byte limit and share the reservation; before, each had its own full budget.
    • When the call ends, its charge is set from everything read so far. A chunk that arrives after that (an answer still in flight, or a late event) is added to the run's byte total and ends that response.
    • A call that reads past its reservation is charged the full reservation, nothing more. The chunk that crossed the limit is read but not charged on top, which matches the existing oversized-response test.

Tests (all against a real TLS upstream, in extensionUpstreamSessions.test.ts)

  • A 600 KiB unparsable initialize reply, then a successful server/discover and tool call: the run is charged everything the upstream sent. The original code charged 168 bytes instead of 614,569. With an initialize reply over the reservation, the call fails and is charged the full reservation.
  • An event stream that keeps sending 128 KiB notifications after the reply: the late bytes are charged, and the stream is ended well before the one-second grace.
  • Three server-to-client requests whose answers each get a 100 KiB response: everything is charged with the call. Eight answers of 200 KiB fail the call, which is charged the full reservation.

Checks run

  • Core: the upstream-sessions suite and the other core extension suites pass (142 tests, with PROPR_DEMO_MODE=true). Lint and the core typecheck are clean.
  • API: the extension tests pass except one, "server mounts extension gateway before auth…", which fails the same way with this branch's original gateway and transport. The discovery test needs --experimental-test-module-mocks to run. I didn't run the full repository suite.
  • Docs: I extended the byte-accounting paragraph in docs/docs/features/agent-extensions.md to cover these cases.

There's no visible change, so no previews.

Found but not fixed (outside F7): the gateway's answers to server-to-client requests are small error messages, but the bytes it sends for them are still not added to the run's request-byte total. The finding was about response bytes only.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (2 files)
    • packages/core/src/extensions/endpointPolicy.ts (+28/−6)
    • packages/core/src/extensions/mcpGateway.ts (+27/−10)
  • Low risk (2 files)
    • docs/docs/features/agent-extensions.md (+6/−2)
    • packages/core/test/extensionUpstreamSessions.test.ts (+109/−0)

Diff size: 4 files changed, +170/−18 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 12m 4s
  • Tokens: 3,130,708 (3,107,286 in / 23,422 out)
  • Cost: $1.61

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

@integry

integry commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Live Sprites run: the OAuth fixture's Sprite uses the org's last Sprite

https://github.com/integry/propr/actions/runs/45972876911 (6991785, agent_runtime=sprites, extensions mode). The fixture started fine (the execFile fix works) and the library saved urlServers=4. Then the agent run failed before it began:

Error during Claude agent execution: The Free plan is limited to 3 sprites. Upgrade to Pay As You Go to raise the limit

The Fly Free Plan allows 3 Sprites per org, like its 3 Machines, and the e2e org has two long-lived Sprites that must stay. On a Sprites run, the OAuth fixture's Sprite plus the agent's Sprite comes to 4. So on the Sprites runtime the fixture can't be a Sprite.

Fix: host the OAuth fixture in the pool the run's agents don't use.

  • agent_runtime=sprites → run the fixture on a Fly Machine in its own disposable app (e.g. propr-e2e-oauth-<run>), deployed from a small image or node:22-slim with the fixture file. It gets a public HTTPS *.fly.dev URL on 443 through the Fly proxy. Together with the ProPR Machine that's 2 of 3 Machines.
  • agent_runtime=fly-machines → keep the fixture on a Sprite, as now. The agent Machines (and the Fly Machines: bake runtime packages into a derived agent image #3821 builder, once merged) then have the Machines to themselves.
  • Use the same fixture code and the same OAUTH_FIXTURE_ORIGIN output either way. Teardown deletes whichever was created (flyctl apps destroy --yes / delete the Sprite), even on failure. Put the host kind in the step summary.
  • Mind the fixture's state: a Fly Machine with auto_stop_machines could stop between calls and lose in-memory OAuth state. Set auto_stop_machines = "off" / min_machines_running = 1 for the fixture app, or keep using STATE_FILE on the Machine's disk.

Push this soon. I'll then run extensions mode on Sprites and then Fly Machines. The ultrafix cycle that's running can carry on in parallel.

I fixed F7. The gateway now counts every upstream response byte as it is read, so all three paths the finding describes are charged against the call's one reservation. Three new regression tests fail on the original code and pass now.

**What changed**
- **Transport** (`endpointPolicy.ts`):
  - Each exchange can now be given a callback that gets every chunk read from the upstream, whether the exchange later succeeds or fails, including error bodies drained on a pinned connection. If the callback says the reservation is spent, the response is ended and the exchange fails.
  - Once the matching event-stream reply has arrived, the next data from the upstream is counted and the stream is ended right away. Before, the gateway kept reading for the one-second grace without counting anything. A stream that just closes after the reply still keeps the pinned socket.
- **Gateway** (`mcpGateway.ts`):
  - The handshake, recovery handshake, the call itself and the answers to server-to-client requests all report to one counter.
  - So a swallowed `initialize` failure stays charged when the gateway falls back to `server/discover`, and the discovery request only gets what is left.
  - The answers now have a byte limit and share the reservation; before, each had its own full budget.
  - When the call ends, its charge is set from everything read so far. A chunk that arrives after that (an answer still in flight, or a late event) is added to the run's byte total and ends that response.
  - A call that reads past its reservation is charged the full reservation, nothing more. The chunk that crossed the limit is read but not charged on top, which matches the existing oversized-response test.

**Tests** (all against a real TLS upstream, in `extensionUpstreamSessions.test.ts`)
- A 600 KiB unparsable `initialize` reply, then a successful `server/discover` and tool call: the run is charged everything the upstream sent. The original code charged 168 bytes instead of 614,569. With an `initialize` reply over the reservation, the call fails and is charged the full reservation.
- An event stream that keeps sending 128 KiB notifications after the reply: the late bytes are charged, and the stream is ended well before the one-second grace.
- Three server-to-client requests whose answers each get a 100 KiB response: everything is charged with the call. Eight answers of 200 KiB fail the call, which is charged the full reservation.

**Checks run**
- **Core:** the upstream-sessions suite and the other core extension suites pass (142 tests, with `PROPR_DEMO_MODE=true`). Lint and the core typecheck are clean.
- **API:** the extension tests pass except one, "server mounts extension gateway before auth…", which fails the same way with this branch's original gateway and transport. The discovery test needs `--experimental-test-module-mocks` to run. I didn't run the full repository suite.
- **Docs:** I extended the byte-accounting paragraph in `docs/docs/features/agent-extensions.md` to cover these cases.

There's no visible change, so no previews.

**Found but not fixed** (outside F7): the gateway's answers to server-to-client requests are small error messages, but the bytes it sends for them are still not added to the run's request-byte total. The finding was about response bytes only.

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

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Ultrafix stopped before reaching its goal. Requested goal: 8/10. Last score: 6/10. Stopped in cycle 3 of 3. Max cycles were exhausted, so manual review and merge are now required.

@propr-dev propr-dev Bot removed the ultrafix label Nov 27, 2026
@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 672fc66

Summary of Changes

On Sprites runs, the OAuth fixture now runs on a Fly Machine in its own disposable app, so it no longer takes the org's last Sprite. Fly Machines runs keep it on a Sprite. I haven't run it live: I don't have Fly credentials here. Your Sprites dispatch will be the first real test of the new Machine step.

How the host is chosen (.github/workflows/fly-e2e.yml)

  • A new job variable picks the host from the runtime: sprites gives a Fly Machine, fly-machines gives a Sprite. Both use the name propr-e2e-oauth-<run>-<attempt> (the old OAUTH_SPRITE variable is now OAUTH_FIXTURE_NAME).
  • Sprites runs: a new step creates the app and writes a fly.toml for it:
    • Image node:22-slim, with the fixture file copied in. The Fly proxy serves it at https://<name>.fly.dev on 443, with HTTPS forced.
    • auto_stop_machines = "off" and min_machines_running = 1, plus STATE_FILE on the Machine's disk.
    • flyctl deploy --ha=false, so it gets one Machine rather than the default two. The step then checks the app has exactly one; with the ProPR Machine that's 2 of 3.
    • If the deploy allocated no public IPs, it allocates a shared IPv4 and an IPv6 address. It waits for /health and checks the resource metadata, like the Sprite path.
  • Fly Machines runs: the existing Sprite step runs unchanged.
  • Both paths run the same fixture code and write the same OAUTH_FIXTURE_ORIGIN, so the rest of the workflow is unchanged.
  • Step summary: the start step adds a line naming the host kind, the name and the URL. The final OAuth stats line also names the host.
  • Teardown: a new step destroys the fixture app with flyctl apps destroy --yes. Like the Sprite delete, it is keyed on a marker written before the app is created, so it runs whatever failed.
  • Secrets: the same as before. Sprites runs always need the Sprites token, and Fly Machines runs with extensions still need it for the fixture Sprite.

Checked

  • The workflow parses as YAML and the Machine step's script passes bash -n. The generated fly.toml is valid TOML with the values you'd expect.
  • flyctl v0.5.19 has every flag the step uses. flyctl config validate needs a token, so the config itself is untested against Fly.
  • flyOAuthMcpFixture.test.ts and flyE2eMcpAutomation.test.ts pass.

Worth checking in the Sprites run

  • I expect the fixture file to land in the Machine through the [[files]] section of fly.toml. If it doesn't, the Machine won't start and the run fails at the /health wait.

I also updated setup-fly.md, the extensions input description and the fixture's header comment for the two hosts. There are no visual previews: it's a CI-only change.

Review digest

Risk-tiered paths

  • High risk (2 files)
    • .github/fly-e2e/oauth-mcp-fixture.mjs (+5/−3): auth-looking path
    • .github/workflows/fly-e2e.yml (+89/−9): CI or workflow file
  • Normal risk: none
  • Low risk (1 file)
    • docs/docs/tutorials/setup-fly.md (+3/−3)

Diff size: 3 files changed, +97/−15 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 6m 0s
  • Tokens: 1,093,631 (1,081,127 in / 12,504 out)
  • Cost: $0.84

Undo Changes • 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
Processing comment ID: 7215604180✓

On Sprites runs, the OAuth fixture now runs on a Fly Machine in its own disposable app, so it no longer takes the org's last Sprite. Fly Machines runs keep it on a Sprite. I haven't run it live: I don't have Fly credentials here. Your Sprites dispatch will be the first real test of the new Machine step.

**How the host is chosen** (`.github/workflows/fly-e2e.yml`)
- A new job variable picks the host from the runtime: `sprites` gives a Fly Machine, `fly-machines` gives a Sprite. Both use the name `propr-e2e-oauth-<run>-<attempt>` (the old `OAUTH_SPRITE` variable is now `OAUTH_FIXTURE_NAME`).
- **Sprites runs:** a new step creates the app and writes a `fly.toml` for it:
  - Image `node:22-slim`, with the fixture file copied in. The Fly proxy serves it at `https://<name>.fly.dev` on 443, with HTTPS forced.
  - `auto_stop_machines = "off"` and `min_machines_running = 1`, plus `STATE_FILE` on the Machine's disk.
  - `flyctl deploy --ha=false`, so it gets one Machine rather than the default two. The step then checks the app has exactly one; with the ProPR Machine that's 2 of 3.
  - If the deploy allocated no public IPs, it allocates a shared IPv4 and an IPv6 address. It waits for `/health` and checks the resource metadata, like the Sprite path.
- **Fly Machines runs:** the existing Sprite step runs unchanged.
- Both paths run the same fixture code and write the same `OAUTH_FIXTURE_ORIGIN`, so the rest of the workflow is unchanged.
- **Step summary:** the start step adds a line naming the host kind, the name and the URL. The final OAuth stats line also names the host.
- **Teardown:** a new step destroys the fixture app with `flyctl apps destroy --yes`. Like the Sprite delete, it is keyed on a marker written before the app is created, so it runs whatever failed.
- **Secrets:** the same as before. Sprites runs always need the Sprites token, and Fly Machines runs with extensions still need it for the fixture Sprite.

**Checked**
- The workflow parses as YAML and the Machine step's script passes `bash -n`. The generated `fly.toml` is valid TOML with the values you'd expect.
- `flyctl` v0.5.19 has every flag the step uses. `flyctl config validate` needs a token, so the config itself is untested against Fly.
- `flyOAuthMcpFixture.test.ts` and `flyE2eMcpAutomation.test.ts` pass.

**Worth checking in the Sprites run**
- I expect the fixture file to land in the Machine through the `[[files]]` section of `fly.toml`. If it doesn't, the Machine won't start and the run fails at the `/health` wait.

I also updated `setup-fly.md`, the extensions input description and the fixture's header comment for the two hosts. There are no visual previews: it's a CI-only change.

PR: #3826
Comment by: @integry (ID: 7215604180)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5
I fixed F9. When an entry is dropped, `open` now closes any session it just opened and fails the call. A dropped entry can't open a new upstream session, either in `attempt`'s 404 recovery or in any later `open`. The three new tests pass, along with the existing `extensionUpstreamSessions` and `extensionOAuth` suites. All three new tests fail when run against the HEAD sources, so they do catch the bug. Lint (zero warnings) and the typecheck are clean for core's sources; core's lint config ignores test files, so the test file wasn't linted.

**What changed (`mcpUpstreamSessions.ts`)**
- When an entry is dropped, the registry now records why.
- `open` checks that first and refuses the entry:
  - a capacity eviction gets `ExtensionUpstreamSessionCapacityError`.
  - any other reason (grant end, shutdown) gets the new `ExtensionUpstreamSessionEndedError`.
- `open` checks again after the handshake. If the entry was dropped meanwhile, the session it just got is closed (with a `DELETE` if stateful) and the call fails with that error. Before, it returned the closed session.
- A second caller waiting on the same handshake is checked the same way after it finishes, so it can't get the closed session either.

**Gateway (`mcpGateway.ts`)**: the gateway turns the new error into the same 401 a call gets after its grant ends (`Extension grant expired or exhausted`). The capacity error is a 503 (`MCP session capacity reached`), as it already is when a new entry hits the cap.

**Tests (`extensionUpstreamSessions.test.ts`)**
- **Grant end during the first handshake:** `closeGrant` runs while the upstream answers `initialize`. The call fails with the 401, the tool call is never sent, the new session is deleted, and nothing is kept.
- **Grant end during the 404 re-initialize:** the upstream loses the session, and `closeGrant` runs during the new `initialize`. The call fails with the 401, the read call is not replayed, `upstream-session-2` is deleted, and no third session is opened.
- **Calls on a dropped entry:** `open` on an entry whose grant ended, or one evicted for capacity, is refused without starting a handshake. A second caller waiting on the same handshake when the grant ends is refused too, and that session is closed.

One case still works as before. If the grant ends during a handshake the upstream refuses with 401, the original 401 still comes back, so an OAuth server may still refresh its token once. The retry is then refused by the new check and opens no session. I left that alone so an existing test's expected error stays the same.

There's nothing visible to users, so I made no preview.

PR: #3826
Comment by: @integry (ID: 7218712278)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

integry commented Nov 27, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Nov 27, 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 27, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds upstream MCP sessions, protocol negotiation, OAuth session reuse, and runtime smoke coverage. It needs a localized cleanup fix before merge.

✅ Handshake fencing — Dropped entries refuse subsequent opens, and successful handshakes completed after removal close their new state and fail the call. Tests cover initial and recovery handshakes.

✅ Bounded transport — Response metering includes handshakes and server-request replies; stateless connections permit parallel calls while stateful connections have a bounded queue.

This review is a static analysis of the supplied code; no commands were run. Current checks show no failures, with 17 pending.

Merge blockers

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

F10: 🔴 Preserve credentials during cleanup callback replacement

  • Category: correctness

  • Required behavior: Grant-end cleanup must attempt authenticated deletion of existing upstream sessions using the available credential.

  • Evidence: packages/core/src/extensions/mcpGateway.ts, sessions.entry and attempt; packages/core/src/extensions/mcpUpstreamSessions.ts, entry, drop, and closeUpstreamSession.

    static trace:

    1. An OAuth server has an established session. Its existing remove callback captures the credential used successfully by the preceding call.
    2. Another gateway call executes sessions.entry(...). This immediately replaces entry.remove with a closure capturing this new call's latest, which is still undefined.
    3. The call awaits credential(), whose OAuth implementation performs database reads and potentially a refresh. During that await, run completion invokes closeExtensionGrantSessions.
    4. drop invokes the replacement callback before attempt assigns latest. The DELETE therefore carries no Bearer token. The PR's own OAuth fixture rejects such a request with 401 before deleting the session.
    5. The entry has already been removed, and closeUpstreamSession marks the state closed before sending. No subsequent sweep retries this deletion, leaving the upstream session alive.

    The active-call counter prevents capacity eviction, but intentionally does not prevent grant-end cleanup. The real transport accepts any DELETE status, so this refusal also produces deleted: true. The previous usable credential was available through the callback that step 2 replaced; this is an avoidable authentication omission, independent of unavoidable external cleanup failures.

    proposed regression: establish an authenticated session, hold the next credential lookup pending, close the grant, and assert DELETE receives the preceding credential and removes the upstream session.

  • Minimum fix: Preserve the existing cleanup callback until a replacement credential is available. Update the callback when the credential is actually acquired or refreshed, ensuring grant-end cleanup during credential lookup retains the last usable credential.

Suggestions

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

S12: 🟢 Attach updated runtime smoke evidence

Attach the planned Sprites and Fly Machines results for the current head, including the session and authentication tables. The supplied successful Sprites evidence predates the latest changes, and the Fly endpoint correction has no supplied successful live result. This would strengthen deployment confidence without establishing another code defect.

Score

The implementation has substantial targeted coverage and addresses the requested handshake race, but authenticated session cleanup still has a concrete concurrency defect. A localized correction and regression test should resolve it.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 26s
  • Tokens: 122,133 (120,390 in / 1,743 out)
  • Cost: $1.18

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 S12

🤖 Review by ProPR

@propr-dev propr-dev Bot changed the title 🔨 [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live ⚠️❻ [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live Nov 27, 2026
@integry

integry commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Please fix F10 from the latest review. A new call's sessions.entry(...) must not replace the entry's cleanup callback with one whose credential isn't resolved yet. Keep the last credential that worked on the entry and update it only after a call has resolved a new one, so a grant-end DELETE always carries a token. Add a test: an OAuth entry with an established session, a second call waiting on credential(), and the grant ending at that moment; the DELETE carries the previous token. Nothing else needs to change. After this I'll do my own review of the change, rerun both runtimes and merge.

@propr-dev propr-dev Bot changed the title ⚠️❻ [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live 🔨 [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live Nov 27, 2026
@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Summary of Changes

F10 is fixed. A grant-end DELETE now always carries the last credential that worked on the entry, including when it races a call still waiting on credential().

Change

  • mcpUpstreamSessions.ts: entry() sets remove only when it creates the entry. For an existing entry it now updates only alive and the call counters. credentialUsed(entry, credential, remove) is the one place remove gets replaced, and it runs only after a call has resolved its credential.
  • mcpGateway.ts: the shared latest variable is gone. A new entry starts with a no-op remove, since it has no session to delete yet. attempt(used) then sets the DELETE with that call's resolved token, and the 401 retry does the same with the refreshed token. Nothing else changed.

Test (extensionOAuth.test.ts, "a grant ending while a second call waits on its credential deletes the session with the previous token")

  • The first call opens and uses an OAuth session.
  • The clock moves past the refresh margin, so the second call's credential() starts a refresh, and the test holds that refresh request.
  • While it's held, the grant ends with closeGrant. The test checks that the one DELETE is for oauth-session-1 and carries the first token.
  • Once the refresh is released, the second call fails with the grant-expired error and no new upstream session is opened.

Checks

  • New test: passes with the fix. Against the HEAD source it fails with bearer: undefined, which is the F10 bug.
  • Related suites: extensionOAuth, extensionUpstreamSessions and flyOAuthMcpFixture pass.
  • extensionProfiles suite: "catalog stdio is callable through both selected authorized launcher policies…" fails, and the run hangs at exit. That test fails the same way on HEAD without this change. The run was cut off before the failure details printed, so I don't know the exact cause; it is probably the container environment.
  • Lint and typecheck: both are clean for packages/core.

No preview was made, because nothing visible changed.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (2 files)
    • packages/core/src/extensions/mcpGateway.ts (+4/−4)
    • packages/core/src/extensions/mcpUpstreamSessions.ts (+13/−4)
  • Low risk (1 file)
    • packages/core/test/extensionOAuth.test.ts (+39/−0)

Diff size: 3 files changed, +56/−8 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 25m 51s
  • Tokens: 1,871,088 (1,861,866 in / 9,222 out)
  • Cost: $0.90
  • Subscription usage: Fable +1%

Undo Changes • 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
Processing comment ID: 7219181440✓

F10 is fixed. A grant-end `DELETE` now always carries the last credential that worked on the entry, including when it races a call still waiting on `credential()`.

**Change**
- **`mcpUpstreamSessions.ts`:** `entry()` sets `remove` only when it creates the entry. For an existing entry it now updates only `alive` and the call counters. `credentialUsed(entry, credential, remove)` is the one place `remove` gets replaced, and it runs only after a call has resolved its credential.
- **`mcpGateway.ts`:** the shared `latest` variable is gone. A new entry starts with a no-op `remove`, since it has no session to delete yet. `attempt(used)` then sets the `DELETE` with that call's resolved token, and the 401 retry does the same with the refreshed token. Nothing else changed.

**Test** (`extensionOAuth.test.ts`, "a grant ending while a second call waits on its credential deletes the session with the previous token")
- The first call opens and uses an OAuth session.
- The clock moves past the refresh margin, so the second call's `credential()` starts a refresh, and the test holds that refresh request.
- While it's held, the grant ends with `closeGrant`. The test checks that the one `DELETE` is for `oauth-session-1` and carries the first token.
- Once the refresh is released, the second call fails with the grant-expired error and no new upstream session is opened.

**Checks**
- **New test:** passes with the fix. Against the HEAD source it fails with `bearer: undefined`, which is the F10 bug.
- **Related suites:** `extensionOAuth`, `extensionUpstreamSessions` and `flyOAuthMcpFixture` pass.
- **`extensionProfiles` suite:** "catalog stdio is callable through both selected authorized launcher policies…" fails, and the run hangs at exit. That test fails the same way on HEAD without this change. The run was cut off before the failure details printed, so I don't know the exact cause; it is probably the container environment.
- **Lint and typecheck:** both are clean for `packages/core`.

No preview was made, because nothing visible changed.

PR: #3826
Comment by: @integry (ID: 7219181440)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5
@propr-dev propr-dev Bot changed the title 🔨 [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live ⚠️❻ [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live Nov 27, 2026
@integry

integry commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Fly Machines run on 7fb0c0f: url-oauth connected, but Test connections reported it unavailable

https://github.com/integry/propr/actions/runs/46011054496, step "Add Extension Library items before idle shutdown". The OAuth sign-in finished (oauth.connections["url-oauth"].state == "connected"), and the wrong-Bearer check passed in 1 s. Then Test connections returned:

{"name":"url-oauth","reachable":false,"status":"unavailable","session":null,"authentication":"oauth"}

The other three URL servers were reachable. On 45063f1 the same mode passed, with the fixture also on a Sprite, so the only source change in between is F9/F10 (mcpGateway.ts, mcpUpstreamSessions.ts).

Please:

  1. Check whether F9/F10 broke the validate path for OAuth. For example: does Test connections go through sessions.entry/open, so that the new entry's no-op remove, the fence, or credentialUsed now running only after the credential resolves leaves an OAuth probe without its token? Or does a session dropped right after sign-in hit the new ExtensionUpstreamSessionEndedError? Add a unit test: Test connections for an OAuth server that has just connected reports it reachable and stateful.
  2. Expose the reason: a Test connections result that is unavailable should carry a short, secret-free reason (HTTP status, session ended, token refresh failed, timeout and so on), and the workflow should print it. As it stands, the run gives nothing to diagnose from.
  3. If you can show it was the fixture (a cold Sprite, for example), say so with evidence, and make the workflow wait on the fixture's /health right before Test connections.

I'll rerun Fly Machines and Sprites after this.

@propr-dev propr-dev Bot changed the title ⚠️❻ [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live 🔨 [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live Nov 27, 2026
@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit fe7fb19

Summary of Changes

F9/F10 didn't cause this. Test connections never goes through the gateway's session pool. The run's timing points to one 10-second request timeout against the Sprite fixture, but I can't prove it was the fixture. Test connections now reports a reason for any unavailable server, and the workflow prints it.

1. F9/F10 and Test connections

  • A different path. Test connections (validate in extensionProfileRoutes.ts) calls probeExtensionMcp directly. It never uses sessions.entry/open, the new no-op remove, the fence, credentialUsed or ExtensionUpstreamSessionEndedError. Between 45063f1 and 7fb0c0f only mcpGateway.ts and the session-pool part of mcpUpstreamSessions.ts changed. probeExtensionMcp, openUpstreamSession and the transport in endpointPolicy.ts are byte-identical.
  • New test. flyOAuthMcpFixture.test.ts runs Test connections against the real OAuth fixture and ProPR's OAuth client:
    • Before sign-in it reports unavailable with reason OAuth not connected.
    • Right after sign-in it reports reachable, stateful, oauth. The fixture counts one session opened and deleted, and no extra 401s, so the token went with every request.
    • After the run's gateway session is dropped at grant end, it is still reachable, in a new session of its own.

3. Was it the fixture?

There's no direct evidence. The ProPR app logs in the failure dump stop at 14:02:47, at "Extension OAuth server connected", before Test connections ran. The fixture's /stats was never read. What the step timestamps show:

  • This run (46011054496): the wrong-token check ended at 14:02:46.5 and the step failed at 14:02:59.4. Sign-in plus Test connections took about 13 s.
  • Last green Fly Machines run (45998138280, fixture also on a Sprite): the same stretch took under 4 s. The first Test connections, covering all four servers, took 1 s in both runs.

So url-oauth spent about 10 s, which is the per-request timeout (EXTENSION_LIMITS.timeoutMs). The likeliest reading is that initialize to the Sprite got no answer in time. The fallback server/discover then failed fast, which yields unavailable. The Sprite had just answered the token exchange, though, so "cold" isn't proven.

As you asked, the workflow now waits for the fixture's /health right before Test connections. It also prints the fixture's /stats counters before and after, which show whether ProPR's requests reached it.

2. The reason field

An unavailable result now carries a short reason with no secrets in it:

  • HTTP failures: initialize: timeout after 10 s; server/discover: HTTP 400, HTTP 503, JSON-RPC error -32600 (the code only, never the message).
  • Connection and credential failures: connection failed (ECONNRESET), credential refused (HTTP 401).
  • OAuth: OAuth not connected, token refresh failed, token refresh refused: sign in again.

No response body, header, host or token goes into it. The loop moved into a new core file, extensionConnectionTest.ts, which the route calls. The transport's failures now carry a reason through ExtensionUpstreamRequestError; the error message is still MCP connection failed. The OpenAPI text and the UI type gained the field, but the Settings page doesn't display it yet.

The workflow prints each URL server's status and reason, how long Test connections took, and the reason for the wrong-Bearer refusal. A failure's ::error:: line now names the server and its reason. I checked those jq lines against sample results.

Verification

  • Passing: the new reason test in extensionUpstreamSessions.test.ts (real TLS transport for the HTTP status and JSON-RPC cases), the fixture test, the other core extension test files, the API extension route and OpenAPI tests, gen:openapi:check, and the test/fly* workflow tests. Lint and typecheck are clean for core, api and the UI file.
  • Not clean, same on clean HEAD: in extensionProfiles.test.ts, 44 tests pass, catalog stdio … fails ("stdio fixture closed"), and the process never exits. I didn't run the full repository suite.

No previews: nothing in the UI changed visibly.

Review digest

Risk-tiered paths

  • High risk (1 file)
    • .github/workflows/fly-e2e.yml (+17/−2): CI or workflow file
  • Normal risk (6 files)
    • packages/api/openapi/routeDocsSystem.ts (+1/−1)
    • packages/api/routes/extensionProfileRoutes.ts (+3/−16)
    • packages/core/src/extensions/endpointPolicy.ts (+30/−8)
    • packages/core/src/extensions/extensionConnectionTest.ts (added, +56/−0)
    • packages/core/src/extensions/mcpUpstreamSessions.ts (+23/−9)
    • propr-ui/src/api/extensionProfilesApi.ts (+2/−0)
  • Low risk (3 files)
    • docs/static/openapi/propr-api.yaml (+1/−1)
    • packages/core/test/extensionUpstreamSessions.test.ts (+32/−1)
    • packages/core/test/flyOAuthMcpFixture.test.ts (+18/−2)

Diff size: 10 files changed, +183/−40 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 51m 57s
  • Tokens: 10,408,186 (10,370,099 in / 38,087 out)
  • Cost: $3.67
  • Subscription usage: Weekly +2%

Undo Changes • 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
Processing comment ID: 7220349553✓

F9/F10 didn't cause this. Test connections never goes through the gateway's session pool. The run's timing points to one 10-second request timeout against the Sprite fixture, but I can't prove it was the fixture. Test connections now reports a `reason` for any unavailable server, and the workflow prints it.

## 1. F9/F10 and Test connections
- **A different path.** Test connections (`validate` in `extensionProfileRoutes.ts`) calls `probeExtensionMcp` directly. It never uses `sessions.entry`/`open`, the new no-op `remove`, the fence, `credentialUsed` or `ExtensionUpstreamSessionEndedError`. Between 45063f1 and 7fb0c0f only `mcpGateway.ts` and the session-pool part of `mcpUpstreamSessions.ts` changed. `probeExtensionMcp`, `openUpstreamSession` and the transport in `endpointPolicy.ts` are byte-identical.
- **New test.** `flyOAuthMcpFixture.test.ts` runs Test connections against the real OAuth fixture and ProPR's OAuth client:
  - Before sign-in it reports unavailable with reason `OAuth not connected`.
  - Right after sign-in it reports `reachable`, `stateful`, `oauth`. The fixture counts one session opened and deleted, and no extra 401s, so the token went with every request.
  - After the run's gateway session is dropped at grant end, it is still reachable, in a new session of its own.

## 3. Was it the fixture?
There's no direct evidence. The ProPR app logs in the failure dump stop at 14:02:47, at "Extension OAuth server connected", before Test connections ran. The fixture's `/stats` was never read. What the step timestamps show:
- **This run (46011054496):** the wrong-token check ended at 14:02:46.5 and the step failed at 14:02:59.4. Sign-in plus Test connections took about 13 s.
- **Last green Fly Machines run (45998138280, fixture also on a Sprite):** the same stretch took under 4 s. The first Test connections, covering all four servers, took 1 s in both runs.

So `url-oauth` spent about 10 s, which is the per-request timeout (`EXTENSION_LIMITS.timeoutMs`). The likeliest reading is that `initialize` to the Sprite got no answer in time. The fallback `server/discover` then failed fast, which yields `unavailable`. The Sprite had just answered the token exchange, though, so "cold" isn't proven.

As you asked, the workflow now waits for the fixture's `/health` right before Test connections. It also prints the fixture's `/stats` counters before and after, which show whether ProPR's requests reached it.

## 2. The `reason` field
An `unavailable` result now carries a short reason with no secrets in it:
- **HTTP failures:** `initialize: timeout after 10 s; server/discover: HTTP 400`, `HTTP 503`, `JSON-RPC error -32600` (the code only, never the message).
- **Connection and credential failures:** `connection failed (ECONNRESET)`, `credential refused (HTTP 401)`.
- **OAuth:** `OAuth not connected`, `token refresh failed`, `token refresh refused: sign in again`.

No response body, header, host or token goes into it. The loop moved into a new core file, `extensionConnectionTest.ts`, which the route calls. The transport's failures now carry a reason through `ExtensionUpstreamRequestError`; the error message is still `MCP connection failed`. The OpenAPI text and the UI type gained the field, but the Settings page doesn't display it yet.

The workflow prints each URL server's status and reason, how long Test connections took, and the reason for the wrong-Bearer refusal. A failure's `::error::` line now names the server and its reason. I checked those `jq` lines against sample results.

## Verification
- **Passing:** the new reason test in `extensionUpstreamSessions.test.ts` (real TLS transport for the HTTP status and JSON-RPC cases), the fixture test, the other core extension test files, the API extension route and OpenAPI tests, `gen:openapi:check`, and the `test/fly*` workflow tests. Lint and typecheck are clean for core, api and the UI file.
- **Not clean, same on clean HEAD:** in `extensionProfiles.test.ts`, 44 tests pass, `catalog stdio …` fails ("stdio fixture closed"), and the process never exits. I didn't run the full repository suite.

No previews: nothing in the UI changed visibly.

PR: #3826
Comment by: @integry (ID: 7220349553)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

🔀 Resolved merge conflicts from 3758-epic-runtime-abstraction-sc0 into 3824/claude-opus-5-5-extension-library-url-mcp-20261126-2350-bz1 in commit 6efa15b

Conflicting Files

  • docs/docs/architecture/agent-runtime.md

Resolution Summary

I resolved the one merge conflict, in docs/docs/architecture/agent-runtime.md. A search of the whole repository found no other conflict markers.

What the conflict was about: Both branches rewrote the same paragraph in the "Fly Machines" section, the one about workspaces, credentials, runtime packages and how agent Machines reach MCP.

  • This PR's version: It changed the MCP address. A control plane deployed with propr deploy fly runs the worker and API in one Machine, so agent Machines reach MCP and the extension gateway at http://<control-plane-machine-id>.vm.<control-plane-app>.internal:<DASHBOARD_API_PORT>/api/mcp. When no Machine id is set, the host is <FLY_PROCESS_GROUP>.process.<app>.internal. It also says the API now listens on :: (DASHBOARD_API_HOST), because 0.0.0.0 accepts IPv4 only. It still described runtime packages as "installed at every Machine start".
  • 3758-epic-runtime-abstraction-sc0's version: It changed the runtime-packages sentence. Packages now come preinstalled in a derived image, and PROPR_FLY_BOOT_TIMEOUT does not include building that image or a fallback install at Machine start. But it kept the old MCP address, api.process.<control-plane-app>.internal.

How I resolved it: I kept one paragraph that combines both changes:

  • The runtime-packages sentence comes from 3758-epic-runtime-abstraction-sc0, including its link to the existing "Derived Fly images" section.
  • Everything about the MCP and extension-gateway address comes from this PR: the Machine-id host and its process-group fallback, the IPv6 :: listen note, and the wording that PROPR_FLY_MCP_URL overrides the endpoint "for example when the API runs on another Machine".
  • The sentences that were the same on both sides are unchanged.

Why: Each side updated a different fact in the same paragraph, and neither change replaces the other, so the merged text has to carry both. On the MCP address I followed this PR, because it matches the code: packages/core/src/agents/runtime/fly/config.ts builds the host as ${machine}.vm.${app}.internal, falling back to ${FLY_PROCESS_GROUP || 'app'}.process.${app}.internal. On runtime packages I followed the target branch, because that is where derived images were added.

The edit is in the working tree, but git add failed because the repository's git directory is read-only in this container. Git may therefore still list the file as conflicted until the system stages it.


🤖 Resolution Details

  • Model: Claude Opus 5.5
  • Time: 4m 32s

View Task Execution


System-triggered merge conflict resolution

integry commented Nov 27, 2026

Copy link
Copy Markdown
Owner

/merge

Automatically resolved merge conflicts after merging target branch into PR branch.
Resolved conflicts in:
- docs/docs/architecture/agent-runtime.md

PR: #3826
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

🔀 Auto-merged 3758-epic-runtime-abstraction-sc0 into 3824/claude-opus-5-5-extension-library-url-mcp-20261126-2350-bz1 (clean merge) in commit 6efa15b

No conflicts were found — the merge was verified by an AI agent.


🤖 Verification Details

  • Model: Claude Opus 5.5
  • Time: 4m 6s

View Task Execution


System-triggered merge conflict resolution

@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

🔀 Auto-merged 3758-epic-runtime-abstraction-sc0 into 3824/claude-opus-5-5-extension-library-url-mcp-20261126-2350-bz1 (clean merge) in commit 6efa15b

No conflicts were found — the merge was verified by an AI agent.


🤖 Verification Details

  • Model: Claude Opus 5.5
  • Time: 3m 46s

View Task Execution


System-triggered merge conflict resolution

@integry

integry commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Fly Machines on 6efa15b: the same 10 s hang to the Sprite-hosted fixture. Likely cause: the gateway dials only addresses[0]

https://github.com/integry/propr/actions/runs/46021934633. The fixture passed /health at 15:16:52. The wrong-Bearer check passed at 15:17:06 (credential refused (HTTP 401); the new reason works). The next ProPR call that reaches the fixture (POST /api/instance/extensions/v1/oauth/check) returned 502 after exactly 10 s (15:17:17). That's the second Fly Machines run in a row with a 10 s hang to *.sprites.app, and it was not a cold fixture: the fixture had answered 15 s earlier. ProPR's Machine was healthy, with no restart in the app log.

What I think is happening: resolveExtensionEndpoint resolves with { all: true, verbatim: true } and returns addresses[0]. extensionPinnedConnection then pins the socket to that single address. *.sprites.app has both records:

A    169.155.48.226
AAAA 2a09:8280:1::99:d7b3:0

On a Fly Machine the AAAA record comes first, so ProPR dials only the IPv6 address. When that path stalls, there's no fallback, and the request dies at the 10 s timeout. Sprites runs, where the fixture is on *.fly.dev, and the mcptest.io servers have never hit this. That matches an IPv6-path problem specific to Fly → Sprites. A pinned socket also bypasses Node's own Happy Eyeballs (autoSelectFamily), because the lookup returns a single address.

The fix (this affects real users too: any MCP server or OAuth provider with a broken or slow IPv6 path):

  1. Keep every vetted address, not addresses[0]. All of them already pass the public-address or pinned-address check.
  2. Connect Happy Eyeballs style: try them in order, alternating families, and start the next one after about 250 ms without a connection; the first connected socket wins. Give each address a connect timeout (for example 3 s) inside the overall 10 s request budget. Keep pinning: the session's agent reuses the address that connected, so the address vetted for a session stays the address it uses.
  3. Apply the same thing to the OAuth paths: discovery, registration and token requests (oauth/check, oauth/start, callback, refresh) go through the same resolve-and-pin. That's where this 502 came from.
  4. Reasons: a connect failure's reason names the family and stage, e.g. connect timeout (IPv6 2a09:…, then IPv4 …). oauth/check's 502 body carries the reason too, and the workflow prints it (curl -f hides the body today).
  5. Tests: a lookup returning a black-holed IPv6 address and then a working IPv4 address connects over IPv4 within the budget. Every attempted address is still vetted. A session stays on its connected address.

If you can show from inside a Fly Machine (curl -6 against the fixture) that IPv6 isn't the cause, report what you see. The fallback is still worth having either way. I'll rerun Fly Machines and Sprites after this.

@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 2337a9d

Summary of Changes

MCP and OAuth requests now try every vetted address with Happy Eyeballs fallback instead of dialling only addresses[0]. All the extension suites pass, plus the new tests, lint and typecheck. I couldn't run anything from inside a Fly Machine, so I haven't confirmed that IPv6 caused the 10 s hang. The rerun you have planned will show it either way.

What changed

  • Every vetted address is kept. resolveExtensionEndpoint returns all the addresses that passed the public-address or pinned-address check.
  • Connecting (new packages/core/src/extensions/happyEyeballs.ts):
    • Addresses are tried in resolver order, alternating families, starting the next one 250 ms after the previous one starts, or at once if it fails.
    • Each address gets 3 s to connect. The whole connect phase must finish within the 10 s request timeout, and connect time counts against it.
    • The first socket to connect wins, every other attempt is closed, and only IP literals are dialled. TLS then runs on the winning socket with the original hostname.
  • Pinning: a session's connection records the address that connected first. Every later connection in that session dials only that address, including the pool a stateless server switches to after the handshake. DNS and policy are still checked on every request.
  • OAuth: discovery, registration, token and refresh requests (oauth/check, oauth/start, callback, refresh) use the same connector.
  • Reasons:
    • A failed connect gives connect timeout (IPv6 2606:…, then IPv4 8.8.8.8) when everything timed out. Otherwise it gives connect failed (IPv6 … timed out, then IPv4 … ECONNREFUSED), plus ; N more not tried if the overall limit ran out first.
    • The oauth/check 502 body now carries the reason: {"error":"The MCP server could not be reached","reason":"…"}.
    • Test connections shows token refresh failed (<reason>) when a refresh can't connect.
    • Reasons include the vetted IP addresses, as in your example. They only go to administrators (Test connections and the Settings API), never to agents.
  • Workflow: when oauth/check or oauth/start fails, the workflow now prints the error body (error and reason) as an ::error:: line instead of exiting silently.
  • Docs: the extensions page describes the fallback and the new reasons.

Tests

  • New file packages/core/test/extensionHappyEyeballs.test.ts:
    • A lookup returning a black-holed IPv6 address and then a working IPv4 one connects over IPv4 in about 260 ms. An MCP request and an OAuth request over the same setup both succeed in under 3 s.
    • If any resolved address is non-public, the request is refused and nothing is dialled.
    • A session keeps using the address that connected, even after the DNS answers change, and the policy check still runs on each request.
    • The reason format is checked.
  • oauth/check reason: a route test checks that the 502 body carries the reason.
  • Existing tests: some answer a public address from a local TLS server. They now redirect the dial with a small test helper, because the connector no longer goes through the URL host. One discovery test now expects the new dial agent where it used to expect agent: false.
  • Live check from this container: the new transport reached mcptest.io and DeepWiki, both of which have A and AAAA records, in 550–730 ms.

There are no previews, since nothing in the UI changed.

Review digest

Risk-tiered paths

  • High risk (4 files)
    • .github/workflows/fly-e2e.yml (+8/−3): CI or workflow file
    • packages/core/src/extensions/extensionOAuth.ts (+1/−1): auth-looking path
    • packages/core/src/extensions/extensionOAuthHttp.ts (+21/−15): auth-looking path
    • packages/core/src/extensions/extensionOAuthStore.ts (+6/−4): auth-looking path
  • Normal risk (6 files)
    • packages/api/routes/extensionProfileRoutes.ts (+1/−1)
    • packages/core/src/extensions/endpointPolicy.ts (+41/−22)
    • packages/core/src/extensions/extensionConnectionTest.ts (+2/−1)
    • packages/core/src/extensions/extensionProfileStore.ts (+2/−1)
    • packages/core/src/extensions/happyEyeballs.ts (added, +127/−0)
    • packages/core/src/extensions/mcpUpstreamSessions.ts (+3/−3)
  • Low risk (8 files)
    • docs/docs/features/agent-extensions.md (+13/−5)
    • packages/api/test/extensionDiscovery.test.ts (+4/−2)
    • packages/api/test/extensionOAuthRoutes.test.ts (+10/−1)
    • packages/core/test/extensionHappyEyeballs.test.ts (added, +171/−0)
    • packages/core/test/extensionOAuth.test.ts (+12/−2)
    • packages/core/test/extensionProfiles.test.ts (+3/−0)
    • packages/core/test/extensionUpstreamSessions.test.ts (+7/−0)
    • packages/core/test/helpers/extensionDialRedirect.ts (added, +17/−0)

Diff size: 18 files changed, +449/−61 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 19m 18s
  • Tokens: 8,153,369 (8,103,497 in / 49,872 out)
  • Cost: $3.39
  • Subscription usage: Weekly +2%

Undo Changes • 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
Processing comment ID: 7221952672✓

MCP and OAuth requests now try every vetted address with Happy Eyeballs fallback instead of dialling only `addresses[0]`. All the extension suites pass, plus the new tests, lint and typecheck. I couldn't run anything from inside a Fly Machine, so I haven't confirmed that IPv6 caused the 10 s hang. The rerun you have planned will show it either way.

**What changed**
- **Every vetted address is kept.** `resolveExtensionEndpoint` returns all the addresses that passed the public-address or pinned-address check.
- **Connecting** (new `packages/core/src/extensions/happyEyeballs.ts`):
  - Addresses are tried in resolver order, alternating families, starting the next one 250 ms after the previous one starts, or at once if it fails.
  - Each address gets 3 s to connect. The whole connect phase must finish within the 10 s request timeout, and connect time counts against it.
  - The first socket to connect wins, every other attempt is closed, and only IP literals are dialled. TLS then runs on the winning socket with the original hostname.
- **Pinning:** a session's connection records the address that connected first. Every later connection in that session dials only that address, including the pool a stateless server switches to after the handshake. DNS and policy are still checked on every request.
- **OAuth:** discovery, registration, token and refresh requests (`oauth/check`, `oauth/start`, callback, refresh) use the same connector.
- **Reasons:**
  - A failed connect gives `connect timeout (IPv6 2606:…, then IPv4 8.8.8.8)` when everything timed out. Otherwise it gives `connect failed (IPv6 … timed out, then IPv4 … ECONNREFUSED)`, plus `; N more not tried` if the overall limit ran out first.
  - The `oauth/check` 502 body now carries the reason: `{"error":"The MCP server could not be reached","reason":"…"}`.
  - Test connections shows `token refresh failed (<reason>)` when a refresh can't connect.
  - Reasons include the vetted IP addresses, as in your example. They only go to administrators (Test connections and the Settings API), never to agents.
- **Workflow:** when `oauth/check` or `oauth/start` fails, the workflow now prints the error body (error and reason) as an `::error::` line instead of exiting silently.
- **Docs:** the extensions page describes the fallback and the new reasons.

**Tests**
- **New file `packages/core/test/extensionHappyEyeballs.test.ts`:**
  - A lookup returning a black-holed IPv6 address and then a working IPv4 one connects over IPv4 in about 260 ms. An MCP request and an OAuth request over the same setup both succeed in under 3 s.
  - If any resolved address is non-public, the request is refused and nothing is dialled.
  - A session keeps using the address that connected, even after the DNS answers change, and the policy check still runs on each request.
  - The reason format is checked.
- **`oauth/check` reason:** a route test checks that the 502 body carries the reason.
- **Existing tests:** some answer a public address from a local TLS server. They now redirect the dial with a small test helper, because the connector no longer goes through the URL host. One discovery test now expects the new dial agent where it used to expect `agent: false`.
- **Live check from this container:** the new transport reached mcptest.io and DeepWiki, both of which have A and AAAA records, in 550–730 ms.

There are no previews, since nothing in the UI changed.

PR: #3826
Comment by: @integry (ID: 7221952672)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5
@integry

integry commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Fly Machines on 2337a9d: still a 10 s hang, but it's not the connect

https://github.com/integry/propr/actions/runs/46027327976: OAuth Check failed: {"error":"OAuth request failed","reason":"timeout after 10 s"}. The new dialer would have reported connect timeout (IPv6 …, then IPv4 …) if TCP had failed, so the TCP connection to *.sprites.app succeeded, and the response never came (TLS or HTTP). The Happy Eyeballs change is still good to keep, but it doesn't fix this. It's now the third Fly Machines run in a row where the ProPR Machine → Sprite-hosted fixture path hangs. The runner reaches the same fixture fine (/health and the metadata both answered in the start step).

Before changing anything else, we need to know where the request stops. Please add failure diagnostics to the workflow, all secret-free:

  1. Log every request in the fixture: time, method, path, remote address, Fly-Client-IP / X-Forwarded-For if present, status, duration. Write them to state.json or a log file, and on failure dump them with sprite exec before the Sprite is deleted. That shows whether ProPR's request reached the fixture at all.
  2. Probe from ProPR's Machine on failure: flyctl ssh console --app "$APP" -C running curl -sS -o /dev/null -w '%{remote_ip} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} code=%{http_code}\n' --max-time 20 against $OAUTH_FIXTURE_ORIGIN/health, three times each with -4 and -6. Also run the same from the runner for comparison.
  3. Add the timing to the 10 s reason (timeout after 10 s (connected over IPv6 2a09:…, TLS done | TLS not done, no response)), so the stage is visible without the probe.

If the probe shows that one family (say IPv6) connects but never answers from a Fly Machine while the other works, the dialer can't detect that at TCP level. In that case also widen the fallback: a request that got no response is retried once over the other family when it's idempotent (GET discovery, metadata, /health), never a POST that may have reached the server. If the probe shows both families hang from Fly but not from the runner, it's a Fly→Sprites platform path problem. Then say so, and we decide between reporting it to Fly and moving the fixture.

I'll rerun after this.

@propr-dev

propr-dev Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 29bd6d4

Summary of Changes

I've added the three diagnostics. Nothing else in the gateway changed. I didn't widen the fallback to retry over the other family, because that depends on what the probe shows.

1. Fixture request log (.github/fly-e2e/oauth-mcp-fixture.mjs)

  • Each request is written to REQUEST_LOG (JSON lines) twice: once when it arrives and once when its response finishes or its connection closes. A request that arrives and then hangs still shows up as a start entry.
  • Each entry has: time, method, the path without the query, remote address, Fly-Client-IP and X-Forwarded-For, status (null if no headers were sent), whether the response completed, and duration.
  • The two address headers are cut to 200 characters, and anything not IP-like becomes *. Queries, other headers and bodies are never logged, so no client ids, codes or tokens are written.
  • The log is at ~/oauth-fixture/requests.jsonl on the Sprite and /tmp/oauth-mcp-fixture.requests.jsonl on the Fly Machine host.

2. New failure step: "Probe the OAuth fixture path and dump its request log on failure"

  • It runs on failure() in extensions mode, before any teardown step, and always exits 0.
  • It requests $OAUTH_FIXTURE_ORIGIN/health three times each with -4 and -6, using your -w format (%{remote_ip} connect= tls= ttfb= code=, --max-time 20). It also prints the resolved addresses and curl's exit code and error. This runs from the runner first, then from ProPR's Machine through flyctl ssh console --app "$APP" --container app -C. The control-plane image has curl.
  • It then prints the last 300 log entries: with sprite exec (execFile('tail', …)) for a Sprite host, or flyctl ssh console for the Fly Machine host. It finishes with the /stats counters, minus the echoes.
  • I ran the probe script here against a public origin, both directly and through the same base64 sh -s path the ssh command uses. This container has no IPv6, so only the IPv4 lines show real timings.

3. Stage in the 10 s reason (MCP gateway and OAuth requests alike)

  • The reason now reads, for example, timeout after 10 s (connected over IPv6 2a09:…, TLS done, no response).
  • Other forms are TLS not done, response headers received, body incomplete, and not connected when no socket was assigned.
  • The docs line in agent-extensions.md mentions the new form.

Tests

  • Two new tests in extensionHappyEyeballs.test.ts cover each stage, for MCP and OAuth.
  • flyOAuthMcpFixture.test.ts now checks the request log's fields, and that it contains no fixture_… value, Bearer or ?.
  • I fixed a test-helper problem I found: a test that mocks net.connect twice left a mock in place for the tests after it.
  • The extension, gateway and fixture suites pass, and typecheck and source lint are clean.
  • One test, catalog stdio is callable through both selected authorized launcher policies…, fails in this container. It also fails with the three changed source files swapped back to their HEAD versions, so it isn't caused by this change.

Reading the rerun

  • Request log: if it has no entry from ProPR's Machine, the request never reached the fixture. If it has only a start, it reached the fixture and stalled there.
  • Probe, one family fails: if only one family hangs from the Machine (connects but ttfb never arrives), I'll add the retry: a request that got no response is retried once over the other family, only for idempotent GETs, never a POST.
  • Probe, both families fail: if both hang from the Machine but not from the runner, it's a Fly→Sprites platform path problem.

Review digest

Risk-tiered paths

  • High risk (3 files)
    • .github/fly-e2e/oauth-mcp-fixture.mjs (+28/−2): auth-looking path
    • .github/workflows/fly-e2e.yml (+58/−3): CI or workflow file
    • packages/core/src/extensions/extensionOAuthHttp.ts (+6/−2): auth-looking path
  • Normal risk (2 files)
    • packages/core/src/extensions/endpointPolicy.ts (+6/−4)
    • packages/core/src/extensions/happyEyeballs.ts (+17/−0)
  • Low risk (3 files)
    • docs/docs/features/agent-extensions.md (+3/−1)
    • packages/core/test/extensionHappyEyeballs.test.ts (+52/−1)
    • packages/core/test/flyOAuthMcpFixture.test.ts (+14/−0)

Diff size: 8 files changed, +184/−13 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 18m 30s
  • Tokens: 5,003,904 (4,977,043 in / 26,861 out)
  • Cost: $2.10

Undo Changes • 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
Processing comment ID: 7222635441✓

I've added the three diagnostics. Nothing else in the gateway changed. I didn't widen the fallback to retry over the other family, because that depends on what the probe shows.

**1. Fixture request log** (`.github/fly-e2e/oauth-mcp-fixture.mjs`)
- Each request is written to `REQUEST_LOG` (JSON lines) twice: once when it arrives and once when its response finishes or its connection closes. A request that arrives and then hangs still shows up as a `start` entry.
- Each entry has: time, method, the path without the query, remote address, `Fly-Client-IP` and `X-Forwarded-For`, status (null if no headers were sent), whether the response completed, and duration.
- The two address headers are cut to 200 characters, and anything not IP-like becomes `*`. Queries, other headers and bodies are never logged, so no client ids, codes or tokens are written.
- The log is at `~/oauth-fixture/requests.jsonl` on the Sprite and `/tmp/oauth-mcp-fixture.requests.jsonl` on the Fly Machine host.

**2. New failure step: "Probe the OAuth fixture path and dump its request log on failure"**
- It runs on `failure()` in extensions mode, before any teardown step, and always exits 0.
- It requests `$OAUTH_FIXTURE_ORIGIN/health` three times each with `-4` and `-6`, using your `-w` format (`%{remote_ip} connect= tls= ttfb= code=`, `--max-time 20`). It also prints the resolved addresses and curl's exit code and error. This runs from the runner first, then from ProPR's Machine through `flyctl ssh console --app "$APP" --container app -C`. The control-plane image has curl.
- It then prints the last 300 log entries: with `sprite exec` (`execFile('tail', …)`) for a Sprite host, or `flyctl ssh console` for the Fly Machine host. It finishes with the `/stats` counters, minus the echoes.
- I ran the probe script here against a public origin, both directly and through the same base64 `sh -s` path the ssh command uses. This container has no IPv6, so only the IPv4 lines show real timings.

**3. Stage in the 10 s reason** (MCP gateway and OAuth requests alike)
- The reason now reads, for example, `timeout after 10 s (connected over IPv6 2a09:…, TLS done, no response)`.
- Other forms are `TLS not done`, `response headers received, body incomplete`, and `not connected` when no socket was assigned.
- The docs line in `agent-extensions.md` mentions the new form.

**Tests**
- Two new tests in `extensionHappyEyeballs.test.ts` cover each stage, for MCP and OAuth.
- `flyOAuthMcpFixture.test.ts` now checks the request log's fields, and that it contains no `fixture_…` value, `Bearer` or `?`.
- I fixed a test-helper problem I found: a test that mocks `net.connect` twice left a mock in place for the tests after it.
- The extension, gateway and fixture suites pass, and typecheck and source lint are clean.
- One test, `catalog stdio is callable through both selected authorized launcher policies…`, fails in this container. It also fails with the three changed source files swapped back to their HEAD versions, so it isn't caused by this change.

**Reading the rerun**
- **Request log:** if it has no entry from ProPR's Machine, the request never reached the fixture. If it has only a `start`, it reached the fixture and stalled there.
- **Probe, one family fails:** if only one family hangs from the Machine (connects but `ttfb` never arrives), I'll add the retry: a request that got no response is retried once over the other family, only for idempotent GETs, never a POST.
- **Probe, both families fail:** if both hang from the Machine but not from the runner, it's a Fly→Sprites platform path problem.

PR: #3826
Comment by: @integry (ID: 7222635441)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5
@propr-dev propr-dev Bot changed the title 🔨 [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live ⚠️❻ [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live Nov 27, 2026
@integry
integry merged commit fb9bf04 into 3758-epic-runtime-abstraction-sc0 Nov 27, 2026
47 checks passed
@propr-dev propr-dev Bot changed the title ⚠️❻ [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live [3824 by Claude Opus 5.5] Extension Library: URL MCP servers with stateful sessions and OAuth on remote runtimes, verified live Nov 27, 2026
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