@derwinjs/db 0.11.0 → 0.13.0
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/dist/cost-regression-evaluator.d.ts +48 -0
- package/dist/cost-regression-evaluator.d.ts.map +1 -0
- package/dist/cost-regression-evaluator.js +114 -0
- package/dist/cost-regression-evaluator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/learning-health-reporter.d.ts.map +1 -1
- package/dist/learning-health-reporter.js +14 -3
- package/dist/learning-health-reporter.js.map +1 -1
- package/dist/qa-audit-artifact-store.d.ts +25 -0
- package/dist/qa-audit-artifact-store.d.ts.map +1 -0
- package/dist/qa-audit-artifact-store.js +60 -0
- package/dist/qa-audit-artifact-store.js.map +1 -0
- package/dist/self-review-verdict-store.d.ts +29 -0
- package/dist/self-review-verdict-store.d.ts.map +1 -0
- package/dist/self-review-verdict-store.js +167 -0
- package/dist/self-review-verdict-store.js.map +1 -0
- package/package.json +3 -3
- package/prisma/migrations/20260510000000_sprint13_phase9_self_review_verdict/migration.sql +73 -0
- package/prisma/schema.prisma +54 -3
- package/prisma-client/edge.js +21 -5
- package/prisma-client/index-browser.js +18 -2
- package/prisma-client/index.d.ts +2423 -177
- package/prisma-client/index.js +21 -5
- package/prisma-client/package.json +1 -1
- package/prisma-client/schema.prisma +54 -3
- package/prisma-client/wasm.js +18 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
-- Sprint 13 Phase 9 (QAP-133) — Recursive self-review verdict audit trail.
|
|
2
|
+
--
|
|
3
|
+
-- Adds:
|
|
4
|
+
-- 1. New AttemptStatus enum value `MANUAL_REVIEW_REQUIRED` — set by the
|
|
5
|
+
-- orchestrator when the recursive self-reviewer returns 'fail' or
|
|
6
|
+
-- 'manual_review_required'. Blocks dispatch until an operator overrides
|
|
7
|
+
-- via the orchestrate route's `?force=true` query flag.
|
|
8
|
+
-- 2. New `derwin.self_review_verdicts` table — one row per self-review call
|
|
9
|
+
-- regardless of outcome. Persisted by both the orchestrator (every fix
|
|
10
|
+
-- cycle) and the admin POST /qa/fix-attempts/:id/self-review route.
|
|
11
|
+
-- The `?force=true` operator-override path also writes here with
|
|
12
|
+
-- verdict='pass' and reasonHints capturing the operator's userId so
|
|
13
|
+
-- every override is auditable.
|
|
14
|
+
-- 3. Indexes:
|
|
15
|
+
-- - (projectId) for tenant-scoped scans
|
|
16
|
+
-- - (qaFixAttemptId) for the per-attempt latest-verdict lookup
|
|
17
|
+
-- - (projectId, classification, surface) for cohort dashboards
|
|
18
|
+
-- - (projectId, createdAt DESC) for the recent-verdicts pane
|
|
19
|
+
-- 4. Foreign keys to derwin.projects and derwin.qa_fix_attempts (cascade
|
|
20
|
+
-- on delete — deleting a project/attempt removes its verdict trail).
|
|
21
|
+
--
|
|
22
|
+
-- Idempotent (IF NOT EXISTS) — safe to re-run on environments where parts
|
|
23
|
+
-- of the migration already landed.
|
|
24
|
+
|
|
25
|
+
-- ─── 1. Extend AttemptStatus enum ───────────────────────────────────────────
|
|
26
|
+
-- ALTER TYPE ... ADD VALUE is not transactional in Postgres < 12, but Prisma
|
|
27
|
+
-- supports it on 12+ which is our target. IF NOT EXISTS guards against
|
|
28
|
+
-- re-running on environments where this already landed.
|
|
29
|
+
|
|
30
|
+
ALTER TYPE "AttemptStatus" ADD VALUE IF NOT EXISTS 'MANUAL_REVIEW_REQUIRED';
|
|
31
|
+
|
|
32
|
+
-- ─── 2. self_review_verdicts table ──────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
CREATE TABLE IF NOT EXISTS "derwin"."self_review_verdicts" (
|
|
35
|
+
"id" TEXT NOT NULL,
|
|
36
|
+
"projectId" TEXT NOT NULL,
|
|
37
|
+
"qaFixAttemptId" TEXT NOT NULL,
|
|
38
|
+
"qaTicketId" TEXT NOT NULL,
|
|
39
|
+
"classification" TEXT NOT NULL,
|
|
40
|
+
"surface" TEXT NOT NULL,
|
|
41
|
+
"verdict" TEXT NOT NULL,
|
|
42
|
+
"reasonHints" TEXT[] NOT NULL,
|
|
43
|
+
"criticalIssuesFound" INTEGER NOT NULL,
|
|
44
|
+
"minorIssuesFound" INTEGER NOT NULL,
|
|
45
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
46
|
+
CONSTRAINT "self_review_verdicts_pkey" PRIMARY KEY ("id")
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
-- ─── 3. Indexes ────────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
CREATE INDEX IF NOT EXISTS "self_review_verdicts_projectId_idx"
|
|
52
|
+
ON "derwin"."self_review_verdicts"("projectId");
|
|
53
|
+
|
|
54
|
+
CREATE INDEX IF NOT EXISTS "self_review_verdicts_qaFixAttemptId_idx"
|
|
55
|
+
ON "derwin"."self_review_verdicts"("qaFixAttemptId");
|
|
56
|
+
|
|
57
|
+
CREATE INDEX IF NOT EXISTS "self_review_verdicts_projectId_classification_surface_idx"
|
|
58
|
+
ON "derwin"."self_review_verdicts"("projectId", "classification", "surface");
|
|
59
|
+
|
|
60
|
+
CREATE INDEX IF NOT EXISTS "self_review_verdicts_projectId_createdAt_idx"
|
|
61
|
+
ON "derwin"."self_review_verdicts"("projectId", "createdAt" DESC);
|
|
62
|
+
|
|
63
|
+
-- ─── 4. Foreign keys ───────────────────────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
ALTER TABLE "derwin"."self_review_verdicts"
|
|
66
|
+
ADD CONSTRAINT "self_review_verdicts_projectId_fkey"
|
|
67
|
+
FOREIGN KEY ("projectId") REFERENCES "derwin"."projects"("id")
|
|
68
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
69
|
+
|
|
70
|
+
ALTER TABLE "derwin"."self_review_verdicts"
|
|
71
|
+
ADD CONSTRAINT "self_review_verdicts_qaFixAttemptId_fkey"
|
|
72
|
+
FOREIGN KEY ("qaFixAttemptId") REFERENCES "derwin"."qa_fix_attempts"("id")
|
|
73
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -153,6 +153,7 @@ model Project {
|
|
|
153
153
|
tenantFuzzConfig TenantFuzzConfig?
|
|
154
154
|
rumSamples RumSample[]
|
|
155
155
|
milestoneEvents MilestoneEvent[]
|
|
156
|
+
selfReviewVerdicts SelfReviewVerdict[]
|
|
156
157
|
|
|
157
158
|
@@map("projects")
|
|
158
159
|
@@schema("derwin")
|
|
@@ -485,9 +486,10 @@ model QAFixAttempt {
|
|
|
485
486
|
attemptedAt DateTime @default(now())
|
|
486
487
|
closedAt DateTime?
|
|
487
488
|
|
|
488
|
-
ticket
|
|
489
|
-
project
|
|
490
|
-
artifacts
|
|
489
|
+
ticket QATicket @relation(fields: [qaTicketId], references: [id], onDelete: Cascade)
|
|
490
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
491
|
+
artifacts AuditArtifact[]
|
|
492
|
+
selfReviewVerdicts SelfReviewVerdict[]
|
|
491
493
|
|
|
492
494
|
@@index([qaTicketId, attemptNumber])
|
|
493
495
|
@@index([projectId, attemptedAt(sort: Desc)])
|
|
@@ -505,6 +507,11 @@ enum AttemptStatus {
|
|
|
505
507
|
REJECTED
|
|
506
508
|
REGRESSED_REVERTED
|
|
507
509
|
FAILED
|
|
510
|
+
// QAP-133 (Sprint 13 Phase 9). Set by the orchestrator when the recursive
|
|
511
|
+
// self-reviewer returns 'fail' or 'manual_review_required'. Blocks dispatch
|
|
512
|
+
// until an operator overrides via the orchestrate route's ?force=true flag
|
|
513
|
+
// (which auditably writes a synthetic SelfReviewVerdict 'pass' row).
|
|
514
|
+
MANUAL_REVIEW_REQUIRED
|
|
508
515
|
|
|
509
516
|
@@schema("derwin")
|
|
510
517
|
}
|
|
@@ -1171,3 +1178,47 @@ model MilestoneEvent {
|
|
|
1171
1178
|
@@map("milestone_events")
|
|
1172
1179
|
@@schema("derwin")
|
|
1173
1180
|
}
|
|
1181
|
+
|
|
1182
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1183
|
+
// QAP-133 (Sprint 13 Phase 9) — Recursive self-review verdict audit trail.
|
|
1184
|
+
//
|
|
1185
|
+
// Pre-merge gate: the recursive self-reviewer (Anthropic-backed adapter
|
|
1186
|
+
// reviewing Claude's own diff) emits one verdict row per call. The
|
|
1187
|
+
// orchestrator persists every call's verdict regardless of outcome — the
|
|
1188
|
+
// audit trail is non-negotiable. The orchestrate route's `?force=true`
|
|
1189
|
+
// override path also writes here with verdict='pass' and reasonHints
|
|
1190
|
+
// capturing the operator's userId so every override is auditable.
|
|
1191
|
+
//
|
|
1192
|
+
// Tenant scope: every read/write filters by projectId (Pattern D). The
|
|
1193
|
+
// (projectId, classification, surface) compound index supports cohort
|
|
1194
|
+
// queries surfaced on the dashboard. The (projectId, createdAt desc)
|
|
1195
|
+
// index supports the recent-verdicts pane.
|
|
1196
|
+
//
|
|
1197
|
+
// The Prisma-backed implementation lives at
|
|
1198
|
+
// packages/db/src/self-review-verdict-store.ts; the SDK contract is in
|
|
1199
|
+
// @derwinjs/sdk (SelfReviewVerdictStore in
|
|
1200
|
+
// packages/sdk/src/types/self-review-verdict-store.ts).
|
|
1201
|
+
|
|
1202
|
+
model SelfReviewVerdict {
|
|
1203
|
+
id String @id @default(cuid())
|
|
1204
|
+
projectId String
|
|
1205
|
+
qaFixAttemptId String
|
|
1206
|
+
qaTicketId String
|
|
1207
|
+
classification String // mirrored from QATicket for cohort analysis
|
|
1208
|
+
surface String // mirrored from QATicket for cohort analysis
|
|
1209
|
+
verdict String // 'pass' | 'fail' | 'manual_review_required'
|
|
1210
|
+
reasonHints String[] // pgsql native array; reasonHints from the SDK
|
|
1211
|
+
criticalIssuesFound Int
|
|
1212
|
+
minorIssuesFound Int
|
|
1213
|
+
createdAt DateTime @default(now())
|
|
1214
|
+
|
|
1215
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
1216
|
+
qaFixAttempt QAFixAttempt @relation(fields: [qaFixAttemptId], references: [id], onDelete: Cascade)
|
|
1217
|
+
|
|
1218
|
+
@@index([projectId])
|
|
1219
|
+
@@index([qaFixAttemptId])
|
|
1220
|
+
@@index([projectId, classification, surface]) // cohort queries
|
|
1221
|
+
@@index([projectId, createdAt(sort: Desc)]) // recent verdicts
|
|
1222
|
+
@@map("self_review_verdicts")
|
|
1223
|
+
@@schema("derwin")
|
|
1224
|
+
}
|