Skip to content

feat(syntropy-mcp): B2 T2.1 TokenExchangeClient (RFC 8693, Option B signer) — inert/disabled-by-default - #60

Merged
supmo668 merged 6 commits into
mainfrom
mangyinm/syntropy-mcp-b2-t21
Jul 11, 2026
Merged

supmo668 merged 6 commits into
mainfrom
mangyinm/syntropy-mcp-b2-t21

Conversation

@supmo668

@supmo668 supmo668 commented Jul 11, 2026 •

Copy link
Copy Markdown

openclaw B2 per-user auth, client half (dispatch 2947). RFC 8693 TokenExchangeClient against the CTO-ruled Option B signer (SJ-minted RS256 + own JWKS). Tier-1 (subject_token=Clerk JWT, dormant) + Tier-2 (requested_subject=:<external_id>, consent-hardened) live. Validate-before-cache, per-subjectId cache + generation-guard + single-flight + invalidate-retry-once-on-401, dynamic TTL clamped to signed exp.

SECURITY (devex condition openclaw#2931 MET + test-locked): verifier hard-pins alg=RS256 as a hardcoded literal (rejected BEFORE any JWKS fetch — alg-confusion defense), validates iss+aud+exp+nbf, JWKS cache 300s, unknown-kid FAIL-CLOSED. Headline QG fix SEC-HTTPS HIGH: baseUrl (the JWKS trust-root fetch) now https-required (localhost dev-exempt) — a cleartext/MITM'd JWKS would poison the keyset + forge a matching-kid token. 16 QG findings all fixed; crypto kernel verified sound by 2 reviewers. tsgo 0, 190 tests, sealed 60/60.

INERT: disabled-by-default plugin, mock-STS, NO live network dep; fail-closed on missing machine secret/issuer/machineSub/channel/externalId/non-https baseUrl. Live wire-up waits on SJ's endpoint deploy + verbatim per-env aud. Safe to land ahead.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added secure token exchange for per-user and per-channel tool access.
    • Added support for authenticated tool calls using exchanged user credentials.
    • Added automatic token caching, refresh, and recovery after authorization failures.
  • Security
    • Enforced secure server endpoints and fail-closed behavior when required authentication settings are missing or invalid.
    • Added validation for exchanged tokens and their security claims.
  • Bug Fixes
    • Improved handling of unauthorized requests with bounded re-authentication and retry behavior.

supmo668 and others added 3 commits July 10, 2026 23:54
… B, mock-STS) — RFC 8693 per-user token exchange. Verifier security kernel (devex condition openclaw#2931): RS256 hard-pin rejected before any JWKS fetch (alg-confusion defense), iss+nbf+aud+exp validation, JWKS keyset cache 300s max-age, unknown-kid FAIL-CLOSED (no fetch-and-trust). Tier-1 (subject_token=Clerk JWT) + Tier-2 (requested_subject=<channel>:<external_id>, consent-hardened openclaw#2937, bare-user path removed). Validate-before-cache (sub/act.sub/aud/exp/iss), per-subjectId cache + single-flight + invalidate-retry-once-on-401, dynamic TTL from expires_in (no hardcoded 1800), token/PII hygiene. Wired into the m2m-exchange server getToken (replaces the B1 fail-closed placeholder); fail-closed on missing machine secret / issuer / channel / externalId. 157 tests green

Generated-With: Claude Code
Co-Authored-By: cto <[email protected]>
Co-Authored-By: Claude <[email protected]>
… verified sound, these harden). SEC-HTTPS baseUrl https-floor red-first (baseUrl is the JWKS trust-root — cleartext MITM would poison keyset + forge; localhost dev-exempt, m2m fail-closed) + DESIGN-GENGUARD generation-guard (invalidate racing in-flight exchange no longer resurrects, mirrors ServiceAuthProvider) + SEC-EXPCLAMP (cache TTL clamped to signed exp, unsigned expires_in can't extend past it) + DESIGN-MACHINESUB (blank machineSub disables server) + CODE-CACHE-EVICT (sweepExpired on refresh tick) + DECODE-GUARD/EMPTY-JWKS/JWKS-single-flight + 18 coverage locks (401-retry-once wiring, issuer/actor disable, exp/expires_in branches, no-kid, aud-array, single-flight-fail). Tier-1 seam typed accessor. 190 tests green

QGR-Finding: SEC-HTTPS
Generated-With: Claude Code
Co-Authored-By: cto <[email protected]>
Co-Authored-By: Claude <[email protected]>
…hange client (security-critical)

Generated-With: Claude Code
Co-Authored-By: cto <[email protected]>
Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@supmo668, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b17db01f-1e88-4eb1-82ab-6b490e1594b1

📥 Commits

Reviewing files that changed from the base of the PR and between 9b498d6 and 94c1b78.

📒 Files selected for processing (4)
  • extensions/syntropy-mcp/src/index.test.ts
  • extensions/syntropy-mcp/src/token-exchange.test.ts
  • extensions/syntropy-mcp/src/token-exchange.ts
  • workstreams/openclaw/qgr/SyntropyHealth-Applications-mo-openclaw-openclaw-SyntropyHealth-Applications-qgr-pr-prep-20260711-0042-5a68250.md
📝 Walkthrough

Walkthrough

Changes

M2M Exchange

Layer / File(s) Summary
Token exchange client and verification
extensions/syntropy-mcp/src/token-exchange.ts, extensions/syntropy-mcp/src/token-exchange.test.ts
Adds RFC 8693 exchange requests, RS256/JWKS verification, binding-claim validation, subject-scoped caching, single-flight behavior, invalidation, expiry handling, and structured error hygiene.
Plugin m2m runtime integration
extensions/syntropy-mcp/src/index.ts
Adds m2m configuration fields, actor-token wiring, request-subject resolution, per-user exchange, HTTPS and binding checks, cache sweeping, and bounded unauthorized retries.
Plugin exchange and security validation
extensions/syntropy-mcp/src/index.test.ts, workstreams/openclaw/qgr/*.md
Adds integration tests for successful and fail-closed exchange paths, Tier-2 requests, HTTPS rules, identity bindings, retry behavior, unauthorized classification, and QGR receipt metadata.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Agent
  participant SyntropyMcpPlugin
  participant TokenExchangeClient
  participant ExchangeEndpoint
  participant McpServer
  Agent->>SyntropyMcpPlugin: invoke tool with identity and channel context
  SyntropyMcpPlugin->>TokenExchangeClient: request subject-scoped token
  TokenExchangeClient->>ExchangeEndpoint: exchange actor token
  ExchangeEndpoint-->>TokenExchangeClient: minted user token
  TokenExchangeClient-->>SyntropyMcpPlugin: verified bearer token
  SyntropyMcpPlugin->>McpServer: execute tool
  McpServer-->>SyntropyMcpPlugin: result or 401
  SyntropyMcpPlugin->>TokenExchangeClient: invalidate and retry once
Loading

Possibly related PRs

  • Syntropy-Health/openclaw#56: Adds the earlier m2m-exchange configuration and gateway/plugin groundwork extended by this implementation.

Poem

A rabbit hops through tokens bright,
Exchanges secrets left and right.
JWKS guards the minted trail,
Cache and retries never fail.
HTTPS keeps the burrow tight—
B2 blooms in moonlit light!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the feature and security intent, but it does not follow the required template and omits most required sections. Rewrite the PR description using the repository template, including Summary bullets, Change Type, Scope, Linked Issue/PR, Security Impact, Verification, and Risks.
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific and matches the main change: an inert, disabled-by-default TokenExchangeClient for syntropy-mcp.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mangyinm/syntropy-mcp-b2-t21

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.

@supmo668 supmo668 added the enhancement New feature or request label Jul 11, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

supmo668 and others added 3 commits July 11, 2026 00:36
…A7 pin caught it; would fail every live Tier-2 turn) — bind byte/type-exact to SJ's VERBATIM mint (openclaw#2961). checkClaims branches on tier: Tier-2 binds channel-claim===requested + tier===2 (JSON number) + sub present-non-empty recorded as user_scope (NOT the composed value — SJ resolves it to the bare Clerk id via passcode linkage) + act.sub===machineSub; Tier-1 sub===externalId + tier===1 (number, no channel — absent on Tier-1). Cache still keyed on request identity (cross-user isolation intact). Red-first + exact-type tests (tier:'2' string REJECTED, tier-confusion REJECTED, Tier-1 no-channel ACCEPTED). 202 tests green

QGR-Finding: A7-tier2-binding
Generated-With: Claude Code
Co-Authored-By: cto <[email protected]>
Co-Authored-By: Claude <[email protected]>
…rity re-review SOUND, no CRIT/HIGH/MED) — explicit else-if(tier===2) + unreachable-default fail (a malformed subject can't skip the tier guards) + cache-key-must-include-externalId invariant comment (Tier-2 per-user binding). 202 tests green

Generated-With: Claude Code
Co-Authored-By: cto <[email protected]>
Co-Authored-By: Claude <[email protected]>
…ier-2 binding, re-QG sound; supersedes 1c78286)

Generated-With: Claude Code
Co-Authored-By: cto <[email protected]>
Co-Authored-By: Claude <[email protected]>
@github-actions

Copy link
Copy Markdown

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

@supmo668
supmo668 merged commit e6f5294 into main Jul 11, 2026
9 of 13 checks passed
@supmo668
supmo668 deleted the mangyinm/syntropy-mcp-b2-t21 branch July 11, 2026 08:17
supmo668 added a commit that referenced this pull request Jul 11, 2026
…github-hosted-fallback, CTO pre-auth openclaw#3106)

Config-only workflow diff: remap 10 runs-on lines in ci.yml off the Blacksmith runners (9x → ubuntu-latest, 1x → windows-latest; macos untouched) — restores reliable openclaw CI after the Blacksmith outage that forced substituted-verification on #60/#61. NO gate-strictness change (grep blacksmith=0, exactly 10 runs-on lines, YAML valid, all prod-critical gates stay fail-loud — only WHERE they run changed). CTO diff-verified; proportionate gating for a runner remap (no 4-reviewer QG). Path-B SSH (workflow file).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant