File size: 113,026 Bytes
ad4c666
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
--
-- PostgreSQL database dump
--

\restrict THevuI5nL8va278qqO7jMSTP5LK8tqxqzRceXTedW4fR4pqR5ttaHEIfQb9Nuug

-- Dumped from database version 16.14 (Debian 16.14-1.pgdg12+1)
-- Dumped by pg_dump version 16.14 (Debian 16.14-1.pgdg12+1)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;


--
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';


--
-- Name: vector; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS vector WITH SCHEMA public;


--
-- Name: EXTENSION vector; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION vector IS 'vector data type and ivfflat and hnsw access methods';


--
-- Name: capability_tag_t; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public.capability_tag_t AS ENUM (
    'concise',
    'summarization',
    'thinking_mode',
    'tool_calling'
);


--
-- Name: pipeline_status_t; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public.pipeline_status_t AS ENUM (
    'INGESTED',
    'DEDUPED',
    'SCORED',
    'PUBLISHABLE'
);


--
-- Name: review_dimension; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE public.review_dimension AS ENUM (
    'overall',
    'correctness',
    'teaching_value',
    'language_quality',
    'completeness',
    'cultural_accuracy'
);


--
-- Name: model_format_spec_touch_updated_at(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.model_format_spec_touch_updated_at() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
    NEW.updated_at := now();
    RETURN NEW;
END;
$$;


--
-- Name: set_pipeline_status(text, public.pipeline_status_t, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.set_pipeline_status(p_content_hash text, p_status public.pipeline_status_t, p_reason text DEFAULT NULL::text) RETURNS void
    LANGUAGE sql
    AS $$
    UPDATE samples SET pipeline_status = p_status,
                        pipeline_status_reason = p_reason,
                        pipeline_status_updated_at = now()
    WHERE content_hash = p_content_hash;
$$;


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: backfill_progress; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.backfill_progress (
    pass_name text NOT NULL,
    blob_path text NOT NULL,
    done boolean DEFAULT false NOT NULL,
    rows_seen integer DEFAULT 0 NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


--
-- Name: chunks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.chunks (
    chunk_hash text NOT NULL,
    parent_hash text NOT NULL,
    "position" integer NOT NULL,
    chunk_text text NOT NULL,
    n_chars integer NOT NULL,
    embedding public.vector(768),
    lang text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    kb_doc_id bigint
)
WITH (autovacuum_vacuum_insert_scale_factor='0.02');


--
-- Name: TABLE chunks; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.chunks IS 'RAG retrieval chunks split from rag_pool-eligible samples (encyclopedic/news/cultural kinds or known factual-crawl sources). ~1200-char chunks, 150-char overlap, sentence-boundary aware. embedding is NULL at write time — populated later by an extended bitdeer embed worker (see generation/embed_worker_bitdeer.py, owned by another task/agent).';


--
-- Name: COLUMN chunks.kb_doc_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.chunks.kb_doc_id IS 'FK to kb_documents — makes this chunk citable with real source/version/license metadata. NULL for chunks ingested before the kb layer existed (e.g. legacy wiki/fineweb chunks); backfill separately, this column addition does not retroactively populate it.';


--
-- Name: coldstart_coding_rollouts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.coldstart_coding_rollouts (
    rollout_id bigint NOT NULL,
    trajectory_id text NOT NULL,
    content_hash text NOT NULL,
    format text DEFAULT 'rowc.selfscaffold.v1'::text,
    role_in_dataset text DEFAULT 'sft_coldstart'::text,
    teacher_model text NOT NULL,
    teacher_quant text,
    teacher_provider text,
    teacher_license text,
    teacher_model_id smallint,
    source text NOT NULL,
    source_id smallint,
    domain text,
    language text,
    task_kind text,
    generated boolean DEFAULT true,
    test_gated boolean DEFAULT false,
    test_passed boolean,
    gate_detail jsonb,
    upstream_task_id text,
    upstream_repo text,
    upstream_commit text,
    task_source text,
    task_source_license text,
    trajectory_blob_path text,
    scaffold_text text,
    stage1_token_count integer,
    stage2_token_count integer,
    obs_token_count integer,
    trainable_token_count integer,
    prompt_tokens integer,
    completion_tokens integer,
    gen_seconds real,
    created_at timestamp with time zone DEFAULT now()
);


--
-- Name: coldstart_coding_rollouts_rollout_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.coldstart_coding_rollouts ALTER COLUMN rollout_id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.coldstart_coding_rollouts_rollout_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: samples; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.samples (
    content_hash text NOT NULL,
    kind text NOT NULL,
    lang text,
    source text NOT NULL,
    minhash bigint[],
    embedding public.vector(768),
    sprapp_filter_score jsonb,
    sprapp_filter_flagged text[],
    quarantined boolean DEFAULT false,
    verify_status text,
    register text,
    promoted boolean DEFAULT false,
    blob_path text NOT NULL,
    row_len_chars integer,
    created_at timestamp with time zone DEFAULT now(),
    near_dup_of text,
    textbook_quality double precision,
    cultural_nuance boolean DEFAULT false,
    cultural_markers text[],
    minhash_algo text DEFAULT 'datasketch_v1'::text,
    license text,
    review_score double precision,
    generated_by_model smallint,
    reviewed_by_model smallint,
    generation_score double precision,
    structural_quality double precision,
    structural_signals jsonb,
    split text,
    perplexity double precision,
    quality_tier text,
    composite_score double precision,
    composite_profile text,
    contaminated boolean DEFAULT false,
    translated_from text,
    text_inline text,
    model_quality_score double precision,
    langid_pred text,
    langid_conf double precision,
    source_id smallint,
    usage_tags text[] DEFAULT '{}'::text[],
    fts tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, COALESCE(text_inline, ''::text))) STORED,
    minhash_packed bytea,
    embedding_h public.halfvec(768),
    shard_id integer,
    kind_id smallint,
    lang_id smallint,
    license_id smallint,
    register_id smallint,
    quality_tier_id smallint,
    split_id smallint,
    gen_temperature double precision,
    gen_max_tokens integer,
    gen_repeat_penalty double precision,
    gen_seed bigint,
    gen_provider text,
    gen_quantization text,
    gen_prompt_variant text,
    pipeline_status public.pipeline_status_t DEFAULT 'INGESTED'::public.pipeline_status_t NOT NULL,
    pipeline_status_updated_at timestamp with time zone DEFAULT now() NOT NULL,
    pipeline_status_reason text,
    restricted_overlap boolean DEFAULT false,
    restricted_overlap_source text,
    capability_tags public.capability_tag_t[],
    pii_detected boolean DEFAULT false,
    pii_types text[],
    input_tokens integer,
    output_tokens integer,
    token_count integer,
    token_count_tokenizer text,
    best_of_n_score double precision,
    cpt_eligible boolean DEFAULT false,
    sft_eligible boolean DEFAULT false,
    ingest_origin text
)
WITH (fillfactor='90', autovacuum_vacuum_scale_factor='0.02', autovacuum_analyze_scale_factor='0.01');
ALTER TABLE ONLY public.samples ALTER COLUMN sprapp_filter_score SET COMPRESSION lz4;
ALTER TABLE ONLY public.samples ALTER COLUMN structural_signals SET COMPRESSION lz4;
ALTER TABLE ONLY public.samples ALTER COLUMN text_inline SET COMPRESSION lz4;


--
-- Name: COLUMN samples.gen_temperature; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.samples.gen_temperature IS 'Sampling temperature used for this row''s generation call, e.g. 0.7-0.85 across the *_ms.py drivers (per-family default from generation/optimal_configs.json via cfg_for()), or gen_sea_data.py''s fixed 0.8 for API generators. NULL = not recorded (pre-2026-07-05 row) or not generated (real/relicensed text).';


--
-- Name: COLUMN samples.gen_max_tokens; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.samples.gen_max_tokens IS 'max_tokens request cap sent to the generating backend for this row. NOT the actual completion length (row_len_chars is) — this is the ceiling; hitting it exactly is a truncation signal cross-checked by structural_quality.py separately.';


--
-- Name: COLUMN samples.gen_repeat_penalty; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.samples.gen_repeat_penalty IS 'llama.cpp/vLLM repeat_penalty param (repeat_last_n=256 fixed across drivers, not itself stored — only the penalty value varies by family). NULL for API generators (MiniMax/GLM) that do not expose this knob via gen_sea_data.py''s call().';


--
-- Name: COLUMN samples.gen_seed; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.samples.gen_seed IS 'Per-request sampling seed, when the backend accepts one. llama.cpp''s /v1/chat/completions takes an integer "seed" field — wired through from the *_ms.py drivers'' worker RNG (NOT reproducible-guaranteed; llama.cpp seed affects the initial RNG state only, not full determinism under batching). MiniMax/GLM APIs (gen_sea_data.py) expose no seed parameter at all as of 2026-07 — always NULL for those rows, by design, not an omission.';


--
-- Name: COLUMN samples.gen_provider; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.samples.gen_provider IS 'Where generation actually ran: ''local-llamacpp'' (the 6 *_ms.py drivers, bitdeer CPU fleet ports 8091-8098/8191), ''minimax-api'' or ''glm-api'' (gen_sea_data.py / gen_concurrent.py), ''local-vllm'' (if/when a vLLM backend is used instead of llama.cpp — same OpenAI-compatible request shape). NULL means unrecorded (older row) or non-generated source — see samples.source/sources table for the latter case.';


--
-- Name: COLUMN samples.gen_quantization; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.samples.gen_quantization IS 'Quantization level of the weights that generated this row, stated EXPLICITLY — never left blank/assumed-full-precision. Known values: ''q8_0'' (current local qwen3.6-35b-a3b-q8.gguf teacher, hardcoded at the driver since the binary itself does not report it back over the API). For API-served models (MiniMax, GLM): ''unknown'' — these providers do NOT disclose quant level in responses, and are known to silently serve quantized variants without saying so in the model name; ''unknown'' here is an honest gap, not a placeholder for ''none''. NULL (distinct from ''unknown'') means this column was not populated at all for the row (older ingest, pre-2026-07-05).';


--
-- Name: COLUMN samples.gen_prompt_variant; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.samples.gen_prompt_variant IS 'template_bandit.py mutator variant_id applied to this row''s prompt before sending to the teacher (e.g. ''toggle_exemplar'', ''format_explicitness'', ''control'' = unmutated base prompt). Populated by gen_sft_ms.py''s apply_prompt_variant() via the driver''s gen_params dict, same wiring as gen_temperature etc above. NULL means EITHER the family has no prompt_variant entry in optimal_configs.json at gen time, OR the row predates this column (pre-2026-07-05 follow-up) — see the NULL-ambiguity note below, same caveat applies here.';


--
-- Name: COLUMN samples.best_of_n_score; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.samples.best_of_n_score IS 'gen_params.best_of_n_score from generation/best_of_n.py''s select_best_of_n() (reward_selection_bestofN_v1 selection_algorithm), when the producing driver ran with --best-of-n N>1. NULL = either N=1 (no-op best-of-n) or row predates this column (pre-2026-07-07 ingest) — same NULL-ambiguity caveat as the other gen_* columns in generation_params_schema.sql.';


--
-- Name: composition_report; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.composition_report AS
 SELECT kind,
    lang,
    source,
    count(*) AS n,
    count(*) FILTER (WHERE promoted) AS n_promoted,
    count(*) FILTER (WHERE quarantined) AS n_quarantined
   FROM public.samples
  GROUP BY kind, lang, source
  ORDER BY (count(*)) DESC;


--
-- Name: contamination_hashes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.contamination_hashes (
    content_hash text NOT NULL,
    eval_set text NOT NULL,
    added_at timestamp with time zone DEFAULT now()
);


--
-- Name: context_size_composition; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.context_size_composition AS
 SELECT lang,
    kind,
    count(*) FILTER (WHERE (input_tokens IS NOT NULL)) AS n_split,
    count(*) FILTER (WHERE (token_count IS NOT NULL)) AS n_bulk,
    avg(input_tokens) AS avg_input_tokens,
    avg(output_tokens) AS avg_output_tokens,
    avg(token_count) AS avg_token_count
   FROM public.samples
  WHERE ((input_tokens IS NOT NULL) OR (token_count IS NOT NULL))
  GROUP BY lang, kind
  ORDER BY (count(*) FILTER (WHERE (input_tokens IS NOT NULL)) + count(*) FILTER (WHERE (token_count IS NOT NULL))) DESC;


--
-- Name: corpus_snapshot_members; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.corpus_snapshot_members (
    snapshot text NOT NULL,
    content_hash text NOT NULL
);


--
-- Name: corpus_snapshots; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.corpus_snapshots (
    name text NOT NULL,
    profile text,
    filter_sql text,
    n_rows bigint,
    manifest_hash text,
    created_at timestamp with time zone DEFAULT now(),
    notes text,
    parent_snapshot text,
    as_of timestamp with time zone,
    selection_algorithm text
);


--
-- Name: corpus_version; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.corpus_version (
    version bigint NOT NULL,
    pass_name text NOT NULL,
    rows_affected bigint NOT NULL,
    at timestamp with time zone DEFAULT now() NOT NULL
);


--
-- Name: TABLE corpus_version; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.corpus_version IS 'Monotonic version counter bumped by pipeline passes after they finish a run (one row per pass-run, not per-row). GET /version on the serving API exposes MAX(version) as the freshness contract for consumers pinning to a corpus state — see CURATION_DOCTRINE.md "Trust layer" section.';


--
-- Name: corpus_version_version_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.corpus_version ALTER COLUMN version ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.corpus_version_version_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: cpt_pool; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.cpt_pool AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf,
    source_id,
    usage_tags,
    fts
   FROM public.samples
  WHERE ((license = ANY (ARRAY['Apache-2.0'::text, 'MIT'::text, 'CC0-1.0'::text, 'CC-BY-4.0'::text, 'CC-BY-SA-4.0'::text, 'CC-BY-SA-3.0'::text, 'ODC-By-1.0'::text])) AND (split = 'train'::text) AND (COALESCE(contaminated, false) = false) AND (near_dup_of IS NULL) AND (COALESCE(quarantined, false) = false) AND ((quality_tier = ANY (ARRAY['head'::text, 'middle'::text])) OR ((quality_tier IS NULL) AND (composite_score >= (0.5)::double precision))));


--
-- Name: VIEW cpt_pool; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.cpt_pool IS 'Base CPT pool: license-safe (excludes ToS-unverified), split=train, not contaminated/near-dup/quarantined, head|middle quality tier (or un-tiered rows with composite_score>=0.5 as a fallback). Per DatologyAI: quality is the globally-beneficial signal — this pool is NOT per-language filtered beyond the shared quality bar. License whitelist per 2026-07-04 policy ruling: Apache-2.0, MIT, CC0-1.0, CC-BY-4.0, CC-BY-SA-4.0, CC-BY-SA-3.0, ODC-By-1.0 — attribution/ShareAlike obligations for the CC-BY*/ODC-By licenses are handled in the model card, not by exclusion here.';


--
-- Name: gold_candidates; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.gold_candidates AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf
   FROM public.samples
  WHERE ((NOT quarantined) AND (NOT contaminated) AND (near_dup_of IS NULL) AND (verify_status IS DISTINCT FROM 'fail'::text) AND ((textbook_quality IS NULL) OR (textbook_quality >= (0.4)::double precision)) AND ((structural_quality IS NULL) OR (structural_quality >= (0.5)::double precision)) AND (license = ANY (ARRAY['Apache-2.0'::text, 'MIT'::text, 'CC0'::text, 'CC-BY-4.0'::text])))
  ORDER BY textbook_quality DESC NULLS LAST, cultural_nuance DESC;


--
-- Name: heal_pool; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.heal_pool AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf,
    source_id,
    usage_tags,
    fts,
    minhash_packed,
    embedding_h,
    shard_id,
    kind_id,
    lang_id,
    license_id,
    register_id,
    quality_tier_id,
    split_id
   FROM public.samples
  WHERE ((license = ANY (ARRAY['Apache-2.0'::text, 'MIT'::text, 'CC0-1.0'::text, 'CC-BY-4.0'::text, 'CC-BY-SA-4.0'::text, 'CC-BY-SA-3.0'::text, 'ODC-By-1.0'::text])) AND ((split IS NULL) OR (split = 'train'::text)) AND (COALESCE(contaminated, false) = false) AND (near_dup_of IS NULL) AND (COALESCE(quarantined, false) = false) AND ((structural_quality IS NULL) OR (structural_quality >= (0.5)::double precision)));


--
-- Name: VIEW heal_pool; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.heal_pool IS 'Ternary QAT-heal data pool: license-safe (CPT whitelist incl ODC-By/CC-BY-SA), split=train-or-unscored, not contaminated/near-dup/quarantined, structural_quality>=0.5-or-unscored. DOMAIN-FLOOR CONTRACT (enforced by the exporter, pipeline/heal_mix_export.py, not by this view): a heal mix drawn from this pool must be (a) >=40% general-web tokens (fineweb2/cc100-style sources), (b) the remaining <=60% floor-mixed across kind-groups (reasoning/sft/cultural/encyclopedic/news/dialogue/other) so no single domain dominates via repetition/cycling, and (c) globally shuffle-interleaved in final row order (measured: sequential domain files caused late-phase overfit twice, DATA_BUDGET_PROJECTION.md §4/§7). This view only answers "is this row heal-eligible at all" — it deliberately has no notion of proportion or order, since a SQL view result has no meaningful row order to depend on.';


--
-- Name: heal_pool_supply; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.heal_pool_supply AS
 SELECT
        CASE
            WHEN ((kind = ANY (ARRAY['web'::text, 'webtext'::text, 'web-informal'::text])) OR (source ~~* '%fineweb%'::text) OR (source = 'cc100_ms'::text)) THEN 'general_web'::text
            WHEN (kind = 'encyclopedic'::text) THEN 'encyclopedic'::text
            WHEN (kind = ANY (ARRAY['d1-logic'::text, 'd1-plan'::text, 'd1-math'::text, 'd1-estimate'::text])) THEN 'reasoning'::text
            WHEN (kind = ANY (ARRAY['d2-openbook'::text, 'd3-tool'::text, 'd5-code'::text, 'long-form'::text])) THEN 'sft'::text
            WHEN (kind = 'cultural'::text) THEN 'cultural'::text
            WHEN (kind = 'news'::text) THEN 'news'::text
            WHEN (kind = ANY (ARRAY['factual-qa'::text, 'parallel-translation'::text])) THEN 'dialogue'::text
            ELSE 'other'::text
        END AS kind_group,
    count(*) AS n_rows,
    (sum(
        CASE
            WHEN (text_inline IS NOT NULL) THEN ((array_length(regexp_split_to_array(TRIM(BOTH FROM text_inline), '\s+'::text), 1))::numeric * 1.3)
            ELSE (((COALESCE(row_len_chars, 0))::numeric / 7.04) * 1.3)
        END))::bigint AS est_tokens
   FROM public.heal_pool
  GROUP BY
        CASE
            WHEN ((kind = ANY (ARRAY['web'::text, 'webtext'::text, 'web-informal'::text])) OR (source ~~* '%fineweb%'::text) OR (source = 'cc100_ms'::text)) THEN 'general_web'::text
            WHEN (kind = 'encyclopedic'::text) THEN 'encyclopedic'::text
            WHEN (kind = ANY (ARRAY['d1-logic'::text, 'd1-plan'::text, 'd1-math'::text, 'd1-estimate'::text])) THEN 'reasoning'::text
            WHEN (kind = ANY (ARRAY['d2-openbook'::text, 'd3-tool'::text, 'd5-code'::text, 'long-form'::text])) THEN 'sft'::text
            WHEN (kind = 'cultural'::text) THEN 'cultural'::text
            WHEN (kind = 'news'::text) THEN 'news'::text
            WHEN (kind = ANY (ARRAY['factual-qa'::text, 'parallel-translation'::text])) THEN 'dialogue'::text
            ELSE 'other'::text
        END
  ORDER BY ((sum(
        CASE
            WHEN (text_inline IS NOT NULL) THEN ((array_length(regexp_split_to_array(TRIM(BOTH FROM text_inline), '\s+'::text), 1))::numeric * 1.3)
            ELSE (((COALESCE(row_len_chars, 0))::numeric / 7.04) * 1.3)
        END))::bigint) DESC;


--
-- Name: VIEW heal_pool_supply; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.heal_pool_supply IS 'Human-facing sanity check only — approximate token supply per kind-group in heal_pool, same estimator convention as heal_mix_export.py (words*1.3; CHARS_PER_WORD_BULK=7.04 for rows without text_inline, measured from /mnt/raid0/cpt_ms_bulk/filter_summary.json). Not read by the exporter itself.';


--
-- Name: kb_documents; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.kb_documents (
    id bigint NOT NULL,
    title text NOT NULL,
    source_url text,
    source_org text,
    license text NOT NULL,
    version_date date,
    retrieval_date date DEFAULT CURRENT_DATE NOT NULL,
    doc_type text NOT NULL,
    content_hash text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT kb_documents_doc_type_check CHECK ((doc_type = ANY (ARRAY['first-aid'::text, 'encyclopedic'::text, 'faq'::text, 'legal'::text])))
);


--
-- Name: TABLE kb_documents; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.kb_documents IS 'Knowledge-base document registry: real source/version/license metadata so a RAG answer can cite "per kb_documents.title (kb_documents.source_org), dated kb_documents.version_date, kb_documents.license" instead of just a free-text samples.source label. One row per distinct fetched document (article/guide/page), NOT per chunk — chunks.kb_doc_id (see below) links many chunks to one kb_documents row.';


--
-- Name: kb_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.kb_documents ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.kb_documents_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: kinds; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.kinds (
    id smallint NOT NULL,
    name text NOT NULL
);


--
-- Name: kinds_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.kinds ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.kinds_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: label_audit; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.label_audit (
    id bigint NOT NULL,
    content_hash text NOT NULL,
    column_name text NOT NULL,
    old_value text,
    new_value text,
    pass_name text NOT NULL,
    changed_at timestamp with time zone DEFAULT now() NOT NULL
);


--
-- Name: TABLE label_audit; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.label_audit IS 'Lineage trail for samples column changes. Populated BY CONVENTION (no trigger — avoids write-amplification on the hot `samples` table): each pipeline pass that mutates a column calls pipeline/audit_helper.py log_label_change()/bulk_log_label_changes() itself. Absence of rows for a given (content_hash, column) does not prove the value never changed — only that no pass has adopted the convention for that change yet.';


--
-- Name: label_audit_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.label_audit ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.label_audit_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: lang_quality_config; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.lang_quality_config (
    lang text NOT NULL,
    textbook_min double precision DEFAULT 0.40,
    structural_min double precision DEFAULT 0.50,
    composite_min double precision DEFAULT 0.55,
    perplexity_head_max double precision,
    perplexity_tail_min double precision,
    set_by text,
    notes text,
    updated_at timestamp with time zone DEFAULT now()
);


--
-- Name: lang_token_budget; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.lang_token_budget AS
 SELECT lang,
    count(*) AS n_rows,
    count(*) FILTER (WHERE (split = 'train'::text)) AS n_train,
    sum(row_len_chars) AS total_chars,
    round(((sum(row_len_chars))::numeric / 4.0)) AS approx_tokens,
    round((avg(composite_score))::numeric, 3) AS avg_composite,
    count(*) FILTER (WHERE (quality_tier = 'head'::text)) AS n_head
   FROM public.samples
  GROUP BY lang
  ORDER BY (round(((sum(row_len_chars))::numeric / 4.0))) DESC NULLS LAST;


--
-- Name: langs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.langs (
    id smallint NOT NULL,
    name text NOT NULL
);


--
-- Name: langs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.langs ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.langs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: licenses; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.licenses (
    id smallint NOT NULL,
    name text NOT NULL
);


--
-- Name: licenses_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.licenses ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.licenses_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: lora_pool_high; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.lora_pool_high AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf,
    source_id,
    usage_tags,
    fts
   FROM public.cpt_pool
  WHERE (register = 'HIGH'::text);


--
-- Name: VIEW lora_pool_high; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.lora_pool_high IS 'Register-pure (HIGH) slice of cpt_pool — register-LoRA training only, never a CPT substitute.';


--
-- Name: lora_pool_low; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.lora_pool_low AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf,
    source_id,
    usage_tags,
    fts
   FROM public.cpt_pool
  WHERE (register = 'LOW'::text);


--
-- Name: VIEW lora_pool_low; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.lora_pool_low IS 'Register-pure (LOW) slice of cpt_pool — register-LoRA training only, never a CPT substitute.';


--
-- Name: lora_pool_mid; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.lora_pool_mid AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf,
    source_id,
    usage_tags,
    fts
   FROM public.cpt_pool
  WHERE (register = 'MID'::text);


--
-- Name: VIEW lora_pool_mid; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.lora_pool_mid IS 'Register-pure (MID) slice of cpt_pool — register-LoRA training only, never a CPT substitute.';


--
-- Name: model_format_spec; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.model_format_spec (
    id bigint NOT NULL,
    model_id text NOT NULL,
    model_family text NOT NULL,
    task_type text NOT NULL,
    assistant_target_template text NOT NULL,
    think_block_convention text,
    eval_harness_ref text,
    direction text,
    example text,
    notes text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT model_format_spec_think_block_convention_check CHECK ((think_block_convention = ANY (ARRAY['none'::text, 'empty_marker_kept'::text, 'stripped_at_eval'::text, 'pending_verify'::text])))
);


--
-- Name: TABLE model_format_spec; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.model_format_spec IS 'Per-(model_id, task_type) assistant-target output-format registry. Generation + pretok pipelines look up the exact required output shape + eval-parse contract here so we never train the wrong assistant-target format. See header of pipeline/model_format_spec_schema.sql for the Nanbeige-3B SEA-HELM bug it encodes.';


--
-- Name: COLUMN model_format_spec.assistant_target_template; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.model_format_spec.assistant_target_template IS 'Exact assistant-target output shape. {text} is the model-generated payload slot. Literal sentinels like ''clean-answer-no-think-prefix'' / ''rowc.selfscaffold.v1'' name a format contract rather than a fill template.';


--
-- Name: COLUMN model_format_spec.think_block_convention; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.model_format_spec.think_block_convention IS 'How the <think>...</think> block is handled in the assistant target: ''none'' = no think block at all (clean answer only); ''empty_marker_kept'' = the empty "<think>\n\n</think>\n\n" marker is intentionally retained but MUST be stripped by the parser and never leak into the parsed answer; ''stripped_at_eval'' = think block present in the SFT target but removed before the harness parses; ''pending_verify'' = convention not yet decided — the verify stream chooses ''none'' vs ''empty_marker_kept''; current live state is the leak BUG.';


--
-- Name: COLUMN model_format_spec.direction; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.model_format_spec.direction IS 'Translation direction (source->target), e.g. ''ms->en''. NULL for non-directional axes.';


--
-- Name: model_format_spec_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.model_format_spec_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: model_format_spec_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.model_format_spec_id_seq OWNED BY public.model_format_spec.id;


--
-- Name: models; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.models (
    id smallint NOT NULL,
    name text NOT NULL
);


--
-- Name: models_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.models ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.models_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: ms_train_gold; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.ms_train_gold AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf
   FROM public.samples
  WHERE ((lang = 'ms'::text) AND (split = 'train'::text) AND (NOT contaminated) AND (NOT quarantined) AND (near_dup_of IS NULL) AND (verify_status IS DISTINCT FROM 'fail'::text) AND ((structural_quality IS NULL) OR (structural_quality >= (0.5)::double precision)) AND (license = ANY (ARRAY['Apache-2.0'::text, 'MIT'::text, 'CC0'::text, 'CC-BY-4.0'::text, 'ODC-By-1.0'::text])));


--
-- Name: near_dup_scan_progress; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.near_dup_scan_progress (
    id integer NOT NULL,
    table_name text NOT NULL,
    kind text,
    lang text,
    source text,
    label_provenance text,
    minhash_algo text NOT NULL,
    threshold double precision NOT NULL,
    row_count integer,
    dup_marked integer,
    started_at timestamp with time zone DEFAULT now(),
    finished_at timestamp with time zone,
    status text DEFAULT 'running'::text
);


--
-- Name: near_dup_scan_progress_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.near_dup_scan_progress_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: near_dup_scan_progress_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.near_dup_scan_progress_id_seq OWNED BY public.near_dup_scan_progress.id;


--
-- Name: parked_datasets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.parked_datasets (
    id smallint NOT NULL,
    hf_repo text NOT NULL,
    name text NOT NULL,
    decline_reason text,
    decline_category text,
    cleanroom_viable boolean,
    cleanroom_notes text,
    cleanroom_output_source text,
    discovered_date date,
    reviewed_by text DEFAULT 'agent-review'::text,
    CONSTRAINT parked_datasets_decline_category_check CHECK ((decline_category = ANY (ARRAY['license-unclear'::text, 'language-mismatch'::text, 'synthetic-competing-weights'::text, 'other'::text])))
);


--
-- Name: parked_datasets_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.parked_datasets ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.parked_datasets_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: pii_composition; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.pii_composition AS
 SELECT lang,
    unnest(pii_types) AS pii_type,
    count(*) AS n
   FROM public.samples
  WHERE (pii_detected = true)
  GROUP BY lang, (unnest(pii_types))
  ORDER BY (count(*)) DESC;


--
-- Name: processing_state; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.processing_state (
    content_hash text NOT NULL,
    tbl text NOT NULL,
    pass_name text NOT NULL,
    pass_version text NOT NULL,
    status text DEFAULT 'done'::text NOT NULL,
    detail text,
    updated_at timestamp with time zone DEFAULT now()
);


--
-- Name: quality_profiles; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.quality_profiles (
    name text NOT NULL,
    weights jsonb NOT NULL,
    description text,
    is_active boolean DEFAULT false,
    created_at timestamp with time zone DEFAULT now()
);


--
-- Name: quality_tiers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.quality_tiers (
    id smallint NOT NULL,
    name text NOT NULL
);


--
-- Name: quality_tiers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.quality_tiers ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.quality_tiers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: rag_pool; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.rag_pool AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf,
    source_id,
    usage_tags,
    fts
   FROM public.samples
  WHERE (((kind = ANY (ARRAY['encyclopedic'::text, 'news'::text, 'cultural'::text])) OR (source ~~* '%wiki%'::text) OR (source ~~* '%fineweb%'::text) OR (source ~~* '%news%'::text)) AND (embedding IS NOT NULL) AND (COALESCE(quarantined, false) = false) AND (COALESCE(contaminated, false) = false));


--
-- Name: VIEW rag_pool; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.rag_pool IS 'RAG retrieval pool: kind in (encyclopedic,news,cultural) OR source matches known factual-crawl patterns (wiki/fineweb/news), requires embedding NOT NULL. NOTE: as of 2026-07-04 no rows carry kind=encyclopedic/news yet (legacy ingests labelled webtext/unknown) — the source-pattern clause is the effective filter today; re-tag `kind` upstream to tighten.';


--
-- Name: reg_backfill_staging; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.reg_backfill_staging (
    content_hash text NOT NULL,
    register text NOT NULL
);


--
-- Name: registers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.registers (
    id smallint NOT NULL,
    name text NOT NULL
);


--
-- Name: registers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.registers ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.registers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: restricted_corpus_hashes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.restricted_corpus_hashes (
    shingle_hash text NOT NULL,
    source_name text NOT NULL,
    source_kind text DEFAULT 'parked_dataset'::text NOT NULL,
    added_at timestamp with time zone DEFAULT now(),
    notes text
);


--
-- Name: review_batch_rows; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.review_batch_rows (
    batch_id text NOT NULL,
    content_hash text NOT NULL,
    "position" integer NOT NULL,
    reviewed boolean DEFAULT false NOT NULL
);


--
-- Name: TABLE review_batch_rows; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.review_batch_rows IS 'The (up to 165) content_hash rows assigned to one batch, in sampled order (position). reviewed flips to TRUE once the reviewer submits a score for that row via POST /survey/submit, which also writes the real score into the existing `reviews` table (pipeline/reviews_schema.sql) — this table is purely batch/progress bookkeeping, never the score of record.';


--
-- Name: review_batches; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.review_batches (
    batch_id text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by text NOT NULL,
    dimension text DEFAULT 'overall'::text NOT NULL,
    rubric_version text DEFAULT 'r1'::text NOT NULL
);


--
-- Name: TABLE review_batches; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.review_batches IS 'One row per calibration-survey session a human reviewer starts. A reviewer with an incomplete batch (unreviewed rows remain) resumes it rather than getting a fresh 165-row sample — see serving/perahu_survey.py get_or_create_batch().';


--
-- Name: reviews; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.reviews (
    id bigint NOT NULL,
    content_hash text NOT NULL,
    judge smallint NOT NULL,
    dimension public.review_dimension DEFAULT 'overall'::public.review_dimension NOT NULL,
    score double precision NOT NULL,
    reason text,
    rubric_version text DEFAULT 'r1'::text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT reviews_score_check CHECK (((score >= (0)::double precision) AND (score <= (1)::double precision)))
);


--
-- Name: TABLE reviews; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.reviews IS 'Multi-judge, multi-dimension review layer. Many rows per content_hash (one per judge x dimension x rubric_version). samples.review_score / samples.reviewed_by_model are a CACHED AGGREGATE of the overall-dimension consensus (see review_consensus view + reviews_helper.refresh_review_score_cache) - kept for backward compat, THIS TABLE is the source of truth going forward.';


--
-- Name: review_consensus; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.review_consensus AS
 SELECT content_hash,
    dimension,
    rubric_version,
    count(*) AS n_judges,
    avg(score) AS avg_score,
    percentile_cont((0.5)::double precision) WITHIN GROUP (ORDER BY score) AS median_score,
    stddev_samp(score) AS score_stddev
   FROM public.reviews
  GROUP BY content_hash, dimension, rubric_version;


--
-- Name: VIEW review_consensus; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.review_consensus IS 'Per (content_hash, dimension, rubric_version) aggregate across all judges: n_judges, avg/median score, stddev as a disagreement measure (NULL with a single judge). samples.review_score is refreshed FROM this view''s dimension=''overall'' rows — see reviews_helper.refresh_review_score_cache().';


--
-- Name: review_disagreement; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.review_disagreement AS
 SELECT content_hash,
    dimension,
    rubric_version,
    n_judges,
    avg_score,
    median_score,
    score_stddev
   FROM public.review_consensus
  WHERE ((n_judges >= 2) AND (score_stddev > (0.15)::double precision));


--
-- Name: VIEW review_disagreement; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.review_disagreement IS 'Ambiguity queue: (content_hash, dimension, rubric_version) cells where >=2 judges scored the same row and disagree by stddev > 0.15. Feeds active_learning_sample.py as a review-priority signal (judges disagreeing is itself informative — these rows are the ones worth a tie-breaking human/LLM pass or extra scrutiny before promotion).';


--
-- Name: reviews_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.reviews ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.reviews_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: rl_coding_rollouts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.rl_coding_rollouts (
    rollout_id bigint NOT NULL,
    task_id text NOT NULL,
    trajectory_id text,
    format text DEFAULT 'rowc.selfscaffold.v1'::text,
    role_in_dataset text,
    model_checkpoint text,
    training_step bigint,
    behavior_step bigint,
    staleness integer,
    staleness_weight real,
    trajectory_blob_path text,
    scaffold_text text,
    rollout_trace text,
    stage1_token_count integer,
    stage2_token_count integer,
    obs_token_count integer,
    trainable_token_count integer,
    milestone_reached smallint,
    milestone_bitmap smallint,
    milestone_after_last smallint,
    reward_dense real,
    reward_milestones jsonb,
    reward_verifier real,
    reward_judge real,
    reward_total real,
    grpo_group_id text,
    advantage real,
    stage1_credit_weight real DEFAULT 1.0,
    stage2_credit_weight real DEFAULT 1.0,
    flagged_cheating text,
    cheating_layer smallint,
    excluded_from_advantage boolean DEFAULT false,
    env_run_id text,
    created_at timestamp with time zone DEFAULT now(),
    ingest_origin text
);


--
-- Name: rl_coding_rollouts_rollout_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.rl_coding_rollouts ALTER COLUMN rollout_id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.rl_coding_rollouts_rollout_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: rl_coding_tasks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.rl_coding_tasks (
    task_id text NOT NULL,
    source_id smallint,
    repo_url text NOT NULL,
    repo_license text,
    base_commit text NOT NULL,
    generator_method text,
    task_description text NOT NULL,
    category text,
    difficulty text,
    language text,
    test_command text NOT NULL,
    failing_test_ids text[],
    passing_test_ids text[],
    gold_patch text,
    gold_patch_source_model smallint,
    harness_type text,
    harness_ref text,
    env_verified boolean DEFAULT false,
    license_ok boolean,
    build_command text,
    lint_command text,
    typecheck_command text,
    k_of_n_threshold smallint,
    milestone_weights jsonb,
    test_report_format text,
    withheld_paths text[],
    trust_boundary_ref text,
    allowed_tool_surface jsonb,
    scaffold_seed text,
    ingested_at timestamp with time zone DEFAULT now(),
    notes text,
    seed_key text
);


--
-- Name: safety_checks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.safety_checks (
    check_id bigint NOT NULL,
    content_hash text NOT NULL,
    arm text NOT NULL,
    classifier text NOT NULL,
    classifier_version text,
    verdict text NOT NULL,
    categories text[],
    score double precision,
    input_text_sha text,
    translator text DEFAULT 'none'::text NOT NULL,
    translator_version text,
    check_method text NOT NULL,
    run_id text NOT NULL,
    checked_by text NOT NULL,
    ingest_origin text NOT NULL,
    checked_at timestamp with time zone DEFAULT now() NOT NULL,
    notes text
);


--
-- Name: TABLE safety_checks; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.safety_checks IS 'Standardized external + internal safety-classifier verdicts over the Malay corpus. Signal-only (never a gate); LICENSE-SAFE: Aegis/Nemotron verdicts are eval/filter signals, NOT trained into model weights (Llama2/Gemma ToS non-compete). One row = (sample, arm, classifier, run). arm=raw_ms vs translated_en is the bias probe; eval_gold_en = Aegis own test split for calibration F1. checked_by/check_method/classifier_version/translator standardize the "checked/by-who/how" provenance. See docs/SAFETY_CROSSCHECK_PIPELINE.md.';


--
-- Name: safety_check_by_register; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.safety_check_by_register AS
 SELECT s.register,
    sc.classifier,
    sc.arm,
    count(*) AS n,
    count(*) FILTER (WHERE (sc.verdict = 'unsafe'::text)) AS n_unsafe,
    COALESCE(avg(
        CASE
            WHEN (sc.verdict = 'unsafe'::text) THEN 1.0
            ELSE 0.0
        END), 0.0) AS unsafe_rate
   FROM (public.safety_checks sc
     JOIN public.samples s ON ((s.content_hash = sc.content_hash)))
  WHERE (sc.arm = ANY (ARRAY['raw_ms'::text, 'translated_en'::text]))
  GROUP BY s.register, sc.classifier, sc.arm
  ORDER BY s.register, sc.classifier, sc.arm;


--
-- Name: safety_check_composition; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.safety_check_composition AS
 SELECT classifier,
    arm,
    verdict,
    count(*) AS n
   FROM public.safety_checks
  GROUP BY classifier, arm, verdict
  ORDER BY classifier, arm, verdict;


--
-- Name: safety_check_disagreement; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.safety_check_disagreement AS
 SELECT a.content_hash,
    a.arm,
    a.run_id,
    a.classifier AS clf_a,
    a.verdict AS verdict_a,
    b.classifier AS clf_b,
    b.verdict AS verdict_b,
    s.register,
    s.source,
    s.lang
   FROM ((public.safety_checks a
     JOIN public.safety_checks b ON (((a.content_hash = b.content_hash) AND (a.arm = b.arm) AND (a.run_id = b.run_id) AND (a.classifier < b.classifier))))
     JOIN public.samples s ON ((s.content_hash = a.content_hash)))
  WHERE ((a.verdict = 'unsafe'::text) <> (b.verdict = 'unsafe'::text))
  ORDER BY a.content_hash;


--
-- Name: safety_check_raw_vs_translated; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.safety_check_raw_vs_translated AS
 SELECT sc.classifier,
    sc.run_id,
    count(*) AS n,
    count(*) FILTER (WHERE ((raw.verdict = 'unsafe'::text) AND (tr.verdict = 'unsafe'::text))) AS both_unsafe,
    count(*) FILTER (WHERE ((raw.verdict <> 'unsafe'::text) AND (tr.verdict <> 'unsafe'::text))) AS both_other,
    count(*) FILTER (WHERE ((raw.verdict = 'unsafe'::text) AND (tr.verdict <> 'unsafe'::text))) AS raw_only_unsafe,
    count(*) FILTER (WHERE ((raw.verdict <> 'unsafe'::text) AND (tr.verdict = 'unsafe'::text))) AS trans_only_unsafe
   FROM ((public.safety_checks sc
     JOIN public.safety_checks raw ON (((raw.content_hash = sc.content_hash) AND (raw.classifier = sc.classifier) AND (raw.run_id = sc.run_id) AND (raw.arm = 'raw_ms'::text))))
     JOIN public.safety_checks tr ON (((tr.content_hash = sc.content_hash) AND (tr.classifier = sc.classifier) AND (tr.run_id = sc.run_id) AND (tr.arm = 'translated_en'::text))))
  GROUP BY sc.classifier, sc.run_id
  ORDER BY sc.classifier, sc.run_id;


--
-- Name: safety_checks_check_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.safety_checks_check_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: safety_checks_check_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.safety_checks_check_id_seq OWNED BY public.safety_checks.check_id;


--
-- Name: sample_edits_staging; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sample_edits_staging (
    id bigint NOT NULL,
    content_hash text NOT NULL,
    field_name text NOT NULL,
    old_value text,
    new_value text NOT NULL,
    edited_by text NOT NULL,
    status text DEFAULT 'pending'::text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    reviewed_at timestamp with time zone,
    reviewed_by text,
    CONSTRAINT sample_edits_staging_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'approved'::text, 'rejected'::text, 'applied'::text])))
);


--
-- Name: TABLE sample_edits_staging; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.sample_edits_staging IS 'Google-Sign-In-gated manual field-edit staging queue. pending -> approved|rejected -> applied (applied performs the actual `UPDATE samples`). Distinct from the older username/password review_edits table (pipeline/review_edits_schema.sql) — see this file''s header for why they are kept separate.';


--
-- Name: sample_edits_staging_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.sample_edits_staging ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.sample_edits_staging_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: sample_feedback; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sample_feedback (
    id bigint NOT NULL,
    content_hash text NOT NULL,
    reporter text,
    issue text NOT NULL,
    detail text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    resolved boolean DEFAULT false NOT NULL,
    CONSTRAINT sample_feedback_issue_check CHECK ((issue = ANY (ARRAY['garbage'::text, 'wrong_lang'::text, 'license_concern'::text, 'factual_error'::text, 'quality'::text, 'other'::text])))
);


--
-- Name: TABLE sample_feedback; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.sample_feedback IS 'Consumer-reported issues against a content_hash. Fed by serving API POST /feedback (open) and drained via GET /feedback?unresolved=1 (auth). Wiring TODO: unresolved rows should feed pipeline/active_learning_sample.pyas a review-priority queue — not yet wired, see CURATION_DOCTRINE.md "Trust layer" section.';


--
-- Name: sample_feedback_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.sample_feedback ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.sample_feedback_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: search_pool; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.search_pool AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf,
    source_id,
    usage_tags,
    fts
   FROM public.samples
  WHERE (embedding IS NOT NULL);


--
-- Name: VIEW search_pool; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.search_pool IS 'Offline semantic search index pool: embedding NOT NULL, ANY license — internal search/browse use only, must never be exported as a training or redistribution artifact regardless of license.';


--
-- Name: selection_algorithms; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.selection_algorithms (
    name text NOT NULL,
    description text NOT NULL,
    target_use_case text NOT NULL,
    script_reference text,
    params_schema jsonb DEFAULT '{}'::jsonb NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT selection_algorithms_target_use_case_check CHECK ((target_use_case = ANY (ARRAY['CPT'::text, 'SFT'::text, 'quant-calibration'::text, 'eval-heldout'::text, 'RAG'::text, 'other'::text])))
);


--
-- Name: sft_pool; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.sft_pool AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf,
    source_id,
    usage_tags,
    fts
   FROM public.samples
  WHERE ((kind = ANY (ARRAY['d1-logic'::text, 'd1-plan'::text, 'd1-math'::text, 'd1-estimate'::text, 'd2-openbook'::text, 'd3-tool'::text, 'd5-code'::text, 'long-form'::text])) AND ((verify_status = 'pass'::text) OR (verify_status IS NULL)) AND (COALESCE(review_score, model_quality_score, (0)::double precision) >= (0.6)::double precision) AND (license = ANY (ARRAY['Apache-2.0'::text, 'MIT'::text, 'CC0-1.0'::text])) AND (COALESCE(quarantined, false) = false) AND (COALESCE(contaminated, false) = false));


--
-- Name: VIEW sft_pool; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON VIEW public.sft_pool IS 'SFT pool: reasoning/code/tool/plan/estimate/long-form kinds, verify pass-or-null (verify_filter has not run on every kind), review_score (human) else model_quality_score >= 0.6, not quarantined/contaminated. License whitelist per 2026-07-04 policy ruling is STRICT (narrower than cpt_pool): Apache-2.0, MIT, CC0-1.0 only — no attribution/ShareAlike-encumbered licenses (ODC-By/CC-BY*) in SFT data, since instruction-tuned responses ship closer to end users and are harder to trace attribution obligations through.';


--
-- Name: shards; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.shards (
    id integer NOT NULL,
    path text NOT NULL
);


--
-- Name: shards_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.shards ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.shards_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: sources; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sources (
    id smallint NOT NULL,
    name text NOT NULL,
    origin_url text,
    hf_repo text,
    upstream_version text,
    license text,
    license_url text,
    retrieval_date date,
    method text,
    notes text
);


--
-- Name: sources_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.sources ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.sources_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: splits; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.splits (
    id smallint NOT NULL,
    name text NOT NULL
);


--
-- Name: splits_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

ALTER TABLE public.splits ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.splits_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- Name: sprapp_filter_categories; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sprapp_filter_categories (
    idx smallint NOT NULL,
    name text NOT NULL
);


--
-- Name: sprapp_filter_corpus; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sprapp_filter_corpus (
    content_hash text NOT NULL,
    text text NOT NULL,
    expected_decision text,
    expected_categories smallint[],
    lineage text,
    source text NOT NULL,
    split text,
    label_provenance text,
    minhash bigint[],
    embedding public.vector(768),
    created_at timestamp with time zone DEFAULT now(),
    id bigint NOT NULL,
    near_dup_of bigint,
    minhash_algo text DEFAULT 'datasketch_v1'::text,
    license text DEFAULT 'proprietary-internal'::text,
    lang text,
    review_score double precision,
    generated_by_model smallint,
    reviewed_by_model smallint,
    generation_score double precision,
    ingest_origin text
);


--
-- Name: sprapp_filter_composition; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.sprapp_filter_composition AS
 SELECT source,
    split,
    expected_decision,
    count(*) AS n,
    count(*) FILTER (WHERE (near_dup_of IS NOT NULL)) AS n_near_dup
   FROM public.sprapp_filter_corpus
  GROUP BY source, split, expected_decision
  ORDER BY (count(*)) DESC;


--
-- Name: sprapp_filter_corpus_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.sprapp_filter_corpus_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sprapp_filter_corpus_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.sprapp_filter_corpus_id_seq OWNED BY public.sprapp_filter_corpus.id;


--
-- Name: sprapp_filter_corpus_named; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.sprapp_filter_corpus_named AS
 SELECT content_hash,
    text,
    expected_decision,
    expected_categories,
    lineage,
    source,
    split,
    label_provenance,
    minhash,
    embedding,
    created_at,
    id,
    near_dup_of,
    ARRAY( SELECT c.name
           FROM (unnest(f.expected_categories) cat_idx(cat_idx)
             JOIN public.sprapp_filter_categories c ON ((c.idx = cat_idx.cat_idx)))) AS category_names
   FROM public.sprapp_filter_corpus f;


--
-- Name: tb_st_backfill_checkpoint; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.tb_st_backfill_checkpoint (
    shard text NOT NULL,
    rows_seen integer NOT NULL,
    rows_updated integer NOT NULL,
    elapsed_s real NOT NULL,
    done_at timestamp with time zone DEFAULT now() NOT NULL
);


--
-- Name: training_run_datasets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.training_run_datasets (
    id bigint NOT NULL,
    run_id uuid NOT NULL,
    snapshot_name text NOT NULL,
    row_count_used bigint,
    percent_of_total_mix numeric(6,3),
    role text
);


--
-- Name: training_run_datasets_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.training_run_datasets_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: training_run_datasets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.training_run_datasets_id_seq OWNED BY public.training_run_datasets.id;


--
-- Name: training_run_results; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.training_run_results (
    id bigint NOT NULL,
    run_id uuid NOT NULL,
    benchmark_name text NOT NULL,
    metric_name text NOT NULL,
    metric_value double precision NOT NULL,
    eval_date date,
    eval_methodology_notes text
);


--
-- Name: training_run_results_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.training_run_results_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: training_run_results_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.training_run_results_id_seq OWNED BY public.training_run_results.id;


--
-- Name: training_run_unverified_datasets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.training_run_unverified_datasets (
    id bigint NOT NULL,
    run_id uuid NOT NULL,
    claimed_snapshot_name text NOT NULL,
    row_count_used bigint,
    percent_of_total_mix numeric(6,3),
    role text
);


--
-- Name: training_run_unverified_datasets_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.training_run_unverified_datasets_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: training_run_unverified_datasets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.training_run_unverified_datasets_id_seq OWNED BY public.training_run_unverified_datasets.id;


--
-- Name: training_runs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.training_runs (
    run_id uuid DEFAULT gen_random_uuid() NOT NULL,
    submitted_at timestamp with time zone DEFAULT now() NOT NULL,
    submitter_org text,
    submitter_contact text,
    model_name text NOT NULL,
    architecture text,
    base_model text,
    training_type text NOT NULL,
    framework text,
    hardware text,
    seeds jsonb DEFAULT '{}'::jsonb NOT NULL,
    hyperparameters jsonb DEFAULT '{}'::jsonb NOT NULL,
    status text DEFAULT 'pending_verification'::text NOT NULL,
    verification_notes text,
    notes text,
    CONSTRAINT training_runs_status_check CHECK ((status = ANY (ARRAY['pending_verification'::text, 'verified'::text, 'rejected'::text]))),
    CONSTRAINT training_runs_training_type_check CHECK ((training_type = ANY (ARRAY['CPT'::text, 'SFT'::text, 'RLHF'::text, 'DPO'::text, 'continued-pretrain'::text, 'other'::text])))
);


--
-- Name: zero_attrib_clean; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.zero_attrib_clean AS
 SELECT content_hash,
    kind,
    lang,
    source,
    minhash,
    embedding,
    sprapp_filter_score,
    sprapp_filter_flagged,
    quarantined,
    verify_status,
    register,
    promoted,
    blob_path,
    row_len_chars,
    created_at,
    near_dup_of,
    textbook_quality,
    cultural_nuance,
    cultural_markers,
    minhash_algo,
    license,
    review_score,
    generated_by_model,
    reviewed_by_model,
    generation_score,
    structural_quality,
    structural_signals,
    split,
    perplexity,
    quality_tier,
    composite_score,
    composite_profile,
    contaminated,
    translated_from,
    text_inline,
    model_quality_score,
    langid_pred,
    langid_conf,
    source_id,
    usage_tags,
    fts,
    minhash_packed,
    embedding_h,
    shard_id,
    kind_id,
    lang_id,
    license_id,
    register_id,
    quality_tier_id,
    split_id,
    gen_temperature,
    gen_max_tokens,
    gen_repeat_penalty,
    gen_seed,
    gen_provider,
    gen_quantization,
    gen_prompt_variant,
    pipeline_status,
    pipeline_status_updated_at,
    pipeline_status_reason,
    restricted_overlap,
    restricted_overlap_source,
    capability_tags,
    pii_detected,
    pii_types,
    input_tokens,
    output_tokens,
    token_count,
    token_count_tokenizer,
    best_of_n_score,
    cpt_eligible,
    sft_eligible,
    ingest_origin
   FROM public.samples
  WHERE ((license = ANY (ARRAY['Apache-2.0'::text, 'MIT'::text, 'CC0'::text, 'BSD-3-Clause'::text])) AND (source !~~* '%minimax%'::text));


--
-- Name: model_format_spec id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.model_format_spec ALTER COLUMN id SET DEFAULT nextval('public.model_format_spec_id_seq'::regclass);


--
-- Name: near_dup_scan_progress id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.near_dup_scan_progress ALTER COLUMN id SET DEFAULT nextval('public.near_dup_scan_progress_id_seq'::regclass);


--
-- Name: safety_checks check_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.safety_checks ALTER COLUMN check_id SET DEFAULT nextval('public.safety_checks_check_id_seq'::regclass);


--
-- Name: sprapp_filter_corpus id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sprapp_filter_corpus ALTER COLUMN id SET DEFAULT nextval('public.sprapp_filter_corpus_id_seq'::regclass);


--
-- Name: training_run_datasets id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_datasets ALTER COLUMN id SET DEFAULT nextval('public.training_run_datasets_id_seq'::regclass);


--
-- Name: training_run_results id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_results ALTER COLUMN id SET DEFAULT nextval('public.training_run_results_id_seq'::regclass);


--
-- Name: training_run_unverified_datasets id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_unverified_datasets ALTER COLUMN id SET DEFAULT nextval('public.training_run_unverified_datasets_id_seq'::regclass);


--
-- Name: backfill_progress backfill_progress_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.backfill_progress
    ADD CONSTRAINT backfill_progress_pkey PRIMARY KEY (pass_name, blob_path);


--
-- Name: chunks chunks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.chunks
    ADD CONSTRAINT chunks_pkey PRIMARY KEY (chunk_hash);


--
-- Name: coldstart_coding_rollouts coldstart_coding_rollouts_content_hash_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.coldstart_coding_rollouts
    ADD CONSTRAINT coldstart_coding_rollouts_content_hash_key UNIQUE (content_hash);


--
-- Name: coldstart_coding_rollouts coldstart_coding_rollouts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.coldstart_coding_rollouts
    ADD CONSTRAINT coldstart_coding_rollouts_pkey PRIMARY KEY (rollout_id);


--
-- Name: coldstart_coding_rollouts coldstart_coding_rollouts_trajectory_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.coldstart_coding_rollouts
    ADD CONSTRAINT coldstart_coding_rollouts_trajectory_id_key UNIQUE (trajectory_id);


--
-- Name: contamination_hashes contamination_hashes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.contamination_hashes
    ADD CONSTRAINT contamination_hashes_pkey PRIMARY KEY (content_hash);


--
-- Name: corpus_snapshot_members corpus_snapshot_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.corpus_snapshot_members
    ADD CONSTRAINT corpus_snapshot_members_pkey PRIMARY KEY (snapshot, content_hash);


--
-- Name: corpus_snapshots corpus_snapshots_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.corpus_snapshots
    ADD CONSTRAINT corpus_snapshots_pkey PRIMARY KEY (name);


--
-- Name: corpus_version corpus_version_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.corpus_version
    ADD CONSTRAINT corpus_version_pkey PRIMARY KEY (version);


--
-- Name: kb_documents kb_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.kb_documents
    ADD CONSTRAINT kb_documents_pkey PRIMARY KEY (id);


--
-- Name: kinds kinds_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.kinds
    ADD CONSTRAINT kinds_name_key UNIQUE (name);


--
-- Name: kinds kinds_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.kinds
    ADD CONSTRAINT kinds_pkey PRIMARY KEY (id);


--
-- Name: label_audit label_audit_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.label_audit
    ADD CONSTRAINT label_audit_pkey PRIMARY KEY (id);


--
-- Name: lang_quality_config lang_quality_config_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lang_quality_config
    ADD CONSTRAINT lang_quality_config_pkey PRIMARY KEY (lang);


--
-- Name: langs langs_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.langs
    ADD CONSTRAINT langs_name_key UNIQUE (name);


--
-- Name: langs langs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.langs
    ADD CONSTRAINT langs_pkey PRIMARY KEY (id);


--
-- Name: licenses licenses_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.licenses
    ADD CONSTRAINT licenses_name_key UNIQUE (name);


--
-- Name: licenses licenses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.licenses
    ADD CONSTRAINT licenses_pkey PRIMARY KEY (id);


--
-- Name: model_format_spec model_format_spec_model_id_task_type_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.model_format_spec
    ADD CONSTRAINT model_format_spec_model_id_task_type_key UNIQUE (model_id, task_type);


--
-- Name: model_format_spec model_format_spec_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.model_format_spec
    ADD CONSTRAINT model_format_spec_pkey PRIMARY KEY (id);


--
-- Name: models models_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.models
    ADD CONSTRAINT models_name_key UNIQUE (name);


--
-- Name: models models_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.models
    ADD CONSTRAINT models_pkey PRIMARY KEY (id);


--
-- Name: near_dup_scan_progress near_dup_scan_progress_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.near_dup_scan_progress
    ADD CONSTRAINT near_dup_scan_progress_pkey PRIMARY KEY (id);


--
-- Name: near_dup_scan_progress near_dup_scan_progress_table_name_kind_lang_source_label_pr_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.near_dup_scan_progress
    ADD CONSTRAINT near_dup_scan_progress_table_name_kind_lang_source_label_pr_key UNIQUE (table_name, kind, lang, source, label_provenance, minhash_algo, threshold);


--
-- Name: parked_datasets parked_datasets_hf_repo_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.parked_datasets
    ADD CONSTRAINT parked_datasets_hf_repo_key UNIQUE (hf_repo);


--
-- Name: parked_datasets parked_datasets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.parked_datasets
    ADD CONSTRAINT parked_datasets_pkey PRIMARY KEY (id);


--
-- Name: processing_state processing_state_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.processing_state
    ADD CONSTRAINT processing_state_pkey PRIMARY KEY (content_hash, tbl, pass_name);


--
-- Name: quality_profiles quality_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.quality_profiles
    ADD CONSTRAINT quality_profiles_pkey PRIMARY KEY (name);


--
-- Name: quality_tiers quality_tiers_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.quality_tiers
    ADD CONSTRAINT quality_tiers_name_key UNIQUE (name);


--
-- Name: quality_tiers quality_tiers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.quality_tiers
    ADD CONSTRAINT quality_tiers_pkey PRIMARY KEY (id);


--
-- Name: reg_backfill_staging reg_backfill_staging_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reg_backfill_staging
    ADD CONSTRAINT reg_backfill_staging_pkey PRIMARY KEY (content_hash);


--
-- Name: registers registers_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.registers
    ADD CONSTRAINT registers_name_key UNIQUE (name);


--
-- Name: registers registers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.registers
    ADD CONSTRAINT registers_pkey PRIMARY KEY (id);


--
-- Name: restricted_corpus_hashes restricted_corpus_hashes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.restricted_corpus_hashes
    ADD CONSTRAINT restricted_corpus_hashes_pkey PRIMARY KEY (shingle_hash, source_name);


--
-- Name: review_batch_rows review_batch_rows_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review_batch_rows
    ADD CONSTRAINT review_batch_rows_pkey PRIMARY KEY (batch_id, content_hash);


--
-- Name: review_batches review_batches_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review_batches
    ADD CONSTRAINT review_batches_pkey PRIMARY KEY (batch_id);


--
-- Name: reviews reviews_content_hash_judge_dimension_rubric_version_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT reviews_content_hash_judge_dimension_rubric_version_key UNIQUE (content_hash, judge, dimension, rubric_version);


--
-- Name: reviews reviews_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT reviews_pkey PRIMARY KEY (id);


--
-- Name: rl_coding_rollouts rl_coding_rollouts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rl_coding_rollouts
    ADD CONSTRAINT rl_coding_rollouts_pkey PRIMARY KEY (rollout_id);


--
-- Name: rl_coding_rollouts rl_coding_rollouts_trajectory_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rl_coding_rollouts
    ADD CONSTRAINT rl_coding_rollouts_trajectory_id_key UNIQUE (trajectory_id);


--
-- Name: rl_coding_tasks rl_coding_tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rl_coding_tasks
    ADD CONSTRAINT rl_coding_tasks_pkey PRIMARY KEY (task_id);


--
-- Name: safety_checks safety_checks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.safety_checks
    ADD CONSTRAINT safety_checks_pkey PRIMARY KEY (check_id);


--
-- Name: sample_edits_staging sample_edits_staging_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sample_edits_staging
    ADD CONSTRAINT sample_edits_staging_pkey PRIMARY KEY (id);


--
-- Name: sample_feedback sample_feedback_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sample_feedback
    ADD CONSTRAINT sample_feedback_pkey PRIMARY KEY (id);


--
-- Name: samples samples_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_pkey PRIMARY KEY (content_hash);


--
-- Name: selection_algorithms selection_algorithms_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.selection_algorithms
    ADD CONSTRAINT selection_algorithms_pkey PRIMARY KEY (name);


--
-- Name: shards shards_path_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.shards
    ADD CONSTRAINT shards_path_key UNIQUE (path);


--
-- Name: shards shards_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.shards
    ADD CONSTRAINT shards_pkey PRIMARY KEY (id);


--
-- Name: sources sources_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sources
    ADD CONSTRAINT sources_name_key UNIQUE (name);


--
-- Name: sources sources_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sources
    ADD CONSTRAINT sources_pkey PRIMARY KEY (id);


--
-- Name: splits splits_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.splits
    ADD CONSTRAINT splits_name_key UNIQUE (name);


--
-- Name: splits splits_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.splits
    ADD CONSTRAINT splits_pkey PRIMARY KEY (id);


--
-- Name: sprapp_filter_categories sprapp_filter_categories_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sprapp_filter_categories
    ADD CONSTRAINT sprapp_filter_categories_name_key UNIQUE (name);


--
-- Name: sprapp_filter_categories sprapp_filter_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sprapp_filter_categories
    ADD CONSTRAINT sprapp_filter_categories_pkey PRIMARY KEY (idx);


--
-- Name: sprapp_filter_corpus sprapp_filter_corpus_hash_provenance_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sprapp_filter_corpus
    ADD CONSTRAINT sprapp_filter_corpus_hash_provenance_uniq UNIQUE (content_hash, label_provenance);


--
-- Name: sprapp_filter_corpus sprapp_filter_corpus_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sprapp_filter_corpus
    ADD CONSTRAINT sprapp_filter_corpus_pkey PRIMARY KEY (id);


--
-- Name: tb_st_backfill_checkpoint tb_st_backfill_checkpoint_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.tb_st_backfill_checkpoint
    ADD CONSTRAINT tb_st_backfill_checkpoint_pkey PRIMARY KEY (shard);


--
-- Name: training_run_datasets training_run_datasets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_datasets
    ADD CONSTRAINT training_run_datasets_pkey PRIMARY KEY (id);


--
-- Name: training_run_results training_run_results_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_results
    ADD CONSTRAINT training_run_results_pkey PRIMARY KEY (id);


--
-- Name: training_run_unverified_datasets training_run_unverified_datasets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_unverified_datasets
    ADD CONSTRAINT training_run_unverified_datasets_pkey PRIMARY KEY (id);


--
-- Name: training_runs training_runs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_runs
    ADD CONSTRAINT training_runs_pkey PRIMARY KEY (run_id);


--
-- Name: idx_ccr_domain; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ccr_domain ON public.coldstart_coding_rollouts USING btree (domain, test_passed);


--
-- Name: idx_ccr_gated; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ccr_gated ON public.coldstart_coding_rollouts USING btree (test_gated) WHERE test_gated;


--
-- Name: idx_ccr_source; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ccr_source ON public.coldstart_coding_rollouts USING btree (source);


--
-- Name: idx_ccr_teacher; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_ccr_teacher ON public.coldstart_coding_rollouts USING btree (teacher_model);


--
-- Name: idx_chunks_kb_doc_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_chunks_kb_doc_id ON public.chunks USING btree (kb_doc_id);


--
-- Name: idx_chunks_lang; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_chunks_lang ON public.chunks USING btree (lang);


--
-- Name: idx_chunks_parent_hash; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_chunks_parent_hash ON public.chunks USING btree (parent_hash);


--
-- Name: idx_contam_evalset; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_contam_evalset ON public.contamination_hashes USING btree (eval_set);


--
-- Name: idx_corpus_snapshots_selection_algorithm; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_corpus_snapshots_selection_algorithm ON public.corpus_snapshots USING btree (selection_algorithm);


--
-- Name: idx_kb_documents_content_hash; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX idx_kb_documents_content_hash ON public.kb_documents USING btree (content_hash) WHERE (content_hash IS NOT NULL);


--
-- Name: idx_kb_documents_org; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_kb_documents_org ON public.kb_documents USING btree (source_org);


--
-- Name: idx_kb_documents_type; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_kb_documents_type ON public.kb_documents USING btree (doc_type);


--
-- Name: idx_label_audit_hash_time; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_label_audit_hash_time ON public.label_audit USING btree (content_hash, changed_at);


--
-- Name: idx_parked_datasets_category; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_parked_datasets_category ON public.parked_datasets USING btree (decline_category);


--
-- Name: idx_parked_datasets_cleanroom_viable; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_parked_datasets_cleanroom_viable ON public.parked_datasets USING btree (cleanroom_viable);


--
-- Name: idx_procstate_pass; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_procstate_pass ON public.processing_state USING btree (tbl, pass_name, pass_version);


--
-- Name: idx_restricted_hashes_kind; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_restricted_hashes_kind ON public.restricted_corpus_hashes USING btree (source_kind);


--
-- Name: idx_restricted_hashes_source; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_restricted_hashes_source ON public.restricted_corpus_hashes USING btree (source_name);


--
-- Name: idx_review_batch_rows_unreviewed; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_review_batch_rows_unreviewed ON public.review_batch_rows USING btree (batch_id) WHERE (NOT reviewed);


--
-- Name: idx_review_batches_created_by; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_review_batches_created_by ON public.review_batches USING btree (created_by);


--
-- Name: idx_reviews_content_hash; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_reviews_content_hash ON public.reviews USING btree (content_hash);


--
-- Name: idx_reviews_judge_created; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_reviews_judge_created ON public.reviews USING btree (judge, created_at);


--
-- Name: idx_rl_coding_rollouts_clean; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_rollouts_clean ON public.rl_coding_rollouts USING btree (grpo_group_id) WHERE (NOT excluded_from_advantage);


--
-- Name: idx_rl_coding_rollouts_group; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_rollouts_group ON public.rl_coding_rollouts USING btree (grpo_group_id);


--
-- Name: idx_rl_coding_rollouts_milestone; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_rollouts_milestone ON public.rl_coding_rollouts USING btree (milestone_reached);


--
-- Name: idx_rl_coding_rollouts_step; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_rollouts_step ON public.rl_coding_rollouts USING btree (training_step);


--
-- Name: idx_rl_coding_rollouts_task; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_rollouts_task ON public.rl_coding_rollouts USING btree (task_id);


--
-- Name: idx_rl_coding_tasks_category; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_tasks_category ON public.rl_coding_tasks USING btree (category, difficulty);


--
-- Name: idx_rl_coding_tasks_env_verified; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_tasks_env_verified ON public.rl_coding_tasks USING btree (env_verified) WHERE env_verified;


--
-- Name: idx_rl_coding_tasks_license_ok; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_tasks_license_ok ON public.rl_coding_tasks USING btree (license_ok) WHERE license_ok;


--
-- Name: idx_rl_coding_tasks_rl_ready; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_tasks_rl_ready ON public.rl_coding_tasks USING btree (env_verified, license_ok) WHERE (env_verified AND license_ok);


--
-- Name: idx_rl_coding_tasks_source; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_rl_coding_tasks_source ON public.rl_coding_tasks USING btree (source_id);


--
-- Name: idx_safety_checks_arm; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_safety_checks_arm ON public.safety_checks USING btree (arm);


--
-- Name: idx_safety_checks_cats; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_safety_checks_cats ON public.safety_checks USING gin (categories);


--
-- Name: idx_safety_checks_checked_by; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_safety_checks_checked_by ON public.safety_checks USING btree (checked_by);


--
-- Name: idx_safety_checks_classifier; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_safety_checks_classifier ON public.safety_checks USING btree (classifier);


--
-- Name: idx_safety_checks_run; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_safety_checks_run ON public.safety_checks USING btree (run_id);


--
-- Name: idx_safety_checks_translator; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_safety_checks_translator ON public.safety_checks USING btree (translator);


--
-- Name: idx_safety_checks_verdict; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_safety_checks_verdict ON public.safety_checks USING btree (verdict);


--
-- Name: idx_sample_edits_staging_content_hash; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sample_edits_staging_content_hash ON public.sample_edits_staging USING btree (content_hash);


--
-- Name: idx_sample_edits_staging_status; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sample_edits_staging_status ON public.sample_edits_staging USING btree (status);


--
-- Name: idx_sample_feedback_hash; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sample_feedback_hash ON public.sample_feedback USING btree (content_hash);


--
-- Name: idx_sample_feedback_unresolved; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sample_feedback_unresolved ON public.sample_feedback USING btree (resolved, created_at) WHERE (NOT resolved);


--
-- Name: idx_samples_analytics_source_cover; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_analytics_source_cover ON public.samples USING btree (source) INCLUDE (composite_score, textbook_quality, structural_quality, cultural_nuance);


--
-- Name: idx_samples_capability_tags; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_capability_tags ON public.samples USING gin (capability_tags);


--
-- Name: idx_samples_capability_tags_notnull; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_capability_tags_notnull ON public.samples USING btree (content_hash) WHERE (capability_tags IS NOT NULL);


--
-- Name: idx_samples_composite; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_composite ON public.samples USING btree (composite_score);


--
-- Name: idx_samples_composition_cover; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_composition_cover ON public.samples USING btree (kind, lang, source) INCLUDE (promoted, quarantined);


--
-- Name: idx_samples_contaminated; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_contaminated ON public.samples USING btree (contaminated) WHERE contaminated;


--
-- Name: idx_samples_cpt_eligible; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_cpt_eligible ON public.samples USING btree (cpt_eligible) WHERE cpt_eligible;


--
-- Name: idx_samples_cultural_nuance; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_cultural_nuance ON public.samples USING btree (cultural_nuance) WHERE cultural_nuance;


--
-- Name: idx_samples_fts; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_fts ON public.samples USING gin (fts);


--
-- Name: idx_samples_gen_prompt_variant; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_gen_prompt_variant ON public.samples USING btree (gen_prompt_variant);


--
-- Name: idx_samples_gen_provider; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_gen_provider ON public.samples USING btree (gen_provider);


--
-- Name: idx_samples_gen_quantization; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_gen_quantization ON public.samples USING btree (gen_quantization);


--
-- Name: idx_samples_generated_by; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_generated_by ON public.samples USING btree (generated_by_model);


--
-- Name: idx_samples_input_tokens; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_input_tokens ON public.samples USING btree (input_tokens) WHERE (input_tokens IS NOT NULL);


--
-- Name: idx_samples_kind_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_kind_id ON public.samples USING btree (kind_id);


--
-- Name: idx_samples_kind_lang; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_kind_lang ON public.samples USING btree (kind, lang);


--
-- Name: idx_samples_lang_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_lang_id ON public.samples USING btree (lang_id);


--
-- Name: idx_samples_license; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_license ON public.samples USING btree (license);


--
-- Name: idx_samples_license_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_license_id ON public.samples USING btree (license_id);


--
-- Name: idx_samples_model_quality_score; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_model_quality_score ON public.samples USING btree (model_quality_score);


--
-- Name: idx_samples_near_dup; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_near_dup ON public.samples USING btree (near_dup_of) WHERE (near_dup_of IS NOT NULL);


--
-- Name: idx_samples_output_tokens; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_output_tokens ON public.samples USING btree (output_tokens) WHERE (output_tokens IS NOT NULL);


--
-- Name: idx_samples_pii_detected; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_pii_detected ON public.samples USING btree (pii_detected) WHERE (pii_detected = true);


--
-- Name: idx_samples_pii_detected_full; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_pii_detected_full ON public.samples USING btree (pii_detected);


--
-- Name: idx_samples_pii_types; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_pii_types ON public.samples USING gin (pii_types);


--
-- Name: idx_samples_pipeline_status; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_pipeline_status ON public.samples USING btree (pipeline_status);


--
-- Name: idx_samples_promoted; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_promoted ON public.samples USING btree (promoted);


--
-- Name: idx_samples_quality_tier; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_quality_tier ON public.samples USING btree (quality_tier);


--
-- Name: idx_samples_quality_tier_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_quality_tier_id ON public.samples USING btree (quality_tier_id);


--
-- Name: idx_samples_quarantined; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_quarantined ON public.samples USING btree (quarantined) WHERE quarantined;


--
-- Name: idx_samples_register; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_register ON public.samples USING btree (register);


--
-- Name: idx_samples_register_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_register_id ON public.samples USING btree (register_id);


--
-- Name: idx_samples_restricted_overlap; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_restricted_overlap ON public.samples USING btree (restricted_overlap) WHERE restricted_overlap;


--
-- Name: idx_samples_review_score; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_review_score ON public.samples USING btree (review_score);


--
-- Name: idx_samples_reviewed_by; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_reviewed_by ON public.samples USING btree (reviewed_by_model);


--
-- Name: idx_samples_sft_eligible; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_sft_eligible ON public.samples USING btree (sft_eligible) WHERE sft_eligible;


--
-- Name: idx_samples_shard_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_shard_id ON public.samples USING btree (shard_id);


--
-- Name: idx_samples_source; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_source ON public.samples USING btree (source);


--
-- Name: idx_samples_split; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_split ON public.samples USING btree (split);


--
-- Name: idx_samples_split_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_split_id ON public.samples USING btree (split_id);


--
-- Name: idx_samples_sprapp_filter_flagged; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_sprapp_filter_flagged ON public.samples USING gin (sprapp_filter_flagged);


--
-- Name: idx_samples_structural_quality; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_structural_quality ON public.samples USING btree (structural_quality);


--
-- Name: idx_samples_textbook_quality; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_textbook_quality ON public.samples USING btree (textbook_quality);


--
-- Name: idx_samples_token_count; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_token_count ON public.samples USING btree (token_count) WHERE (token_count IS NOT NULL);


--
-- Name: idx_samples_translated_from; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_translated_from ON public.samples USING btree (translated_from) WHERE (translated_from IS NOT NULL);


--
-- Name: idx_samples_usage_tags; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_samples_usage_tags ON public.samples USING gin (usage_tags);


--
-- Name: idx_sfc_categories; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_categories ON public.sprapp_filter_corpus USING gin (expected_categories);


--
-- Name: idx_sfc_content_hash; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_content_hash ON public.sprapp_filter_corpus USING btree (content_hash);


--
-- Name: idx_sfc_generated_by; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_generated_by ON public.sprapp_filter_corpus USING btree (generated_by_model);


--
-- Name: idx_sfc_lang; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_lang ON public.sprapp_filter_corpus USING btree (lang);


--
-- Name: idx_sfc_license; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_license ON public.sprapp_filter_corpus USING btree (license);


--
-- Name: idx_sfc_lineage; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_lineage ON public.sprapp_filter_corpus USING btree (lineage);


--
-- Name: idx_sfc_near_dup; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_near_dup ON public.sprapp_filter_corpus USING btree (near_dup_of) WHERE (near_dup_of IS NOT NULL);


--
-- Name: idx_sfc_review_score; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_review_score ON public.sprapp_filter_corpus USING btree (review_score);


--
-- Name: idx_sfc_reviewed_by; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_reviewed_by ON public.sprapp_filter_corpus USING btree (reviewed_by_model);


--
-- Name: idx_sfc_source_split; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_sfc_source_split ON public.sprapp_filter_corpus USING btree (source, split);


--
-- Name: rl_coding_rollouts_ingest_origin_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX rl_coding_rollouts_ingest_origin_idx ON public.rl_coding_rollouts USING btree (ingest_origin);


--
-- Name: safety_checks_uniq; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX safety_checks_uniq ON public.safety_checks USING btree (content_hash, arm, classifier, run_id);


--
-- Name: samples_ingest_origin_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX samples_ingest_origin_idx ON public.samples USING btree (ingest_origin);


--
-- Name: samples_source_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX samples_source_id_idx ON public.samples USING btree (source_id);


--
-- Name: sprapp_filter_corpus_ingest_origin_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX sprapp_filter_corpus_ingest_origin_idx ON public.sprapp_filter_corpus USING btree (ingest_origin);


--
-- Name: training_runs_model_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX training_runs_model_idx ON public.training_runs USING btree (model_name);


--
-- Name: training_runs_status_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX training_runs_status_idx ON public.training_runs USING btree (status);


--
-- Name: training_runs_submitted_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX training_runs_submitted_idx ON public.training_runs USING btree (submitted_at DESC);


--
-- Name: trd_run_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX trd_run_idx ON public.training_run_datasets USING btree (run_id);


--
-- Name: trd_snapshot_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX trd_snapshot_idx ON public.training_run_datasets USING btree (snapshot_name);


--
-- Name: trr_benchmark_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX trr_benchmark_idx ON public.training_run_results USING btree (benchmark_name);


--
-- Name: trr_run_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX trr_run_idx ON public.training_run_results USING btree (run_id);


--
-- Name: trud_run_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX trud_run_idx ON public.training_run_unverified_datasets USING btree (run_id);


--
-- Name: model_format_spec trg_model_format_spec_touch; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER trg_model_format_spec_touch BEFORE UPDATE ON public.model_format_spec FOR EACH ROW EXECUTE FUNCTION public.model_format_spec_touch_updated_at();


--
-- Name: chunks chunks_kb_doc_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.chunks
    ADD CONSTRAINT chunks_kb_doc_id_fkey FOREIGN KEY (kb_doc_id) REFERENCES public.kb_documents(id);


--
-- Name: chunks chunks_parent_hash_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.chunks
    ADD CONSTRAINT chunks_parent_hash_fkey FOREIGN KEY (parent_hash) REFERENCES public.samples(content_hash);


--
-- Name: coldstart_coding_rollouts coldstart_coding_rollouts_source_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.coldstart_coding_rollouts
    ADD CONSTRAINT coldstart_coding_rollouts_source_id_fkey FOREIGN KEY (source_id) REFERENCES public.sources(id);


--
-- Name: coldstart_coding_rollouts coldstart_coding_rollouts_teacher_model_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.coldstart_coding_rollouts
    ADD CONSTRAINT coldstart_coding_rollouts_teacher_model_id_fkey FOREIGN KEY (teacher_model_id) REFERENCES public.models(id);


--
-- Name: corpus_snapshot_members corpus_snapshot_members_snapshot_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.corpus_snapshot_members
    ADD CONSTRAINT corpus_snapshot_members_snapshot_fkey FOREIGN KEY (snapshot) REFERENCES public.corpus_snapshots(name) ON DELETE CASCADE;


--
-- Name: corpus_snapshots corpus_snapshots_parent_snapshot_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.corpus_snapshots
    ADD CONSTRAINT corpus_snapshots_parent_snapshot_fkey FOREIGN KEY (parent_snapshot) REFERENCES public.corpus_snapshots(name);


--
-- Name: corpus_snapshots corpus_snapshots_profile_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.corpus_snapshots
    ADD CONSTRAINT corpus_snapshots_profile_fkey FOREIGN KEY (profile) REFERENCES public.quality_profiles(name);


--
-- Name: corpus_snapshots corpus_snapshots_selection_algorithm_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.corpus_snapshots
    ADD CONSTRAINT corpus_snapshots_selection_algorithm_fkey FOREIGN KEY (selection_algorithm) REFERENCES public.selection_algorithms(name);


--
-- Name: review_batch_rows review_batch_rows_batch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review_batch_rows
    ADD CONSTRAINT review_batch_rows_batch_id_fkey FOREIGN KEY (batch_id) REFERENCES public.review_batches(batch_id);


--
-- Name: review_batch_rows review_batch_rows_content_hash_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review_batch_rows
    ADD CONSTRAINT review_batch_rows_content_hash_fkey FOREIGN KEY (content_hash) REFERENCES public.samples(content_hash);


--
-- Name: reviews reviews_content_hash_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT reviews_content_hash_fkey FOREIGN KEY (content_hash) REFERENCES public.samples(content_hash);


--
-- Name: reviews reviews_judge_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT reviews_judge_fkey FOREIGN KEY (judge) REFERENCES public.models(id);


--
-- Name: rl_coding_rollouts rl_coding_rollouts_task_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rl_coding_rollouts
    ADD CONSTRAINT rl_coding_rollouts_task_id_fkey FOREIGN KEY (task_id) REFERENCES public.rl_coding_tasks(task_id);


--
-- Name: rl_coding_tasks rl_coding_tasks_gold_patch_source_model_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rl_coding_tasks
    ADD CONSTRAINT rl_coding_tasks_gold_patch_source_model_fkey FOREIGN KEY (gold_patch_source_model) REFERENCES public.models(id);


--
-- Name: rl_coding_tasks rl_coding_tasks_source_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rl_coding_tasks
    ADD CONSTRAINT rl_coding_tasks_source_id_fkey FOREIGN KEY (source_id) REFERENCES public.sources(id);


--
-- Name: sample_edits_staging sample_edits_staging_content_hash_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sample_edits_staging
    ADD CONSTRAINT sample_edits_staging_content_hash_fkey FOREIGN KEY (content_hash) REFERENCES public.samples(content_hash);


--
-- Name: samples samples_generated_by_model_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_generated_by_model_fkey FOREIGN KEY (generated_by_model) REFERENCES public.models(id);


--
-- Name: samples samples_kind_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_kind_id_fkey FOREIGN KEY (kind_id) REFERENCES public.kinds(id);


--
-- Name: samples samples_lang_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_lang_id_fkey FOREIGN KEY (lang_id) REFERENCES public.langs(id);


--
-- Name: samples samples_license_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_license_id_fkey FOREIGN KEY (license_id) REFERENCES public.licenses(id);


--
-- Name: samples samples_near_dup_of_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_near_dup_of_fkey FOREIGN KEY (near_dup_of) REFERENCES public.samples(content_hash);


--
-- Name: samples samples_quality_tier_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_quality_tier_id_fkey FOREIGN KEY (quality_tier_id) REFERENCES public.quality_tiers(id);


--
-- Name: samples samples_register_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_register_id_fkey FOREIGN KEY (register_id) REFERENCES public.registers(id);


--
-- Name: samples samples_reviewed_by_model_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_reviewed_by_model_fkey FOREIGN KEY (reviewed_by_model) REFERENCES public.models(id);


--
-- Name: samples samples_shard_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_shard_id_fkey FOREIGN KEY (shard_id) REFERENCES public.shards(id);


--
-- Name: samples samples_source_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_source_id_fkey FOREIGN KEY (source_id) REFERENCES public.sources(id);


--
-- Name: samples samples_split_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.samples
    ADD CONSTRAINT samples_split_id_fkey FOREIGN KEY (split_id) REFERENCES public.splits(id);


--
-- Name: sprapp_filter_corpus sprapp_filter_corpus_generated_by_model_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sprapp_filter_corpus
    ADD CONSTRAINT sprapp_filter_corpus_generated_by_model_fkey FOREIGN KEY (generated_by_model) REFERENCES public.models(id);


--
-- Name: sprapp_filter_corpus sprapp_filter_corpus_near_dup_of_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sprapp_filter_corpus
    ADD CONSTRAINT sprapp_filter_corpus_near_dup_of_fkey FOREIGN KEY (near_dup_of) REFERENCES public.sprapp_filter_corpus(id);


--
-- Name: sprapp_filter_corpus sprapp_filter_corpus_reviewed_by_model_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sprapp_filter_corpus
    ADD CONSTRAINT sprapp_filter_corpus_reviewed_by_model_fkey FOREIGN KEY (reviewed_by_model) REFERENCES public.models(id);


--
-- Name: training_run_datasets training_run_datasets_run_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_datasets
    ADD CONSTRAINT training_run_datasets_run_id_fkey FOREIGN KEY (run_id) REFERENCES public.training_runs(run_id) ON DELETE CASCADE;


--
-- Name: training_run_datasets training_run_datasets_snapshot_name_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_datasets
    ADD CONSTRAINT training_run_datasets_snapshot_name_fkey FOREIGN KEY (snapshot_name) REFERENCES public.corpus_snapshots(name);


--
-- Name: training_run_results training_run_results_run_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_results
    ADD CONSTRAINT training_run_results_run_id_fkey FOREIGN KEY (run_id) REFERENCES public.training_runs(run_id) ON DELETE CASCADE;


--
-- Name: training_run_unverified_datasets training_run_unverified_datasets_run_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_run_unverified_datasets
    ADD CONSTRAINT training_run_unverified_datasets_run_id_fkey FOREIGN KEY (run_id) REFERENCES public.training_runs(run_id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

\unrestrict THevuI5nL8va278qqO7jMSTP5LK8tqxqzRceXTedW4fR4pqR5ttaHEIfQb9Nuug