Skip to content

fix(#9962,#9960): every list queries entry names its client; MCP and Gremlin Server name the leader of a refusal - #9980

Merged
lvca merged 6 commits into
mainfrom
fix/9962-9960-mcp-gremlin-client-and-leader
Oct 14, 2026
Merged

lvca merged 6 commits into
mainfrom
fix/9962-9960-mcp-gremlin-client-and-leader

Conversation

@lvca

@lvca lvca commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #9962
Fixes #9960

#9962 - every list queries entry names its client

The issue proposed one more setConnection line per surface. That keeps recording the client a separate, forgettable step, which is exactly how three surfaces missed it. Instead:

  • RunningQueryRegistry.register(...) / open(...) take a RunningQuery.Client (connection id + address) as part of opening the entry, and set it before the entry is listed (a listing can no longer see an entry without its client). One value rather than two more positional strings, so it cannot be swapped with the session id or tag; Client.NONE for work from no connection, Client.of(id, SocketAddress) for a socket peer (a peer the transport does not report is omitted, never listed as "null"). The setter is package-private, so the registry is the only path. A ninth surface cannot compile without deciding who its client is.
  • Surfaces that recorded nothing now do:
    • MCP: peer address on the HTTP transport, stdio on the stdio one. Passed per message (dispatch(request, user, client)), not as a dispatcher field, because one HTTP dispatcher serves every client of the endpoint.
    • /ws insert: session id as connectionId and the WebSocket peer as address, in every transaction mode (not only none).
    • Gremlin Server: channel id + peer address. TinkerPop's RequestMessage carries no channel, so ConcealingWebSocketChannelizer publishes the connection on the Netty thread around the read that submits the evaluation (relying on TinkerPop 3.8 submitting from inside that read, documented at the handler); GremlinPrincipalPropagatingExecutorService carries it to the pool thread in the same holder.
    • gRPC (missed by the issue's census): unary RPCs and the four client-streaming loads (StreamingLoadEntry, via a Context key set by GrpcAdmissionInterceptor) listed no client either.
  • HTTP, Postgres, Bolt, Redis and MongoDB moved to the new signature, with no change in behaviour.

#9960 - MCP and the Gremlin Server name the leader of a refusal

  • ServerIsNotTheLeaderException.withLeaderSentence(text, error) is the shared arm (redirectIn + leaderSentence). Redis and Postgres now delegate to it instead of carrying their own copy.
  • MCP: failureMessage appends the sentence after concealment, in both modes. A production tool error now reads <placeholder>. The leader is server 'host:port' instead of the bare placeholder.
  • Gremlin Server: by the time the answer reaches the pipeline the exception object is gone, but TinkerPop attaches the class name of every throwable in the chain. A refusal is recognised from that list, and the leader of this server's cluster view (the same view the refusal reads when it is raised) is named after the message, or after the placeholder in production. The sentence says it is the HTTP address, since the Gremlin port differs.

Not changed: Database.transaction still retries a leader refusal txRetries times before answering. This applies to every transport (HTTP's auto-retry too), not only MCP, and a retry can succeed when the refusal came from a transiently failed forward. Changing it is an engine-wide HA semantics decision, so it is out of scope here.

Tests

  • New: Issue9962MCPClientListedTest (HTTP + stdio, end to end), Issue9962GremlinRequestClientTest, Issue9960MCPLeaderRefusalTest, Issue9960GremlinLeaderRefusalTest, ExceptionTest.withLeaderSentenceNamesTheLeaderOnlyForARedirect
  • Client assertions added to Issue9689GremlinTerminateTest (Gremlin Server end to end), Issue9838WsInsertSessionListedInEveryModeTest, Issue9689GrpcRunningQueryIT, Issue9875GrpcStreamingLoadsListedIT, Issue9689RunningQueryFollowUpsTest
  • Run green: engine/network/server/mcp/redisw/postgresw/mongodbw related tests (22 classes), Gremlin via gremlin-it (5 classes), ITs Issue9689GrpcRunningQueryIT, Issue9875GrpcStreamingLoadsListedIT, Issue9689BoltTerminateTransactionsIT, Issue9689PostgresCancelIT

Summary by CodeRabbit

  • New Features
    • Running-query details now include the client connection ID and address across supported protocols, available as soon as a request is listed. Requests without a client address no longer display the literal text “null”; MCP stdio requests are identified as stdio.
    • Leader-refusal responses can include guidance pointing to the current leader, with addresses sanitized for safe display. This guidance is available in Gremlin and MCP responses, including concealed production errors.

…and the Gremlin Server name the leader of a refusal

#9962: RunningQueryRegistry.register/open now take the client (connectionId, clientAddress) as part of opening the
entry, set before it is listed; RunningQuery.setConnection is package-private. The surfaces that recorded no client
now do: MCP (peer address over HTTP, "stdio" over stdio, passed per message), the /ws insert session (session id and
WebSocket peer, in every transaction mode), the Gremlin Server (channel id and peer, published by the channelizer
around the read that submits the evaluation) and gRPC (unary RPCs and the client-streaming loads, which the issue's
census missed).

#9960: ServerIsNotTheLeaderException.withLeaderSentence is the shared arm (Redis and Postgres delegate to it). MCP
appends the leader sentence to a tool error after concealment; the Gremlin Server recognises a refusal by the
exception classes TinkerPop attaches and names the leader of the cluster view, after the placeholder in production.
@lvca lvca added this to the 26.11.1 milestone Oct 13, 2026
@lvca lvca self-assigned this Oct 13, 2026
@mergify

mergify Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@codacy-production

codacy-production Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 22 complexity

Metric Results
Complexity 22

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc403434-0f50-4404-ae76-caf5b6a68319
📥 Commits

Reviewing files that changed from the base of the PR and between 46a50b2 and 230fa02.

📒 Files selected for processing: 26
  • bolt/src/main/java/com/arcadedb/bolt/BoltNetworkExecutor.java
  • engine/src/main/java/com/arcadedb/query/RunningQuery.java
  • engine/src/main/java/com/arcadedb/query/RunningQueryRegistry.java
  • engine/src/test/java/com/arcadedb/function/sql/fulltext/Issue9894SearchIndexCancellationTest.java
  • engine/src/test/java/com/arcadedb/index/vector/Issue9896VectorSearchCancellationTest.java
  • engine/src/test/java/com/arcadedb/query/Issue9680RunningQueryTerminationTest.java
  • engine/src/test/java/com/arcadedb/query/Issue9689RunningQueryFollowUpsTest.java
  • engine/src/test/java/com/arcadedb/query/sql/executor/Issue9893IndexReplayCancellationTest.java
  • gremlin/src/main/java/com/arcadedb/server/gremlin/ArcadeGraphManager.java
  • gremlin/src/main/java/com/arcadedb/server/gremlin/ConcealingWebSocketChannelizer.java
  • gremlin/src/main/java/com/arcadedb/server/gremlin/GremlinAuthContext.java
  • gremlin/src/main/java/com/arcadedb/server/gremlin/GremlinPrincipalPropagatingExecutorService.java
  • gremlin/src/test/java/com/arcadedb/server/gremlin/Issue9689GremlinTerminateTest.java
  • gremlin/src/test/java/com/arcadedb/server/gremlin/Issue9962GremlinRequestClientTest.java
  • grpcw/src/main/java/com/arcadedb/server/grpc/GrpcAdmissionInterceptor.java
  • grpcw/src/main/java/com/arcadedb/server/grpc/StreamingLoadEntry.java
  • mcp/src/main/java/com/arcadedb/mcp/MCPDispatcher.java
  • mcp/src/main/java/com/arcadedb/mcp/MCPHttpHandler.java
  • mcp/src/main/java/com/arcadedb/mcp/MCPStdioServer.java
  • mcp/src/test/java/com/arcadedb/mcp/Issue9962MCPClientListedTest.java
  • mongodbw/src/main/java/com/arcadedb/mongo/MongoDBBackend.java
  • postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java
  • redisw/src/main/java/com/arcadedb/redis/RedisNetworkExecutor.java
  • server/src/main/java/com/arcadedb/server/http/handler/AbstractServerHttpHandler.java
  • server/src/main/java/com/arcadedb/server/http/ws/insert/WebSocketInsertSession.java
  • server/src/test/java/com/arcadedb/server/AdmittedWorkIsListedTest.java

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

📝 Walkthrough

Running-query entries now receive client metadata when they are registered or opened across protocol surfaces. MCP and Gremlin error responses also add leader guidance for recognized leader refusals when a leader address is available.

Changes: Running-query client attribution

Layer / File(s) Summary
Registry client contract and tests
engine/src/main/java/com/arcadedb/query/RunningQuery.java, engine/src/main/java/com/arcadedb/query/RunningQueryRegistry.java, engine/src/test/java/com/arcadedb/..., server/src/test/java/com/arcadedb/server/AdmittedWorkIsListedTest.java
RunningQuery.Client groups a connection ID and address. register and open require a client and assign it before publishing the entry. Tests pass Client.NONE where no client applies and verify the listed fields.
Protocol adapter attribution
bolt/src/main/java/com/arcadedb/bolt/BoltNetworkExecutor.java, mongodbw/src/main/java/com/arcadedb/mongo/MongoDBBackend.java, postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java, redisw/src/main/java/com/arcadedb/redis/RedisNetworkExecutor.java, server/src/main/java/com/arcadedb/server/http/handler/AbstractServerHttpHandler.java, server/src/main/java/com/arcadedb/server/http/ws/insert/WebSocketInsertSession.java
These adapters pass available connection identifiers and peer addresses when creating running-query entries. WebSocket insert entries use the session ID and peer address when available.
gRPC, Gremlin, and MCP attribution
grpcw/src/main/java/com/arcadedb/server/grpc/*, grpcw/src/test/java/com/arcadedb/server/grpc/*, gremlin/src/main/java/com/arcadedb/server/gremlin/*, gremlin/src/test/java/com/arcadedb/server/gremlin/*, mcp/src/main/java/com/arcadedb/mcp/*, mcp/src/test/java/com/arcadedb/mcp/*
gRPC passes client details to admitted and streaming work. Gremlin publishes request client details through context and propagates them to worker threads. MCP HTTP and stdio transports pass client details through dispatch to query registration.

Leader-refusal error guidance

Layer / File(s) Summary
Shared leader-sentence formatting
network/src/main/java/com/arcadedb/network/binary/ServerIsNotTheLeaderException.java, network/src/test/java/com/arcadedb/network/binary/ExceptionTest.java, postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java, redisw/src/main/java/com/arcadedb/redis/RedisNetworkExecutor.java
The exception class adds wire-safe leader-sentence formatting and a helper that appends the sentence when a redirectable refusal appears in the error chain. PostgreSQL and Redis use the shared helper.
MCP and Gremlin responses
mcp/src/main/java/com/arcadedb/mcp/MCPDispatcher.java, mcp/src/test/java/com/arcadedb/mcp/Issue9960MCPLeaderRefusalTest.java, gremlin/src/main/java/com/arcadedb/server/gremlin/ConcealingWebSocketChannelizer.java, gremlin/src/test/java/com/arcadedb/server/gremlin/Issue9960GremlinLeaderRefusalTest.java
MCP messages and Gremlin responses append available leader guidance for recognized refusals. Tests cover production concealment, development responses, and unavailable leader addresses.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: Low

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant MCPDispatcher
  participant ServerIsNotTheLeaderException
  MCPClient->>MCPDispatcher: Send tool call
  MCPDispatcher->>ServerIsNotTheLeaderException: Format refusal error
  ServerIsNotTheLeaderException-->>MCPDispatcher: Return text with leader sentence when available
  MCPDispatcher-->>MCPClient: Return tool-call error
Loading
sequenceDiagram
  participant GremlinClient
  participant ConcealingWebSocketChannelizer
  participant HAPlugin
  GremlinClient->>ConcealingWebSocketChannelizer: Send request
  ConcealingWebSocketChannelizer->>HAPlugin: Read leader address for recognized refusal
  HAPlugin-->>ConcealingWebSocketChannelizer: Return address when available
  ConcealingWebSocketChannelizer-->>GremlinClient: Return response with applicable leader guidance
Loading

Suggested reviewers: robfrank

Merge Risk: ⚪ Minimal · up to 230fa

The identified Gremlin response concern does not affect leader-refusal results. No actionable merge-blocking issue remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 39.60% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 101 functions across 33 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes both primary changes: client details for listed queries and leader identification for MCP and Gremlin refusals.
Description check Passed The description provides detailed change context, motivation, related issues, implementation scope, tests, and reported results. It does not use every template heading or checklist item verbatim, but …
Linked Issues check Passed [#9962] RunningQueryRegistry.open requires a non-null RunningQuery.Client and sets it before map publication. The MCP HTTP and stdio paths pass per-message clients. WebSocket insert passes the ses…
Out of Scope Changes check Passed The registry API migration and protocol updates implement [#9962]. The gRPC additions extend the same client-attribution rule to running-query surfaces. The shared leader-sentence helper, Redis and Po…
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Oct 13, 2026

Copy link
Copy Markdown

Review of #9980

I read the registry, Bolt, Gremlin and test-migration parts of the diff in detail. The MCP, gRPC, /ws, Postgres, Redis and MongoDB changes I did not read closely. I did not build or run the tests.

Design

  • Moving connectionId and clientAddress into RunningQueryRegistry.register/open is a good fix. The client is set before running.put, so a listing can never see an entry without it. Making setConnection package-private means a new surface cannot forget it.
  • Sharing ServerIsNotTheLeaderException.withLeaderSentence between Redis, Postgres and MCP removes duplicated code.

Points to check

  1. Gremlin client propagation relies on handler order. RequestClientPublisher is added last in configure(), and the correctness argument is that TinkerPop's op selector is added after it and submits on the same Netty thread. That is an undocumented ordering in TinkerPop internals. Please confirm Issue9689GremlinTerminateTest fails if the handler is moved, and note the TinkerPop version assumption in a comment. If the submit ever moves off the Netty thread, the client silently becomes null. The lookups are already null-safe, so the effect is a missing client in the listing, not a crash.
  2. String.valueOf(socket.getRemoteSocketAddress()) and String.valueOf(ctx.channel().remoteAddress()) produce the literal string "null" for a closed or absent peer. The Gremlin test guards against that with isNotEqualTo("null"), but production code would list "null". A small helper that returns null for a null address would be cleaner and could be shared by Bolt, Gremlin and the other surfaces.
  3. Gremlin leader refusal is detected by class name. isLeaderRefusal matches ServerIsNotTheLeaderException.class.getName() in the exceptions attribute. This is reasonable given that TinkerPop drops the exception object. A rename or relocation of the exception would break it silently, but the test would catch that, and getName() is not a hard-coded string, so the risk is low.
  4. Leader address in production mode. The leader's HTTP address is now appended even when error text is concealed. This matches the other transports and the PR describes it, so it seems intentional. It does expose an internal hostname to any authenticated client that triggers a refusal. Please confirm that is acceptable under the production-mode concealment policy.
  5. Call-site noise. Many call sites now pass null, null as trailing arguments, which is easy to get wrong with seven positional parameters. A small parameter object or a Client record shared with GremlinAuthContext.Client could reduce this. It is not blocking.
  6. Style (CLAUDE.md). The new conceal(boolean, String, ResponseMessage) has a long line in the ternary, around 150 characters. It is within the 160 limit but hard to read, so consider extracting redirect first.

Tests
Coverage looks good: new tests per issue (Issue9962MCPClientListedTest over HTTP and stdio, Issue9960GremlinLeaderRefusalTest), plus existing tests migrated to the new signature. It would help to have a registry-level unit test that open(...) makes the client visible to a concurrent listing, because that is the central invariant of the change.

Overall this looks solid. Point 1 and the "null" address string in point 2 are the main things to look at before merging.

🤖 Generated with Claude Code

…of "null"; document the Gremlin pipeline-order assumption

RunningQueryRegistry.clientAddress(SocketAddress) is the one conversion every surface uses (HTTP, MCP, /ws, Bolt,
Redis, MongoDB, Postgres, Gremlin, gRPC), so a closed or in-process peer leaves the field out of the listing. Adds a
registry-level test that an entry is listed with its client from the start.
@claude

claude Bot commented Oct 14, 2026

Copy link
Copy Markdown

Review of #9980 (client in every list queries entry, leader named in MCP/Gremlin refusals)

I read the full diff but did not build or run the tests, so everything below comes from reading the code.

What I like

  • Moving connectionId and clientAddress into register()/open() and making setConnection package-private is the right fix. The registry is now the only way to set them, and they are set before the entry is put into running, so a listing can't see an entry without its client. A new surface can't compile without deciding who its client is.
  • RunningQueryRegistry.clientAddress(SocketAddress) centralises the null handling, so the listing omits the field instead of showing the string "null".
  • ServerIsNotTheLeaderException.withLeaderSentence removes the duplicated Redis/Postgres code. The wireSafe sanitisation is reused, and theAddressCannotForgeTheRestOfTheText covers it.
  • Test coverage is good. The end-to-end assertions are the valuable ones: HTTP and stdio MCP, the Gremlin server, the /ws insert, and gRPC unary and streaming. The pure-logic Gremlin tests call conceal(boolean, String, ResponseMessage) directly, which keeps them cheap.
  • The comments in ConcealingWebSocketChannelizer openly say that the design relies on TinkerPop 3.8 internals (when the op executor submits the evaluation), and which test fails if that changes. That is the right way to handle a fragile dependency.

Suggestions

  1. Positional API with many nulls. register(db, user, protocol, sessionId, tag, connectionId, clientAddress) has five adjacent Strings, and most call sites now end in null, null, null, null. Swapping connectionId and clientAddress, or sessionId and tag, compiles silently. That is exactly the kind of mistake this PR is meant to rule out. Since you are touching every call site anyway, consider a small record ClientInfo(String connectionId, String address) with a ClientInfo.NONE constant and a ClientInfo.of(SocketAddress) factory. It would also remove the ~30 test-line churn of , null, null. If you keep the flat signature, a short overload without the client for tests would reduce the noise.

  2. Duplicate thread-local in Gremlin. ArcadeGraphManager.CLIENT (with setRequestClient) and GremlinAuthContext.CLIENT (with setClient/getClient) hold the same value, and there are two pairs of setters to keep in sync. GremlinPrincipalPropagatingExecutorService is already the one place that copies Netty thread to pool thread. Having ArcadeGraphManager read a single holder, or fold the client into the existing user holder, would shrink the surface. It would also remove a place where a missed remove() could leak a client onto a pooled thread (the finally does clear it today).

  3. gRPC streaming loads depend on where the constructor runs. StreamingLoadEntry reads CLIENT_ADDRESS_KEY.get() in its constructor, which only works if it is built inside the handler on the call's Context thread. If a handler ever builds it on another executor, the client silently becomes null. The IT covers the current path, which is good. A one-line note on the constructor saying it must run on the call's Context would help. A null there is also the only case where a gRPC entry has no connectionId at all: unary RPCs pass null. A call-scoped id would help tell apart two clients that sit behind one NAT or proxy address.

  4. Gremlin RequestClientPublisher tests. The !(msg instanceof RequestMessage) pass-through and the clear-in-finally path have no unit test. An EmbeddedChannel test could check both: that the client is visible during channelRead and cleared afterwards, including when a downstream handler throws. It is cheap and would pin the behaviour independently of the TinkerPop upgrade fragility.

  5. Minor.

    • WebSocketInsertSession.openChunkEntry has a line well over the 160-column width the project uses. The long register(...) lines in MongoDBBackend and RedisNetworkExecutor are also over it.
    • The stdio client constant "stdio" is a magic string. It is a package constant in MCPStdioServer, which is fine, but MCPDispatcher is documented as expecting it, so the contract lives in two places.
    • InetSocketAddress.toString() yields /127.0.0.1:5000 with a leading slash. That matches the previous behaviour, so no change is needed. It may be worth normalising later for a nicer listing.

Behaviour and security

  • Naming the leader in production-mode MCP/Gremlin errors discloses an internal address to authenticated clients. This is consistent with the other transports and the address is sanitised, so I think it is acceptable. It is worth a line in the changelog or docs, as it is a visible change in production-mode output.
  • The PR explains why Database.transaction still retries leader refusals. Leaving that out of scope is reasonable.
  • No performance concern. The per-request cost is one small record and one asShortText() per Gremlin request, and nothing is allocated on the hot path of the other protocols beyond what was already there.

Overall this is a solid, well-tested change. Item 1 is the one I would most like addressed before merge. Items 2 to 4 are optional.

…ry.Client value, not two positional strings

register()/open() take a RunningQuery.Client (Client.NONE for work from no connection, Client.of(id, SocketAddress)
for a socket peer, which leaves a missing peer out instead of listing "null"), so the client fields can no longer be
swapped with each other or with the session id and tag. Gremlin reuses the record and keeps it in one thread-local
holder on both threads, published around the pipeline read by GremlinAuthContext.publishing, which is unit-tested.
StreamingLoadEntry documents that it must be built on the call's gRPC Context.
@claude

claude Bot commented Oct 14, 2026

Copy link
Copy Markdown

Review of #9980

Good design overall. Putting the client into register/open through a RunningQuery.Client record means a new surface cannot compile without deciding who its client is, which beats the extra setConnection line the issue suggested. The client is set before the entry is listed and setClient is package-private. Tests are broad (HTTP, stdio, Gremlin and gRPC end to end, plus unit tests). I did not build or run anything; this is from reading the diff.

Things to check

  1. Address format may have changed. The old call sites used RunningQueryRegistry.clientAddress(...), which this PR removes. The new code uses SocketAddress.toString(), which gives a leading slash (/10.0.0.1:5000), and the new engine test asserts exactly that. If clientAddress stripped the slash or normalised the format, the HTTP, Postgres, Redis and Mongo listings now differ, despite the description saying no change in behaviour. Please confirm, or note the change. Studio or any client parsing clientAddress would be affected.
  2. PostgresNetworkExecutor.clientAddress() duplicates Client.of: it calls getRemoteSocketAddress() twice and re-implements the null handling. Client.of(String.valueOf(processId), socketOrNull) would reuse the helper, as Redis and Mongo do.
  3. Gremlin client publishing depends on TinkerPop internals (RequestClientPublisher is added last in configure() and assumes OpExecutorHandler submits synchronously inside channelRead). The comments say so and Issue9689GremlinTerminateTest would catch a regression. The failure mode is only a missing client, which is acceptable. Keep that end-to-end assertion mandatory in CI.
  4. Leader-refusal detection reads STATUS_ATTRIBUTE_EXCEPTIONS and matches a class name, which is fragile across TinkerPop upgrades. The test covers current behaviour; a comment naming the verified TinkerPop version would help.
  5. In production mode, appending the leader address after CONCEALED_ERROR_MESSAGE discloses a cluster-internal host:port to authenticated clients that got a refusal. This matches Redis, Postgres and HTTP so it looks intentional; worth stating as a deliberate exception to concealment.
  6. gRPC StreamingLoadEntry reads CLIENT_KEY in its constructor and silently lists no client if built off the call's Context. The Javadoc now says to build it in the handler; a small test building it on a worker thread would pin the documented degradation.

Style (CLAUDE.md): several test call lines (the register(..., RunningQuery.Client.NONE) ones) are very long; wrap them to match the surrounding files.

Coverage: strong. ThreadLocal clean-up on a failed read is covered at the helper level.

No blocking issues found. The main open question is item 1.

Generated with Claude Code

…nt the Gremlin refusal detection's TinkerPop version and the concealment exception
@lvca

lvca commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

Review round 3 addressed in the latest commit:

  1. Address format: no change against main. RunningQueryRegistry.clientAddress was added and removed within this PR; on main every surface already listed String.valueOf(socketAddress), i.e. the same /host:port text that Client.of produces. Only a missing peer differs: it is now omitted instead of listed as "null".
  2. Postgres now goes through RunningQuery.Client.of like Redis and MongoDB.
  3. Kept: Issue9689GremlinTerminateTest asserts the client end to end and runs in the regular gremlin-it lane.
  4. Documented: the refusal detection names the TinkerPop version it was verified on (3.8.2) and the test that fails if the attribute disappears.
  5. Documented as the one deliberate exception to concealment, as on HTTP, gRPC, Bolt, PostgreSQL, Redis and MongoDB.
  6. Not added: built off the call's Context, the entry is listed without a client, which is a missing field, not a failure, and the constructor documents it.
    Style: long call lines wrapped.

@claude

claude Bot commented Oct 14, 2026

Copy link
Copy Markdown

Review of #9980 (client on every list queries entry, leader named on MCP and Gremlin refusals)

I read the full diff but did not build or run the tests. Overall this is a well-designed change and I have no blocking concerns.

What I like

  • The client is part of opening the entry. register/open take a RunningQuery.Client and setClient is package-private, so a new surface cannot compile without deciding who its client is, and a listing never sees an entry without one. This fixes the root cause rather than adding another setConnection line per surface.
  • Client.of(id, SocketAddress) omits a missing peer instead of listing the literal "null". anEntryIsListedWithItsClientFromTheStart covers it.
  • Leader redirect is consolidated in ServerIsNotTheLeaderException.withLeaderSentence, replacing the Redis and Postgres copies. The address goes through wireSafe, and the Gremlin test covers CR/LF forging.
  • The MCP client is passed per message, not held on the dispatcher, which is right since one HTTP dispatcher serves every client.
  • Gremlin thread-local handling is careful: publishing(...) clears in finally, and the executor service restores the previous value rather than blindly clearing it.
  • Tests are good: unit tests plus end-to-end checks across the Gremlin, gRPC, MCP and WS-insert surfaces.

Suggestions

  1. RunningQuery.setClient ignores null. if (client != null) quietly lists an entry with no client, which undercuts the "cannot forget" guarantee. A bare null compiles for every caller, and GremlinAuthContext.getClient() can return null today (ArcadeGraphManager.beforeQueryStart passes it straight through). Consider Objects.requireNonNull(client) in open, with an explicit Client.NONE fallback at the Gremlin call site, so a TinkerPop upgrade that moves the submit off the Netty thread shows up as a visible fallback rather than a hidden null. Not a blocker, since Issue9689GremlinTerminateTest pins it.
  2. Gremlin depends on TinkerPop internals (the synchronous submit inside channelRead, and the STATUS_ATTRIBUTE_EXCEPTIONS class names). Both are documented and have failing tests if they break, which is a reasonable tradeoff. However Issue9960GremlinLeaderRefusalTest builds the response by hand with statusAttributeException, so it does not prove a real failed evaluation carries the class names. An end-to-end test for the refusal path would close that gap.
  3. Public API break in MCPDispatcher: dispatch(...) and dispatchBatch(...) are public and their signatures changed. Fine if nothing outside the module calls them. A 2-arg overload would keep source compatibility but reintroduce the "forgot the client" path, so I lean towards leaving it.
  4. stdio in clientAddress: consumers may parse that field as host:port. It is documented in the Client javadoc, but worth mentioning in the list queries docs too.
  5. gRPC:
    • connectionId is always null. A stable per-call identifier would help tell clients apart behind one NAT, though the peer address may be enough.
    • isStreamingLoad is !clientSendsOneMessage() on the service, so it also matches bidi-streaming methods. Please confirm that is intended for every such method, not only the four loads.
    • StreamingLoadEntry reads CLIENT_KEY.get() in its constructor, which silently yields null if built off the call Context. The javadoc says so. A debug log when registry != null && client == null would make a regression visible.
  6. Nits:
    • In GrpcAdmissionInterceptor, the new io.grpc.Grpc and io.grpc.Contexts imports are out of alphabetical order against ForwardingServerCallListener.
    • Issue9962MCPClientListedTest runs a roughly 16 s Cypher statement and terminates it. Consider @Tag("slow") if it runs long on CI.

Security and performance

  • The leader address is the one deliberate exception to production-mode concealment. It is justified in the comments, sanitised, and matches the other transports. Fine by me.
  • The added cost is one small record allocation per registered statement plus one ThreadLocal set/remove per Gremlin request. Negligible.

Nice work overall.

…d; surfaces that may have none pass Client.NONE explicitly
@lvca

lvca commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

Review round 4 addressed in the latest commit:

  1. Done: RunningQueryRegistry.open refuses a null client (Objects.requireNonNull, pinned by the registry test). Gremlin and the gRPC streaming loads, which can legitimately have none (a custom channelizer, a Gremlin session, an entry built off the call's Context), now pass RunningQuery.Client.NONE explicitly.
  2. An end-to-end leader refusal needs an HA cluster in front of the Gremlin Server, which is what No end-to-end test drives a follower's leader refusal over Bolt, MongoDB, Postgres or Redis #9870 is open for. The attribute TinkerPop attaches is pinned against the builder TinkerPop itself uses on every error path.
  3. Kept as is: the dispatcher's callers are the module's two transports, and a 2-arg overload would bring back the path where the client is forgotten.
  4. Will be covered in the list queries docs.
  5. Intended: the service's only client-streaming RPCs are the four loads (InsertBidirectional is the bidi one). gRPC has no connection id the server can see, and the peer address is what the other surfaces list too.
  6. Import order fixed. Issue9962MCPClientListedTest terminates the statement as soon as it is listed, so it does not run its 16 s.

@claude

claude Bot commented Oct 14, 2026

Copy link
Copy Markdown

Review of #9980 (client on every list-queries entry, leader named in MCP/Gremlin refusals)

I read the engine, Gremlin and test changes closely. I did not read the MCP, gRPC, /ws and Redis/Postgres delegation hunks line by line, and I did not build or run anything.

What looks good

  • Making Client a required argument of register/open is better than one more setConnection call per surface. It is set before running.put, so no listing can see an entry without its client. Client.of(id, null) omits the address instead of printing "null".
  • Gremlin thread-locals: publishing(...) clears the client in finally, so a Netty thread cannot leak one channel's client to another. The executor service restores the previous client rather than clearing it.
  • The reliance on TinkerPop 3.8 internals is documented and guarded by end-to-end tests, so an upgrade that breaks it fails a test.
  • Redis and Postgres now delegate to withLeaderSentence, removing duplicated code.
  • Test coverage is broad: HTTP and stdio MCP, Gremlin, gRPC ITs, and a unit test for Client semantics including null.

Points to consider (none blocking)

  1. Leader address in production mode: Gremlin and MCP errors now carry the leader's HTTP address after the placeholder. The PR says this matches other transports and it is only added for a genuine leader refusal. A short docs note would help, since it is a deliberate exception to concealment.
  2. Sanitising: the summary says addresses are sanitised, but the Gremlin redirectSentence concatenates leaderAddress directly. Please confirm leaderSentence sanitises it, since it comes from cluster state and reaches a client-visible message.
  3. Per-request allocation: RequestClientPublisher.channelRead builds a Client, an id string and a lambda for every request message. Small next to a Gremlin evaluation, but the id and address strings could be cached once per channel as a channel attribute. Optional.
  4. Style: some new lines in tests and in conceal run long. The statusMessage(redirect != null ? ...) expression could use a local final String. Minor.
  5. The Client.NONE fallback in ArcadeGraphManager means sessions and custom channelizers silently list no client. It is commented, but a test pinning it would keep it from being mistaken for a regression. Optional.
  6. Leaving the txRetries retry semantics out of scope is reasonable. Please make sure a follow-up issue exists.

Overall this is a clean, well-tested change. I would approve once point 2 is confirmed.

🤖 Generated with Claude Code

@lvca

lvca commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

Review round 5:

  1. Confirmed: redirectSentence goes through ServerIsNotTheLeaderException.leaderSentence(address), which passes the address through wireSafe (control characters, line breaks included, become spaces). Pinned by Issue9960GremlinLeaderRefusalTest.theAddressCannotForgeTheRestOfTheText and ExceptionTest.withLeaderSentenceNamesTheLeaderOnlyForARedirect.
  2. Done: the concealed message is a local before the answer is built.
  3. Filed as Database.transaction retries a follower's leader refusal that names the leader txRetries times before answering #9995.
  4. Will be in the list queries / production-mode docs.
    3, 5: kept as is. Netty already caches the channel's short id and peer address, so per request this is one small record and one lambda, next to a Gremlin evaluation. The Client.NONE fallback for a session or a custom channelizer is a missing field by design, and it is commented at the call site.

@claude

claude Bot commented Oct 14, 2026

Copy link
Copy Markdown

Review of #9980 (list queries client + leader refusal naming)

Overall this is a well-designed change. Making the client a required argument of register/open is a good way to stop a ninth surface from forgetting it. The Client record is a clean value type. Objects.requireNonNull fails fast. Setting the client before the entry becomes visible closes the listing race. Tests cover each surface and the end-to-end Gremlin and gRPC paths. I found no blocking bugs.

Observations and suggestions

  1. Scope: the PR bundles two issues (Three of the eight surfaces that open a list queries entry record no client on it, so MCP, /ws insert and Gremlin work lists with no address: it can be stopped but not attributed #9962 and MCP and the Gremlin Server answer a follower's leader refusal as a generic failure that never names the leader, and in production as the concealment placeholder: the two transports #9845 missed #9960). They share files, so I understand it, but the leader-refusal work (ServerIsNotTheLeaderException.withLeaderSentence, the Gremlin concealer rewrite, the MCP failureMessage change) is a separate behavior change from the client plumbing. Splitting would have made review and revert easier. Not a blocker.

  2. Hot-path allocation: Client.of(...) calls peer.toString() eagerly on every registration. For HTTP, Redis (per command) and Postgres (per statement) that is a String allocation per request even when nobody lists queries. The old code did the same via String.valueOf, so there is no regression. Since CLAUDE.md stresses GC pressure, you could hold the SocketAddress in the record and stringify lazily in RunningQuery.getClientAddress()/toJSON(). Fine as a follow-up.

  3. Gremlin fragility (ConcealingWebSocketChannelizer, GremlinPrincipalPropagatingExecutorService):

    • Correctness depends on TinkerPop 3.8 submitting the evaluation synchronously from inside channelRead on the Netty thread. The class comment and the fallback to NONE are honest about this, and Issue9689GremlinTerminateTest guards it. Session-based requests will list no client. That is documented, but worth a user-facing note.
    • isLeaderRefusal relies on the exceptions status attribute holding the class name. It is guarded by a test, but note that production-mode concealment strips attributes only after isLeaderRefusal has read them. The ordering is correct today, so keep it that way.
  4. gRPC: StreamingLoadEntry must be constructed on the call's Context, or it silently falls back to NONE. This is documented in the Javadoc. A GrpcAdmissionInterceptor.CLIENT_KEY.get() == null log at debug level, or a constructor parameter, would make that misuse visible instead of silent.

  5. Semantics: MCPStdioServer.STDIO_CLIENT puts "stdio" in the clientAddress field, which is not an address. The Javadoc on Client.address allows it, so this is just something consumers of list queries should know about. HTTP connectionId stays null, so a client can only be told apart by address (multiple clients behind one NAT will look alike).

  6. API break: RunningQueryRegistry.register/open lose their 5-argument forms and RunningQuery.setConnection is removed. This is intentional and confined to in-repo callers, but it breaks embedders and plugins that call the registry. Mention it in the release notes.

  7. Behavior change: a missing peer address used to be listed as the string "null" and is now omitted. This is better, and it is tested. Anyone parsing the old output could notice.

  8. Style nits: several new test lines exceed the 160-column width used elsewhere (e.g. the registry.register(..., RunningQuery.Client.NONE) calls). In Issue9689RunningQueryFollowUpsTest, hardcoded IPs are fine since they are never bound. In withLeaderRedirect (Redis/Postgres) the remaining wrappers are now thin delegates; you could inline them.

Security

  • Leader address disclosure in production mode is a deliberate exception, passes through wireSafe (CR/LF stripped, tested), and matches the other transports. Good.
  • No new unauthenticated surface, and client addresses are only shown through the existing visibility-checked listing.

Tests

Coverage is good: unit tests for Client and the registry, a null-rejection test, and per-surface tests (MCP, Gremlin, gRPC unary and streaming, ws in every mode). I could not run the suite in this review, so please make sure CI is green, in particular the Gremlin and gRPC modules, which need verify rather than test.

🤖 Generated with Claude Code

@lvca

lvca commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

Review round 6: no blocking findings, and CodeRabbit generated no actionable comments. Remaining points, judged not worth changing in this PR:

  • 2: the eager toString() is the same one allocation per request String.valueOf made on main. Deferring it would mean a typed-weak holder (an address that may be stdio or a SocketAddress) for a saving next to the request's own work. Possible follow-up, not a regression.
  • 1, 3, 4, 5: already discussed in rounds 2-5. The session/custom-channelizer fallback and stdio as a client name go into the list queries docs.
  • 6, 7: for the release notes. The registry signature change (register/open now take a RunningQuery.Client) and clientAddress being omitted rather than "null" will be listed there.
  • 8: the Redis and Postgres wrappers are kept because their tests address them by name. The long test lines left are a scanned source fixture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment