Make MCP runtime generation ownership client/session-aware so multiple LLMs can work concurrently #948
Closed
opened 2026-07-27 03:44:40 -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
No labels
type:feature
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#948
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
The control plane currently treats legitimate MCP generations launched by different active LLM clients as globally conflicting duplicates. Claude, Codex, Gemini, Grok, Antigravity, or other clients cannot simultaneously use the control plane, even when they are working on different issues.
The global “exactly one MCP generation” mutation gate is the defect. Concurrency ownership should be scoped to authenticated client/session/generation identity, while issue ownership should be enforced independently through atomic leases, heartbeats, expiration, and fencing.
Required behavior
Do not prematurely require either a shared fleet or one fleet per client. The implementation may choose the repository-appropriate architecture, but it must satisfy the behavioral contract.
Acceptance criteria
client_instance_id.session_id.generation_idor boot epoch.work_issueatomically acquires an issue lease; no operator assignment step is required.REQUEST_CHANGESprevents merging.worker_identityis independent of role and profile. Neither a role nor a profile is ever used as, or derived into, the unique identity of a worker.worker_identity.<llm-name>-<UTC-timestamp>-<short-sha>.sha256(llm_name + session_id + timestamp_ns + random_nonce)— or an equivalently collision-resistant construction.worker_identitythat is already active fails closed, without replacing, adopting, merging with, or corrupting the existing worker registration.worker_identity.worker_identityis unique.worker_identityor generation.worker_identityfrom valid concurrent workers holding different identities under the same role/profile.Identity invariants
Roles and profiles remain reusable capability definitions, not singleton worker identities:
Criteria 26–44 and these invariants are recorded from scope-clarification comment 17651.
Non-goals and prohibited fixes
P0 scope clarification: worker identity collision handling
This issue is the top-priority concurrency blocker limiting how many independent LLM workers can operate simultaneously.
Please make the following requirements explicit in the implementation and acceptance criteria:
worker_identitymust remain independent of role and profile.Each LLM instance must establish a collision-resistant identity, for example:
<llm-name>-<UTC-timestamp>-<short-sha>The digest should incorporate sufficient entropy, such as:
sha256(llm_name + session_id + timestamp_ns + random_nonce)Worker registration must be atomic.
A registration collision must be detected and rejected without replacing, adopting, or corrupting the existing worker.
After a collision, the new worker must generate and atomically register a different identity.
A restarted worker must receive a new identity and must not silently inherit the previous worker's leases or fencing tokens.
Automated tests must deliberately force an identity collision and verify safe regeneration and registration.
Roles and profiles must remain reusable capability definitions:
UNIQUE: worker_identityNOT UNIQUE: roleNOT UNIQUE: profileEXCLUSIVE: active lease targetMultiple healthy workers sharing the same role/profile must never trigger a profile-wide duplicate-process or stale-runtime block.
Required issue reconciliation
Issue #900 appears to require one eligible runtime cohort per profile. That requirement conflicts with #948 if "cohort" or profile eligibility permits only one LLM worker.
Implementation of #948 must explicitly reconcile #900 so that lifecycle supervision may detect abandoned or superseded instances without terminating or blocking legitimate, independently identified workers sharing the same profile.
Issue #686 should also be revisited because its duplicate-role-server guardrail must distinguish:
Killing every additional process using a shared profile is not an acceptable resolution.
Canonical Issue State
STATE: ready
WHO_IS_NEXT: author
NEXT_ACTION: Amend the #948 acceptance criteria to add the ten worker-identity collision requirements above as explicit numbered criteria, add the forced-collision regression test to AC25, and record the #900 and #686 reconciliation decisions in the issue body before implementation starts.
NEXT_PROMPT:
WHAT_HAPPENED: A duplicate-issue scan for a proposed new P0 issue titled "Support concurrent per-LLM workers independently of shared roles and profiles" found #948 already covers that architectural defect. No duplicate issue was created. This comment records the one requirement gap found during that comparison plus two cross-issue conflicts.
WHY: #948 AC1 requires a stable, non-LLM-forgeable client identity but never states what happens when registration collides. Without an explicit collision requirement an implementation may satisfy AC1 by adopting or overwriting an existing registration, which silently transfers ownership and defeats the lease and fencing guarantees in AC10, AC14, and AC16. #900 and #686 are named because both encode the one-worker-per-profile assumption that #948 exists to remove; leaving them unreconciled would let a correct #948 implementation be reverted by the guardrails that remain.
RELATED_PRS: none
BLOCKERS: none
VALIDATION: Live state re-read at comment time. #948 open, labels status:ready and type:feature, comment thread empty before this comment. Native duplicate scan over all open issues and 120 closed issues found no equivalent clarification. Related issues confirmed open: #900, #887, #937, #797. Related issues confirmed closed: #686, #613. Runtime parity verified in agreement at
ed9414ebdawith live_stale false, mutation_safe true, restart_required false. No code, branch, commit, or pull request was produced by this task.LAST_UPDATED_BY: jcwalker3 (prgs-author)
Author handoff: implementation pushed, PR #968 open
Root cause
Two surfaces computed provenance independently and disagreed about one process.
gitea_get_runtime_contextread the liveos.environand reportedclient_managed.mcp_namespace_health.classify_namespace_probederived the flag from_safe_env_summary(process), whoseSAFE_ENV_KEYSallowlist carries onlyGITEA_MCP_PROFILE,GITEA_PROFILE_NAME,GITEA_SERVICE,GITEA_EXECUTION_ROLE,GITEA_MCP_CONFIG— and none of the three provenance keys it then looked up. Those lookups could only returnNone, so that surface was structurally incapable of reporting anything butmanual_launchfor any process. An allowlist for deciding what may be echoed was deciding what may be believed.Underneath, neither model could name which client or session owned a runtime. Ownership was inferred from a process environment flag the launcher sets once, which says nothing about who owns the process now — so a healthy daemon serving a second client could not be told apart from a duplicate, and the cohort scan walled every process sharing a profile.
Authoritative provenance model
mcp_worker_identity.pyis the single authority for runtime context, namespace health, namespace attachment, the fleet/cohort scan, capability resolution, and typed reconnect assessment. It splits two claims the old code ran together:is_client_managedstays bound to the launch dimension, so unification changes which code decides, not what gets decided. Invariants:UNIQUE worker_identity,NOT UNIQUE role,NOT UNIQUE profile,EXCLUSIVE active lease target. Identity collision fails closed and never adopts the incumbent; a generation held by a live session cannot be claimed twice; a non-live claimant is superseded with a higher fencing epoch; liveness is heartbeat freshness, not PID comparison. Missing proof reportsunprovenrather than assertingmanual_launch, and both fail closed.Also closed: reconnect guidance no longer defaults to Codex (
DEFAULT_CLIENTbecomesgeneric, client resolved from the attachment record), andresolve_bound_remotekeeps a PRGS-bound namespace off thedadeschoolslibrary default.Files changed
mcp_worker_identity.py(new) ·gitea_mcp_server.py·mcp_namespace_health.py·mcp_client_reconnect.py·tests/test_issue_948_client_session_provenance.py(new) ·tests/test_issue_686_manual_mcp_provenance.py·docs/remote-mcp/threat-model.md·docs/remote-mcp/threat-model-anchors.jsonTests and results
pytest tests/test_issue_948_client_session_provenance.py— 43 passedbranches/worktree,-p no:randomly: head 28F/5953P/6S vs merge base8eada1fb28F/5910P/6S;diffof failing-ID sets is empty, so the 28 are pre-existing by merge-base evidence, not assumption.Head and deployment
Complete head SHA:
fa510dd28dd5f9ca4f81e5b3048ceab584f0b7d7(local,git ls-remote, and PR #968 agree). Serving daemons run the code from their boot commit, so the new surfaces appear only after the control checkout advances and the operator reconnects the MCP namespaces. No process kill, restart loop, raw API call, fallback transport, or configuration edit is required or was performed.Scope note
This delivers the provenance model and the surfaces named above. Issue-lease acquisition via
work_issue(AC9-AC16) and the merge-gate criteria (AC19-AC21) build on this model and are not in this change. Boundary with #934: that child defines provenance for a remote non-stdio transport and waits on #931/#932; this change governs the local stdio fleet and leaves every stdio guard in force.[THREAD STATE LEDGER]
What is true now: PR #968 is open against master at head
fa510dd28dd5f9ca4f81e5b3048ceab584f0b7d7, mergeable, authored by jcwalker3 under prgs-author. Issue #948 carriesstatus:pr-open. No review verdict exists on PR #968 yet.What changed: Two commits were pushed to
feat/issue-948-client-session-provenance— the implementation plus a restamp of the #956 threat-model anchors onto the commit whose line numbers they resolve at. Gitea server-side state changed: PR #968 was created and the issue label set moved tostatus:pr-open.What is blocked: Nothing. Blocker classification: no blocker.
Who/what acts next: An independent reviewer, because the author of this change must not review or merge it.
fa510dd28dd5f9ca4f81e5b3048ceab584f0b7d7and post a formal verdict through the reviewer namespace.status:pr-open. No merge performed. No MCP configuration, session-state file, credential, or runtime process was altered.Do not do: Do not review or merge PR #968 from the author namespace — the author of a change must not be its reviewer or merger. Do not re-open a second issue or branch for #948;
feat/issue-948-client-session-provenanceis the canonical branch and #968 the canonical PR. Do not kill MCP processes, run a restart loop, edit MCP configuration,.env, or session-state files, or reach for a raw Gitea API or fallback transport to work around a gate. Do not classify any of the 28 full-suite failures as introduced by this branch — compare failing IDs against the merge-base run, never counts. Do not treat a process environment flag as proof of session ownership when reviewing the model.Canonical Issue State
STATE: pr-open
WHO_IS_NEXT: reviewer
NEXT_ACTION: Review PR #968 at head
fa510dd28dagainst the #948 acceptance criteria for the provenance model, and post a formal verdict from the gitea-reviewer namespace.NEXT_PROMPT:
WHAT_HAPPENED: Implemented the client/session-aware provenance model for #948 on branch
feat/issue-948-client-session-provenance, pushed two commits, and opened PR #968. The root cause was reproduced from source:SAFE_ENV_KEYSomits every provenance key thatclassify_namespace_probelooked up in the summary it produces, so that surface could never reportclient_managed, whilegitea_get_runtime_contextread the live environment and did. Both surfaces now call one authority. Hardcodedclient='codex'remediation and thedadeschoolsdefault-remote fallback were also removed.WHY: #948 AC1-AC8, AC17, AC22-AC23, AC26-AC44 require one non-forgeable client/session/generation ownership model that no environment flag alone can satisfy, with refusals scoped to a worker identity rather than a profile. The two divergent implementations made agreement impossible by construction, so a shared authority had to exist before any of the ownership criteria could hold. AC42/AC43 reconciliation with #900 and #686 is served by proving distinctness from identity evidence instead of assuming duplication from a shared profile.
RELATED_PRS: #968
BLOCKERS: none
VALIDATION: Preflight verified natively before every mutation — gitea_whoami (jcwalker3, prgs-author, role author, remote prgs, host gitea.prgs.cc) then gitea_resolve_task_capability for the exact task key, with nothing between. Runtime parity in agreement at
8eada1fbe4with live_stale false, mutation_safe true, restart_required false. Author capability resolved with stop_required false and restart_required false, so the provenance gate did not block the author path. Full suite run from a branches/ worktree at head and at merge base with identical failing-ID sets (28 each). Remote head confirmed by git ls-remote and by gitea_view_pr. Worktree clean at handoff.LAST_UPDATED_BY: jcwalker3 (prgs-author)