@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
@@ -551,6 +551,40 @@ export declare const resultNotifications: import("drizzle-orm/pg-core").PgTableW
551
551
  identity: undefined;
552
552
  generated: undefined;
553
553
  }, {}, {}>;
554
+ kind: import("drizzle-orm/pg-core").PgColumn<{
555
+ name: "kind";
556
+ tableName: "result_notifications";
557
+ dataType: "string";
558
+ columnType: "PgText";
559
+ data: string;
560
+ driverParam: string;
561
+ notNull: false;
562
+ hasDefault: false;
563
+ isPrimaryKey: false;
564
+ isAutoincrement: false;
565
+ hasRuntimeDefault: false;
566
+ enumValues: [string, ...string[]];
567
+ baseColumn: never;
568
+ identity: undefined;
569
+ generated: undefined;
570
+ }, {}, {}>;
571
+ provider: import("drizzle-orm/pg-core").PgColumn<{
572
+ name: "provider";
573
+ tableName: "result_notifications";
574
+ dataType: "string";
575
+ columnType: "PgText";
576
+ data: string;
577
+ driverParam: string;
578
+ notNull: false;
579
+ hasDefault: false;
580
+ isPrimaryKey: false;
581
+ isAutoincrement: false;
582
+ hasRuntimeDefault: false;
583
+ enumValues: [string, ...string[]];
584
+ baseColumn: never;
585
+ identity: undefined;
586
+ generated: undefined;
587
+ }, {}, {}>;
554
588
  context: import("drizzle-orm/pg-core").PgColumn<{
555
589
  name: "context";
556
590
  tableName: "result_notifications";
@@ -3446,10 +3480,27 @@ export declare const classificationLabels: import("drizzle-orm/pg-core").PgTable
3446
3480
  dataType: "json";
3447
3481
  columnType: "PgJsonb";
3448
3482
  data: {
3449
- category: "env" | "agent" | "product-bug" | "test-case" | "flaky";
3483
+ category: string | null;
3450
3484
  confidence: number;
3451
3485
  reason: string;
3452
- source: "model" | "fallback" | "rule" | "human";
3486
+ source: "model" | "rule" | "fallback" | "human";
3487
+ origin?: "unknown" | "judge" | "product" | "harness" | "infra" | undefined;
3488
+ cause?: string | undefined;
3489
+ taxonomy?: {
3490
+ project: string;
3491
+ version: string;
3492
+ } | undefined;
3493
+ flakiness?: "unknown" | "observed" | undefined;
3494
+ needsReview?: boolean | undefined;
3495
+ classifierVersion?: string | undefined;
3496
+ rawPrediction?: {
3497
+ category: string | null;
3498
+ confidence: number;
3499
+ reason: string;
3500
+ origin?: "unknown" | "judge" | "product" | "harness" | "infra" | undefined;
3501
+ cause?: string | undefined;
3502
+ modelVersion?: string | undefined;
3503
+ } | undefined;
3453
3504
  };
3454
3505
  driverParam: unknown;
3455
3506
  notNull: false;
@@ -3463,12 +3514,48 @@ export declare const classificationLabels: import("drizzle-orm/pg-core").PgTable
3463
3514
  generated: undefined;
3464
3515
  }, {}, {
3465
3516
  $type: {
3466
- category: "env" | "agent" | "product-bug" | "test-case" | "flaky";
3517
+ category: string | null;
3467
3518
  confidence: number;
3468
3519
  reason: string;
3469
- source: "model" | "fallback" | "rule" | "human";
3520
+ source: "model" | "rule" | "fallback" | "human";
3521
+ origin?: "unknown" | "judge" | "product" | "harness" | "infra" | undefined;
3522
+ cause?: string | undefined;
3523
+ taxonomy?: {
3524
+ project: string;
3525
+ version: string;
3526
+ } | undefined;
3527
+ flakiness?: "unknown" | "observed" | undefined;
3528
+ needsReview?: boolean | undefined;
3529
+ classifierVersion?: string | undefined;
3530
+ rawPrediction?: {
3531
+ category: string | null;
3532
+ confidence: number;
3533
+ reason: string;
3534
+ origin?: "unknown" | "judge" | "product" | "harness" | "infra" | undefined;
3535
+ cause?: string | undefined;
3536
+ modelVersion?: string | undefined;
3537
+ } | undefined;
3470
3538
  };
3471
3539
  }>;
3540
+ details: import("drizzle-orm/pg-core").PgColumn<{
3541
+ name: "details";
3542
+ tableName: "classification_labels";
3543
+ dataType: "json";
3544
+ columnType: "PgJsonb";
3545
+ data: Record<string, import("zod").JSONType>;
3546
+ driverParam: unknown;
3547
+ notNull: false;
3548
+ hasDefault: false;
3549
+ isPrimaryKey: false;
3550
+ isAutoincrement: false;
3551
+ hasRuntimeDefault: false;
3552
+ enumValues: undefined;
3553
+ baseColumn: never;
3554
+ identity: undefined;
3555
+ generated: undefined;
3556
+ }, {}, {
3557
+ $type: Record<string, import("zod").JSONType>;
3558
+ }>;
3472
3559
  };
3473
3560
  dialect: "pg";
3474
3561
  }>;
@@ -3530,3 +3617,245 @@ export declare const workerSlots: import("drizzle-orm/pg-core").PgTableWithColum
3530
3617
  };
3531
3618
  dialect: "pg";
3532
3619
  }>;
3620
+ export declare const trialGroups: import("drizzle-orm/pg-core").PgTableWithColumns<{
3621
+ name: "trial_groups";
3622
+ schema: "qa";
3623
+ columns: {
3624
+ projectId: import("drizzle-orm/pg-core").PgColumn<{
3625
+ name: "project_id";
3626
+ tableName: "trial_groups";
3627
+ dataType: "string";
3628
+ columnType: "PgText";
3629
+ data: string;
3630
+ driverParam: string;
3631
+ notNull: true;
3632
+ hasDefault: false;
3633
+ isPrimaryKey: false;
3634
+ isAutoincrement: false;
3635
+ hasRuntimeDefault: false;
3636
+ enumValues: [string, ...string[]];
3637
+ baseColumn: never;
3638
+ identity: undefined;
3639
+ generated: undefined;
3640
+ }, {}, {}>;
3641
+ groupId: import("drizzle-orm/pg-core").PgColumn<{
3642
+ name: "group_id";
3643
+ tableName: "trial_groups";
3644
+ dataType: "string";
3645
+ columnType: "PgText";
3646
+ data: string;
3647
+ driverParam: string;
3648
+ notNull: true;
3649
+ hasDefault: false;
3650
+ isPrimaryKey: false;
3651
+ isAutoincrement: false;
3652
+ hasRuntimeDefault: false;
3653
+ enumValues: [string, ...string[]];
3654
+ baseColumn: never;
3655
+ identity: undefined;
3656
+ generated: undefined;
3657
+ }, {}, {}>;
3658
+ flow: import("drizzle-orm/pg-core").PgColumn<{
3659
+ name: "flow";
3660
+ tableName: "trial_groups";
3661
+ dataType: "string";
3662
+ columnType: "PgText";
3663
+ data: string;
3664
+ driverParam: string;
3665
+ notNull: true;
3666
+ hasDefault: false;
3667
+ isPrimaryKey: false;
3668
+ isAutoincrement: false;
3669
+ hasRuntimeDefault: false;
3670
+ enumValues: [string, ...string[]];
3671
+ baseColumn: never;
3672
+ identity: undefined;
3673
+ generated: undefined;
3674
+ }, {}, {}>;
3675
+ startedAt: import("drizzle-orm/pg-core").PgColumn<{
3676
+ name: string;
3677
+ tableName: "trial_groups";
3678
+ dataType: "number";
3679
+ columnType: "PgDoublePrecision";
3680
+ data: number;
3681
+ driverParam: string | number;
3682
+ notNull: true;
3683
+ hasDefault: false;
3684
+ isPrimaryKey: false;
3685
+ isAutoincrement: false;
3686
+ hasRuntimeDefault: false;
3687
+ enumValues: undefined;
3688
+ baseColumn: never;
3689
+ identity: undefined;
3690
+ generated: undefined;
3691
+ }, {}, {}>;
3692
+ document: import("drizzle-orm/pg-core").PgColumn<{
3693
+ name: "document";
3694
+ tableName: "trial_groups";
3695
+ dataType: "json";
3696
+ columnType: "PgJsonb";
3697
+ data: unknown;
3698
+ driverParam: unknown;
3699
+ notNull: true;
3700
+ hasDefault: false;
3701
+ isPrimaryKey: false;
3702
+ isAutoincrement: false;
3703
+ hasRuntimeDefault: false;
3704
+ enumValues: undefined;
3705
+ baseColumn: never;
3706
+ identity: undefined;
3707
+ generated: undefined;
3708
+ }, {}, {}>;
3709
+ };
3710
+ dialect: "pg";
3711
+ }>;
3712
+ export declare const trialGroupReceipts: import("drizzle-orm/pg-core").PgTableWithColumns<{
3713
+ name: "trial_group_receipts";
3714
+ schema: "qa";
3715
+ columns: {
3716
+ projectId: import("drizzle-orm/pg-core").PgColumn<{
3717
+ name: "project_id";
3718
+ tableName: "trial_group_receipts";
3719
+ dataType: "string";
3720
+ columnType: "PgText";
3721
+ data: string;
3722
+ driverParam: string;
3723
+ notNull: true;
3724
+ hasDefault: false;
3725
+ isPrimaryKey: false;
3726
+ isAutoincrement: false;
3727
+ hasRuntimeDefault: false;
3728
+ enumValues: [string, ...string[]];
3729
+ baseColumn: never;
3730
+ identity: undefined;
3731
+ generated: undefined;
3732
+ }, {}, {}>;
3733
+ groupId: import("drizzle-orm/pg-core").PgColumn<{
3734
+ name: "group_id";
3735
+ tableName: "trial_group_receipts";
3736
+ dataType: "string";
3737
+ columnType: "PgText";
3738
+ data: string;
3739
+ driverParam: string;
3740
+ notNull: true;
3741
+ hasDefault: false;
3742
+ isPrimaryKey: false;
3743
+ isAutoincrement: false;
3744
+ hasRuntimeDefault: false;
3745
+ enumValues: [string, ...string[]];
3746
+ baseColumn: never;
3747
+ identity: undefined;
3748
+ generated: undefined;
3749
+ }, {}, {}>;
3750
+ key: import("drizzle-orm/pg-core").PgColumn<{
3751
+ name: "key";
3752
+ tableName: "trial_group_receipts";
3753
+ dataType: "string";
3754
+ columnType: "PgText";
3755
+ data: string;
3756
+ driverParam: string;
3757
+ notNull: true;
3758
+ hasDefault: false;
3759
+ isPrimaryKey: false;
3760
+ isAutoincrement: false;
3761
+ hasRuntimeDefault: false;
3762
+ enumValues: [string, ...string[]];
3763
+ baseColumn: never;
3764
+ identity: undefined;
3765
+ generated: undefined;
3766
+ }, {}, {}>;
3767
+ document: import("drizzle-orm/pg-core").PgColumn<{
3768
+ name: "document";
3769
+ tableName: "trial_group_receipts";
3770
+ dataType: "json";
3771
+ columnType: "PgJsonb";
3772
+ data: unknown;
3773
+ driverParam: unknown;
3774
+ notNull: true;
3775
+ hasDefault: false;
3776
+ isPrimaryKey: false;
3777
+ isAutoincrement: false;
3778
+ hasRuntimeDefault: false;
3779
+ enumValues: undefined;
3780
+ baseColumn: never;
3781
+ identity: undefined;
3782
+ generated: undefined;
3783
+ }, {}, {}>;
3784
+ };
3785
+ dialect: "pg";
3786
+ }>;
3787
+ export declare const auditDecisions: import("drizzle-orm/pg-core").PgTableWithColumns<{
3788
+ name: "audit_decisions";
3789
+ schema: "qa";
3790
+ columns: {
3791
+ projectId: import("drizzle-orm/pg-core").PgColumn<{
3792
+ name: "project_id";
3793
+ tableName: "audit_decisions";
3794
+ dataType: "string";
3795
+ columnType: "PgText";
3796
+ data: string;
3797
+ driverParam: string;
3798
+ notNull: true;
3799
+ hasDefault: false;
3800
+ isPrimaryKey: false;
3801
+ isAutoincrement: false;
3802
+ hasRuntimeDefault: false;
3803
+ enumValues: [string, ...string[]];
3804
+ baseColumn: never;
3805
+ identity: undefined;
3806
+ generated: undefined;
3807
+ }, {}, {}>;
3808
+ subject: import("drizzle-orm/pg-core").PgColumn<{
3809
+ name: "subject";
3810
+ tableName: "audit_decisions";
3811
+ dataType: "string";
3812
+ columnType: "PgText";
3813
+ data: string;
3814
+ driverParam: string;
3815
+ notNull: true;
3816
+ hasDefault: false;
3817
+ isPrimaryKey: false;
3818
+ isAutoincrement: false;
3819
+ hasRuntimeDefault: false;
3820
+ enumValues: [string, ...string[]];
3821
+ baseColumn: never;
3822
+ identity: undefined;
3823
+ generated: undefined;
3824
+ }, {}, {}>;
3825
+ key: import("drizzle-orm/pg-core").PgColumn<{
3826
+ name: "key";
3827
+ tableName: "audit_decisions";
3828
+ dataType: "string";
3829
+ columnType: "PgText";
3830
+ data: string;
3831
+ driverParam: string;
3832
+ notNull: true;
3833
+ hasDefault: false;
3834
+ isPrimaryKey: false;
3835
+ isAutoincrement: false;
3836
+ hasRuntimeDefault: false;
3837
+ enumValues: [string, ...string[]];
3838
+ baseColumn: never;
3839
+ identity: undefined;
3840
+ generated: undefined;
3841
+ }, {}, {}>;
3842
+ document: import("drizzle-orm/pg-core").PgColumn<{
3843
+ name: "document";
3844
+ tableName: "audit_decisions";
3845
+ dataType: "json";
3846
+ columnType: "PgJsonb";
3847
+ data: unknown;
3848
+ driverParam: unknown;
3849
+ notNull: true;
3850
+ hasDefault: false;
3851
+ isPrimaryKey: false;
3852
+ isAutoincrement: false;
3853
+ hasRuntimeDefault: false;
3854
+ enumValues: undefined;
3855
+ baseColumn: never;
3856
+ identity: undefined;
3857
+ generated: undefined;
3858
+ }, {}, {}>;
3859
+ };
3860
+ dialect: "pg";
3861
+ }>;
package/src/db/schema.js CHANGED
@@ -31,6 +31,14 @@ const batches = qa.table(
31
31
  },
32
32
  (t) => [primaryKey({ columns: [t.projectId, t.id] })]
33
33
  );
34
+ const taxonomyShape = (document, projectId) => sql`NOT (${document} ? 'taxonomy') OR (
35
+ jsonb_typeof(${document}->'taxonomy') = 'object'
36
+ AND jsonb_typeof(${document}->'taxonomy'->'project') = 'string'
37
+ AND ${document}->'taxonomy'->>'project' = ${projectId}
38
+ AND jsonb_typeof(${document}->'taxonomy'->'version') = 'string'
39
+ AND length(${document}->'taxonomy'->>'version') BETWEEN 1 AND 70
40
+ ) IS TRUE`;
41
+ const categoryShape = (document) => sql`NOT (${document} ? 'category') OR jsonb_typeof(${document}->'category') IN ('null', 'string')`;
34
42
  const runs = qa.table(
35
43
  "runs",
36
44
  {
@@ -62,13 +70,18 @@ const runs = qa.table(
62
70
  foreignColumns: [batches.projectId, batches.id]
63
71
  }),
64
72
  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
- ),
73
+ check("run_classification", sql`length(${t.classification}) BETWEEN 1 AND 70`),
69
74
  check(
70
75
  "run_classification_metadata",
71
- sql`${t.metadata}->'failureClassification'->>'category' IN ('product-bug','test-case','env','flaky','agent')`
76
+ sql`NOT (${t.metadata} ? 'failureClassification')
77
+ OR jsonb_typeof(${t.metadata}->'failureClassification') = 'null'
78
+ OR (jsonb_typeof(${t.metadata}->'failureClassification') = 'object'
79
+ AND (${categoryShape(sql`(${t.metadata}->'failureClassification')`)})
80
+ AND (NOT (${t.metadata}->'failureClassification' ? 'taxonomy') OR (
81
+ (${taxonomyShape(sql`(${t.metadata}->'failureClassification')`, t.projectId)})
82
+ AND (${t.metadata}->'failureClassification' ? 'category')
83
+ AND ${t.metadata}->'failureClassification'->>'category' IS NOT DISTINCT FROM ${t.classification}
84
+ )))`
72
85
  ),
73
86
  check(
74
87
  "run_cursor_nonnegative",
@@ -82,6 +95,8 @@ const resultNotifications = qa.table(
82
95
  projectId: project(),
83
96
  batchId: text("batch_id").notNull(),
84
97
  channel: text("channel").notNull(),
98
+ kind: text("kind"),
99
+ provider: text("provider"),
85
100
  context: jsonb("context").notNull(),
86
101
  completedAt: timestamp("completed_at", { withTimezone: true }),
87
102
  abandonedAt: timestamp("abandoned_at", { withTimezone: true }),
@@ -94,7 +109,15 @@ const resultNotifications = qa.table(
94
109
  columns: [t.projectId, t.batchId],
95
110
  foreignColumns: [batches.projectId, batches.id]
96
111
  }),
97
- check("result_notification_channel", sql`${t.channel} IN ('commit','pr','discord')`),
112
+ check("result_notification_channel", sql`${t.channel} ~ '^[a-z][a-z0-9-]{0,69}$'`),
113
+ check(
114
+ "result_notification_route",
115
+ sql`(${t.kind} IS NULL AND ${t.provider} IS NULL) OR (
116
+ ${t.kind} IS NOT NULL AND ${t.provider} IS NOT NULL
117
+ AND ${t.kind} ~ '^[a-z][a-z0-9.-]{0,63}$'
118
+ AND ${t.provider} ~ '^[a-z][a-z0-9-]{0,63}$'
119
+ )`
120
+ ),
98
121
  check("result_notification_attempts", sql`${t.attempts} BETWEEN 0 AND 5`),
99
122
  index("result_notifications_pending").on(t.availableAt).where(sql`${t.completedAt} IS NULL AND ${t.abandonedAt} IS NULL`)
100
123
  ]
@@ -445,18 +468,23 @@ const classificationLabels = qa.table(
445
468
  reason: text("reason").notNull(),
446
469
  modifiedBy: text("modified_by").notNull(),
447
470
  modifiedAt: time("modified_at"),
448
- predicted: jsonb("predicted").$type()
471
+ predicted: jsonb("predicted").$type(),
472
+ details: jsonb("details").$type()
449
473
  },
450
474
  (t) => [
451
475
  primaryKey({ columns: [t.projectId, t.runId, t.ordinal] }),
452
476
  foreignKey({ columns: [t.projectId, t.runId], foreignColumns: [runs.projectId, runs.id] }),
477
+ check("classification_label_category", sql`length(${t.category}) BETWEEN 1 AND 70`),
453
478
  check(
454
- "classification_label_category",
455
- sql`${t.category} IN ('product-bug','test-case','env','flaky','agent')`
479
+ "classification_prediction_category",
480
+ sql`jsonb_typeof(${t.predicted}) = 'null' OR (jsonb_typeof(${t.predicted}) = 'object'
481
+ AND (${categoryShape(sql`${t.predicted}`)})
482
+ AND (${taxonomyShape(sql`${t.predicted}`, t.projectId)}))`
456
483
  ),
457
484
  check(
458
- "classification_prediction_category",
459
- sql`${t.predicted}->>'category' IN ('product-bug','test-case','env','flaky','agent')`
485
+ "classification_label_details",
486
+ sql`jsonb_typeof(${t.details}) = 'object'
487
+ AND (${taxonomyShape(sql`${t.details}`, t.projectId)})`
460
488
  )
461
489
  ]
462
490
  );
@@ -473,8 +501,50 @@ const workerSlots = qa.table(
473
501
  uniqueIndex("worker_slot_job").on(t.projectId, t.jobId)
474
502
  ]
475
503
  );
504
+ const trialGroups = qa.table(
505
+ "trial_groups",
506
+ {
507
+ projectId: project(),
508
+ groupId: text("group_id").notNull(),
509
+ flow: text("flow").notNull(),
510
+ startedAt: time("started_at"),
511
+ document: jsonb("document").notNull()
512
+ },
513
+ (t) => [
514
+ primaryKey({ columns: [t.projectId, t.groupId] }),
515
+ index("trial_groups_flow").on(t.projectId, t.flow, t.startedAt)
516
+ ]
517
+ );
518
+ const trialGroupReceipts = qa.table(
519
+ "trial_group_receipts",
520
+ {
521
+ projectId: project(),
522
+ groupId: text("group_id").notNull(),
523
+ key: text("key").notNull(),
524
+ document: jsonb("document").notNull()
525
+ },
526
+ (t) => [
527
+ primaryKey({ columns: [t.projectId, t.groupId, t.key] }),
528
+ foreignKey({
529
+ columns: [t.projectId, t.groupId],
530
+ foreignColumns: [trialGroups.projectId, trialGroups.groupId],
531
+ name: "trial_group_receipts_group"
532
+ })
533
+ ]
534
+ );
535
+ const auditDecisions = qa.table(
536
+ "audit_decisions",
537
+ {
538
+ projectId: project(),
539
+ subject: text("subject").notNull(),
540
+ key: text("key").notNull(),
541
+ document: jsonb("document").notNull()
542
+ },
543
+ (t) => [primaryKey({ columns: [t.projectId, t.subject, t.key] })]
544
+ );
476
545
  export {
477
546
  artifacts,
547
+ auditDecisions,
478
548
  batches,
479
549
  cacheEntries,
480
550
  classificationLabels,
@@ -497,5 +567,7 @@ export {
497
567
  runs,
498
568
  serverSubmissions,
499
569
  stepRuns,
570
+ trialGroupReceipts,
571
+ trialGroups,
500
572
  workerSlots
501
573
  };