fix(runtime): recognize client identity environment and refresh worker registrations #975
Closed
opened 2026-07-29 19:42:27 -05:00 by jcwalker3
·
1 comment
No Branch/Tag Specified
master
feat/issue-978-instance-fleet-snapshot
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
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
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Scaled-Tech-Consulting/Gitea-Tools#975
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.
Related: #963 (blocked by this), #948 (closed, introduced the incomplete lifecycle), #949, #969, #887, #929
Problem
Two defects in the #948 client/session ownership lifecycle make sanctioned
multi-client operation impossible. They are inseparable: fixing either alone
still leaves the four-client canary unable to run, and the second cannot even be
authored while the first stands.
1. Production client-identity environment keys are not recognized
gitea_mcp_server.pyreads three environment variables as the authoritativeclient-identity inputs for worker registration:
None of the three is present in
gitea_config.RECOGNIZED_GITEA_ENV_KEYS, andnone matches
RECOGNIZED_GITEA_ENV_PREFIXES. The runtime diagnostic scans everypeer
mcp_server.pyprocess environment and classifies any unlistedGITEA_*key as an unsupported override. That reason is then raised as a runtime blocker,
so
gitea_resolve_task_capabilityreturns:The capability resolver is the mandatory preflight for every author, reviewer,
and merger mutation, so setting the very variable #948 requires for client
identity closes the mutation gate for the whole fleet. The refusal is also
misdiagnosed as a staleness problem: reconnecting cannot clear it, because the
variable is re-exported from the client's server definition on every launch. It
was reached with the server in full parity (
in_parity: true,stale: false,mutation_safe: true).A second, smaller inconsistency in the same path: the diagnostic reasons are
raised as a
RuntimeErrorthat is re-raised only when the message contains"stale-runtime:", so anunsupported-env:reason is silently swallowed on thatbranch while still failing the resolver.
2.
WorkerRegistry.heartbeat()has no production callerWorkerRegistry.heartbeat()was delivered by #948 but is called only fromtests/test_issue_948_client_session_provenance.py. The single production writerregisters exactly once per process, behind a module-level attempted-once flag,
and
register()stamps the same timestamp into bothstarted_atandlast_heartbeat_at. Nothing ever advances the heartbeat afterwards: there is nolifespan hook, no background task, and no
atexithandler in the server process,which blocks in
mcp.run(...)until exit.Liveness is computed as
age = now - last_heartbeat_atagainstheartbeat_ttl_seconds(900.0). Soheartbeat_ttl_secondsis not a livenesswindow at all in production — it is a hard cap on how long any client may remain
attached. At 900 seconds a completely healthy, connected, client-managed process
becomes:
and can no longer perform sanctioned mutations.
Observed evidence
Read from a live, healthy, client-managed author namespace at control revision
324a0c8a8d76137b8466fe621b983c6ccf135be6:The identical timestamps are the defect for every production worker row, not a
property of this one process.
Required behavior
Environment recognition
GITEA_MCP_CLIENT,GITEA_MCP_CLIENT_INSTANCE, andGITEA_MCP_CLIENT_SESSIONto the authoritative recognized-key set, so thekeys production consumes are the keys the gate accepts.
GITEA_*acceptance. An unrecognized override must still be refused exactly as it is
today.
Heartbeat lifecycle
not create a second registration or a second worker-identity system.
remains healthy, at an interval safely below
heartbeat_ttl_seconds.identity, session id, generation id, and process identity. One worker can never
refresh another worker's row, and a superseded or fenced session can never
renew its way back into ownership.
separate clients, and separate legitimate applications stay distinct.
fail safely: a failure never grants ownership and never crashes a tool call.
behavior. No mutation that is refused today becomes permitted.
Acceptance criteria
set, individually asserted.
GITEA_*variable is still reported as an unsupported override.blocker_kind=runtime_reconnect_requiredon a server that is otherwise inparity.
session_ownership: ownedbeyond twocomplete TTL periods of simulated time.
last_heartbeat_atadvances while the worker stays healthy, and diverges fromstarted_at.other's rows.
Non-goals
Duplicate verdict
NOT a duplicate. Verified by reading the bodies and acceptance criteria of #949,
#963, #969, #890, #900, #689, and #950, and the full open-issue list.
WorkerRegistry.heartbeat()with no production caller. This issue is the regression that omission left behind; a closed issue cannot own the repair.Canonical issue state
Issue claim heartbeat
b0868be6b3