feat(sdk): add strict mode and explicit fallback policy to runtime bridge

This commit is contained in:
Tom Boucher
2026-05-05 19:23:39 -04:00
parent 98dd9e4afb
commit 0026065c7a
6 changed files with 79 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import type { QueryCommandResolution } from './query/query-command-resolution-st
import { resolveQueryCommand } from './query/query-command-resolution-strategy.js';
import { QueryExecutionPolicy } from './query-execution-policy.js';
import { QueryNativeHotpathAdapter } from './query-native-hotpath-adapter.js';
import { GSDToolsError } from './gsd-tools-error.js';
export interface RuntimeBridgeExecuteInput {
legacyCommand: string;
@@ -25,6 +26,10 @@ export class QueryRuntimeBridge {
private readonly executionPolicy: QueryExecutionPolicy,
private readonly nativeHotpathAdapter: QueryNativeHotpathAdapter,
private readonly shouldUseNativeQuery: () => boolean,
private readonly options?: {
strictSdk?: boolean;
allowFallbackToSubprocess?: boolean;
},
) {}
getRegistry(): QueryRegistry {
@@ -36,6 +41,15 @@ export class QueryRuntimeBridge {
}
async execute(input: RuntimeBridgeExecuteInput): Promise<unknown> {
if (this.options?.strictSdk && !this.registry.has(input.registryCommand)) {
throw GSDToolsError.failure(
`Strict SDK mode: command '${input.registryCommand}' has no native adapter`,
input.legacyCommand,
input.legacyArgs,
null,
);
}
return this.executionPolicy.execute({
legacyCommand: input.legacyCommand,
legacyArgs: input.legacyArgs,
@@ -45,6 +59,7 @@ export class QueryRuntimeBridge {
projectDir: input.projectDir,
workstream: input.workstream,
preferNativeQuery: this.shouldUseNativeQuery(),
allowFallbackToSubprocess: this.options?.allowFallbackToSubprocess,
});
}