Implement graceful MCP maintenance-drain mode #659
Open
opened 2026-07-10 15:31:23 -05:00 by jcwalker3
·
2 comments
No Branch/Tag Specified
master
fix/issue-987-native-mcp-bootstrap
feat/issue-985-project-scoped-launcher-identity
fix/issue-983-cross-repo-base-ref
feat/issue-980-stale-worker-retirement
fix/issue-975-client-identity-heartbeat
fix/issue-973-cross-repo-canonical-roots
fix/issue-970-safely-resolve-missing-worktrees
fix/issue-969-native-mcp-bootstrap
feat/issue-664-break-glass-restart
feat/issue-708-mcp-namespace-attachment
feat/issue-665-restart-audit
fix/issue-700-durable-walls
fix/issue-704-prevent-env-workspace-bindings
feat/issue-707-cross-project-boundaries
fix/issue-690-review-profile-switch-guard
fix/issue-953-bootstrap-lock-provenance
feat/issue-949-native-fleet-inventory
fix/issue-943-runtime-context-helpers
fix/issue-945-owning-pr-renewal-evidence
fix/issue-941-scope-guard-bootstrap-wiring
docs/issue-930-remote-mcp-coupling-inventory
fix/issue-892-author-bootstrap-deadlock
fix/issue-686-detect-reject-manual-mcp
fix/issue-672-mcp-config-drift
fix/issue-689-deterministic-mcp-namespace
feat/issue-666-concurrent-mcp-restart-tests
feat/issue-659-maintenance-drain-mode
feat/issue-648-notifications-console
fix/issue-670-direct-master-incident
feat/issue-644-console-recovery
feat/issue-650-providers-insights
feat/issue-669-scoped-component-recovery
docs/issue-668-mcp-ha-rolling-restart
feat/issue-667-console-restart-controls
feat/issue-645-linkage-console
feat/issue-643-request-preview-initiate
fix/issue-897-permission-stale-runtime-classification
feat/issue-641-runtime-session-view
feat/issue-663-restart-classes
feat/issue-661-drain-proof-hard-gate
fix/issue-854-semantic-container-exclusion
issue-640
fix/issue-682-starlette-httpx2
v1.1.0
Labels
Clear labels
allocator
anti-stomp
architecture
bug
chore
codex
concurrency
contamination
control-plane
dashboard
database
design
documentation
enhancement
gitea
glitchtip
important
incident
incident-bridge
integration
jenkins
labels
leases
mcp
mcp-health
mcp-menu
multi-project
mutating
nice-to-have
observability
portability
preflight
protected-branch
queue
read-only
reconnect
recovery
refactor
release
reliability
resumable-review
reviewer
roadmap
safety
security
self-hosted
sentry
stale-runtime
status:blocked
status:in-progress
status:pr-open
status:ready
terminal-lock
testing
tracker
type:bug
type:feature
type:feature
type:guardrail
visibility
workflow
workflow-hardening
workflow-hardening
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
Controller-owned work allocator
Prevent concurrent LLM session stomping
Architecture / structural design
OpenAI Codex client / workflow session surface
Concurrent session safety
Workflow or session contamination incident
MCP control-plane coordination and allocation authority
MCP operational dashboard/queue view
Internal coordination storage (SQLite/Postgres)
Design / investigation, no implementation
Docs / runbooks
New feature or improvement
Gitea MCP workflow
GlitchTip integration
Operational or process incident requiring durable audit trail
Sentry-to-Gitea incident bridging
Integration testing
Jenkins integration
Label taxonomy management
Lease adopt/release/expire lifecycle
MCP server / tooling
MCP namespace and runtime health
MCP menu surface
Work spanning multiple monitoring projects or Gitea repos
Mutating action; requires gating
Observability, metrics, traces, error reporting
Cross-platform / portability
Shared preflight gates before mutation
Protected branch / stable-branch policy concern
Work queue visibility and allocation
Read-only, no mutation
MCP client reconnect/reload recovery path
Recovery paths for stale/foreign leases
Code refactor / restructure
Release / versioning
Reliability / failure handling
Persist and resume prepared review verdicts across sessions
Reviewer workflow tooling
Roadmap / umbrella issue
Safety rails and fail-closed mutation guards
Security / trust boundary
Self-hosted infrastructure integration
Sentry error monitoring integration
Stale backend daemon / runtime-vs-master parity failures
Issue is blocked
Issue is being worked on
Issue has an open pull request
Issue is ready for work
Terminal review lock (#332) path
Tests / test coverage
Issue tracker hygiene / meta
Bug or defect
Feature or enhancement
Feature or enhancement
Safety gate or guardrail
Workflow state visibility for LLMs/operators
Cross-tool workflow
LLM workflow coordination hardening
LLM workflow coordination hardening
Something is not working
This issue or pull request already exists
New feature
Need some help
Something is wrong
More information is needed
This won't be fixed
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Scaled-Tech-Consulting/Gitea-Tools#659
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem statement
MCP has no visible maintenance-drain state that stops new work, defers mutations, notifies sessions, finishes critical ops, and checkpoints before restart.
Operational impact
Restarts cut mid-mutation; new work is still assigned during recovery chaos.
Scope
Implement drain protocol steps:
Non-goals
Required implementation investigation
#655 #658; allocator; mutation preflight; session registry; #628 handoffs.
Proposed implementation direction
Global
maintenance_drainflag in control-plane + MCP process; preflight hooks deny mutations; allocator returns WAIT; status tool for clients.Security / workflow-safety
Fail closed: if drain incomplete, no restart; reads redacted.
Failure behavior
Drain timeout → fail drain proof → durable incident issue.
Acceptance criteria
Required tests
Concurrent assign during drain fails; mutation fail closed; read still works.
Observability and audit
Drain enter/exit/progress events.
Dependencies
Rollout
Dogfood on Gitea-Tools MCP namespaces first.
Canonical issue state
Required proof
Code + tests + drain status sample.
Required final response and handoff
Brief PR → reviewer.
Issue claim heartbeat
Canonical Issue State
STATE: PR-open
WHO_IS_NEXT: author
NEXT_ACTION: Address the three blockers recorded in review 611 on PR #907, then hand back for re-review.
NEXT_PROMPT:
WHAT_HAPPENED: PR #907 for this issue received its first formal review decision — REQUEST_CHANGES, recorded server-side as review 611 at head
f0c6255d7dby sysadmin under profile prgs-reviewer. The full findings, per-blocker evidence, and the author remediation prompt are in that review body on PR #907.WHY: AC3 of this issue promises a defined set of quiesce operations keeps working while draining, so in-flight sessions can finish and hand their claims back before a restart. As implemented the allowlist cannot deliver that: nine of its eleven entries name strings the chokepoint never receives, and the one entry corresponding to a real gated call — the reviewer lease heartbeat — is refused because the tool passes the literal
review_pr. The observable consequence is a reviewer lease expiring during the very drain entered to avoid stranding it. AC1, AC2, AC4, AC5 and AC6 are satisfied by the current implementation; AC3 is not.ISSUE: #659
RELATED_PRS: #907
REVIEW_STATUS: REQUEST_CHANGES
MERGE_READY: false
HEAD_SHA:
f0c6255d7dBLOCKERS: B1 the drain safety allowlist is keyed on task literals the mutation chokepoint never passes, so the reviewer lease heartbeat is refused during a drain; B2 the gate's scope resolution fails open on a
_resolveexception inside a gate documented as fail-closed; B3 the allowlist test asserts the constant against itself and cannot detect B1.VALIDATION: Static review at head
f0c6255d7dagainst base branch master. The head advanced from77d808e7d4during the review cycle by a base-integration commit only (first parent77d808e7, second parent masterd7ad2838ec);maintenance_drain.py,tests/test_maintenance_drain.py,allocator_service.pyandcontrol_plane_db.pyare byte-identical across that advance, and every cited line ingitea_mcp_server.pywas re-read atf0c6255d. Author changes to the feature during validation: none. No test suite was executed at this head in this session and none is claimed.LAST_UPDATED_BY: sysadmin (prgs-reviewer)
NATIVE_REVIEW_PROOF: gitea_submit_pr_review via native MCP namespace gitea-reviewer, profile prgs-reviewer, identity sysadmin, expected_head_sha
f0c6255d7d, server-side review id 611. This issue comment was posted via gitea_create_issue_comment on the same native namespace. No offline, import, or helper path was used.[THREAD STATE LEDGER]
what is true now
Issue #659 is open with PR #907 open against master at head
f0c6255d7d.Server-side decision state: review 611, REQUEST_CHANGES, recorded at the current head and not stale; it is the first review decision of any kind on PR #907.
Local verdict/state: REQUEST_CHANGES, three blockers, verified statically against the live head.
what changed
The review verdict for this issue's PR moved from a locally-held result carried across earlier sessions to a recorded server-side decision. The PR head advanced from
77d808e7tof0c6255dduring that interval by a base-integration commit only; the blocker evidence was re-verified atf0c6255dbefore the verdict was recorded.what is blocked
Blocker classification: code blocker
B1 —
maintenance_drain.py:59-77allowlists eleven task names, but the gate atgitea_mcp_server.py:2029compares them against the literal passed toverify_preflight_purity. Two entries name nothing in the tree, seven name tools that never call the chokepoint, one (post_heartbeat) matches correctly, andgitea_heartbeat_reviewer_pr_leasereaches it asreview_pr(line 15493) and is deferred. B2 —gitea_mcp_server.py:2032-2035degrades to scope("", "")on any_resolveexception and permits the mutation, contradicting the fail-closed contract stated at lines 2022-2023. B3 —tests/test_maintenance_drain.py:43-54asserts allowlist membership using the allowlist's own constants and cannot fail while B1 is present.who/what acts next
Next actor: author
Required action: Give the reviewer lease-lifecycle calls a task literal distinct from
review_prand key the allowlist on it; reconcile or drop the allowlist entries that name ungated tools or nonexistent symbols; make the gate's scope-resolution failure raise instead of defaulting to an empty scope; replace the tautological allowlist test with one driving real task literals, plus a regression test per blocker.Do not do: Do not resolve B1 by adding
review_prto the allowlist — that literal is shared with review-verdict submission, which must stay deferred during a drain, so that change would open a hole rather than close one.