Repository navigation
fix(lifespan): bound the startup gate below the client handshake budget - #199
Merged
Merged
Conversation
A stdio server blocked in maintenance_lock.acquire() waited the full 120 s default, while the opencode v2 client gives up on initialize after ~6 s and logs 'mcp transport error ... process exited'. The process was alive and polling the lock the whole time, so the client's message was simply wrong — but the effect was real: for every session that started during the wedge there was no memory server at all. The gate's own docstring already promised the fallback is 'better a noisy success than a server that never comes up'. A 120 s wait broke that promise: the ungated fallback only ran long after the client had stopped listening. Measured 2026-11-13 (holding the lock with a probe process): uncontended handshake ~2.7 s gate 4 s + work ~6.24 s (still late, right on the cliff) gate 2 s + work ~4.27 s (inside the budget) So: gate 2 s, with CLIENT_HANDSHAKE_BUDGET_S recording the constraint, and ARIEL_MIGRATION_GATE_TIMEOUT_S to override when a long migration must be waited out. Regression test asserts gate < budget. Verified: contended handshake 4.27 s, uncontended 2.7 s, 5 gate tests pass, full suite 2870 passed, mypy clean.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A stdio MCP server blocked in
maintenance_lock.acquire()waited the full 120 s default, while the opencode v2 client gives up oninitializeafter ~6 s and logs:The process was alive and polling the lock the whole time, so the client's message was wrong — but the effect was real: for every session that started during the wedge there was no memory server at all. That is exactly the 2026-11-13 incident (a wedged v1 process held
.maintenance.lockfor 3.5 days; v2 clients saw a dead server).The gate's own docstring already promised the fallback is "better a noisy success than a server that never comes up". A 120 s wait broke that promise: the ungated fallback only ran long after the client had stopped listening.
Evidence
Measured with a probe process holding the lock:
Uncontended startup is ~2.7 s (imports + migrations), so the gate has to leave room inside the budget rather than assume the work is free.
Fix
CLIENT_HANDSHAKE_BUDGET_S = 6.0records the constraint that was implicit before.MIGRATION_GATE_TIMEOUT_Sdefault 120 → 2, overridable withARIEL_MIGRATION_GATE_TIMEOUT_Swhen a deliberately long migration must be waited out.MIGRATION_GATE_TIMEOUT_S < CLIENT_HANDSHAKE_BUDGET_S, so the asymmetry cannot come back silently.Verification
tests/test_mcp_server/test_lifespan_gate.py: 5 passed