Skip to content

fix(mcp-gateway): give a server reaped at the initialize deadline a longer one next time (0.13) - #39598

Merged
buluoray merged 2 commits into
release/0.13.0from
crew/slack/0.13-core-init-deadline
Nov 20, 2026
Merged

buluoray merged 2 commits into
release/0.13.0from
crew/slack/0.13-core-init-deadline

Conversation

@buluoray

@buluoray buluoray commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Ship the fix from #39546 in 0.13, so a Crew MCP server whose cold start runs a little past the 30 s initialize deadline starts on a later attempt, instead of failing every chat.

Every commit in this PR is a cherry-pick from main (git cherry-pick -x).

Pick From main Why in 0.13
fix(mcp-gateway): give a server reaped at the initialize deadline a longer one next time #39546, 8548bc5df60e A user-reported KAS bug: every chat fails with kirocrew-core: failed (backend init failed: initialize did not complete within 30s), and updating does not help (#30915)
fix(mcp-gateway): cap the initialize-deadline reap memory and key it by a digest #39878, e77a3e51f025 Follow-up to the pick above: keys the reap count by a fixed-size digest and caps it at 256 keys, so caller-chosen pool keys cannot grow it forever (the review finding on this PR)

Prerequisites: none. Both picks applied cleanly to release/0.13.0.

Why it matters

When it happens, no chat works on that machine. The gateway kills the slow backend at 30 s and starts the next attempt cold with the same 30 s, so every attempt fails the same way.

Not a goal

  • Any change beyond the pick from main.

What changed (motivation → approach → change)

The pick makes the next spawn of a pool key wait longer after a deadline reap: 60 s after one reap, 120 s (cap) after two or more; a completed handshake resets it. The first spawn keeps today's deadline. Full rationale on #39546.

Backwards compatibility

Compatible: the first spawn of every key keeps today's deadline; only a respawn after a deadline reap waits longer.

Removes nothing: the pick only lengthens a deadline for a key whose last spawns were reaped.

Tests

The picks carry test/test_mcp_gateway_spawn_gate.py::TestAcquireBackendOrder::test_a_key_reaped_at_the_initialize_deadline_gets_a_longer_one_next and ::test_reaped_keys_that_never_come_back_ready_are_capped. After the second pick, test_mcp_gateway_spawn_gate.py passes on this branch (96 passed) and flake8 is clean.

Run on this branch (release PRs get no backend CI lanes): test_mcp_gateway_spawn_gate.py 95 passed, test_mcp_gateway_spawn_order.py 17, test_adaptive_controller.py 71, test_mcp_gateway_daemon_composition_contract.py 60, test_kas_managed_mcp_start_reattempt.py 26, test_mcp_gateway_breaker.py 4, test_mcp_gateway_backend_coverage.py 88, test_flake_pattern_ratchet.py 71; flake8 and mypy clean.

Proof: not provable -- other: backport of a pick from main; the proof and the before/after run are on #39546.

Manual verification

N/A — verified on #39546 with a real slow server through the real spawn path.

Real-machine verification

N/A -- backport of #39546; its real-machine before/after run is on that PR.

Related Issues

Part of #30915

Sibling sweep

Siblings: none -- a backport; the sweep is on #39546.

Pattern harvest

Not generalizable: a backport of #39546, whose harvest line covers it.

Checklist

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 19, 2026 20:14
@buluoray
buluoray requested review from dodgeblaster and removed request for a team November 19, 2026 20:14
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of e8feab50c8e20e25c6687f907831afc99dca2c32 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check: this backend-only change to MCP gateway deadlines adds or changes no user-visible control.

[UX-REVIEWED] e8feab5

Description read

[DESCRIPTION-READ] 6fb71ea16d2771c6507dc523859c857a2cc12d7676a32d7e694e85530efb86b9

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of e8feab50c8e20e25c6687f907831afc99dca2c32 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this is a clean backport of #39546 and its follow-up #39878. The deadline only gets longer for a pool key after a deadline reap, and the reap memory is capped.

Notes

  • The reap count is kept in memory per Admission instance, so a gateway restart resets it to the base deadline. That is acceptable: the next reap starts the backoff again, which is what this fix aims for.
  • gatewayd.py reaches into the Backend private fields _init_done_event, _init_state and _dead_reason from outside that class. A small public accessor on Backend on main would keep this seam from silently breaking if those fields change. That belongs in a later PR on main, not in this backport.

[DESIGN-REVIEWED] e8feab5

Description read

[DESCRIPTION-READ] 376ed2fe42fbdaee2d12a36700af08be77dcd44e77e2b892c16a0bc51c50e827

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of e8feab50c8e20e25c6687f907831afc99dca2c32 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks: this backports two fixes from main that remove a reported failure (#30915) at the point where it happens, by stretching the respawn deadline after a deadline reap.

Not checked: the patch file lists 94 files; git shows only 3 differ between this merge and its base. The other 91 are already on the base.

What this change ships

Inventory (5 items) — 5 justified

Intent: let a slow-starting MCP server start on a later try in 0.13, instead of every chat failing at the 30 s initialize deadline. This is a FIX.

  1. After a server is killed at the initialize deadline, its next start waits 60 s, then 120 s at most; a completed handshake resets the wait — justified
  2. The first start of every server keeps today's deadline — justified
  3. The gateway remembers deadline kills for at most 256 servers and forgets the oldest first — justified
  4. Each remembered server is stored as a fixed-size digest instead of its caller-chosen key — justified
  5. A background task per spawned backend records how the handshake ended and stops when the process exits — justified

[FIRST-PRINCIPLES-REVIEWED] e8feab5

Description read

[DESCRIPTION-READ] 3952bb1b4f158066c305b0b3b254ccdf1913bdc6643da29d2a431815615d615b

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed e8feab50c8e20e25c6687f907831afc99dca2c32 — this comment is updated in place on each push.

Review details

No findings.

Notes:

  • The new per-key stretch of the initialize deadline (doubling, INIT_DEADLINE_STRETCH_CAP_SECS, reset once a handshake completes) is not yet described where initialize_timeout_secs is documented, in docs/architecture/mcp.md:1697 and docs/system-specs/modules/config.md:3465.

[OPUS-REVIEWED] e8feab5

Verdict parsed from the review's SHA-scoped output markers for commit e8feab50c8e20e25c6687f907831afc99dca2c32.

False positive or not applicable? A repository writer can comment:
/ai-review override fable e8feab50c8e20e25c6687f907831afc99dca2c32 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ human override accepted

Human judgment by @buluoray overrides the GPT 6.1 finding for e8feab50c8e20e25c6687f907831afc99dca2c32; the recorded reason is authoritative for this commit.

[GPT-OVERRIDE] e8feab5

This comment is updated in place on each push.

The model was not re-run because an authorized human decision supersedes it.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e8feab50c8e20e25c6687f907831afc99dca2c32 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 19, 2026
@buluoray buluoray changed the title [0.13] fix(mcp-gateway): give a server reaped at the initialize deadline a longer one next time fix(mcp-gateway): give a server reaped at the initialize deadline a longer one next time (0.13) Nov 20, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 20, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 20, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt e8feab5 not-applicable: finding is in dashboard/chat_api/slot_detail.py, which this backport does not touch; the same code is already on main. The diff only changes mcp_gateway/admission.py, gatewayd.py and one test.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@buluoray recorded a not-applicable release (class not-applicable) for the gpt AI finding on e8feab50c8e20e25c6687f907831afc99dca2c32.

finding is in dashboard/chat_api/slot_detail.py, which this backport does not touch; the same code is already on main. The diff only changes mcp_gateway/admission.py, gatewayd.py and one test.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 20, 2026
@buluoray
buluoray merged commit b8de376 into release/0.13.0 Nov 20, 2026
96 of 100 checks passed
@buluoray
buluoray deleted the crew/slack/0.13-core-init-deadline branch November 20, 2026 13:11
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant