@open-qa/qa 0.0.0-stage → 0.1.0-alpha.4
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.
- package/LICENSE +204 -0
- package/NOTICE +7 -0
- package/THIRD_PARTY.md +12 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/drizzle/0000_qa_core.sql +158 -0
- package/drizzle/0001_run_health.sql +3 -0
- package/drizzle/0002_bounded_cleanup.sql +5 -0
- package/drizzle/0003_step_replay_cache.sql +9 -0
- package/drizzle/0004_credential_expiry.sql +1 -0
- package/drizzle/0005_server_api.sql +19 -0
- package/drizzle/0006_submission_created.sql +3 -0
- package/drizzle/0007_findings.sql +19 -0
- package/drizzle/0008_classification_labels.sql +14 -0
- package/drizzle/0009_job_queue.sql +20 -0
- package/drizzle/0010_result_notifications.sql +13 -0
- package/drizzle/0011_result_notification_retries.sql +5 -0
- package/drizzle/0012_result_notification_flows.sql +44 -0
- package/drizzle/0013_flow_quarantine.sql +35 -0
- package/drizzle/0014_run_budgets.sql +2 -0
- package/drizzle/0015_flow_lifecycle.sql +9 -0
- package/drizzle/0016_open_qa_classification.sql +28 -0
- package/drizzle/meta/0000_snapshot.json +1002 -0
- package/drizzle/meta/0001_snapshot.json +1021 -0
- package/drizzle/meta/0002_snapshot.json +1027 -0
- package/drizzle/meta/0003_snapshot.json +1081 -0
- package/drizzle/meta/0004_snapshot.json +1087 -0
- package/drizzle/meta/0005_snapshot.json +1210 -0
- package/drizzle/meta/0006_snapshot.json +1244 -0
- package/drizzle/meta/0007_snapshot.json +1353 -0
- package/drizzle/meta/0008_snapshot.json +1435 -0
- package/drizzle/meta/0009_snapshot.json +1587 -0
- package/drizzle/meta/0010_snapshot.json +1675 -0
- package/drizzle/meta/0011_snapshot.json +1692 -0
- package/drizzle/meta/0012_snapshot.json +1818 -0
- package/drizzle/meta/0013_snapshot.json +2016 -0
- package/drizzle/meta/0014_snapshot.json +2028 -0
- package/drizzle/meta/0015_snapshot.json +2064 -0
- package/drizzle/meta/0016_snapshot.json +2076 -0
- package/drizzle/meta/_journal.json +125 -0
- package/package.json +118 -4
- package/problem-matcher.json +32 -0
- package/src/adapters/db-lease-pool.d.ts +25 -0
- package/src/adapters/db-lease-pool.js +293 -0
- package/src/adapters/dir-artifact-store.d.ts +9 -0
- package/src/adapters/dir-artifact-store.js +64 -0
- package/src/adapters/e2b-agent.d.ts +7 -0
- package/src/adapters/e2b-agent.js +94 -0
- package/src/adapters/e2b-artifacts.d.ts +3 -0
- package/src/adapters/e2b-artifacts.js +66 -0
- package/src/adapters/e2b-bounded.d.ts +1 -0
- package/src/adapters/e2b-bounded.js +19 -0
- package/src/adapters/e2b-client.d.ts +33 -0
- package/src/adapters/e2b-client.js +114 -0
- package/src/adapters/e2b-executor.d.ts +26 -0
- package/src/adapters/e2b-executor.js +194 -0
- package/src/adapters/e2b-lifetime.d.ts +20 -0
- package/src/adapters/e2b-lifetime.js +73 -0
- package/src/adapters/e2b-prune.d.ts +13 -0
- package/src/adapters/e2b-prune.js +42 -0
- package/src/adapters/file-replay-cache.d.ts +14 -0
- package/src/adapters/file-replay-cache.js +120 -0
- package/src/adapters/file-run-store.d.ts +175 -0
- package/src/adapters/file-run-store.js +280 -0
- package/src/adapters/fixed-lease-pool.d.ts +10 -0
- package/src/adapters/fixed-lease-pool.js +237 -0
- package/src/adapters/gcs/artifact-store.d.ts +49 -0
- package/src/adapters/gcs/artifact-store.js +247 -0
- package/src/adapters/gcs/client.d.ts +22 -0
- package/src/adapters/gcs/client.js +106 -0
- package/src/adapters/gcs/download.d.ts +9 -0
- package/src/adapters/gcs/download.js +43 -0
- package/src/adapters/gcs/index.d.ts +8 -0
- package/src/adapters/gcs/index.js +23 -0
- package/src/adapters/gcs/periodic-flush.d.ts +5 -0
- package/src/adapters/gcs/periodic-flush.js +16 -0
- package/src/adapters/gcs/pg-catalog.d.ts +16 -0
- package/src/adapters/gcs/pg-catalog.js +149 -0
- package/src/adapters/gcs/replay-completeness.d.ts +1 -0
- package/src/adapters/gcs/replay-completeness.js +65 -0
- package/src/adapters/gcs/scan-upload.d.ts +10 -0
- package/src/adapters/gcs/scan-upload.js +26 -0
- package/src/adapters/index.d.ts +5 -0
- package/src/adapters/index.js +12 -0
- package/src/adapters/lease-transaction.d.ts +2 -0
- package/src/adapters/lease-transaction.js +61 -0
- package/src/adapters/local-credential-resolver.d.ts +5 -0
- package/src/adapters/local-credential-resolver.js +15 -0
- package/src/adapters/local-env.d.ts +1 -0
- package/src/adapters/local-env.js +37 -0
- package/src/adapters/local-files.d.ts +17 -0
- package/src/adapters/local-files.js +150 -0
- package/src/adapters/pg-classification-store.d.ts +58 -0
- package/src/adapters/pg-classification-store.js +112 -0
- package/src/adapters/pg-replay-cache.d.ts +16 -0
- package/src/adapters/pg-replay-cache.js +111 -0
- package/src/adapters/pg-run-store.d.ts +58 -0
- package/src/adapters/pg-run-store.js +399 -0
- package/src/adapters/resource-pools.d.ts +2 -0
- package/src/adapters/resource-pools.js +28 -0
- package/src/adapters/secret-manager-credential-resolver.d.ts +44 -0
- package/src/adapters/secret-manager-credential-resolver.js +102 -0
- package/src/artifact-scan.d.ts +21 -0
- package/src/artifact-scan.js +139 -0
- package/src/budget-confirmation.d.ts +23 -0
- package/src/budget-confirmation.js +43 -0
- package/src/cache-command.d.ts +7 -0
- package/src/cache-command.js +107 -0
- package/src/classification-command.d.ts +14 -0
- package/src/classification-command.js +72 -0
- package/src/classification-diff.d.ts +10 -0
- package/src/classification-diff.js +47 -0
- package/src/classification-model.d.ts +17 -0
- package/src/classification-model.js +51 -0
- package/src/classification-notifier.d.ts +21 -0
- package/src/classification-notifier.js +34 -0
- package/src/classify-runs.d.ts +31 -0
- package/src/classify-runs.js +138 -0
- package/src/cli-program.d.ts +9 -0
- package/src/cli-program.js +172 -0
- package/src/cli.d.ts +2 -0
- package/src/cli.js +12 -0
- package/src/commands.d.ts +7 -0
- package/src/commands.js +17 -0
- package/src/credential-references.d.ts +24 -0
- package/src/credential-references.js +33 -0
- package/src/db/commands.d.ts +1 -0
- package/src/db/commands.js +34 -0
- package/src/db/credentials.d.ts +16 -0
- package/src/db/credentials.js +73 -0
- package/src/db/database.d.ts +12 -0
- package/src/db/database.js +135 -0
- package/src/db/event-chunks.d.ts +405 -0
- package/src/db/event-chunks.js +74 -0
- package/src/db/fencing.d.ts +8 -0
- package/src/db/fencing.js +16 -0
- package/src/db/flow-status.d.ts +41 -0
- package/src/db/flow-status.js +208 -0
- package/src/db/index.d.ts +12 -0
- package/src/db/index.js +24 -0
- package/src/db/queries.d.ts +73 -0
- package/src/db/queries.js +122 -0
- package/src/db/resources.d.ts +14 -0
- package/src/db/resources.js +61 -0
- package/src/db/schema.d.ts +3532 -0
- package/src/db/schema.js +501 -0
- package/src/demo-command.d.ts +1 -0
- package/src/demo-command.js +50 -0
- package/src/doctor-command.d.ts +15 -0
- package/src/doctor-command.js +275 -0
- package/src/doctor-summary.d.ts +2 -0
- package/src/doctor-summary.js +31 -0
- package/src/draft-api.d.ts +460 -0
- package/src/draft-api.js +333 -0
- package/src/draft-command.d.ts +10 -0
- package/src/draft-command.js +73 -0
- package/src/draft-hooks.d.ts +3 -0
- package/src/draft-hooks.js +33 -0
- package/src/draft-pages.d.ts +11 -0
- package/src/draft-pages.js +82 -0
- package/src/engine.d.ts +105 -0
- package/src/engine.js +323 -0
- package/src/execution-snapshot.d.ts +21 -0
- package/src/execution-snapshot.js +141 -0
- package/src/flow-check.d.ts +9 -0
- package/src/flow-check.js +68 -0
- package/src/flow-lifecycle.d.ts +6 -0
- package/src/flow-lifecycle.js +61 -0
- package/src/flow-lint.d.ts +8 -0
- package/src/flow-lint.js +73 -0
- package/src/flow-loader.d.ts +219 -0
- package/src/flow-loader.js +236 -0
- package/src/flow-source.d.ts +2 -0
- package/src/flow-source.js +6 -0
- package/src/flows-api.d.ts +1 -0
- package/src/flows-api.js +12 -0
- package/src/heal-notification.d.ts +16 -0
- package/src/heal-notification.js +62 -0
- package/src/hooks/api.d.ts +29 -0
- package/src/hooks/api.js +15 -0
- package/src/hooks/consumer.d.ts +18 -0
- package/src/hooks/consumer.js +98 -0
- package/src/hooks/loader.d.ts +6 -0
- package/src/hooks/loader.js +28 -0
- package/src/hooks/registry.d.ts +22 -0
- package/src/hooks/registry.js +23 -0
- package/src/hooks/runner.d.ts +19 -0
- package/src/hooks/runner.js +279 -0
- package/src/hooks/session-cache.d.ts +16 -0
- package/src/hooks/session-cache.js +42 -0
- package/src/hooks/session-store.d.ts +20 -0
- package/src/hooks/session-store.js +95 -0
- package/src/hooks/worker.d.ts +1 -0
- package/src/hooks/worker.js +84 -0
- package/src/http-stage-client.d.ts +367 -0
- package/src/http-stage-client.js +190 -0
- package/src/independent-model.d.ts +22 -0
- package/src/independent-model.js +215 -0
- package/src/lifecycle-command.d.ts +15 -0
- package/src/lifecycle-command.js +190 -0
- package/src/local-command.d.ts +3 -0
- package/src/local-command.js +27 -0
- package/src/local-host-executor.d.ts +38 -0
- package/src/local-host-executor.js +196 -0
- package/src/open-command.d.ts +7 -0
- package/src/open-command.js +39 -0
- package/src/operations-api.d.ts +2 -0
- package/src/operations-api.js +6 -0
- package/src/personas.d.ts +2 -0
- package/src/personas.js +61 -0
- package/src/program-runner.d.ts +3 -0
- package/src/program-runner.js +263 -0
- package/src/program-sandbox.py +75 -0
- package/src/program-scratch.d.ts +2 -0
- package/src/program-scratch.js +48 -0
- package/src/program-worker.mjs +101 -0
- package/src/public-id.d.ts +2 -0
- package/src/public-id.js +5 -0
- package/src/public-report-url.d.ts +1 -0
- package/src/public-report-url.js +18 -0
- package/src/publication-check.d.ts +1 -0
- package/src/publication-check.js +31 -0
- package/src/quarantine-command.d.ts +9 -0
- package/src/quarantine-command.js +69 -0
- package/src/remote-command.d.ts +30 -0
- package/src/remote-command.js +156 -0
- package/src/replay-image.d.ts +1 -0
- package/src/replay-image.js +35 -0
- package/src/report/assets.d.ts +1 -0
- package/src/report/assets.js +5 -0
- package/src/report/browser.css +414 -0
- package/src/report/browser.d.ts +1 -0
- package/src/report/browser.js +219 -0
- package/src/report/data.d.ts +1 -0
- package/src/report/data.js +4 -0
- package/src/report/generate.d.ts +1 -0
- package/src/report/generate.js +54 -0
- package/src/report/load.d.ts +870 -0
- package/src/report/load.js +139 -0
- package/src/report/resource-table.d.ts +2 -0
- package/src/report/resource-table.js +4 -0
- package/src/report/status-icon.d.ts +2 -0
- package/src/report/status-icon.js +20 -0
- package/src/report/style.css +413 -0
- package/src/result-notifier.d.ts +121 -0
- package/src/result-notifier.js +230 -0
- package/src/result-transports.d.ts +12 -0
- package/src/result-transports.js +150 -0
- package/src/run-command.d.ts +32 -0
- package/src/run-command.js +493 -0
- package/src/run-setup-error.d.ts +11 -0
- package/src/run-setup-error.js +18 -0
- package/src/sandboxes-command.d.ts +9 -0
- package/src/sandboxes-command.js +29 -0
- package/src/screen-proxy.d.ts +5 -0
- package/src/screen-proxy.js +79 -0
- package/src/screen-url.d.ts +18 -0
- package/src/screen-url.js +54 -0
- package/src/server/app.d.ts +29 -0
- package/src/server/app.js +350 -0
- package/src/server/auth.d.ts +33 -0
- package/src/server/auth.js +113 -0
- package/src/server/credentials.d.ts +30 -0
- package/src/server/credentials.js +77 -0
- package/src/server/errors.d.ts +9 -0
- package/src/server/errors.js +26 -0
- package/src/server/index.d.ts +35 -0
- package/src/server/index.js +96 -0
- package/src/server/maintenance.d.ts +13 -0
- package/src/server/maintenance.js +54 -0
- package/src/server/repository.d.ts +534 -0
- package/src/server/repository.js +219 -0
- package/src/setup-command.d.ts +10 -0
- package/src/setup-command.js +52 -0
- package/src/stage-environment.d.ts +1 -0
- package/src/stage-environment.js +35 -0
- package/src/stage-supervisor.mjs +95 -0
- package/src/studio-command.d.ts +7 -0
- package/src/studio-command.js +47 -0
- package/src/studio-control.d.ts +5 -0
- package/src/studio-control.js +207 -0
- package/src/studio-review.d.ts +24 -0
- package/src/studio-review.js +64 -0
- package/src/studio-worker.d.ts +1 -0
- package/src/studio-worker.js +48 -0
- package/src/system-config.d.ts +7 -0
- package/src/system-config.js +70 -0
- package/src/terminal-reporter.d.ts +13 -0
- package/src/terminal-reporter.js +93 -0
- package/src/vendor/gmail.d.ts +45 -0
- package/src/vendor/gmail.js +193 -0
- package/src/watch-command.d.ts +16 -0
- package/src/watch-command.js +93 -0
- package/src/watch-state.d.ts +4 -0
- package/src/watch-state.js +53 -0
- package/src/worker/execution-error.d.ts +5 -0
- package/src/worker/execution-error.js +10 -0
- package/src/worker/execution.d.ts +24 -0
- package/src/worker/execution.js +190 -0
- package/src/worker/index.d.ts +8 -0
- package/src/worker/index.js +40 -0
- package/src/worker/prune.d.ts +3 -0
- package/src/worker/prune.js +22 -0
- package/src/worker/quarantine-notifications.d.ts +8 -0
- package/src/worker/quarantine-notifications.js +89 -0
- package/src/worker/queue.d.ts +65 -0
- package/src/worker/queue.js +438 -0
- package/src/worker/result-notifications.d.ts +28 -0
- package/src/worker/result-notifications.js +347 -0
- package/src/worker/store.d.ts +4 -0
- package/src/worker/store.js +46 -0
- package/src/worker/worker.d.ts +21 -0
- package/src/worker/worker.js +140 -0
- package/README.md +0 -3
package/src/db/schema.js
ADDED
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import {
|
|
3
|
+
bigint,
|
|
4
|
+
bigserial,
|
|
5
|
+
check,
|
|
6
|
+
doublePrecision,
|
|
7
|
+
foreignKey,
|
|
8
|
+
index,
|
|
9
|
+
integer,
|
|
10
|
+
jsonb,
|
|
11
|
+
pgSchema,
|
|
12
|
+
primaryKey,
|
|
13
|
+
text,
|
|
14
|
+
timestamp,
|
|
15
|
+
uniqueIndex
|
|
16
|
+
} from "drizzle-orm/pg-core";
|
|
17
|
+
const qa = pgSchema("qa");
|
|
18
|
+
const project = () => text("project_id").notNull();
|
|
19
|
+
const time = (name) => doublePrecision(name).notNull();
|
|
20
|
+
const created = () => timestamp("created_at", { withTimezone: true }).notNull().defaultNow();
|
|
21
|
+
const batches = qa.table(
|
|
22
|
+
"batches",
|
|
23
|
+
{
|
|
24
|
+
projectId: project(),
|
|
25
|
+
id: text("id").notNull(),
|
|
26
|
+
trigger: text("trigger").notNull(),
|
|
27
|
+
target: text("target"),
|
|
28
|
+
commit: text("commit"),
|
|
29
|
+
createdBy: text("created_by"),
|
|
30
|
+
createdAt: created()
|
|
31
|
+
},
|
|
32
|
+
(t) => [primaryKey({ columns: [t.projectId, t.id] })]
|
|
33
|
+
);
|
|
34
|
+
const runs = qa.table(
|
|
35
|
+
"runs",
|
|
36
|
+
{
|
|
37
|
+
projectId: project(),
|
|
38
|
+
id: text("id").notNull(),
|
|
39
|
+
batchId: text("batch_id"),
|
|
40
|
+
flow: text("flow").notNull(),
|
|
41
|
+
startedAt: time("started_at"),
|
|
42
|
+
metadata: jsonb("metadata").$type(),
|
|
43
|
+
phase: text("phase").notNull().default("queued"),
|
|
44
|
+
verdict: text("verdict"),
|
|
45
|
+
finishedAt: doublePrecision("finished_at"),
|
|
46
|
+
reason: text("reason"),
|
|
47
|
+
eventCount: integer("event_count").notNull().default(0),
|
|
48
|
+
lastSeq: bigint("last_seq", { mode: "number" }).notNull().default(0),
|
|
49
|
+
lastT: time("last_t").default(0),
|
|
50
|
+
eventBytes: bigint("event_bytes", { mode: "number" }).notNull().default(0),
|
|
51
|
+
writerLeaseId: text("writer_lease_id"),
|
|
52
|
+
heartbeatAt: timestamp("heartbeat_at", { withTimezone: true }),
|
|
53
|
+
usage: jsonb("usage").$type(),
|
|
54
|
+
errorReason: text("error_reason"),
|
|
55
|
+
costUsd: doublePrecision("cost_usd").notNull().default(0),
|
|
56
|
+
classification: text("classification")
|
|
57
|
+
},
|
|
58
|
+
(t) => [
|
|
59
|
+
primaryKey({ columns: [t.projectId, t.id] }),
|
|
60
|
+
foreignKey({
|
|
61
|
+
columns: [t.projectId, t.batchId],
|
|
62
|
+
foreignColumns: [batches.projectId, batches.id]
|
|
63
|
+
}),
|
|
64
|
+
index("runs_recent").on(t.projectId, t.startedAt.desc(), sql`${t.id} COLLATE "C"`),
|
|
65
|
+
check(
|
|
66
|
+
"run_classification",
|
|
67
|
+
sql`${t.classification} IN ('product-bug','test-case','env','flaky','agent')`
|
|
68
|
+
),
|
|
69
|
+
check(
|
|
70
|
+
"run_classification_metadata",
|
|
71
|
+
sql`${t.metadata}->'failureClassification'->>'category' IN ('product-bug','test-case','env','flaky','agent')`
|
|
72
|
+
),
|
|
73
|
+
check(
|
|
74
|
+
"run_cursor_nonnegative",
|
|
75
|
+
sql`${t.lastSeq} >= 0 AND ${t.lastT} >= 0 AND ${t.eventCount} >= 0 AND ${t.eventBytes} >= 0`
|
|
76
|
+
)
|
|
77
|
+
]
|
|
78
|
+
);
|
|
79
|
+
const resultNotifications = qa.table(
|
|
80
|
+
"result_notifications",
|
|
81
|
+
{
|
|
82
|
+
projectId: project(),
|
|
83
|
+
batchId: text("batch_id").notNull(),
|
|
84
|
+
channel: text("channel").notNull(),
|
|
85
|
+
context: jsonb("context").notNull(),
|
|
86
|
+
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
87
|
+
abandonedAt: timestamp("abandoned_at", { withTimezone: true }),
|
|
88
|
+
attempts: integer("attempts").notNull().default(0),
|
|
89
|
+
availableAt: timestamp("available_at", { withTimezone: true }).notNull().defaultNow()
|
|
90
|
+
},
|
|
91
|
+
(t) => [
|
|
92
|
+
primaryKey({ columns: [t.projectId, t.batchId, t.channel] }),
|
|
93
|
+
foreignKey({
|
|
94
|
+
columns: [t.projectId, t.batchId],
|
|
95
|
+
foreignColumns: [batches.projectId, batches.id]
|
|
96
|
+
}),
|
|
97
|
+
check("result_notification_channel", sql`${t.channel} IN ('commit','pr','discord')`),
|
|
98
|
+
check("result_notification_attempts", sql`${t.attempts} BETWEEN 0 AND 5`),
|
|
99
|
+
index("result_notifications_pending").on(t.availableAt).where(sql`${t.completedAt} IS NULL AND ${t.abandonedAt} IS NULL`)
|
|
100
|
+
]
|
|
101
|
+
);
|
|
102
|
+
const resultNotificationFlows = qa.table(
|
|
103
|
+
"result_notification_flows",
|
|
104
|
+
{
|
|
105
|
+
projectId: project(),
|
|
106
|
+
batchId: text("batch_id").notNull(),
|
|
107
|
+
channel: text("channel").notNull().default("pr"),
|
|
108
|
+
flow: text("flow").notNull(),
|
|
109
|
+
outcome: text("outcome"),
|
|
110
|
+
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
111
|
+
abandonedAt: timestamp("abandoned_at", { withTimezone: true }),
|
|
112
|
+
attempts: integer("attempts").notNull().default(0),
|
|
113
|
+
availableAt: timestamp("available_at", { withTimezone: true }).notNull().defaultNow()
|
|
114
|
+
},
|
|
115
|
+
(t) => [
|
|
116
|
+
primaryKey({ columns: [t.projectId, t.batchId, t.flow] }),
|
|
117
|
+
foreignKey({
|
|
118
|
+
columns: [t.projectId, t.batchId, t.channel],
|
|
119
|
+
foreignColumns: [
|
|
120
|
+
resultNotifications.projectId,
|
|
121
|
+
resultNotifications.batchId,
|
|
122
|
+
resultNotifications.channel
|
|
123
|
+
]
|
|
124
|
+
}),
|
|
125
|
+
check("result_notification_flow_channel", sql`${t.channel} = 'pr'`),
|
|
126
|
+
check("result_notification_flow_attempts", sql`${t.attempts} BETWEEN 0 AND 5`),
|
|
127
|
+
check("result_notification_flow_outcome", sql`${t.outcome} IN ('delivered','superseded')`),
|
|
128
|
+
check(
|
|
129
|
+
"result_notification_flow_completion",
|
|
130
|
+
sql`(${t.outcome} IS NULL) = (${t.completedAt} IS NULL)`
|
|
131
|
+
),
|
|
132
|
+
index("result_notification_flow_delivered").on(t.projectId, t.flow).where(sql`${t.outcome} = 'delivered'`)
|
|
133
|
+
]
|
|
134
|
+
);
|
|
135
|
+
const flowStatuses = qa.table(
|
|
136
|
+
"flow_statuses",
|
|
137
|
+
{
|
|
138
|
+
projectId: project(),
|
|
139
|
+
flow: text("flow").notNull(),
|
|
140
|
+
status: text("status").notNull().default("draft"),
|
|
141
|
+
flakyStreak: integer("flaky_streak").notNull().default(0),
|
|
142
|
+
generation: integer("generation").notNull().default(0),
|
|
143
|
+
owner: text("owner"),
|
|
144
|
+
latestRepeat: jsonb("latest_repeat").$type(),
|
|
145
|
+
firstRunId: text("first_run_id"),
|
|
146
|
+
firstRunRevision: text("first_run_revision"),
|
|
147
|
+
firstRunAt: timestamp("first_run_at", { withTimezone: true }),
|
|
148
|
+
acceptedAt: timestamp("accepted_at", { withTimezone: true }),
|
|
149
|
+
acceptedBy: text("accepted_by"),
|
|
150
|
+
retiredAt: timestamp("retired_at", { withTimezone: true })
|
|
151
|
+
},
|
|
152
|
+
(t) => [
|
|
153
|
+
primaryKey({ columns: [t.projectId, t.flow] }),
|
|
154
|
+
check("flow_status", sql`${t.status} IN ('draft','review','active','quarantined','retired')`),
|
|
155
|
+
check("flow_streak", sql`${t.flakyStreak} >= 0 AND ${t.generation} >= 0`)
|
|
156
|
+
]
|
|
157
|
+
);
|
|
158
|
+
const flowResults = qa.table(
|
|
159
|
+
"flow_results",
|
|
160
|
+
{
|
|
161
|
+
projectId: project(),
|
|
162
|
+
executionId: text("execution_id").notNull(),
|
|
163
|
+
flow: text("flow").notNull(),
|
|
164
|
+
quarantined: integer("quarantined").notNull()
|
|
165
|
+
},
|
|
166
|
+
(t) => [
|
|
167
|
+
primaryKey({ columns: [t.projectId, t.executionId] }),
|
|
168
|
+
check("flow_result_quarantined", sql`${t.quarantined} IN (0,1)`)
|
|
169
|
+
]
|
|
170
|
+
);
|
|
171
|
+
const quarantineNotifications = qa.table(
|
|
172
|
+
"quarantine_notifications",
|
|
173
|
+
{
|
|
174
|
+
projectId: project(),
|
|
175
|
+
flow: text("flow").notNull(),
|
|
176
|
+
generation: integer("generation").notNull(),
|
|
177
|
+
runId: text("run_id").notNull(),
|
|
178
|
+
owner: text("owner"),
|
|
179
|
+
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
180
|
+
abandonedAt: timestamp("abandoned_at", { withTimezone: true }),
|
|
181
|
+
attempts: integer("attempts").notNull().default(0),
|
|
182
|
+
availableAt: timestamp("available_at", { withTimezone: true }).notNull().defaultNow()
|
|
183
|
+
},
|
|
184
|
+
(t) => [
|
|
185
|
+
primaryKey({ columns: [t.projectId, t.flow, t.generation] }),
|
|
186
|
+
check("quarantine_notification_attempts", sql`${t.attempts} BETWEEN 0 AND 5`)
|
|
187
|
+
]
|
|
188
|
+
);
|
|
189
|
+
const lanes = qa.table(
|
|
190
|
+
"lanes",
|
|
191
|
+
{
|
|
192
|
+
projectId: project(),
|
|
193
|
+
runId: text("run_id").notNull(),
|
|
194
|
+
actor: text("actor").notNull(),
|
|
195
|
+
status: text("status").notNull(),
|
|
196
|
+
startedAt: time("started_at"),
|
|
197
|
+
finishedAt: doublePrecision("finished_at")
|
|
198
|
+
},
|
|
199
|
+
(t) => [
|
|
200
|
+
primaryKey({ columns: [t.projectId, t.runId, t.actor] }),
|
|
201
|
+
foreignKey({ columns: [t.projectId, t.runId], foreignColumns: [runs.projectId, runs.id] })
|
|
202
|
+
]
|
|
203
|
+
);
|
|
204
|
+
const stepRuns = qa.table(
|
|
205
|
+
"step_runs",
|
|
206
|
+
{
|
|
207
|
+
projectId: project(),
|
|
208
|
+
runId: text("run_id").notNull(),
|
|
209
|
+
actor: text("actor").notNull(),
|
|
210
|
+
step: text("step").notNull(),
|
|
211
|
+
seq: bigint("seq", { mode: "number" }).notNull(),
|
|
212
|
+
status: text("status").notNull(),
|
|
213
|
+
startedAt: time("started_at"),
|
|
214
|
+
finishedAt: doublePrecision("finished_at")
|
|
215
|
+
},
|
|
216
|
+
(t) => [
|
|
217
|
+
primaryKey({ columns: [t.projectId, t.runId, t.seq] }),
|
|
218
|
+
foreignKey({ columns: [t.projectId, t.runId], foreignColumns: [runs.projectId, runs.id] })
|
|
219
|
+
]
|
|
220
|
+
);
|
|
221
|
+
const eventChunks = qa.table(
|
|
222
|
+
"event_chunks",
|
|
223
|
+
{
|
|
224
|
+
projectId: project(),
|
|
225
|
+
runId: text("run_id").notNull(),
|
|
226
|
+
id: text("id").notNull(),
|
|
227
|
+
objectKey: text("object_key").notNull(),
|
|
228
|
+
sha256: text("sha256").notNull(),
|
|
229
|
+
count: integer("count").notNull(),
|
|
230
|
+
bytes: integer("bytes").notNull(),
|
|
231
|
+
firstSeq: bigint("first_seq", { mode: "number" }).notNull(),
|
|
232
|
+
lastSeq: bigint("last_seq", { mode: "number" }).notNull(),
|
|
233
|
+
firstT: time("first_t"),
|
|
234
|
+
lastT: time("last_t"),
|
|
235
|
+
state: text("state").notNull().default("uploading"),
|
|
236
|
+
cleanedAt: timestamp("cleaned_at", { withTimezone: true }),
|
|
237
|
+
createdAt: created()
|
|
238
|
+
},
|
|
239
|
+
(t) => [
|
|
240
|
+
primaryKey({ columns: [t.projectId, t.runId, t.id] }),
|
|
241
|
+
uniqueIndex("event_object_key").on(t.objectKey),
|
|
242
|
+
foreignKey({ columns: [t.projectId, t.runId], foreignColumns: [runs.projectId, runs.id] }),
|
|
243
|
+
check("chunk_state", sql`${t.state} IN ('uploading','committed','abandoned','cleaned')`),
|
|
244
|
+
check(
|
|
245
|
+
"chunk_range",
|
|
246
|
+
sql`${t.count} > 0 AND ${t.bytes} > 0 AND ${t.firstSeq} > 0 AND ${t.lastSeq} >= ${t.firstSeq} AND ${t.lastT} >= ${t.firstT}`
|
|
247
|
+
)
|
|
248
|
+
]
|
|
249
|
+
);
|
|
250
|
+
const events = qa.table(
|
|
251
|
+
"events",
|
|
252
|
+
{
|
|
253
|
+
projectId: project(),
|
|
254
|
+
runId: text("run_id").notNull(),
|
|
255
|
+
seq: bigint("seq", { mode: "number" }).notNull(),
|
|
256
|
+
t: time("t"),
|
|
257
|
+
kind: text("kind").notNull(),
|
|
258
|
+
actor: text("actor"),
|
|
259
|
+
step: text("step"),
|
|
260
|
+
chunkId: text("chunk_id").notNull(),
|
|
261
|
+
offset: integer("offset").notNull()
|
|
262
|
+
},
|
|
263
|
+
(t) => [
|
|
264
|
+
primaryKey({ columns: [t.projectId, t.runId, t.seq] }),
|
|
265
|
+
foreignKey({
|
|
266
|
+
columns: [t.projectId, t.runId, t.chunkId],
|
|
267
|
+
foreignColumns: [eventChunks.projectId, eventChunks.runId, eventChunks.id]
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
);
|
|
271
|
+
const artifacts = qa.table(
|
|
272
|
+
"artifacts",
|
|
273
|
+
{
|
|
274
|
+
projectId: project(),
|
|
275
|
+
runId: text("run_id").notNull(),
|
|
276
|
+
path: text("path").notNull(),
|
|
277
|
+
kind: text("kind").notNull(),
|
|
278
|
+
objectKey: text("object_key").notNull(),
|
|
279
|
+
bytes: bigint("bytes", { mode: "number" }).notNull(),
|
|
280
|
+
sha256: text("sha256").notNull()
|
|
281
|
+
},
|
|
282
|
+
(t) => [
|
|
283
|
+
primaryKey({ columns: [t.projectId, t.runId, t.path] }),
|
|
284
|
+
foreignKey({ columns: [t.projectId, t.runId], foreignColumns: [runs.projectId, runs.id] })
|
|
285
|
+
]
|
|
286
|
+
);
|
|
287
|
+
const leaseResources = qa.table(
|
|
288
|
+
"lease_resources",
|
|
289
|
+
{
|
|
290
|
+
projectId: project(),
|
|
291
|
+
id: text("id").notNull(),
|
|
292
|
+
kind: text("kind").notNull(),
|
|
293
|
+
canonicalId: text("canonical_id").notNull(),
|
|
294
|
+
secretRef: text("secret_ref").notNull()
|
|
295
|
+
},
|
|
296
|
+
(t) => [
|
|
297
|
+
primaryKey({ columns: [t.projectId, t.id] }),
|
|
298
|
+
index("resource_kinds").on(t.projectId, t.kind)
|
|
299
|
+
]
|
|
300
|
+
);
|
|
301
|
+
const leases = qa.table(
|
|
302
|
+
"leases",
|
|
303
|
+
{
|
|
304
|
+
projectId: project(),
|
|
305
|
+
id: text("id").notNull(),
|
|
306
|
+
runId: text("run_id").notNull(),
|
|
307
|
+
actor: text("actor").notNull(),
|
|
308
|
+
owner: text("owner").notNull(),
|
|
309
|
+
epoch: bigserial("epoch", { mode: "bigint" }).notNull(),
|
|
310
|
+
state: text("state").notNull().default("active"),
|
|
311
|
+
expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
|
|
312
|
+
allocations: jsonb("allocations").$type().notNull()
|
|
313
|
+
},
|
|
314
|
+
(t) => [
|
|
315
|
+
primaryKey({ columns: [t.projectId, t.id] }),
|
|
316
|
+
check("lease_state", sql`${t.state} IN ('active','quarantined','released')`)
|
|
317
|
+
]
|
|
318
|
+
);
|
|
319
|
+
const leaseClaims = qa.table(
|
|
320
|
+
"lease_claims",
|
|
321
|
+
{
|
|
322
|
+
projectId: project(),
|
|
323
|
+
identity: text("identity").notNull(),
|
|
324
|
+
leaseId: text("lease_id").notNull()
|
|
325
|
+
},
|
|
326
|
+
(t) => [
|
|
327
|
+
primaryKey({ columns: [t.projectId, t.identity] }),
|
|
328
|
+
foreignKey({
|
|
329
|
+
columns: [t.projectId, t.leaseId],
|
|
330
|
+
foreignColumns: [leases.projectId, leases.id]
|
|
331
|
+
})
|
|
332
|
+
]
|
|
333
|
+
);
|
|
334
|
+
const jobs = qa.table(
|
|
335
|
+
"jobs",
|
|
336
|
+
{
|
|
337
|
+
projectId: project(),
|
|
338
|
+
id: text("id").notNull(),
|
|
339
|
+
runId: text("run_id").notNull(),
|
|
340
|
+
state: text("state").notNull().default("queued"),
|
|
341
|
+
availableAt: timestamp("available_at", { withTimezone: true }).notNull().defaultNow(),
|
|
342
|
+
attempts: integer("attempts").notNull().default(0),
|
|
343
|
+
owner: text("owner"),
|
|
344
|
+
epoch: bigserial("epoch", { mode: "bigint" }).notNull(),
|
|
345
|
+
leaseUntil: timestamp("lease_until", { withTimezone: true }),
|
|
346
|
+
retryOf: text("retry_of"),
|
|
347
|
+
cleanedAt: timestamp("cleaned_at", { withTimezone: true }),
|
|
348
|
+
verifiedRevision: text("verified_revision"),
|
|
349
|
+
infrastructureFailure: integer("infrastructure_failure").notNull().default(0)
|
|
350
|
+
},
|
|
351
|
+
(t) => [
|
|
352
|
+
primaryKey({ columns: [t.projectId, t.id] }),
|
|
353
|
+
foreignKey({ columns: [t.projectId, t.runId], foreignColumns: [runs.projectId, runs.id] }),
|
|
354
|
+
index("jobs_available").on(t.projectId, t.state, t.availableAt),
|
|
355
|
+
uniqueIndex("job_run").on(t.projectId, t.runId),
|
|
356
|
+
uniqueIndex("job_retry").on(t.projectId, t.retryOf),
|
|
357
|
+
check("job_attempt", sql`${t.attempts} IN (0,1)`)
|
|
358
|
+
]
|
|
359
|
+
);
|
|
360
|
+
const credentials = qa.table(
|
|
361
|
+
"credentials",
|
|
362
|
+
{
|
|
363
|
+
projectId: project(),
|
|
364
|
+
userId: text("user_id").notNull(),
|
|
365
|
+
provider: text("provider").notNull(),
|
|
366
|
+
secretRef: text("secret_ref").notNull(),
|
|
367
|
+
expiresAt: timestamp("expires_at", { withTimezone: true })
|
|
368
|
+
},
|
|
369
|
+
(t) => [primaryKey({ columns: [t.projectId, t.userId, t.provider] })]
|
|
370
|
+
);
|
|
371
|
+
const serverSubmissions = qa.table(
|
|
372
|
+
"server_submissions",
|
|
373
|
+
{
|
|
374
|
+
projectId: project(),
|
|
375
|
+
principalId: text("principal_id").notNull(),
|
|
376
|
+
idempotencyKey: text("idempotency_key").notNull(),
|
|
377
|
+
fingerprint: text("fingerprint").notNull(),
|
|
378
|
+
batchId: text("batch_id").notNull(),
|
|
379
|
+
response: jsonb("response").notNull(),
|
|
380
|
+
createdAt: created()
|
|
381
|
+
},
|
|
382
|
+
(t) => [
|
|
383
|
+
primaryKey({ columns: [t.projectId, t.principalId, t.idempotencyKey] }),
|
|
384
|
+
uniqueIndex("submission_batch").on(t.projectId, t.batchId),
|
|
385
|
+
index("submission_created").on(t.projectId, t.createdAt.desc(), t.batchId),
|
|
386
|
+
foreignKey({
|
|
387
|
+
columns: [t.projectId, t.batchId],
|
|
388
|
+
foreignColumns: [batches.projectId, batches.id]
|
|
389
|
+
})
|
|
390
|
+
]
|
|
391
|
+
);
|
|
392
|
+
const readPublications = qa.table(
|
|
393
|
+
"read_publications",
|
|
394
|
+
{
|
|
395
|
+
projectId: project(),
|
|
396
|
+
kind: text("kind").notNull(),
|
|
397
|
+
document: jsonb("document").notNull()
|
|
398
|
+
},
|
|
399
|
+
(t) => [primaryKey({ columns: [t.projectId, t.kind] })]
|
|
400
|
+
);
|
|
401
|
+
const cacheEntries = qa.table(
|
|
402
|
+
"cache_entries",
|
|
403
|
+
{
|
|
404
|
+
projectId: project(),
|
|
405
|
+
cacheKey: text("cache_key").notNull(),
|
|
406
|
+
version: integer("version").notNull(),
|
|
407
|
+
entry: jsonb("entry").$type().notNull(),
|
|
408
|
+
createdAt: created()
|
|
409
|
+
},
|
|
410
|
+
(t) => [
|
|
411
|
+
primaryKey({ columns: [t.projectId, t.cacheKey, t.version] }),
|
|
412
|
+
check("cache_version_positive", sql`${t.version} > 0`)
|
|
413
|
+
]
|
|
414
|
+
);
|
|
415
|
+
const findings = qa.table(
|
|
416
|
+
"findings",
|
|
417
|
+
{
|
|
418
|
+
projectId: project(),
|
|
419
|
+
runId: text("run_id").notNull(),
|
|
420
|
+
ordinal: integer("ordinal").notNull(),
|
|
421
|
+
actor: text("actor").notNull(),
|
|
422
|
+
step: text("step").notNull(),
|
|
423
|
+
category: text("category").notNull(),
|
|
424
|
+
severity: text("severity").notNull(),
|
|
425
|
+
description: text("description").notNull(),
|
|
426
|
+
eventSeqs: jsonb("event_seqs").$type().notNull(),
|
|
427
|
+
shots: jsonb("shots").$type().notNull(),
|
|
428
|
+
createdAt: created()
|
|
429
|
+
},
|
|
430
|
+
(t) => [
|
|
431
|
+
primaryKey({ columns: [t.projectId, t.runId, t.ordinal] }),
|
|
432
|
+
foreignKey({ columns: [t.projectId, t.runId], foreignColumns: [runs.projectId, runs.id] }),
|
|
433
|
+
check("finding_ordinal_positive", sql`${t.ordinal} > 0`),
|
|
434
|
+
check("finding_severity", sql`${t.severity} IN ('low','medium','high')`),
|
|
435
|
+
check("finding_category", sql`${t.category} IN ('scope','other')`)
|
|
436
|
+
]
|
|
437
|
+
);
|
|
438
|
+
const classificationLabels = qa.table(
|
|
439
|
+
"classification_labels",
|
|
440
|
+
{
|
|
441
|
+
projectId: project(),
|
|
442
|
+
runId: text("run_id").notNull(),
|
|
443
|
+
ordinal: integer("ordinal").notNull(),
|
|
444
|
+
category: text("category").notNull(),
|
|
445
|
+
reason: text("reason").notNull(),
|
|
446
|
+
modifiedBy: text("modified_by").notNull(),
|
|
447
|
+
modifiedAt: time("modified_at"),
|
|
448
|
+
predicted: jsonb("predicted").$type()
|
|
449
|
+
},
|
|
450
|
+
(t) => [
|
|
451
|
+
primaryKey({ columns: [t.projectId, t.runId, t.ordinal] }),
|
|
452
|
+
foreignKey({ columns: [t.projectId, t.runId], foreignColumns: [runs.projectId, runs.id] }),
|
|
453
|
+
check(
|
|
454
|
+
"classification_label_category",
|
|
455
|
+
sql`${t.category} IN ('product-bug','test-case','env','flaky','agent')`
|
|
456
|
+
),
|
|
457
|
+
check(
|
|
458
|
+
"classification_prediction_category",
|
|
459
|
+
sql`${t.predicted}->>'category' IN ('product-bug','test-case','env','flaky','agent')`
|
|
460
|
+
)
|
|
461
|
+
]
|
|
462
|
+
);
|
|
463
|
+
const workerSlots = qa.table(
|
|
464
|
+
"worker_slots",
|
|
465
|
+
{
|
|
466
|
+
id: integer("id").primaryKey(),
|
|
467
|
+
projectId: text("project_id"),
|
|
468
|
+
jobId: text("job_id")
|
|
469
|
+
},
|
|
470
|
+
(t) => [
|
|
471
|
+
check("worker_slot_range", sql`${t.id} BETWEEN 1 AND 8`),
|
|
472
|
+
check("worker_slot_pair", sql`(${t.projectId} IS NULL) = (${t.jobId} IS NULL)`),
|
|
473
|
+
uniqueIndex("worker_slot_job").on(t.projectId, t.jobId)
|
|
474
|
+
]
|
|
475
|
+
);
|
|
476
|
+
export {
|
|
477
|
+
artifacts,
|
|
478
|
+
batches,
|
|
479
|
+
cacheEntries,
|
|
480
|
+
classificationLabels,
|
|
481
|
+
credentials,
|
|
482
|
+
eventChunks,
|
|
483
|
+
events,
|
|
484
|
+
findings,
|
|
485
|
+
flowResults,
|
|
486
|
+
flowStatuses,
|
|
487
|
+
jobs,
|
|
488
|
+
lanes,
|
|
489
|
+
leaseClaims,
|
|
490
|
+
leaseResources,
|
|
491
|
+
leases,
|
|
492
|
+
qa,
|
|
493
|
+
quarantineNotifications,
|
|
494
|
+
readPublications,
|
|
495
|
+
resultNotificationFlows,
|
|
496
|
+
resultNotifications,
|
|
497
|
+
runs,
|
|
498
|
+
serverSubmissions,
|
|
499
|
+
stepRuns,
|
|
500
|
+
workerSlots
|
|
501
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function demoCommand(directory: string): Promise<void>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { rm } from "node:fs/promises";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { generateReport } from "./report/generate.js";
|
|
7
|
+
async function demoCommand(directory) {
|
|
8
|
+
const root = resolve(directory);
|
|
9
|
+
try {
|
|
10
|
+
await promisify(execFile)(
|
|
11
|
+
process.execPath,
|
|
12
|
+
[fileURLToPath(import.meta.resolve("@open-qa/qa-studio/demo")), root],
|
|
13
|
+
{
|
|
14
|
+
env: { PATH: process.env.PATH }
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
} catch (cause) {
|
|
18
|
+
const stderr = cause && typeof cause === "object" && "stderr" in cause && typeof cause.stderr === "string" ? cause.stderr.trim() : "";
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Could not create demo data: ${stderr || (cause instanceof Error ? cause.message : String(cause))}`,
|
|
21
|
+
{ cause }
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
for (const id of [
|
|
26
|
+
"demo-passed",
|
|
27
|
+
"demo-single",
|
|
28
|
+
"demo-multi",
|
|
29
|
+
"demo-heal-known",
|
|
30
|
+
"demo-heal-unknown"
|
|
31
|
+
])
|
|
32
|
+
await generateReport(root, id);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
try {
|
|
35
|
+
await rm(root, { recursive: true, force: true });
|
|
36
|
+
} catch (cleanup) {
|
|
37
|
+
throw new AggregateError([error, cleanup], "Demo report generation and cleanup failed", {
|
|
38
|
+
cause: cleanup
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
console.log(
|
|
44
|
+
`Created synthetic demo data at ${root}. No models or cloud services were called.
|
|
45
|
+
Open with: pnpm qa studio --root ${JSON.stringify(root)}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
demoCommand
|
|
50
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HookRegistry } from "./hooks/registry.js";
|
|
2
|
+
import { type LocalCommand } from "./local-command.js";
|
|
3
|
+
export interface DoctorAdapters {
|
|
4
|
+
registry?: HookRegistry;
|
|
5
|
+
command?: LocalCommand;
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
login?: () => Promise<unknown>;
|
|
8
|
+
leaseLock?: () => Promise<void>;
|
|
9
|
+
output?: (line: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function doctorCommand(options: {
|
|
12
|
+
root?: string;
|
|
13
|
+
target?: string;
|
|
14
|
+
save?: boolean;
|
|
15
|
+
}, adapters?: DoctorAdapters): Promise<number>;
|