Skip to content

pr_review_context uses SessionIDFromContext for an overlay session id, bypassing the cohort accessor #708

Closed

Description

@zzet

PR #649 split overlay-cohort identity out of the universal session identity: WithOverlayCohortID / OverlayCohortIDFromContext is the accessor every overlay-scoped call site is meant to use, while SessionIDFromContext stays the caller's real transport session for policy, token stats, notes, diagnostics and the rest.

internal/mcp/tools_pr_review_context.go:451 was missed by that sweep:

sessionID := strings.TrimSpace(req.GetString("session_id", ""))
if sessionID == "" {
    sessionID = SessionIDFromContext(ctx)
}

The value is explicitly an overlay session — the surrounding code feeds it to simulate_chain and the skip message reads "pass an explicit session_id (an overlay session)".

Consequence is small and in the safe direction: the fallback picks the caller's real session rather than the requested cohort, so a caller setting X-Gortex-Overlay-Session finds the review's simulation section reading the wrong (their own) overlay scope instead of the one they asked for. No cross-session exposure — the conservative identity is the one it lands on.

Fix is a one-line swap to OverlayCohortIDFromContext(ctx), which falls back to SessionIDFromContext when no cohort override is set, so the no-header behaviour is byte-identical.

Worth a quick audit of the other SessionIDFromContext consumers at the same time to confirm the remaining ones are all genuinely non-overlay. I walked them while reviewing #649 and they looked right (sessionFor, tokenStatsFor, agent registry, diagnostics / health / readiness / stale-refs subscriptions, query log, notes, tools_llm, tools_proxy), but a second pass on a file that already slipped through is cheap.

Activity

  1. added
    bugSomething isn't working
    mcpMCP tool surface, schemas, facade and errors
    help wantedExtra attention is needed
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is neededmcpMCP tool surface, schemas, facade and errors

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions