agent-platform/Pull requests/#1842
代码仓库已连接
PR #1842 · feature/space-channel-credentials

Unify per-space channel credential resolution

BE提交者希望将 6 个 commits 合并到 main·18 分钟前更新

Changes requested

整体迁移方向正确,新增测试也覆盖了主要路径。但 credential cache 的 key 没有包含 Space,可能导致不同 Space 之间串用密钥。合并前应先修复这一处隔离问题。

P1

Credential cache 没有按 Space 隔离

app/services/channel_registry.rb · line 87–93
Security

credential_cache 仅以 channel name 为 key。同一进程处理多个 Space 时,后续请求可能复用前一个 Space 的凭据。这会造成跨租户信息泄漏,且现有测试使用单一 Space,无法捕获。

87def credentials_for(name, space:)
88 credential_cache[name] ||= load_credentials(name, space)
88 cache_key = [space.id, name]
89 credential_cache[cache_key] ||= load_credentials(name, space)
90end
P2

缺少多 Space cache 行为的回归测试

test/services/channel_registry_test.rb
Coverage

建议新增两个 Space 配置不同 token 的测试,并在同一进程内交替调用两次。这样能直接证明 cache 隔离,不依赖实现细节。

142test "credentials are isolated between spaces" do
143 assert_equal "token-a", registry.credentials_for(:code_host, space: spaces(:a))
144 assert_equal "token-b", registry.credentials_for(:code_host, space: spaces(:b))
145end