@open-qa/qa 0.1.0-alpha.3 → 0.1.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/THIRD_PARTY.md +5 -0
  2. package/drizzle/0017_provider_notifications.sql +13 -0
  3. package/drizzle/0018_classification_registry.sql +39 -0
  4. package/drizzle/0019_trial_audit.sql +44 -0
  5. package/drizzle/meta/0017_snapshot.json +2092 -0
  6. package/drizzle/meta/0018_snapshot.json +2102 -0
  7. package/drizzle/meta/0019_snapshot.json +2451 -0
  8. package/drizzle/meta/_journal.json +21 -0
  9. package/package.json +12 -7
  10. package/src/access-binding.d.ts +8 -0
  11. package/src/access-binding.js +26 -0
  12. package/src/adapters/classification-write.d.ts +87 -0
  13. package/src/adapters/classification-write.js +64 -0
  14. package/src/adapters/e2b-executor.js +4 -0
  15. package/src/adapters/file-run-store.d.ts +186 -41
  16. package/src/adapters/file-run-store.js +87 -19
  17. package/src/adapters/file-trial-audit.d.ts +280 -0
  18. package/src/adapters/file-trial-audit.js +105 -0
  19. package/src/adapters/pg-classification-store.d.ts +98 -20
  20. package/src/adapters/pg-classification-store.js +84 -44
  21. package/src/adapters/pg-run-store.d.ts +1 -0
  22. package/src/adapters/pg-run-store.js +70 -9
  23. package/src/adapters/run-metadata.d.ts +2 -0
  24. package/src/adapters/run-metadata.js +10 -0
  25. package/src/adapters/secret-manager-credential-resolver.d.ts +1 -1
  26. package/src/attempt-audit.d.ts +363 -0
  27. package/src/attempt-audit.js +253 -0
  28. package/src/audit-command.d.ts +13 -0
  29. package/src/audit-command.js +77 -0
  30. package/src/classification-command.d.ts +14 -9
  31. package/src/classification-command.js +119 -26
  32. package/src/classification-model.d.ts +10 -3
  33. package/src/classification-model.js +40 -24
  34. package/src/classification-notifier.d.ts +4 -3
  35. package/src/classification-notifier.js +26 -6
  36. package/src/classify-runs.d.ts +2 -1
  37. package/src/classify-runs.js +39 -3
  38. package/src/cli-program.js +54 -8
  39. package/src/commands.d.ts +1 -0
  40. package/src/commands.js +2 -0
  41. package/src/db/database.d.ts +7 -0
  42. package/src/db/database.js +15 -0
  43. package/src/db/event-chunks.d.ts +38 -29
  44. package/src/db/flow-status.d.ts +7 -3
  45. package/src/db/flow-status.js +240 -16
  46. package/src/db/queries.d.ts +24 -1
  47. package/src/db/queries.js +22 -0
  48. package/src/db/schema.d.ts +333 -4
  49. package/src/db/schema.js +83 -11
  50. package/src/db/trial-audit.d.ts +526 -0
  51. package/src/db/trial-audit.js +84 -0
  52. package/src/doctor-command.js +2 -1
  53. package/src/draft-api.d.ts +25 -421
  54. package/src/draft-api.js +10 -3
  55. package/src/engine.d.ts +47 -4
  56. package/src/engine.js +97 -8
  57. package/src/execution-snapshot.d.ts +1 -1
  58. package/src/execution-snapshot.js +24 -18
  59. package/src/export-command.d.ts +6 -0
  60. package/src/export-command.js +106 -0
  61. package/src/flow-check.js +1 -1
  62. package/src/flow-loader.d.ts +72 -6
  63. package/src/flow-loader.js +76 -12
  64. package/src/http-stage-client.d.ts +98 -1
  65. package/src/independent-model.js +53 -6
  66. package/src/judge-review-store.d.ts +13 -0
  67. package/src/judge-review-store.js +58 -0
  68. package/src/local-host-executor.d.ts +3 -1
  69. package/src/local-host-executor.js +2 -0
  70. package/src/quarantine-command.d.ts +5 -1
  71. package/src/quarantine-command.js +56 -13
  72. package/src/remote-command.js +2 -0
  73. package/src/report/browser.css +1 -1
  74. package/src/report/browser.js +41 -41
  75. package/src/report/ctrf.d.ts +983 -0
  76. package/src/report/ctrf.js +306 -0
  77. package/src/report/generate.d.ts +1 -1
  78. package/src/report/generate.js +29 -6
  79. package/src/report/load.d.ts +738 -42
  80. package/src/report/load.js +78 -6
  81. package/src/result-notifier.js +1 -1
  82. package/src/result-trace.d.ts +62 -0
  83. package/src/result-trace.js +81 -0
  84. package/src/run-command.d.ts +9 -0
  85. package/src/run-command.js +300 -63
  86. package/src/run-setup-error.d.ts +11 -0
  87. package/src/run-setup-error.js +18 -0
  88. package/src/server/app.js +5 -4
  89. package/src/server/index.d.ts +2 -0
  90. package/src/server/index.js +11 -2
  91. package/src/server/repository.d.ts +166 -29
  92. package/src/server/repository.js +14 -2
  93. package/src/studio-command.d.ts +1 -0
  94. package/src/studio-command.js +11 -0
  95. package/src/studio-control.d.ts +5 -0
  96. package/src/studio-control.js +207 -0
  97. package/src/studio-review.d.ts +24 -0
  98. package/src/studio-review.js +64 -0
  99. package/src/studio-worker.d.ts +1 -0
  100. package/src/studio-worker.js +48 -0
  101. package/src/system-config.d.ts +2 -2
  102. package/src/system-config.js +5 -4
  103. package/src/trial-audit.d.ts +630 -0
  104. package/src/trial-audit.js +272 -0
  105. package/src/visual-baseline.d.ts +4 -0
  106. package/src/visual-baseline.js +42 -0
  107. package/src/webhook-notification.d.ts +15 -0
  108. package/src/webhook-notification.js +61 -0
  109. package/src/worker/execution.d.ts +2 -1
  110. package/src/worker/execution.js +122 -3
  111. package/src/worker/index.d.ts +4 -0
  112. package/src/worker/index.js +10 -1
  113. package/src/worker/quarantine-notifications.js +2 -2
  114. package/src/worker/queue.d.ts +6 -2
  115. package/src/worker/queue.js +80 -19
  116. package/src/worker/result-notifications.d.ts +10 -2
  117. package/src/worker/result-notifications.js +120 -23
  118. package/src/worker/store.js +6 -3
package/src/engine.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { readVisualBaseline } from "./visual-baseline.js";
2
+ import { AttemptAuditCapture } from "./attempt-audit.js";
3
+ import { ReplayReader } from "@open-qa/qa-inspect/server";
1
4
  import { randomUUID } from "node:crypto";
2
5
  import { join } from "node:path";
3
6
  import {
@@ -6,6 +9,7 @@ import {
6
9
  SecretRedactor,
7
10
  ModelJudge,
8
11
  ModelReviewer,
12
+ loadClassificationRegistry,
9
13
  credentialSecrets
10
14
  } from "@open-qa/qa-engine";
11
15
  import { ClaudeCodeRuntime, CodexRuntime, PiRuntime } from "@open-qa/qa-agents";
@@ -86,7 +90,8 @@ function createEngine(options) {
86
90
  ...Object.values(options.stage?.email ?? {}),
87
91
  options.stage?.discord?.botToken ?? "",
88
92
  options.stage?.page?.access?.clientId ?? "",
89
- options.stage?.page?.access?.clientSecret ?? ""
93
+ options.stage?.page?.access?.clientSecret ?? "",
94
+ ...Object.values(options.stage?.page?.accessHeaders?.headers ?? {})
90
95
  ].filter(Boolean);
91
96
  redactor.add([
92
97
  ...privateEnvSecrets(options.env ?? {}, publicEnv),
@@ -102,6 +107,8 @@ function createEngine(options) {
102
107
  placement: null,
103
108
  capabilities: null
104
109
  };
110
+ const visualBaseline = options.visualBaseline;
111
+ const flowRevision = options.flowRevision;
105
112
  const stageOptions = { ...options.stage, redactions: stageSecrets };
106
113
  const e2b = options.placement === "e2b" && !options.executor ? new E2bExecutor({
107
114
  ...requiredE2bOptions(options),
@@ -131,13 +138,68 @@ function createEngine(options) {
131
138
  return session;
132
139
  }
133
140
  });
134
- const store = options.runStore ?? new FileRunStore(options.root);
135
- const history = options.runHistory ?? (store.listRuns ? { listRuns: store.listRuns.bind(store) } : void 0);
136
- const classifications = options.classifications ?? (store instanceof FileRunStore ? store : void 0);
141
+ const scope = options.classificationScope ?? (options.runStore instanceof FileRunStore ? options.runStore.classificationScope : loadClassificationRegistry().forProject("local"));
142
+ const physicalStore = options.runStore ?? new FileRunStore(options.root, scope);
143
+ const history = options.runHistory ?? (physicalStore.listRuns ? { listRuns: physicalStore.listRuns.bind(physicalStore) } : void 0);
144
+ const classifications = options.classifications ?? (physicalStore instanceof FileRunStore ? physicalStore : void 0);
145
+ const captures = /* @__PURE__ */ new Map();
146
+ const views = /* @__PURE__ */ new Map();
147
+ const store = {
148
+ async createRun(run) {
149
+ activeHandle = void 0;
150
+ observation.runtime = null;
151
+ observation.placement = null;
152
+ observation.credentialSource = null;
153
+ observation.modelAccess = null;
154
+ await physicalStore.createRun(run);
155
+ captures.set(run.id, new AttemptAuditCapture());
156
+ views.set(run.id, []);
157
+ },
158
+ async appendEvents(id, events) {
159
+ await physicalStore.appendEvents(id, events);
160
+ captures.get(id)?.record(events);
161
+ },
162
+ async finishRun(id, result) {
163
+ const audit = captures.get(id)?.document();
164
+ const opened = views.get(id) ?? [];
165
+ const replay = opened.length ? await new ReplayReader(options.root, `runs/${id}/stage/`).manifest().catch(() => null) : null;
166
+ const environment = {
167
+ image: {
168
+ template: activeHandle?.image?.template ?? null,
169
+ digest: activeHandle?.image?.digest ?? null
170
+ },
171
+ runtime: observation.runtime,
172
+ views: opened.map(({ view, viewport, browser, device }) => ({
173
+ view,
174
+ viewport: viewport ?? null,
175
+ browser: browser ?? replay?.views.find((recording) => recording.view === view)?.browser ?? null,
176
+ device: device ?? null
177
+ }))
178
+ };
179
+ const browserViews = opened.flatMap(
180
+ ({ actor, view, browserSettings }) => browserSettings ? [
181
+ {
182
+ actor,
183
+ view,
184
+ device: { ...browserSettings, userAgent: redactor.text(browserSettings.userAgent) }
185
+ }
186
+ ] : []
187
+ );
188
+ await physicalStore.finishRun(id, {
189
+ ...result,
190
+ ...browserViews.length > 0 && { browserViews },
191
+ ...audit && { attemptAudit: redactor.json({ ...audit, environment }) }
192
+ });
193
+ captures.delete(id);
194
+ views.delete(id);
195
+ },
196
+ recordClassifierUsage: physicalStore.recordClassifierUsage?.bind(physicalStore)
197
+ };
137
198
  const pendingNotifications = [];
138
199
  const classifying = classifications ? new ClassifyingRuns({
139
200
  store,
140
201
  classifications,
202
+ scope,
141
203
  redactor,
142
204
  classifier: options.classifier ?? new ModelClassifier(
143
205
  new IndependentModelCaller({
@@ -150,7 +212,12 @@ function createEngine(options) {
150
212
  localAccess: modelAccess === "env" ? options.modelCredentials : void 0,
151
213
  requireTeam: options.origin === "server"
152
214
  }),
153
- { ...options.classifierConfig, redactor }
215
+ {
216
+ ...options.classifierConfig,
217
+ modelVersion: options.classifierConfig?.model,
218
+ scope,
219
+ redactor
220
+ }
154
221
  ),
155
222
  diff: async (flow) => {
156
223
  let reason = "Run store has no classification history reader; inject runHistory";
@@ -249,6 +316,18 @@ function createEngine(options) {
249
316
  hostEnv: options.env
250
317
  }),
251
318
  connectStage: (handle) => options.connectStage?.(handle) ?? e2b?.connectStage(handle) ?? new HttpStageClient(handle),
319
+ ...visualBaseline && flowRevision && {
320
+ visualBaseline: ({ attemptId, check, device }, signal) => readVisualBaseline(
321
+ options.root,
322
+ {
323
+ attemptId,
324
+ key: { ...visualBaseline, caseRevision: flowRevision, check, device }
325
+ },
326
+ signal
327
+ )
328
+ },
329
+ onViewOpened: (id, view) => views.get(id)?.push(view),
330
+ onUsage: (id, role, usage, context) => captures.get(id)?.recordUsage(role, usage, context),
252
331
  placement: options.placement ?? "local-host",
253
332
  clock: { now: Date.now },
254
333
  ids: {
@@ -275,7 +354,10 @@ function createEngine(options) {
275
354
  const records = await Promise.all(
276
355
  result.runs.map((run) => classifications?.getClassification(run.runId))
277
356
  );
278
- const category = records.find((record) => record?.classification?.category === "flaky")?.classification?.category ?? records.findLast((record) => record?.classification)?.classification?.category ?? null;
357
+ const observed = records.find((record) => record?.classification?.flakiness === "observed");
358
+ const effective = (observed ?? records.findLast((record) => record?.classification))?.classification;
359
+ const category = effective?.category ?? null;
360
+ const taxonomy = effective?.taxonomy;
279
361
  let state;
280
362
  try {
281
363
  state = await options.flowStatus?.record({
@@ -283,11 +365,17 @@ function createEngine(options) {
283
365
  executionId: result.runId,
284
366
  verdict: result.verdict,
285
367
  category,
368
+ flakiness: effective?.flakiness,
286
369
  owner: options.classificationOwners?.flowOwner,
287
- ...options.flowRevision && { revision: options.flowRevision }
370
+ ...options.flowRevision && { revision: options.flowRevision },
371
+ quarantine: {
372
+ policy: options.quarantine,
373
+ caseId: options.quarantineCaseId,
374
+ target: options.quarantineTarget
375
+ }
288
376
  });
289
377
  } catch {
290
- throw new FlowStatusWriteError({ ...result, category });
378
+ throw new FlowStatusWriteError({ ...result, category, taxonomy });
291
379
  }
292
380
  if (!state?.quarantined)
293
381
  for (const run of pendingNotifications.splice(0)) {
@@ -304,6 +392,7 @@ function createEngine(options) {
304
392
  return {
305
393
  ...result,
306
394
  category,
395
+ taxonomy,
307
396
  quarantined: state?.quarantined ?? false,
308
397
  lifecycle: state?.status
309
398
  };
@@ -6,7 +6,7 @@ export declare function captureExecutionSnapshot(input: {
6
6
  definitions: LoadedFlow["definitions"];
7
7
  plan: ExecutionPlan;
8
8
  targetName: string;
9
- runtime: "claude-code" | "codex";
9
+ runtime: "claude-code" | "codex" | "pi";
10
10
  retries: 0 | 1;
11
11
  placement?: "local-host" | "e2b";
12
12
  agentAt?: "host" | "stage";
@@ -1,3 +1,4 @@
1
+ import { isProtectedTarget } from "@open-qa/qa-engine";
1
2
  import { execFile } from "node:child_process";
2
3
  import { readFile } from "node:fs/promises";
3
4
  import { promisify } from "node:util";
@@ -49,8 +50,13 @@ function captureExecutionSnapshot(input) {
49
50
  const value = Intl.DateTimeFormat().resolvedOptions().timeZone;
50
51
  zone = value ? { value, source: "machine" } : { value: "UTC", source: "fallback" };
51
52
  }
53
+ const webDevices = Object.fromEntries(
54
+ Object.entries(plan.views).flatMap(([view, spec]) => spec.device ? [[view, spec.device]] : [])
55
+ );
56
+ const hasDevice = Object.keys(webDevices).length > 0;
57
+ const schemaVersion = hasDevice || input.runtime === "pi" ? 8 : 7;
52
58
  const snapshot = executionSnapshotSchema.parse({
53
- schemaVersion: 6,
59
+ schemaVersion,
54
60
  capturedAt: Date.now(),
55
61
  projectId: config.projectId,
56
62
  timeZone: zone,
@@ -61,7 +67,7 @@ function captureExecutionSnapshot(input) {
61
67
  origin: new URL(target.url).origin,
62
68
  allow: target.allow,
63
69
  access: target.access ?? "none",
64
- prodSafeOnly: targetName === "prod" || !!target.prodSafeOnly
70
+ prodSafeOnly: isProtectedTarget(targetName, target)
65
71
  },
66
72
  effective: {
67
73
  prod: plan.prod,
@@ -73,6 +79,7 @@ function captureExecutionSnapshot(input) {
73
79
  level: input.level ?? null
74
80
  },
75
81
  declared: {
82
+ ...hasDevice && { webDevices },
76
83
  heal: {
77
84
  runtime: config.heal?.runtime ?? input.runtime,
78
85
  model: config.heal?.model ?? null,
@@ -84,11 +91,13 @@ function captureExecutionSnapshot(input) {
84
91
  placement: input.placement ?? "local-host",
85
92
  capabilities: {
86
93
  surfaces: [...new Set(Object.values(plan.views).map((view) => view.surface))],
94
+ providers: plan.providers ?? [],
87
95
  recording: ["rrweb"],
88
96
  levels: ["semantic", "pixel", "hybrid"]
89
97
  }
90
98
  },
91
99
  observed: {
100
+ ...schemaVersion === 8 && { browserViews: [] },
92
101
  runtime: null,
93
102
  modelAccess: null,
94
103
  credentialSource: null,
@@ -113,26 +122,23 @@ function captureExecutionSnapshot(input) {
113
122
  throw new Error(
114
123
  "Execution snapshot contains sensitive configuration in public identity fields"
115
124
  );
116
- if ((snapshot.schemaVersion === 5 || snapshot.schemaVersion === 6) && snapshot.declared.heal.model)
125
+ if ((snapshot.schemaVersion === 5 || snapshot.schemaVersion === 6 || snapshot.schemaVersion === 7 || snapshot.schemaVersion === 8) && snapshot.declared.heal.model)
117
126
  snapshot.declared.heal.model = redactor.text(snapshot.declared.heal.model);
118
127
  const revision = (value) => value ? { ...value, source: redactor.text(value.source) } : null;
119
- return {
120
- ...snapshot,
121
- definitions: {
122
- flow: {
123
- ...snapshot.definitions.flow,
124
- source: redactor.text(snapshot.definitions.flow.source)
125
- },
126
- suite: revision(snapshot.definitions.suite),
127
- config: revision(snapshot.definitions.config)
128
+ snapshot.definitions = {
129
+ flow: {
130
+ ...snapshot.definitions.flow,
131
+ source: redactor.text(snapshot.definitions.flow.source)
128
132
  },
129
- target: {
130
- ...snapshot.target,
131
- name: redactor.text(snapshot.target.name),
132
- origin: snapshot.target.origin && redactor.text(snapshot.target.origin) === snapshot.target.origin ? snapshot.target.origin : null,
133
- allow: snapshot.target.allow.map((host) => redactor.text(host))
134
- }
133
+ suite: revision(snapshot.definitions.suite),
134
+ config: revision(snapshot.definitions.config)
135
135
  };
136
+ const { target: snapshotTarget } = snapshot;
137
+ snapshotTarget.name = redactor.text(snapshotTarget.name);
138
+ if (snapshotTarget.origin && redactor.text(snapshotTarget.origin) !== snapshotTarget.origin)
139
+ snapshotTarget.origin = null;
140
+ snapshotTarget.allow = snapshotTarget.allow.map((host) => redactor.text(host));
141
+ return snapshot;
136
142
  }
137
143
  export {
138
144
  captureExecutionSnapshot,
@@ -0,0 +1,6 @@
1
+ export declare function exportCommand(input: string, options: {
2
+ batch?: boolean;
3
+ root?: string;
4
+ postgres?: boolean;
5
+ project?: string;
6
+ }): Promise<number>;
@@ -0,0 +1,106 @@
1
+ import { readResultTrace } from "@open-qa/qa-engine/protocol";
2
+ import { FileRunStore } from "./adapters/file-run-store.js";
3
+ import { FileTrialAudit } from "./adapters/file-trial-audit.js";
4
+ import { QaDatabase } from "./db/database.js";
5
+ import { PgQueries } from "./db/queries.js";
6
+ import { PgTrialAudit } from "./db/trial-audit.js";
7
+ import { loadConfig } from "./flow-loader.js";
8
+ import { readJudgeReviews } from "./judge-review-store.js";
9
+ import { publicId } from "./public-id.js";
10
+ import { buildCtrfReport, selectReportAttempts } from "./report/ctrf.js";
11
+ import { PgFlowStatus } from "./db/flow-status.js";
12
+ import { summarizeTrial } from "./trial-audit.js";
13
+ async function exportCommand(input, options) {
14
+ const id = publicId.parse(input);
15
+ const root = options.root ?? ".qa";
16
+ const batch = options.batch ?? false;
17
+ const config = await loadConfig(root).catch(() => void 0);
18
+ const project = options.project ?? (options.postgres ? process.env.QA_PROJECT_ID : void 0) ?? config?.projectId;
19
+ if (project !== void 0) publicId.parse(project);
20
+ let database;
21
+ if (options.postgres) {
22
+ if (!project || !process.env.QA_DATABASE_URL)
23
+ throw new Error("PostgreSQL export requires a project ID and QA_DATABASE_URL");
24
+ database = new QaDatabase(process.env.QA_DATABASE_URL);
25
+ }
26
+ try {
27
+ const candidates = database ? await new PgQueries(database, project).reportAttempts(id, batch) : await new FileRunStore(root).listRuns(Number.MAX_SAFE_INTEGER);
28
+ const attempts = selectReportAttempts(candidates, id, batch);
29
+ const trialScope = (scope) => database ? new PgTrialAudit(database, scope) : new FileTrialAudit(root, scope);
30
+ const groups = /* @__PURE__ */ new Map();
31
+ const addGroup = (projectId, groupId) => groups.set(JSON.stringify([projectId, groupId]), { projectId, groupId });
32
+ const attemptScopes = /* @__PURE__ */ new Map();
33
+ for (const { run } of attempts) {
34
+ const trace = readResultTrace(run.metadata?.resultTrace);
35
+ if (trace.status !== "recorded") continue;
36
+ const { projectId, trial } = trace.trace;
37
+ attemptScopes.set(run.id, projectId);
38
+ if (trial) addGroup(projectId, trial.groupId);
39
+ }
40
+ if (batch) {
41
+ for (const scope of /* @__PURE__ */ new Set([project ?? "local", ...attemptScopes.values()]))
42
+ for (const group of await trialScope(scope).list())
43
+ if (group.batchId === id) addGroup(scope, group.groupId);
44
+ }
45
+ const trials = [];
46
+ const quarantined = /* @__PURE__ */ new Map();
47
+ for (const { projectId, groupId } of groups.values()) {
48
+ const history = await trialScope(projectId).get(groupId);
49
+ if (!history) continue;
50
+ trials.push(summarizeTrial(history));
51
+ for (const receipt of history.receipts)
52
+ if (receipt.kind === "trial-finished")
53
+ quarantined.set(receipt.attemptId, receipt.quarantined);
54
+ }
55
+ if (!attempts.length && !trials.length)
56
+ throw new Error(`${batch ? "Batch" : "Run"} not found: ${id}`);
57
+ const reviewed = await Promise.all(
58
+ attempts.map(async (item) => {
59
+ const scope = attemptScopes.get(item.run.id);
60
+ const local = item.run.metadata?.flowQuarantined;
61
+ return {
62
+ ...item,
63
+ quarantined: ("quarantined" in item ? item.quarantined : void 0) ?? quarantined.get(item.run.id) ?? (typeof local === "boolean" ? local : void 0),
64
+ judgeReviews: scope ? await readJudgeReviews(root, database, scope, item.run.id) : []
65
+ };
66
+ })
67
+ );
68
+ const overdue = /* @__PURE__ */ new Map();
69
+ if (database) {
70
+ const flows = /* @__PURE__ */ new Set([
71
+ ...attempts.map(({ run }) => run.flow),
72
+ ...trials.map(({ group }) => group.flow)
73
+ ]);
74
+ const quarantines = await new PgFlowStatus(database, project).list([...flows]);
75
+ for (const { flow, quarantineDeadline } of quarantines)
76
+ if (quarantineDeadline?.overdue) overdue.set(flow, quarantineDeadline.expiresAt);
77
+ } else {
78
+ for (const { run } of attempts) {
79
+ const expiresAt = run.metadata?.flowQuarantineOverdueSince;
80
+ if (typeof expiresAt === "number") overdue.set(run.flow, expiresAt);
81
+ }
82
+ }
83
+ console.log(
84
+ JSON.stringify(
85
+ buildCtrfReport(reviewed, {
86
+ id,
87
+ project,
88
+ trials,
89
+ quarantineOverdue: [...overdue].map(([flow, expiresAt]) => ({ flow, expiresAt })),
90
+ ...!batch && { relatedAttempts: candidates }
91
+ }),
92
+ null,
93
+ 2
94
+ )
95
+ );
96
+ return 0;
97
+ } catch (error) {
98
+ if (database) throw new Error("Could not read PostgreSQL QA results for export");
99
+ throw error;
100
+ } finally {
101
+ await database?.close();
102
+ }
103
+ }
104
+ export {
105
+ exportCommand
106
+ };
package/src/flow-check.js CHANGED
@@ -29,7 +29,7 @@ async function checkFlows(path, options) {
29
29
  let warnings = 0;
30
30
  for (const document of documents) {
31
31
  try {
32
- compile(document.flow);
32
+ compile(document.flow, void 0, { providers: document.providers });
33
33
  } catch (error) {
34
34
  if (!(error instanceof CompileError)) throw error;
35
35
  diagnostics.push(...error.issues.map((issue) => document.diagnostic(issue, "compile")));
@@ -1,9 +1,10 @@
1
- import { type FlowSpec, type DefinitionRevision } from "@open-qa/qa-engine";
1
+ import { type ProviderRegistry, type FlowSpec, type DefinitionRevision } from "@open-qa/qa-engine";
2
2
  import { type ValidationIssue } from "./flow-source.js";
3
3
  export declare function findQaRoot(file: string): string;
4
4
  export interface LoadedFlow {
5
5
  flow: FlowSpec;
6
6
  programSource?: string;
7
+ providers?: ProviderRegistry;
7
8
  definitions: {
8
9
  flow: DefinitionRevision;
9
10
  suite: DefinitionRevision | null;
@@ -12,10 +13,10 @@ export interface LoadedFlow {
12
13
  diagnostic(issue: ValidationIssue, rule: string): string;
13
14
  }
14
15
  export declare function loadFlow(file: string, qaRoot?: string): Promise<FlowSpec>;
15
- export declare function loadFlowDocument(file: string, qaRoot?: string): Promise<LoadedFlow>;
16
+ export declare function loadFlowDocument(file: string, qaRoot?: string, registry?: ProviderRegistry): Promise<LoadedFlow>;
16
17
  export declare function loadFlows(qaRoot: string, directory?: string): Promise<FlowSpec[]>;
17
- export declare function loadFlowDocuments(qaRoot: string, directory?: string, onError?: (error: unknown) => void): Promise<LoadedFlow[]>;
18
- export declare function loadConfig(qaRoot: string): Promise<{
18
+ export declare function loadFlowDocuments(qaRoot: string, directory?: string, onError?: (error: unknown) => void, registry?: ProviderRegistry): Promise<LoadedFlow[]>;
19
+ export declare function loadConfig(qaRoot: string, providers?: ProviderRegistry): Promise<{
19
20
  budgets?: Partial<Record<"T1" | "T2" | "T3" | "T4", {
20
21
  actions?: number | undefined;
21
22
  minutes?: number | undefined;
@@ -38,6 +39,19 @@ export declare function loadConfig(qaRoot: string): Promise<{
38
39
  screenshots: boolean;
39
40
  model?: string | undefined;
40
41
  } | undefined;
42
+ judgeReviewers?: string[] | undefined;
43
+ quarantine?: {
44
+ flakyStreak: number;
45
+ expiresAfterHours: number;
46
+ evidenceMaxAgeHours: number;
47
+ minimumPassedTrials: number;
48
+ releaseActors: string[];
49
+ flows: Record<string, {
50
+ owner?: string | undefined;
51
+ reason?: string | undefined;
52
+ fixIssue?: string | undefined;
53
+ }>;
54
+ } | undefined;
41
55
  classifier?: {
42
56
  screenshots: boolean;
43
57
  timeoutMs: number;
@@ -69,13 +83,31 @@ export declare function loadConfig(qaRoot: string): Promise<{
69
83
  views?: string[] | undefined;
70
84
  persona?: string | undefined;
71
85
  count?: number | undefined;
72
- tools?: ("db" | "logs" | "github" | "http")[] | undefined;
86
+ tools?: string[] | undefined;
73
87
  }> | undefined;
74
88
  views?: Record<string, {
75
89
  surface: string;
76
90
  start?: string | undefined;
77
91
  chat?: string | undefined;
78
92
  owner?: string | undefined;
93
+ device?: {
94
+ browser?: "chromium" | undefined;
95
+ preset?: "desktop" | "mobile" | undefined;
96
+ viewport?: {
97
+ width: number;
98
+ height: number;
99
+ } | undefined;
100
+ userAgent?: string | undefined;
101
+ hasTouch?: boolean | undefined;
102
+ isMobile?: boolean | undefined;
103
+ locale?: string | undefined;
104
+ colorScheme?: "light" | "dark" | undefined;
105
+ deviceScaleFactor?: number | undefined;
106
+ } | undefined;
107
+ popup?: {
108
+ allowedOrigins: string[];
109
+ callbackOrigin?: string | undefined;
110
+ } | undefined;
79
111
  }> | undefined;
80
112
  setup?: {
81
113
  hook: string;
@@ -86,6 +118,40 @@ export declare function loadConfig(qaRoot: string): Promise<{
86
118
  params?: Record<string, import("zod").JSONType> | undefined;
87
119
  }[] | undefined;
88
120
  expect_always?: ({
121
+ "web.trace": {
122
+ scope: "view" | "step";
123
+ operation: "web_goto" | "web_back" | "web_reload" | "web_click" | "web_fill" | "web_press" | "web_select" | "web_scroll" | "web_wait_for" | "web_open_window" | "web_callback";
124
+ outcome: "passed" | "failed";
125
+ within?: string | undefined;
126
+ view?: string | undefined;
127
+ };
128
+ } | {
129
+ "web.network": {
130
+ scope: "view" | "step";
131
+ method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
132
+ path: string;
133
+ status: number;
134
+ within?: string | undefined;
135
+ view?: string | undefined;
136
+ };
137
+ } | {
138
+ "web.visual": {
139
+ baseline: string;
140
+ maxDiffRatio: number;
141
+ mask: string[];
142
+ view?: string | undefined;
143
+ };
144
+ } | {
145
+ "web.a11y": {
146
+ tags: ("wcag2a" | "wcag2aa" | "wcag21a" | "wcag21aa" | "wcag22aa" | "best-practice")[];
147
+ exemptions: {
148
+ rule: string;
149
+ target: string;
150
+ reason: string;
151
+ }[];
152
+ view?: string | undefined;
153
+ };
154
+ } | {
89
155
  "web.url": {
90
156
  matches: string;
91
157
  view?: string | undefined;
@@ -205,7 +271,7 @@ export declare function loadConfig(qaRoot: string): Promise<{
205
271
  url: string;
206
272
  allow: string[];
207
273
  revision?: string | undefined;
208
- access?: "cloudflare" | undefined;
274
+ access?: string | undefined;
209
275
  prodSafeOnly?: boolean | undefined;
210
276
  systems?: {
211
277
  db?: string | undefined;