refactor(query): deepen command/dispatch seams and resolve coderabbit findings
* refactor(query): deepen command definition seam and fold fallback mapping cleanup * refactor(query): add shared dispatch formatting module seam * fix(query): restore QueryResult type import in dispatch deps * test/query: align raw-output policy and definition normalization contracts * refactor(query): deepen diagnosis, invariant report, and error taxonomy seams * refactor(query): deepen dispatch plan, fallback bridge, policy snapshot, and hints seams * refactor(query): deepen validation, fallback policy, capability, and result builder seams * refactor(query): deepen resolution strategy, output classifier, observability, and policy-capability seams * refactor(query): finalize deep strategy/classifier/observability/capability seams * test/query: address coderabbit inline and out-of-diff dispatch nits * fix(query): address remaining coderabbit input-validation and bridge stderr threads * fix(query): address remaining coderabbit dispatch and strategy/output nits
This commit is contained in:
31
sdk/src/query/query-error-taxonomy.test.ts
Normal file
31
sdk/src/query/query-error-taxonomy.test.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
fallbackFailureError,
|
||||
internalError,
|
||||
nativeFailureError,
|
||||
nativeTimeoutError,
|
||||
unknownCommandError,
|
||||
validationError,
|
||||
} from './query-error-taxonomy.js';
|
||||
|
||||
describe('query-error-taxonomy', () => {
|
||||
it('builds unknown_command error', () => {
|
||||
const err = unknownCommandError({
|
||||
message: 'Error: Unknown command: "x"',
|
||||
normalized: 'x',
|
||||
attempted: ['x'],
|
||||
hints: ['h1'],
|
||||
});
|
||||
expect(err.kind).toBe('unknown_command');
|
||||
expect(err.code).toBe(10);
|
||||
expect(err.details).toMatchObject({ normalized: 'x', attempted: ['x'], hints: ['h1'] });
|
||||
});
|
||||
|
||||
it('builds native/fallback/validation/internal errors', () => {
|
||||
expect(nativeFailureError({ message: 'boom', command: 'state.load', args: [] }).kind).toBe('native_failure');
|
||||
expect(nativeTimeoutError({ message: 'timeout', command: 'state.load', args: [], timeoutMs: 30000 }).kind).toBe('native_timeout');
|
||||
expect(fallbackFailureError({ message: 'spawn', command: 'state', args: ['load'] }).kind).toBe('fallback_failure');
|
||||
expect(validationError({ message: 'bad', details: { r: 'x' } }).kind).toBe('validation_error');
|
||||
expect(internalError({ message: 'bad' }).kind).toBe('internal_error');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user