-
-
Notifications
You must be signed in to change notification settings - Fork 16
fix(sdk): harden guard client with policy pack schema fields and test coverage #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -519,7 +519,59 @@ describe('RegistryBrokerClient', () => { | |
| expect(targetUrl).toBe('https://api.example.com/api/v1/delegate'); | ||
| expect(init?.method).toBe('POST'); | ||
| expect(init?.headers).toBeInstanceOf(Headers); | ||
| expect((init?.headers as Headers).get('content-type')).toBe('application/json'); | ||
| expect((init?.headers as Headers).get('content-type')).toBe( | ||
| 'application/json', | ||
| ); | ||
| }); | ||
|
|
||
| it('calls the delegate endpoint with payload and options overload', async () => { | ||
| fetchImplementation.mockResolvedValueOnce( | ||
| createResponse({ | ||
| json: async () => ({ | ||
| task: 'review this repo', | ||
| intents: ['delegate'], | ||
| protocols: ['registry-broker'], | ||
| surfaces: ['cli'], | ||
| shouldDelegate: true, | ||
| opportunities: [], | ||
| }), | ||
| }) as unknown as Response, | ||
| ); | ||
|
|
||
| const client = new RegistryBrokerClient({ | ||
| baseUrl: 'https://api.example.com', | ||
| fetchImplementation, | ||
| }); | ||
|
|
||
| await client.delegate( | ||
| { | ||
| task: 'review this repo', | ||
| context: 'focus on broker chat parity', | ||
| }, | ||
| { | ||
| limit: 2, | ||
| filter: { | ||
| protocols: ['mcp'], | ||
| }, | ||
|
Comment on lines
+551
to
+555
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| workspace: { | ||
| openFiles: ['src/api/chat/contract.ts'], | ||
| }, | ||
| }, | ||
| ); | ||
|
Comment on lines
+546
to
+560
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test attempts to call |
||
|
|
||
| expect(fetchImplementation).toHaveBeenCalledTimes(1); | ||
| const [, init] = fetchImplementation.mock.calls[0]; | ||
| expect(JSON.parse(init?.body as string)).toEqual({ | ||
| task: 'review this repo', | ||
| context: 'focus on broker chat parity', | ||
| limit: 2, | ||
| filter: { | ||
| protocols: ['mcp'], | ||
| }, | ||
| workspace: { | ||
| openFiles: ['src/api/chat/contract.ts'], | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('throws RegistryBrokerError on non-OK response', async () => { | ||
|
|
@@ -743,6 +795,8 @@ describe('RegistryBrokerClient', () => { | |
| name: 'Security team default', | ||
| sharedHarnessDefaults: { codex: 'prompt' }, | ||
| allowedPublishers: ['hol'], | ||
| blockedPublishers: [], | ||
| blockedDomains: [], | ||
| blockedArtifacts: ['plugin:forked/risky-tool'], | ||
| alertChannel: 'email', | ||
| updatedAt: '2026-04-11T00:00:00.000Z', | ||
|
|
@@ -756,6 +810,8 @@ describe('RegistryBrokerClient', () => { | |
| name: 'Security team default', | ||
| sharedHarnessDefaults: { codex: 'prompt' }, | ||
| allowedPublishers: ['hol'], | ||
| blockedPublishers: [], | ||
| blockedDomains: [], | ||
| blockedArtifacts: ['plugin:forked/risky-tool'], | ||
| alertChannel: 'slack', | ||
| updatedAt: '2026-04-11T00:00:00.000Z', | ||
|
|
@@ -1408,6 +1464,7 @@ describe('RegistryBrokerClient', () => { | |
| agentUrl: 'https://demo.agent', | ||
| sessionId: 'session-1', | ||
| message: 'Hi', | ||
| idempotencyKey: 'chat-send-1', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| auth, | ||
| }); | ||
| expect(message.message).toBe('Hello'); | ||
|
|
@@ -1436,6 +1493,7 @@ describe('RegistryBrokerClient', () => { | |
| expect(JSON.parse(messageRequestInit.body as string)).toEqual({ | ||
| agentUrl: 'https://demo.agent', | ||
| auth: { type: 'bearer', token: 'user-key' }, | ||
| idempotencyKey: 'chat-send-1', | ||
| message: 'Hi', | ||
| sessionId: 'session-1', | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRITICAL: Invalid method invocation -
delegateexpects 1 argument but 2 providedThe
delegatemethod signature isdelegate(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: