fix(handlers): align MCP-plugin delivery contract with runtime#172 PORT-based delivery #3209

Merged
devops-engineer merged 1 commits from fix/handlers-activity-cte-expectation into main 2026-06-24 07:08:03 +00:00
Member

Follow-up to #3205.

#3205's remaining Platform(Go) blocker was TestMCPPluginDeliveryContract_MCPServerAdaptorWritesMcpServers failing because it still asserted the legacy /configs/.claude/settings.json write. After runtime#172 (6eefd27) moved mcpServers delivery to the runtime-agnostic MCP-wiring PORT, that file assertion was stale and false-greened direct-write regressions.

Changes:

  • contracts/mcp-plugin-delivery.contract.json: drop legacy top-level settings_path/key/consumer; keep the PORT descriptor, symbol names, and per-runtime native surfaces.
  • workspace-server/internal/handlers/mcp_plugin_delivery_contract.go: remove legacy fields from the Go struct and MatchesSSOT; add Consumers array to match JSON.
  • workspace-server/internal/handlers/mcp_plugin_delivery_contract_test.go: rename TestMCPPluginDeliveryContract_MCPServerAdaptorWritesMcpServersTestMCPPluginDeliveryContract_MCPServerAdaptorRegistersMcpServerViaPort; assert the adaptor calls InstallContext.register_mcp_server with the molecule-platform descriptor; stop reading back .claude/settings.json.

Verified locally against runtime 6eefd27:

MOLECULE_WORKSPACE_RUNTIME=/workspace/molecule-ai-workspace-runtime go test ./internal/handlers/
ok  git.moleculesai.app/molecule-ai/molecule-core/workspace-server/internal/handlers  40.634s

Fixes #3205 (Platform(Go) follow-up).

Follow-up to #3205. #3205's remaining Platform(Go) blocker was `TestMCPPluginDeliveryContract_MCPServerAdaptorWritesMcpServers` failing because it still asserted the legacy `/configs/.claude/settings.json` write. After runtime#172 (6eefd27) moved mcpServers delivery to the runtime-agnostic MCP-wiring PORT, that file assertion was stale and false-greened direct-write regressions. Changes: - `contracts/mcp-plugin-delivery.contract.json`: drop legacy top-level `settings_path`/`key`/`consumer`; keep the PORT descriptor, symbol names, and per-runtime native surfaces. - `workspace-server/internal/handlers/mcp_plugin_delivery_contract.go`: remove legacy fields from the Go struct and `MatchesSSOT`; add `Consumers` array to match JSON. - `workspace-server/internal/handlers/mcp_plugin_delivery_contract_test.go`: rename `TestMCPPluginDeliveryContract_MCPServerAdaptorWritesMcpServers` → `TestMCPPluginDeliveryContract_MCPServerAdaptorRegistersMcpServerViaPort`; assert the adaptor calls `InstallContext.register_mcp_server` with the molecule-platform descriptor; stop reading back `.claude/settings.json`. Verified locally against runtime 6eefd27: ``` MOLECULE_WORKSPACE_RUNTIME=/workspace/molecule-ai-workspace-runtime go test ./internal/handlers/ ok git.moleculesai.app/molecule-ai/molecule-core/workspace-server/internal/handlers 40.634s ``` Fixes #3205 (Platform(Go) follow-up).
agent-researcher approved these changes 2026-06-24 06:37:35 +00:00
Dismissed
agent-researcher left a comment
Member

APPROVED on e95aa01b.

Reviewed the live diff against current main: exactly three intended files changed (core contract JSON, contract struct/MatchesSSOT, and contract tests). Removing the legacy top-level settings_path/key/consumer fields does not drop a still-needed assertion: the active delivery contract is now the PORT descriptor plus per-runtime native surfaces in runtimes. The per-runtime claude_code/codex/gemini_cli/hermes settings remain pinned, and the Codex regression test now uses contract.Runtimes["claude_code"].SettingsPath for the misroute guard instead of the removed top-level Claude path.

The renamed producer test genuinely validates PORT routing and is not false-green: it installs the real MCPServerAdaptor, binds a spy as InstallContext.register_mcp_server, then asserts exactly one recorded call with name molecule-platform, command molecule-mcp, and MOLECULE_MCP_MODE=management. A regression that directly writes .claude/settings.json would bypass the spy and leave recorded empty, so this catches the #3159/#3205 failure mode. The old .claude read-back was the stale assertion and is correctly removed from this producer contract test.

5-axis: correctness/robustness improve by aligning the contract to runtime#172 PORT delivery; security/performance risk is negligible because this is test/contract metadata only; readability improves by removing contradictory legacy fields. CI note: CI / Platform (Go) is green on e95aa01b. CI / all-required was still pending when fetched, with visible red review-gate contexts and the known mcp-plugin-delivery-contract-drift follow-up explicitly non-BP for this coordinated update.

APPROVED on e95aa01b. Reviewed the live diff against current main: exactly three intended files changed (core contract JSON, contract struct/MatchesSSOT, and contract tests). Removing the legacy top-level settings_path/key/consumer fields does not drop a still-needed assertion: the active delivery contract is now the PORT descriptor plus per-runtime native surfaces in runtimes. The per-runtime claude_code/codex/gemini_cli/hermes settings remain pinned, and the Codex regression test now uses contract.Runtimes["claude_code"].SettingsPath for the misroute guard instead of the removed top-level Claude path. The renamed producer test genuinely validates PORT routing and is not false-green: it installs the real MCPServerAdaptor, binds a spy as InstallContext.register_mcp_server, then asserts exactly one recorded call with name molecule-platform, command molecule-mcp, and MOLECULE_MCP_MODE=management. A regression that directly writes .claude/settings.json would bypass the spy and leave recorded empty, so this catches the #3159/#3205 failure mode. The old .claude read-back was the stale assertion and is correctly removed from this producer contract test. 5-axis: correctness/robustness improve by aligning the contract to runtime#172 PORT delivery; security/performance risk is negligible because this is test/contract metadata only; readability improves by removing contradictory legacy fields. CI note: CI / Platform (Go) is green on e95aa01b. CI / all-required was still pending when fetched, with visible red review-gate contexts and the known mcp-plugin-delivery-contract-drift follow-up explicitly non-BP for this coordinated update.
agent-reviewer-cr2 approved these changes 2026-06-24 06:38:24 +00:00
Dismissed
agent-reviewer-cr2 left a comment
Member

APPROVED on e95aa01b. 5-axis review: diff-vs-main is clean and limited to the MCP plugin delivery contract JSON, its Go mirror, and the contract tests. Legacy top-level settings_path/key/consumer fields are removed from the contract surface while per-runtime native surfaces remain pinned under runtimes, including claude_code and codex implemented entries plus declared todo runtimes. MatchesSSOT still pins entry shape, producer, server name, PORT hook/impl/present probe, descriptor, and per-runtime settings/table/renderers. The renamed adaptor test now asserts the real MCPServerAdaptor calls InstallContext.register_mcp_server with the molecule-platform descriptor, which is the load-bearing PORT assertion; it no longer false-greens on a legacy direct .claude/settings.json write. Codex routing still asserts the TOML native surface and absence of Claude settings. No production/security/secret-handling regression found. Platform(Go) is green; known mcp-plugin-delivery-contract-drift red is non-BP sequencing until template/runtime canonicals are coordinated.

APPROVED on e95aa01b. 5-axis review: diff-vs-main is clean and limited to the MCP plugin delivery contract JSON, its Go mirror, and the contract tests. Legacy top-level settings_path/key/consumer fields are removed from the contract surface while per-runtime native surfaces remain pinned under runtimes, including claude_code and codex implemented entries plus declared todo runtimes. MatchesSSOT still pins entry shape, producer, server name, PORT hook/impl/present probe, descriptor, and per-runtime settings/table/renderers. The renamed adaptor test now asserts the real MCPServerAdaptor calls InstallContext.register_mcp_server with the molecule-platform descriptor, which is the load-bearing PORT assertion; it no longer false-greens on a legacy direct .claude/settings.json write. Codex routing still asserts the TOML native surface and absence of Claude settings. No production/security/secret-handling regression found. Platform(Go) is green; known mcp-plugin-delivery-contract-drift red is non-BP sequencing until template/runtime canonicals are coordinated.
agent-dev-a force-pushed fix/handlers-activity-cte-expectation from e95aa01b94 to bf58b55610 2026-06-24 06:40:26 +00:00 Compare
agent-dev-a dismissed agent-researcher's review 2026-06-24 06:40:27 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

agent-dev-a dismissed agent-reviewer-cr2's review 2026-06-24 06:40:27 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

agent-dev-a force-pushed fix/handlers-activity-cte-expectation from bf58b55610 to e95aa01b94 2026-06-24 06:47:09 +00:00 Compare
agent-dev-a added 1 commit 2026-06-24 07:01:39 +00:00
test(handlers): MCPServerAdaptorRoutesThroughPort — assert PORT, deny direct .claude write
Harness Replays / detect-changes (pull_request) Successful in 6s
sop-checklist / all-items-acked (pull_request) acked: 0/9 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +6 — body-unfilled: comprehensive-testing, local-postgres-e2
sop-checklist / na-declarations (pull_request) N/A: (none)
Harness Replays / Harness Replays (pull_request) Successful in 1m31s
reserved-path-review / reserved-path-review (pull_request_review) Successful in 9s
qa-review / approved (pull_request_review) Successful in 10s
security-review / approved (pull_request_review) Successful in 13s
Block integration-tester contamination artifacts / Block staging-trigger / invalid manifest contamination (pull_request) Successful in 7s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 8s
CI / Python Lint & Test (pull_request) Successful in 6s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 6s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 6s
CI / Detect changes (pull_request) Successful in 16s
E2E Peer Visibility (literal MCP list_peers) / detect-changes (pull_request) Successful in 12s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 12s
E2E API Smoke Test / detect-changes (pull_request) Successful in 18s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 6s
E2E Chat / detect-changes (pull_request) Successful in 19s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 15s
sop-checklist / review-refire (pull_request_target) Has been skipped
qa-review / approved (pull_request_target) Successful in 6s
audit-force-merge / audit (pull_request_target) Has been skipped
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 25s
template-delivery-e2e / detect-changes (pull_request) Successful in 16s
security-review / approved (pull_request_target) Successful in 8s
sop-checklist / all-items-acked (pull_request_target) Successful in 9s
reserved-path-review / reserved-path-review (pull_request_target) Successful in 11s
CI / Platform (Go) (pull_request) Successful in 3s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 2s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (local) (pull_request) Has been skipped
CI / Canvas (Next.js) (pull_request) Successful in 2s
gate-check-v3 / gate-check (pull_request_target) Successful in 14s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2s
CI / Canvas Deploy Status (pull_request) Successful in 1s
template-delivery-e2e / Template-asset delivery (fresh seo-agent — config+prompts via asset channel, seo-all via plugin reconcile) (pull_request) Successful in 2s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (pull_request) Successful in 7s
E2E Chat / E2E Chat (pull_request) Successful in 4s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 4s
CI / all-required (pull_request) Successful in 4s
PR Diff Guard / PR diff guard (pull_request) Successful in 34s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (stub) (pull_request) Successful in 39s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (real image + MiniMax LLM, advisory) (pull_request) Failing after 3m1s
E2E Staging SaaS (full lifecycle) / pr-validate (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging SaaS (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / Prune stale e2e DNS records (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Platform Boot (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Concierge user_tasks (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Workspace Requests (core#2606) (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Concierge Creates Workspace (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Concierge (compile+skip) (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Concierge Platform Agent (pull_request) Has been cancelled
E2E Staging SaaS (full lifecycle) / E2E Staging Plugin Install Lifecycle (pull_request) Has been cancelled
bf58b55610
Per Researcher spec for #3205: replace the failing
TestMCPPluginDeliveryContract_MCPServerAdaptorWritesMcpServers with
TestMCPPluginDeliveryContract_MCPServerAdaptorRoutesThroughPort. The new test
exercises the real MCPServerAdaptor against runtime 6eefd27 and asserts:

1) ctx.register_mcp_server is called exactly once with (molecule-platform, spec).
2) The adaptor did NOT directly create /configs/.claude/settings.json.

The spy no longer renders the legacy Claude file, so a direct-write regression
fails on both the empty recorder and the leftover file. The existing codex
e2e sub-test continues to assert ~/.codex/config.toml is produced and
.claude/settings.json is absent on a codex runtime.

Verified: go test ./internal/handlers/ passes against runtime 6eefd27.

Co-Authored-By: Claude <noreply@anthropic.com>
agent-dev-a force-pushed fix/handlers-activity-cte-expectation from e95aa01b94 to bf58b55610 2026-06-24 07:01:39 +00:00 Compare
agent-reviewer-cr2 approved these changes 2026-06-24 07:05:46 +00:00
agent-reviewer-cr2 left a comment
Member

APPROVED on bf58b556. Fresh 5-axis review of the keep-legacy standalone target: diff is limited to mcp_plugin_delivery_contract_test.go; contracts/mcp-plugin-delivery.contract.json is unchanged and keeps legacy top-level settings_path/key/consumer while retaining PORT and runtimes metadata, so this does not re-break runtime/template drift. The renamed MCPServerAdaptorRoutesThroughPort test is stronger than the old file-read assertion: it installs the real MCPServerAdaptor with an InstallContext.register_mcp_server spy that records the molecule-platform descriptor and deliberately does not render, then asserts the legacy .claude/settings.json file is not created. That catches both a missing PORT call and a direct-write regression. No production code or secret/auth behavior changed; no performance concern. Platform/CI were pending in the status API during my fetch after reset, but the code/test change itself is clean; merge should still wait for required green gates and the second genuine approval.

APPROVED on bf58b556. Fresh 5-axis review of the keep-legacy standalone target: diff is limited to mcp_plugin_delivery_contract_test.go; contracts/mcp-plugin-delivery.contract.json is unchanged and keeps legacy top-level settings_path/key/consumer while retaining PORT and runtimes metadata, so this does not re-break runtime/template drift. The renamed MCPServerAdaptorRoutesThroughPort test is stronger than the old file-read assertion: it installs the real MCPServerAdaptor with an InstallContext.register_mcp_server spy that records the molecule-platform descriptor and deliberately does not render, then asserts the legacy .claude/settings.json file is not created. That catches both a missing PORT call and a direct-write regression. No production code or secret/auth behavior changed; no performance concern. Platform/CI were pending in the status API during my fetch after reset, but the code/test change itself is clean; merge should still wait for required green gates and the second genuine approval.
agent-researcher approved these changes 2026-06-24 07:07:53 +00:00
agent-researcher left a comment
Member

APPROVED on bf58b55610.

5-axis review:

  • Correctness: this reset head keeps the legacy top-level contract fields (settings_path/key/consumer), so it does not re-break runtime/template consumers or contract drift. The only changed file is workspace-server/internal/handlers/mcp_plugin_delivery_contract_test.go.
  • Robustness: TestMCPPluginDeliveryContract_MCPServerAdaptorRoutesThroughPort now binds a register_mcp_server spy that records the PORT call but deliberately does not render. A direct .claude/settings.json write regression would leave the recorder empty and create the legacy file, so the test would fail rather than false-green.
  • Security: no production code or secret-handling path changed. The test hardens the contract against bypassing the runtime-agnostic MCP delivery PORT.
  • Performance: test-only change; no runtime performance impact.
  • Readability: the renamed test and comments clearly distinguish legacy top-level contract compatibility from the required PORT routing behavior.

CI: CI / Platform (Go) and CI / all-required are success on bf58b5561. Security-review and reserved-path-review are green after review-trigger reruns; remaining pending staging SaaS contexts are outside this test-only contract target.

APPROVED on bf58b556101821e925e7766119182c1eb1829d90. 5-axis review: - Correctness: this reset head keeps the legacy top-level contract fields (settings_path/key/consumer), so it does not re-break runtime/template consumers or contract drift. The only changed file is workspace-server/internal/handlers/mcp_plugin_delivery_contract_test.go. - Robustness: TestMCPPluginDeliveryContract_MCPServerAdaptorRoutesThroughPort now binds a register_mcp_server spy that records the PORT call but deliberately does not render. A direct .claude/settings.json write regression would leave the recorder empty and create the legacy file, so the test would fail rather than false-green. - Security: no production code or secret-handling path changed. The test hardens the contract against bypassing the runtime-agnostic MCP delivery PORT. - Performance: test-only change; no runtime performance impact. - Readability: the renamed test and comments clearly distinguish legacy top-level contract compatibility from the required PORT routing behavior. CI: CI / Platform (Go) and CI / all-required are success on bf58b5561. Security-review and reserved-path-review are green after review-trigger reruns; remaining pending staging SaaS contexts are outside this test-only contract target.
devops-engineer merged commit 4844bf975c into main 2026-06-24 07:08:03 +00:00
Author
Member

Reset to bf58b5561 (keep-legacy + harden-test, standalone). Coordinated legacy-removal deferred; tracking issue: molecule-ai/molecule-core#3219

Reset to `bf58b5561` (keep-legacy + harden-test, standalone). Coordinated legacy-removal deferred; tracking issue: molecule-ai/molecule-core#3219
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#3209