fix(handlers): update activity_logs test expectation for #2560 CTE + message_id #3205
Reference in New Issue
Block a user
Delete Branch "fix/handlers-activity-cte-expectation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #3203.
Problem
TestProxyA2A_PollMode_CanvasUserCallerID_PropagatesToActivityLogwas failing onmain, causing theCI / Platform (Go)blocking gate to fail (handlers package FAIL).Root cause
The test expected the pre-#2560 simple
INSERT INTO activity_logsquery with 12 args. Production now uses a CTE that inserts withmessage_id($13) and updatesworkspaces.last_activity_atatomically. The sqlmockExpectExec("INSERT INTO activity_logs")substring still matches the CTE text, but theWithArgslist had the wrong arity, so the expectation did not match.Fix
Add
sqlmock.AnyArg()formessage_id($13) in the test's activity_logs expectation.Verification
go test -timeout 3m ./internal/handlers/...— PASS (45s)go test -race -timeout 10m ./internal/handlers/...— PASS (80s)go test -timeout 10m -coverprofile=coverage.out ./...— PASSgo vet ./internal/handlers/...— cleangofmt— clean5-axis review on current head
5f3d794bcf: APPROVE. Correctness: diff is limited to workspace-server/internal/handlers/a2a_proxy_test.go and aligns the sqlmock expectation with the current #2560 CTE/activity_logs INSERT shape by adding the message_id argument; it preserves the source_id contract the test pins. Robustness: this fixes the main-red test expectation without changing production behavior or weakening the assertion. Security: no production code, auth, logging, or secret-handling changes. Performance: test-only, no runtime impact. Readability: the new comment explains the CTE/message_id expectation clearly. Diff-against-main is clean: merge-base is current main and only this test file changes.APPROVED on head
5f3d794bcf. Verified base=main, mergeable=true, and files API shows only workspace-server/internal/handlers/a2a_proxy_test.go. The diff is test-only: TestProxyA2A_PollMode_CanvasUserCallerID_PropagatesToActivityLog updates its sqlmock expectation for the #2560 activity_logs CTE by adding the 13th message_id argument and explanatory comments; production code is untouched.5-axis: correctness aligns the test with the current production INSERT/CTE shape while preserving the source_id propagation assertion this test exists to pin. Robustness improves main CI compatibility without weakening assertions. Security/performance risk is nil because no runtime code or secrets/auth path changed. Readability is fine. Merge after the approval-triggered security/qa/reserved-path contexts clear.
New commits pushed, approval review dismissed automatically according to repository settings
New commits pushed, approval review dismissed automatically according to repository settings
APPROVED on head
7d1b899ed2. Verified base=main, mergeable=true, and files API contains only the expected three files: a2a_proxy_test.go, contracts/mcp-plugin-delivery.contract.json, and mcp_plugin_delivery_contract_test.go.5-axis: correctness looks sound. The original activity_logs test expectation now matches the #2560/#2567 CTE/message_id shape while preserving the caller source_id assertion. The MCP contract re-sync documents runtime-agnostic descriptor delivery through InstallContext.register_mcp_server -> BaseAdapter.register_mcp_server_hook -> mcp_render.render_for_runtime, including Claude/Codex implemented render targets. The contract test now binds register_mcp_server to the real Claude renderer, so MCPServerAdaptor.install exercises the PORT path and still verifies the produced Claude settings file. Robustness improves by testing the runtime#172 delivery path instead of the obsolete direct .claude write. Security/performance risk is low: no production request/auth path changed; this is contract/test metadata. Readability is clear.
Merge when Researcher also approves on-head and required Platform Go/security/qa contexts are green. I am treating mcp-plugin-delivery-contract-drift as non-blocking per dispatch.
REQUEST_CHANGES on current head
7d1b899ed2.The a2a_proxy_test.go CTE/message_id fix is still correct, and contracts/mcp-plugin-delivery.contract.json now appears synced to runtime#172's canonical contract. The blocker is that the core contract test/type still does not enforce the new runtime-agnostic MCP-wiring contract, so this can false-green the exact #3159 regression class.
Findings:
workspace-server/internal/handlers/mcp_plugin_delivery_contract.go:21-34 only unmarshals the old top-level fields. The new contract fields (descriptor, port.hook/impl/present_probe/dispatch, runtimes.claude_code/codex/gemini_cli/hermes) are ignored, so Go tests cannot assert the codex config.toml table, gemini/hermes todo status, or the PORT names. Please extend the struct enough to inspect these fields.
workspace-server/internal/handlers/mcp_plugin_delivery_contract_test.go:23-40 still treats /configs/.claude/settings.json + mcpServers + claude_sdk_executor as the universal contract. That is now only the claude_code runtime entry. Please change this test to assert the new per-runtime contract: claude_code settings_path/key implemented, codex settings_path ~/.codex/config.toml + table mcp_servers implemented, gemini_cli/hermes todo-unverified, port.hook=InstallContext.register_mcp_server, port.impl=BaseAdapter.register_mcp_server_hook, present_probe=BaseAdapter.management_mcp_present.
workspace-server/internal/handlers/mcp_plugin_delivery_contract_test.go:109-206 still passes if an old MCPServerAdaptor writes .claude/settings.json directly. It wires register_mcp_server to render_for_runtime("claude_code", ...), but then only checks that /configs/.claude/settings.json exists. An old direct-write adaptor could ignore ctx.register_mcp_server and still satisfy the assertion. Please make the test prove PORT routing: record calls to register_mcp_server and assert [("molecule-platform", spec)], and assert the adaptor itself did not write .claude/settings.json when the callback is a recorder-only stub. Separately add/port a Codex production-path assertion that the active codex runtime writes HOME/.codex/config.toml [mcp_servers.molecule-platform] and does not write configs/.claude/settings.json.
5-axis summary: correctness blocked by insufficient regression coverage for the new contract; robustness blocked because this can false-green direct Claude-only writes; security/performance unaffected by the current diff; readability is fine but comments overstate what the test proves.
New commits pushed, approval review dismissed automatically according to repository settings
Addressed RC 13562 (the false-greening). New head
b217c8bfappends the hardening (no rebase/force-push of the existing work):register_mcp_serverand asserts the adaptor calls it exactly once with(molecule-platform, {command: molecule-mcp, env.MOLECULE_MCP_MODE: management}). A direct.claudewrite now leaves the recorder empty → fails (proven empirically: a regressed direct-write adaptor passed the OLD test but fails this one). The end-to-end Claude-file check is retained.TestMCPPluginDeliveryContract_CodexRoutesToCodexConfig) — installs the real adaptor onruntime=codex, asserts$HOME/.codex/config.tomlhas[mcp_servers.molecule-platform]+MOLECULE_MCP_MODE=management, and thatconfigs/.claude/settings.jsonis absent.Descriptor,Port{Hook,Impl,PresentProbe,Dispatch,ResolverDefault},Runtimesmap;MatchesSSOT()asserts scalars + PORT symbol names + per-runtime surfaces (claude_code/codeximplemented, gemini_cli/hermestodo— fails if a stub claims implemented or a runtime drops out).go build ./...+go vetclean; all 5 contract tests pass. The 2TestManifest_RefPinning_*failures are pre-existing (network SHA-reachability, fail identically on clean HEAD). Authored by the ceo-delegated identity (not in the reviewer pool) so this doesn't bypass the gate — re-requesting CR2 + Researcher for the 2-genuine. This is the keystone that greensmain.APPROVED on head
b217c8bf16. Verified base=main, mergeable=true, and files API contains the expected four files: a2a_proxy_test.go, contracts/mcp-plugin-delivery.contract.json, mcp_plugin_delivery_contract.go, and mcp_plugin_delivery_contract_test.go.5-axis: correctness looks sound. The activity_logs sqlmock expectation still matches the #2560/#2567 CTE/message_id shape while preserving the caller source_id assertion. The prior Researcher RC is addressed: the Go contract struct now reads descriptor/port/runtimes, MatchesSSOT asserts PORT symbol names plus Claude/Codex implemented and Gemini/Hermes todo surfaces, the Claude harness records register_mcp_server calls so direct .claude writes cannot false-green, and the Codex regression asserts HOME/.codex/config.toml [mcp_servers.molecule-platform] plus absence of configs/.claude/settings.json. Robustness improves by testing both PORT call semantics and Codex native output. Security/performance risk is low because runtime behavior is not changed here; this is test/contract hardening plus the original test expectation. Readability is clear.
Do not merge until Researcher clears the prior RC on this head and required CI, especially Platform Go/all-required/security/qa, is green.
REQUEST_CHANGES on
b217c8bf.The original RC 13562 false-green concern is addressed in shape: the Claude producer test now binds a register_mcp_server recorder/spy and would fail on a direct .claude/settings.json write; the new Codex regression asserts ~/.codex/config.toml and absence of .claude/settings.json; the contract struct/MatchesSSOT now covers descriptor/port/runtimes.
Blocking issue: the new Codex contract test does not pass in the actual Platform (Go) CI environment. CI / Platform (Go) fails in TestMCPPluginDeliveryContract_CodexRoutesToCodexConfig at workspace-server/internal/handlers/mcp_plugin_delivery_contract_test.go:231 with ModuleNotFoundError: No module named a2a, coming from molecule_runtime/adapter_base.py imported by plugins_registry/builtins.py. This is introduced by the new runtime harness path, not the claimed pre-existing RefPinning network tests. The a2a proxy 13-arg CTE expectation itself passes, and RefPinning tests pass in the observed log.
Five-axis: correctness blocked because the new required contract regression is red on-head; robustness blocked because the harness depends on a runtime transitive Python dependency absent from Platform Go CI; security no new secret exposure observed; performance not material; readability/intent is clear. Fix shape: make the contract harness self-contained in CI (install/provide the runtime Python dependencies or stub only the unrelated a2a import surface before importing MCPServerAdaptor), then rerun Platform Go.
TestMCPPluginDeliveryContract_CodexRoutesToCodexConfig failed Platform (Go) with `ModuleNotFoundError: No module named 'a2a'` (RC 13567). Root cause is the test harness, not the runtime: the codex sub-test pins HOME to a temp sandbox so the codex renderer's ~/.codex/config.toml lands inside it. In CI the runtime's deps (incl. a2a-sdk, imported at module level by adapter_base) are pip-installed into the *user* site ("Defaulting to user installation because normal site-packages is not writeable"), whose location Python derives from $HOME. Overriding HOME relocated user-site to the empty sandbox, so `import a2a` vanished. The claude sub-test passes only because it does NOT override HOME. Fix (option a, harness-only): resolve the interpreter's user+global site-packages dirs under the inherited HOME and pin them onto the child's PYTHONPATH before the HOME override, so the runtime import survives the swap. No production code and no Python-source changes. Verified: with a2a present only in a HOME-derived user-site, the old harness ModuleNotFoundErrors and the new one imports cleanly. The register_mcp_server spy keystone still fails on a direct-.claude #3159 regression (both claude and codex go red, recorder empty). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>New commits pushed, approval review dismissed automatically according to repository settings
Fixed the codex-test Platform(Go) red — new head
dfc43395a. Root cause (verified from the actual job log, run 399903): not thea2aimport per se — both sub-tests importbuiltins→adapter_base→a2a, and CI does installa2a-sdk. The codex sub-test pinsHOMEto a temp sandbox (so the codex renderer writes~/.codex/config.tomlthere), which relocates Python's user-site (where CI installed the deps: "Defaulting to user installation…") to the empty sandbox →a2avanished. The claude sub-test passes only because it never overrides HOME.Fix: in
runMCPAdaptorHarness, resolve the interpreter's user + global site-packages and pin them onto the child'sPYTHONPATHbefore the HOME override. Harness-only — no production or Python-source changes (+61/-2 in the test file).Verified: faithful CI repro (old harness
ModuleNotFoundErrors, new imports clean); both contract tests pass; keystone intact — injecting a simulated #3159 direct-.claude-write regression turns BOTH theregister_mcp_serverspy AND the codex assertion RED;go build ./...clean.The remaining
sop-checklist / all-items-acked+gate-check-v3reds are governance gates (not Platform(Go)). Re-requesting CR2 + Researcher ondfc43395afor the final 2-genuine — this greens main.APPROVE on
dfc43395a.Re-reviewed current head only; prior RCs 13562 and 13567 are resolved on this head. The producer contract test now binds a register_mcp_server recorder/spy and asserts the adaptor calls the MCP-wiring PORT exactly once with molecule-platform + molecule-mcp + MOLECULE_MCP_MODE=management, so the old direct .claude/settings.json write would no longer false-green. The Codex regression exercises the real MCPServerAdaptor path, asserts ~/.codex/config.toml contains [mcp_servers.molecule-platform] and MOLECULE_MCP_MODE=management, and asserts /configs/.claude/settings.json is absent for Codex.
The RC 13567 CI failure is also addressed: runMCPAdaptorHarness now builds PYTHONPATH from the runtime source plus the interpreter's resolved user/global site-packages before applying the sandbox HOME override, preserving a2a-sdk imports while still sandboxing Codex config output. Live statuses on
dfc43395ashow CI / Platform (Go) SUCCESS and CI / all-required SUCCESS.Five-axis: correctness looks sound for the #2560 activity_logs CTE expectation and the runtime#172 PORT contract; robustness improved by non-skipping real-adaptor tests plus explicit site-package path handling; security no secret/logging expansion or production runtime behavior change observed; performance impact is test-only; readability is acceptable with clear comments around the HOME/PYTHONPATH edge. Remaining gate-check/staging red is outside this review axis and not from these contract assertions.
APPROVED on current head
dfc43395a.5-axis review: Correctness: the activity_logs sqlmock expectation now matches the #2560/#2567 13-arg CTE/message_id path, and the MCP plugin delivery contract test now exercises both Claude and Codex runtime delivery through the register_mcp_server PORT. The Codex regression keeps the spy guard, asserts ~/.codex/config.toml, asserts no Claude settings write, and fixes the prior CI-only HOME/user-site issue by pinning the interpreter-resolved site-packages onto PYTHONPATH. Robustness: harness fails rather than skips when runtime source is missing, preserves inherited PYTHONPATH, and degrades site-dir discovery to the actual harness assertion. Security: no credential handling or new secret exposure; this is contract/test hardening. Performance: test-only process/env work, no production runtime impact. Readability: comments explain the HOME/user-site failure and the #3159/#2560 contracts clearly.