refactor: deepen GSDTools query execution seams (#3085)

* refactor: deepen gsdtools query execution seams

* docs: add changeset for query seam deepening

* docs: fix changeset summary text

* fix: address coderabbit query seam findings

* test: address remaining coderabbit findings and notes

* refactor: use internal gsdtools error type import
This commit is contained in:
Tom Boucher
2026-05-03 18:56:41 -04:00
committed by GitHub
parent 5e21bf7567
commit 42ed7cee8d
24 changed files with 871 additions and 445 deletions

View File

@@ -0,0 +1,42 @@
import { resolveTransportPolicy } from './gsd-transport-policy.js';
import type { GSDTransport } from './gsd-transport.js';
import type { TransportMode } from './gsd-transport-policy.js';
export interface QueryExecutionRequest {
legacyCommand: string;
legacyArgs: string[];
registryCommand: string;
registryArgs: string[];
mode: TransportMode;
projectDir: string;
workstream?: string;
preferNativeQuery: boolean;
}
/**
* Execution policy for query command dispatch.
* Owns routing decision inputs for native/subprocess dispatch.
*/
export class QueryExecutionPolicy {
constructor(private readonly transport: GSDTransport) {}
async execute(request: QueryExecutionRequest): Promise<unknown> {
const policy = resolveTransportPolicy(request.registryCommand);
return this.transport.run(
{
legacyCommand: request.legacyCommand,
legacyArgs: request.legacyArgs,
registryCommand: request.registryCommand,
registryArgs: request.registryArgs,
mode: request.mode,
projectDir: request.projectDir,
workstream: request.workstream,
},
{
preferNative: request.preferNativeQuery && policy.preferNative,
allowFallbackToSubprocess: policy.allowFallbackToSubprocess,
},
);
}
}