Repository navigation
Refuse an ended session in words true of it - #1484
Merged
Merged
Conversation
On --stateless=false the gate answers 404 to a request whose session ID names no session open for the presented credential, and it said "This session does not belong to the presented credential." That is true of a session another credential opened and false of the commoner case, a client's own session that idled out, was deleted, went with its credential's pool entry, or was opened before a restart or on another replica: nothing that client presented belongs to anybody else. The refusal now says "This session is not open for the presented credential. Start a new session by sending initialize without a session ID.", which is true of both. Answering the two apart would tell a caller whether another credential holds the ID, which INV-019 forbids, and would need a record of each credential's ended session IDs, keyed on a value the caller mints. The log tells them apart instead: the WARN line for another credential's session stays, and an ID the process does not hold gets an INFO line of its own, throttled like the gates' other refusal lines. Row ADM-007 moves with the gate: its resource names both cases, its refusal the new words, and it records issue 1102's decision. The unit pins and the e2e phrase the go-sdk client pins expect follow it.
The HTTP module opens a stateful session, presents its ID under another credential and presents an ID no session was opened under with the owner's own, which is the state an idle timeout, an eviction or a restart leaves. Both are answered with the same bytes, a 404 carrying -32600 and the one sentence, and the server's log carries the WARN line for the first and the INFO line for the second.
Row 68 of the upstream register quotes the gate's new words and no longer says the call path shows the wrong cause: what a go-sdk client is left with there is a refusal on a connection that looks alive, with an error that does not wrap ErrSessionMissing. The HTTP server page, in English and Spanish, says the 404 answers another credential's session and an ended one alike, why, and which log line names each, and its refusal table names that row's condition as ADM-007 does, an ID that names no session open for the presented credential, rather than one the deployment did not open, which is false of a client's own ended session.
The two lines that describe mcpServerGate.resolve had drifted above the Mcp-Session-Id header constant, so godoc read them as part of the constant's comment and resolve had none. They sit on resolve again.
There was a problem hiding this comment.
jmrplens has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #1102.
This is the fifth layer of the authentication-budget stack, on top of the discovery documents' bucket of #1053. It changes the words of the gate's session refusal and nothing about when it refuses, as the decision of 2026-10-17 on the issue set out: one answer for both cases, no record of each credential's ended session IDs, an INFO line of its own for a session the process does not hold, and the WARN line for another credential's session kept.
What was wrong
On
--stateless=falsethe gate answers404to a request whoseMcp-Session-Idnames no session open for the credential it presents, and the answer said "This session does not belong to the presented credential." That is true of a session another credential opened. It is false of the case a client meets every day, its own session that idled out past--session-timeout, was deleted, went with its credential's pool entry, or was opened before a restart or on another replica: nothing that client presented belongs to anybody else, and the message told it otherwise. Row ADM-007 of the tenant policy register described only the first case too.What changed
sessionOwnershipFailureincmd/server/auth_gate.gonow answers "This session is not open for the presented credential. Start a new session by sending initialize without a session ID.", which is true of both cases. The status, the code (-32600) and when it is answered are unchanged. I kept one answer rather than two because answering the cases apart would tell a caller whether another credential holds the ID, which INV-019 forbids, and because it would need a record of each credential's ended session IDs, state keyed on a value the caller mints, with a row and a capacity of its own.checkSessionOwnershiptells the cases apart in the log instead. Another credential's session keeps its WARN line,request rejected: session ID does not belong to the presented credential, word for word, since it is true of that case and an operator may already alert on it. An ID the process does not hold gets an INFO line,request rejected: session ID names no session open in this process, through the same once-a-minute throttle as the gates' other refusal lines, since a caller can send any ID it likes. Neither names the ID.Row ADM-007 in
internal/tenancy/decisions_admit.gomoves with the gate: its resource is now "a session ID that names no session open for the presented credential", its refusal prefix is the new first sentence, and it records issue 1102's decision. It stays a rule with no value, no table and no capacity, which is the half of the decision a test holds it to.The e2e phrase the go-sdk client pins expect (
test/e2e/http/session_not_found_test.go) and row 68 ofdocs/development/upstream-bugs.mdquote the new words. Row 68 no longer says the call path shows the wrong cause; what a go-sdk v1.8.0 client is left with there is a true refusal on a connection that looks alive, with an error that does not wrapErrSessionMissing. The HTTP server page, in English and Spanish, says the404answers both cases alike, why, and which log line names each, and its refusal table now names that row's condition as ADM-007 does, "anMcp-Session-Idthat names no session open for the presented credential", where it said one "this deployment did not open", which is false of the client's own session that ended.A last commit puts
resolve's doc comment back onresolve. It had drifted above theMcp-Session-Idheader constant beside the check this changes, so godoc read it as part of the constant's comment andresolvehad none.How I tested it
Tests first, each shown red on the parent as it stood before the stack was rebased onto
main(3df394937, nowb37e82899) and green on this branch:TestDecisions_EachRowIsWhatTheSpecificationSays/ADM-007pins the new prefix, andTestDecisions_SessionRefusal_IsOneAnswerByIssue1102pins the resource, the recorded decision, the absence of any value, table or capacity, and the one refusal.TestMcpServerGate_CheckSessionOwnership_RefusesASessionFromAnotherCredentialnow holds every refusal (another credential's session, an ID never recorded, a session whose credential was evicted) to the same code and the same full text, and asserts the log: the WARN line for the first, the INFO line for the other two, and neither for a request the check lets through. On the parent the text differed and the INFO line was missing.TestMCPServerGate_EachRefusal_CarriesItsOwnStatusAndCodedrives a real foreign session (its old case was in fact an unrecorded ID) and an unrecorded one through the middleware. Since both are answered alike, each also asserts the line the session check logged, WARN for the foreign session and INFO for the unrecorded one, and every other case that it logged neither; without that, a foreign session whose ID was never recorded passes as one, which is how the old case went unnoticed. I checked that both ways: with the foreign case's ID swapped for an unrecorded one, the table without the log assertion still passes and this one fails on the log line.TestMcpServerGate_Middleware_RefusesASessionMintedForAnotherCredentialholds POST, GET and DELETE to the full text.TestGate_SessionRefusal_IsOneAnswerOnTheWireAndTwoLinesInTheLogintest/e2e/httpdrives the binary: another credential's session and an ID the process does not hold are answered with byte-identical bodies, and the server's stderr carries the WARN line for the first and the INFO line for the second. The two go-sdk pins of row 68 pass with the new phrase.Results on this branch:
go test ./internal/tenancy/... ./cmd/server/... ./cmd/audit_tenancy/...passes;make check-tenancyreports 0 findings over 89 rows;make test-e2e-httppasses, 708 tests with 8 skipped for want of Docker; statement coverage is 100.0% forcmd/serverandinternal/tenancy; gobco conditions are 2356/2356 forcmd/serverand 454/454 forinternal/tenancy;make coverage-mutantsover the whole of each package, no file excluded, reports Lived 0 and Timed out 0 oncmd/server(1301 killed, the five incheckSessionOwnershipamong them, in 3 hours 7 minutes) and oninternal/tenancy(255 killed). The 47 and 66 it calls not covered are the tool artifactdocs/development/testing/README.mddescribes, mutations in package-level constant and variable initializers, which carry no statement counter (the gate's error codes and message concatenations, the HTTP timeouts and other durations, the env flag names, the listen endings' and subscription errors' texts, the register's codes, values andiotaenumerations), plus two insocket_mode_windows.goandconn_refused_windows.go, which are not compiled on Linux; none is on a line this branch touches;golangci-lintis clean on both packages undere2eand ontest/e2e/httpunderhttpe2e;go test -tags e2e -ccompilestest/e2e/gitlab/...;make check-test-subtests,check-test-goroutines,check-test-file-names,check-action-ids,check-dead-consts,check-doc-tool-names,check-md-escapingandcheck-e2e-staticand the godoc audit pass; markdownlint, the Markdown table check, the doc link check, and the site's i18n, facts, chips, llms, build and lint checks pass.I then rebased the stack onto
mainata0e4e6cf6, with no conflict and every commit's patch unchanged, so the results above were measured on the branch as it stood on19746966465. Of the packages this layer touches,mainmovedcmd/serverin two test files (#1472). At this headgo build ./...,go vet,golangci-lint --build-tags e2eandgo testoncmd/serverandinternal/tenancypass, each still at 100.0% of statements, and so do the tests ofcmd/audit_tenancy, also at 100.0%;make check-tenancystill reports 0 findings over 89 rows;make test-e2e-httppasses with the same 708 tests; andmake check-closed-serversandmake check-godocs, the two gatesmaingained since (#1474, #1478), pass. The gobco figures count the conditions of codemaindid not change, so they stand; I did not repeat the three-hour mutation run.Tenant policy checklist
This changes a refusal's text and a row's resource, not a limit. VAL-001 to VAL-006, VAL-008, VAL-009 and VAL-011 are unchanged on ADM-007 (Admit, keyed on the session, class C, a rule, nothing kept, not charged, no value, none on stdio). VAL-007 is the change: the gate's
404with-32600, noRetry-Afterand no challenge, answer "start over", now in words true of both cases. VAL-010: with telemetry on, the new INFO line is exported as a log record, as the WARN line beside it already is; it carries no attribute but the throttle's count of repeats it held back, so it names no session ID and no credential, and no metric, span or reason changes. VAL-012 does not apply, since nothing here protects one population from another.The generated testing reference gains the new tests' entries when the top of the stack regenerates it, as the stack's other layers leave theirs.