Skip to content

Commit d23558e

Browse files
committed
docs: document qa runtime facade contracts
1 parent 2f00fbf commit d23558e

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/plugin-sdk/qa-channel.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,53 +97,69 @@ function loadFacadeModule(): FacadeModule {
9797
});
9898
}
9999

100+
/** Build a QA bus target string from conversation and optional thread parts. */
100101
export const buildQaTarget: FacadeModule["buildQaTarget"] = ((...args) =>
101102
loadFacadeModule().buildQaTarget(...args)) as FacadeModule["buildQaTarget"];
102103

104+
/** Format a QA bus target string for display and CLI output. */
103105
export const formatQaTarget: FacadeModule["buildQaTarget"] = ((...args) =>
104106
loadFacadeModule().buildQaTarget(...args)) as FacadeModule["buildQaTarget"];
105107

108+
/** Create a QA bus thread through the bundled QA channel facade. */
106109
export const createQaBusThread: FacadeModule["createQaBusThread"] = ((...args) =>
107110
loadFacadeModule().createQaBusThread(...args)) as FacadeModule["createQaBusThread"];
108111

112+
/** Delete a QA bus message through the bundled QA channel facade. */
109113
export const deleteQaBusMessage: FacadeModule["deleteQaBusMessage"] = ((...args) =>
110114
loadFacadeModule().deleteQaBusMessage(...args)) as FacadeModule["deleteQaBusMessage"];
111115

116+
/** Edit a QA bus message through the bundled QA channel facade. */
112117
export const editQaBusMessage: FacadeModule["editQaBusMessage"] = ((...args) =>
113118
loadFacadeModule().editQaBusMessage(...args)) as FacadeModule["editQaBusMessage"];
114119

120+
/** Read the current QA bus state snapshot. */
115121
export const getQaBusState: FacadeModule["getQaBusState"] = ((...args) =>
116122
loadFacadeModule().getQaBusState(...args)) as FacadeModule["getQaBusState"];
117123

124+
/** Inject an inbound QA bus message for channel and gateway tests. */
118125
export const injectQaBusInboundMessage: FacadeModule["injectQaBusInboundMessage"] = ((...args) =>
119126
loadFacadeModule().injectQaBusInboundMessage(
120127
...args,
121128
)) as FacadeModule["injectQaBusInboundMessage"];
122129

130+
/** Normalize a user-provided QA target string when possible. */
123131
export const normalizeQaTarget: FacadeModule["normalizeQaTarget"] = ((...args) =>
124132
loadFacadeModule().normalizeQaTarget(...args)) as FacadeModule["normalizeQaTarget"];
125133

134+
/** Parse a QA target string into chat type, conversation id, and optional thread id. */
126135
export const parseQaTarget: FacadeModule["parseQaTarget"] = ((...args) =>
127136
loadFacadeModule().parseQaTarget(...args)) as FacadeModule["parseQaTarget"];
128137

138+
/** Poll the QA bus for new messages from a cursor. */
129139
export const pollQaBus: FacadeModule["pollQaBus"] = ((...args) =>
130140
loadFacadeModule().pollQaBus(...args)) as FacadeModule["pollQaBus"];
131141

142+
/** Lazy QA channel plugin object used by plugin loader tests. */
132143
export const qaChannelPlugin: FacadeModule["qaChannelPlugin"] = createLazyFacadeObjectValue(
133144
() => loadFacadeModule().qaChannelPlugin,
134145
);
135146

147+
/** Add a reaction to a QA bus message. */
136148
export const reactToQaBusMessage: FacadeModule["reactToQaBusMessage"] = ((...args) =>
137149
loadFacadeModule().reactToQaBusMessage(...args)) as FacadeModule["reactToQaBusMessage"];
138150

151+
/** Read one QA bus message by id. */
139152
export const readQaBusMessage: FacadeModule["readQaBusMessage"] = ((...args) =>
140153
loadFacadeModule().readQaBusMessage(...args)) as FacadeModule["readQaBusMessage"];
141154

155+
/** Search QA bus messages using the bundled channel facade. */
142156
export const searchQaBusMessages: FacadeModule["searchQaBusMessages"] = ((...args) =>
143157
loadFacadeModule().searchQaBusMessages(...args)) as FacadeModule["searchQaBusMessages"];
144158

159+
/** Send an outbound QA bus message with optional attachments and tool calls. */
145160
export const sendQaBusMessage: FacadeModule["sendQaBusMessage"] = ((...args) =>
146161
loadFacadeModule().sendQaBusMessage(...args)) as FacadeModule["sendQaBusMessage"];
147162

163+
/** Install a test runtime implementation into the bundled QA channel facade. */
148164
export const setQaChannelRuntime: FacadeModule["setQaChannelRuntime"] = ((...args) =>
149165
loadFacadeModule().setQaChannelRuntime(...args)) as FacadeModule["setQaChannelRuntime"];

src/plugin-sdk/qa-runtime.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function isMissingQaRuntimeError(error: unknown) {
3030
);
3131
}
3232

33+
/** Load the bundled QA lab runtime surface, throwing when the private bundle is absent. */
3334
export function loadQaRuntimeModule(): QaRuntimeSurface {
3435
const env = resolvePrivateQaBundledPluginsEnv();
3536
return loadBundledPluginPublicSurfaceModuleSync<QaRuntimeSurface>({
@@ -39,6 +40,7 @@ export function loadQaRuntimeModule(): QaRuntimeSurface {
3940
});
4041
}
4142

43+
/** Check whether the bundled QA lab runtime surface is present without hiding other load errors. */
4244
export function isQaRuntimeAvailable(): boolean {
4345
try {
4446
loadQaRuntimeModule();
@@ -51,6 +53,7 @@ export function isQaRuntimeAvailable(): boolean {
5153
}
5254
}
5355

56+
/** Normalized options passed from live-transport QA CLIs into lane runners. */
5457
export type LiveTransportQaCommandOptions = {
5558
repoRoot?: string;
5659
outputDir?: string;
@@ -85,16 +88,19 @@ type LiveTransportQaCommanderOptions = {
8588
credentialRole?: string;
8689
};
8790

91+
/** Commander registration hook for one live-transport QA subcommand. */
8892
export type LiveTransportQaCliRegistration = {
8993
commandName: string;
9094
register(qa: Command): void;
9195
};
9296

97+
/** Help text customizations for live credential source and role flags. */
9398
export type LiveTransportQaCredentialCliOptions = {
9499
sourceDescription?: string;
95100
roleDescription?: string;
96101
};
97102

103+
/** Declarative command metadata and runner used to install a live-transport QA CLI. */
98104
export type LiveTransportQaCliRegistrationOptions = {
99105
commandName: string;
100106
credentialOptions?: LiveTransportQaCredentialCliOptions;
@@ -111,6 +117,7 @@ export type LiveTransportQaCliRegistrationOptions = {
111117
run: (opts: LiveTransportQaCommandOptions) => Promise<void>;
112118
};
113119

120+
/** Memoize a lazy CLI runtime import so repeated command paths share one loaded module. */
114121
export function createLazyCliRuntimeLoader<T>(load: () => Promise<T>) {
115122
let promise: Promise<T> | null = null;
116123
return async () => {
@@ -195,6 +202,7 @@ function registerLiveTransportQaCli(
195202
});
196203
}
197204

205+
/** Build a Commander registration object for one live-transport QA command. */
198206
export function createLiveTransportQaCliRegistration(
199207
params: LiveTransportQaCliRegistrationOptions,
200208
): LiveTransportQaCliRegistration {
@@ -209,12 +217,14 @@ export function createLiveTransportQaCliRegistration(
209217
};
210218
}
211219

220+
/** One top-level check row in a rendered QA markdown report. */
212221
export type QaReportCheck = {
213222
name: string;
214223
status: "pass" | "fail" | "skip";
215224
details?: string;
216225
};
217226

227+
/** One scenario section in a rendered QA markdown report. */
218228
export type QaReportScenario = {
219229
name: string;
220230
status: "pass" | "fail" | "skip";
@@ -231,12 +241,14 @@ export {
231241
type LiveTransportStandardScenarioId,
232242
} from "./qa-live-transport-scenarios.js";
233243

244+
/** Docker command runner abstraction used by QA Docker helpers and tests. */
234245
export type QaDockerRunCommand = (
235246
command: string,
236247
args: string[],
237248
cwd: string,
238249
) => Promise<{ stdout: string; stderr: string }>;
239250

251+
/** Minimal fetch-like health probe used by QA Docker runtime helpers. */
240252
export type QaDockerFetchLike = (input: string) => Promise<{ ok: boolean }>;
241253

242254
const DEFAULT_QA_DOCKER_COMMAND_TIMEOUT_MS = 120_000;
@@ -250,6 +262,7 @@ function pushQaReportDetailsBlock(lines: string[], label: string, details: strin
250262
lines.push("", "```text", details, "```");
251263
}
252264

265+
/** Render checks, scenarios, timeline, and notes into the standard QA markdown report format. */
253266
export function renderQaMarkdownReport(params: {
254267
title: string;
255268
startedAt: Date;
@@ -329,10 +342,12 @@ export function renderQaMarkdownReport(params: {
329342
return lines.join("\n");
330343
}
331344

345+
/** Append a formatted live-lane issue while preserving the caller-owned issue list. */
332346
export function appendQaLiveLaneIssue(issues: string[], label: string, error: unknown) {
333347
issues.push(`${label}: ${formatErrorMessage(error)}`);
334348
}
335349

350+
/** Format a live-lane failure message that includes artifact labels and paths. */
336351
export function buildQaLiveLaneArtifactsError(params: {
337352
heading: string;
338353
artifacts: Record<string, string>;
@@ -346,6 +361,7 @@ export function buildQaLiveLaneArtifactsError(params: {
346361
].join("\n");
347362
}
348363

364+
/** Print live-transport QA artifact paths with a lane label for CI log parsers. */
349365
export function printLiveTransportQaArtifacts(
350366
laneLabel: string,
351367
artifacts: Record<string, string>,
@@ -397,6 +413,7 @@ async function findFreeQaDockerPort() {
397413
});
398414
}
399415

416+
/** Return the preferred Docker host port unless it is unpinned and already occupied. */
400417
export async function resolveQaDockerHostPort(preferredPort: number, pinned: boolean) {
401418
if (pinned || (await isQaDockerPortFree(preferredPort))) {
402419
return preferredPort;
@@ -471,6 +488,7 @@ async function isQaDockerHealthy(url: string, fetchImpl: QaDockerFetchLike) {
471488
}
472489
}
473490

491+
/** Create Docker command, health-check, and compose helpers for QA harnesses. */
474492
export function createQaDockerRuntime(params: {
475493
auditContext: string;
476494
commandTimeoutMs?: number | null;
@@ -639,6 +657,7 @@ export function createQaDockerRuntime(params: {
639657

640658
type ProcessWriteCallback = (err?: Error | null) => void;
641659

660+
/** Tee stdout and stderr into a private artifact file until the returned stop hook runs. */
642661
export async function startLiveTransportQaOutputTee(params: {
643662
fileName: string;
644663
outputDir: string;

0 commit comments

Comments
 (0)