Skip to content

refactor(ddd): isolate MCP adapter contracts - #272

Open
seonghobae wants to merge 52 commits into
mainfrom
fix/ddd-mcp-adapter-boundary
Open

refactor(ddd): isolate MCP adapter contracts#272
seonghobae wants to merge 52 commits into
mainfrom
fix/ddd-mcp-adapter-boundary

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Scope

This PR keeps MCP as an external protocol adapter. originweave-mcp depends inward on stable core contracts and the protocol-independent policy API; originweave-core and originweave-policy do not depend outward on MCP transport types. Route validation proves protocol integrity only and grants no browser, network, policy, secret, approval, evidence, or ambient execution authority.

Protected main is exact 87c4daa1830bac5a5228b6036752ad5633232085 through #286. Exact current head is b1cae8ad1cbd8eb6992037c830aea30b9aa436b3, Ready and mergeable. Fresh compare is 52 ahead / 0 behind with merge base exactly current protected main. The effective PR delta contains no .github/** mutation.

Original stdio RED and repair

Test-only bbe6b219a33f78e3b8b1c0166a00e5c34a2ede22 specified modern MCP 2026-07-28 stdio admission for tools/call and tools/list without fabricated HTTP routing headers while retaining required body protocolVersion and clientCapabilities evidence. CI 33646560232 produced the intended hosted RED because the stdio constructors did not exist.

Production 09ffcccfd91d478120642a4db9bda501655e4533 added adapter-local new_for_stdio constructors while reusing the bounded routing/catalog/cursor validators. Stdio and Streamable HTTP remain distinct adapter transports; no MCP transport type or authorization decision moved into core/policy. 80272f18422c9946077ad9bd674f603db8f020da made the transport distinction durable in docs/traceability/mcp-authority-route.md.

Hosted quality-gate RED and causal repair

CI 33722893474 on exact 80272f18422c9946077ad9bd674f603db8f020da exposed two real defects: strict Clippy rejected three integration-test .expect(...) calls, and exact production coverage exposed the private six-arm routing::McpToolBoundaryError::Display surface. The branch repaired those without weakening Clippy, coverage, or DDD boundaries:

  • eda00dc5c87ce6164e687d13bea7ce0aa55b909f removes the prohibited expect from modern request-metadata success assertions;
  • c0e587e36045f4128b4c1dd414298c1171abe600 removes the two stdio expect calls; and
  • cae3e02cd2edc08db06111fb309a5b437c5a6598 executes all six existing private routing-error Display arms and verifies source-free error semantics without widening that internal type.

The later exact CI 33876274503 on cae3e02c... narrowed the remaining defect to canonical rustfmt after Production coverage had already succeeded. Canonical formatting artifact 9944034273 identified one exact diff in crates/originweave-mcp/tests/mcp_stdio_transport.rs. Commit fe124e447cad3f679e22337fb6fbdfd135ab3652 applied only that artifact-derived formatting repair.

Protected-main reconciliation

At unchanged fe124e..., native CI 33893256407 and MV3 33893256372 were GREEN, while same-generation Security/Semgrep/CodeQL were cancelled. Protected main then advanced through #286 and changed CI/MV3 lifecycle controls plus their repository contracts.

This branch repaired that divergence non-destructively rather than rebasing or overwriting the intervening generation:

  • merge commit 7763bd5398380d958b0d1aa09be510b6365ffeda keeps the prior refactor(ddd): isolate MCP adapter contracts #272 head as first parent and protected main@87c4daa... as second parent while adopting the protected CI/MV3 workflow blobs and MV3 contract exactly;
  • 55b2f06b038faab50496d33e1affcbb5517af0e5 reconciles the overlapping generic repository contract so it retains ci: stop draft PR jobs from occupying runners #286's lifecycle/Draft assertions and adds only originweave-mcp workspace membership;
  • 975492b156803210bd08f5ae27bd78a5da48c693 moves the MCP-specific dependency-direction assertions into focused tests/test_mcp_adapter_repository_contract.py instead of making the generic governance contract own adapter details; and
  • current b1cae8ad1cbd8eb6992037c830aea30b9aa436b3 updates the MCP traceability record to the current protected generation and records that the effective PR delta is workflow-free.

Fresh compare from current protected main is behind 0 and contains 17 semantic paths: the existing MCP crate/source/tests/docs delta, one workspace-member assertion, and the focused MCP repository contract. No protected workflow semantics are reintroduced or authored by this lane.

Verification state

The ready_for_review event on predecessor exact 975492b1... reproduced #279's #286 lifecycle defect: CI 33929826137 and MV3 33929826220 completed skipped although the PR had become Ready. Those results remain diagnostic only.

Fresh exact-current execution on b1cae8ad1cbd8eb6992037c830aea30b9aa436b3 is now terminal except for the central CodeQL verdict:

  • CI 33929881742: success;
  • Manifest V3 Compatibility 33929881782: success;
  • Security Scan 33929881739: success;
  • SAST Semgrep 33929881729: success;
  • CodeQL PR 33929881687: failure.

The CodeQL failure is not an observed MCP source finding. Language detection completed successfully. The python, actions, and javascript-typescript compatibility jobs each successfully completed Request current-head CodeQL scan dispatch, then failed at Release runner or enforce current-head CodeQL verdict. The exact jobs are 101238565589, 101238565594, and 101238565606. This remains fail-closed and belongs to the canonical central queue/dispatch owner .github#712; do not mutate leaf .github/**, synthesize status, transfer predecessor GREEN, or treat a queued central run as a verdict.

PR #273 remains the dependent documentation child. Reconstruct it non-destructively only after this exact parent generation has a terminal authenticated CodeQL verdict; preserve only its validated documentation/fitness delta and do not transfer predecessor checks.

Standards and dependency boundary

The MCP 2026-07-28 revision makes requests self-describing through per-request _meta: protocol version and client capabilities belong to the request body, while Streamable HTTP correlates transport metadata separately. Optional or self-reported client identity is not OriginWeave authorization input. The complete MCP adapter remains Planned; this slice does not claim complete stdio runtime framing, Streamable HTTP serialization, OAuth deployment, browser I/O, secret materialization, persistence, or evidence export.

No self-approval, bypass, force-push, destructive rebase, workflow/ruleset/secret mutation, gate weakening, tag, release, or publication is authorized.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 002fb75a-a33b-4aea-90ee-eaba3e02c04e

📥 Commits

Reviewing files that changed from the base of the PR and between 87c4daa and b1cae8a.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • CHANGELOG.md
  • Cargo.toml
  • crates/originweave-core/src/root.rs
  • crates/originweave-mcp/Cargo.toml
  • crates/originweave-mcp/src/lib.rs
  • crates/originweave-mcp/src/request.rs
  • crates/originweave-mcp/src/routing.rs
  • crates/originweave-mcp/tests/mcp_authority_route.rs
  • crates/originweave-mcp/tests/mcp_modern_request_metadata.rs
  • crates/originweave-mcp/tests/mcp_stdio_transport.rs
  • crates/originweave-mcp/tests/mcp_tools_list_cache.rs
  • crates/originweave-mcp/tests/policy_route_binding.rs
  • crates/originweave-policy/src/lib.rs
  • docs/traceability/mcp-authority-route.md
  • tests/test_mcp_adapter_repository_contract.py
  • tests/test_repository_contract.py

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.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current-head standards finding: originweave-mcp is a transport-agnostic external adapter boundary, but both modern validators currently require MCP-Protocol-Version unconditionally. MCP 2026-07-28 transport semantics make request-body _meta.io.modelcontextprotocol/protocolVersion and client capabilities the transport-independent source of truth; Streamable HTTP mirrors selected metadata into headers and defines mismatch rejection, while stdio carries the JSON-RPC body without an HTTP header. The current generic constructor therefore cannot represent a valid modern stdio tools/call (and ValidatedMcpToolsListRequest::new has the same transport conflation).

Repair acceptance: add a realistic RED that admits the same valid 2026-07-28 body metadata over stdio without an HTTP header while continuing to require/match the header for Streamable HTTP. Make transport binding explicit at the MCP adapter boundary (or provide equivalently unambiguous binding-specific constructors); do not move this distinction into core/policy. Preserve fail-closed behavior for missing body protocol metadata/capabilities, HTTP header/body mismatch, unsupported protocol generation, malformed method/tool routing, and unknown tools. Cover both tools/call and tools/list, and update doctoring/traceability to the 2026-07-28 transport overview/versioning pages. Do not claim RED/GREEN from currently queued hosted runs.

Copy link
Copy Markdown
Contributor Author

Fresh exact-head queue RCA for bbe6b219a33f78e3b8b1c0166a00e5c34a2ede22: repository-native CI run 33646560232 still has both required jobs queued with zero executed steps. Rust contracts 100302670660 and Production coverage 100302670895 each require only ubuntu-24.04, report runner_id=0, and have empty runner/group names. This is hosted-runner acquisition evidence, not an executed test result. The current test-only stdio contract therefore remains neither RED nor GREEN, and production new_for_stdio must remain unchanged until the contract actually executes. The exact canary has been routed to central queue-starvation owner ContextualWisdomLab/.github#712 (comment 5512825120) so the leaf repository does not churn source or weaken gates to manufacture runner acquisition. CodeQL 33646562998 remains a separate startup-failure owner-path case. Keep this PR Draft and preserve exact head until a material execution-state change.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head hosted RED is now actionable. CI 33722893474 checked out 80272f1. Rust contracts job 100545578684 passed repository contracts, rustfmt, workspace check, and the full test suite, then failed strict Clippy because three integration-test success paths use prohibited Result::expect: mcp_modern_request_metadata.rs:80 and mcp_stdio_transport.rs:8,43. Production coverage job 100545578332 completed measurement and failed exact enforcement; its artifact shows the uncovered production surface is the private routing::McpToolBoundaryError Display implementation. This is not a runner/workflow failure and does not require weakening Clippy or coverage. Minimal repair should stay adapter-local and test-only: remove the prohibited expect calls without changing behavior, and execute the private deterministic routing-error Display/source contract so every existing production arm is covered. Keep the MCP adapter inward dependency and policy/browser authority boundary unchanged.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current-head verification note for cae3e02: the hosted failure on 80272f1 was repaired without production/API/workflow changes. The three prohibited expect() success assertions are gone, and the previously uncovered private routing-error diagnostic implementation is now exercised across every variant with source-free Error semantics. Fresh CI/security/MV3/CodeQL runs are materialized but non-terminal, so this remains Draft and no GREEN transfers from predecessor heads. Keep #273 parent-first blocked until exact-current terminal evidence exists; only then adopt current protected main non-destructively.

Signed-off-by: Seongho Bae <me@seonghobae.me>
@seonghobae

Copy link
Copy Markdown
Contributor Author

Current-main reconciliation is pushed at exact head ab33144240875540f4e22f7678b727e40c0c40ab (signed merge commit; non-force fast-forward). The only reconciliation repair beyond adopting protected main is rustfmt's one-expression collapse in mcp_stdio_transport.rs; no production MCP behavior or authority boundary changed. Verified on this exact tree: MCP crate all-target/all-feature tests 25 passed, Python repository contracts 153 passed, workspace fmt/strict Clippy/all-target all-feature tests/rustdoc passed, and pinned-nightly LLVM coverage proved 100% functions, lines, regions, and branches. Keep Draft: hosted exact-head checks and current review are newly materialized/non-terminal, and dependent #273 remains parent-first blocked.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head verification note: CI 33876274503 on predecessor cae3e02c... is now terminal. Production coverage 101033892627 passed exact enforcement; Rust contracts 101033892459 failed only at rustfmt after repository contracts passed. Canonical artifact 9944034273 contains one formatting diff in mcp_stdio_transport.rs, and current commit fe124e447cad3f679e22337fb6fbdfd135ab3652 applies exactly that diff. This does not transfer predecessor GREEN to the new head: current CI/security/SAST/CodeQL/MV3 runs must complete on fe124e... before parent-first reconstruction of #273.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head verification update: CI 33893256407 is now terminal success. Rust contracts 101089771465 passed repository contracts, rustfmt, full Rust tests, strict Clippy and rustdoc; Production coverage 101089771864 passed exact enforcement. Manifest V3 33893256372 also succeeded. Security 33893256413, Semgrep 33893256402 and CodeQL 33893256357 remain queued, so keep Draft and do not restack #273 yet.

@seonghobae
seonghobae marked this pull request as ready for review September 4, 2026 23:31

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-current reconciliation review for b1cae8ad1cbd8eb6992037c830aea30b9aa436b3: the branch now adopts protected main@87c4daa... non-destructively, preserves #286's CI/MV3 lifecycle contracts, keeps .github/** identical to protected main, retains originweave-mcp workspace membership, and isolates MCP-specific dependency-direction assertions in focused tests/test_mcp_adapter_repository_contract.py. Fresh compare is behind 0 with merge base exactly current protected main. The predecessor ready_for_review event reproduced #279's skip defect; this Ready synchronize has materialized fresh CI/MV3/Security/Semgrep/CodeQL runs. Do not transfer predecessor GREEN or reconstruct #273 until this exact generation reaches terminal required evidence.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Exact-head review evidence for b1cae8ad1cbd8eb6992037c830aea30b9aa436b3: the adapter split keeps MCP types out of core/policy, modern HTTP validation binds required _meta protocol/capability presence to the protocol-version and routing headers, the explicit stdio constructors accept the same required body metadata without fabricating HTTP evidence, and route/action mismatch still fails before ordinary policy evaluation. This matches the final MCP 2026-07-28 stateless lifecycle and transport distinction. Fresh local verification passed 153 Python repository tests, rustfmt, all workspace/all-target Rust tests, strict Clippy, rustdoc with warnings denied, and exact 100% production function/line/region/branch coverage. The worktree is clean and no current review threads remain. Hosted checks are still queued and REVIEW_REQUIRED remains, so this is not merge evidence yet.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-current verification update for b1cae8ad1cbd8eb6992037c830aea30b9aa436b3: repository-native CI 33929881742, Manifest V3 33929881782, Security Scan 33929881739, and SAST Semgrep 33929881729 are terminal success on this unchanged head. CodeQL PR 33929881687 is terminal failure, but the failure is not a product-source finding: its language-detection job succeeds and each compatibility shard reaches the central dispatch handoff. For example python job 101238565589 validates the live exact PR/head, obtains GitHub OIDC and a repository-scoped App token, dispatches codeql-scan, then intentionally fails with VERDICT_STATE=pending while awaiting an authenticated codeql-dispatch/python terminal status and rerun. A fresh exact-head commit-status read contains no codeql-dispatch/* verdicts. I routed this consumer evidence to canonical central queue/dispatch owner ContextualWisdomLab/.github#712 as comment 5551060102. Do not change MCP source to satisfy this control-plane stall, synthesize statuses, or promote the four GREEN sibling workflows as a substitute for CodeQL. #273 remains parent-first blocked until a genuine exact-head CodeQL verdict/rerun completes and normal review/governance gates are satisfied.

@opencode-agent

opencode-agent Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Scheduled review-feedback autofix for this PR head.

  • Head SHA: b1cae8ad1cbd8eb6992037c830aea30b9aa436b3

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant