Repository navigation
feat(gateway): B1 — Syntropy MCP gateway link (KG-first, config-gated, disabled-by-default) - #56
Conversation
… discovery on the shared transport (never-throws result union, nameless entries skipped, token never in errors, shared MCP_TIMEOUT_MS) + 8 tests Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
…discovered-tool cache (single-flight refresh, stale-while-refreshing <= maxStale, mutating-tools fail-closed drop past maxStale, collision prefixing, injectable clock/transport) + 13 tests + package scaffold Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
…g-gated MCP-client plugin (per-server auth seams: static-key env / m2m-exchange fail-closed B2 placeholder; fire-and-forget primed discovery w/ capped backoff; sync registerTool factory mapping descriptors→tools via shared transport; unknown-tool refresh+retry-once; before_agent_start availability line; plugin-owned refresh interval + gateway_stop cleanup) + 17 tests; disabled-by-default (bundled, config-gated) Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
…w fail-closed via isProvablyReadOnly (unannotated tools drop past maxStale; red-first) + folded coverage: retry-once bound on persistent unknown-tool, execute getToken-reject fail-closed (no transport call, no token text), collision-prefixed tool executes unprefixed wire name on owning server, exact exponential backoff assertions (was vacuous <=30000); 33/33 QGR-Finding: SEC-B1-1 Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
…der (fixes FastMCP 406) + SSE-framed response parsing + McpSession stateful streamable-http handshake (initialize/mcp-session-id/initialized, single-flight, expired-session invalidate+retry-once, stateless servers unaffected — SJ path byte-identical) threaded per-server through catalog discovery + tool execute; +19 tests (237 green). LIVE-PROVEN vs kg-mcp-test: 10 kg_* tools discovered, real kg_bilingual_term round-trip, bad-key fail-closed 401 Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
…ink complete (supersedes 921df67) Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
…ly swept into 2f1c442 — push accountability logs live monorepo-side, not in this repo Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
…persedes 545f4d2) Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 30 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a new ChangesMCP plugin functionality
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant OpenClaw
participant SyntropyMcpPlugin
participant ToolCatalog
participant MCPServer
OpenClaw->>SyntropyMcpPlugin: register plugin
SyntropyMcpPlugin->>ToolCatalog: refresh configured servers
ToolCatalog->>MCPServer: tools/list
MCPServer-->>ToolCatalog: tool descriptors
ToolCatalog-->>SyntropyMcpPlugin: catalog snapshot
SyntropyMcpPlugin-->>OpenClaw: register executable tools
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
The formal models extracted constants ( This check is informational (not blocking merges yet). If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@extensions/syntropy-mcp/src/catalog.ts`:
- Around line 182-186: Update isProvablyReadOnly to fail closed on contradictory
annotations: return false whenever annotations.mutates is true or
annotations.readOnlyHint is explicitly false, and only return true when the
available annotations contain no mutation indication and at least one
affirmative read-only indication. Add tests covering contradictory combinations
such as readOnlyHint true with mutates true and readOnlyHint false with mutates
false.
In `@extensions/syntropy-mcp/src/index.ts`:
- Around line 126-133: Validate that a positive maxStaleSeconds is at least
refreshSeconds before assigning it in the configuration parsing logic. Update
the existing validation around maxStaleSecondsRaw and throw a clear error when
maxStaleSecondsRaw is less than refreshSeconds, preventing inconsistent
freshness and staleness behavior in getToolDescriptors.
- Around line 240-242: Track the original tool name explicitly instead of
inferring it from surfacedName. Add a wireName field to CatalogEntry and
populate it with the tool’s original descriptor name when catalog entries are
created; then update the wire-name resolution in the relevant request-handling
logic to use the catalog entry’s wireName directly, removing the server.id
prefix check and slicing logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 69429ede-e530-42dc-b2bc-2d2addef6d4c
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (13)
extensions/syntropy-mcp/openclaw.plugin.jsonextensions/syntropy-mcp/package.jsonextensions/syntropy-mcp/src/catalog.test.tsextensions/syntropy-mcp/src/catalog.tsextensions/syntropy-mcp/src/index.test.tsextensions/syntropy-mcp/src/index.tsextensions/syntropy/src/client.list-tools.test.tsextensions/syntropy/src/client.session.test.tsextensions/syntropy/src/client.test.tsextensions/syntropy/src/client.tsworkstreams/openclaw/qgr/SyntropyHealth-Applications-mo-openclaw-openclaw-SyntropyHealth-Applications-qgr-pr-prep-20260708-2020-921df67.mdworkstreams/openclaw/qgr/SyntropyHealth-Applications-mo-openclaw-openclaw-SyntropyHealth-Applications-qgr-pr-prep-20260708-2035-545f4d2.mdworkstreams/openclaw/qgr/SyntropyHealth-Applications-mo-openclaw-openclaw-SyntropyHealth-Applications-qgr-pr-prep-20260708-2038-4d09854.md
| isProvablyReadOnly(descriptor: McpToolDescriptor): boolean { | ||
| const annotations = descriptor.annotations; | ||
| if (!annotations) return false; | ||
| return annotations.readOnlyHint === true || annotations.mutates === false; | ||
| } |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
isProvablyReadOnly uses || — contradictory annotations survive the max-stale drop.
A tool with { readOnlyHint: true, mutates: true } passes as "provably read-only" because true || false === true, yet isMutating also flags it as mutating. Similarly, { readOnlyHint: false, mutates: false } passes via false || true === true despite readOnlyHint: false explicitly asserting non-read-only. In a fail-closed model, a compromised backend could exploit this by setting readOnlyHint: true alongside mutates: true to keep write tools alive past the stale horizon.
The test at line 112-140 covers individual annotation cases but not contradictory combinations.
🔒 Proposed fix — veto any mutation-suggesting annotation first
isProvablyReadOnly(descriptor: McpToolDescriptor): boolean {
const annotations = descriptor.annotations;
if (!annotations) return false;
- return annotations.readOnlyHint === true || annotations.mutates === false;
+ // Veto: any annotation suggesting mutation disqualifies provably read-only status.
+ if (
+ annotations.mutates === true ||
+ annotations.readOnlyHint === false ||
+ annotations.requires_confirm === true
+ ) {
+ return false;
+ }
+ return annotations.readOnlyHint === true || annotations.mutates === false;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| isProvablyReadOnly(descriptor: McpToolDescriptor): boolean { | |
| const annotations = descriptor.annotations; | |
| if (!annotations) return false; | |
| return annotations.readOnlyHint === true || annotations.mutates === false; | |
| } | |
| isProvablyReadOnly(descriptor: McpToolDescriptor): boolean { | |
| const annotations = descriptor.annotations; | |
| if (!annotations) return false; | |
| // Veto: any annotation suggesting mutation disqualifies provably read-only status. | |
| if ( | |
| annotations.mutates === true || | |
| annotations.readOnlyHint === false || | |
| annotations.requires_confirm === true | |
| ) { | |
| return false; | |
| } | |
| return annotations.readOnlyHint === true || annotations.mutates === false; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@extensions/syntropy-mcp/src/catalog.ts` around lines 182 - 186, Update
isProvablyReadOnly to fail closed on contradictory annotations: return false
whenever annotations.mutates is true or annotations.readOnlyHint is explicitly
false, and only return true when the available annotations contain no mutation
indication and at least one affirmative read-only indication. Add tests covering
contradictory combinations such as readOnlyHint true with mutates true and
readOnlyHint false with mutates false.
| const maxStaleSecondsRaw = raw?.maxStaleSeconds; | ||
| if (maxStaleSecondsRaw !== undefined && typeof maxStaleSecondsRaw !== "number") { | ||
| throw new Error("maxStaleSeconds must be a number"); | ||
| } | ||
| const maxStaleSeconds = | ||
| typeof maxStaleSecondsRaw === "number" && maxStaleSecondsRaw > 0 | ||
| ? maxStaleSecondsRaw | ||
| : 3 * refreshSeconds; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Validate maxStaleSeconds >= refreshSeconds to prevent surprising tool drops.
If maxStaleSeconds < refreshSeconds, tools can be simultaneously "fresh" (age ≤ refreshSeconds) and "past max stale" (age > maxStaleSeconds). The fail-closed drop at getToolDescriptors line 159 would drop mutating tools while they're still tagged "fresh" — likely not the operator's intent. A one-line guard prevents this.
🛡️ Proposed validation
const maxStaleSeconds =
typeof maxStaleSecondsRaw === "number" && maxStaleSecondsRaw > 0
? maxStaleSecondsRaw
: 3 * refreshSeconds;
+ if (maxStaleSeconds < refreshSeconds) {
+ throw new Error("maxStaleSeconds must be >= refreshSeconds");
+ }
+
return { servers, refreshSeconds, maxStaleSeconds };📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const maxStaleSecondsRaw = raw?.maxStaleSeconds; | |
| if (maxStaleSecondsRaw !== undefined && typeof maxStaleSecondsRaw !== "number") { | |
| throw new Error("maxStaleSeconds must be a number"); | |
| } | |
| const maxStaleSeconds = | |
| typeof maxStaleSecondsRaw === "number" && maxStaleSecondsRaw > 0 | |
| ? maxStaleSecondsRaw | |
| : 3 * refreshSeconds; | |
| const maxStaleSecondsRaw = raw?.maxStaleSeconds; | |
| if (maxStaleSecondsRaw !== undefined && typeof maxStaleSecondsRaw !== "number") { | |
| throw new Error("maxStaleSeconds must be a number"); | |
| } | |
| const maxStaleSeconds = | |
| typeof maxStaleSecondsRaw === "number" && maxStaleSecondsRaw > 0 | |
| ? maxStaleSecondsRaw | |
| : 3 * refreshSeconds; | |
| if (maxStaleSeconds < refreshSeconds) { | |
| throw new Error("maxStaleSeconds must be >= refreshSeconds"); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@extensions/syntropy-mcp/src/index.ts` around lines 126 - 133, Validate that a
positive maxStaleSeconds is at least refreshSeconds before assigning it in the
configuration parsing logic. Update the existing validation around
maxStaleSecondsRaw and throw a clear error when maxStaleSecondsRaw is less than
refreshSeconds, preventing inconsistent freshness and staleness behavior in
getToolDescriptors.
| const wireName = surfacedName.startsWith(`${server.id}:`) | ||
| ? surfacedName.slice(server.id.length + 1) | ||
| : surfacedName; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
wireName prefix inference can produce the wrong wire name.
When a tool's natural name starts with serverId: (e.g., server "kg" exposes tool "kg:search") and no collision occurs, surfacedName is "kg:search" (unprefixed by the catalog). The startsWith check then strips "kg:" → wire name becomes "search" instead of "kg:search". The MCP server receives the wrong tool name.
The root cause is that the catalog overwrites descriptor.name with the prefixed name but doesn't preserve the original. Adding a wireName field to CatalogEntry eliminates the inference entirely.
🐛 Proposed fix — track original name in CatalogEntry
In catalog.ts, add wireName to the type and populate it:
export type CatalogEntry = {
serverId: string;
descriptor: McpToolDescriptor;
staleness: "fresh" | "stale";
+ wireName: string;
}; seenNames.add(surfaced.name);
- out.push({ serverId: entry.config.id, descriptor: surfaced, staleness });
+ out.push({ serverId: entry.config.id, descriptor: surfaced, staleness, wireName: descriptor.name });Then in index.ts, replace the inference:
- const wireName = surfacedName.startsWith(`${server.id}:`)
- ? surfacedName.slice(server.id.length + 1)
- : surfacedName;
+ const wireName = entry.wireName;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const wireName = surfacedName.startsWith(`${server.id}:`) | |
| ? surfacedName.slice(server.id.length + 1) | |
| : surfacedName; | |
| const wireName = entry.wireName; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@extensions/syntropy-mcp/src/index.ts` around lines 240 - 242, Track the
original tool name explicitly instead of inferring it from surfacedName. Add a
wireName field to CatalogEntry and populate it with the tool’s original
descriptor name when catalog entries are created; then update the wire-name
resolution in the relevant request-handling logic to use the catalog entry’s
wireName directly, removing the server.id prefix check and slicing logic.
…he version token from either bare or banner-style ('OpenClaw X (sha)') --version output instead of exact line match (false-negative fix; format change pre-existing on main, not B1)
Generated-With: Claude Code
Co-Authored-By: openclaw <[email protected]>
Co-Authored-By: Claude <[email protected]>
…t-reconcile Generated-With: Claude Code Co-Authored-By: openclaw <[email protected]> Co-Authored-By: Claude <[email protected]>
|
The formal models extracted constants ( This check is informational (not blocking merges yet). If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there. |
…sProvablyReadOnly, maxStale>=refresh guard, explicit wireName (#67) Addresses the 3 CodeRabbit change-requests on the merged PR #56 (B1). Verified each against current main (a2df2c4) — all 3 still valid; fixed red-first. (1) SECURITY (Major) — isProvablyReadOnly fail-closed veto (catalog.ts): the old returned true on CONTRADICTORY annotations — {readOnlyHint:true, mutates:true} passed as provably-read-only, letting a compromised backend keep a WRITE tool alive past the max-stale fail-closed drop (S6). Fix: veto via isMutating() FIRST, then require an affirmative read-only assertion — which also guarantees the documented invariant (isProvablyReadOnly ⟹ !isMutating, now test-enforced). Strictly-more-restrictive: it only DROPS more tools past the horizon, cannot create exposure. (2) DATA-INTEGRITY (Minor) — maxStaleSeconds>=refreshSeconds guard (index.ts): reject at config-parse time; otherwise a tool could be both 'fresh' and 'past max-stale', firing the drop on still-fresh tools. (3) CORRECTNESS (Minor) — explicit wireName (catalog.ts + index.ts): the wire name was inferred by stripping a '<serverId>:' prefix from surfacedName — wrong when a tool's natural name legitimately starts with '<serverId>:' (e.g. server 'kg' exposing 'kg:search' → mis-stripped to 'search', hitting the wrong tool). Added a wireName field to CatalogEntry preserving the ORIGINAL descriptor name; index.ts uses it directly (no inference). Red-first tests added for all 3 (contradictory-annotation combos + the RO⟹!mutating invariant; maxStale<refresh throws; wireName preserves a 'kg:search' name). 120 tests pass (catalog+index+governor), tsgo clean, oxfmt clean. Off fresh main a2df2c4. Generated-With: Claude Code Co-authored-by: cto <[email protected]> Co-authored-by: Claude <[email protected]>
openclaw-syntropy-agentic-chat B1 (T1.1-T1.4). listMcpTools on shared transport · ToolCatalog (single-flight refresh, stale-while-refreshing, FAIL-CLOSED max-stale drop, collision prefixing) · SyntropyMcpPlugin (config-gated, DISABLED-BY-DEFAULT, static-key/m2m seams, primed discovery w/ capped backoff, registerTool factory injection through tool-policy pipeline, unknown-tool refresh+retry-once, gateway_stop cleanup) · T1.4 live-QA transport fixes (MCP Accept header/406, SSE-framed parse, McpSession streamable-http handshake + expired-session retry-once; SJ stateless path byte-identical + regression-pinned). Gates: 237 tests, tsgo 0, sealed 60/60. Receipt qgr-pr-prep-20260708-2038-4d09854 (receipt-verify ✓). Disabled-by-default = inert until enabled (B2 gated on SJ /tokens/exchange). 🤖 Generated with Claude Code
Summary by CodeRabbit