feat(coding): add plugin capability policy registry
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
PI_PRODUCT_FIXTURE_SOURCE,
|
||||
PI_WIRE_TO_PRODUCT_BOUNDARY,
|
||||
} from '../fixtures/coding-conversation-product-fixtures';
|
||||
import { productToolDetails } from '../../shared/coding-conversation-product-tool-protocol';
|
||||
|
||||
function reduceAll(
|
||||
snapshot: ConversationSnapshot,
|
||||
@@ -49,6 +50,62 @@ function envelope(
|
||||
}
|
||||
|
||||
describe('Conversation product contracts', () => {
|
||||
it('accepts bounded capability envelopes for every Data Service operation', () => {
|
||||
const control = new Set(['configure', 'inspect', 'list_projects', 'remove_collection', 'reset', 'remove_project']);
|
||||
const operations = [
|
||||
'configure', 'inspect', 'list_projects', 'get_document', 'list_documents',
|
||||
'put_document', 'delete_document', 'remove_collection', 'reset', 'remove_project',
|
||||
];
|
||||
for (const operation of operations) {
|
||||
const parsed = productToolDetails({
|
||||
schema: 'makelore-capability.v1',
|
||||
plugin_id: 'makelore.data-service',
|
||||
plugin_version: '1.0.0',
|
||||
capability_id: control.has(operation) ? 'data-service.control' : 'data-service.documents',
|
||||
operation,
|
||||
request_id: 'pi:run-a:resource-a',
|
||||
success: false,
|
||||
status: operation === 'put_document' ? 413 : operation === 'delete_document' ? 409 : 429,
|
||||
code: operation === 'put_document' ? 'document_too_large' : 'rate_limited',
|
||||
error: 'Data Service request was rejected',
|
||||
retryable: true,
|
||||
retry_after_seconds: 30,
|
||||
context: operation === 'put_document'
|
||||
? { resource: 'bytes', actual: 100_000, limit: 98_304 }
|
||||
: operation === 'delete_document'
|
||||
? { current_revision: 3 }
|
||||
: { resource: 'documents' },
|
||||
billing: { mode: 'included', status: 'included' },
|
||||
payload_schema: 'data-service.v1',
|
||||
data: null,
|
||||
});
|
||||
expect(parsed).toMatchObject({ schema: 'makelore-capability.v1', operation });
|
||||
}
|
||||
expect(productToolDetails({
|
||||
schema: 'makelore-capability.v1',
|
||||
plugin_id: 'makelore.data-service', plugin_version: '1.0.0',
|
||||
capability_id: 'data-service.documents', operation: 'get_document',
|
||||
request_id: 'pi:run-a:resource-a', success: true, status: 200,
|
||||
code: null, error: null, retryable: false,
|
||||
billing: { mode: 'platform_metered', status: 'refunded', reserved_points: '2.50', actual_points: '1.25' },
|
||||
payload_schema: 'data-service.v1', data: { id: 'one' },
|
||||
})).toMatchObject({ billing: { mode: 'platform_metered', status: 'refunded', actual_points: '1.25' } });
|
||||
expect(productToolDetails({
|
||||
schema: 'makelore-capability.v1', plugin_id: 'makelore.data-service', plugin_version: '1.0.0',
|
||||
capability_id: 'data-service.documents', operation: 'get_document', request_id: 'pi:run-a:resource-a',
|
||||
success: false, status: 409, code: 'quota_exceeded', error: 'Quota exceeded', retryable: false,
|
||||
billing: { mode: 'included', status: 'included' }, payload_schema: 'data-service.v1', data: null,
|
||||
context: { allowed: 1 },
|
||||
})).toBeNull();
|
||||
expect(productToolDetails({
|
||||
schema: 'makelore-capability.v1', plugin_id: 'makelore.data-service', plugin_version: '1.0.0',
|
||||
capability_id: 'data-service.documents', operation: 'get_document', request_id: 'pi:run-a:resource-a',
|
||||
success: true, status: 200, code: null, error: null, retryable: false,
|
||||
billing: { mode: 'included', status: 'included' }, payload_schema: 'data-service.v1',
|
||||
data: { body: 'raw upstream body must be projected' }, extra: 'reject',
|
||||
})).toBeNull();
|
||||
});
|
||||
|
||||
it('accepts schema v1 snapshots and fail-closes unknown schemas until replacement', () => {
|
||||
const snapshot = createProductSnapshot();
|
||||
expect(isConversationSnapshot(snapshot)).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user