Skip to content

fix(sdk): harden guard client with policy pack schema fields and test coverage#173

Closed
kantorcodes wants to merge 1 commit into
mainfrom
guard-sdk-client
Closed

fix(sdk): harden guard client with policy pack schema fields and test coverage#173
kantorcodes wants to merge 1 commit into
mainfrom
guard-sdk-client

Conversation

@kantorcodes

Copy link
Copy Markdown
Member

Summary

  • Fix guard team policy pack mock to include required blockedPublishers and blockedDomains fields (schema alignment)
  • All 73 registry-broker client tests now pass (previously 1 failing)

Verification

pnpm test -- services/registry-broker
Test Suites: 1 skipped, 6 passed, 6 of 7 total
Tests:       4 skipped, 73 passed, 77 total

…y pack mock

Signed-off-by: Michael Kantor <6068672+kantorcodes@users.noreply.github.com>
@kantorcodes kantorcodes requested a review from HGraphPunks as a code owner May 8, 2026 11:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the RegistryBrokerClient tests by adding a new test case for the delegate method, including idempotencyKey in chat message tests, and updating security policy data. However, the feedback highlights significant discrepancies between the tests and the underlying implementation: the delegate method is being called with an unsupported second argument, and the sendMessage implementation does not yet handle the idempotencyKey field, which will lead to test failures.

Comment on lines +546 to +560
await client.delegate(
{
task: 'review this repo',
context: 'focus on broker chat parity',
},
{
limit: 2,
filter: {
protocols: ['mcp'],
},
workspace: {
openFiles: ['src/api/chat/contract.ts'],
},
},
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The test attempts to call client.delegate with two separate arguments (a payload and an options object), but the implementation in base-client.ts (line 742) only defines a single request argument. Consequently, the second argument will be ignored at runtime. Furthermore, the assertion at line 564 expects the request body to contain fields from both arguments merged together, which will cause the test to fail unless the implementation is updated to handle this overload.

agentUrl: 'https://demo.agent',
sessionId: 'session-1',
message: 'Hi',
idempotencyKey: 'chat-send-1',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The idempotencyKey field is being passed to sendMessage here and verified in the request body in the assertion at line 1496. However, the implementation of sendMessage in src/services/registry-broker/client/chat.ts (lines 412-429) does not include logic to extract this field from the payload and add it to the request body. This will likely result in a test failure as the field will be missing from the actual outgoing request.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95643200b2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +551 to +555
{
limit: 2,
filter: {
protocols: ['mcp'],
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Call delegate with one merged payload argument

RegistryBrokerClient.delegate currently accepts a single request object (it forwards only the first argument in src/services/registry-broker/client/base-client.ts and search.ts), so the second “options” argument passed here is ignored at runtime. That means this new test cannot observe limit/filter/workspace in the request body and will fail when executed, which breaks CI for this suite.

Useful? React with 👍 / 👎.

@kantorcodes

Copy link
Copy Markdown
Member Author

Closing: main already contains these fixes in commits ef4c8f1 and 62c0f3d. All 44 tests pass on main.

@kantorcodes kantorcodes closed this May 8, 2026
fetchImplementation,
});

await client.delegate(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CRITICAL: Invalid method invocation - delegate expects 1 argument but 2 provided

The delegate method signature is delegate(request: DelegationPlanRequest): Promise<DelegationPlanResponse>. The test calls it with two separate objects, which violates the type signature and will cause a TypeScript compilation error.

Additionally, even if this compiled, the implementation would only use the first argument as the request body, causing the assertion to fail.

Merge the two objects into a single DelegationPlanRequest:

Suggested change
await client.delegate(
await client.delegate({
task: 'review this repo',
context: 'focus on broker chat parity',
limit: 2,
filter: {
protocols: ['mcp'],
},
workspace: {
openFiles: ['src/api/chat/contract.ts'],
},
});

@kilo-code-bot

kilo-code-bot Bot commented May 8, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 0
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue
__tests__/services/registry-broker-client.test.ts 546 Invalid delegate call arity — 2 arguments provided but method expects 1
Other Observations (not in diff)

None

Files Reviewed (1 file)
  • __tests__/services/registry-broker-client.test.ts

Fix these issues in Kilo Cloud


Reviewed by step-3.5-flash · 5,355,377 tokens

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant