Skip to content

fix(ci): MCP replacement proof stalls during provider discovery - #137639

Merged
steipete merged 1 commit into
mainfrom
codex/test-mcp-replacement-warmup
Sep 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-mcp-replacement-warmup

Conversation

@steipete

@steipete steipete commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Related: #137502.

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.

What Problem This Solves

Resolves a problem where the authenticated MCP plugin-replacement test could time out while asserting that a retired handle rejects. The handle rejected immediately; unrelated provider-auth discovery occupied the test thread for roughly a minute before the assertion resumed.

Why This Change Was Made

The fixture already isolates prepared-model and context refresh, leaving the subsequent provider-auth warmup to discover providers from a deliberately unprepared catalog. It now isolates that third refresh boundary and asserts that the reload schedules it with the replacement configuration. Existing reload-order and provider-auth owner tests cover the excluded discovery work.

All real HTTP MCP traffic, credential checks, registry retirement, stale-handle rejection, request counters, replacement routing, and cleanup remain in the fixture. No production code, deadline, or behavior assertion is relaxed.

User Impact

CI retains the authenticated MCP replacement proof without spending roughly a minute on unrelated provider discovery. Application behavior is unchanged.

Evidence

On the exact failing CI merge, the unchanged file passed locally but repeatedly spent 52–60 seconds in this case. A CPU profile attributed 95% of the stalled interval to provider-auth discovery and source transformation after the stale call had already rejected. The exact CI timeout was 120 seconds under the original hosted child.

The unchanged 135-pattern hosted child passes: 1,771 tests across 89 files, with one pre-existing skip. The auth owners pass 35 tests across two files, and two targeted reload/disposal sibling cases pass. The final formatted MCP file passes all 12 tests; formatter, lint, and assertion-safety checks pass.

A sequential same-host benchmark measured 67.63 seconds and 2,303,036 KiB peak RSS before, versus 10.94 seconds and 2,100,532 KiB after; the affected case changed from 57,318 ms to 285 ms. These include test-launcher and source-transform overhead, not application-runtime performance.

Production delta: zero. Tests: +10/−2, net +8. The changed test and seven relevant owner/sibling files match current main before the patch. Independent Codex review completed all four context partitions with no P0–P2 findings. Exact-head CI 33817192970 passed, including the production dependency audit. Native preparation also passed.

@steipete steipete self-assigned this Sep 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Sep 3, 2026
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The final test-only head is ef55dedb1895883758f7bdaddf7969759f724bca. The original hosted child passes 1,771 tests, auth/reload siblings pass, independent Codex review is clean, and exact-head CI is green. Native preparation passed; landing requires a completed ClawSweeper review.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 3, 2026, 7:45 PM ET / 23:45 UTC.

ClawSweeper review

What this changes

The branch stubs and asserts the provider-auth warmup in the MCP plugin-replacement test so unrelated provider discovery cannot stall the credential-revocation proof.

Merge readiness

✅ Ready for maintainer review

Keep open. This focused, maintainer-owned test reliability repair preserves the production reload call while preventing unrelated provider-auth discovery from delaying the MCP replacement proof; no blocking finding was identified.

Priority: P3
Reviewed head: ef55dedb1895883758f7bdaddf7969759f724bca

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, well-contained test fix that preserves and explicitly checks the production scheduling contract.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-owned, test-only PR; the external-contributor real-behavior-proof gate does not apply. The reviewed fixture still exercises authenticated loopback MCP traffic, while the provided CI evidence is supplemental.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-owned, test-only PR; the external-contributor real-behavior-proof gate does not apply. The reviewed fixture still exercises authenticated loopback MCP traffic, while the provided CI evidence is supplemental.
Evidence reviewed 5 items Introduced test isolation: The verified introduced delta adds only a spy for provider-auth warmup and an assertion that reload schedules it; the authenticated MCP traffic, retirement, stale-handle rejection, and replacement-routing assertions remain unchanged.
Production scheduling contract: Current main invokes provider-auth warmup only after the reload work and passes a cancellation predicate; plugin reloads require that rewarm, so the new assertion preserves the relevant production composition while avoiding its incidental execution.
Warmup owner and sibling coverage: The warmup performs runtime-auth store and lookup collection before its worker call, while the gateway reload owner suite separately asserts rewarm ordering after plugin reload and provider-auth configuration changes.
Findings None None.
Security None None.

How this fits together

Gateway reload replaces plugin registry state, disposes MCP runtimes, and schedules cache refreshes. This test drives a plugin replacement through authenticated loopback MCP traffic, then checks that retired credentials cannot be reused and replacement routing works.

flowchart LR
  A[Authenticated MCP fixture] --> B[Gateway plugin reload]
  B --> C[Registry replacement]
  B --> D[Cache refresh scheduling]
  D --> E[Provider auth warmup]
  C --> F[Retired runtime disposal]
  F --> G[Stale credential rejection]
  C --> H[Replacement MCP routing]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +8. Total +8 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 10 2 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 10 2 +8

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +10/-2 The patch is confined to one test and adds no runtime, configuration, dependency, or compatibility surface.

Technical review

Best possible solution:

Retain this narrow test-only isolation and continue to cover provider-auth rewarm semantics in the gateway reload and provider-auth owner suites.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the path: plugin reload schedules the warmup, whose pre-worker lookup collection can execute during this focused MCP proof; the reviewed snapshot also records the affected CI timing evidence.

Is this the best way to solve the issue?

Yes. Stubbing the unrelated asynchronous refresh while asserting it was scheduled keeps the MCP credential-revocation boundary intact; its owner suites already cover the warmup behavior itself.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against e93edb0af270.

Labels

Label changes:

  • add P3: This is a bounded CI-test reliability improvement with no application behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-owned, test-only PR; the external-contributor real-behavior-proof gate does not apply. The reviewed fixture still exercises authenticated loopback MCP traffic, while the provided CI evidence is supplemental.

Label justifications:

  • P3: This is a bounded CI-test reliability improvement with no application behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-owned, test-only PR; the external-contributor real-behavior-proof gate does not apply. The reviewed fixture still exercises authenticated loopback MCP traffic, while the provided CI evidence is supplemental.

Evidence

What I checked:

  • Introduced test isolation: The verified introduced delta adds only a spy for provider-auth warmup and an assertion that reload schedules it; the authenticated MCP traffic, retirement, stale-handle rejection, and replacement-routing assertions remain unchanged. (src/agents/mcp-connection-resolver.test.ts:258, ef55dedb1895)
  • Production scheduling contract: Current main invokes provider-auth warmup only after the reload work and passes a cancellation predicate; plugin reloads require that rewarm, so the new assertion preserves the relevant production composition while avoiding its incidental execution. (src/gateway/server-reload-hot.ts:668, e93edb0af270)
  • Warmup owner and sibling coverage: The warmup performs runtime-auth store and lookup collection before its worker call, while the gateway reload owner suite separately asserts rewarm ordering after plugin reload and provider-auth configuration changes. (src/agents/model-provider-auth.ts:559, e93edb0af270)
  • Test cleanup boundary: The MCP test restores all spies after every case, and its explicit finally block disposes MCP runtimes, clears provider-auth state, restores model state, and closes the loopback server. (src/agents/mcp-connection-resolver.test.ts:175, ef55dedb1895)
  • Current-main and ownership history: The fetched main revision does not contain this test-only improvement; repository history shows a recent merged gateway change touching this test, authored by Peter Steinberger. Parent/blob availability prevented a verified line-introduction attribution, so this is routing evidence only. (src/agents/mcp-connection-resolver.test.ts:246, 5a9168fea35b)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 0b3c5f9 into main Sep 3, 2026
112 checks passed
@steipete
steipete deleted the codex/test-mcp-replacement-warmup branch September 3, 2026 23:49
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 4, 2026
…date-command

* origin/main:
  fix(ci): retry transient npm advisory timeouts (#137716)
  fix: keep restored Usage navigation from being replaced by Chat (#137402)
  fix: keep Usage day totals within the selected session scope (#137396)
  refactor: reduce live digest scheduling allocations (#137655)
  fix(ui): submit selected slash arguments in new sessions (#137571)
  fix(ui): expand collapsed task progress on final (#137569)
  fix(test): prevent auth discovery from stalling MCP replacement proof (#137639)
  test(cli): reuse canonical directory mock call helper (#137640)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant