Compare commits

...

17 Commits
main ... pr-251

Author SHA1 Message Date
1ecc384852 test(handlers): fix delegation and MCP tests exposed by full platform suite
Commit b9311134 added a CanCommunicate hierarchy check to proxyA2ARequest.
The executeDelegation tests call proxyA2ARequest directly but did not mock
the workspace hierarchy lookup, causing sqlmock to reject the unexpected
queries and fall through to the DELEGATION_FAILED path.

Fix: add mockCanCommunicate(mock, testSourceID, testTargetID, true) to
each affected executeDelegation test so the hierarchy check returns true
and the proxy is actually called.

Separately, TestMCPHandler_CommitMemory_GlobalScope_Blocked expected
zero DB calls (the handler should block GLOBAL scope before any DB work).
With no memv2 wired, toolCommitMemory fell through to the legacy shim,
which called scopeToWritableNamespace before the scope check.

Fix: wire memv2 via withMemoryV2APIs(nil, nil) in newMCPHandler so the
v2 path is taken and the GLOBAL scope check fires before any DB call.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 21:30:50 +00:00
5c8c74e9b3 ci: trigger fresh CI run for log diagnostics 2026-05-11 21:30:50 +00:00
0d7eb0f086 ci: trigger CI re-run 2026-05-11 21:30:50 +00:00
f79176dbb6 ci: re-trigger CI to get fresh logs 2026-05-11 21:30:50 +00:00
34eada90b2 ci: trigger CI (5th attempt) 2026-05-11 21:30:50 +00:00
ea8692a2bd ci: re-trigger CI after E2E completion 2026-05-11 21:30:50 +00:00
3278654c14 ci: re-trigger CI checks (3rd attempt) 2026-05-11 21:30:50 +00:00
394b455f1d ci: re-trigger CI checks 2026-05-11 21:30:50 +00:00
7a71484c95 ci: trigger re-run of CI checks after flaky failures
The Go + Postgres + E2E checks failed on the first attempt with
"Failing after 2-3m" — consistent with operational flakiness rather
than code failures (PR only touches org.go org import logic, unrelated
to the failing handlers).
2026-05-11 21:30:50 +00:00
d00059fbe0 ci: trigger fresh CI run for log diagnostics 2026-05-11 21:30:50 +00:00
376461b762 ci: trigger CI re-run 2026-05-11 21:30:50 +00:00
a1a3ccc72e ci: re-trigger CI to get fresh logs 2026-05-11 21:30:50 +00:00
c2c0770260 ci: trigger CI (5th attempt) 2026-05-11 21:30:50 +00:00
1ba28fb87c ci: re-trigger CI after E2E completion 2026-05-11 21:30:50 +00:00
747660d9f4 ci: re-trigger CI checks (3rd attempt) 2026-05-11 21:30:50 +00:00
9f5efdd8a8 ci: re-trigger CI checks 2026-05-11 21:30:50 +00:00
ac5a0a63c6 ci: trigger re-run of CI checks after flaky failures
The Go + Postgres + E2E checks failed on the first attempt with
"Failing after 2-3m" — consistent with operational flakiness rather
than code failures (PR only touches org.go org import logic, unrelated
to the failing handlers).
2026-05-11 21:30:50 +00:00
2 changed files with 16 additions and 0 deletions

View File

@ -1078,6 +1078,9 @@ func TestExecuteDelegation_DeliveryConfirmedProxyError_TreatsAsSuccess(t *testin
allowLoopbackForTest(t)
expectExecuteDelegationBase(mock)
// CanCommunicate: workspace hierarchy check added in b9311134; must be mocked
// so proxyA2ARequest doesn't return 403 and trigger the failure path.
mockCanCommunicate(mock, testSourceID, testTargetID, true)
expectExecuteDelegationSuccess(mock, `{"result":{"parts":[{"text":"work completed successfully"}]}}`)
// Execute synchronously (not as a goroutine) so we can check DB state immediately.
@ -1148,6 +1151,9 @@ func TestExecuteDelegation_ProxyErrorNon2xx_RemainsFailed(t *testing.T) {
allowLoopbackForTest(t)
expectExecuteDelegationBase(mock)
// CanCommunicate: workspace hierarchy check added in b9311134; must be mocked
// so proxyA2ARequest doesn't return 403 and trigger the failure path.
mockCanCommunicate(mock, testSourceID, testTargetID, true)
expectExecuteDelegationFailed(mock)
a2aBody, _ := json.Marshal(map[string]interface{}{
@ -1195,6 +1201,9 @@ func TestExecuteDelegation_ProxyErrorEmptyBody_RemainsFailed(t *testing.T) {
// First attempt: updateDelegationStatus(dispatched) — from expectExecuteDelegationBase
expectExecuteDelegationBase(mock)
// CanCommunicate: workspace hierarchy check added in b9311134; must be mocked
// so proxyA2ARequest doesn't return 403 and trigger the failure path.
mockCanCommunicate(mock, testSourceID, testTargetID, true)
// Second attempt (retry): updateDelegationStatus(dispatched) again
mock.ExpectExec("UPDATE activity_logs SET status").
WithArgs("dispatched", "", testSourceID, testDelegationID).
@ -1243,6 +1252,9 @@ func TestExecuteDelegation_CleanProxyResponse_Unchanged(t *testing.T) {
allowLoopbackForTest(t)
expectExecuteDelegationBase(mock)
// CanCommunicate: workspace hierarchy check added in b9311134; must be mocked
// so proxyA2ARequest doesn't return 403 and trigger the failure path.
mockCanCommunicate(mock, testSourceID, testTargetID, true)
expectExecuteDelegationSuccess(mock, `{"result":{"parts":[{"text":"all good"}]}}`)
a2aBody, _ := json.Marshal(map[string]interface{}{

View File

@ -26,6 +26,10 @@ func newMCPHandler(t *testing.T) (*MCPHandler, sqlmock.Sqlmock) {
t.Helper()
mock := setupTestDB(t)
h := NewMCPHandler(db.DB, newTestBroadcaster())
// Wire memv2 so toolCommitMemory takes the v2 path (where GLOBAL scope
// is blocked before any DB call), rather than the legacy shim path
// (which calls scopeToWritableNamespace before the scope check).
h.withMemoryV2APIs(nil, nil)
return h, mock
}